Skip to content

Commit

Permalink
Item14288: Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Dec 11, 2017
2 parents 805d981 + 180d5da commit ca6e25f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 23 deletions.
3 changes: 2 additions & 1 deletion JQueryPlugin/data/System/JQueryPlugin.txt
Expand Up @@ -129,7 +129,8 @@ required for Foswiki 1.1 or later.
Item14567: added keyboard navigation to jquery.stars <br /> \
Item14568: added chili recipes for autolisp and ini <br /> \
Item14569: deprecated jquery.placeholder <br /> \
Item14571: added manual sorting mode to textboxlist |
Item14571: added manual sorting mode to textboxlist <br /> \
Item14572: upgraded jquery.livequery |
| 11 Dec 2017: | (7.25) - Item14565: bundle jquery.validate js files into one <br /> \
Item14566: don't cache a null result in foswiki.getPreference() <br /> \
Item14570: add "use strict" to farbtastic's init and fix js errors |
Expand Down
2 changes: 1 addition & 1 deletion JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/LIVEQUERY.pm
Expand Up @@ -44,7 +44,7 @@ sub new {
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2010-2016 Foswiki Contributors. Foswiki Contributors
Copyright (C) 2010-2017 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
Expand Down
Expand Up @@ -3,3 +3,11 @@ TARGET=\
$(JQUERYPLUGIN_LIB)/LIVEQUERY.pm

-include ../../Makefile.include

git:
git clone https://github.com/hazzik/livequery.git $@

ifneq (,$(wildcard git))
jquery.livequery.uncompressed.js: git/dist/jquery.livequery.js
cat $^ > $@
endif
@@ -1,24 +1,34 @@
/*! Copyright
* (c) 2010, Brandon Aaron (http://brandonaaron.net)
* (c) 2012, Alexander Zaytsev (http://hazzik.ru/en)
* Dual licensed under the MIT (MIT_LICENSE.txt)
* and GPL Version 2 (GPL_LICENSE.txt) licenses.
*
* Version: 1.3.1
* Requires jQuery 1.3+
* Docs: http://docs.jquery.com/Plugins/livequery
*/

(function($) {
/*! jquery.livequery - v1.3.6 - 2016-12-09
* Copyright (c)
* (c) 2010, Brandon Aaron (http://brandonaaron.net)
* (c) 2012 - 2016, Alexander Zaytsev (https://alexzaytsev.me)
* Dual licensed under the MIT (MIT_LICENSE.txt)
* and GPL Version 2 (GPL_LICENSE.txt) licenses.
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else if (typeof exports === 'object') {
factory(require('jquery'));
} else {
factory(jQuery);
}
}(function ($, undefined) {

function _match(me, query, fn, fn2) {
return me.selector == query.selector &&
me.context == query.context &&
(!fn || fn.$lqguid == query.fn.$lqguid) &&
(!fn2 || fn2.$lqguid == query.fn2.$lqguid);
}

$.extend($.fn, {
livequery: function(fn, fn2) {
var me = this, q;

// See if Live Query already exists
$.each( $jQlq.queries, function(i, query) {
if ( me.selector == query.selector && me.context == query.context &&
(!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) )
if ( _match(me, query, fn, fn2) )
// Found the query, exit the each loop
return (q = query) && false;
});
Expand All @@ -41,8 +51,7 @@ $.extend($.fn, {

// Find the Live Query based on arguments and stop it
$.each( $jQlq.queries, function(i, query) {
if ( me.selector == query.selector && me.context == query.context &&
(!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) && !me.stopped )
if ( _match(me, query, fn, fn2) && !me.stopped)
$jQlq.stop(query.id);
});

Expand Down Expand Up @@ -117,6 +126,7 @@ $.extend($jQlq, {
queue: [],
running: false,
timeout: null,
registered: [],

checkQueue: function() {
if ( $jQlq.running && $jQlq.queue.length ) {
Expand All @@ -142,7 +152,7 @@ $.extend($jQlq, {
registerPlugin: function() {
$.each( arguments, function(i,n) {
// Short-circuit if the method doesn't exist
if (!$.fn[n]) return;
if (!$.fn[n] || $.inArray(n, $jQlq.registered) > 0) return;

// Save a reference to the original method
var old = $.fn[n];
Expand All @@ -157,12 +167,14 @@ $.extend($jQlq, {

// Return the original methods result
return r;
}
};

$jQlq.registered.push(n);
});
},

run: function(id) {
if (id != undefined) {
if (id !== undefined) {
// Put the particular Live Query in the queue if it doesn't already exist
if ( $.inArray(id, $jQlq.queue) < 0 )
$jQlq.queue.push( id );
Expand All @@ -181,7 +193,7 @@ $.extend($jQlq, {
},

stop: function(id) {
if (id != undefined)
if (id !== undefined)
// Stop are particular Live Query
$jQlq.queries[ id ].stop();
else
Expand All @@ -196,4 +208,4 @@ $jQlq.registerPlugin('append', 'prepend', 'after', 'before', 'wrap', 'attr', 're
// Run Live Queries when the Document is ready
$(function() { $jQlq.play(); });

})(jQuery);
}));

0 comments on commit ca6e25f

Please sign in to comment.