use unminified jQuery textchange plugin
This commit is contained in:
parent
47412a39e7
commit
ea8f358a9a
5 changed files with 79 additions and 13 deletions
|
|
@ -3,6 +3,6 @@
|
||||||
* the COPYRIGHT file.
|
* the COPYRIGHT file.
|
||||||
*/
|
*/
|
||||||
//= require publisher
|
//= require publisher
|
||||||
//= require jquery.textchange.min
|
//= require jquery.textchange
|
||||||
//= require aspect-edit-pane
|
//= require aspect-edit-pane
|
||||||
//= require fileuploader-custom
|
//= require fileuploader-custom
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||||
-# licensed under the Affero General Public License version 3 or later. See
|
-# licensed under the Affero General Public License version 3 or later. See
|
||||||
-# the COPYRIGHT file.
|
-# the COPYRIGHT file.
|
||||||
= javascript_include_tag 'jquery.textchange.min.js', "publisher.js"
|
= javascript_include_tag 'jquery.textchange.js', "publisher.js"
|
||||||
|
|
||||||
:javascript
|
:javascript
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ module Diaspora
|
||||||
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
||||||
# Javascripts
|
# Javascripts
|
||||||
config.assets.precompile += [ "aspect-contacts.js", "contact-list.js", "finder.js",
|
config.assets.precompile += [ "aspect-contacts.js", "contact-list.js", "finder.js",
|
||||||
"home.js", "ie.js", "inbox.js", "jquery.js", "jquery_ujs.js", "jquery.textchange.min.js",
|
"home.js", "ie.js", "inbox.js", "jquery.js", "jquery_ujs.js", "jquery.textchange.js",
|
||||||
"login.js", "mailchimp.js", "main.js", "mobile.js", "profile.js", "people.js", "photos.js",
|
"login.js", "mailchimp.js", "main.js", "mobile.js", "profile.js", "people.js", "photos.js",
|
||||||
"profile.js", "publisher.js", "templates.js", "validation.js" ]
|
"profile.js", "publisher.js", "templates.js", "validation.js" ]
|
||||||
|
|
||||||
|
|
|
||||||
76
vendor/assets/javascripts/jquery.textchange.js
vendored
Normal file
76
vendor/assets/javascripts/jquery.textchange.js
vendored
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*!
|
||||||
|
* 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);
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
/*!
|
|
||||||
* jQuery TextChange Plugin
|
|
||||||
* http://www.zurb.com/playground/jquery-text-change-custom-event
|
|
||||||
*
|
|
||||||
* Copyright 2010, ZURB
|
|
||||||
* Released under the MIT License
|
|
||||||
*/
|
|
||||||
(function(a){a.event.special.textchange={setup:function(){a(this).data("lastValue",this.contentEditable==="true"?a(this).html():a(this).val());a(this).bind("keyup.textchange",a.event.special.textchange.handler);a(this).bind("cut.textchange paste.textchange input.textchange",a.event.special.textchange.delayedHandler)},teardown:function(){a(this).unbind(".textchange")},handler:function(){a.event.special.textchange.triggerIfChanged(a(this))},delayedHandler:function(){var c=a(this);setTimeout(function(){a.event.special.textchange.triggerIfChanged(c)},
|
|
||||||
25)},triggerIfChanged:function(a){var b=a[0].contentEditable==="true"?a.html():a.val();b!==a.data("lastValue")&&(a.trigger("textchange",[a.data("lastValue")]),a.data("lastValue",b))}};a.event.special.hastext={setup:function(){a(this).bind("textchange",a.event.special.hastext.handler)},teardown:function(){a(this).unbind("textchange",a.event.special.hastext.handler)},handler:function(c,b){b===""&&b!==a(this).val()&&a(this).trigger("hastext")}};a.event.special.notext={setup:function(){a(this).bind("textchange",
|
|
||||||
a.event.special.notext.handler)},teardown:function(){a(this).unbind("textchange",a.event.special.notext.handler)},handler:function(c,b){a(this).val()===""&&a(this).val()!==b&&a(this).trigger("notext")}}})(jQuery);
|
|
||||||
Loading…
Reference in a new issue