Skip to content

Commit

Permalink
Item13980: update jquery.queryObject
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Feb 23, 2016
1 parent 7d49f3b commit 2fc17d2
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 28 deletions.
2 changes: 1 addition & 1 deletion JQueryPlugin/data/System/JQueryQueryObject.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1265987465" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1456220586" format="1.1" version="1"}%
%META:TOPICPARENT{name="JQueryPlugin"}%
---+ %TOPIC%
%JQPLUGINS{"queryobject"
Expand Down
10 changes: 5 additions & 5 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/QUERYOBJECT.pm
Expand Up @@ -26,10 +26,10 @@ sub new {

my $this = bless(
$class->SUPER::new(
name => 'QueryObject',
version => '2.1.7',
author => 'Blair Mitchelmore',
homepage => 'http://plugins.jquery.com/project/query-object',
name => 'QueryObject',
version => '2.2.2',
author => 'Blair Mitchelmore',
homepage => 'https://github.com/alrusdi/jquery-plugin-query-object',
javascript => ['jquery.queryobject.js']
),
$class
Expand All @@ -42,7 +42,7 @@ sub new {
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2010-2015 Foswiki Contributors. Foswiki Contributors
Copyright (C) 2010-2016 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
15 changes: 12 additions & 3 deletions JQueryPlugin/pub/System/JQueryPlugin/plugins/queryobject/Makefile
@@ -1,5 +1,14 @@
TARGET=\
jquery.queryobject.js \
$(JQUERYPLUGIN_LIB)/QUERYOBJECT.pm
TARGET=jquery.queryobject.js

-include ../../Makefile.include

clean:
rm -f $(TARGET) *.gz

git:
git clone https://github.com/alrusdi/jquery-plugin-query-object.git $@

ifneq (,$(wildcard git))
jquery.queryobject.uncompressed.js: git/jquery.query-object.js
cat $^ > $@
endif
@@ -1,11 +1,11 @@
/**
/**
* jQuery.query - Query String Modification and Creation for jQuery
* Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
* Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
* Date: 2009/8/13
*
* @author Blair Mitchelmore
* @version 2.1.7
* @version 2.2.2
*
**/
new function(settings) {
Expand All @@ -16,7 +16,7 @@ new function(settings) {
var $prefix = settings.prefix === false ? false : true;
var $hash = $prefix ? settings.hash === true ? "#" : "?" : "";
var $numbers = settings.numbers === false ? false : true;

jQuery.query = new function() {
var is = function(o, t) {
return o != undefined && o !== null && (!!t ? o.constructor == t : true);
Expand Down Expand Up @@ -71,6 +71,16 @@ new function(settings) {
self.SET(key, val);
});
} else {
self.parseNew.apply(self, arguments);
}
return self;
};

queryObject.prototype = {
queryObject: true,
parseNew: function(){
var self = this;
self.keys = {};
jQuery.each(arguments, function() {
var q = "" + this;
q = q.replace(/^[?#]/,''); // remove any leading ? || #
Expand All @@ -86,24 +96,17 @@ new function(settings) {
if ($numbers) {
if (/^[+-]?[0-9]+\.[0-9]*$/.test(val)) // simple float regex
val = parseFloat(val);
else if (/^[+-]?[0-9]+$/.test(val)) // simple int regex
else if (/^[+-]?[1-9][0-9]*$/.test(val)) // simple int regex
val = parseInt(val, 10);
}

val = (!val && val !== 0) ? true : val;

if (val !== false && val !== true && typeof val != 'number')
val = val;

self.SET(key, val);
});
});
}
return self;
};

queryObject.prototype = {
queryObject: true,
return self;
},
has: function(key, type) {
var value = this.get(key);
return is(value, type);
Expand Down Expand Up @@ -135,11 +138,28 @@ new function(settings) {
set: function(key, val) {
return this.copy().SET(key, val);
},
REMOVE: function(key) {
REMOVE: function(key, val) {
if (val) {
var target = this.GET(key);
if (is(target, Array)) {
for (tval in target) {
target[tval] = target[tval].toString();
}
var index = $.inArray(val, target);
if (index >= 0) {
key = target.splice(index, 1);
key = key[index];
} else {
return;
}
} else if (val != target) {
return;
}
}
return this.SET(key, null).COMPACT();
},
remove: function(key) {
return this.copy().REMOVE(key);
remove: function(key, val) {
return this.copy().REMOVE(key, val);
},
EMPTY: function() {
var self = this;
Expand Down Expand Up @@ -186,8 +206,9 @@ new function(settings) {
var i = 0, queryString = [], chunks = [], self = this;
var encode = function(str) {
str = str + "";
if ($spaces) str = str.replace(/ /g, "+");
return encodeURIComponent(str);
str = encodeURIComponent(str);
if ($spaces) str = str.replace(/%20/g, "+");
return str;
};
var addFields = function(arr, key, value) {
if (!is(value) || value === false) return;
Expand Down Expand Up @@ -222,4 +243,3 @@ new function(settings) {
return new queryObject(location.search, location.hash);
};
}(jQuery.query || {}); // Pass in jQuery.query as settings object

0 comments on commit 2fc17d2

Please sign in to comment.