Commit d7e8e2ce authored by Sandip Trivedi's avatar Sandip Trivedi
Browse files

Replaced jquery.textchange.js vendored asset with a bower package #5194

parent 4f87a47d
......@@ -86,6 +86,7 @@ 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'
# Localization
......
......@@ -357,6 +357,8 @@ GEM
railties (= 4.1.6)
sprockets-rails (~> 2.0)
rails-assets-jquery (1.11.1)
rails-assets-jquery-textchange (0.2.3)
rails-assets-jquery
rails-assets-perfect-scrollbar (0.4.11)
rails-assets-jquery (>= 1.10)
rails-assets-punycode (1.3.1)
......@@ -574,6 +576,7 @@ DEPENDENCIES
rack-ssl (= 1.4.1)
rails (= 4.1.6)
rails-assets-jquery (= 1.11.1)
rails-assets-jquery-textchange (= 0.2.3)
rails-assets-perfect-scrollbar (= 0.4.11)
rails-assets-punycode (= 1.3.1)
rails-i18n (= 4.0.3)
......
......@@ -8,7 +8,7 @@
//= require ./publisher/aspect_selector_blueprint_view
//= require ./publisher/getting_started_view
//= require ./publisher/uploader_view
//= require jquery.textchange
//= require jquery-textchange
app.views.Publisher = Backbone.View.extend({
......
......@@ -57,7 +57,7 @@ module Diaspora
inbox.js
jquery.js
jquery_ujs.js
jquery.textchange.js
jquery-textchange.js
mailchimp.js
main.js
mobile.js
......
/*!
* jQuery TextChange Plugin
* http://www.zurb.com/playground/jquery-text-change-custom-event
*
* Copyright 2010, ZURB
* Released under the MIT License
*/
(function ($) {
$.event.special.textchange = {
setup: function (data, namespaces) {
$(this).data('lastValue', this.contentEditable === 'true' ? $(this).html() : $(this).val());
$(this).bind('keyup.textchange', $.event.special.textchange.handler);
$(this).bind('cut.textchange paste.textchange input.textchange', $.event.special.textchange.delayedHandler);
},
teardown: function (namespaces) {
$(this).unbind('.textchange');
},
handler: function (event) {
$.event.special.textchange.triggerIfChanged($(this));
},
delayedHandler: function (event) {
var element = $(this);
setTimeout(function () {
$.event.special.textchange.triggerIfChanged(element);
}, 25);
},
triggerIfChanged: function (element) {
var current = element[0].contentEditable === 'true' ? element.html() : element.val();
if (current !== element.data('lastValue')) {
element.trigger('textchange', [element.data('lastValue')]);
element.data('lastValue', current);
}
}
};
$.event.special.hastext = {
setup: function (data, namespaces) {
$(this).bind('textchange', $.event.special.hastext.handler);
},
teardown: function (namespaces) {
$(this).unbind('textchange', $.event.special.hastext.handler);
},
handler: function (event, lastValue) {
if ((lastValue === '') && lastValue !== $(this).val()) {
$(this).trigger('hastext');
}
}
};
$.event.special.notext = {
setup: function (data, namespaces) {
$(this).bind('textchange', $.event.special.notext.handler);
},
teardown: function (namespaces) {
$(this).unbind('textchange', $.event.special.notext.handler);
},
handler: function (event, lastValue) {
if ($(this).val() === '' && $(this).val() !== lastValue) {
$(this).trigger('notext');
}
}
};
})(jQuery);
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment