joosy 1.0.0.RC7 → 1.1.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +19 -54
- data/app/assets/javascripts/joosy/core/form.js.coffee +8 -7
- data/app/assets/javascripts/joosy/core/layout.js.coffee +3 -3
- data/app/assets/javascripts/joosy/core/modules/events.js.coffee +1 -1
- data/app/assets/javascripts/joosy/core/modules/module.js.coffee +2 -4
- data/app/assets/javascripts/joosy/core/page.js.coffee +3 -3
- data/app/assets/javascripts/joosy/core/router.js.coffee +106 -2
- data/app/assets/javascripts/joosy.js.coffee +0 -1
- data/joosy.gemspec +4 -6
- data/lib/joosy/rails/engine.rb +4 -0
- data/lib/joosy/version.rb +3 -0
- data/lib/joosy.rb +11 -10
- data/spec/javascripts/joosy/core/router_spec.js.coffee +92 -1
- data/vendor/assets/javascripts/jquery.hashchange.js +1 -1
- data/vendor/assets/javascripts/sugar.js +6968 -5062
- metadata +20 -42
- data/lib/joosy/rails/version.rb +0 -5
data/Gemfile.lock
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
GIT
|
2
2
|
remote: git://github.com/pivotal/jasmine-gem.git
|
3
|
-
revision:
|
3
|
+
revision: ff6fa02f3083b8f9423ddf0cdee5b41ff6d18de1
|
4
4
|
specs:
|
5
5
|
jasmine (1.3.2)
|
6
6
|
jasmine-core (~> 1.3.1)
|
@@ -11,19 +11,14 @@ GIT
|
|
11
11
|
PATH
|
12
12
|
remote: .
|
13
13
|
specs:
|
14
|
-
joosy (1.
|
15
|
-
coffee-rails
|
14
|
+
joosy (1.1.0.alpha.1)
|
16
15
|
haml_coffee_assets
|
17
16
|
i18n-js
|
18
|
-
|
19
|
-
rails (>= 3.1.0)
|
17
|
+
sprockets
|
20
18
|
|
21
19
|
GEM
|
22
20
|
remote: http://rubygems.org/
|
23
21
|
specs:
|
24
|
-
actionmailer (3.2.11)
|
25
|
-
actionpack (= 3.2.11)
|
26
|
-
mail (~> 2.4.4)
|
27
22
|
actionpack (3.2.11)
|
28
23
|
activemodel (= 3.2.11)
|
29
24
|
activesupport (= 3.2.11)
|
@@ -37,26 +32,13 @@ GEM
|
|
37
32
|
activemodel (3.2.11)
|
38
33
|
activesupport (= 3.2.11)
|
39
34
|
builder (~> 3.0.0)
|
40
|
-
activerecord (3.2.11)
|
41
|
-
activemodel (= 3.2.11)
|
42
|
-
activesupport (= 3.2.11)
|
43
|
-
arel (~> 3.0.2)
|
44
|
-
tzinfo (~> 0.3.29)
|
45
|
-
activeresource (3.2.11)
|
46
|
-
activemodel (= 3.2.11)
|
47
|
-
activesupport (= 3.2.11)
|
48
35
|
activesupport (3.2.11)
|
49
36
|
i18n (~> 0.6)
|
50
37
|
multi_json (~> 1.0)
|
51
|
-
addressable (2.3.2)
|
52
|
-
arel (3.0.2)
|
53
38
|
builder (3.0.4)
|
54
|
-
childprocess (0.3.
|
39
|
+
childprocess (0.3.7)
|
55
40
|
ffi (~> 1.0, >= 1.0.6)
|
56
41
|
coderay (1.0.8)
|
57
|
-
coffee-rails (3.2.2)
|
58
|
-
coffee-script (>= 2.2.0)
|
59
|
-
railties (~> 3.2.0)
|
60
42
|
coffee-script (2.2.0)
|
61
43
|
coffee-script-source
|
62
44
|
execjs
|
@@ -70,18 +52,20 @@ GEM
|
|
70
52
|
multi_json (~> 1.0)
|
71
53
|
ffi (1.3.1)
|
72
54
|
ffi (1.3.1-java)
|
73
|
-
guard (1.6.
|
55
|
+
guard (1.6.2)
|
74
56
|
listen (>= 0.6.0)
|
75
57
|
lumberjack (>= 1.0.2)
|
76
58
|
pry (>= 0.9.10)
|
59
|
+
terminal-table (>= 1.4.3)
|
77
60
|
thor (>= 0.14.6)
|
78
61
|
guard-coffeescript (1.2.1)
|
79
62
|
coffee-script (>= 2.2.0)
|
80
63
|
guard (>= 1.1.0)
|
81
|
-
guard-sprockets (0.4.
|
64
|
+
guard-sprockets (0.4.2)
|
65
|
+
execjs (~> 1.0)
|
82
66
|
guard (>= 1.1.0)
|
83
67
|
sprockets (~> 2.0)
|
84
|
-
haml_coffee_assets (1.
|
68
|
+
haml_coffee_assets (1.11.1)
|
85
69
|
coffee-script (>= 1.0.0)
|
86
70
|
sprockets (>= 2.0.3)
|
87
71
|
tilt (>= 1.3.3)
|
@@ -91,31 +75,22 @@ GEM
|
|
91
75
|
i18n
|
92
76
|
jasmine-core (1.3.1)
|
93
77
|
journey (1.0.4)
|
94
|
-
jquery-rails (2.
|
78
|
+
jquery-rails (2.2.0)
|
95
79
|
railties (>= 3.0, < 5.0)
|
96
80
|
thor (>= 0.14, < 2.0)
|
97
81
|
json (1.7.6)
|
98
82
|
json (1.7.6-java)
|
99
83
|
libnotify (0.8.0)
|
100
84
|
ffi (>= 1.0.11)
|
101
|
-
libwebsocket (0.1.7.1)
|
102
|
-
addressable
|
103
|
-
websocket
|
104
85
|
listen (0.7.2)
|
105
86
|
lumberjack (1.0.2)
|
106
|
-
mail (2.4.4)
|
107
|
-
i18n (>= 0.4.0)
|
108
|
-
mime-types (~> 1.16)
|
109
|
-
treetop (~> 1.4.8)
|
110
87
|
method_source (0.8.1)
|
111
|
-
mime-types (1.19)
|
112
88
|
multi_json (1.5.0)
|
113
|
-
|
114
|
-
pry (0.9.11.3)
|
89
|
+
pry (0.9.11.4)
|
115
90
|
coderay (~> 1.0.5)
|
116
91
|
method_source (~> 0.8)
|
117
92
|
slop (~> 3.4)
|
118
|
-
pry (0.9.11.
|
93
|
+
pry (0.9.11.4-java)
|
119
94
|
coderay (~> 1.0.5)
|
120
95
|
method_source (~> 0.8)
|
121
96
|
slop (~> 3.4)
|
@@ -127,14 +102,6 @@ GEM
|
|
127
102
|
rack
|
128
103
|
rack-test (0.6.2)
|
129
104
|
rack (>= 1.0)
|
130
|
-
rails (3.2.11)
|
131
|
-
actionmailer (= 3.2.11)
|
132
|
-
actionpack (= 3.2.11)
|
133
|
-
activerecord (= 3.2.11)
|
134
|
-
activeresource (= 3.2.11)
|
135
|
-
activesupport (= 3.2.11)
|
136
|
-
bundler (~> 1.0)
|
137
|
-
railties (= 3.2.11)
|
138
105
|
railties (3.2.11)
|
139
106
|
actionpack (= 3.2.11)
|
140
107
|
activesupport (= 3.2.11)
|
@@ -154,13 +121,13 @@ GEM
|
|
154
121
|
rspec-core (2.12.2)
|
155
122
|
rspec-expectations (2.12.1)
|
156
123
|
diff-lcs (~> 1.1.3)
|
157
|
-
rspec-mocks (2.12.
|
124
|
+
rspec-mocks (2.12.2)
|
158
125
|
rubyzip (0.9.9)
|
159
|
-
selenium-webdriver (2.
|
126
|
+
selenium-webdriver (2.29.0)
|
160
127
|
childprocess (>= 0.2.5)
|
161
|
-
libwebsocket (~> 0.1.3)
|
162
128
|
multi_json (~> 1.0)
|
163
129
|
rubyzip
|
130
|
+
websocket (~> 1.0.4)
|
164
131
|
slop (3.4.3)
|
165
132
|
spoon (0.0.1)
|
166
133
|
sprockets (2.2.2)
|
@@ -168,17 +135,14 @@ GEM
|
|
168
135
|
multi_json (~> 1.0)
|
169
136
|
rack (~> 1.0)
|
170
137
|
tilt (~> 1.1, != 1.3.0)
|
138
|
+
terminal-table (1.4.5)
|
171
139
|
thin (1.5.0)
|
172
140
|
daemons (>= 1.0.9)
|
173
141
|
eventmachine (>= 0.12.6)
|
174
142
|
rack (>= 1.0.0)
|
175
|
-
thor (0.
|
143
|
+
thor (0.17.0)
|
176
144
|
tilt (1.3.3)
|
177
|
-
|
178
|
-
polyglot
|
179
|
-
polyglot (>= 0.3.1)
|
180
|
-
tzinfo (0.3.35)
|
181
|
-
websocket (1.0.6)
|
145
|
+
websocket (1.0.7)
|
182
146
|
|
183
147
|
PLATFORMS
|
184
148
|
java
|
@@ -190,6 +154,7 @@ DEPENDENCIES
|
|
190
154
|
guard-sprockets
|
191
155
|
jasmine!
|
192
156
|
joosy!
|
157
|
+
jquery-rails
|
193
158
|
libnotify
|
194
159
|
rb-inotify
|
195
160
|
thin
|
@@ -26,9 +26,9 @@
|
|
26
26
|
# @include Joosy.Modules.Container
|
27
27
|
#
|
28
28
|
class Joosy.Form extends Joosy.Module
|
29
|
+
@include Joosy.Modules.Container
|
29
30
|
@include Joosy.Modules.Log
|
30
31
|
@include Joosy.Modules.Events
|
31
|
-
@include Joosy.Modules.Container
|
32
32
|
|
33
33
|
#
|
34
34
|
# Marks the CSS class to use to mark invalidated fields
|
@@ -114,7 +114,7 @@ class Joosy.Form extends Joosy.Module
|
|
114
114
|
@__delegateEvents()
|
115
115
|
|
116
116
|
method = @container.get(0).getAttribute('method')?.toLowerCase()
|
117
|
-
if method && !['get', 'post'].
|
117
|
+
if method && !['get', 'post'].any method
|
118
118
|
@__markMethod method
|
119
119
|
@container.attr 'method', 'POST'
|
120
120
|
|
@@ -196,13 +196,14 @@ class Joosy.Form extends Joosy.Module
|
|
196
196
|
input.filter("[value='#{val}']").attr 'checked', 'checked'
|
197
197
|
else
|
198
198
|
input.val val
|
199
|
-
if
|
200
|
-
filler val, key
|
201
|
-
else if val instanceof Joosy.Resource.REST
|
202
|
-
filler val.data, @concatFieldName(scope, "[#{property}_attributes][0]")
|
203
|
-
else if val instanceof Joosy.Resource.RESTCollection
|
199
|
+
if val instanceof Joosy.Resource.RESTCollection
|
204
200
|
for entity, i in val.data
|
205
201
|
filler entity.data, @concatFieldName(scope, "[#{property}_attributes][#{i}]")
|
202
|
+
else if val instanceof Joosy.Resource.REST
|
203
|
+
filler val.data, @concatFieldName(scope, "[#{property}_attributes][0]")
|
204
|
+
else if Object.isObject(val) || Object.isArray(val)
|
205
|
+
filler val, key
|
206
|
+
else
|
206
207
|
delete data.__joosy_form_filler_lock
|
207
208
|
|
208
209
|
filler data, resource.__entityName || options.resourceName
|
@@ -45,7 +45,7 @@ class Joosy.Layout extends Joosy.Module
|
|
45
45
|
# preparations are done you should call that function.
|
46
46
|
#
|
47
47
|
# @example Sample before painter
|
48
|
-
# @beforePaint (complete) ->
|
48
|
+
# @beforePaint (container, page, complete) ->
|
49
49
|
# if !@data # checks if parallel fetching finished
|
50
50
|
# $('preloader').slideDown -> complete()
|
51
51
|
#
|
@@ -63,7 +63,7 @@ class Joosy.Layout extends Joosy.Module
|
|
63
63
|
# preparations are done you should call that function.
|
64
64
|
#
|
65
65
|
# @example Sample painter
|
66
|
-
# @paint (complete) ->
|
66
|
+
# @paint (container, page, complete) ->
|
67
67
|
# @container.fadeIn -> complete()
|
68
68
|
#
|
69
69
|
@paint: (callback) ->
|
@@ -81,7 +81,7 @@ class Joosy.Layout extends Joosy.Module
|
|
81
81
|
# access layout data from that. Think twice if you are doing it right though.
|
82
82
|
#
|
83
83
|
# @example Sample eraser
|
84
|
-
# @erase (complete) ->
|
84
|
+
# @erase (container, page, complete) ->
|
85
85
|
# @container.fadeOut -> complete()
|
86
86
|
#
|
87
87
|
@erase: (callback) ->
|
@@ -1,5 +1,3 @@
|
|
1
|
-
moduleKeywords = ['included', 'extended']
|
2
|
-
|
3
1
|
#
|
4
2
|
# Base Joosy class extending Coffee class with module-like injections
|
5
3
|
# and other tiny stuff.
|
@@ -95,8 +93,8 @@ class Joosy.Module
|
|
95
93
|
unless object
|
96
94
|
throw new Error 'include(object) requires obj'
|
97
95
|
|
98
|
-
|
99
|
-
if key
|
96
|
+
for key, value of object
|
97
|
+
if key != 'included' && key != 'extended'
|
100
98
|
this::[key] = value
|
101
99
|
|
102
100
|
object.included?.apply this
|
@@ -74,7 +74,7 @@ class Joosy.Page extends Joosy.Module
|
|
74
74
|
# preparations are done you should call that function.
|
75
75
|
#
|
76
76
|
# @example Sample before painter
|
77
|
-
# @beforePaint (complete) ->
|
77
|
+
# @beforePaint (container, complete) ->
|
78
78
|
# if !@data # checks if parallel fetching finished
|
79
79
|
# $('preloader').slideDown -> complete()
|
80
80
|
#
|
@@ -92,7 +92,7 @@ class Joosy.Page extends Joosy.Module
|
|
92
92
|
# preparations are done you should call that function.
|
93
93
|
#
|
94
94
|
# @example Sample painter
|
95
|
-
# @paint (complete) ->
|
95
|
+
# @paint (container, complete) ->
|
96
96
|
# @container.fadeIn -> complete()
|
97
97
|
#
|
98
98
|
@paint: (callback) ->
|
@@ -113,7 +113,7 @@ class Joosy.Page extends Joosy.Module
|
|
113
113
|
# access page data from that. Think twice if you are doing it right though.
|
114
114
|
#
|
115
115
|
# @example Sample eraser
|
116
|
-
# @erase (complete) ->
|
116
|
+
# @erase (container, complete) ->
|
117
117
|
# @container.fadeOut -> complete()
|
118
118
|
#
|
119
119
|
@erase: (callback) ->
|
@@ -26,13 +26,19 @@ Joosy.Router =
|
|
26
26
|
# need) and actual executors
|
27
27
|
#
|
28
28
|
routes: Object.extended()
|
29
|
-
|
29
|
+
|
30
30
|
#
|
31
31
|
# The regexp to restrict the next loading url. By default set to false and
|
32
32
|
# therefore no restrictions apply.
|
33
33
|
#
|
34
34
|
restrictPattern: false
|
35
|
-
|
35
|
+
|
36
|
+
#
|
37
|
+
# TODO: Write readme
|
38
|
+
#
|
39
|
+
__namespace: ""
|
40
|
+
__asNamespace: ""
|
41
|
+
|
36
42
|
#
|
37
43
|
# Set the restriction pattern. If the requested url does not match this it
|
38
44
|
# will not load. Set `false` to avoid check.
|
@@ -45,6 +51,17 @@ Joosy.Router =
|
|
45
51
|
reset: ->
|
46
52
|
@rawRoutes = Object.extended()
|
47
53
|
@routes = Object.extended()
|
54
|
+
@__namespace = ""
|
55
|
+
@__asNamespace = ""
|
56
|
+
|
57
|
+
|
58
|
+
#
|
59
|
+
# Draws the routes similar to Ruby on Rails
|
60
|
+
#
|
61
|
+
# @param [Function] block callback for child commands
|
62
|
+
#
|
63
|
+
draw: (block)->
|
64
|
+
block.call(this) if Object.isFunction(block)
|
48
65
|
|
49
66
|
#
|
50
67
|
# Registers the set of raw routes
|
@@ -78,7 +95,68 @@ Joosy.Router =
|
|
78
95
|
, 2 # jQuery.hashchange checks hash changing every 1ms
|
79
96
|
else
|
80
97
|
history[if options.replaceState then 'replaceState' else 'pushState'] {}, '', '#'+path
|
98
|
+
|
99
|
+
#
|
100
|
+
# Match route (ads it to @rawRoutes)
|
101
|
+
#
|
102
|
+
# @param [String] route similar to ones sent in map hash
|
103
|
+
#
|
104
|
+
# @param options [String] to function to which the route routes
|
105
|
+
# @option options [String] as name of the route, used for reverse routing
|
106
|
+
#
|
107
|
+
match: (route, options={}) ->
|
108
|
+
if @__asNamespace
|
109
|
+
as = @__asNamespace + options["as"].capitalize()
|
110
|
+
else
|
111
|
+
as = options["as"]
|
112
|
+
|
113
|
+
routeName = @__namespace + route
|
81
114
|
|
115
|
+
map = {}
|
116
|
+
map[route] = options["to"]
|
117
|
+
|
118
|
+
Joosy.Module.merge @rawRoutes, map
|
119
|
+
|
120
|
+
@__injectReverseUrl(as, routeName)
|
121
|
+
|
122
|
+
#
|
123
|
+
# Shortcut to match "/"
|
124
|
+
#
|
125
|
+
# @param options [String] to function to which the route routes
|
126
|
+
# @option options [String] as name of the route, used for reverse routing
|
127
|
+
# default it is "root"
|
128
|
+
#
|
129
|
+
root: (options={}) ->
|
130
|
+
as = options["as"] || "root"
|
131
|
+
@match("/", to: options["to"], as: as)
|
132
|
+
|
133
|
+
#
|
134
|
+
# Routes the 404
|
135
|
+
#
|
136
|
+
# @param options [String] to function to which the route routes
|
137
|
+
#
|
138
|
+
notFound: (options={}) ->
|
139
|
+
@match(404, to: options["to"])
|
140
|
+
|
141
|
+
#
|
142
|
+
# Namespaces a match route
|
143
|
+
#
|
144
|
+
# @param [String] name name of the namespace, prefixes other commands
|
145
|
+
#
|
146
|
+
# @option [Hash] options "as", prefixes all other "as" commands
|
147
|
+
# @param [Function] block callback for child commands
|
148
|
+
namespace: (name, options={}, block) ->
|
149
|
+
if Object.isFunction(options)
|
150
|
+
block = options
|
151
|
+
options = {}
|
152
|
+
|
153
|
+
newScope = $.extend({}, this)
|
154
|
+
newScope.rawRoutes = {}
|
155
|
+
newScope.__namespace += name
|
156
|
+
newScope.__asNamespace += "#{options["as"]}" if options["as"]
|
157
|
+
block.call(newScope) if Object.isFunction(block)
|
158
|
+
@rawRoutes[name] = newScope.rawRoutes
|
159
|
+
|
82
160
|
#
|
83
161
|
# Inits the routing system and loads the current route
|
84
162
|
# Binds the window hashchange event and therefore should only be called once
|
@@ -199,5 +277,31 @@ Joosy.Router =
|
|
199
277
|
params[pair[0]] = pair[1]
|
200
278
|
|
201
279
|
params
|
280
|
+
|
281
|
+
#
|
282
|
+
# Injects reverse routing function into global namespace
|
283
|
+
# @param [String] as The name for the route, ex: for "projects"
|
284
|
+
# builds "projects_url" and "projects_path" functions
|
285
|
+
# @param [String] route Entire route, joined by namespaces, ex:
|
286
|
+
# "/projects/":
|
287
|
+
# "/:id" :
|
288
|
+
# "/edit": TestPage
|
289
|
+
# joins to "/projects/:id/edit"
|
290
|
+
#
|
291
|
+
__injectReverseUrl: (as, route) ->
|
292
|
+
return if as == undefined
|
293
|
+
|
294
|
+
fnc = (options) ->
|
295
|
+
url = route
|
296
|
+
(route.match(/\/:[^\/]+/g) || []).each (str) ->
|
297
|
+
url = url.replace(str.substr(1), options[str.substr(2)])
|
298
|
+
"#!#{url}"
|
299
|
+
|
300
|
+
Joosy.Helpers.Application["#{as}Path"] = (options) ->
|
301
|
+
fnc(options)
|
302
|
+
|
303
|
+
Joosy.Helpers.Application["#{as}Url"] = (options) ->
|
304
|
+
url = 'http://' + window.location.host + window.location.pathname
|
305
|
+
"#{url}#{fnc(options)}"
|
202
306
|
|
203
307
|
Joosy.Module.merge Joosy.Router, Joosy.Modules.Events
|
data/joosy.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require File.expand_path("../lib/joosy/
|
1
|
+
require File.expand_path("../lib/joosy/version", __FILE__)
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "joosy"
|
5
|
-
s.version = Joosy::
|
5
|
+
s.version = Joosy::VERSION
|
6
6
|
s.platform = Gem::Platform::RUBY
|
7
7
|
s.summary = "Joosy Framework support for Ruby on Rails"
|
8
8
|
s.email = "boris@roundlake.ru"
|
@@ -13,12 +13,10 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.files = `git ls-files`.split("\n")
|
14
14
|
s.require_paths = ["lib"]
|
15
15
|
|
16
|
-
s.add_dependency '
|
17
|
-
s.add_dependency 'coffee-rails'
|
18
|
-
s.add_dependency 'jquery-rails'
|
16
|
+
s.add_dependency 'sprockets'
|
19
17
|
s.add_dependency 'haml_coffee_assets'
|
20
|
-
s.add_dependency 'i18n-js'
|
21
18
|
|
19
|
+
s.add_development_dependency 'jquery-rails'
|
22
20
|
s.add_development_dependency 'guard'
|
23
21
|
s.add_development_dependency 'guard-coffeescript'
|
24
22
|
s.add_development_dependency 'guard-sprockets'
|
data/lib/joosy/rails/engine.rb
CHANGED
data/lib/joosy.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
require 'haml_coffee_assets'
|
2
|
-
require '
|
3
|
-
require 'coffee-rails'
|
4
|
-
|
5
|
-
require 'joosy/rails/engine'
|
6
|
-
require 'joosy/rails/version'
|
7
|
-
require 'rails/resources_with_joosy'
|
8
|
-
|
9
|
-
require 'i18n-js'
|
2
|
+
require 'joosy/version'
|
10
3
|
|
4
|
+
if defined?(Rails)
|
5
|
+
require 'joosy/rails/engine'
|
6
|
+
require 'rails/resources_with_joosy'
|
7
|
+
end
|
11
8
|
|
12
9
|
module Joosy
|
13
|
-
def self.
|
14
|
-
|
10
|
+
def self.assets_paths
|
11
|
+
[
|
12
|
+
File.expand_path('../../app/assets/javascripts', __FILE__),
|
13
|
+
File.expand_path('../../vendor/assets/javascripts', __FILE__),
|
14
|
+
File.dirname(HamlCoffeeAssets.helpers_path)
|
15
|
+
]
|
15
16
|
end
|
16
17
|
end
|
@@ -140,4 +140,95 @@ describe "Joosy.Router", ->
|
|
140
140
|
expect(Joosy.Application.setCurrentPage.args.last()).toEqual [TestPage, Object.extended()]
|
141
141
|
|
142
142
|
Joosy.Application.setCurrentPage.restore()
|
143
|
-
Joosy.Router.restrict false
|
143
|
+
Joosy.Router.restrict false
|
144
|
+
|
145
|
+
it "should DRAW simple routes, only using match and root", ->
|
146
|
+
Joosy.Router.map
|
147
|
+
'/': spies.root
|
148
|
+
'/page': TestPage
|
149
|
+
404: spies.wildcard
|
150
|
+
raw_routes_for_map = Joosy.Router.rawRoutes
|
151
|
+
|
152
|
+
Joosy.Router.reset()
|
153
|
+
|
154
|
+
Joosy.Router.draw ->
|
155
|
+
@root to: spies.root
|
156
|
+
@match '/page', to: TestPage
|
157
|
+
@notFound to: spies.wildcard
|
158
|
+
|
159
|
+
expect(Joosy.Router.rawRoutes).toEqual(raw_routes_for_map)
|
160
|
+
|
161
|
+
it "should DRAW namespaced routes", ->
|
162
|
+
Joosy.Router.map
|
163
|
+
'/': spies.root
|
164
|
+
'/page': TestPage
|
165
|
+
'/section':
|
166
|
+
'/page/:id': spies.section
|
167
|
+
'/page2/:more': TestPage
|
168
|
+
404: spies.wildcard
|
169
|
+
rawRoutesForMap = Joosy.Router.rawRoutes
|
170
|
+
|
171
|
+
Joosy.Router.reset()
|
172
|
+
|
173
|
+
Joosy.Router.draw ->
|
174
|
+
@root to: spies.root
|
175
|
+
@match '/page', to: TestPage
|
176
|
+
@namespace '/section', ->
|
177
|
+
@match '/page/:id', to: spies.section
|
178
|
+
@match '/page2/:more', to: TestPage
|
179
|
+
@notFound to: spies.wildcard
|
180
|
+
|
181
|
+
expect(Joosy.Router.rawRoutes).toEqual(rawRoutesForMap)
|
182
|
+
|
183
|
+
it "should DRAW simple route reverses, only using match and root", ->
|
184
|
+
Joosy.Router.draw ->
|
185
|
+
@root to: spies.root
|
186
|
+
@match '/page', to: TestPage, as: "page"
|
187
|
+
@match '/page/:id', to: TestPage, as: "pageFor"
|
188
|
+
@notFound to: spies.wildcard
|
189
|
+
|
190
|
+
validate = ->
|
191
|
+
expect(@rootUrl).not.toEqual undefined
|
192
|
+
expect(@rootPath).not.toEqual undefined
|
193
|
+
|
194
|
+
expect(@rootPath()).toEqual "#!/"
|
195
|
+
expect(@pagePath()).toEqual "#!/page"
|
196
|
+
expect(@pageForPath(id: 3)).toEqual "#!/page/3"
|
197
|
+
validate.call(Joosy.Helpers.Application)
|
198
|
+
|
199
|
+
it "should DRAW more complex reverses using namespaces", ->
|
200
|
+
Joosy.Router.draw ->
|
201
|
+
@namespace '/projects', as: "projects", ->
|
202
|
+
@match "/", to: TestPage, as: "index"
|
203
|
+
@namespace "/:id", ->
|
204
|
+
@match "/", to: TestPage, as: "show"
|
205
|
+
@match "/edit", to: TestPage, as: "edit"
|
206
|
+
@match "/delete", to: TestPage, as: "delete"
|
207
|
+
|
208
|
+
@namespace '/tickets', ->
|
209
|
+
@match "/", to: TestPage, as: "tasksIndex"
|
210
|
+
|
211
|
+
@namespace '/activities', ->
|
212
|
+
@root to: TestPage, as: "activities"
|
213
|
+
|
214
|
+
validate = ->
|
215
|
+
expect(@projectsIndexPath).not.toEqual undefined
|
216
|
+
expect(@projectsIndexPath()).not.toEqual "#!/projects"
|
217
|
+
expect(@projectsIndexPath()).toEqual "#!/projects/"
|
218
|
+
|
219
|
+
expect(@projectsShowPath(id: 3)).toEqual "#!/projects/3/"
|
220
|
+
expect(@projectsEditPath(id: 3)).toEqual "#!/projects/3/edit"
|
221
|
+
expect(@projectsDeletePath(id: 3)).toEqual "#!/projects/3/delete"
|
222
|
+
|
223
|
+
expect(@tasksIndexPath()).toEqual "#!/tickets/"
|
224
|
+
expect(@activitiesPath()).toEqual "#!/activities/"
|
225
|
+
validate.call(Joosy.Helpers.Application)
|
226
|
+
|
227
|
+
it "should return reverse url with hostname and pathname", ->
|
228
|
+
Joosy.Router.draw ->
|
229
|
+
@match "/projects/", to: TestPage, as: "projectsIndex"
|
230
|
+
|
231
|
+
validate = ->
|
232
|
+
expect(@projectsIndexPath()).toEqual "#!/projects/"
|
233
|
+
expect(@projectsIndexUrl()).toEqual "http://localhost:8888/#!/projects/"
|
234
|
+
validate.call(Joosy.Helpers.Application)
|
@@ -297,7 +297,7 @@
|
|
297
297
|
// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
298
298
|
// vvvvvvvvvvvvvvvvvvv REMOVE IF NOT SUPPORTING IE6/7/8 vvvvvvvvvvvvvvvvvvv
|
299
299
|
// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
300
|
-
|
300
|
+
!supports_onhashchange && (function(){
|
301
301
|
// Not only do IE6/7 need the "magical" Iframe treatment, but so does IE8
|
302
302
|
// when running in "IE7 compatibility" mode.
|
303
303
|
|