joosy 1.2.0.alpha.57 → 1.2.0.alpha.58

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 738fb1a1338734dc8f3c610080dc4dc493f54d11
4
- data.tar.gz: 024f3bc99a0d6e4fa6ca359963986f7cf1478d41
3
+ metadata.gz: 877691f0d3fe49b4f115f111663aba62396a0421
4
+ data.tar.gz: 7996ed76d2bddc7349b6ec2d316ee0a7ab4c1883
5
5
  SHA512:
6
- metadata.gz: acf0c72593d7633f50696582e09ecc567142ab7b88803c209c2746fe1ea2f7b35cfb76496c66a76792c080630cb8a5b99342eb9cb240e4dd5db04eb30be21d9f
7
- data.tar.gz: b9ffc28b0933ff209712aa1241f6128aa2b1c08d91c2e4b6dce2ddae1e52b8e24adf8f6e504c64c79ca7d7e2b4a24ccb3a6c6113ecd389549e29da47d75e0111
6
+ metadata.gz: 5b169f311b2a03478e24b1be422843e2ceb4786c4389217029f04b10e7a8245a0b6b156295cd1cdfae2486cd17d0c5b26a3a99c307b09d6dd5d251c1072d36d6
7
+ data.tar.gz: 673c4f423886679626cf29d4255bba23aba634aeca135358243b9e9b7efacfb4c3d5d37a9c6b3882b67f8dc0454f69e03b596a1820e177c832764d5b23b1ccd6
data/bower.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "joosy",
3
- "version": "1.2.0-alpha.57",
3
+ "version": "1.2.0-alpha.58",
4
4
  "main": "lib/joosy.js",
5
5
  "ignore": [
6
6
  "bin",
data/build/joosy.js CHANGED
@@ -534,10 +534,7 @@
534
534
  });
535
535
  },
536
536
  __clearContainer: function() {
537
- var _ref;
538
- if ((_ref = this.$container) != null) {
539
- _ref.unbind().off();
540
- }
537
+ this.$container.unbind().off();
541
538
  return this.$container = $();
542
539
  }
543
540
  };
@@ -1351,21 +1348,19 @@
1351
1348
  $container = this.__normalizeSelector($container);
1352
1349
  }
1353
1350
  widget = this.__normalizeWidget(widget);
1354
- widget.__bootstrapDefault($container);
1355
- this.__nestedSections || (this.__nestedSections = []);
1356
- this.__nestedSections.push(widget);
1351
+ widget.__bootstrapDefault(this, $container);
1357
1352
  return widget;
1358
1353
  };
1359
1354
 
1360
1355
  Widget.prototype.unregisterWidget = function(widget) {
1361
- widget.__unload();
1362
- return this.__nestedSections.splice(this.__nestedSections.indexOf(widget), 1);
1356
+ return widget.__unload();
1363
1357
  };
1364
1358
 
1365
1359
  Widget.prototype.replaceWidget = function(widget, replacement) {
1366
1360
  replacement = this.__normalizeWidget(replacement);
1367
1361
  replacement.previous = widget;
1368
- return replacement.__bootstrapDefault(widget.$container);
1362
+ replacement.__bootstrapDefault(this, widget.$container);
1363
+ return replacement;
1369
1364
  };
1370
1365
 
1371
1366
  Widget.prototype.navigate = function() {
@@ -1392,11 +1387,11 @@
1392
1387
  return map;
1393
1388
  };
1394
1389
 
1395
- Widget.prototype.__bootstrapDefault = function($container) {
1396
- return this.__bootstrap(this.__nestingMap(), $container);
1390
+ Widget.prototype.__bootstrapDefault = function(parent, $container) {
1391
+ return this.__bootstrap(parent, this.__nestingMap(), $container);
1397
1392
  };
1398
1393
 
1399
- Widget.prototype.__bootstrap = function(nestingMap, $container, fetch) {
1394
+ Widget.prototype.__bootstrap = function(parent, nestingMap, $container, fetch) {
1400
1395
  var _this = this;
1401
1396
  this.$container = $container;
1402
1397
  if (fetch == null) {
@@ -1404,7 +1399,7 @@
1404
1399
  }
1405
1400
  this.wait('section:fetched section:erased', function() {
1406
1401
  return _this.__runPaints([], function() {
1407
- return _this.__paint(nestingMap, _this.$container);
1402
+ return _this.__paint(parent, nestingMap, _this.$container);
1408
1403
  });
1409
1404
  });
1410
1405
  this.__erase();
@@ -1437,7 +1432,7 @@
1437
1432
  });
1438
1433
  };
