joosy 1.2.0.beta.4 → 1.2.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codoopts +1 -1
- data/Gruntfile.coffee +3 -3
- data/README.md +4 -0
- data/bower.json +1 -1
- data/build/joosy.js +2 -2
- data/build/joosy/form.js +1 -1
- data/build/joosy/resources.js +1 -1
- data/package.json +2 -2
- data/source/joosy/application.coffee +2 -2
- data/source/joosy/form.coffee +4 -4
- data/source/joosy/helpers/form.coffee +12 -3
- data/source/joosy/helpers/index.coffee +0 -1
- data/source/joosy/helpers/view.coffee +16 -3
- data/source/joosy/layout.coffee +0 -4
- data/source/joosy/module.coffee +16 -1
- data/source/joosy/modules/dom.coffee +106 -101
- data/source/joosy/modules/events.coffee +44 -10
- data/source/joosy/modules/filters.coffee +64 -60
- data/source/joosy/modules/page.coffee +3 -0
- data/source/joosy/modules/page/scrolling.coffee +46 -29
- data/source/joosy/modules/page/title.coffee +14 -0
- data/source/joosy/modules/renderer.coffee +219 -190
- data/source/joosy/modules/resources.coffee +3 -0
- data/source/joosy/modules/resources/cacher.coffee +81 -10
- data/source/joosy/modules/resources/function.coffee +26 -29
- data/source/joosy/modules/resources/identity_map.coffee +64 -42
- data/source/joosy/modules/resources/model.coffee +127 -73
- data/source/joosy/modules/time_manager.coffee +2 -0
- data/source/joosy/page.coffee +3 -6
- data/source/joosy/resources/array.coffee +87 -2
- data/source/joosy/resources/hash.coffee +53 -1
- data/source/joosy/resources/rest.coffee +59 -3
- data/source/joosy/resources/scalar.coffee +47 -1
- data/source/joosy/router.coffee +63 -21
- data/source/joosy/templaters/jst.coffee +3 -0
- data/source/joosy/widget.coffee +17 -11
- data/spec/joosy/core/helpers/view_spec.coffee +14 -0
- data/spec/joosy/core/modules/dom_spec.coffee +1 -1
- data/spec/joosy/core/modules/filters_spec.coffee +2 -2
- data/spec/joosy/core/modules/module_spec.coffee +1 -1
- data/spec/joosy/core/modules/renderer_spec.coffee +19 -1
- data/spec/joosy/core/router_spec.coffee +80 -45
- data/spec/joosy/core/widget_spec.coffee +9 -0
- data/spec/joosy/resources/modules/cacher_spec.coffee +3 -3
- data/spec/joosy/resources/modules/function_spec.coffee +2 -2
- data/spec/joosy/resources/modules/identity_map_spec.coffee +2 -2
- data/spec/joosy/resources/modules/model_spec.coffee +1 -1
- metadata +2 -5
- data/source/joosy/helpers/routes.coffee +0 -17
- data/source/joosy/modules/widgets_manager.coffee +0 -90
- data/spec/joosy/core/helpers/routes_spec.coffee +0 -15
@@ -327,6 +327,15 @@ describe "Joosy.Widget", ->
|
|
327
327
|
@a.__bootstrap null, @nestingMap, @$ground
|
328
328
|
expect(@$ground.html()).toEqualHTML '<div id="b"><div id="c"></div><div id="d">D</div></div>'
|
329
329
|
|
330
|
+
it 'loads children before parent', ->
|
331
|
+
order = []
|
332
|
+
for instance in ['a', 'b', 'c', 'd', 'e', 'f']
|
333
|
+
do (instance) =>
|
334
|
+
@[instance].constructor.afterLoad ->
|
335
|
+
order.push(instance)
|
336
|
+
@a.__bootstrap null, @nestingMap, @$ground
|
337
|
+
expect(order).toEqual ['d', 'e', 'f', 'c', 'b', 'a']
|
338
|
+
|
330
339
|
describe 'independent', ->
|
331
340
|
|
332
341
|
it 'loads independent children synchronously if they managed to fetch', ->
|
@@ -12,7 +12,7 @@ describe 'Joosy.Modules.Resources.Cacher', ->
|
|
12
12
|
spy = @spy
|
13
13
|
|
14
14
|
class @Cacher extends Joosy.Resources.Scalar
|
15
|
-
@
|
15
|
+
@concern Joosy.Modules.Resources.Cacher
|
16
16
|
|
17
17
|
@cache 'scalar'
|
18
18
|
@fetcher (callback) ->
|
@@ -35,7 +35,7 @@ describe 'Joosy.Modules.Resources.Cacher', ->
|
|
35
35
|
spy = @spy
|
36
36
|
|
37
37
|
class @Cacher extends Joosy.Resources.Array
|
38
|
-
@
|
38
|
+
@concern Joosy.Modules.Resources.Cacher
|
39
39
|
|
40
40
|
@cache 'array'
|
41
41
|
@fetcher (callback) ->
|
@@ -63,7 +63,7 @@ describe 'Joosy.Modules.Resources.Cacher', ->
|
|
63
63
|
spy = @spy
|
64
64
|
|
65
65
|
class @Cacher extends Joosy.Resources.Hash
|
66
|
-
@
|
66
|
+
@concern Joosy.Modules.Resources.Cacher
|
67
67
|
|
68
68
|
@cache 'hash'
|
69
69
|
@fetcher (callback) ->
|
@@ -2,7 +2,7 @@ describe 'Joosy.Modules.Resources.Function', ->
|
|
2
2
|
|
3
3
|
it 'works', ->
|
4
4
|
class Generic extends Joosy.Module
|
5
|
-
@
|
5
|
+
@concern Joosy.Modules.Resources.Function
|
6
6
|
|
7
7
|
constructor: (@bar) ->
|
8
8
|
@foo = 'bar'
|
@@ -19,7 +19,7 @@ describe 'Joosy.Modules.Resources.Function', ->
|
|
19
19
|
describe 'Hash', ->
|
20
20
|
it 'works', ->
|
21
21
|
class Hash extends Joosy.Resources.Hash
|
22
|
-
@
|
22
|
+
@concern Joosy.Modules.Resources.Function
|
23
23
|
|
24
24
|
constructor: (data) ->
|
25
25
|
data.bar = 'foo'
|
@@ -1,8 +1,8 @@
|
|
1
1
|
describe "Joosy.Modules.Resources.IdentityMap", ->
|
2
2
|
|
3
3
|
class Model extends Joosy.Resources.Hash
|
4
|
-
@
|
5
|
-
@
|
4
|
+
@concern Joosy.Modules.Resources.Model
|
5
|
+
@concern Joosy.Modules.Resources.IdentityMap
|
6
6
|
|
7
7
|
class TestInline extends Model
|
8
8
|
@entity 'test_inline'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: joosy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.0.
|
4
|
+
version: 1.2.0.rc.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boris Staal
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-12-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sprockets
|
@@ -63,7 +63,6 @@ files:
|
|
63
63
|
- source/joosy/form.coffee
|
64
64
|
- source/joosy/helpers/form.coffee
|
65
65
|
- source/joosy/helpers/index.coffee
|
66
|
-
- source/joosy/helpers/routes.coffee
|
67
66
|
- source/joosy/helpers/view.coffee
|
68
67
|
- source/joosy/helpers/widgets.coffee
|
69
68
|
- source/joosy/joosy.coffee
|
@@ -83,7 +82,6 @@ files:
|
|
83
82
|
- source/joosy/modules/resources/identity_map.coffee
|
84
83
|
- source/joosy/modules/resources/model.coffee
|
85
84
|
- source/joosy/modules/time_manager.coffee
|
86
|
-
- source/joosy/modules/widgets_manager.coffee
|
87
85
|
- source/joosy/page.coffee
|
88
86
|
- source/joosy/resources/array.coffee
|
89
87
|
- source/joosy/resources/hash.coffee
|
@@ -99,7 +97,6 @@ files:
|
|
99
97
|
- spec/helpers/ground.coffee
|
100
98
|
- spec/helpers/matchers.coffee
|
101
99
|
- spec/joosy/core/application_spec.coffee
|
102
|
-
- spec/joosy/core/helpers/routes_spec.coffee
|
103
100
|
- spec/joosy/core/helpers/view_spec.coffee
|
104
101
|
- spec/joosy/core/helpers/widgets_spec.coffee
|
105
102
|
- spec/joosy/core/joosy_spec.coffee
|
@@ -1,17 +0,0 @@
|
|
1
|
-
#= require joosy/joosy
|
2
|
-
#= require joosy/helpers/view
|
3
|
-
|
4
|
-
#
|
5
|
-
# Rendering and string representation helpers
|
6
|
-
#
|
7
|
-
Joosy.helpers 'Routes', ->
|
8
|
-
|
9
|
-
@linkTo = (name='', url='', tagOptions={}) ->
|
10
|
-
|
11
|
-
# (url, tagOptions, block) ->
|
12
|
-
if typeof(tagOptions) == 'function'
|
13
|
-
block = tagOptions
|
14
|
-
[url, tagOptions] = [name, url]
|
15
|
-
name = block()
|
16
|
-
|
17
|
-
Joosy.Helpers.Application.contentTag 'a', name, Joosy.Module.merge(tagOptions, 'data-joosy': true, href: url)
|
@@ -1,90 +0,0 @@
|
|
1
|
-
#= require joosy/joosy
|
2
|
-
|
3
|
-
#
|
4
|
-
# Widgets management routines
|
5
|
-
#
|
6
|
-
# @mixin
|
7
|
-
#
|
8
|
-
Joosy.Modules.WidgetsManager =
|
9
|
-
|
10
|
-
included: ->
|
11
|
-
@mapWidgets = (map) ->
|
12
|
-
unless @::hasOwnProperty "__widgets"
|
13
|
-
@::__widgets = Joosy.Module.merge {}, @.__super__.widgets
|
14
|
-
Joosy.Module.merge @::__widgets, map
|
15
|
-
|
16
|
-
#
|
17
|
-
# Registeres and runs widget inside specified container
|
18
|
-
#
|
19
|
-
# @param [DOM] container jQuery or direct dom node object
|
20
|
-
# @param [Joosy.Widget] widget Class or object of Joosy.Widget to register
|
21
|
-
#
|
22
|
-
registerWidget: (container, widget) ->
|
23
|
-
if Joosy.Module.hasAncestor widget, Joosy.Widget
|
24
|
-
widget = new widget()
|
25
|
-
|
26
|
-
if typeof(widget) == 'function'
|
27
|
-
widget = widget()
|
28
|
-
|
29
|
-
@__activeWidgets ||= []
|
30
|
-
@__activeWidgets.push widget.__load(@, $(container))
|
31
|
-
|
32
|
-
widget
|
33
|
-
|
34
|
-
#
|
35
|
-
# Unregisteres and destroys widget
|
36
|
-
#
|
37
|
-
# @param [Joosy.Widget] widget Object of Joosy.Widget to unregister
|
38
|
-
#
|
39
|
-
unregisterWidget: (widget) ->
|
40
|
-
widget.__unload()
|
41
|
-
|
42
|
-
@__activeWidgets.splice @__activeWidgets.indexOf(widget), 1
|
43
|
-
|
44
|
-
#
|
45
|
-
# Intialize all widgets for current object
|
46
|
-
#
|
47
|
-
__setupWidgets: ->
|
48
|
-
return unless @__widgets
|
49
|
-
|
50
|
-
registered = {}
|
51
|
-
|
52
|
-
for selector, widget of @__widgets
|
53
|
-
if selector == '$container'
|
54
|
-
activeSelector = @$container
|
55
|
-
else
|
56
|
-
selector = @__extractSelector(selector) if @__extractSelector?
|
57
|
-
activeSelector = $(selector, @$container)
|
58
|
-
|
59
|
-
registered[selector] = {}
|
60
|
-
|
61
|
-
activeSelector.each (index, elem) =>
|
62
|
-
if Joosy.Module.hasAncestor widget, Joosy.Widget
|
63
|
-
instance = new widget
|
64
|
-
else
|
65
|
-
instance = widget.call this, index
|
66
|
-
|
67
|
-
if Joosy.debug()
|
68
|
-
registered[selector][Joosy.Module.__className instance] ||= 0
|
69
|
-
registered[selector][Joosy.Module.__className instance] += 1
|
70
|
-
|
71
|
-
@registerWidget $(elem), instance
|
72
|
-
|
73
|
-
@__widgets = {}
|
74
|
-
|
75
|
-
if Joosy.debug()
|
76
|
-
for selector, value of registered
|
77
|
-
for widget, count of value
|
78
|
-
Joosy.Modules.Log.debugAs @, "Widget #{widget} registered at '#{selector}'. Elements: #{count}"
|
79
|
-
|
80
|
-
#
|
81
|
-
# Unregister all widgets for current object
|
82
|
-
#
|
83
|
-
__unloadWidgets: ->
|
84
|
-
if @__activeWidgets
|
85
|
-
for widget in @__activeWidgets
|
86
|
-
widget.__unload()
|
87
|
-
|
88
|
-
# AMD wrapper
|
89
|
-
if define?.amd?
|
90
|
-
define 'joosy/modules/widgets_manager', -> Joosy.Modules.WidgetsManager
|
@@ -1,15 +0,0 @@
|
|
1
|
-
describe "Joosy.Helpers.Routes", ->
|
2
|
-
|
3
|
-
it "renders data-joosy links", ->
|
4
|
-
link = Joosy.Helpers.Routes.linkTo 'test', '/app/link', nice: true
|
5
|
-
expect(link).toBeTag 'a', 'test',
|
6
|
-
'data-joosy': 'true'
|
7
|
-
nice: 'true'
|
8
|
-
href: '/app/link'
|
9
|
-
|
10
|
-
it "renders data-joosy links yielding block", ->
|
11
|
-
link = Joosy.Helpers.Routes.linkTo '/app/link', nice: true, -> 'test'
|
12
|
-
expect(link).toBeTag 'a', 'test',
|
13
|
-
'data-joosy': 'true'
|
14
|
-
nice: 'true'
|
15
|
-
href: '/app/link'
|