uri-js-rails 1.7.4 → 1.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +1 -1
- data/lib/uri-js-rails/version.rb +1 -1
- data/vendor/assets/javascripts/URI.js +455 -238
- data/vendor/assets/javascripts/jquery.URI.js +117 -87
- metadata +7 -9
@@ -2,7 +2,7 @@
|
|
2
2
|
* URI.js - Mutating URLs
|
3
3
|
* jQuery Plugin
|
4
4
|
*
|
5
|
-
* Version: 1.
|
5
|
+
* Version: 1.10.2
|
6
6
|
*
|
7
7
|
* Author: Rodney Rehm
|
8
8
|
* Web: http://medialize.github.com/URI.js/jquery-uri-plugin.html
|
@@ -13,11 +13,53 @@
|
|
13
13
|
*
|
14
14
|
*/
|
15
15
|
|
16
|
-
(function(
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
(function (root, factory) {
|
17
|
+
// https://github.com/umdjs/umd/blob/master/returnExports.js
|
18
|
+
if (typeof exports === 'object') {
|
19
|
+
// Node
|
20
|
+
module.exports = factory(require('jquery', './URI'));
|
21
|
+
} else if (typeof define === 'function' && define.amd) {
|
22
|
+
// AMD. Register as an anonymous module.
|
23
|
+
define(['jquery', './URI'], factory);
|
24
|
+
} else {
|
25
|
+
// Browser globals (root is window)
|
26
|
+
factory(root.jQuery, root.URI);
|
27
|
+
}
|
28
|
+
}(this, function ($, URI) {
|
29
|
+
"use strict";
|
30
|
+
|
31
|
+
var comparable = {};
|
32
|
+
var compare = {
|
33
|
+
// equals
|
34
|
+
'=': function(value, target) {
|
35
|
+
return value === target;
|
36
|
+
},
|
37
|
+
// ~= translates to value.match((?:^|\s)target(?:\s|$)) which is useless for URIs
|
38
|
+
// |= translates to value.match((?:\b)target(?:-|\s|$)) which is useless for URIs
|
39
|
+
// begins with
|
40
|
+
'^=': function(value, target, property) {
|
41
|
+
return !!(value + "").match(new RegExp('^' + escapeRegEx(target), 'i'));
|
42
|
+
},
|
43
|
+
// ends with
|
44
|
+
'$=': function(value, target, property) {
|
45
|
+
return !!(value + "").match(new RegExp(escapeRegEx(target) + '$', 'i'));
|
46
|
+
},
|
47
|
+
// contains
|
48
|
+
'*=': function(value, target, property) {
|
49
|
+
if (property == 'directory') {
|
50
|
+
// add trailing slash so /dir/ will match the deep-end as well
|
51
|
+
value += '/';
|
52
|
+
}
|
53
|
+
|
54
|
+
return !!(value + "").match(new RegExp(escapeRegEx(target), 'i'));
|
55
|
+
},
|
56
|
+
'equals:': function(uri, target) {
|
57
|
+
return uri.equals(target);
|
58
|
+
},
|
59
|
+
'is:': function(uri, target) {
|
60
|
+
return uri.is(target);
|
61
|
+
}
|
62
|
+
};
|
21
63
|
|
22
64
|
function escapeRegEx(string) {
|
23
65
|
// https://github.com/medialize/URI.js/commit/85ac21783c11f8ccab06106dba9735a31a86924d#commitcomment-821963
|
@@ -42,66 +84,55 @@ function getUriProperty(elem) {
|
|
42
84
|
return undefined;
|
43
85
|
}
|
44
86
|
|
87
|
+
if (!property) {
|
88
|
+
// you can set any property you wish. So for elements that don't have
|
89
|
+
// either of [src, href, action] we simply return src.
|
90
|
+
// https://github.com/medialize/URI.js/issues/69
|
91
|
+
return 'src';
|
92
|
+
}
|
93
|
+
|
45
94
|
return property;
|
46
95
|
}
|
47
96
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
// equals
|
53
|
-
'=': function(value, target) {
|
54
|
-
return value === target;
|
97
|
+
function generateAccessor(property) {
|
98
|
+
return {
|
99
|
+
get: function(elem) {
|
100
|
+
return $(elem).uri()[property]();
|
55
101
|
},
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
'^=': function(value, target, property) {
|
60
|
-
return !!(value + "").match(new RegExp('^' + escapeRegEx(target), 'i'));
|
61
|
-
},
|
62
|
-
// ends with
|
63
|
-
'$=': function(value, target, property) {
|
64
|
-
return !!(value + "").match(new RegExp(escapeRegEx(target) + '$', 'i'));
|
65
|
-
},
|
66
|
-
// contains
|
67
|
-
'*=': function(value, target, property) {
|
68
|
-
if (property == 'directory') {
|
69
|
-
// add trailing slash so /dir/ will match the deep-end as well
|
70
|
-
value += '/';
|
71
|
-
}
|
72
|
-
|
73
|
-
return !!(value + "").match(new RegExp(escapeRegEx(target), 'i'));
|
74
|
-
},
|
75
|
-
'equals:': function(uri, target) {
|
76
|
-
return uri.equals(target);
|
77
|
-
},
|
78
|
-
'is:': function(uri, target) {
|
79
|
-
return uri.is(target);
|
102
|
+
set: function(elem, value) {
|
103
|
+
$(elem).uri()[property](value);
|
104
|
+
return value;
|
80
105
|
}
|
81
|
-
},
|
82
|
-
generateAccessor = function(property) {
|
83
|
-
return {
|
84
|
-
get: function(elem) {
|
85
|
-
return $(elem).uri()[property]();
|
86
|
-
},
|
87
|
-
set: function(elem, value) {
|
88
|
-
$(elem).uri()[property](value);
|
89
|
-
return value;
|
90
|
-
}
|
91
|
-
};
|
92
106
|
};
|
107
|
+
};
|
93
108
|
|
94
109
|
// populate lookup table and register $.attr('uri:accessor') handlers
|
95
|
-
$.each('authority directory domain filename fragment hash host hostname href password path pathname port protocol query scheme search subdomain suffix tld username'.split(" "), function(k, v) {
|
110
|
+
$.each('authority directory domain filename fragment hash host hostname href password path pathname port protocol query resource scheme search subdomain suffix tld username'.split(" "), function(k, v) {
|
96
111
|
comparable[v] = true;
|
97
112
|
$.attrHooks['uri:' + v] = generateAccessor(v);
|
98
113
|
});
|
99
114
|
|
115
|
+
// pipe $.attr('src') and $.attr('href') through URI.js
|
116
|
+
var _attrHooks = {
|
117
|
+
get: function(elem) {
|
118
|
+
return $(elem).uri();
|
119
|
+
},
|
120
|
+
set: function(elem, value) {
|
121
|
+
return $(elem).uri().href(value).toString();
|
122
|
+
}
|
123
|
+
};
|
124
|
+
$.each(['src', 'href', 'action', 'uri'], function(k, v) {
|
125
|
+
$.attrHooks[v] = {
|
126
|
+
set: _attrHooks.set
|
127
|
+
};
|
128
|
+
});
|
129
|
+
$.attrHooks.uri.get = _attrHooks.get;
|
130
|
+
|
100
131
|
// general URI accessor
|
101
132
|
$.fn.uri = function(uri) {
|
102
|
-
var $this = this.first()
|
103
|
-
|
104
|
-
|
133
|
+
var $this = this.first();
|
134
|
+
var elem = $this.get(0);
|
135
|
+
var property = getUriProperty(elem);
|
105
136
|
|
106
137
|
if (!property) {
|
107
138
|
throw new Error('Element "' + elem.nodeName + '" does not have either property: href, src, action');
|
@@ -121,7 +152,7 @@ $.fn.uri = function(uri) {
|
|
121
152
|
if (uri) {
|
122
153
|
return uri;
|
123
154
|
} else {
|
124
|
-
|
155
|
+
uri = URI($this.attr(property));
|
125
156
|
}
|
126
157
|
}
|
127
158
|
|
@@ -150,22 +181,20 @@ URI.prototype.build = function(deferBuild) {
|
|
150
181
|
return this;
|
151
182
|
};
|
152
183
|
|
153
|
-
// :uri() pseudo
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
184
|
+
// add :uri() pseudo class selector to sizzle
|
185
|
+
var uriSizzle;
|
186
|
+
var pseudoArgs = /^([a-zA-Z]+)\s*([\^\$*]?=|:)\s*(['"]?)(.+)\3|^\s*([a-zA-Z0-9]+)\s*$/;
|
187
|
+
function uriPseudo (elem, text) {
|
188
|
+
var match, property, uri;
|
189
|
+
|
159
190
|
// skip anything without src|href|action and bad :uri() syntax
|
160
|
-
if (!getUriProperty(elem) || !
|
191
|
+
if (!getUriProperty(elem) || !text) {
|
161
192
|
return false;
|
162
193
|
}
|
163
194
|
|
164
|
-
|
165
|
-
property,
|
166
|
-
uri;
|
195
|
+
match = text.match(pseudoArgs);
|
167
196
|
|
168
|
-
if (!
|
197
|
+
if (!match || (!match[5] && match[2] !== ':' && !compare[match[2]])) {
|
169
198
|
// abort because the given selector cannot be executed
|
170
199
|
// filers seem to fail silently
|
171
200
|
return false;
|
@@ -173,44 +202,45 @@ $.expr.filters.uri = function(elem, index, matches) {
|
|
173
202
|
|
174
203
|
uri = $(elem).uri();
|
175
204
|
|
176
|
-
if (
|
177
|
-
return uri.is(
|
178
|
-
} else if (
|
179
|
-
property =
|
205
|
+
if (match[5]) {
|
206
|
+
return uri.is(match[5]);
|
207
|
+
} else if (match[2] === ':') {
|
208
|
+
property = match[1].toLowerCase() + ':';
|
180
209
|
if (!compare[property]) {
|
181
210
|
// filers seem to fail silently
|
182
211
|
return false;
|
183
212
|
}
|
184
213
|
|
185
|
-
return compare[property](uri,
|
214
|
+
return compare[property](uri, match[4]);
|
186
215
|
} else {
|
187
|
-
property =
|
216
|
+
property = match[1].toLowerCase();
|
188
217
|
if (!comparable[property]) {
|
189
218
|
// filers seem to fail silently
|
190
219
|
return false;
|
191
220
|
}
|
192
221
|
|
193
|
-
return compare[
|
222
|
+
return compare[match[2]](uri[property](), match[4], property);
|
194
223
|
}
|
195
224
|
|
196
225
|
return false;
|
197
|
-
}
|
226
|
+
}
|
198
227
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
return
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
set: _attrHooks.set
|
228
|
+
if ($.expr.createPseudo) {
|
229
|
+
// jQuery >= 1.8
|
230
|
+
uriSizzle = $.expr.createPseudo(function (text) {
|
231
|
+
return function (elem) {
|
232
|
+
return uriPseudo(elem, text);
|
233
|
+
};
|
234
|
+
});
|
235
|
+
} else {
|
236
|
+
// jQuery < 1.8
|
237
|
+
uriSizzle = function (elem, i, match) {
|
238
|
+
return uriPseudo(elem, match[3]);
|
211
239
|
};
|
212
|
-
}
|
213
|
-
$.attrHooks.uri.get = _attrHooks.get;
|
240
|
+
}
|
214
241
|
|
242
|
+
$.expr[":"].uri = uriSizzle;
|
215
243
|
|
216
|
-
|
244
|
+
// extending existing object rather than defining something new
|
245
|
+
return {};
|
246
|
+
}));
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uri-js-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.10.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Robin Wenglewski
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-05-16 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: ''
|
15
14
|
email:
|
@@ -31,27 +30,26 @@ files:
|
|
31
30
|
- vendor/assets/javascripts/jquery.URI.js
|
32
31
|
homepage: ''
|
33
32
|
licenses: []
|
33
|
+
metadata: {}
|
34
34
|
post_install_message:
|
35
35
|
rdoc_options: []
|
36
36
|
require_paths:
|
37
37
|
- lib
|
38
38
|
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
39
|
requirements:
|
41
|
-
- -
|
40
|
+
- - '>='
|
42
41
|
- !ruby/object:Gem::Version
|
43
42
|
version: '0'
|
44
43
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
-
none: false
|
46
44
|
requirements:
|
47
|
-
- -
|
45
|
+
- - '>='
|
48
46
|
- !ruby/object:Gem::Version
|
49
47
|
version: '0'
|
50
48
|
requirements: []
|
51
49
|
rubyforge_project:
|
52
|
-
rubygems_version:
|
50
|
+
rubygems_version: 2.0.3
|
53
51
|
signing_key:
|
54
|
-
specification_version:
|
52
|
+
specification_version: 4
|
55
53
|
summary: URI.js for rails
|
56
54
|
test_files: []
|
57
55
|
has_rdoc:
|