1439
1434
 
1440
- Widget.prototype.__erase = function() {
1435
+ Widget.prototype.__erase = function(parent) {
1441
1436
  var _this = this;
1442
1437
  if (this.previous != null) {
1443
1438
  return this.previous.__runErases([], function() {
@@ -1459,43 +1454,57 @@
1459
1454
  }
1460
1455
  };
1461
1456
 
1462
- Widget.prototype.__paint = function(nestingMap, $container) {
1457
+ Widget.prototype.__paint = function(parent, nestingMap, $container) {
1463
1458
  var _this = this;
1459
+ this.parent = parent;
1464
1460
  this.$container = $container;
1465
1461
  this.__nestedSections = [];
1466
1462
  this.$container.html(typeof this.__renderDefault === "function" ? this.__renderDefault(this.data || {}) : void 0);
1467
1463
  this.__load();
1468
1464
  return Object.each(nestingMap, function(selector, section) {
1469
1465
  var _ref;
1470
- _this.__nestedSections.push(section.instance);
1471
1466
  $container = _this.__normalizeSelector(selector);
1472
1467
  if (!section.instance.__independent || ((_ref = section.instance.__triggeredEvents) != null ? _ref['section:fetched'] : void 0)) {
1473
- return section.instance.__paint(section.nested, $container);
1468
+ return section.instance.__paint(_this, section.nested, $container);
1474
1469
  } else {
1475
- return section.instance.__bootstrap(section.nested, $container, false);
1470
+ return section.instance.__bootstrap(_this, section.nested, $container, false);
1476
1471
  }
1477
1472
  });
1478
1473
  };
1479
1474
 
1480
1475
  Widget.prototype.__load = function() {
1476
+ var _base;
1477
+ if (this.parent) {
1478
+ (_base = this.parent).__nestedSections || (_base.__nestedSections = []);
1479
+ this.parent.__nestedSections.push(this);
1480
+ }
1481
1481
  this.__assignElements();
1482
1482
  this.__delegateEvents();
1483
1483
  return this.__runAfterLoads();
1484
1484
  };
1485
1485
 
1486
- Widget.prototype.__unload = function() {
1486
+ Widget.prototype.__unload = function(modifyParent) {
1487
1487
  var section, _i, _len, _ref;
1488
- _ref = this.__nestedSections;
1489
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1490
- section = _ref[_i];
1491
- section.__unload();
1488
+ if (modifyParent == null) {
1489
+ modifyParent = true;
1490
+ }
1491
+ if (this.__nestedSections) {
1492
+ _ref = this.__nestedSections;
1493
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1494
+ section = _ref[_i];
1495
+ section.__unload(false);
1496
+ }
1497
+ delete this.__nestedSections;
1492
1498
  }
1493
- delete this.__nestedSections;
1494
1499
  this.__clearContainer();
1495
1500
  this.__clearTime();
1496
1501
  this.__removeMetamorphs();
1497
1502
  this.__runAfterUnloads();
1498
- return delete this.previous;
1503
+ if (this.parent && modifyParent) {
1504
+ this.parent.__nestedSections.splice(this.parent.__nestedSections.indexOf(this), 1);
1505
+ }
1506
+ delete this.previous;
1507
+ return delete this.parent;
1499
1508
  };
1500
1509
 
1501
1510
  Widget.prototype.__normalizeSelector = function(selector) {
@@ -1661,7 +1670,7 @@
1661
1670
  };
1662
1671
 
1663
1672
  Layout.prototype.__bootstrapDefault = function(page, applicationContainer) {
1664
- return this.__bootstrap(this.__nestingMap(page), applicationContainer);
1673
+ return this.__bootstrap(null, this.__nestingMap(page), applicationContainer);
1665
1674
  };
1666
1675
 
1667
1676
  return Layout;
@@ -1783,7 +1792,7 @@
1783
1792
 
1784
1793
  Page.prototype.__bootstrapDefault = function(applicationContainer) {
1785
1794
  var _ref;
1786
- return this.__bootstrap(this.__nestingMap(), ((_ref = this.layout) != null ? _ref.content() : void 0) || applicationContainer);
1795
+ return this.__bootstrap(this.layout, this.__nestingMap(), ((_ref = this.layout) != null ? _ref.content() : void 0) || applicationContainer);
1787
1796
  };
1788
1797
 
1789
1798
  return Page;
@@ -1809,6 +1818,11 @@
1809
1818
  if (tagOptions == null) {
1810
1819
  tagOptions = {};
1811
1820
  }
1821
+ if (Object.isFunction(tagOptions)) {
1822
+ url = name;
1823
+ tagOptions = url;
1824
+ name = tagOptions();
1825
+ }
1812
1826
  return Joosy.Helpers.Application.contentTag('a', name, Joosy.Module.merge(tagOptions, {
1813
1827
  'data-joosy': true,
1814
1828
  href: url
@@ -1844,8 +1858,8 @@
1844
1858
  });
1845
1859
 
1846
1860
  $(document).on('click', 'a[data-joosy]', function(event) {
1847
- Router.navigate(event.target.getAttribute('href'));
1848
- return false;
1861
+ event.preventDefault();
1862
+ return Joosy.Router.navigate(this.getAttribute('href'));
1849
1863
  });
1850
1864
 
1851
1865
  Drawer = (function() {
@@ -4,6 +4,7 @@ Path = require 'path'
4
4
 
5
5
  module.exports = class
6
6
  constructor: (@options) ->
7
+ @options.enableHTML5 = true
7
8
  @options.dependencies = """
8
9
  #= require jquery/jquery.js
9
10
  #= require jquery-form/jquery.form.js
@@ -22,17 +22,18 @@ module.exports = (grunt) ->
22
22
 
23
23
  assets:
24
24
  application:
25
- src: 'application.coffee'
25
+ src: 'application.coffee'
26
26
  dest: 'public/assets/application.js'
27
27
  styles:
28
- src: 'application.styl'
28
+ src: 'application.styl'
29
29
  dest: 'public/assets/application.css'
30
30
  haml:
31
31
  application:
32
- path: '/'
33
- src: 'index.haml'
34
- dest: 'public/index.html'
35
- url: ['/', '/index.html']
32
+ path: '/'
33
+ src: 'index.haml'
34
+ dest: 'public/index.html'
35
+ url: '/'
36
+ greedy: true
36
37
 
37
38
  uglify:
38
39
  application:
@@ -50,7 +51,7 @@ module.exports = (grunt) ->
50
51
  options:
51
52
  keepRunner: true
52
53
  outfile: 'spec/application.html'
53
- specs: '.grunt/spec/*_spec.js'
54
+ specs: '.grunt/spec/*_spec.js'
54
55
  helpers: '.grunt/spec/helpers/environment.js'
55
56
 
56
57
  #
data/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "keywords": [
5
5
  "joosy"
6
6
  ],
7
- "version": "1.2.0-alpha.57",
7
+ "version": "1.2.0-alpha.58",
8
8
  "author": "Boris Staal <boris@staal.io>",
9
9
  "homepage": "http://joosy.ws/",
10
10
  "repository": {
@@ -7,4 +7,9 @@
7
7
  Joosy.helpers 'Routes', ->
8
8
 
9
9
  @linkTo = (name='', url='', tagOptions={}) ->
10
+ if Object.isFunction tagOptions
11
+ url = name
12
+ tagOptions = url
13
+ name = tagOptions()
14
+
10
15
  Joosy.Helpers.Application.contentTag 'a', name, Joosy.Module.merge(tagOptions, 'data-joosy': true, href: url)
@@ -66,7 +66,7 @@ class Joosy.Layout extends Joosy.Widget
66
66
  # @param [jQuery] applicationContainer The base container for the application to paint at
67
67
  #
68
68
  __bootstrapDefault: (page, applicationContainer) ->
69
- @__bootstrap @__nestingMap(page), applicationContainer
69
+ @__bootstrap null, @__nestingMap(page), applicationContainer
70
70
 
71
71
  # AMD wrapper
72
72
  if define?.amd?
@@ -131,7 +131,7 @@ Joosy.Modules.DOM =
131
131
 
132
132
  # @private
133
133
  __clearContainer: ->
134
- @$container?.unbind().off()
134
+ @$container.unbind().off()
135
135
  @$container = $()
136
136
 
137
137
 
@@ -61,7 +61,7 @@ class Joosy.Page extends Joosy.Widget
61
61
  # as a fallback for cases when no Layout has been set
62
62
  #
63
63
  __bootstrapDefault: (applicationContainer) ->
64
- @__bootstrap @__nestingMap(), @layout?.content() || applicationContainer
64
+ @__bootstrap @layout, @__nestingMap(), @layout?.content() || applicationContainer
65
65
 
66
66
  # AMD wrapper
67
67
  if define?.amd?
@@ -33,9 +33,9 @@ class Joosy.Router extends Joosy.Module
33
33
  else
34
34
  window.history.loaded = true
35
35
 
36
- $(document).on 'click', 'a[data-joosy]', (event) =>
37
- @navigate event.target.getAttribute('href')
38
- false
36
+ $(document).on 'click', 'a[data-joosy]', (event) ->
37
+ event.preventDefault()
38
+ Joosy.Router.navigate @getAttribute('href')
39
39
 
40
40
  #
41
41
  # Rails-like wrapper around internal raw routes representation
@@ -160,10 +160,7 @@ class Joosy.Widget extends Joosy.Module
160
160
  $container = @__normalizeSelector($container)
161
161
 
162
162
  widget = @__normalizeWidget(widget)
163
- widget.__bootstrapDefault $container
164
-
165
- @__nestedSections ||= []
166
- @__nestedSections.push widget
163
+ widget.__bootstrapDefault @, $container
167
164
 
168
165
  widget
169
166
 
@@ -175,13 +172,12 @@ class Joosy.Widget extends Joosy.Module
175
172
  unregisterWidget: (widget) ->
176
173
  widget.__unload()
177
174
 
178
- @__nestedSections.splice @__nestedSections.indexOf(widget), 1
179
-
180
175
  replaceWidget: (widget, replacement) ->
181
176
  replacement = @__normalizeWidget(replacement)
182
177
  replacement.previous = widget
183
178
 
184
- replacement.__bootstrapDefault widget.$container
179
+ replacement.__bootstrapDefault @, widget.$container
180
+ replacement
185
181
 
186
182
  #
187
183
  # @see Joosy.Router.navigate
@@ -216,8 +212,8 @@ class Joosy.Widget extends Joosy.Module
216
212
  #
217
213
  # @param [jQuery] $container DOM container to inject to
218
214
  #
219
- __bootstrapDefault: ($container) ->
220
- @__bootstrap @__nestingMap(), $container
215
+ __bootstrapDefault: (parent, $container) ->
216
+ @__bootstrap parent, @__nestingMap(), $container
221
217
 
222
218
  #
223
219
  # Bootstraps the section with given nestings at given container
@@ -235,10 +231,10 @@ class Joosy.Widget extends Joosy.Module
235
231
  # @param [jQuery] $container DOM container to inject into
236
232
  # @param [boolean] fetch Boolean flag used to avoid double fetch during recursion
237
233
  #
238
- __bootstrap: (nestingMap, @$container, fetch=true) ->
234
+ __bootstrap: (parent, nestingMap, @$container, fetch=true) ->
239
235
  @wait 'section:fetched section:erased', =>
240
236
  @__runPaints [], =>
241
- @__paint nestingMap, @$container
237
+ @__paint parent, nestingMap, @$container
242
238
 
243
239
  @__erase()
244
240
  @__fetch(nestingMap) if fetch
@@ -271,7 +267,7 @@ class Joosy.Widget extends Joosy.Module
271
267
  #
272
268
  # Runs erasing chain for the previous section and beforePaints for current
273
269
  #
274
- __erase: ->
270
+ __erase: (parent) ->
275
271
  if @previous?
276
272
  @previous.__runErases [], =>
277
273
  @previous.__unload()
@@ -285,26 +281,28 @@ class Joosy.Widget extends Joosy.Module
285
281
  #
286
282
  # Builds HTML of section and its dependent nestings and injects it into DOM
287
283
  #
288
- __paint: (nestingMap, @$container) ->
284
+ __paint: (@parent, nestingMap, @$container) ->
289
285
  @__nestedSections = []
290
286
  @$container.html @__renderDefault?(@data || {})
291
287
 
292
288
  @__load()
293
289
 
294
290
  Object.each nestingMap, (selector, section) =>
295
- @__nestedSections.push section.instance
296
-
297
291
  $container = @__normalizeSelector(selector)
298
292
 
299
293
  if !section.instance.__independent || section.instance.__triggeredEvents?['section:fetched']
300
- section.instance.__paint section.nested, $container
294
+ section.instance.__paint @, section.nested, $container
301
295
  else
302
- section.instance.__bootstrap section.nested, $container, false
296
+ section.instance.__bootstrap @, section.nested, $container, false
303
297
 
304
298
  #
305
299
  # Initializes section that was injected into DOM
306
300
  #
307
301
  __load: ->
302
+ if @parent
303
+ @parent.__nestedSections ||= []
304
+ @parent.__nestedSections.push @
305
+
308
306
  @__assignElements()
309
307
  @__delegateEvents()
310
308
  @__runAfterLoads()
@@ -312,15 +310,21 @@ class Joosy.Widget extends Joosy.Module
312
310
  #
313
311
  # Deinitializes section that is preparing to be removed from DOM
314
312
  #
315
- __unload: ->
316
- section.__unload() for section in @__nestedSections
317
- delete @__nestedSections
313
+ __unload: (modifyParent=true) ->
314
+ if @__nestedSections
315
+ section.__unload(false) for section in @__nestedSections
316
+ delete @__nestedSections
318
317
 
319
318
  @__clearContainer()
320
319
  @__clearTime()
321
320
  @__removeMetamorphs()
322
321
  @__runAfterUnloads()
322
+
323
+ if @parent && modifyParent
324
+ @parent.__nestedSections.splice @parent.__nestedSections.indexOf(@), 1
325
+
323
326
  delete @previous
327
+ delete @parent
324
328
 
325
329
  #
326
330
  # Normalizes selector and returns jQuery wrap
@@ -62,7 +62,7 @@ describe "Joosy.Widget", ->
62
62
  '#subcontent': {instance: @d}
63
63
 
64
64
  it 'calls paint callbacks', ->
65
- @a.__bootstrap @nestingMap, @$ground
65
+ @a.__bootstrap null, @nestingMap, @$ground
66
66
 
67
67
  expect(@spies["a/paint"].callCount).toEqual 1
68
68
  expect(@spies["b/paint"].callCount).toEqual 0
@@ -77,7 +77,7 @@ describe "Joosy.Widget", ->
77
77
  expect(@spies['b/erase'].callCount).toEqual 0
78
78
  expect(@spies['c/erase'].callCount).toEqual 0
79
79
 
80
- @c.__bootstrap {}, $('#content', @$ground)
80
+ @c.__bootstrap null, {}, $('#content', @$ground)
81
81
 
82
82
  ['paint', 'beforePaint'].each (filter) =>
83
83
  expect(@spies["a/#{filter}"].callCount).toEqual 1
@@ -92,7 +92,7 @@ describe "Joosy.Widget", ->
92
92
  expect(@spies['c/erase'].callCount).toEqual 0
93
93
 
94
94
  it 'calls load/unload callbacks', ->
95
- @a.__bootstrap @nestingMap, @$ground
95
+ @a.__bootstrap null, @nestingMap, @$ground
96
96
 
97
97
  expect(@a.__load.callCount).toEqual 1
98
98
  expect(@b.__load.callCount).toEqual 1
@@ -103,7 +103,7 @@ describe "Joosy.Widget", ->
103
103
  expect(@c.__unload.callCount).toEqual 0
104
104
  expect(@d.__unload.callCount).toEqual 0
105
105
 
106
- @c.__bootstrap {}, $('#content', @$ground)
106
+ @c.__bootstrap @a, {}, $('#content', @$ground)
107
107
 
108
108
  expect(@a.__load.callCount).toEqual 1
109
109
  expect(@b.__load.callCount).toEqual 1
@@ -114,6 +114,16 @@ describe "Joosy.Widget", ->
114
114
  expect(@c.__unload.callCount).toEqual 0
115
115
  expect(@d.__unload.callCount).toEqual 1
116
116
 
117
+ @a.__unload()
118
+ expect(@a.__load.callCount).toEqual 1
119
+ expect(@b.__load.callCount).toEqual 1
120
+ expect(@c.__load.callCount).toEqual 1
121
+ expect(@d.__load.callCount).toEqual 1
122
+ expect(@a.__unload.callCount).toEqual 1
123
+ expect(@b.__unload.callCount).toEqual 1
124
+ expect(@c.__unload.callCount).toEqual 1
125
+ expect(@d.__unload.callCount).toEqual 1
126
+
117
127
  describe 'widgets manager', ->
118
128
 
119
129
  @beforeEach ->
@@ -141,7 +151,7 @@ describe "Joosy.Widget", ->
141
151
  '#b': B
142
152
 
143
153
  it 'bootstraps registered widgets', ->
144
- (new @A).__bootstrapDefault @$ground
154
+ (new @A).__bootstrapDefault null, @$ground
145
155
  expect(@$ground.html()).toEqualHTML '<div id="b"><div id="c">C</div></div>'
146
156
 
147
157
  it 'bootstraps registered independent widgets', ->
@@ -149,7 +159,7 @@ describe "Joosy.Widget", ->
149
159
  @C.independent()
150
160
 
151
161
  runs ->
152
- (new @A).__bootstrapDefault @$ground
162
+ (new @A).__bootstrapDefault null, @$ground
153
163
  expect(@$ground.html()).toEqualHTML '<div id="b"><div id="c"></div></div>'
154
164
 
155
165
  waits 0
@@ -159,22 +169,24 @@ describe "Joosy.Widget", ->
159
169
 
160
170
  it 'registeres widgets on the fly', ->
161
171
  a = new @A
162
- a.__bootstrapDefault @$ground
172
+ a.__bootstrapDefault null, @$ground
163
173
  expect(@$ground.html()).toEqualHTML '<div id="b"><div id="c">C</div></div>'
164
174
 
165
- a.registerWidget '#b', @D
175
+ d = a.registerWidget '#b', @D
176
+ expect(d.parent).toEqual a
166
177
 
167
178
  expect(@$ground.html()).toEqualHTML '<div id="b">D</div>'
168
179
 
169
180
  it 'replaces widget', ->
170
181
  a = new @A
171
- a.__bootstrapDefault @$ground
182
+ a.__bootstrapDefault null, @$ground
172
183
  expect(@$ground.html()).toEqualHTML '<div id="b"><div id="c">C</div></div>'
173
184
 
174
185
  d = a.registerWidget '#b', @D
175
186
  sinon.spy d, '__unload'
176
187
 
177
- a.replaceWidget d, @C
188
+ c = a.replaceWidget d, @C
189
+ expect(c.parent).toEqual a
178
190
  expect(@$ground.html()).toEqualHTML '<div id="b">C</div>'
179
191
  expect(d.__unload.callCount).toEqual 1
180
192
 
@@ -283,11 +295,11 @@ describe "Joosy.Widget", ->
283
295
  describe 'dependent', ->
284
296
 
285
297
  it 'loads when no nesting defined', ->
286
- @f.__bootstrap @nestingMap, @$ground
298
+ @f.__bootstrap null, @nestingMap, @$ground
287
299
  expect(@$ground.html()).toEqual 'F'
288
300
 
289
301
  it 'loads whole dependency tree synchronously', ->
290
- @a.__bootstrap @nestingMap, @$ground
302
+ @a.__bootstrap null, @nestingMap, @$ground
291
303
  expect(@$ground.html()).toEqualHTML '<div id="b"><div id="c"><div id="e">E</div><div id="f">F</div></div><div id="d">D</div></div>'
292
304
 
293
305
  it 'loads whole dependency tree asynchronously', ->
@@ -295,7 +307,7 @@ describe "Joosy.Widget", ->
295
307
  @B.fetch (complete) -> setTimeout complete, 100
296
308
 
297
309
  runs ->
298
- @a.__bootstrap @nestingMap, @$ground
310
+ @a.__bootstrap null, @nestingMap, @$ground
299
311
  expect(@$ground.html()).toEqualHTML ''
300
312
 
301
313
  waits 0
@@ -312,7 +324,7 @@ describe "Joosy.Widget", ->
312
324
  @C.fetch (complete) -> setTimeout complete, 0
313
325
  @C.independent()
314
326
 
315
- @a.__bootstrap @nestingMap, @$ground
327
+ @a.__bootstrap null, @nestingMap, @$ground
316
328
  expect(@$ground.html()).toEqualHTML '<div id="b"><div id="c"></div><div id="d">D</div></div>'
317
329
 
318
330
  describe 'independent', ->
@@ -324,7 +336,7 @@ describe "Joosy.Widget", ->
324
336
  @C.independent()
325
337
 
326
338
  runs ->
327
- @a.__bootstrap @nestingMap, @$ground
339
+ @a.__bootstrap null, @nestingMap, @$ground
328
340
 
329
341
  waits 100
330
342
 
@@ -339,7 +351,7 @@ describe "Joosy.Widget", ->
339
351
  @E.independent()
340
352
 
341
353
  runs ->
342
- @a.__bootstrap @nestingMap, @$ground
354
+ @a.__bootstrap null, @nestingMap, @$ground
343
355
  expect(@$ground.html()).toEqualHTML '<div id="b"><div id="c"></div><div id="d">D</div></div>'
344
356
 
345
357
  waits 0
@@ -361,7 +373,7 @@ describe "Joosy.Widget", ->
361
373
  @E.fetch (complete) -> setTimeout complete, 100
362
374
 
363
375
  runs ->
364
- @a.__bootstrap @nestingMap, @$ground
376
+ @a.__bootstrap null, @nestingMap, @$ground
365
377
  expect(@$ground.html()).toEqualHTML '<div id="b"></div>'
366
378
 
367
379
  waits 0
data/tasks/joosy.coffee CHANGED
@@ -111,13 +111,13 @@ module.exports = (grunt) ->
111
111
  console.log "=> Serving assets from #{path}"
112
112
 
113
113
  serveHAML: (server, map) ->
114
- serve = (urls, template, partials) ->
114
+ serve = (urls, greedy, template, partials) ->
115
115
  urls = [urls] unless Object.isArray(urls)
116
116
 
117
117
  for url in urls
118
118
  do (url) ->
119
119
  server.use url, (req, res, next) ->
120
- if req.originalUrl == url
120
+ if greedy && req.originalUrl.startsWith(url) || req.originalUrl == url
121
121
  res.end grunt.joosy.haml.compile(template, partials)
122
122
  console.log "Served #{url} (#{template})"
123
123
  else
@@ -127,13 +127,14 @@ module.exports = (grunt) ->
127
127
  for entry in map
128
128
  do (entry) ->
129
129
  unless entry.expand
130
- serve(entry.url, Path.join(paths.haml, entry.src), entry.partials)
130
+ serve(entry.url, entry.greedy, Path.join(paths.haml, entry.src), entry.partials)
131
131
  else
132
132
  files = grunt.joosy.helpers.expandFiles(paths.haml, entry)
133
133
 
134
134
  for file in files.list
135
135
  serve(
136
136
  entry.url(file),
137
+ entry.greedy,
137
138
  Path.join(files.cwd, file.src),
138
139
  entry.partials
139
140
  )
@@ -198,9 +199,9 @@ module.exports = (grunt) ->
198
199
 
199
200
  grunt.joosy.server.start 4000, (server) ->
200
201
  grunt.joosy.server.serveAssets server
201
- grunt.joosy.server.serveHAML server, grunt.joosy.helpers.normalizeFiles('joosy.haml')
202
202
  grunt.joosy.server.serveProxied server, grunt.config.get('joosy.server.proxy')
203
203
  grunt.joosy.server.serveStatic server
204
+ grunt.joosy.server.serveHAML server, grunt.joosy.helpers.normalizeFiles('joosy.haml')
204
205
 
205
206
  grunt.registerTask 'joosy:server:production', ->
206
207
  @async()
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.alpha.57
4
+ version: 1.2.0.alpha.58
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boris Staal