Nuevo plugin Additionals 2.0.20

This commit is contained in:
Manuel Cillero 2019-06-16 12:53:09 +02:00
parent a2a901b71b
commit 93e1e28683
354 changed files with 40514 additions and 0 deletions

View file

@ -0,0 +1,52 @@
// see https://github.com/splendeo/jquery.observe_field
(function($) {
'use strict';
$.fn.live_observe_field = function(frequency, callback) {
frequency = frequency * 100; // translate to milliseconds
return this.each(function() {
var $this = $(this);
var prev = $this.val();
var prevChecked = $this.prop('checked');
var check = function() {
if (removed()) {
// if removed clear the interval and don't fire the callback
if (ti)
clearInterval(ti);
return;
}
var val = $this.val();
var checked = $this.prop('checked');
if (prev != val || checked != prevChecked) {
prev = val;
prevChecked = checked;
$this.map(callback); // invokes the callback on $this
}
};
var removed = function() {
return $this.closest('html').length == 0;
};
var reset = function() {
if (ti) {
clearInterval(ti);
ti = setInterval(check, frequency);
}
};
check();
var ti = setInterval(check, frequency); // invoke check periodically
// reset counter after user interaction
$this.bind('keyup click mousemove', reset); // mousemove is for selects
});
};
})(jQuery);