diff options
-rw-r--r-- | Gemfile | 5 | ||||
-rw-r--r-- | Gemfile.lock | 2 | ||||
-rw-r--r-- | app/assets/javascripts/main.js | 2 | ||||
-rw-r--r-- | vendor/assets/javascripts/jquery.placeholder.js | 104 |
4 files changed, 6 insertions, 107 deletions
@@ -86,8 +86,9 @@ gem 'rails-assets-punycode', '1.3.1' # jQuery plugins -gem 'rails-assets-jquery-textchange', '0.2.3' -gem 'rails-assets-perfect-scrollbar', '0.4.11' +gem 'rails-assets-jquery-placeholder', '1.8.7' +gem 'rails-assets-jquery-textchange', '0.2.3' +gem 'rails-assets-perfect-scrollbar', '0.4.11' # Localization diff --git a/Gemfile.lock b/Gemfile.lock index b26e349bd..7dd5e88e2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -357,6 +357,7 @@ GEM railties (= 4.1.6) sprockets-rails (~> 2.0) rails-assets-jquery (1.11.1) + rails-assets-jquery-placeholder (1.8.7) rails-assets-jquery-textchange (0.2.3) rails-assets-jquery rails-assets-perfect-scrollbar (0.4.11) @@ -576,6 +577,7 @@ DEPENDENCIES rack-ssl (= 1.4.1) rails (= 4.1.6) rails-assets-jquery (= 1.11.1) + rails-assets-jquery-placeholder (= 1.8.7) rails-assets-jquery-textchange (= 0.2.3) rails-assets-perfect-scrollbar (= 0.4.11) rails-assets-punycode (= 1.3.1) diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js index a0d61d8bd..b0ae002b8 100644 --- a/app/assets/javascripts/main.js +++ b/app/assets/javascripts/main.js @@ -10,7 +10,7 @@ //= require jquery.remotipart //= require jquery.autoresize //= require jquery.charcount -//= require jquery.placeholder +//= require jquery-placeholder //= require rails-timeago //= require facebox //= require browser_detection diff --git a/vendor/assets/javascripts/jquery.placeholder.js b/vendor/assets/javascripts/jquery.placeholder.js deleted file mode 100644 index b4bbc7cbe..000000000 --- a/vendor/assets/javascripts/jquery.placeholder.js +++ /dev/null @@ -1,104 +0,0 @@ -/*! http://mths.be/placeholder v1.8.7 by @mathias */ -;(function(window, document, $) { - - var isInputSupported = 'placeholder' in document.createElement('input'), - isTextareaSupported = 'placeholder' in document.createElement('textarea'), - prototype = $.fn, - placeholder; - - if (isInputSupported && isTextareaSupported) { - - placeholder = prototype.placeholder = function() { - return this; - }; - - placeholder.input = placeholder.textarea = true; - - } else { - - placeholder = prototype.placeholder = function() { - return this - .filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]') - .not('.placeholder') - .bind('focus.placeholder', clearPlaceholder) - .bind('blur.placeholder', setPlaceholder) - .trigger('blur.placeholder').end(); - }; - - placeholder.input = isInputSupported; - placeholder.textarea = isTextareaSupported; - - $(function() { - // Look for forms - $(document).delegate('form', 'submit.placeholder', function() { - // Clear the placeholder values so they don’t get submitted - var $inputs = $('.placeholder', this).each(clearPlaceholder); - setTimeout(function() { - $inputs.each(setPlaceholder); - }, 10); - }); - }); - - // Clear placeholder values upon page reload - $(window).bind('unload.placeholder', function() { - $('.placeholder').val(''); - }); - - } - - function args(elem) { - // Return an object of element attributes - var newAttrs = {}, - rinlinejQuery = /^jQuery\d+$/; - $.each(elem.attributes, function(i, attr) { - if (attr.specified && !rinlinejQuery.test(attr.name)) { - newAttrs[attr.name] = attr.value; - } - }); - return newAttrs; - } - - function clearPlaceholder() { - var $input = $(this); - if ($input.val() === $input.attr('placeholder') && $input.hasClass('placeholder')) { - if ($input.data('placeholder-password')) { - $input.hide().next().show().focus().attr('id', $input.removeAttr('id').data('placeholder-id')); - } else { - $input.val('').removeClass('placeholder'); - } - } - } - - function setPlaceholder() { - var $replacement, - $input = $(this), - $origInput = $input, - id = this.id; - if ($input.val() === '') { - if ($input.is(':password')) { - if (!$input.data('placeholder-textinput')) { - try { - $replacement = $input.clone().attr({ 'type': 'text' }); - } catch(e) { - $replacement = $('<input>').attr($.extend(args(this), { 'type': 'text' })); - } - $replacement - .removeAttr('name') - // We could just use the `.data(obj)` syntax here, but that wouldn’t work in pre-1.4.3 jQueries - .data('placeholder-password', true) - .data('placeholder-id', id) - .bind('focus.placeholder', clearPlaceholder); - $input - .data('placeholder-textinput', $replacement) - .data('placeholder-id', id) - .before($replacement); - } - $input = $input.removeAttr('id').hide().prev().attr('id', id).show(); - } - $input.addClass('placeholder').val($input.attr('placeholder')); - } else { - $input.removeClass('placeholder'); - } - } - -}(this, document, jQuery));
\ No newline at end of file |