js_routes 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
|
|
2
2
|
var __slice = Array.prototype.slice;
|
3
3
|
$.buildPath = function() {
|
4
4
|
var extraParams, lastParam, params, paramsHash, path;
|
5
|
-
path = arguments[0],
|
5
|
+
path = arguments[0],params = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
6
6
|
extraParams = {};
|
7
7
|
paramsHash = {};
|
8
8
|
if ($.isPlainObject(lastParam = params.pop())) {
|
@@ -29,7 +29,12 @@
|
|
29
29
|
}
|
30
30
|
});
|
31
31
|
path = path.replace(/\(.*\)/, '');
|
32
|
+
if (!$.isEmptyObject(extraParams) && extraParams.anchor) {
|
33
|
+
path += "#" + extraParams.anchor;
|
34
|
+
delete extraParams['anchor'];
|
35
|
+
}
|
32
36
|
if (!$.isEmptyObject(extraParams)) {
|
37
|
+
|
33
38
|
path += "?" + ($.param(extraParams));
|
34
39
|
}
|
35
40
|
return path;
|
data/lib/js_routes/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js_routes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-09-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &13668440 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.0.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *13668440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rails
|
27
|
-
requirement: &
|
27
|
+
requirement: &13667920 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '3.0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *13667920
|
36
36
|
description: ''
|
37
37
|
email:
|
38
38
|
- st8998@gmail.com
|
@@ -45,7 +45,6 @@ files:
|
|
45
45
|
- Rakefile
|
46
46
|
- js_routes.gemspec
|
47
47
|
- lib/assets/javascripts/jquery.pathBuilder.js
|
48
|
-
- lib/assets/javascripts/jquery.pathBuilder.js.coffee
|
49
48
|
- lib/assets/javascripts/routes.js.erb
|
50
49
|
- lib/generators/js_routes/install/install_generator.rb
|
51
50
|
- lib/js_routes.rb
|
@@ -1,30 +0,0 @@
|
|
1
|
-
$.buildPath = (path, params...) ->
|
2
|
-
extraParams = {}
|
3
|
-
paramsHash = {}
|
4
|
-
|
5
|
-
if $.isPlainObject(lastParam = params.pop()) then paramsHash = lastParam
|
6
|
-
else params.push(lastParam)
|
7
|
-
|
8
|
-
$.each params, (_, value) ->
|
9
|
-
replacement = "/#{value}"
|
10
|
-
path = path.replace /\/:[\w_]+/, replacement
|
11
|
-
|
12
|
-
# try to insert parameters
|
13
|
-
$.each paramsHash, (name, value) ->
|
14
|
-
if path.match(new RegExp(":#{name}"))
|
15
|
-
pattern = "(.*?)\\(([\\.\\/\\w]*?):#{name}(\\(.*?\\)|[^\\)]*)?\\)(.*)"
|
16
|
-
replacement = "$1$2#{value}$3$4"
|
17
|
-
path = path.replace new RegExp(pattern), replacement
|
18
|
-
|
19
|
-
pattern = "(.*?):#{name}(.*)"
|
20
|
-
replacement = "$1#{value}$2"
|
21
|
-
path = path.replace new RegExp(pattern), replacement
|
22
|
-
else extraParams[name] = value
|
23
|
-
|
24
|
-
# cleanup
|
25
|
-
path = path.replace(/\(.*\)/, '')
|
26
|
-
|
27
|
-
# add extra params
|
28
|
-
path += "?#{$.param(extraParams)}" unless $.isEmptyObject(extraParams)
|
29
|
-
|
30
|
-
return path
|