marionette-rails 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  module Marionette
2
2
  module Rails
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
1
  // MarionetteJS (Backbone.Marionette)
2
2
  // ----------------------------------
3
- // v1.0.1
3
+ // v1.0.2
4
4
  //
5
5
  // Copyright (c)2013 Derick Bailey, Muted Solutions, LLC.
6
6
  // Distributed under MIT license
@@ -17,10 +17,15 @@
17
17
  * https://github.com/marionettejs/backbone.wreqr/
18
18
  */
19
19
 
20
- // Backbone.BabySitter, v0.0.4
21
- // Copyright (c)2012 Derick Bailey, Muted Solutions, LLC.
20
+ // Backbone.BabySitter
21
+ // -------------------
22
+ // v0.0.5
23
+ //
24
+ // Copyright (c)2013 Derick Bailey, Muted Solutions, LLC.
22
25
  // Distributed under MIT license
23
- // http://github.com/marionettejs/backbone.babysitter
26
+ //
27
+ // http://github.com/babysitterjs/backbone.babysitter
28
+
24
29
  // Backbone.ChildViewContainer
25
30
  // ---------------------------
26
31
  //
@@ -28,7 +33,7 @@
28
33
  // shut down child views.
29
34
 
30
35
  Backbone.ChildViewContainer = (function(Backbone, _){
31
-
36
+
32
37
  // Container Constructor
33
38
  // ---------------------
34
39
 
@@ -194,9 +199,9 @@ Backbone.ChildViewContainer = (function(Backbone, _){
194
199
  //
195
200
  // Mix in methods from Underscore, for iteration, and other
196
201
  // collection related features.
197
- var methods = ['forEach', 'each', 'map', 'find', 'detect', 'filter',
198
- 'select', 'reject', 'every', 'all', 'some', 'any', 'include',
199
- 'contains', 'invoke', 'toArray', 'first', 'initial', 'rest',
202
+ var methods = ['forEach', 'each', 'map', 'find', 'detect', 'filter',
203
+ 'select', 'reject', 'every', 'all', 'some', 'any', 'include',
204
+ 'contains', 'invoke', 'toArray', 'first', 'initial', 'rest',
200
205
  'last', 'without', 'isEmpty', 'pluck'];
201
206
 
202
207
  _.each(methods, function(method) {
@@ -231,14 +236,14 @@ Backbone.Wreqr = (function(Backbone, Marionette, _){
231
236
 
232
237
  Wreqr.Handlers = (function(Backbone, _){
233
238
  "use strict";
234
-
239
+
235
240
  // Constructor
236
241
  // -----------
237
242
 
238
243
  var Handlers = function(options){
239
244
  this.options = options;
240
245
  this._wreqrHandlers = {};
241
-
246
+
242
247
  if (_.isFunction(this.initialize)){
243
248
  this.initialize(options);
244
249
  }
@@ -344,7 +349,7 @@ Wreqr.CommandStorage = (function(){
344
349
 
345
350
  // build the configuration
346
351
  commands = {
347
- command: commandName,
352
+ command: commandName,
348
353
  instances: []
349
354
  };
350
355
 
@@ -530,18 +535,18 @@ Marionette.getOption = function(target, optionName){
530
535
  // Trigger an event and a corresponding method name. Examples:
531
536
  //
532
537
  // `this.triggerMethod("foo")` will trigger the "foo" event and
533
- // call the "onFoo" method.
538
+ // call the "onFoo" method.
534
539
  //
535
540
  // `this.triggerMethod("foo:bar") will trigger the "foo:bar" event and
536
541
  // call the "onFooBar" method.
537
542
  Marionette.triggerMethod = (function(){
538
-
543
+
539
544
  // split the event name on the :
540
545
  var splitter = /(^|:)(\w)/gi;
541
546
 
542
547
  // take the event section ("section1:section2:section3")
543
548
  // and turn it in to uppercase name
544
- function getEventName(match, prefix, eventName) {
549
+ function getEventName(match, prefix, eventName) {
545
550
  return eventName.toUpperCase();
546
551
  }
547
552
 
@@ -610,8 +615,8 @@ Marionette.MonitorDOMRefresh = (function(){
610
615
  // Marionette.bindEntityEvents & unbindEntityEvents
611
616
  // ---------------------------
612
617
  //
613
- // These methods are used to bind/unbind a backbone "entity" (collection/model)
614
- // to methods on a target object.
618
+ // These methods are used to bind/unbind a backbone "entity" (collection/model)
619
+ // to methods on a target object.
615
620
  //
616
621
  // The first parameter, `target`, must have a `listenTo` method from the
617
622
  // EventBinder object.
@@ -621,7 +626,7 @@ Marionette.MonitorDOMRefresh = (function(){
621
626
  //
622
627
  // The third parameter is a hash of { "event:name": "eventHandler" }
623
628
  // configuration. Multiple handlers can be separated by a space. A
624
- // function can be supplied instead of a string handler name.
629
+ // function can be supplied instead of a string handler name.
625
630
 
626
631
  (function(Marionette){
627
632
  "use strict";
@@ -663,7 +668,7 @@ Marionette.MonitorDOMRefresh = (function(){
663
668
  target.stopListening(entity, evt, method, target);
664
669
  }
665
670
 
666
-
671
+
667
672
  // generic looping function
668
673
  function iterateEvents(target, entity, bindings, functionCallback, stringCallback){
669
674
  if (!entity || !bindings) { return; }
@@ -676,7 +681,7 @@ Marionette.MonitorDOMRefresh = (function(){
676
681
  // iterate the bindings and bind them
677
682
  _.each(bindings, function(methods, evt){
678
683
 
679
- // allow for a function as the handler,
684
+ // allow for a function as the handler,
680
685
  // or a list of event names as a string
681
686
  if (_.isFunction(methods)){
682
687
  functionCallback(target, entity, evt, methods);
@@ -686,7 +691,7 @@ Marionette.MonitorDOMRefresh = (function(){
686
691
 
687
692
  });
688
693
  }
689
-
694
+
690
695
  // Export Public API
691
696
  Marionette.bindEntityEvents = function(target, entity, bindings){
692
697
  iterateEvents(target, entity, bindings, bindToFunction, bindFromStrings);
@@ -713,7 +718,7 @@ Marionette.Callbacks = function(){
713
718
  _.extend(Marionette.Callbacks.prototype, {
714
719
 
715
720
  // Add a callback to be executed. Callbacks added here are
716
- // guaranteed to execute, even if they are added after the
721
+ // guaranteed to execute, even if they are added after the
717
722
  // `run` method is called.
718
723
  add: function(callback, contextOverride){
719
724
  this._callbacks.push({cb: callback, ctx: contextOverride});
@@ -724,8 +729,8 @@ _.extend(Marionette.Callbacks.prototype, {
724
729
  });
725
730
  },
726
731
 
727
- // Run all registered callbacks with the context specified.
728
- // Additional callbacks can be added after this has been run
732
+ // Run all registered callbacks with the context specified.
733
+ // Additional callbacks can be added after this has been run
729
734
  // and they will still be executed.
730
735
  run: function(options, context){
731
736
  this._deferred.resolve(context, options);
@@ -737,7 +742,7 @@ _.extend(Marionette.Callbacks.prototype, {
737
742
  var callbacks = this._callbacks;
738
743
  this._deferred = Marionette.$.Deferred();
739
744
  this._callbacks = [];
740
-
745
+
741
746
  _.each(callbacks, function(cb){
742
747
  this.add(cb.cb, cb.ctx);
743
748
  }, this);
@@ -774,7 +779,7 @@ _.extend(Marionette.Controller.prototype, Backbone.Events, {
774
779
  }
775
780
  });
776
781
 
777
- // Region
782
+ // Region
778
783
  // ------
779
784
  //
780
785
  // Manage the visual regions of your composite application. See
@@ -828,19 +833,19 @@ _.extend(Marionette.Region, {
828
833
  }
829
834
 
830
835
  var selector, RegionType;
831
-
836
+
832
837
  // get the selector for the region
833
-
838
+
834
839
  if (regionIsString) {
835
840
  selector = regionConfig;
836
- }
841
+ }
837
842
 
838
843
  if (regionConfig.selector) {
839
844
  selector = regionConfig.selector;
840
845
  }
841
846
 
842
847
  // get the type for the region
843
-
848
+
844
849
  if (regionIsType){
845
850
  RegionType = regionConfig;
846
851
  }
@@ -852,7 +857,7 @@ _.extend(Marionette.Region, {
852
857
  if (regionConfig.regionType) {
853
858
  RegionType = regionConfig.regionType;
854
859
  }
855
-
860
+
856
861
  // build the region instance
857
862
  var region = new RegionType({
858
863
  el: selector
@@ -941,8 +946,8 @@ _.extend(Marionette.Region.prototype, Backbone.Events, {
941
946
  delete this.currentView;
942
947
  },
943
948
 
944
- // Attach an existing view to the region. This
945
- // will not call `render` or `onShow` for the new view,
949
+ // Attach an existing view to the region. This
950
+ // will not call `render` or `onShow` for the new view,
946
951
  // and will not replace the current HTML for the `el`
947
952
  // of the region.
948
953
  attachView: function(view){
@@ -1073,9 +1078,9 @@ Marionette.RegionManager = (function(Marionette){
1073
1078
  //
1074
1079
  // Mix in methods from Underscore, for iteration, and other
1075
1080
  // collection related features.
1076
- var methods = ['forEach', 'each', 'map', 'find', 'detect', 'filter',
1077
- 'select', 'reject', 'every', 'all', 'some', 'any', 'include',
1078
- 'contains', 'invoke', 'toArray', 'first', 'initial', 'rest',
1081
+ var methods = ['forEach', 'each', 'map', 'find', 'detect', 'filter',
1082
+ 'select', 'reject', 'every', 'all', 'some', 'any', 'include',
1083
+ 'contains', 'invoke', 'toArray', 'first', 'initial', 'rest',
1079
1084
  'last', 'without', 'isEmpty', 'pluck'];
1080
1085
 
1081
1086
  _.each(methods, function(method) {
@@ -1100,7 +1105,7 @@ Marionette.TemplateCache = function(templateId){
1100
1105
  };
1101
1106
 
1102
1107
  // TemplateCache object-level methods. Manage the template
1103
- // caches from these method calls instead of creating
1108
+ // caches from these method calls instead of creating
1104
1109
  // your own TemplateCache instances
1105
1110
  _.extend(Marionette.TemplateCache, {
1106
1111
  templateCaches: {},
@@ -1123,7 +1128,7 @@ _.extend(Marionette.TemplateCache, {
1123
1128
  // are specified, clears all templates:
1124
1129
  // `clear()`
1125
1130
  //
1126
- // If arguments are specified, clears each of the
1131
+ // If arguments are specified, clears each of the
1127
1132
  // specified templates from the cache:
1128
1133
  // `clear("#t1", "#t2", "...")`
1129
1134
  clear: function(){
@@ -1163,7 +1168,7 @@ _.extend(Marionette.TemplateCache.prototype, {
1163
1168
  // Load a template from the DOM, by default. Override
1164
1169
  // this method to provide your own template retrieval
1165
1170
  // For asynchronous loading with AMD/RequireJS, consider
1166
- // using a template-loader plugin as described here:
1171
+ // using a template-loader plugin as described here:
1167
1172
  // https://github.com/marionettejs/backbone.marionette/wiki/Using-marionette-with-requirejs
1168
1173
  loadTemplate: function(templateId){
1169
1174
  var template = Marionette.$(templateId).html();
@@ -1221,7 +1226,7 @@ Marionette.View = Backbone.View.extend({
1221
1226
  },
1222
1227
 
1223
1228
  // import the "triggerMethod" to trigger events with corresponding
1224
- // methods if the method exists
1229
+ // methods if the method exists
1225
1230
  triggerMethod: Marionette.triggerMethod,
1226
1231
 
1227
1232
  // Get the template for this view
@@ -1283,7 +1288,7 @@ Marionette.View = Backbone.View.extend({
1283
1288
  return triggerEvents;
1284
1289
  },
1285
1290
 
1286
- // Overriding Backbone.View's delegateEvents to handle
1291
+ // Overriding Backbone.View's delegateEvents to handle
1287
1292
  // the `triggers`, `modelEvents`, and `collectionEvents` configuration
1288
1293
  delegateEvents: function(events){
1289
1294
  this._delegateDOMEvents(events);
@@ -1330,15 +1335,16 @@ Marionette.View = Backbone.View.extend({
1330
1335
  return;
1331
1336
  }
1332
1337
 
1333
- // unbind UI elements
1334
- this.unbindUIElements();
1335
-
1336
1338
  // mark as closed before doing the actual close, to
1337
1339
  // prevent infinite loops within "close" event handlers
1338
1340
  // that are trying to close other views
1339
1341
  this.isClosed = true;
1340
1342
  this.triggerMethod("close");
1341
1343
 
1344
+ // unbind UI elements
1345
+ this.unbindUIElements();
1346
+
1347
+ // remove the view from the DOM
1342
1348
  this.remove();
1343
1349
  },
1344
1350
 
@@ -1589,9 +1595,9 @@ Marionette.CollectionView = Marionette.View.extend({
1589
1595
  itemViewOptions = itemViewOptions.call(this, item, index);
1590
1596
  }
1591
1597
 
1592
- // build the view
1598
+ // build the view
1593
1599
  var view = this.buildItemView(item, ItemView, itemViewOptions);
1594
-
1600
+
1595
1601
  // set up the child view event forwarding
1596
1602
  this.addChildViewEventForwarding(view);
1597
1603
 
@@ -1751,7 +1757,7 @@ Marionette.CompositeView = Marionette.CollectionView.extend({
1751
1757
  return itemView;
1752
1758
  },
1753
1759
 
1754
- // Serialize the collection for the view.
1760
+ // Serialize the collection for the view.
1755
1761
  // You can override the `serializeData` method in your own view
1756
1762
  // definition, to provide custom serialization for your view's data.
1757
1763
  serializeData: function(){
@@ -1775,7 +1781,7 @@ Marionette.CompositeView = Marionette.CollectionView.extend({
1775
1781
  this.triggerBeforeRender();
1776
1782
  var html = this.renderModel();
1777
1783
  this.$el.html(html);
1778
- // the ui bindings is done here and not at the end of render since they
1784
+ // the ui bindings is done here and not at the end of render since they
1779
1785
  // will not be available until after the model is rendered, but should be
1780
1786
  // available before the collection is rendered.
1781
1787
  this.bindUIElements();
@@ -1860,7 +1866,7 @@ Marionette.CompositeView = Marionette.CollectionView.extend({
1860
1866
  // Used for composite view management and sub-application areas.
1861
1867
  Marionette.Layout = Marionette.ItemView.extend({
1862
1868
  regionType: Marionette.Region,
1863
-
1869
+
1864
1870
  // Ensure the regions are available when the `initialize` method
1865
1871
  // is called.
1866
1872
  constructor: function (options) {
@@ -1868,7 +1874,7 @@ Marionette.Layout = Marionette.ItemView.extend({
1868
1874
 
1869
1875
  this._firstRender = true;
1870
1876
  this._initializeRegions(options);
1871
-
1877
+
1872
1878
  Marionette.ItemView.call(this, options);
1873
1879
  },
1874
1880
 
@@ -1883,11 +1889,11 @@ Marionette.Layout = Marionette.ItemView.extend({
1883
1889
  // reset the regions
1884
1890
  this._firstRender = false;
1885
1891
  } else if (this.isClosed){
1886
- // a previously closed layout means we need to
1892
+ // a previously closed layout means we need to
1887
1893
  // completely re-initialize the regions
1888
1894
  this._initializeRegions();
1889
1895
  } else {
1890
- // If this is not the first render call, then we need to
1896
+ // If this is not the first render call, then we need to
1891
1897
  // re-initializing the `el` for each region
1892
1898
  this._reInitializeRegions();
1893
1899
  }
@@ -1936,7 +1942,7 @@ Marionette.Layout = Marionette.ItemView.extend({
1936
1942
  },
1937
1943
 
1938
1944
  // Internal method to initialize the regions that have been defined in a
1939
- // `regions` attribute on this layout.
1945
+ // `regions` attribute on this layout.
1940
1946
  _initializeRegions: function (options) {
1941
1947
  var regions;
1942
1948
  this._initRegionManager();
@@ -1987,7 +1993,7 @@ Marionette.Layout = Marionette.ItemView.extend({
1987
1993
  //
1988
1994
  // Configure an AppRouter with `appRoutes`.
1989
1995
  //
1990
- // App routers can only take one `controller` object.
1996
+ // App routers can only take one `controller` object.
1991
1997
  // It is recommended that you divide your controller
1992
1998
  // objects in to smaller pieces of related functionality
1993
1999
  // and have multiple routers / controllers, instead of
@@ -2011,8 +2017,11 @@ Marionette.AppRouter = Backbone.Router.extend({
2011
2017
  // Internal method to process the `appRoutes` for the
2012
2018
  // router, and turn them in to routes that trigger the
2013
2019
  // specified method on the specified `controller`.
2014
- processAppRoutes: function(controller, appRoutes){
2015
- _.each(appRoutes, function(methodName, route) {
2020
+ processAppRoutes: function(controller, appRoutes) {
2021
+ var routeNames = _.keys(appRoutes).reverse(); // Backbone requires reverted order of routes
2022
+
2023
+ _.each(routeNames, function(route) {
2024
+ var methodName = appRoutes[route];
2016
2025
  var method = controller[methodName];
2017
2026
 
2018
2027
  if (!method) {
@@ -2075,7 +2084,7 @@ _.extend(Marionette.Application.prototype, Backbone.Events, {
2075
2084
  this.triggerMethod("start", options);
2076
2085
  },
2077
2086
 
2078
- // Add regions to your app.
2087
+ // Add regions to your app.
2079
2088
  // Accepts a hash of named strings or Region objects
2080
2089
  // addRegions({something: "#someRegion"})
2081
2090
  // addRegions({something: Region.extend({el: "#someRegion"}) });
@@ -2280,7 +2289,7 @@ _.extend(Marionette.Module, {
2280
2289
  },
2281
2290
 
2282
2291
  _addModuleDefinition: function(parentModule, module, def, args){
2283
- var fn;
2292
+ var fn;
2284
2293
  var startWithParent;
2285
2294
 
2286
2295
  if (_.isFunction(def)){
@@ -2292,7 +2301,7 @@ _.extend(Marionette.Module, {
2292
2301
  // if an object is supplied
2293
2302
  fn = def.define;
2294
2303
  startWithParent = def.startWithParent;
2295
-
2304
+
2296
2305
  } else {
2297
2306
  // if nothing is supplied
2298
2307
  startWithParent = true;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marionette-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-03-25 00:00:00.000000000 Z
13
+ date: 2013-04-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  version: 1.3.6
62
62
  requirements: []
63
63
  rubyforge_project:
64
- rubygems_version: 1.8.25
64
+ rubygems_version: 1.8.23
65
65
  signing_key:
66
66
  specification_version: 3
67
67
  summary: Backbone.Marionette for Rails