luca 0.9.4 → 0.9.6
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.
- data/CHANGELOG +41 -1
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/README.md +5 -0
- data/Rakefile +4 -0
- data/assets/javascripts/dependencies/underscore-min.js +5 -31
- data/assets/javascripts/luca-templates.js +1 -0
- data/assets/javascripts/luca-ui-base.coffee +1 -1
- data/assets/javascripts/luca-ui-development-tools.coffee +1 -1
- data/assets/javascripts/luca-ui-full.js +1 -1
- data/assets/javascripts/luca-ui-spec.coffee +1 -1
- data/assets/javascripts/luca-ui.js +3 -0
- data/assets/javascripts/luca/index.coffee +1 -0
- data/lib/generators/luca/application/application_generator.rb +71 -0
- data/lib/generators/luca/application/templates/controller.rb +6 -0
- data/lib/generators/luca/application/templates/index.html.erb +7 -0
- data/lib/generators/luca/application/templates/index.html.haml +6 -0
- data/lib/generators/luca/application/templates/javascripts/application.js +28 -0
- data/lib/generators/luca/application/templates/javascripts/application.js.coffee +20 -0
- data/lib/generators/luca/application/templates/javascripts/config.js +15 -0
- data/lib/generators/luca/application/templates/javascripts/config.js.coffee +9 -0
- data/lib/generators/luca/application/templates/javascripts/dependencies.js +5 -0
- data/lib/generators/luca/application/templates/javascripts/dependencies.js.coffee +5 -0
- data/lib/generators/luca/application/templates/javascripts/index.js +9 -0
- data/lib/generators/luca/application/templates/javascripts/index.js.coffee +9 -0
- data/lib/generators/luca/application/templates/javascripts/main.js +8 -0
- data/lib/generators/luca/application/templates/javascripts/main.js.coffee +3 -0
- data/lib/generators/luca/application/templates/javascripts/main.jst.ejs +1 -0
- data/lib/generators/luca/application/templates/javascripts/router.js +12 -0
- data/lib/generators/luca/application/templates/javascripts/router.js.coffee +7 -0
- data/lib/luca/rails/version.rb +1 -1
- data/lib/luca/template.rb +1 -1
- data/spec/components/collection_view_spec.coffee +37 -0
- data/spec/components/multi_collection_view_spec.coffee +5 -0
- data/spec/components/table_view_spec.coffee +17 -0
- data/spec/core/container_spec.coffee +112 -5
- data/spec/core/model_spec.coffee +21 -3
- data/spec/define_spec.coffee +19 -0
- data/spec/mixin_spec.coffee +49 -0
- data/src/components/application.coffee +33 -19
- data/src/components/collection_view.coffee +109 -38
- data/src/components/fields/checkbox_field.coffee +2 -2
- data/src/components/fields/file_upload_field.coffee +0 -3
- data/src/components/fields/hidden_field.coffee +0 -3
- data/src/components/fields/label_field.coffee +1 -4
- data/src/components/fields/select_field.coffee +6 -6
- data/src/components/fields/text_area_field.coffee +1 -0
- data/src/components/fields/text_field.coffee +4 -0
- data/src/components/fields/type_ahead_field.coffee +5 -9
- data/src/components/form_view.coffee +2 -0
- data/src/components/index.coffee +1 -0
- data/src/components/multi_collection_view.coffee +94 -0
- data/src/components/pagination_control.coffee +100 -0
- data/src/components/table_view.coffee +62 -0
- data/src/containers/card_view.coffee +44 -11
- data/src/containers/panel_toolbar.coffee +88 -82
- data/src/containers/tab_view.coffee +3 -3
- data/src/containers/viewport.coffee +10 -4
- data/src/core/collection.coffee +11 -4
- data/src/core/container.coffee +189 -113
- data/src/core/field.coffee +13 -10
- data/src/core/model.coffee +23 -27
- data/src/core/registry.coffee +48 -35
- data/src/core/view.coffee +60 -140
- data/src/define.coffee +91 -19
- data/src/framework.coffee +10 -8
- data/src/index.coffee +23 -0
- data/src/managers/collection_manager.coffee +24 -8
- data/src/modules/application_event_bindings.coffee +19 -0
- data/src/modules/collection_event_bindings.coffee +26 -0
- data/src/modules/deferrable.coffee +3 -1
- data/src/modules/dom_helpers.coffee +49 -0
- data/src/modules/enhanced_properties.coffee +23 -0
- data/src/modules/filterable.coffee +60 -0
- data/src/modules/grid_layout.coffee +15 -0
- data/src/modules/{load_mask.coffee → loadmaskable.coffee} +10 -4
- data/src/modules/modal_view.coffee +38 -0
- data/src/modules/paginatable.coffee +79 -0
- data/src/modules/state_model.coffee +16 -0
- data/src/modules/templating.coffee +8 -0
- data/src/plugins/events.coffee +30 -2
- data/src/templates/components/bootstrap_form_controls.jst.ejs +10 -0
- data/src/templates/components/collection_loader_view.jst.ejs +6 -0
- data/src/templates/components/form_alert.jst.ejs +4 -0
- data/src/templates/components/grid_view.jst.ejs +11 -0
- data/src/templates/components/grid_view_empty_text.jst.ejs +3 -0
- data/src/templates/components/load_mask.jst.ejs +5 -0
- data/src/templates/components/nav_bar.jst.ejs +4 -0
- data/src/templates/components/pagination.jst.ejs +10 -0
- data/src/templates/containers/basic.jst.ejs +1 -0
- data/src/templates/containers/tab_selector_container.jst.ejs +12 -0
- data/src/templates/containers/tab_view.jst.ejs +2 -0
- data/src/templates/containers/toolbar_wrapper.jst.ejs +1 -0
- data/src/templates/fields/button_field.jst.ejs +2 -0
- data/src/templates/fields/button_field_link.jst.ejs +6 -0
- data/src/templates/fields/checkbox_array.jst.ejs +4 -0
- data/src/templates/fields/checkbox_array_item.jst.ejs +3 -0
- data/src/templates/fields/checkbox_field.jst.ejs +10 -0
- data/src/templates/fields/file_upload_field.jst.ejs +10 -0
- data/src/templates/fields/hidden_field.jst.ejs +1 -0
- data/src/templates/fields/select_field.jst.ejs +11 -0
- data/src/templates/fields/text_area_field.jst.ejs +11 -0
- data/src/templates/fields/text_field.jst.ejs +16 -0
- data/src/templates/table_view.jst.ejs +4 -0
- data/src/tools/console.coffee +51 -21
- data/src/util.coffee +17 -4
- data/vendor/assets/javascripts/luca-ui-base.js +3288 -613
- data/vendor/assets/javascripts/luca-ui-development-tools.js +49 -21
- data/vendor/assets/javascripts/luca-ui-development-tools.min.js +1 -1
- data/vendor/assets/javascripts/luca-ui-full.js +1704 -554
- data/vendor/assets/javascripts/luca-ui-full.min.js +7 -6
- data/vendor/assets/javascripts/luca-ui-spec.js +1783 -830
- data/vendor/assets/javascripts/luca-ui-templates.js +92 -0
- data/vendor/assets/javascripts/luca-ui.js +1694 -523
- data/vendor/assets/javascripts/luca-ui.min.js +4 -4
- metadata +69 -31
- data/assets/javascripts/luca-ui.coffee +0 -3
- data/src/luca.coffee +0 -22
- data/src/templates/components/bootstrap_form_controls.luca +0 -7
- data/src/templates/components/collection_loader_view.luca +0 -5
- data/src/templates/components/form_alert +0 -0
- data/src/templates/components/form_alert.luca +0 -3
- data/src/templates/components/grid_view.luca +0 -7
- data/src/templates/components/grid_view_empty_text.luca +0 -3
- data/src/templates/components/load_mask.luca +0 -3
- data/src/templates/components/nav_bar.luca +0 -2
- data/src/templates/containers/basic.luca +0 -1
- data/src/templates/containers/tab_selector_container.luca +0 -8
- data/src/templates/containers/tab_view.luca +0 -2
- data/src/templates/containers/toolbar_wrapper.luca +0 -1
- data/src/templates/fields/button_field.luca +0 -2
- data/src/templates/fields/button_field_link.luca +0 -5
- data/src/templates/fields/checkbox_array.luca +0 -4
- data/src/templates/fields/checkbox_array_item.luca +0 -4
- data/src/templates/fields/checkbox_field.luca +0 -9
- data/src/templates/fields/file_upload_field.luca +0 -8
- data/src/templates/fields/hidden_field.luca +0 -1
- data/src/templates/fields/select_field.luca +0 -8
- data/src/templates/fields/text_area_field.luca +0 -8
- data/src/templates/fields/text_field.luca +0 -17
- data/src/templates/sample/contents.luca +0 -1
- data/src/templates/sample/welcome.luca +0 -1
- data/vendor/assets/javascripts/luca-spec-dependencies.js +0 -6135
- data/vendor/assets/javascripts/luca-ui-development-dependencies.js +0 -12845
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
this.JST || (this.JST = {});
|
|
3
|
+
this.JST["luca-src/templates/components/bootstrap_form_controls"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="btn-group form-actions">\n <a class="btn btn-primary submit-button">\n <i class="icon icon-ok icon-white"></i>\n Save Changes\n </a>\n <a class="btn reset-button cancel-button">\n <i class="icon icon-remove"></i>\n Cancel\n </a>\n</div>\n');}return __p.join('');};
|
|
4
|
+
}).call(this);
|
|
5
|
+
(function() {
|
|
6
|
+
this.JST || (this.JST = {});
|
|
7
|
+
this.JST["luca-src/templates/components/collection_loader_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div id="progress-modal" class="modal" style="display: none">\n <div class="progress progress-info progress-striped active">\n <div class="bar" style="width:0%;"></div>\n </div>\n <div class="message">Initializing...</div>\n</div>\n');}return __p.join('');};
|
|
8
|
+
}).call(this);
|
|
9
|
+
(function() {
|
|
10
|
+
this.JST || (this.JST = {});
|
|
11
|
+
this.JST["luca-src/templates/components/form_alert"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="', className ,'">\n <a class="close" href="#" data-dismiss="alert">x</a>\n ', message ,'\n</div>\n');}return __p.join('');};
|
|
12
|
+
}).call(this);
|
|
13
|
+
(function() {
|
|
14
|
+
this.JST || (this.JST = {});
|
|
15
|
+
this.JST["luca-src/templates/components/grid_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="luca-ui-g-view-wrapper">\n <div class="g-view-header"></div>\n <div class="luca-ui-g-view-body">\n <table class="luca-ui-g-view scrollable-table" width="100%" cellpadding=0 cellspacing=0>\n <thead class="fixed"></thead>\n <tbody class="scrollable"></tbody>\n <tfoot></tfoot>\n </table>\n </div>\n <div class="luca-ui-g-view-header"></div>\n</div>\n');}return __p.join('');};
|
|
16
|
+
}).call(this);
|
|
17
|
+
(function() {
|
|
18
|
+
this.JST || (this.JST = {});
|
|
19
|
+
this.JST["luca-src/templates/components/grid_view_empty_text"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="empty-text empty-text-wrapper">\n <p>', text ,'</p>\n</div>\n');}return __p.join('');};
|
|
20
|
+
}).call(this);
|
|
21
|
+
(function() {
|
|
22
|
+
this.JST || (this.JST = {});
|
|
23
|
+
this.JST["luca-src/templates/components/load_mask"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="load-mask">\n <div class="progress progress-striped active">\n <div class="bar" style="width:0%"></div>\n </div>\n</div>\n');}return __p.join('');};
|
|
24
|
+
}).call(this);
|
|
25
|
+
(function() {
|
|
26
|
+
this.JST || (this.JST = {});
|
|
27
|
+
this.JST["luca-src/templates/components/nav_bar"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="navbar-inner">\n <div class="luca-ui-navbar-body container">\n </div>\n</div>\n');}return __p.join('');};
|
|
28
|
+
}).call(this);
|
|
29
|
+
(function() {
|
|
30
|
+
this.JST || (this.JST = {});
|
|
31
|
+
this.JST["luca-src/templates/components/pagination"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="pagination">\n <a class="btn previous">\n <i class="icon icon-chevron-left"></i>\n </a>\n <div class="pagination-group">\n </div>\n <a class="btn next">\n <i class="icon icon-chevron-right"></i>\n </a>\n</div>\n');}return __p.join('');};
|
|
32
|
+
}).call(this);
|
|
33
|
+
(function() {
|
|
34
|
+
this.JST || (this.JST = {});
|
|
35
|
+
this.JST["luca-src/templates/containers/basic"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div id="', id ,'" class="', classes ,'" style="', style ,'"></div>\n');}return __p.join('');};
|
|
36
|
+
}).call(this);
|
|
37
|
+
(function() {
|
|
38
|
+
this.JST || (this.JST = {});
|
|
39
|
+
this.JST["luca-src/templates/containers/tab_selector_container"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div id="', cid ,'-tab-selector" class="tab-selector-container">\n <ul id="', cid ,'-tabs-nav" class="nav nav-tabs">\n '); for(var i = 0; i < components.length; i++ ) { __p.push('\n '); var component = components[i];__p.push('\n <li class="tab-selector" data-target="', i ,'">\n <a data-target="', i ,'">\n ', component.title ,'\n </a>\n </li>\n '); } __p.push('\n </ul>\n</div>\n');}return __p.join('');};
|
|
40
|
+
}).call(this);
|
|
41
|
+
(function() {
|
|
42
|
+
this.JST || (this.JST = {});
|
|
43
|
+
this.JST["luca-src/templates/containers/tab_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<ul id="', cid ,'-tabs-selector" class="nav ', navClass ,'"></ul>\n<div id="', cid ,'-tab-view-content" class="tab-content"></div>\n');}return __p.join('');};
|
|
44
|
+
}).call(this);
|
|
45
|
+
(function() {
|
|
46
|
+
this.JST || (this.JST = {});
|
|
47
|
+
this.JST["luca-src/templates/containers/toolbar_wrapper"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="luca-ui-toolbar-wrapper" id="', id ,'"></div>\n');}return __p.join('');};
|
|
48
|
+
}).call(this);
|
|
49
|
+
(function() {
|
|
50
|
+
this.JST || (this.JST = {});
|
|
51
|
+
this.JST["luca-src/templates/fields/button_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label> </label>\n<input style="', inputStyles ,'" class="btn ', input_class ,'" value="', input_value ,'" type="', input_type ,'" id="<%= input_id" />\n');}return __p.join('');};
|
|
52
|
+
}).call(this);
|
|
53
|
+
(function() {
|
|
54
|
+
this.JST || (this.JST = {});
|
|
55
|
+
this.JST["luca-src/templates/fields/button_field_link"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<a class="btn ', input_class ,'">\n '); if(icon_class.length) { __p.push('\n <i class="', icon_class ,'"></i>\n ', input_value ,'\n '); } __p.push('\n</a>\n');}return __p.join('');};
|
|
56
|
+
}).call(this);
|
|
57
|
+
(function() {
|
|
58
|
+
this.JST || (this.JST = {});
|
|
59
|
+
this.JST["luca-src/templates/fields/checkbox_array"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="control-group">\n <label for="', input_id ,'"><%= label =>\n <div class="controls"><div>\n</div>\n');}return __p.join('');};
|
|
60
|
+
}).call(this);
|
|
61
|
+
(function() {
|
|
62
|
+
this.JST || (this.JST = {});
|
|
63
|
+
this.JST["luca-src/templates/fields/checkbox_array_item"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for="', input_id ,'">\n <input id="', input_id ,'" type="checkbox" name="', input_name ,'" value="', value ,'" />\n</label>\n');}return __p.join('');};
|
|
64
|
+
}).call(this);
|
|
65
|
+
(function() {
|
|
66
|
+
this.JST || (this.JST = {});
|
|
67
|
+
this.JST["luca-src/templates/fields/checkbox_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for="', input_id ,'">\n ', label ,'\n <input type="checkbox" name="', input_name ,'" value="', input_value ,'" style="', inputStyles ,'" />\n</label>\n\n'); if(helperText) { __p.push('\n<p class="helper-text help-block">\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');};
|
|
68
|
+
}).call(this);
|
|
69
|
+
(function() {
|
|
70
|
+
this.JST || (this.JST = {});
|
|
71
|
+
this.JST["luca-src/templates/fields/file_upload_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for="', input_id ,'">\n ', label ,'\n <input type="file" name="', input_name ,'" value="', input_value ,'" style="', inputStyles ,'" />\n</label>\n\n'); if(helperText) { __p.push('\n<p class="helper-text help-block">\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');};
|
|
72
|
+
}).call(this);
|
|
73
|
+
(function() {
|
|
74
|
+
this.JST || (this.JST = {});
|
|
75
|
+
this.JST["luca-src/templates/fields/hidden_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push(' <input type="hidden" name="', input_name ,'" value="', input_value ,'" style="', inputStyles ,'" />\n');}return __p.join('');};
|
|
76
|
+
}).call(this);
|
|
77
|
+
(function() {
|
|
78
|
+
this.JST || (this.JST = {});
|
|
79
|
+
this.JST["luca-src/templates/fields/select_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for="', input_id ,'">\n ', label ,'\n</label>\n<div class="controls">\n <select name="', input_name ,'" value="', input_value ,'" style="', inputStyles ,'" ></select>\n '); if(helperText) { __p.push('\n <p class="helper-text help-block">\n ', helperText ,'\n </p>\n '); } __p.push('\n</div>\n');}return __p.join('');};
|
|
80
|
+
}).call(this);
|
|
81
|
+
(function() {
|
|
82
|
+
this.JST || (this.JST = {});
|
|
83
|
+
this.JST["luca-src/templates/fields/text_area_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for="', input_id ,'">\n ', label ,'\n</label>\n<div class="controls">\n <textarea name="', input_name ,'" style="', inputStyles ,'" >', input_value ,'</textarea>\n '); if(helperText) { __p.push('\n <p class="helper-text help-block">\n ', helperText ,'\n </p>\n '); } __p.push('\n</div>\n');}return __p.join('');};
|
|
84
|
+
}).call(this);
|
|
85
|
+
(function() {
|
|
86
|
+
this.JST || (this.JST = {});
|
|
87
|
+
this.JST["luca-src/templates/fields/text_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push(''); if(typeof(label)!=="undefined" && (typeof(hideLabel) !== "undefined" && !hideLabel) || (typeof(hideLabel)==="undefined")) {__p.push('\n<label class="control-label" for="', input_id ,'">', label ,'</label>\n'); } __p.push('\n\n<div class="controls">\n'); if( typeof(addOn) !== "undefined" ) { __p.push('\n <span class="add-on">', addOn ,'</span>\n'); } __p.push('\n<input type="text" name="', input_name ,'" style="', inputStyles ,'" value="', input_value ,'" />\n'); if(helperText) { __p.push('\n<p class="helper-text help-block">\n ', helperText ,'\n</p>\n'); } __p.push('\n\n</div>\n');}return __p.join('');};
|
|
88
|
+
}).call(this);
|
|
89
|
+
(function() {
|
|
90
|
+
this.JST || (this.JST = {});
|
|
91
|
+
this.JST["luca-src/templates/table_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<thead></thead>\n<tbody class="table-body"></tbody>\n<tfoot></tfoot>\n<caption></caption>\n');}return __p.join('');};
|
|
92
|
+
}).call(this);
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
_.extend(Luca, {
|
|
21
|
-
VERSION: "0.9.
|
|
21
|
+
VERSION: "0.9.6",
|
|
22
22
|
core: {},
|
|
23
23
|
containers: {},
|
|
24
24
|
components: {},
|
|
@@ -26,18 +26,21 @@
|
|
|
26
26
|
util: {},
|
|
27
27
|
fields: {},
|
|
28
28
|
registry: {},
|
|
29
|
-
options: {}
|
|
29
|
+
options: {},
|
|
30
|
+
config: {}
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
_.extend(Luca, Backbone.Events);
|
|
33
34
|
|
|
34
|
-
Luca.autoRegister = true;
|
|
35
|
+
Luca.autoRegister = Luca.config.autoRegister = true;
|
|
35
36
|
|
|
36
|
-
Luca.developmentMode = false;
|
|
37
|
+
Luca.developmentMode = Luca.config.developmentMode = false;
|
|
37
38
|
|
|
38
|
-
Luca.enableGlobalObserver = false;
|
|
39
|
+
Luca.enableGlobalObserver = Luca.config.enableGlobalObserver = false;
|
|
39
40
|
|
|
40
|
-
Luca.enableBootstrap = true;
|
|
41
|
+
Luca.enableBootstrap = Luca.config.enableBootstrap = true;
|
|
42
|
+
|
|
43
|
+
Luca.config.enhancedViewProperties = true;
|
|
41
44
|
|
|
42
45
|
Luca.keys = {
|
|
43
46
|
ENTER: 13,
|
|
@@ -55,8 +58,8 @@
|
|
|
55
58
|
return memo;
|
|
56
59
|
}, {});
|
|
57
60
|
|
|
58
|
-
Luca.find = function() {
|
|
59
|
-
return;
|
|
61
|
+
Luca.find = function(el) {
|
|
62
|
+
return Luca($(el).data('luca-id'));
|
|
60
63
|
};
|
|
61
64
|
|
|
62
65
|
Luca.supportsEvents = Luca.supportsBackboneEvents = function(obj) {
|
|
@@ -228,17 +231,133 @@
|
|
|
228
231
|
|
|
229
232
|
}).call(this);
|
|
230
233
|
(function() {
|
|
231
|
-
|
|
234
|
+
this.JST || (this.JST = {});
|
|
235
|
+
this.JST["luca-src/templates/components/bootstrap_form_controls"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="btn-group form-actions">\n <a class="btn btn-primary submit-button">\n <i class="icon icon-ok icon-white"></i>\n Save Changes\n </a>\n <a class="btn reset-button cancel-button">\n <i class="icon icon-remove"></i>\n Cancel\n </a>\n</div>\n');}return __p.join('');};
|
|
236
|
+
}).call(this);
|
|
237
|
+
(function() {
|
|
238
|
+
this.JST || (this.JST = {});
|
|
239
|
+
this.JST["luca-src/templates/components/collection_loader_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div id="progress-modal" class="modal" style="display: none">\n <div class="progress progress-info progress-striped active">\n <div class="bar" style="width:0%;"></div>\n </div>\n <div class="message">Initializing...</div>\n</div>\n');}return __p.join('');};
|
|
240
|
+
}).call(this);
|
|
241
|
+
(function() {
|
|
242
|
+
this.JST || (this.JST = {});
|
|
243
|
+
this.JST["luca-src/templates/components/form_alert"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="', className ,'">\n <a class="close" href="#" data-dismiss="alert">x</a>\n ', message ,'\n</div>\n');}return __p.join('');};
|
|
244
|
+
}).call(this);
|
|
245
|
+
(function() {
|
|
246
|
+
this.JST || (this.JST = {});
|
|
247
|
+
this.JST["luca-src/templates/components/grid_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="luca-ui-g-view-wrapper">\n <div class="g-view-header"></div>\n <div class="luca-ui-g-view-body">\n <table class="luca-ui-g-view scrollable-table" width="100%" cellpadding=0 cellspacing=0>\n <thead class="fixed"></thead>\n <tbody class="scrollable"></tbody>\n <tfoot></tfoot>\n </table>\n </div>\n <div class="luca-ui-g-view-header"></div>\n</div>\n');}return __p.join('');};
|
|
248
|
+
}).call(this);
|
|
249
|
+
(function() {
|
|
250
|
+
this.JST || (this.JST = {});
|
|
251
|
+
this.JST["luca-src/templates/components/grid_view_empty_text"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="empty-text empty-text-wrapper">\n <p>', text ,'</p>\n</div>\n');}return __p.join('');};
|
|
252
|
+
}).call(this);
|
|
253
|
+
(function() {
|
|
254
|
+
this.JST || (this.JST = {});
|
|
255
|
+
this.JST["luca-src/templates/components/load_mask"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="load-mask">\n <div class="progress progress-striped active">\n <div class="bar" style="width:0%"></div>\n </div>\n</div>\n');}return __p.join('');};
|
|
256
|
+
}).call(this);
|
|
257
|
+
(function() {
|
|
258
|
+
this.JST || (this.JST = {});
|
|
259
|
+
this.JST["luca-src/templates/components/nav_bar"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="navbar-inner">\n <div class="luca-ui-navbar-body container">\n </div>\n</div>\n');}return __p.join('');};
|
|
260
|
+
}).call(this);
|
|
261
|
+
(function() {
|
|
262
|
+
this.JST || (this.JST = {});
|
|
263
|
+
this.JST["luca-src/templates/components/pagination"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="pagination">\n <a class="btn previous">\n <i class="icon icon-chevron-left"></i>\n </a>\n <div class="pagination-group">\n </div>\n <a class="btn next">\n <i class="icon icon-chevron-right"></i>\n </a>\n</div>\n');}return __p.join('');};
|
|
264
|
+
}).call(this);
|
|
265
|
+
(function() {
|
|
266
|
+
this.JST || (this.JST = {});
|
|
267
|
+
this.JST["luca-src/templates/containers/basic"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div id="', id ,'" class="', classes ,'" style="', style ,'"></div>\n');}return __p.join('');};
|
|
268
|
+
}).call(this);
|
|
269
|
+
(function() {
|
|
270
|
+
this.JST || (this.JST = {});
|
|
271
|
+
this.JST["luca-src/templates/containers/tab_selector_container"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div id="', cid ,'-tab-selector" class="tab-selector-container">\n <ul id="', cid ,'-tabs-nav" class="nav nav-tabs">\n '); for(var i = 0; i < components.length; i++ ) { __p.push('\n '); var component = components[i];__p.push('\n <li class="tab-selector" data-target="', i ,'">\n <a data-target="', i ,'">\n ', component.title ,'\n </a>\n </li>\n '); } __p.push('\n </ul>\n</div>\n');}return __p.join('');};
|
|
272
|
+
}).call(this);
|
|
273
|
+
(function() {
|
|
274
|
+
this.JST || (this.JST = {});
|
|
275
|
+
this.JST["luca-src/templates/containers/tab_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<ul id="', cid ,'-tabs-selector" class="nav ', navClass ,'"></ul>\n<div id="', cid ,'-tab-view-content" class="tab-content"></div>\n');}return __p.join('');};
|
|
276
|
+
}).call(this);
|
|
277
|
+
(function() {
|
|
278
|
+
this.JST || (this.JST = {});
|
|
279
|
+
this.JST["luca-src/templates/containers/toolbar_wrapper"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="luca-ui-toolbar-wrapper" id="', id ,'"></div>\n');}return __p.join('');};
|
|
280
|
+
}).call(this);
|
|
281
|
+
(function() {
|
|
282
|
+
this.JST || (this.JST = {});
|
|
283
|
+
this.JST["luca-src/templates/fields/button_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label> </label>\n<input style="', inputStyles ,'" class="btn ', input_class ,'" value="', input_value ,'" type="', input_type ,'" id="<%= input_id" />\n');}return __p.join('');};
|
|
284
|
+
}).call(this);
|
|
285
|
+
(function() {
|
|
286
|
+
this.JST || (this.JST = {});
|
|
287
|
+
this.JST["luca-src/templates/fields/button_field_link"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<a class="btn ', input_class ,'">\n '); if(icon_class.length) { __p.push('\n <i class="', icon_class ,'"></i>\n ', input_value ,'\n '); } __p.push('\n</a>\n');}return __p.join('');};
|
|
288
|
+
}).call(this);
|
|
289
|
+
(function() {
|
|
290
|
+
this.JST || (this.JST = {});
|
|
291
|
+
this.JST["luca-src/templates/fields/checkbox_array"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="control-group">\n <label for="', input_id ,'"><%= label =>\n <div class="controls"><div>\n</div>\n');}return __p.join('');};
|
|
292
|
+
}).call(this);
|
|
293
|
+
(function() {
|
|
294
|
+
this.JST || (this.JST = {});
|
|
295
|
+
this.JST["luca-src/templates/fields/checkbox_array_item"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for="', input_id ,'">\n <input id="', input_id ,'" type="checkbox" name="', input_name ,'" value="', value ,'" />\n</label>\n');}return __p.join('');};
|
|
296
|
+
}).call(this);
|
|
297
|
+
(function() {
|
|
298
|
+
this.JST || (this.JST = {});
|
|
299
|
+
this.JST["luca-src/templates/fields/checkbox_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for="', input_id ,'">\n ', label ,'\n <input type="checkbox" name="', input_name ,'" value="', input_value ,'" style="', inputStyles ,'" />\n</label>\n\n'); if(helperText) { __p.push('\n<p class="helper-text help-block">\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');};
|
|
300
|
+
}).call(this);
|
|
301
|
+
(function() {
|
|
302
|
+
this.JST || (this.JST = {});
|
|
303
|
+
this.JST["luca-src/templates/fields/file_upload_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for="', input_id ,'">\n ', label ,'\n <input type="file" name="', input_name ,'" value="', input_value ,'" style="', inputStyles ,'" />\n</label>\n\n'); if(helperText) { __p.push('\n<p class="helper-text help-block">\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');};
|
|
304
|
+
}).call(this);
|
|
305
|
+
(function() {
|
|
306
|
+
this.JST || (this.JST = {});
|
|
307
|
+
this.JST["luca-src/templates/fields/hidden_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push(' <input type="hidden" name="', input_name ,'" value="', input_value ,'" style="', inputStyles ,'" />\n');}return __p.join('');};
|
|
308
|
+
}).call(this);
|
|
309
|
+
(function() {
|
|
310
|
+
this.JST || (this.JST = {});
|
|
311
|
+
this.JST["luca-src/templates/fields/select_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for="', input_id ,'">\n ', label ,'\n</label>\n<div class="controls">\n <select name="', input_name ,'" value="', input_value ,'" style="', inputStyles ,'" ></select>\n '); if(helperText) { __p.push('\n <p class="helper-text help-block">\n ', helperText ,'\n </p>\n '); } __p.push('\n</div>\n');}return __p.join('');};
|
|
312
|
+
}).call(this);
|
|
313
|
+
(function() {
|
|
314
|
+
this.JST || (this.JST = {});
|
|
315
|
+
this.JST["luca-src/templates/fields/text_area_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for="', input_id ,'">\n ', label ,'\n</label>\n<div class="controls">\n <textarea name="', input_name ,'" style="', inputStyles ,'" >', input_value ,'</textarea>\n '); if(helperText) { __p.push('\n <p class="helper-text help-block">\n ', helperText ,'\n </p>\n '); } __p.push('\n</div>\n');}return __p.join('');};
|
|
316
|
+
}).call(this);
|
|
317
|
+
(function() {
|
|
318
|
+
this.JST || (this.JST = {});
|
|
319
|
+
this.JST["luca-src/templates/fields/text_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push(''); if(typeof(label)!=="undefined" && (typeof(hideLabel) !== "undefined" && !hideLabel) || (typeof(hideLabel)==="undefined")) {__p.push('\n<label class="control-label" for="', input_id ,'">', label ,'</label>\n'); } __p.push('\n\n<div class="controls">\n'); if( typeof(addOn) !== "undefined" ) { __p.push('\n <span class="add-on">', addOn ,'</span>\n'); } __p.push('\n<input type="text" name="', input_name ,'" style="', inputStyles ,'" value="', input_value ,'" />\n'); if(helperText) { __p.push('\n<p class="helper-text help-block">\n ', helperText ,'\n</p>\n'); } __p.push('\n\n</div>\n');}return __p.join('');};
|
|
320
|
+
}).call(this);
|
|
321
|
+
(function() {
|
|
322
|
+
this.JST || (this.JST = {});
|
|
323
|
+
this.JST["luca-src/templates/table_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<thead></thead>\n<tbody class="table-body"></tbody>\n<tfoot></tfoot>\n<caption></caption>\n');}return __p.join('');};
|
|
324
|
+
}).call(this);
|
|
325
|
+
(function() {
|
|
326
|
+
var currentNamespace,
|
|
327
|
+
__slice = Array.prototype.slice;
|
|
232
328
|
|
|
233
329
|
Luca.util.resolve = function(accessor, source_object) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
330
|
+
var resolved;
|
|
331
|
+
try {
|
|
332
|
+
source_object || (source_object = window || global);
|
|
333
|
+
resolved = _(accessor.split(/\./)).inject(function(obj, key) {
|
|
334
|
+
return obj = obj != null ? obj[key] : void 0;
|
|
335
|
+
}, source_object);
|
|
336
|
+
} catch (e) {
|
|
337
|
+
console.log("Error resolving", accessor, source_object);
|
|
338
|
+
throw e;
|
|
339
|
+
}
|
|
340
|
+
return resolved;
|
|
238
341
|
};
|
|
239
342
|
|
|
240
343
|
Luca.util.nestedValue = Luca.util.resolve;
|
|
241
344
|
|
|
345
|
+
Luca.util.argumentsLogger = function(prompt) {
|
|
346
|
+
return function() {
|
|
347
|
+
return console.log(prompt, arguments);
|
|
348
|
+
};
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
Luca.util.read = function() {
|
|
352
|
+
var args, property;
|
|
353
|
+
property = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
|
354
|
+
if (_.isFunction(property)) {
|
|
355
|
+
return property.apply(this, args);
|
|
356
|
+
} else {
|
|
357
|
+
return property;
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
|
|
242
361
|
Luca.util.classify = function(string) {
|
|
243
362
|
if (string == null) string = "";
|
|
244
363
|
return _.string.camelize(_.string.capitalize(string));
|
|
@@ -385,13 +504,13 @@
|
|
|
385
504
|
|
|
386
505
|
}).call(this);
|
|
387
506
|
(function() {
|
|
388
|
-
var DeferredBindingProxy
|
|
507
|
+
var DeferredBindingProxy,
|
|
508
|
+
__slice = Array.prototype.slice;
|
|
389
509
|
|
|
390
510
|
DeferredBindingProxy = (function() {
|
|
391
511
|
|
|
392
512
|
function DeferredBindingProxy(object, operation, wrapWithUnderscore) {
|
|
393
|
-
var fn
|
|
394
|
-
_this = this;
|
|
513
|
+
var fn;
|
|
395
514
|
this.object = object;
|
|
396
515
|
if (wrapWithUnderscore == null) wrapWithUnderscore = true;
|
|
397
516
|
if (_.isFunction(operation)) {
|
|
@@ -403,11 +522,11 @@
|
|
|
403
522
|
throw "Must pass a function or a string representing one";
|
|
404
523
|
}
|
|
405
524
|
if (wrapWithUnderscore === true) {
|
|
406
|
-
this.fn = function() {
|
|
525
|
+
this.fn = _.bind(function() {
|
|
407
526
|
return _.defer(fn);
|
|
408
|
-
};
|
|
527
|
+
}, this.object);
|
|
409
528
|
} else {
|
|
410
|
-
this.fn = fn;
|
|
529
|
+
this.fn = _.bind(fn, this.object);
|
|
411
530
|
}
|
|
412
531
|
this;
|
|
413
532
|
}
|
|
@@ -441,15 +560,80 @@
|
|
|
441
560
|
}
|
|
442
561
|
};
|
|
443
562
|
|
|
563
|
+
Luca.EventsExt = {
|
|
564
|
+
waitUntil: function(trigger, context) {
|
|
565
|
+
return this.waitFor.call(this, trigger, context);
|
|
566
|
+
},
|
|
567
|
+
waitFor: function(trigger, context) {
|
|
568
|
+
var proxy, self;
|
|
569
|
+
self = this;
|
|
570
|
+
return proxy = {
|
|
571
|
+
on: function(target) {
|
|
572
|
+
return target.waitFor.call(target, trigger, context);
|
|
573
|
+
},
|
|
574
|
+
and: function() {
|
|
575
|
+
var fn, runList, _i, _len, _results;
|
|
576
|
+
runList = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
|
577
|
+
_results = [];
|
|
578
|
+
for (_i = 0, _len = runList.length; _i < _len; _i++) {
|
|
579
|
+
fn = runList[_i];
|
|
580
|
+
fn = _.isFunction(fn) ? fn : self[fn];
|
|
581
|
+
_results.push(self.once(trigger, fn, context));
|
|
582
|
+
}
|
|
583
|
+
return _results;
|
|
584
|
+
},
|
|
585
|
+
andThen: function() {
|
|
586
|
+
return self.and.apply(self, arguments);
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
},
|
|
590
|
+
relayEvent: function(trigger) {
|
|
591
|
+
var _this = this;
|
|
592
|
+
return {
|
|
593
|
+
on: function() {
|
|
594
|
+
var components;
|
|
595
|
+
components = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
|
596
|
+
return {
|
|
597
|
+
to: function() {
|
|
598
|
+
var component, target, targets, _i, _len, _results;
|
|
599
|
+
targets = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
|
600
|
+
_results = [];
|
|
601
|
+
for (_i = 0, _len = targets.length; _i < _len; _i++) {
|
|
602
|
+
target = targets[_i];
|
|
603
|
+
_results.push((function() {
|
|
604
|
+
var _j, _len2, _results2,
|
|
605
|
+
_this = this;
|
|
606
|
+
_results2 = [];
|
|
607
|
+
for (_j = 0, _len2 = components.length; _j < _len2; _j++) {
|
|
608
|
+
component = components[_j];
|
|
609
|
+
_results2.push(component.on(trigger, function() {
|
|
610
|
+
var args;
|
|
611
|
+
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
|
612
|
+
args.unshift(trigger);
|
|
613
|
+
return target.trigger.apply(target, args);
|
|
614
|
+
}));
|
|
615
|
+
}
|
|
616
|
+
return _results2;
|
|
617
|
+
}).call(_this));
|
|
618
|
+
}
|
|
619
|
+
return _results;
|
|
620
|
+
}
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
|
|
444
627
|
}).call(this);
|
|
445
628
|
(function() {
|
|
446
|
-
var DefineProxy
|
|
447
|
-
|
|
448
|
-
Luca.define = function(componentName) {
|
|
449
|
-
return new DefineProxy(componentName);
|
|
450
|
-
};
|
|
629
|
+
var DefineProxy,
|
|
630
|
+
__slice = Array.prototype.slice;
|
|
451
631
|
|
|
452
|
-
|
|
632
|
+
_.mixin({
|
|
633
|
+
def: Luca.component = Luca.define = Luca.register = function(componentName) {
|
|
634
|
+
return new DefineProxy(componentName);
|
|
635
|
+
}
|
|
636
|
+
});
|
|
453
637
|
|
|
454
638
|
DefineProxy = (function() {
|
|
455
639
|
|
|
@@ -457,6 +641,7 @@
|
|
|
457
641
|
var parts;
|
|
458
642
|
this.namespace = Luca.util.namespace();
|
|
459
643
|
this.componentId = this.componentName = componentName;
|
|
644
|
+
this.superClassName = 'Luca.View';
|
|
460
645
|
if (componentName.match(/\./)) {
|
|
461
646
|
this.namespaced = true;
|
|
462
647
|
parts = componentName.split('.');
|
|
@@ -486,19 +671,58 @@
|
|
|
486
671
|
return this;
|
|
487
672
|
};
|
|
488
673
|
|
|
489
|
-
DefineProxy.prototype.
|
|
490
|
-
|
|
674
|
+
DefineProxy.prototype.triggers = function() {
|
|
675
|
+
var hook, hooks, _i, _len;
|
|
676
|
+
hooks = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
|
677
|
+
_.defaults(this.properties || (this.properties = {}), {
|
|
678
|
+
hooks: []
|
|
679
|
+
});
|
|
680
|
+
for (_i = 0, _len = hooks.length; _i < _len; _i++) {
|
|
681
|
+
hook = hooks[_i];
|
|
682
|
+
this.properties.hooks.push(hook);
|
|
683
|
+
}
|
|
684
|
+
this.properties.hooks = _.uniq(this.properties.hooks);
|
|
491
685
|
return this;
|
|
492
686
|
};
|
|
493
687
|
|
|
494
|
-
DefineProxy.prototype
|
|
688
|
+
DefineProxy.prototype.includes = function() {
|
|
689
|
+
var include, includes, _i, _len;
|
|
690
|
+
includes = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
|
691
|
+
_.defaults(this.properties || (this.properties = {}), {
|
|
692
|
+
include: []
|
|
693
|
+
});
|
|
694
|
+
for (_i = 0, _len = includes.length; _i < _len; _i++) {
|
|
695
|
+
include = includes[_i];
|
|
696
|
+
this.properties.include.push(include);
|
|
697
|
+
}
|
|
698
|
+
this.properties.include = _.uniq(this.properties.include);
|
|
699
|
+
return this;
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
DefineProxy.prototype.mixesIn = function() {
|
|
703
|
+
var mixin, mixins, _i, _len;
|
|
704
|
+
mixins = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
|
705
|
+
_.defaults(this.properties || (this.properties = {}), {
|
|
706
|
+
mixins: []
|
|
707
|
+
});
|
|
708
|
+
for (_i = 0, _len = mixins.length; _i < _len; _i++) {
|
|
709
|
+
mixin = mixins[_i];
|
|
710
|
+
this.properties.mixins.push(mixin);
|
|
711
|
+
}
|
|
712
|
+
this.properties.mixins = _.uniq(this.properties.mixins);
|
|
713
|
+
return this;
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
DefineProxy.prototype.defaultProperties = function(properties) {
|
|
495
717
|
var at, componentType, _base;
|
|
718
|
+
if (properties == null) properties = {};
|
|
719
|
+
_.defaults((this.properties || (this.properties = {})), properties);
|
|
496
720
|
at = this.namespaced ? Luca.util.resolve(this.namespace, window || global) : window || global;
|
|
497
721
|
if (this.namespaced && !(at != null)) {
|
|
498
722
|
eval("(window||global)." + this.namespace + " = {}");
|
|
499
723
|
at = Luca.util.resolve(this.namespace, window || global);
|
|
500
724
|
}
|
|
501
|
-
at[this.componentId] = Luca.extend(this.superClassName, this.componentName, properties);
|
|
725
|
+
at[this.componentId] = Luca.extend(this.superClassName, this.componentName, this.properties);
|
|
502
726
|
if (Luca.autoRegister === true) {
|
|
503
727
|
if (Luca.isViewPrototype(at[this.componentId])) componentType = "view";
|
|
504
728
|
if (Luca.isCollectionPrototype(at[this.componentId])) {
|
|
@@ -507,7 +731,7 @@
|
|
|
507
731
|
componentType = "collection";
|
|
508
732
|
}
|
|
509
733
|
if (Luca.isModelPrototype(at[this.componentId])) componentType = "model";
|
|
510
|
-
Luca.
|
|
734
|
+
Luca.registerComponent(_.string.underscored(this.componentId), this.componentName, componentType);
|
|
511
735
|
}
|
|
512
736
|
return at[this.componentId];
|
|
513
737
|
};
|
|
@@ -516,12 +740,19 @@
|
|
|
516
740
|
|
|
517
741
|
})();
|
|
518
742
|
|
|
743
|
+
DefineProxy.prototype.behavesAs = DefineProxy.prototype.uses = DefineProxy.prototype.mixesIn;
|
|
744
|
+
|
|
745
|
+
DefineProxy.prototype.defines = DefineProxy.prototype.defaults = DefineProxy.prototype.exports = DefineProxy.prototype.defaultProperties;
|
|
746
|
+
|
|
747
|
+
DefineProxy.prototype.defaultsTo = DefineProxy.prototype.enhance = DefineProxy.prototype["with"] = DefineProxy.prototype.defaultProperties;
|
|
748
|
+
|
|
519
749
|
Luca.extend = function(superClassName, childName, properties) {
|
|
520
|
-
var definition,
|
|
750
|
+
var definition, include, superClass, _i, _len, _ref;
|
|
521
751
|
if (properties == null) properties = {};
|
|
522
752
|
superClass = Luca.util.resolve(superClassName, window || global);
|
|
753
|
+
superClass.__initializers || (superClass.__initializers = []);
|
|
523
754
|
if (!_.isFunction(superClass != null ? superClass.extend : void 0)) {
|
|
524
|
-
throw "" + superClassName + " is not a valid component to extend from";
|
|
755
|
+
throw "Error defining " + childName + ". " + superClassName + " is not a valid component to extend from";
|
|
525
756
|
}
|
|
526
757
|
properties.displayName = childName;
|
|
527
758
|
properties._superClass = function() {
|
|
@@ -530,48 +761,128 @@
|
|
|
530
761
|
};
|
|
531
762
|
properties._super = function(method, context, args) {
|
|
532
763
|
var _ref;
|
|
764
|
+
if (context == null) context = this;
|
|
765
|
+
if (args == null) args = [];
|
|
533
766
|
return (_ref = this._superClass().prototype[method]) != null ? _ref.apply(context, args) : void 0;
|
|
534
767
|
};
|
|
535
768
|
definition = superClass.extend(properties);
|
|
536
769
|
if (_.isArray(properties != null ? properties.include : void 0)) {
|
|
537
770
|
_ref = properties.include;
|
|
538
771
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
539
|
-
|
|
540
|
-
if (_.isString(
|
|
541
|
-
_.extend(definition.prototype,
|
|
772
|
+
include = _ref[_i];
|
|
773
|
+
if (_.isString(include)) include = Luca.util.resolve(include);
|
|
774
|
+
_.extend(definition.prototype, include);
|
|
542
775
|
}
|
|
543
776
|
}
|
|
544
777
|
return definition;
|
|
545
778
|
};
|
|
546
779
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
780
|
+
Luca.mixin = function(mixinName) {
|
|
781
|
+
var namespace, resolved;
|
|
782
|
+
namespace = _(Luca.mixin.namespaces).detect(function(space) {
|
|
783
|
+
var _ref;
|
|
784
|
+
return ((_ref = Luca.util.resolve(space)) != null ? _ref[mixinName] : void 0) != null;
|
|
785
|
+
});
|
|
786
|
+
namespace || (namespace = "Luca.modules");
|
|
787
|
+
resolved = Luca.util.resolve(namespace)[mixinName];
|
|
788
|
+
if (resolved == null) {
|
|
789
|
+
console.log("Could not find " + mixinName + " in ", Luca.mixin.namespaces);
|
|
790
|
+
}
|
|
791
|
+
return resolved;
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
Luca.mixin.namespaces = ["Luca.modules"];
|
|
795
|
+
|
|
796
|
+
Luca.mixin.namespace = function(namespace) {
|
|
797
|
+
Luca.mixin.namespaces.push(namespace);
|
|
798
|
+
return Luca.mixin.namespaces = _(Luca.mixin.namespaces).uniq();
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
Luca.decorate = function(componentPrototype) {
|
|
802
|
+
if (_.isString(componentPrototype)) {
|
|
803
|
+
componentPrototype = Luca.util.resolve(componentPrototype).prototype;
|
|
804
|
+
}
|
|
805
|
+
return {
|
|
806
|
+
"with": function(mixin) {
|
|
807
|
+
var mixinDefinition, mixinPrivates, sanitized, superclassMixins, _ref;
|
|
808
|
+
mixinDefinition = Luca.mixin(mixin);
|
|
809
|
+
mixinPrivates = _(mixinDefinition).chain().keys().select(function(key) {
|
|
810
|
+
return ("" + key).match(/^__/);
|
|
811
|
+
});
|
|
812
|
+
sanitized = _(mixinDefinition).omit(mixinPrivates.value());
|
|
813
|
+
_.extend(componentPrototype, sanitized);
|
|
814
|
+
if (mixinDefinition != null) {
|
|
815
|
+
if ((_ref = mixinDefinition.__included) != null) {
|
|
816
|
+
_ref.call(mixinDefinition, mixin);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
superclassMixins = componentPrototype._superClass().prototype.mixins;
|
|
820
|
+
componentPrototype.mixins || (componentPrototype.mixins = []);
|
|
821
|
+
componentPrototype.mixins.push(mixin);
|
|
822
|
+
componentPrototype.mixins = componentPrototype.mixins.concat(superclassMixins);
|
|
823
|
+
componentPrototype.mixins = _(componentPrototype.mixins).chain().uniq().compact().value();
|
|
824
|
+
return componentPrototype;
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
};
|
|
828
|
+
|
|
829
|
+
}).call(this);
|
|
830
|
+
(function() {
|
|
831
|
+
|
|
832
|
+
Luca.modules.ApplicationEventBindings = {
|
|
833
|
+
__initializer: function() {
|
|
834
|
+
var app, eventTrigger, handler, _len, _ref, _ref2, _results;
|
|
835
|
+
if (_.isEmpty(this.applicationEvents)) return;
|
|
836
|
+
app = this.app;
|
|
837
|
+
if (_.isString(app) || _.isUndefined(app)) {
|
|
838
|
+
app = (_ref = Luca.Application) != null ? typeof _ref.get === "function" ? _ref.get(app) : void 0 : void 0;
|
|
839
|
+
}
|
|
840
|
+
if (!Luca.supportsEvents(app)) {
|
|
841
|
+
throw "Error binding to the application object on " + (this.name || this.cid);
|
|
842
|
+
}
|
|
843
|
+
_ref2 = this.applicationEvents;
|
|
844
|
+
_results = [];
|
|
845
|
+
for (handler = 0, _len = _ref2.length; handler < _len; handler++) {
|
|
846
|
+
eventTrigger = _ref2[handler];
|
|
847
|
+
if (_.isString(handler)) handler = this[handler];
|
|
848
|
+
if (!_.isFunction(handler)) {
|
|
849
|
+
throw "Error registering application event " + eventTrigger + " on " + (this.name || this.cid);
|
|
850
|
+
}
|
|
851
|
+
_results.push(app.on(eventTrigger, handler));
|
|
852
|
+
}
|
|
853
|
+
return _results;
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
|
|
857
|
+
}).call(this);
|
|
858
|
+
(function() {
|
|
859
|
+
|
|
860
|
+
Luca.modules.CollectionEventBindings = {
|
|
861
|
+
__initializer: function() {
|
|
862
|
+
var collection, eventTrigger, handler, key, manager, signature, _ref, _ref2, _results;
|
|
863
|
+
if (_.isEmpty(this.collectionEvents)) return;
|
|
864
|
+
manager = this.collectionManager || Luca.CollectionManager.get();
|
|
865
|
+
_ref = this.collectionEvents;
|
|
866
|
+
_results = [];
|
|
867
|
+
for (signature in _ref) {
|
|
868
|
+
handler = _ref[signature];
|
|
869
|
+
_ref2 = signature.split(" "), key = _ref2[0], eventTrigger = _ref2[1];
|
|
870
|
+
collection = manager.getOrCreate(key);
|
|
871
|
+
if (!collection) throw "Could not find collection specified by " + key;
|
|
872
|
+
if (_.isString(handler)) handler = this[handler];
|
|
873
|
+
if (!_.isFunction(handler)) throw "invalid collectionEvents configuration";
|
|
874
|
+
try {
|
|
875
|
+
_results.push(collection.on(eventTrigger, handler, collection));
|
|
876
|
+
} catch (e) {
|
|
877
|
+
console.log("Error Binding To Collection in registerCollectionEvents", this);
|
|
878
|
+
throw e;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
return _results;
|
|
882
|
+
}
|
|
883
|
+
};
|
|
550
884
|
|
|
551
885
|
}).call(this);
|
|
552
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["components/bootstrap_form_controls"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'form-actions\'>\n <a class=\'btn btn-primary submit-button\'>\n <i class=\'icon-ok icon-white\'></i>\n Save Changes\n </a>\n <a class=\'btn reset-button cancel-button\'>\n <i class=\'icon-remove\'></i>\n Cancel\n </a>\n</div>\n');}return __p.join('');}; }).call(this);
|
|
553
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["components/collection_loader_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'modal\' id=\'progress-model\' style=\'display: none;\'>\n <div class=\'progress progress-info progress-striped active\'>\n <div class=\'bar\' style=\'width: 0%;\'></div>\n </div>\n <div class=\'message\'>\n Initializing...\n </div>\n</div>\n');}return __p.join('');}; }).call(this);
|
|
554
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["components/form_alert"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'', className ,'\'>\n <a class=\'close\' data-dismiss=\'alert\' href=\'#\'>x</a>\n ', message ,'\n</div>\n');}return __p.join('');}; }).call(this);
|
|
555
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["components/grid_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'luca-ui-g-view-wrapper\'>\n <div class=\'g-view-header\'></div>\n <div class=\'luca-ui-g-view-body\'>\n <table cellpadding=\'0\' cellspacing=\'0\' class=\'luca-ui-g-view scrollable-table\' width=\'100%\'>\n <thead class=\'fixed\'></thead>\n <tbody class=\'scrollable\'></tbody>\n </table>\n </div>\n <div class=\'luca-ui-g-view-footer\'></div>\n</div>\n');}return __p.join('');}; }).call(this);
|
|
556
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["components/grid_view_empty_text"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'empty-text-wrapper\'>\n <p>\n ', text ,'\n </p>\n</div>\n');}return __p.join('');}; }).call(this);
|
|
557
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["components/load_mask"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'load-mask\'>\n <div class=\'progress progress-striped active\'>\n <div class=\'bar\' style=\'width:1%\'></div>\n </div>\n</div>\n');}return __p.join('');}; }).call(this);
|
|
558
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["components/nav_bar"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'navbar-inner\'>\n <div class=\'luca-ui-navbar-body container\'></div>\n</div>\n');}return __p.join('');}; }).call(this);
|
|
559
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["containers/basic"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'', classes ,'\' id=\'', id ,'\' style=\'', style ,'\'></div>\n');}return __p.join('');}; }).call(this);
|
|
560
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["containers/tab_selector_container"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'tab-selector-container\' id=\'', cid ,'-tab-selector\'>\n <ul class=\'nav nav-tabs\' id=\'', cid ,'-tabs-nav\'>\n '); for(var i = 0; i < components.length; i++ ) { __p.push('\n '); var component = components[i];__p.push('\n <li class=\'tab-selector\' data-target=\'', i ,'\'>\n <a data-target=\'', i ,'\'>\n ', component.title ,'\n </a>\n </li>\n '); } __p.push('\n </ul>\n</div>\n');}return __p.join('');}; }).call(this);
|
|
561
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["containers/tab_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<ul class=\'nav ', navClass ,'\' id=\'', cid ,'-tabs-selector\'></ul>\n<div class=\'tab-content\' id=\'', cid ,'-tab-view-content\'></div>\n');}return __p.join('');}; }).call(this);
|
|
562
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["containers/toolbar_wrapper"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'luca-ui-toolbar-wrapper\' id=\'', id ,'\'></div>\n');}return __p.join('');}; }).call(this);
|
|
563
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["fields/button_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label> </label>\n<input class=\'btn ', input_class ,'\' id=\'', input_id ,'\' style=\'', inputStyles ,'\' type=\'', input_type ,'\' value=\'', input_value ,'\' />\n');}return __p.join('');}; }).call(this);
|
|
564
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["fields/button_field_link"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<a class=\'btn ', input_class ,'\'>\n '); if(icon_class.length) { __p.push('\n <i class=\'', icon_class ,'\'></i>\n '); } __p.push('\n ', input_value ,'\n</a>\n');}return __p.join('');}; }).call(this);
|
|
565
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["fields/checkbox_array"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'control-group\'>\n <label for=\'', input_id ,'\'>\n ', label ,'\n </label>\n <div class=\'controls\'></div>\n</div>\n');}return __p.join('');}; }).call(this);
|
|
566
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["fields/checkbox_array_item"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n <input id=\'', input_id ,'\' name=\'', input_name ,'\' type=\'checkbox\' value=\'', value ,'\' />\n ', label ,'\n</label>\n');}return __p.join('');}; }).call(this);
|
|
567
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["fields/checkbox_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n ', label ,'\n <input name=\'', input_name ,'\' style=\'', inputStyles ,'\' type=\'checkbox\' value=\'', input_value ,'\' />\n</label>\n'); if(helperText) { __p.push('\n<p class=\'helper-text help-block\'>\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');}; }).call(this);
|
|
568
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["fields/file_upload_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n ', label ,'\n</label>\n<input id=\'', input_id ,'\' name=\'', input_name ,'\' style=\'', inputStyles ,'\' type=\'file\' />\n'); if(helperText) { __p.push('\n<p class=\'helper-text help-block\'>\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');}; }).call(this);
|
|
569
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["fields/hidden_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<input id=\'', input_id ,'\' name=\'', input_name ,'\' type=\'hidden\' value=\'', input_value ,'\' />\n');}return __p.join('');}; }).call(this);
|
|
570
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["fields/select_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n ', label ,'\n</label>\n<div class=\'controls\'>\n <select id=\'', input_id ,'\' name=\'', input_name ,'\' style=\'', inputStyles ,'\'></select>\n '); if(helperText) { __p.push('\n <p class=\'helper-text help-block\'>\n ', helperText ,'\n </p>\n '); } __p.push('\n</div>\n');}return __p.join('');}; }).call(this);
|
|
571
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["fields/text_area_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n ', label ,'\n</label>\n<textarea class=\'', input_class ,'\' id=\'', input_id ,'\' name=\'', input_name ,'\' style=\'', inputStyles ,'\'></textarea>\n'); if(helperText) { __p.push('\n<p class=\'helper-text help-block\'>\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');}; }).call(this);
|
|
572
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["fields/text_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push(''); if(typeof(label)!=="undefined" && (typeof(hideLabel) !== "undefined" && !hideLabel) || (typeof(hideLabel)==="undefined")) {__p.push('\n<label class=\'control-label\' for=\'', input_id ,'\'>\n ', label ,'\n</label>\n'); } __p.push('\n<div class=\'controls\'>\n '); if( typeof(addOn) !== "undefined" ) { __p.push('\n <span class=\'add-on\'>\n ', addOn ,'\n </span>\n '); } __p.push('\n <input class=\'', input_class ,'\' id=\'', input_id ,'\' name=\'', input_name ,'\' placeholder=\'', placeHolder ,'\' style=\'', inputStyles ,'\' type=\'text\' />\n '); if(helperText) { __p.push('\n <p class=\'helper-text help-block\'>\n ', helperText ,'\n </p>\n '); } __p.push('\n</div>\n');}return __p.join('');}; }).call(this);
|
|
573
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["sample/contents"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<p>Sample Contents</p>\n');}return __p.join('');}; }).call(this);
|
|
574
|
-
(function() {Luca.templates || (Luca.templates = {}); Luca.templates["sample/welcome"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('welcome.luca\n');}return __p.join('');}; }).call(this);
|
|
575
886
|
(function() {
|
|
576
887
|
|
|
577
888
|
Luca.modules.Deferrable = {
|
|
@@ -592,13 +903,202 @@
|
|
|
592
903
|
}
|
|
593
904
|
};
|
|
594
905
|
|
|
906
|
+
}).call(this);
|
|
907
|
+
(function() {
|
|
908
|
+
|
|
909
|
+
Luca.modules.DomHelpers = {
|
|
910
|
+
__initializer: function() {
|
|
911
|
+
var additional, additionalClasses, _i, _len, _results;
|
|
912
|
+
additionalClasses = _(this.additionalClassNames || []).clone();
|
|
913
|
+
if (this.wrapperClass != null) this.$wrap(this.wrapperClass);
|
|
914
|
+
if (_.isString(additionalClasses)) {
|
|
915
|
+
additionalClasses = additionalClasses.split(" ");
|
|
916
|
+
}
|
|
917
|
+
if (this.gridSpan) additionalClasses.push("span" + this.gridSpan);
|
|
918
|
+
if (this.gridOffset) additionalClasses.push("offset" + this.gridOffset);
|
|
919
|
+
if (this.gridRowFluid) additionalClasses.push("row-fluid");
|
|
920
|
+
if (this.gridRow) additionalClasses.push("row");
|
|
921
|
+
if (additionalClasses == null) return;
|
|
922
|
+
_results = [];
|
|
923
|
+
for (_i = 0, _len = additionalClasses.length; _i < _len; _i++) {
|
|
924
|
+
additional = additionalClasses[_i];
|
|
925
|
+
_results.push(this.$el.addClass(additional));
|
|
926
|
+
}
|
|
927
|
+
return _results;
|
|
928
|
+
},
|
|
929
|
+
$wrap: function(wrapper) {
|
|
930
|
+
if (_.isString(wrapper) && !wrapper.match(/[<>]/)) {
|
|
931
|
+
wrapper = this.make("div", {
|
|
932
|
+
"class": wrapper
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
return this.$el.wrap(wrapper);
|
|
936
|
+
},
|
|
937
|
+
$template: function(template, variables) {
|
|
938
|
+
if (variables == null) variables = {};
|
|
939
|
+
return this.$el.html(Luca.template(template, variables));
|
|
940
|
+
},
|
|
941
|
+
$html: function(content) {
|
|
942
|
+
return this.$el.html(content);
|
|
943
|
+
},
|
|
944
|
+
$append: function(content) {
|
|
945
|
+
return this.$el.append(content);
|
|
946
|
+
},
|
|
947
|
+
$attach: function() {
|
|
948
|
+
return this.$container().append(this.el);
|
|
949
|
+
},
|
|
950
|
+
$bodyEl: function() {
|
|
951
|
+
return this.$el;
|
|
952
|
+
},
|
|
953
|
+
$container: function() {
|
|
954
|
+
return $(this.container);
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
}).call(this);
|
|
959
|
+
(function() {
|
|
960
|
+
|
|
961
|
+
Luca.modules.EnhancedProperties = {
|
|
962
|
+
__initializer: function() {
|
|
963
|
+
if (Luca.config.enhancedViewProperties !== true) return;
|
|
964
|
+
if (_.isString(this.collection) && Luca.CollectionManager.get()) {
|
|
965
|
+
this.collection = Luca.CollectionManager.get().getOrCreate(this.collection);
|
|
966
|
+
}
|
|
967
|
+
if (this.template != null) this.$template(this.template, this);
|
|
968
|
+
if (_.isString(this.collectionManager)) {
|
|
969
|
+
return this.collectionManager = Luca.CollectionManager.get(this.collectionManager);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
};
|
|
973
|
+
|
|
974
|
+
}).call(this);
|
|
975
|
+
(function() {
|
|
976
|
+
var FilterModel,
|
|
977
|
+
__hasProp = Object.prototype.hasOwnProperty,
|
|
978
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
|
|
979
|
+
|
|
980
|
+
Luca.modules.Filterable = {
|
|
981
|
+
__included: function(component, module) {
|
|
982
|
+
return _.extend(Luca.Collection.prototype, {
|
|
983
|
+
__filters: {}
|
|
984
|
+
});
|
|
985
|
+
},
|
|
986
|
+
__initializer: function(component, module) {
|
|
987
|
+
var filter,
|
|
988
|
+
_this = this;
|
|
989
|
+
if (this.filterable === false || !Luca.isBackboneCollection(this.collection)) {
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
this.getCollection || (this.getCollection = function() {
|
|
993
|
+
return this.collection;
|
|
994
|
+
});
|
|
995
|
+
filter = this.getFilterState();
|
|
996
|
+
filter.on("change", function(state) {
|
|
997
|
+
_this.trigger("collection:change:filter", state, _this.getCollection());
|
|
998
|
+
return _this.trigger("refresh");
|
|
999
|
+
});
|
|
1000
|
+
if (this.getQuery != null) {
|
|
1001
|
+
this.getQuery = _.compose(this.getQuery, function(query) {
|
|
1002
|
+
var obj;
|
|
1003
|
+
if (query == null) query = {};
|
|
1004
|
+
obj = _.clone(query);
|
|
1005
|
+
return _.extend(obj, filter.toQuery());
|
|
1006
|
+
});
|
|
1007
|
+
} else {
|
|
1008
|
+
this.getQuery = function() {
|
|
1009
|
+
return filter.toQuery();
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
if (this.getQueryOptions != null) {
|
|
1013
|
+
return this.getQueryOptions = _.compose(this.getQueryOptions, function(options) {
|
|
1014
|
+
var obj;
|
|
1015
|
+
if (options == null) options = {};
|
|
1016
|
+
obj = _.clone(options);
|
|
1017
|
+
return _.extend(obj, filter.toOptions());
|
|
1018
|
+
});
|
|
1019
|
+
} else {
|
|
1020
|
+
return this.getQueryOptions = function() {
|
|
1021
|
+
return filter.toOptions();
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
},
|
|
1025
|
+
getFilterState: function() {
|
|
1026
|
+
var _base, _name;
|
|
1027
|
+
return (_base = this.collection.__filters)[_name = this.cid] || (_base[_name] = new FilterModel(this.filterable));
|
|
1028
|
+
},
|
|
1029
|
+
setSortBy: function(sortBy, options) {
|
|
1030
|
+
if (options == null) options = {};
|
|
1031
|
+
return this.getFilterState().setOption('sortBy', sortBy, options);
|
|
1032
|
+
},
|
|
1033
|
+
applyFilter: function(query, options) {
|
|
1034
|
+
var silent;
|
|
1035
|
+
if (query == null) query = {};
|
|
1036
|
+
if (options == null) options = {};
|
|
1037
|
+
options = _.defaults(options, this.getQueryOptions());
|
|
1038
|
+
query = _.defaults(query, this.getQuery());
|
|
1039
|
+
silent = _(options)["delete"]('silent') === true;
|
|
1040
|
+
return this.getFilterState().set({
|
|
1041
|
+
query: query,
|
|
1042
|
+
options: options
|
|
1043
|
+
}, {
|
|
1044
|
+
silent: silent
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
|
|
1049
|
+
FilterModel = (function(_super) {
|
|
1050
|
+
|
|
1051
|
+
__extends(FilterModel, _super);
|
|
1052
|
+
|
|
1053
|
+
function FilterModel() {
|
|
1054
|
+
FilterModel.__super__.constructor.apply(this, arguments);
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
FilterModel.prototype.setOption = function(option, value, options) {
|
|
1058
|
+
var payload;
|
|
1059
|
+
payload = {};
|
|
1060
|
+
payload[option] = value;
|
|
1061
|
+
return this.set('options', _.extend(this.toOptions(), payload), options);
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
FilterModel.prototype.setQueryOption = function(option, value, options) {
|
|
1065
|
+
var payload;
|
|
1066
|
+
payload = {};
|
|
1067
|
+
payload[option] = value;
|
|
1068
|
+
return this.set('query', _.extend(this.toQuery(), payload), options);
|
|
1069
|
+
};
|
|
1070
|
+
|
|
1071
|
+
FilterModel.prototype.toOptions = function() {
|
|
1072
|
+
return this.toJSON().options;
|
|
1073
|
+
};
|
|
1074
|
+
|
|
1075
|
+
FilterModel.prototype.toQuery = function() {
|
|
1076
|
+
return this.toJSON().query;
|
|
1077
|
+
};
|
|
1078
|
+
|
|
1079
|
+
return FilterModel;
|
|
1080
|
+
|
|
1081
|
+
})(Backbone.Model);
|
|
1082
|
+
|
|
1083
|
+
}).call(this);
|
|
1084
|
+
(function() {
|
|
1085
|
+
|
|
1086
|
+
Luca.modules.GridLayout = {
|
|
1087
|
+
_initializer: function() {
|
|
1088
|
+
if (this.gridSpan) this.$el.addClass("span" + this.gridSpan);
|
|
1089
|
+
if (this.gridOffset) this.$el.addClass("offset" + this.gridOffset);
|
|
1090
|
+
if (this.gridRowFluid) this.$el.addClass("row-fluid");
|
|
1091
|
+
if (this.gridRow) return this.$el.addClass("row");
|
|
1092
|
+
}
|
|
1093
|
+
};
|
|
1094
|
+
|
|
595
1095
|
}).call(this);
|
|
596
1096
|
(function() {
|
|
597
1097
|
|
|
598
1098
|
Luca.modules.LoadMaskable = {
|
|
599
|
-
|
|
1099
|
+
__initializer: function() {
|
|
600
1100
|
var _this = this;
|
|
601
|
-
|
|
1101
|
+
if (this.loadMask !== true) return;
|
|
602
1102
|
if (this.loadMask === true) {
|
|
603
1103
|
this.defer(function() {
|
|
604
1104
|
_this.$el.addClass('with-mask');
|
|
@@ -607,10 +1107,16 @@
|
|
|
607
1107
|
return _this.$('.load-mask').hide();
|
|
608
1108
|
}
|
|
609
1109
|
}).until("after:render");
|
|
610
|
-
this.on(this.loadmaskEnableEvent || "enable:loadmask", this.applyLoadMask);
|
|
611
|
-
return this.on(this.loadmaskDisableEvent || "disable:loadmask", this.applyLoadMask);
|
|
1110
|
+
this.on(this.loadmaskEnableEvent || "enable:loadmask", this.applyLoadMask, this);
|
|
1111
|
+
return this.on(this.loadmaskDisableEvent || "disable:loadmask", this.applyLoadMask, this);
|
|
612
1112
|
}
|
|
613
1113
|
},
|
|
1114
|
+
showLoadMask: function() {
|
|
1115
|
+
return this.trigger("enable:loadmask");
|
|
1116
|
+
},
|
|
1117
|
+
hideLoadMask: function() {
|
|
1118
|
+
return this.trigger("disable:loadmask");
|
|
1119
|
+
},
|
|
614
1120
|
loadMaskTarget: function() {
|
|
615
1121
|
if (this.loadMaskEl != null) {
|
|
616
1122
|
return this.$(this.loadMaskEl);
|
|
@@ -734,7 +1240,193 @@
|
|
|
734
1240
|
|
|
735
1241
|
}).call(this);
|
|
736
1242
|
(function() {
|
|
737
|
-
var
|
|
1243
|
+
var applyModalConfig;
|
|
1244
|
+
|
|
1245
|
+
Luca.modules.ModalView = {
|
|
1246
|
+
closeOnEscape: true,
|
|
1247
|
+
showOnInitialize: false,
|
|
1248
|
+
backdrop: false,
|
|
1249
|
+
__initializer: function() {
|
|
1250
|
+
this.$el.addClass("modal");
|
|
1251
|
+
this.on("before:render", applyModalConfig, this);
|
|
1252
|
+
return this;
|
|
1253
|
+
},
|
|
1254
|
+
container: function() {
|
|
1255
|
+
return $('body');
|
|
1256
|
+
},
|
|
1257
|
+
toggle: function() {
|
|
1258
|
+
return this.$el.modal('toggle');
|
|
1259
|
+
},
|
|
1260
|
+
show: function() {
|
|
1261
|
+
return this.$el.modal('show');
|
|
1262
|
+
},
|
|
1263
|
+
hide: function() {
|
|
1264
|
+
return this.$el.modal('hide');
|
|
1265
|
+
}
|
|
1266
|
+
};
|
|
1267
|
+
|
|
1268
|
+
applyModalConfig = function() {
|
|
1269
|
+
this.$el.addClass('modal');
|
|
1270
|
+
if (this.fade === true) this.$el.addClass('fade');
|
|
1271
|
+
$('body').append(this.$el);
|
|
1272
|
+
this.$el.modal({
|
|
1273
|
+
backdrop: this.backdrop === true,
|
|
1274
|
+
keyboard: this.closeOnEscape === true,
|
|
1275
|
+
show: this.showOnInitialize === true
|
|
1276
|
+
});
|
|
1277
|
+
return this;
|
|
1278
|
+
};
|
|
1279
|
+
|
|
1280
|
+
}).call(this);
|
|
1281
|
+
(function() {
|
|
1282
|
+
|
|
1283
|
+
Luca.modules.Paginatable = {
|
|
1284
|
+
paginatorViewClass: 'Luca.components.PaginationControl',
|
|
1285
|
+
paginationSelector: ".toolbar.bottom",
|
|
1286
|
+
__included: function() {
|
|
1287
|
+
return _.extend(Luca.Collection.prototype, {
|
|
1288
|
+
__paginators: {}
|
|
1289
|
+
});
|
|
1290
|
+
},
|
|
1291
|
+
__initializer: function() {
|
|
1292
|
+
var collection, old, paginationState,
|
|
1293
|
+
_this = this;
|
|
1294
|
+
if (this.paginatable === false || !Luca.isBackboneCollection(this.collection)) {
|
|
1295
|
+
return;
|
|
1296
|
+
}
|
|
1297
|
+
_.bindAll(this, "paginationControl");
|
|
1298
|
+
this.getCollection || (this.getCollection = function() {
|
|
1299
|
+
return this.collection;
|
|
1300
|
+
});
|
|
1301
|
+
collection = this.getCollection();
|
|
1302
|
+
paginationState = this.getPaginationState();
|
|
1303
|
+
paginationState.on("change", function(state) {
|
|
1304
|
+
_this.trigger("collection:change:pagination", state, collection);
|
|
1305
|
+
return _this.trigger("refresh");
|
|
1306
|
+
});
|
|
1307
|
+
this.on("after:refresh", function(models, query, options) {
|
|
1308
|
+
return _.defer(function() {
|
|
1309
|
+
return _this.updatePagination.call(_this, models, query, options);
|
|
1310
|
+
});
|
|
1311
|
+
});
|
|
1312
|
+
this.on("after:render", function() {
|
|
1313
|
+
return _this.paginationControl().refresh();
|
|
1314
|
+
});
|
|
1315
|
+
if (old = this.getQueryOptions) {
|
|
1316
|
+
return this.getQueryOptions = function() {
|
|
1317
|
+
return _.extend(old(), paginationState.toJSON());
|
|
1318
|
+
};
|
|
1319
|
+
} else {
|
|
1320
|
+
return this.getQueryOptions = function() {
|
|
1321
|
+
return paginationState.toJSON();
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
},
|
|
1325
|
+
getPaginationState: function() {
|
|
1326
|
+
var _base, _name;
|
|
1327
|
+
return (_base = this.collection.__paginators)[_name = this.cid] || (_base[_name] = this.paginationControl().state);
|
|
1328
|
+
},
|
|
1329
|
+
paginationContainer: function() {
|
|
1330
|
+
return this.$(">" + this.paginationSelector);
|
|
1331
|
+
},
|
|
1332
|
+
setCurrentPage: function(page, options) {
|
|
1333
|
+
if (page == null) page = 1;
|
|
1334
|
+
if (options == null) options = {};
|
|
1335
|
+
return this.getPaginationState().set('page', page, options);
|
|
1336
|
+
},
|
|
1337
|
+
setLimit: function(limit, options) {
|
|
1338
|
+
if (limit == null) limit = 0;
|
|
1339
|
+
if (options == null) options = {};
|
|
1340
|
+
return this.getPaginationState().set('limit', limit, options);
|
|
1341
|
+
},
|
|
1342
|
+
updatePagination: function(models, query, options) {
|
|
1343
|
+
var itemCount, paginator, totalCount, _ref;
|
|
1344
|
+
if (models == null) models = [];
|
|
1345
|
+
if (query == null) query = {};
|
|
1346
|
+
if (options == null) options = {};
|
|
1347
|
+
_.defaults(options, this.getQueryOptions(), {
|
|
1348
|
+
limit: 0
|
|
1349
|
+
});
|
|
1350
|
+
paginator = this.paginationControl();
|
|
1351
|
+
itemCount = (models != null ? models.length : void 0) || 0;
|
|
1352
|
+
totalCount = (_ref = this.getCollection()) != null ? _ref.length : void 0;
|
|
1353
|
+
if (itemCount === 0 || totalCount <= options.limit) {
|
|
1354
|
+
paginator.$el.hide();
|
|
1355
|
+
} else {
|
|
1356
|
+
paginator.$el.show();
|
|
1357
|
+
}
|
|
1358
|
+
return paginator.state.set({
|
|
1359
|
+
page: options.page,
|
|
1360
|
+
limit: options.limit
|
|
1361
|
+
});
|
|
1362
|
+
},
|
|
1363
|
+
paginationControl: function() {
|
|
1364
|
+
if (this.paginator != null) return this.paginator;
|
|
1365
|
+
_.defaults(this.paginatable || (this.paginatable = {}), {
|
|
1366
|
+
page: 1,
|
|
1367
|
+
limit: 20
|
|
1368
|
+
});
|
|
1369
|
+
this.paginator = Luca.util.lazyComponent({
|
|
1370
|
+
type: "pagination_control",
|
|
1371
|
+
collection: this.getCollection(),
|
|
1372
|
+
defaultState: this.paginatable
|
|
1373
|
+
});
|
|
1374
|
+
return this.paginator;
|
|
1375
|
+
},
|
|
1376
|
+
renderPaginationControl: function() {
|
|
1377
|
+
this.paginationControl();
|
|
1378
|
+
return this.paginationContainer().append(this.paginationControl().render().$el);
|
|
1379
|
+
}
|
|
1380
|
+
};
|
|
1381
|
+
|
|
1382
|
+
}).call(this);
|
|
1383
|
+
(function() {
|
|
1384
|
+
|
|
1385
|
+
Luca.modules.StateModel = {
|
|
1386
|
+
__initializer: function() {
|
|
1387
|
+
var _this = this;
|
|
1388
|
+
if (this.stateful !== true) return;
|
|
1389
|
+
if ((this.state != null) && !Luca.isBackboneModel(this.state)) return;
|
|
1390
|
+
this.state = new Backbone.Model(this.defaultState || {});
|
|
1391
|
+
this.set || (this.set = function() {
|
|
1392
|
+
return _this.state.set.apply(_this.state, arguments);
|
|
1393
|
+
});
|
|
1394
|
+
this.get || (this.get = function() {
|
|
1395
|
+
return _this.state.get.apply(_this.state, arguments);
|
|
1396
|
+
});
|
|
1397
|
+
return this.state.on("change", function(state) {
|
|
1398
|
+
var changed, previousValues, value, _len, _ref, _results;
|
|
1399
|
+
_this.trigger("state:change", state);
|
|
1400
|
+
previousValues = state.previousAttributes();
|
|
1401
|
+
_ref = state.changedAttributes;
|
|
1402
|
+
_results = [];
|
|
1403
|
+
for (value = 0, _len = _ref.length; value < _len; value++) {
|
|
1404
|
+
changed = _ref[value];
|
|
1405
|
+
_results.push(_this.trigger("state:change:" + changed, value, state.previous(changed)));
|
|
1406
|
+
}
|
|
1407
|
+
return _results;
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
};
|
|
1411
|
+
|
|
1412
|
+
}).call(this);
|
|
1413
|
+
(function() {
|
|
1414
|
+
|
|
1415
|
+
Luca.modules.Templating = {
|
|
1416
|
+
__initializer: function() {
|
|
1417
|
+
var template, templateContent, templateVars;
|
|
1418
|
+
templateVars = Luca.util.read.call(this, this.bodyTemplateVars) || {};
|
|
1419
|
+
if (template = this.bodyTemplate) {
|
|
1420
|
+
this.$el.empty();
|
|
1421
|
+
templateContent = Luca.template(template, templateVars);
|
|
1422
|
+
return Luca.View.prototype.$html.call(this, templateContent);
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
};
|
|
1426
|
+
|
|
1427
|
+
}).call(this);
|
|
1428
|
+
(function() {
|
|
1429
|
+
var componentCacheStore, registry;
|
|
738
1430
|
|
|
739
1431
|
registry = {
|
|
740
1432
|
classes: {},
|
|
@@ -743,21 +1435,38 @@
|
|
|
743
1435
|
namespaces: ['Luca.containers', 'Luca.components']
|
|
744
1436
|
};
|
|
745
1437
|
|
|
746
|
-
|
|
1438
|
+
componentCacheStore = {
|
|
747
1439
|
cid_index: {},
|
|
748
1440
|
name_index: {}
|
|
749
1441
|
};
|
|
750
1442
|
|
|
751
|
-
Luca.
|
|
1443
|
+
Luca.config.defaultComponentClass = Luca.defaultComponentClass = 'Luca.View';
|
|
1444
|
+
|
|
1445
|
+
Luca.config.defaultComponentType = Luca.defaultComponentType = 'view';
|
|
1446
|
+
|
|
1447
|
+
Luca.registry.aliases = {
|
|
1448
|
+
grid: "grid_view",
|
|
1449
|
+
form: "form_view",
|
|
1450
|
+
text: "text_field",
|
|
1451
|
+
button: "button_field",
|
|
1452
|
+
select: "select_field",
|
|
1453
|
+
card: "card_view",
|
|
1454
|
+
paged: "card_view",
|
|
1455
|
+
wizard: "card_view",
|
|
1456
|
+
collection: "collection_view",
|
|
1457
|
+
list: "collection_view",
|
|
1458
|
+
multi: "collection_multi_view",
|
|
1459
|
+
table: "table_view"
|
|
1460
|
+
};
|
|
752
1461
|
|
|
753
|
-
Luca.
|
|
1462
|
+
Luca.registerComponent = function(component, prototypeName, componentType) {
|
|
754
1463
|
if (componentType == null) componentType = "view";
|
|
755
1464
|
Luca.trigger("component:registered", component, prototypeName);
|
|
756
1465
|
switch (componentType) {
|
|
757
1466
|
case "model":
|
|
758
1467
|
return registry.model_classes[component] = prototypeName;
|
|
759
1468
|
case "collection":
|
|
760
|
-
return registry.
|
|
1469
|
+
return registry.collection_classes[component] = prototypeName;
|
|
761
1470
|
default:
|
|
762
1471
|
return registry.classes[component] = prototypeName;
|
|
763
1472
|
}
|
|
@@ -774,10 +1483,10 @@
|
|
|
774
1483
|
return instance != null ? (_ref = instance.refreshCode) != null ? _ref.call(instance, prototypeDefinition) : void 0 : void 0;
|
|
775
1484
|
});
|
|
776
1485
|
}
|
|
777
|
-
return Luca.
|
|
1486
|
+
return Luca.registerComponent(component, prototypeName);
|
|
778
1487
|
};
|
|
779
1488
|
|
|
780
|
-
Luca.registry.addNamespace = function(identifier) {
|
|
1489
|
+
Luca.registry.addNamespace = Luca.registry.namespace = function(identifier) {
|
|
781
1490
|
registry.namespaces.push(identifier);
|
|
782
1491
|
return registry.namespaces = _(registry.namespaces).uniq();
|
|
783
1492
|
};
|
|
@@ -793,18 +1502,6 @@
|
|
|
793
1502
|
});
|
|
794
1503
|
};
|
|
795
1504
|
|
|
796
|
-
Luca.registry.aliases = {
|
|
797
|
-
grid: "grid_view",
|
|
798
|
-
form: "form_view",
|
|
799
|
-
text: "text_field",
|
|
800
|
-
button: "button_field",
|
|
801
|
-
select: "select_field",
|
|
802
|
-
card: "card_view",
|
|
803
|
-
paged: "card_view",
|
|
804
|
-
wizard: "card_view",
|
|
805
|
-
collection: "collection_view"
|
|
806
|
-
};
|
|
807
|
-
|
|
808
1505
|
Luca.registry.lookup = function(ctype) {
|
|
809
1506
|
var alias, c, className, fullPath, parents, _ref;
|
|
810
1507
|
if (alias = Luca.registry.aliases[ctype]) ctype = alias;
|
|
@@ -818,14 +1515,20 @@
|
|
|
818
1515
|
};
|
|
819
1516
|
|
|
820
1517
|
Luca.registry.instances = function() {
|
|
821
|
-
return _(
|
|
1518
|
+
return _(componentCacheStore.cid_index).values();
|
|
1519
|
+
};
|
|
1520
|
+
|
|
1521
|
+
Luca.registry.findInstancesByClass = function(componentClass) {
|
|
1522
|
+
return Luca.registry.findInstancesByClassName(componentClass.displayName);
|
|
822
1523
|
};
|
|
823
1524
|
|
|
824
1525
|
Luca.registry.findInstancesByClassName = function(className) {
|
|
825
1526
|
var instances;
|
|
1527
|
+
if (!_.isString(className)) className = className.displayName;
|
|
826
1528
|
instances = Luca.registry.instances();
|
|
827
1529
|
return _(instances).select(function(instance) {
|
|
828
|
-
var _ref;
|
|
1530
|
+
var isClass, _ref;
|
|
1531
|
+
isClass = instance.displayName === className;
|
|
829
1532
|
return instance.displayName === className || (typeof instance._superClass === "function" ? (_ref = instance._superClass()) != null ? _ref.displayName : void 0 : void 0) === className;
|
|
830
1533
|
});
|
|
831
1534
|
};
|
|
@@ -844,20 +1547,20 @@
|
|
|
844
1547
|
});
|
|
845
1548
|
};
|
|
846
1549
|
|
|
847
|
-
Luca.cache = function(
|
|
1550
|
+
Luca.cache = Luca.cacheInstance = function(cacheKey, object) {
|
|
848
1551
|
var lookup_id;
|
|
849
|
-
if (
|
|
850
|
-
|
|
851
|
-
if (
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
1552
|
+
if (cacheKey == null) return;
|
|
1553
|
+
if ((object != null ? object.doNotCache : void 0) === true) return object;
|
|
1554
|
+
if (object != null) componentCacheStore.cid_index[cacheKey] = object;
|
|
1555
|
+
object = componentCacheStore.cid_index[cacheKey];
|
|
1556
|
+
if ((object != null ? object.component_name : void 0) != null) {
|
|
1557
|
+
componentCacheStore.name_index[object.component_name] = object.cid;
|
|
1558
|
+
} else if ((object != null ? object.name : void 0) != null) {
|
|
1559
|
+
componentCacheStore.name_index[object.name] = object.cid;
|
|
857
1560
|
}
|
|
858
|
-
if (
|
|
859
|
-
lookup_id =
|
|
860
|
-
return
|
|
1561
|
+
if (object != null) return object;
|
|
1562
|
+
lookup_id = componentCacheStore.name_index[cacheKey];
|
|
1563
|
+
return componentCacheStore.cid_index[lookup_id];
|
|
861
1564
|
};
|
|
862
1565
|
|
|
863
1566
|
}).call(this);
|
|
@@ -903,93 +1606,45 @@
|
|
|
903
1606
|
|
|
904
1607
|
}).call(this);
|
|
905
1608
|
(function() {
|
|
906
|
-
var bindAllEventHandlers,
|
|
1609
|
+
var bindAllEventHandlers, bindEventHandlers, view;
|
|
1610
|
+
|
|
1611
|
+
view = Luca.register("Luca.View");
|
|
907
1612
|
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
1613
|
+
view["extends"]("Backbone.View");
|
|
1614
|
+
|
|
1615
|
+
view.includes("Luca.Events", "Luca.modules.DomHelpers");
|
|
1616
|
+
|
|
1617
|
+
view.mixesIn("DomHelpers", "Templating", "EnhancedProperties", "CollectionEventBindings", "ApplicationEventBindings", "StateModel");
|
|
1618
|
+
|
|
1619
|
+
view.triggers("before:initialize", "after:initialize", "before:render", "after:render", "first:activation", "activation", "deactivation");
|
|
1620
|
+
|
|
1621
|
+
view.defines({
|
|
912
1622
|
initialize: function(options) {
|
|
913
|
-
var
|
|
1623
|
+
var module, _i, _len, _ref, _ref2, _ref3, _ref4;
|
|
914
1624
|
this.options = options != null ? options : {};
|
|
915
1625
|
this.trigger("before:initialize", this, this.options);
|
|
916
1626
|
_.extend(this, this.options);
|
|
917
|
-
if (this.name != null) this.cid = _.uniqueId(this.name);
|
|
918
|
-
templateVars = this.bodyTemplateVars ? this.bodyTemplateVars.call(this) : this;
|
|
919
|
-
if (template = this.bodyTemplate) {
|
|
920
|
-
this.$el.empty();
|
|
921
|
-
Luca.View.prototype.$html.call(this, Luca.template(template, templateVars));
|
|
922
|
-
}
|
|
923
|
-
Luca.cache(this.cid, this);
|
|
924
|
-
this.setupHooks(_(Luca.View.prototype.hooks.concat(this.hooks)).uniq());
|
|
925
1627
|
if (this.autoBindEventHandlers === true || this.bindAllEvents === true) {
|
|
926
1628
|
bindAllEventHandlers.call(this);
|
|
927
1629
|
}
|
|
928
|
-
if (this.
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
if (this.gridOffset) {
|
|
935
|
-
this.additionalClassNames.push("offset" + this.gridOffset);
|
|
936
|
-
}
|
|
937
|
-
if (this.gridRowFluid) this.additionalClassNames.push("row-fluid");
|
|
938
|
-
if (this.gridRow) this.additionalClassNames.push("row");
|
|
939
|
-
if (((_ref = this.additionalClassNames) != null ? _ref.length : void 0) > 0) {
|
|
940
|
-
_ref2 = this.additionalClassNames;
|
|
1630
|
+
if (this.name != null) this.cid = _.uniqueId(this.name);
|
|
1631
|
+
this.$el.attr("data-luca-id", this.name || this.cid);
|
|
1632
|
+
Luca.cacheInstance(this.cid, this);
|
|
1633
|
+
this.setupHooks(_(Luca.View.prototype.hooks.concat(this.hooks)).uniq());
|
|
1634
|
+
if (((_ref = this.mixins) != null ? _ref.length : void 0) > 0) {
|
|
1635
|
+
_ref2 = this.mixins;
|
|
941
1636
|
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
|
942
|
-
|
|
943
|
-
|
|
1637
|
+
module = _ref2[_i];
|
|
1638
|
+
if ((_ref3 = Luca.mixin(module)) != null) {
|
|
1639
|
+
if ((_ref4 = _ref3.__initializer) != null) {
|
|
1640
|
+
_ref4.call(this, this, module);
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
944
1643
|
}
|
|
945
1644
|
}
|
|
946
|
-
if (this.wrapperClass != null) this.$wrap(this.wrapperClass);
|
|
947
|
-
registerCollectionEvents.call(this);
|
|
948
|
-
registerApplicationEvents.call(this);
|
|
949
1645
|
this.delegateEvents();
|
|
950
|
-
if (this.stateful === true && !(this.state != null)) {
|
|
951
|
-
this.state = new Backbone.Model(this.defaultState || {});
|
|
952
|
-
if (this.set == null) {
|
|
953
|
-
this.set = _.bind(this, this.state.set);
|
|
954
|
-
this.get = _.bind(this, this.state.get);
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
if (((_ref3 = this.mixins) != null ? _ref3.length : void 0) > 0) {
|
|
958
|
-
_ref4 = this.mixins;
|
|
959
|
-
for (_j = 0, _len2 = _ref4.length; _j < _len2; _j++) {
|
|
960
|
-
module = _ref4[_j];
|
|
961
|
-
Luca.modules[module]._included.call(this, this, module);
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
1646
|
return this.trigger("after:initialize", this);
|
|
965
1647
|
},
|
|
966
|
-
$wrap: function(wrapper) {
|
|
967
|
-
if (_.isString(wrapper) && !wrapper.match(/[<>]/)) {
|
|
968
|
-
wrapper = this.make("div", {
|
|
969
|
-
"class": wrapper
|
|
970
|
-
});
|
|
971
|
-
}
|
|
972
|
-
return this.$el.wrap(wrapper);
|
|
973
|
-
},
|
|
974
|
-
$template: function(template, variables) {
|
|
975
|
-
if (variables == null) variables = {};
|
|
976
|
-
return this.$el.html(Luca.template(template, variables));
|
|
977
|
-
},
|
|
978
|
-
$html: function(content) {
|
|
979
|
-
return this.$el.html(content);
|
|
980
|
-
},
|
|
981
|
-
$append: function(content) {
|
|
982
|
-
return this.$el.append(content);
|
|
983
|
-
},
|
|
984
|
-
$attach: function() {
|
|
985
|
-
return this.$container().append(this.el);
|
|
986
|
-
},
|
|
987
|
-
$bodyEl: function() {
|
|
988
|
-
return this.$el;
|
|
989
|
-
},
|
|
990
|
-
$container: function() {
|
|
991
|
-
return $(this.container);
|
|
992
|
-
},
|
|
993
1648
|
setupHooks: function(set) {
|
|
994
1649
|
var _this = this;
|
|
995
1650
|
set || (set = this.hooks);
|
|
@@ -998,12 +1653,12 @@
|
|
|
998
1653
|
fn = Luca.util.hook(eventId);
|
|
999
1654
|
callback = function() {
|
|
1000
1655
|
var _ref;
|
|
1001
|
-
return (_ref =
|
|
1656
|
+
return (_ref = this[fn]) != null ? _ref.apply(this, arguments) : void 0;
|
|
1002
1657
|
};
|
|
1003
1658
|
if (eventId != null ? eventId.match(/once:/) : void 0) {
|
|
1004
1659
|
callback = _.once(callback);
|
|
1005
1660
|
}
|
|
1006
|
-
return _this.
|
|
1661
|
+
return _this.on(eventId, callback, _this);
|
|
1007
1662
|
});
|
|
1008
1663
|
},
|
|
1009
1664
|
registerEvent: function(selector, handler) {
|
|
@@ -1047,14 +1702,14 @@
|
|
|
1047
1702
|
}
|
|
1048
1703
|
});
|
|
1049
1704
|
|
|
1050
|
-
|
|
1705
|
+
Luca.View._originalExtend = Backbone.View.extend;
|
|
1051
1706
|
|
|
1052
|
-
|
|
1707
|
+
Luca.View.renderWrapper = function(definition) {
|
|
1053
1708
|
var _base;
|
|
1054
1709
|
_base = definition.render;
|
|
1055
1710
|
_base || (_base = Luca.View.prototype.$attach);
|
|
1056
1711
|
definition.render = function() {
|
|
1057
|
-
var autoTrigger, deferred, fn, target, trigger,
|
|
1712
|
+
var autoTrigger, deferred, fn, target, trigger,
|
|
1058
1713
|
_this = this;
|
|
1059
1714
|
view = this;
|
|
1060
1715
|
if (this.deferrable) {
|
|
@@ -1063,7 +1718,7 @@
|
|
|
1063
1718
|
this.deferrable = this.collection;
|
|
1064
1719
|
}
|
|
1065
1720
|
target || (target = this.deferrable);
|
|
1066
|
-
trigger = this.deferrable_event ? this.deferrable_event :
|
|
1721
|
+
trigger = this.deferrable_event ? this.deferrable_event : Luca.View.deferrableEvent;
|
|
1067
1722
|
deferred = function() {
|
|
1068
1723
|
_base.call(view);
|
|
1069
1724
|
return view.trigger("after:render", view);
|
|
@@ -1092,57 +1747,26 @@
|
|
|
1092
1747
|
};
|
|
1093
1748
|
|
|
1094
1749
|
bindAllEventHandlers = function() {
|
|
1095
|
-
var
|
|
1096
|
-
|
|
1097
|
-
if (_.isString(handler)) return _.bindAll(_this, handler);
|
|
1098
|
-
});
|
|
1099
|
-
};
|
|
1100
|
-
|
|
1101
|
-
registerApplicationEvents = function() {
|
|
1102
|
-
var app, eventTrigger, handler, _len, _ref, _ref2, _results;
|
|
1103
|
-
if (_.isEmpty(this.applicationEvents)) return;
|
|
1104
|
-
app = this.app;
|
|
1105
|
-
if (_.isString(app) || _.isUndefined(app)) {
|
|
1106
|
-
app = (_ref = Luca.Application) != null ? typeof _ref.get === "function" ? _ref.get(app) : void 0 : void 0;
|
|
1107
|
-
}
|
|
1108
|
-
if (!Luca.supportsEvents(app)) {
|
|
1109
|
-
throw "Error binding to the application object on " + (this.name || this.cid);
|
|
1110
|
-
}
|
|
1111
|
-
_ref2 = this.applicationEvents;
|
|
1750
|
+
var config, _i, _len, _ref, _results;
|
|
1751
|
+
_ref = [this.events, this.componentEvents, this.collectionEvents, this.applicationEvents];
|
|
1112
1752
|
_results = [];
|
|
1113
|
-
for (
|
|
1114
|
-
|
|
1115
|
-
if (_.
|
|
1116
|
-
if (!_.isFunction(handler)) {
|
|
1117
|
-
throw "Error registering application event " + eventTrigger + " on " + (this.name || this.cid);
|
|
1118
|
-
}
|
|
1119
|
-
_results.push(app.on(eventTrigger, handler));
|
|
1753
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
1754
|
+
config = _ref[_i];
|
|
1755
|
+
if (!_.isEmpty(config)) _results.push(bindEventHandlers.call(this, config));
|
|
1120
1756
|
}
|
|
1121
1757
|
return _results;
|
|
1122
1758
|
};
|
|
1123
1759
|
|
|
1124
|
-
|
|
1125
|
-
var
|
|
1126
|
-
if (
|
|
1127
|
-
manager = this.collectionManager;
|
|
1128
|
-
if (_.isString(manager) || _.isUndefined(manager)) {
|
|
1129
|
-
manager = Luca.CollectionManager.get(manager);
|
|
1130
|
-
}
|
|
1131
|
-
_ref = this.collectionEvents;
|
|
1760
|
+
bindEventHandlers = function(events) {
|
|
1761
|
+
var eventSignature, handler, _results;
|
|
1762
|
+
if (events == null) events = {};
|
|
1132
1763
|
_results = [];
|
|
1133
|
-
for (
|
|
1134
|
-
handler =
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
if (_.isString(handler)) handler = this[handler];
|
|
1140
|
-
if (!_.isFunction(handler)) throw "invalid collectionEvents configuration";
|
|
1141
|
-
try {
|
|
1142
|
-
_results.push(collection.bind(eventTrigger, handler));
|
|
1143
|
-
} catch (e) {
|
|
1144
|
-
console.log("Error Binding To Collection in registerCollectionEvents", this);
|
|
1145
|
-
throw e;
|
|
1764
|
+
for (eventSignature in events) {
|
|
1765
|
+
handler = events[eventSignature];
|
|
1766
|
+
if (_.isString(handler)) {
|
|
1767
|
+
_results.push(_.bindAll(this, handler));
|
|
1768
|
+
} else {
|
|
1769
|
+
_results.push(void 0);
|
|
1146
1770
|
}
|
|
1147
1771
|
}
|
|
1148
1772
|
return _results;
|
|
@@ -1150,20 +1774,50 @@
|
|
|
1150
1774
|
|
|
1151
1775
|
Luca.View.extend = function(definition) {
|
|
1152
1776
|
var module, _i, _len, _ref;
|
|
1153
|
-
definition =
|
|
1777
|
+
definition = Luca.View.renderWrapper(definition);
|
|
1154
1778
|
if ((definition.mixins != null) && _.isArray(definition.mixins)) {
|
|
1155
1779
|
_ref = definition.mixins;
|
|
1156
1780
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
1157
1781
|
module = _ref[_i];
|
|
1158
|
-
|
|
1782
|
+
Luca.decorate(definition)["with"](module);
|
|
1159
1783
|
}
|
|
1160
1784
|
}
|
|
1161
|
-
return
|
|
1785
|
+
return Luca.View._originalExtend.call(this, definition);
|
|
1162
1786
|
};
|
|
1163
1787
|
|
|
1788
|
+
Luca.View.deferrableEvent = "reset";
|
|
1789
|
+
|
|
1164
1790
|
}).call(this);
|
|
1165
1791
|
(function() {
|
|
1166
|
-
var setupComputedProperties;
|
|
1792
|
+
var model, setupComputedProperties;
|
|
1793
|
+
|
|
1794
|
+
model = Luca.define('Luca.Model');
|
|
1795
|
+
|
|
1796
|
+
model["extends"]('Backbone.Model');
|
|
1797
|
+
|
|
1798
|
+
model.includes('Luca.Events');
|
|
1799
|
+
|
|
1800
|
+
model.defines({
|
|
1801
|
+
initialize: function() {
|
|
1802
|
+
Backbone.Model.prototype.initialize(this, arguments);
|
|
1803
|
+
return setupComputedProperties.call(this);
|
|
1804
|
+
},
|
|
1805
|
+
read: function(attr) {
|
|
1806
|
+
if (_.isFunction(this[attr])) {
|
|
1807
|
+
return this[attr].call(this);
|
|
1808
|
+
} else {
|
|
1809
|
+
return this.get(attr);
|
|
1810
|
+
}
|
|
1811
|
+
},
|
|
1812
|
+
get: function(attr) {
|
|
1813
|
+
var _ref;
|
|
1814
|
+
if ((_ref = this.computed) != null ? _ref.hasOwnProperty(attr) : void 0) {
|
|
1815
|
+
return this._computed[attr];
|
|
1816
|
+
} else {
|
|
1817
|
+
return Backbone.Model.prototype.get.call(this, attr);
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
});
|
|
1167
1821
|
|
|
1168
1822
|
setupComputedProperties = function() {
|
|
1169
1823
|
var attr, dependencies, _ref, _results,
|
|
@@ -1188,32 +1842,22 @@
|
|
|
1188
1842
|
return _results;
|
|
1189
1843
|
};
|
|
1190
1844
|
|
|
1191
|
-
_.def('Luca.Model')["extends"]('Backbone.Model')["with"]({
|
|
1192
|
-
include: ['Luca.Events'],
|
|
1193
|
-
initialize: function() {
|
|
1194
|
-
Backbone.Model.prototype.initialize(this, arguments);
|
|
1195
|
-
return setupComputedProperties.call(this);
|
|
1196
|
-
},
|
|
1197
|
-
get: function(attr) {
|
|
1198
|
-
var _ref;
|
|
1199
|
-
if ((_ref = this.computed) != null ? _ref.hasOwnProperty(attr) : void 0) {
|
|
1200
|
-
return this._computed[attr];
|
|
1201
|
-
} else {
|
|
1202
|
-
return Backbone.Model.prototype.get.call(this, attr);
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
});
|
|
1206
|
-
|
|
1207
1845
|
}).call(this);
|
|
1208
1846
|
(function() {
|
|
1209
|
-
var
|
|
1847
|
+
var collection;
|
|
1848
|
+
|
|
1849
|
+
collection = Luca.define('Luca.Collection');
|
|
1210
1850
|
|
|
1211
|
-
|
|
1851
|
+
if (Backbone.QueryCollection != null) {
|
|
1852
|
+
collection["extends"]('Backbone.QueryCollection');
|
|
1853
|
+
} else {
|
|
1854
|
+
collection["extends"]('Backbone.Collection');
|
|
1855
|
+
}
|
|
1212
1856
|
|
|
1213
|
-
|
|
1857
|
+
collection.includes('Luca.Events');
|
|
1214
1858
|
|
|
1215
|
-
|
|
1216
|
-
|
|
1859
|
+
collection.defines({
|
|
1860
|
+
model: Luca.Model,
|
|
1217
1861
|
cachedMethods: [],
|
|
1218
1862
|
remoteFilter: false,
|
|
1219
1863
|
initialize: function(models, options) {
|
|
@@ -1446,7 +2090,7 @@
|
|
|
1446
2090
|
return _results;
|
|
1447
2091
|
},
|
|
1448
2092
|
setupMethodCaching: function() {
|
|
1449
|
-
var cache,
|
|
2093
|
+
var cache, membershipEvents;
|
|
1450
2094
|
collection = this;
|
|
1451
2095
|
membershipEvents = ["reset", "add", "remove"];
|
|
1452
2096
|
cache = this._methodCache = {};
|
|
@@ -1669,11 +2313,13 @@
|
|
|
1669
2313
|
this.input_id || (this.input_id = _.uniqueId('field'));
|
|
1670
2314
|
this.input_name || (this.input_name = this.name);
|
|
1671
2315
|
this.input_class || (this.input_class = "");
|
|
2316
|
+
this.input_type || (this.input_type = "");
|
|
1672
2317
|
this.helperText || (this.helperText = "");
|
|
1673
2318
|
if (this.required && !((_ref = this.label) != null ? _ref.match(/^\*/) : void 0)) {
|
|
1674
2319
|
this.label || (this.label = "*" + this.label);
|
|
1675
2320
|
}
|
|
1676
2321
|
this.inputStyles || (this.inputStyles = "");
|
|
2322
|
+
this.input_value || (this.input_value = this.value || "");
|
|
1677
2323
|
if (this.disabled) this.disable();
|
|
1678
2324
|
this.updateState(this.state);
|
|
1679
2325
|
this.placeHolder || (this.placeHolder = "");
|
|
@@ -1681,22 +2327,20 @@
|
|
|
1681
2327
|
},
|
|
1682
2328
|
beforeRender: function() {
|
|
1683
2329
|
if (Luca.enableBootstrap) this.$el.addClass('control-group');
|
|
1684
|
-
if (this.required) this.$el.addClass('required');
|
|
1685
|
-
this.$el.html(Luca.template(this.template, this));
|
|
1686
|
-
return this.input = $('input', this.el);
|
|
2330
|
+
if (this.required) return this.$el.addClass('required');
|
|
1687
2331
|
},
|
|
1688
2332
|
change_handler: function(e) {
|
|
1689
2333
|
return this.trigger("on:change", this, e);
|
|
1690
2334
|
},
|
|
1691
2335
|
disable: function() {
|
|
1692
|
-
return
|
|
2336
|
+
return this.getInputElement().attr('disabled', true);
|
|
1693
2337
|
},
|
|
1694
2338
|
enable: function() {
|
|
1695
|
-
return
|
|
2339
|
+
return this.getInputElement().attr('disabled', false);
|
|
1696
2340
|
},
|
|
1697
2341
|
getValue: function() {
|
|
1698
|
-
var raw;
|
|
1699
|
-
raw = this.
|
|
2342
|
+
var raw, _ref;
|
|
2343
|
+
raw = (_ref = this.getInputElement()) != null ? _ref.attr('value') : void 0;
|
|
1700
2344
|
if (_.str.isBlank(raw)) return raw;
|
|
1701
2345
|
switch (this.valueType) {
|
|
1702
2346
|
case "integer":
|
|
@@ -1709,11 +2353,12 @@
|
|
|
1709
2353
|
return raw;
|
|
1710
2354
|
}
|
|
1711
2355
|
},
|
|
1712
|
-
render: function() {
|
|
1713
|
-
return $(this.container).append(this.$el);
|
|
1714
|
-
},
|
|
1715
2356
|
setValue: function(value) {
|
|
1716
|
-
|
|
2357
|
+
var _ref;
|
|
2358
|
+
return (_ref = this.getInputElement()) != null ? _ref.attr('value', value) : void 0;
|
|
2359
|
+
},
|
|
2360
|
+
getInputElement: function() {
|
|
2361
|
+
return this.input || (this.input = this.$('input').eq(0));
|
|
1717
2362
|
},
|
|
1718
2363
|
updateState: function(state) {
|
|
1719
2364
|
var _this = this;
|
|
@@ -1726,57 +2371,28 @@
|
|
|
1726
2371
|
|
|
1727
2372
|
}).call(this);
|
|
1728
2373
|
(function() {
|
|
1729
|
-
var applyDOMConfig, doComponents, doLayout;
|
|
2374
|
+
var applyDOMConfig, container, createGetterMethods, createMethodsToGetComponentsByRole, doComponents, doLayout, indexComponent, validateContainerConfiguration;
|
|
1730
2375
|
|
|
1731
|
-
|
|
1732
|
-
this.trigger("before:layout", this);
|
|
1733
|
-
this.prepareLayout();
|
|
1734
|
-
return this.trigger("after:layout", this);
|
|
1735
|
-
};
|
|
2376
|
+
container = Luca.register("Luca.core.Container");
|
|
1736
2377
|
|
|
1737
|
-
|
|
1738
|
-
var config, style_declarations;
|
|
1739
|
-
style_declarations = [];
|
|
1740
|
-
if (panel.height != null) {
|
|
1741
|
-
style_declarations.push("height: " + (_.isNumber(panel.height) ? panel.height + 'px' : panel.height));
|
|
1742
|
-
}
|
|
1743
|
-
if (panel.width != null) {
|
|
1744
|
-
style_declarations.push("width: " + (_.isNumber(panel.width) ? panel.width + 'px' : panel.width));
|
|
1745
|
-
}
|
|
1746
|
-
if (panel.float) style_declarations.push("float: " + panel.float);
|
|
1747
|
-
config = {
|
|
1748
|
-
"class": (panel != null ? panel.classes : void 0) || this.componentClass,
|
|
1749
|
-
id: "" + this.cid + "-" + panelIndex,
|
|
1750
|
-
style: style_declarations.join(';'),
|
|
1751
|
-
"data-luca-owner": this.name || this.cid
|
|
1752
|
-
};
|
|
1753
|
-
if (this.customizeContainerEl != null) {
|
|
1754
|
-
config = this.customizeContainerEl(config, panel, panelIndex);
|
|
1755
|
-
}
|
|
1756
|
-
return config;
|
|
1757
|
-
};
|
|
2378
|
+
container["extends"]("Luca.components.Panel");
|
|
1758
2379
|
|
|
1759
|
-
|
|
1760
|
-
this.trigger("before:components", this, this.components);
|
|
1761
|
-
this.prepareComponents();
|
|
1762
|
-
this.createComponents();
|
|
1763
|
-
this.trigger("before:render:components", this, this.components);
|
|
1764
|
-
this.renderComponents();
|
|
1765
|
-
return this.trigger("after:components", this, this.components);
|
|
1766
|
-
};
|
|
2380
|
+
container.triggers("before:components", "before:render:components", "before:layout", "after:components", "after:layout", "first:activation");
|
|
1767
2381
|
|
|
1768
|
-
|
|
2382
|
+
container.defines({
|
|
1769
2383
|
className: 'luca-ui-container',
|
|
1770
2384
|
componentTag: 'div',
|
|
1771
2385
|
componentClass: 'luca-ui-panel',
|
|
1772
2386
|
isContainer: true,
|
|
1773
|
-
hooks: ["before:components", "before:render:components", "before:layout", "after:components", "after:layout", "first:activation"],
|
|
1774
2387
|
rendered: false,
|
|
1775
2388
|
components: [],
|
|
2389
|
+
componentEvents: {},
|
|
1776
2390
|
initialize: function(options) {
|
|
1777
2391
|
this.options = options != null ? options : {};
|
|
1778
2392
|
_.extend(this, this.options);
|
|
1779
|
-
this.setupHooks(
|
|
2393
|
+
this.setupHooks(Luca.core.Container.prototype.hooks);
|
|
2394
|
+
this.components || (this.components = this.fields || (this.fields = this.pages || (this.pages = this.cards || (this.cards = this.views))));
|
|
2395
|
+
validateContainerConfiguration(this);
|
|
1780
2396
|
return Luca.View.prototype.initialize.apply(this, arguments);
|
|
1781
2397
|
},
|
|
1782
2398
|
beforeRender: function() {
|
|
@@ -1789,7 +2405,6 @@
|
|
|
1789
2405
|
return containerEl;
|
|
1790
2406
|
},
|
|
1791
2407
|
prepareLayout: function() {
|
|
1792
|
-
var container;
|
|
1793
2408
|
container = this;
|
|
1794
2409
|
return this.componentContainers = _(this.components).map(function(component, index) {
|
|
1795
2410
|
return applyDOMConfig.call(container, component, index);
|
|
@@ -1829,31 +2444,23 @@
|
|
|
1829
2444
|
if (this.componentsCreated === true) return;
|
|
1830
2445
|
map = this.componentIndex = {
|
|
1831
2446
|
name_index: {},
|
|
1832
|
-
cid_index: {}
|
|
2447
|
+
cid_index: {},
|
|
2448
|
+
role_index: {}
|
|
1833
2449
|
};
|
|
2450
|
+
container = this;
|
|
1834
2451
|
this.components = _(this.components).map(function(object, index) {
|
|
1835
|
-
var component;
|
|
1836
|
-
component = Luca.isBackboneView(object) ? object : (object.type || (object.type = object.ctype), !(object.type != null) ? object.components != null ? object.type = object.ctype = 'container' : object.type = object.ctype = Luca.defaultComponentType : void 0, Luca.util.lazyComponent(object));
|
|
1837
|
-
if (_.isString(component.getter)) {
|
|
1838
|
-
_this[component.getter] = (function() {
|
|
1839
|
-
return component;
|
|
1840
|
-
});
|
|
1841
|
-
}
|
|
2452
|
+
var component, created;
|
|
2453
|
+
component = Luca.isBackboneView(object) ? object : (object.type || (object.type = object.ctype), !(object.type != null) ? object.components != null ? object.type = object.ctype = 'container' : object.type = object.ctype = Luca.defaultComponentType : void 0, object = _.defaults(object, container.defaults || {}), created = Luca.util.lazyComponent(object));
|
|
1842
2454
|
if (!component.container && component.options.container) {
|
|
1843
2455
|
component.container = component.options.container;
|
|
1844
2456
|
}
|
|
1845
|
-
|
|
1846
|
-
if (map && (component.name != null)) {
|
|
1847
|
-
map.name_index[component.name] = index;
|
|
1848
|
-
}
|
|
2457
|
+
indexComponent(component).at(index)["in"](_this.componentIndex);
|
|
1849
2458
|
return component;
|
|
1850
2459
|
});
|
|
1851
2460
|
this.componentsCreated = true;
|
|
1852
|
-
if (!_.isEmpty(this.componentEvents)) this.registerComponentEvents();
|
|
1853
2461
|
return map;
|
|
1854
2462
|
},
|
|
1855
2463
|
renderComponents: function(debugMode) {
|
|
1856
|
-
var container;
|
|
1857
2464
|
this.debugMode = debugMode != null ? debugMode : "";
|
|
1858
2465
|
this.debug("container render components");
|
|
1859
2466
|
container = this;
|
|
@@ -1889,43 +2496,102 @@
|
|
|
1889
2496
|
}
|
|
1890
2497
|
});
|
|
1891
2498
|
},
|
|
2499
|
+
_: function() {
|
|
2500
|
+
return _(this.components);
|
|
2501
|
+
},
|
|
1892
2502
|
pluck: function(attribute) {
|
|
1893
|
-
return _(
|
|
2503
|
+
return this._().pluck(attribute);
|
|
1894
2504
|
},
|
|
1895
2505
|
invoke: function(method) {
|
|
1896
|
-
return _(
|
|
2506
|
+
return this._().invoke(method);
|
|
2507
|
+
},
|
|
2508
|
+
select: function(fn) {
|
|
2509
|
+
return this._().select(fn);
|
|
2510
|
+
},
|
|
2511
|
+
detect: function(fn) {
|
|
2512
|
+
return this._().detect(attribute);
|
|
2513
|
+
},
|
|
2514
|
+
reject: function(fn) {
|
|
2515
|
+
return this._().reject(fn);
|
|
1897
2516
|
},
|
|
1898
2517
|
map: function(fn) {
|
|
1899
|
-
return _(
|
|
2518
|
+
return this._().map(fn);
|
|
1900
2519
|
},
|
|
1901
|
-
componentEvents: {},
|
|
1902
2520
|
registerComponentEvents: function() {
|
|
1903
|
-
var component,
|
|
1904
|
-
|
|
2521
|
+
var component, componentNameOrRole, eventId, handler, listener, _ref, _ref2, _results,
|
|
2522
|
+
_this = this;
|
|
2523
|
+
container = this;
|
|
2524
|
+
_ref = this.componentEvents || {};
|
|
1905
2525
|
_results = [];
|
|
1906
2526
|
for (listener in _ref) {
|
|
1907
2527
|
handler = _ref[listener];
|
|
1908
|
-
_ref2 = listener.split(' '),
|
|
1909
|
-
|
|
1910
|
-
|
|
2528
|
+
_ref2 = listener.split(' '), componentNameOrRole = _ref2[0], eventId = _ref2[1];
|
|
2529
|
+
if (!_.isFunction(this[handler])) {
|
|
2530
|
+
console.log("Error registering component event", listener, componentNameOrRole, eventId);
|
|
2531
|
+
throw "Invalid component event definition " + listener + ". Specified handler is not a method on the container";
|
|
2532
|
+
}
|
|
2533
|
+
if (componentNameOrRole === "*") {
|
|
2534
|
+
_results.push(this.eachComponent(function(component) {
|
|
2535
|
+
return component.on(eventId, _this[handler], container);
|
|
2536
|
+
}));
|
|
2537
|
+
} else {
|
|
2538
|
+
component = this.findComponentForEventBinding(componentNameOrRole);
|
|
2539
|
+
if (!((component != null) && Luca.isComponent(component))) {
|
|
2540
|
+
console.log("Error registering component event", listener, componentNameOrRole, eventId);
|
|
2541
|
+
throw "Invalid component event definition: " + componentNameOrRole;
|
|
2542
|
+
}
|
|
2543
|
+
_results.push(component != null ? component.bind(eventId, this[handler], container) : void 0);
|
|
2544
|
+
}
|
|
1911
2545
|
}
|
|
1912
2546
|
return _results;
|
|
1913
2547
|
},
|
|
2548
|
+
subContainers: function() {
|
|
2549
|
+
return this.select(function(component) {
|
|
2550
|
+
return component.isContainer === true;
|
|
2551
|
+
});
|
|
2552
|
+
},
|
|
2553
|
+
roles: function() {
|
|
2554
|
+
return _(this.allChildren()).pluck('role');
|
|
2555
|
+
},
|
|
2556
|
+
allChildren: function() {
|
|
2557
|
+
var children, grandchildren;
|
|
2558
|
+
children = this.components;
|
|
2559
|
+
grandchildren = _(this.subContainers()).invoke('allChildren');
|
|
2560
|
+
return this._allChildren || (this._allChildren = _([children, grandchildren]).chain().compact().flatten().uniq().value());
|
|
2561
|
+
},
|
|
2562
|
+
findComponentForEventBinding: function(nameRoleOrGetter, deep) {
|
|
2563
|
+
if (deep == null) deep = false;
|
|
2564
|
+
return this.findComponentByName(nameRoleOrGetter, deep) || this.findComponentByGetter(nameRoleOrGetter, deep) || this.findComponentByRole(nameRoleOrGetter, deep);
|
|
2565
|
+
},
|
|
2566
|
+
findComponentByGetter: function(getter, deep) {
|
|
2567
|
+
if (deep == null) deep = false;
|
|
2568
|
+
return _(this.allChildren()).detect(function(component) {
|
|
2569
|
+
return component.getter === getter;
|
|
2570
|
+
});
|
|
2571
|
+
},
|
|
2572
|
+
findComponentByRole: function(role, deep) {
|
|
2573
|
+
if (deep == null) deep = false;
|
|
2574
|
+
return _(this.allChildren()).detect(function(component) {
|
|
2575
|
+
return component.role === role;
|
|
2576
|
+
});
|
|
2577
|
+
},
|
|
1914
2578
|
findComponentByName: function(name, deep) {
|
|
1915
2579
|
if (deep == null) deep = false;
|
|
1916
|
-
return this.
|
|
2580
|
+
return _(this.allChildren()).detect(function(component) {
|
|
2581
|
+
return component.name === name;
|
|
2582
|
+
});
|
|
1917
2583
|
},
|
|
1918
2584
|
findComponentById: function(id, deep) {
|
|
1919
2585
|
if (deep == null) deep = false;
|
|
1920
2586
|
return this.findComponent(id, "cid_index", deep);
|
|
1921
2587
|
},
|
|
1922
2588
|
findComponent: function(needle, haystack, deep) {
|
|
1923
|
-
var component, position, sub_container, _ref
|
|
2589
|
+
var component, position, sub_container, _ref;
|
|
1924
2590
|
if (haystack == null) haystack = "name";
|
|
1925
2591
|
if (deep == null) deep = false;
|
|
1926
2592
|
if (this.componentsCreated !== true) this.createComponents();
|
|
1927
2593
|
position = (_ref = this.componentIndex) != null ? _ref[haystack][needle] : void 0;
|
|
1928
|
-
component =
|
|
2594
|
+
component = this.components[position];
|
|
1929
2595
|
if (component) return component;
|
|
1930
2596
|
if (deep === true) {
|
|
1931
2597
|
sub_container = _(this.components).detect(function(component) {
|
|
@@ -1958,20 +2624,16 @@
|
|
|
1958
2624
|
return this.components[this.activeItem];
|
|
1959
2625
|
},
|
|
1960
2626
|
componentElements: function() {
|
|
1961
|
-
return this.$("
|
|
2627
|
+
return this.$("[data-luca-parent='" + (this.name || this.cid) + "']");
|
|
1962
2628
|
},
|
|
1963
2629
|
getComponent: function(needle) {
|
|
1964
2630
|
return this.components[needle];
|
|
1965
2631
|
},
|
|
1966
|
-
rootComponent: function() {
|
|
1967
|
-
console.log("Calling rootComponent will be deprecated. use isRootComponent instead");
|
|
1968
|
-
return !(this.getParent != null);
|
|
1969
|
-
},
|
|
1970
2632
|
isRootComponent: function() {
|
|
1971
2633
|
return !(this.getParent != null);
|
|
1972
2634
|
},
|
|
1973
2635
|
getRootComponent: function() {
|
|
1974
|
-
if (this.
|
|
2636
|
+
if (this.isRootComponent()) {
|
|
1975
2637
|
return this;
|
|
1976
2638
|
} else {
|
|
1977
2639
|
return this.getParent().getRootComponent();
|
|
@@ -1979,23 +2641,21 @@
|
|
|
1979
2641
|
},
|
|
1980
2642
|
selectByAttribute: function(attribute, value, deep) {
|
|
1981
2643
|
var components;
|
|
2644
|
+
if (value == null) value = void 0;
|
|
1982
2645
|
if (deep == null) deep = false;
|
|
1983
2646
|
components = _(this.components).map(function(component) {
|
|
1984
2647
|
var matches, test;
|
|
1985
2648
|
matches = [];
|
|
1986
2649
|
test = component[attribute];
|
|
1987
|
-
if (test === value)
|
|
2650
|
+
if (test === value || (!(value != null) && (test != null))) {
|
|
2651
|
+
matches.push(component);
|
|
2652
|
+
}
|
|
1988
2653
|
if (deep === true) {
|
|
1989
2654
|
matches.push(typeof component.selectByAttribute === "function" ? component.selectByAttribute(attribute, value, true) : void 0);
|
|
1990
2655
|
}
|
|
1991
2656
|
return _.compact(matches);
|
|
1992
2657
|
});
|
|
1993
2658
|
return _.flatten(components);
|
|
1994
|
-
},
|
|
1995
|
-
select: function(attribute, value, deep) {
|
|
1996
|
-
if (deep == null) deep = false;
|
|
1997
|
-
console.log("Container.select will be replaced by selectByAttribute in 1.0");
|
|
1998
|
-
return Luca.core.Container.prototype.selectByAttribute.apply(this, arguments);
|
|
1999
2659
|
}
|
|
2000
2660
|
});
|
|
2001
2661
|
|
|
@@ -2005,6 +2665,97 @@
|
|
|
2005
2665
|
return attachMethod(component.render().el);
|
|
2006
2666
|
};
|
|
2007
2667
|
|
|
2668
|
+
doLayout = function() {
|
|
2669
|
+
this.trigger("before:layout", this);
|
|
2670
|
+
this.prepareLayout();
|
|
2671
|
+
return this.trigger("after:layout", this);
|
|
2672
|
+
};
|
|
2673
|
+
|
|
2674
|
+
applyDOMConfig = function(panel, panelIndex) {
|
|
2675
|
+
var config, style_declarations;
|
|
2676
|
+
style_declarations = [];
|
|
2677
|
+
if (panel.height != null) {
|
|
2678
|
+
style_declarations.push("height: " + (_.isNumber(panel.height) ? panel.height + 'px' : panel.height));
|
|
2679
|
+
}
|
|
2680
|
+
if (panel.width != null) {
|
|
2681
|
+
style_declarations.push("width: " + (_.isNumber(panel.width) ? panel.width + 'px' : panel.width));
|
|
2682
|
+
}
|
|
2683
|
+
if (panel.float) style_declarations.push("float: " + panel.float);
|
|
2684
|
+
config = {
|
|
2685
|
+
"class": (panel != null ? panel.classes : void 0) || this.componentClass,
|
|
2686
|
+
id: "" + this.cid + "-" + panelIndex,
|
|
2687
|
+
style: style_declarations.join(';'),
|
|
2688
|
+
"data-luca-parent": this.name || this.cid
|
|
2689
|
+
};
|
|
2690
|
+
if (this.customizeContainerEl != null) {
|
|
2691
|
+
config = this.customizeContainerEl(config, panel, panelIndex);
|
|
2692
|
+
}
|
|
2693
|
+
return config;
|
|
2694
|
+
};
|
|
2695
|
+
|
|
2696
|
+
createGetterMethods = function() {
|
|
2697
|
+
var childrenWithGetter;
|
|
2698
|
+
container = this;
|
|
2699
|
+
childrenWithGetter = _(this.allChildren()).select(function(component) {
|
|
2700
|
+
return component.getter != null;
|
|
2701
|
+
});
|
|
2702
|
+
return _(childrenWithGetter).each(function(component) {
|
|
2703
|
+
var _name;
|
|
2704
|
+
return container[_name = component.getter] || (container[_name] = function() {
|
|
2705
|
+
console.log("getter is being deprecated in favor of role");
|
|
2706
|
+
console.log(component.getter, component, container);
|
|
2707
|
+
return component;
|
|
2708
|
+
});
|
|
2709
|
+
});
|
|
2710
|
+
};
|
|
2711
|
+
|
|
2712
|
+
createMethodsToGetComponentsByRole = function() {
|
|
2713
|
+
var childrenWithRole;
|
|
2714
|
+
container = this;
|
|
2715
|
+
childrenWithRole = _(this.allChildren()).select(function(component) {
|
|
2716
|
+
return component.role != null;
|
|
2717
|
+
});
|
|
2718
|
+
return _(childrenWithRole).each(function(component) {
|
|
2719
|
+
var getter;
|
|
2720
|
+
getter = _.str.camelize("get_" + component.role);
|
|
2721
|
+
return container[getter] || (container[getter] = function() {
|
|
2722
|
+
return component;
|
|
2723
|
+
});
|
|
2724
|
+
});
|
|
2725
|
+
};
|
|
2726
|
+
|
|
2727
|
+
doComponents = function() {
|
|
2728
|
+
this.trigger("before:components", this, this.components);
|
|
2729
|
+
this.prepareComponents();
|
|
2730
|
+
this.createComponents();
|
|
2731
|
+
this.trigger("before:render:components", this, this.components);
|
|
2732
|
+
this.renderComponents();
|
|
2733
|
+
this.trigger("after:components", this, this.components);
|
|
2734
|
+
createGetterMethods.call(this);
|
|
2735
|
+
createMethodsToGetComponentsByRole.call(this);
|
|
2736
|
+
return this.registerComponentEvents();
|
|
2737
|
+
};
|
|
2738
|
+
|
|
2739
|
+
validateContainerConfiguration = function() {
|
|
2740
|
+
return true;
|
|
2741
|
+
};
|
|
2742
|
+
|
|
2743
|
+
indexComponent = function(component) {
|
|
2744
|
+
return {
|
|
2745
|
+
at: function(index) {
|
|
2746
|
+
return {
|
|
2747
|
+
"in": function(map) {
|
|
2748
|
+
if (component.cid != null) map.cid_index[component.cid] = index;
|
|
2749
|
+
if (component.role != null) map.role_index[component.role] = index;
|
|
2750
|
+
if (component.name != null) {
|
|
2751
|
+
return map.name_index[component.name] = index;
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
};
|
|
2755
|
+
}
|
|
2756
|
+
};
|
|
2757
|
+
};
|
|
2758
|
+
|
|
2008
2759
|
}).call(this);
|
|
2009
2760
|
(function() {
|
|
2010
2761
|
var guessCollectionClass, handleInitialCollections, loadInitialCollections;
|
|
@@ -2055,7 +2806,12 @@
|
|
|
2055
2806
|
CollectionClass = collectionOptions.base;
|
|
2056
2807
|
CollectionClass || (CollectionClass = guessCollectionClass.call(this, key));
|
|
2057
2808
|
if (collectionOptions.private) collectionOptions.name = "";
|
|
2058
|
-
|
|
2809
|
+
try {
|
|
2810
|
+
collection = new CollectionClass(initialModels, collectionOptions);
|
|
2811
|
+
} catch (e) {
|
|
2812
|
+
console.log("Error creating collection", CollectionClass, collectionOptions, key);
|
|
2813
|
+
throw e;
|
|
2814
|
+
}
|
|
2059
2815
|
this.add(key, collection);
|
|
2060
2816
|
collectionManager = this;
|
|
2061
2817
|
if (this.relayEvents === true) {
|
|
@@ -2129,10 +2885,28 @@
|
|
|
2129
2885
|
|
|
2130
2886
|
})();
|
|
2131
2887
|
|
|
2888
|
+
Luca.CollectionManager.isRunning = function() {
|
|
2889
|
+
return _.isEmpty(Luca.CollectionManager.instances) !== true;
|
|
2890
|
+
};
|
|
2891
|
+
|
|
2132
2892
|
Luca.CollectionManager.destroyAll = function() {
|
|
2133
2893
|
return Luca.CollectionManager.instances = {};
|
|
2134
2894
|
};
|
|
2135
2895
|
|
|
2896
|
+
Luca.CollectionManager.loadCollectionsByName = function(set, callback) {
|
|
2897
|
+
var collection, name, _i, _len, _results;
|
|
2898
|
+
_results = [];
|
|
2899
|
+
for (_i = 0, _len = set.length; _i < _len; _i++) {
|
|
2900
|
+
name = set[_i];
|
|
2901
|
+
collection = this.getOrCreate(name);
|
|
2902
|
+
collection.once("reset", function() {
|
|
2903
|
+
return callback(collection);
|
|
2904
|
+
});
|
|
2905
|
+
_results.push(collection.fetch());
|
|
2906
|
+
}
|
|
2907
|
+
return _results;
|
|
2908
|
+
};
|
|
2909
|
+
|
|
2136
2910
|
guessCollectionClass = function(key) {
|
|
2137
2911
|
var classified, guess, guesses, _ref;
|
|
2138
2912
|
classified = Luca.util.classify(key);
|
|
@@ -2149,7 +2923,7 @@
|
|
|
2149
2923
|
};
|
|
2150
2924
|
|
|
2151
2925
|
loadInitialCollections = function() {
|
|
2152
|
-
var collectionDidLoad,
|
|
2926
|
+
var collectionDidLoad, set,
|
|
2153
2927
|
_this = this;
|
|
2154
2928
|
collectionDidLoad = function(collection) {
|
|
2155
2929
|
var current;
|
|
@@ -2158,14 +2932,8 @@
|
|
|
2158
2932
|
_this.trigger("collection_loaded", collection.name);
|
|
2159
2933
|
return collection.unbind("reset");
|
|
2160
2934
|
};
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
collection = _this.getOrCreate(name);
|
|
2164
|
-
collection.once("reset", function() {
|
|
2165
|
-
return collectionDidLoad(collection);
|
|
2166
|
-
});
|
|
2167
|
-
return collection.fetch();
|
|
2168
|
-
});
|
|
2935
|
+
set = this.initialCollections;
|
|
2936
|
+
return Luca.CollectionManager.loadCollectionsByName.call(this, set, collectionDidLoad);
|
|
2169
2937
|
};
|
|
2170
2938
|
|
|
2171
2939
|
handleInitialCollections = function() {
|
|
@@ -2184,6 +2952,7 @@
|
|
|
2184
2952
|
}));
|
|
2185
2953
|
}
|
|
2186
2954
|
loadInitialCollections.call(this);
|
|
2955
|
+
this.initialCollectionsLoadedu;
|
|
2187
2956
|
return this;
|
|
2188
2957
|
};
|
|
2189
2958
|
|
|
@@ -2296,9 +3065,13 @@
|
|
|
2296
3065
|
|
|
2297
3066
|
}).call(this);
|
|
2298
3067
|
(function() {
|
|
3068
|
+
var component;
|
|
3069
|
+
|
|
3070
|
+
component = Luca.define("Luca.containers.CardView");
|
|
2299
3071
|
|
|
2300
|
-
|
|
2301
|
-
|
|
3072
|
+
component["extends"]("Luca.core.Container");
|
|
3073
|
+
|
|
3074
|
+
component.defaults({
|
|
2302
3075
|
className: 'luca-ui-card-view-wrapper',
|
|
2303
3076
|
activeCard: 0,
|
|
2304
3077
|
components: [],
|
|
@@ -2308,21 +3081,16 @@
|
|
|
2308
3081
|
initialize: function(options) {
|
|
2309
3082
|
this.options = options;
|
|
2310
3083
|
Luca.core.Container.prototype.initialize.apply(this, arguments);
|
|
2311
|
-
|
|
3084
|
+
this.setupHooks(this.hooks);
|
|
3085
|
+
return this.components || (this.components = this.pages || (this.pages = this.cards));
|
|
2312
3086
|
},
|
|
2313
3087
|
prepareComponents: function() {
|
|
2314
|
-
var _ref
|
|
2315
|
-
_this = this;
|
|
3088
|
+
var _ref;
|
|
2316
3089
|
if ((_ref = Luca.core.Container.prototype.prepareComponents) != null) {
|
|
2317
3090
|
_ref.apply(this, arguments);
|
|
2318
3091
|
}
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
return $(component.container).show();
|
|
2322
|
-
} else {
|
|
2323
|
-
return $(component.container).hide();
|
|
2324
|
-
}
|
|
2325
|
-
});
|
|
3092
|
+
this.componentElements().hide();
|
|
3093
|
+
return this.activeComponentElement().show();
|
|
2326
3094
|
},
|
|
2327
3095
|
activeComponentElement: function() {
|
|
2328
3096
|
return this.componentElements().eq(this.activeCard);
|
|
@@ -2334,13 +3102,27 @@
|
|
|
2334
3102
|
containerEl.style += panelIndex === this.activeCard ? "display:block;" : "display:none;";
|
|
2335
3103
|
return containerEl;
|
|
2336
3104
|
},
|
|
3105
|
+
atFirst: function() {
|
|
3106
|
+
return this.activeCard === 0;
|
|
3107
|
+
},
|
|
3108
|
+
atLast: function() {
|
|
3109
|
+
return this.activeCard === this.components.length - 1;
|
|
3110
|
+
},
|
|
3111
|
+
next: function() {
|
|
3112
|
+
if (this.atLast()) return;
|
|
3113
|
+
return this.activate(this.activeCard + 1);
|
|
3114
|
+
},
|
|
3115
|
+
previous: function() {
|
|
3116
|
+
if (this.atFirst()) return;
|
|
3117
|
+
return this.activate(this.activeCard - 1);
|
|
3118
|
+
},
|
|
2337
3119
|
cycle: function() {
|
|
2338
3120
|
var nextIndex;
|
|
2339
|
-
nextIndex = this.
|
|
3121
|
+
nextIndex = this.atLast() ? 0 : this.activeCard + 1;
|
|
2340
3122
|
return this.activate(nextIndex);
|
|
2341
3123
|
},
|
|
2342
3124
|
find: function(name) {
|
|
2343
|
-
return
|
|
3125
|
+
return Luca(name);
|
|
2344
3126
|
},
|
|
2345
3127
|
firstActivation: function() {
|
|
2346
3128
|
return this.activeComponent().trigger("first:activation", this, this.activeComponent());
|
|
@@ -2420,45 +3202,105 @@
|
|
|
2420
3202
|
return this.$el.modal('hide');
|
|
2421
3203
|
},
|
|
2422
3204
|
render: function() {
|
|
2423
|
-
this.$el.addClass('modal');
|
|
2424
|
-
if (this.fade === true) this.$el.addClass('fade');
|
|
2425
|
-
$('body').append(this.$el);
|
|
2426
|
-
this.$el.modal({
|
|
2427
|
-
backdrop: this.backdrop === true,
|
|
2428
|
-
keyboard: this.closeOnEscape === true,
|
|
2429
|
-
show: this.showOnInitialize === true
|
|
2430
|
-
});
|
|
3205
|
+
this.$el.addClass('modal');
|
|
3206
|
+
if (this.fade === true) this.$el.addClass('fade');
|
|
3207
|
+
$('body').append(this.$el);
|
|
3208
|
+
this.$el.modal({
|
|
3209
|
+
backdrop: this.backdrop === true,
|
|
3210
|
+
keyboard: this.closeOnEscape === true,
|
|
3211
|
+
show: this.showOnInitialize === true
|
|
3212
|
+
});
|
|
3213
|
+
return this;
|
|
3214
|
+
}
|
|
3215
|
+
});
|
|
3216
|
+
|
|
3217
|
+
_.def("Luca.containers.ModalView")["extends"]("Luca.ModalView")["with"]();
|
|
3218
|
+
|
|
3219
|
+
}).call(this);
|
|
3220
|
+
(function() {
|
|
3221
|
+
|
|
3222
|
+
_.def("Luca.PageView")["extends"]("Luca.containers.CardView")["with"]({
|
|
3223
|
+
version: 2
|
|
3224
|
+
});
|
|
3225
|
+
|
|
3226
|
+
}).call(this);
|
|
3227
|
+
(function() {
|
|
3228
|
+
var buildButton, make, panelToolbar, prepareButtons;
|
|
3229
|
+
|
|
3230
|
+
panelToolbar = Luca.register("Luca.components.PanelToolbar");
|
|
3231
|
+
|
|
3232
|
+
panelToolbar["extends"]("Luca.View");
|
|
3233
|
+
|
|
3234
|
+
panelToolbar.defines({
|
|
3235
|
+
buttons: [],
|
|
3236
|
+
className: "luca-ui-toolbar btn-toolbar",
|
|
3237
|
+
well: true,
|
|
3238
|
+
orientation: 'top',
|
|
3239
|
+
autoBindEventHandlers: true,
|
|
3240
|
+
events: {
|
|
3241
|
+
"click a.btn, click .dropdown-menu li": "clickHandler"
|
|
3242
|
+
},
|
|
3243
|
+
initialize: function(options) {
|
|
3244
|
+
var _ref;
|
|
3245
|
+
this.options = options != null ? options : {};
|
|
3246
|
+
this._super("initialize", this, arguments);
|
|
3247
|
+
if (this.group === true && ((_ref = this.buttons) != null ? _ref.length : void 0) >= 0) {
|
|
3248
|
+
return this.buttons = [
|
|
3249
|
+
{
|
|
3250
|
+
group: true,
|
|
3251
|
+
buttons: this.buttons
|
|
3252
|
+
}
|
|
3253
|
+
];
|
|
3254
|
+
}
|
|
3255
|
+
},
|
|
3256
|
+
clickHandler: function(e) {
|
|
3257
|
+
var eventId, hook, me, my, source;
|
|
3258
|
+
me = my = $(e.target);
|
|
3259
|
+
if (me.is('i')) me = my = $(e.target).parent();
|
|
3260
|
+
if (this.selectable === true) {
|
|
3261
|
+
my.siblings().removeClass("is-selected");
|
|
3262
|
+
me.addClass('is-selected');
|
|
3263
|
+
}
|
|
3264
|
+
if (!(eventId = my.data('eventid'))) return;
|
|
3265
|
+
hook = Luca.util.hook(eventId);
|
|
3266
|
+
source = this.parent || this;
|
|
3267
|
+
if (_.isFunction(source[hook])) {
|
|
3268
|
+
return source[hook].call(this, me, e);
|
|
3269
|
+
} else {
|
|
3270
|
+
return source.trigger(eventId, me, e);
|
|
3271
|
+
}
|
|
3272
|
+
},
|
|
3273
|
+
beforeRender: function() {
|
|
3274
|
+
this._super("beforeRender", this, arguments);
|
|
3275
|
+
if (this.well === true) this.$el.addClass('well');
|
|
3276
|
+
if (this.selectable === true) this.$el.addClass('btn-selectable');
|
|
3277
|
+
this.$el.addClass("toolbar-" + this.orientation);
|
|
3278
|
+
if (this.align === "right") this.$el.addClass("pull-right");
|
|
3279
|
+
if (this.align === "left") return this.$el.addClass("pull-left");
|
|
3280
|
+
},
|
|
3281
|
+
render: function() {
|
|
3282
|
+
var element, _i, _len, _ref;
|
|
3283
|
+
this.$el.empty();
|
|
3284
|
+
_ref = prepareButtons(this.buttons);
|
|
3285
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
3286
|
+
element = _ref[_i];
|
|
3287
|
+
this.$el.append(element);
|
|
3288
|
+
}
|
|
2431
3289
|
return this;
|
|
2432
3290
|
}
|
|
2433
3291
|
});
|
|
2434
3292
|
|
|
2435
|
-
_.def("Luca.containers.ModalView")["extends"]("Luca.ModalView")["with"]();
|
|
2436
|
-
|
|
2437
|
-
}).call(this);
|
|
2438
|
-
(function() {
|
|
2439
|
-
|
|
2440
|
-
_.def("Luca.PageView")["extends"]("Luca.containers.CardView")["with"]({
|
|
2441
|
-
version: 2
|
|
2442
|
-
});
|
|
2443
|
-
|
|
2444
|
-
}).call(this);
|
|
2445
|
-
(function() {
|
|
2446
|
-
var buildButton, make, prepareButtons;
|
|
2447
|
-
|
|
2448
3293
|
make = Backbone.View.prototype.make;
|
|
2449
3294
|
|
|
2450
3295
|
buildButton = function(config, wrap) {
|
|
2451
3296
|
var autoWrapClass, buttonAttributes, buttonEl, buttons, dropdownEl, dropdownItems, label, object, white, wrapper,
|
|
2452
3297
|
_this = this;
|
|
2453
3298
|
if (wrap == null) wrap = true;
|
|
2454
|
-
if (config.ctype != null) {
|
|
3299
|
+
if ((config.ctype != null) || (config.type != null)) {
|
|
2455
3300
|
config.className || (config.className = "");
|
|
2456
3301
|
config.className += 'toolbar-component';
|
|
2457
3302
|
object = Luca(config).render();
|
|
2458
|
-
if (Luca.isBackboneView(object))
|
|
2459
|
-
console.log("Adding toolbar component", object);
|
|
2460
|
-
return object.el;
|
|
2461
|
-
}
|
|
3303
|
+
if (Luca.isBackboneView(object)) return object.$el;
|
|
2462
3304
|
}
|
|
2463
3305
|
if (config.spacer) {
|
|
2464
3306
|
return make("div", {
|
|
@@ -2471,8 +3313,11 @@
|
|
|
2471
3313
|
}, config.text);
|
|
2472
3314
|
}
|
|
2473
3315
|
wrapper = 'btn-group';
|
|
2474
|
-
if (config.wrapper != null) wrapper += "
|
|
2475
|
-
if (config.align != null)
|
|
3316
|
+
if (config.wrapper != null) wrapper += "" + config.wrapper;
|
|
3317
|
+
if (config.align != null) {
|
|
3318
|
+
wrapper += "pull-" + config.align + " align-" + config.align;
|
|
3319
|
+
}
|
|
3320
|
+
if (config.selectable === true) wrapper += 'btn-selectable';
|
|
2476
3321
|
if ((config.group != null) && (config.buttons != null)) {
|
|
2477
3322
|
buttons = prepareButtons(config.buttons, false);
|
|
2478
3323
|
return make("div", {
|
|
@@ -2494,6 +3339,7 @@
|
|
|
2494
3339
|
if (config.color != null) {
|
|
2495
3340
|
buttonAttributes["class"] += " btn-" + config.color;
|
|
2496
3341
|
}
|
|
3342
|
+
if (config.selected != null) buttonAttributes["class"] += " is-selected";
|
|
2497
3343
|
if (config.dropdown) {
|
|
2498
3344
|
label = "" + label + " <span class='caret'></span>";
|
|
2499
3345
|
buttonAttributes["class"] += " dropdown-toggle";
|
|
@@ -2523,51 +3369,16 @@
|
|
|
2523
3369
|
};
|
|
2524
3370
|
|
|
2525
3371
|
prepareButtons = function(buttons, wrap) {
|
|
3372
|
+
var button, _i, _len, _results;
|
|
3373
|
+
if (buttons == null) buttons = [];
|
|
2526
3374
|
if (wrap == null) wrap = true;
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
_.def("Luca.containers.PanelToolbar")["extends"]("Luca.View")["with"]({
|
|
2533
|
-
className: "luca-ui-toolbar btn-toolbar",
|
|
2534
|
-
buttons: [],
|
|
2535
|
-
well: true,
|
|
2536
|
-
orientation: 'top',
|
|
2537
|
-
autoBindEventHandlers: true,
|
|
2538
|
-
events: {
|
|
2539
|
-
"click a.btn, click .dropdown-menu li": "clickHandler"
|
|
2540
|
-
},
|
|
2541
|
-
clickHandler: function(e) {
|
|
2542
|
-
var eventId, hook, me, my, source;
|
|
2543
|
-
me = my = $(e.target);
|
|
2544
|
-
if (me.is('i')) me = my = $(e.target).parent();
|
|
2545
|
-
eventId = my.data('eventid');
|
|
2546
|
-
if (eventId == null) return;
|
|
2547
|
-
hook = Luca.util.hook(eventId);
|
|
2548
|
-
source = this.parent || this;
|
|
2549
|
-
if (_.isFunction(source[hook])) {
|
|
2550
|
-
return source[hook].call(this, me, e);
|
|
2551
|
-
} else {
|
|
2552
|
-
return source.trigger(eventId, me, e);
|
|
2553
|
-
}
|
|
2554
|
-
},
|
|
2555
|
-
beforeRender: function() {
|
|
2556
|
-
this._super("beforeRender", this, arguments);
|
|
2557
|
-
if (this.well === true) this.$el.addClass('well');
|
|
2558
|
-
this.$el.addClass("toolbar-" + this.orientation);
|
|
2559
|
-
if (this.styles != null) return this.applyStyles(this.styles);
|
|
2560
|
-
},
|
|
2561
|
-
render: function() {
|
|
2562
|
-
var elements,
|
|
2563
|
-
_this = this;
|
|
2564
|
-
this.$el.empty();
|
|
2565
|
-
elements = prepareButtons(this.buttons);
|
|
2566
|
-
return _(elements).each(function(element) {
|
|
2567
|
-
return _this.$el.append(element);
|
|
2568
|
-
});
|
|
3375
|
+
_results = [];
|
|
3376
|
+
for (_i = 0, _len = buttons.length; _i < _len; _i++) {
|
|
3377
|
+
button = buttons[_i];
|
|
3378
|
+
_results.push(buildButton(button, wrap));
|
|
2569
3379
|
}
|
|
2570
|
-
|
|
3380
|
+
return _results;
|
|
3381
|
+
};
|
|
2571
3382
|
|
|
2572
3383
|
}).call(this);
|
|
2573
3384
|
(function() {
|
|
@@ -2633,11 +3444,12 @@
|
|
|
2633
3444
|
return (_ref = Luca.containers.CardView.prototype.beforeLayout) != null ? _ref.apply(this, arguments) : void 0;
|
|
2634
3445
|
},
|
|
2635
3446
|
afterRender: function() {
|
|
2636
|
-
var _ref;
|
|
3447
|
+
var tabContainerId, _ref;
|
|
2637
3448
|
if ((_ref = Luca.containers.CardView.prototype.afterRender) != null) {
|
|
2638
3449
|
_ref.apply(this, arguments);
|
|
2639
3450
|
}
|
|
2640
|
-
|
|
3451
|
+
tabContainerId = this.tabContainer().attr("id");
|
|
3452
|
+
this.registerEvent("click #" + tabContainerId + " li a", "select");
|
|
2641
3453
|
if (Luca.enableBootstrap && (this.tab_position === "left" || this.tab_position === "right")) {
|
|
2642
3454
|
this.tabContainerWrapper().addClass("span2");
|
|
2643
3455
|
return this.tabContentWrapper().addClass("span9");
|
|
@@ -2648,7 +3460,9 @@
|
|
|
2648
3460
|
tabView = this;
|
|
2649
3461
|
return this.each(function(component, index) {
|
|
2650
3462
|
var icon, link, selector, _ref;
|
|
2651
|
-
if (component.tabIcon)
|
|
3463
|
+
if (component.tabIcon) {
|
|
3464
|
+
icon = "<i class='icon-" + component.tabIcon + "'></i>";
|
|
3465
|
+
}
|
|
2652
3466
|
link = "<a href='#'>" + (icon || '') + " " + component.title + "</a>";
|
|
2653
3467
|
selector = tabView.make("li", {
|
|
2654
3468
|
"class": "tab-selector",
|
|
@@ -2711,10 +3525,20 @@
|
|
|
2711
3525
|
if (this.fullscreen === true) return this.enableFullscreen();
|
|
2712
3526
|
},
|
|
2713
3527
|
enableFluid: function() {
|
|
2714
|
-
return this
|
|
3528
|
+
return this.enableWrapper();
|
|
2715
3529
|
},
|
|
2716
3530
|
disableFluid: function() {
|
|
2717
|
-
return this
|
|
3531
|
+
return this.disableWrapper();
|
|
3532
|
+
},
|
|
3533
|
+
enableWrapper: function() {
|
|
3534
|
+
if (this.wrapperClass != null) {
|
|
3535
|
+
return this.$el.parent().addClass(this.wrapperClass);
|
|
3536
|
+
}
|
|
3537
|
+
},
|
|
3538
|
+
disableWrapper: function() {
|
|
3539
|
+
if (this.wrapperClass != null) {
|
|
3540
|
+
return this.$el.parent().removeClass(this.wrapperClass);
|
|
3541
|
+
}
|
|
2718
3542
|
},
|
|
2719
3543
|
enableFullscreen: function() {
|
|
2720
3544
|
$('html,body').addClass('luca-ui-fullscreen');
|
|
@@ -2769,16 +3593,6 @@
|
|
|
2769
3593
|
|
|
2770
3594
|
Luca.containers.Viewport.fluidWrapperClass = 'row-fluid';
|
|
2771
3595
|
|
|
2772
|
-
}).call(this);
|
|
2773
|
-
(function() {
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
}).call(this);
|
|
2778
|
-
(function() {
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
3596
|
}).call(this);
|
|
2783
3597
|
(function() {
|
|
2784
3598
|
|
|
@@ -2829,7 +3643,7 @@
|
|
|
2829
3643
|
Luca.Application.instances[appName] = app;
|
|
2830
3644
|
Luca.containers.Viewport.prototype.initialize.apply(this, arguments);
|
|
2831
3645
|
this.state = new Luca.Model(this.defaultState);
|
|
2832
|
-
this.setupMainController();
|
|
3646
|
+
if (this.useController === true) this.setupMainController();
|
|
2833
3647
|
this.setupCollectionManager();
|
|
2834
3648
|
this.defer(function() {
|
|
2835
3649
|
return app.render();
|
|
@@ -2933,7 +3747,9 @@
|
|
|
2933
3747
|
});
|
|
2934
3748
|
}
|
|
2935
3749
|
return (_ref2 = this.getMainController()) != null ? _ref2.each(function(component) {
|
|
2936
|
-
|
|
3750
|
+
var type;
|
|
3751
|
+
type = component.type || component.type;
|
|
3752
|
+
if (type.match(/controller$/)) {
|
|
2937
3753
|
return component.bind("after:card:switch", function(previous, current) {
|
|
2938
3754
|
_this.state.set({
|
|
2939
3755
|
active_sub_section: current.name
|
|
@@ -2949,7 +3765,7 @@
|
|
|
2949
3765
|
definedComponents = this.components || [];
|
|
2950
3766
|
this.components = [
|
|
2951
3767
|
{
|
|
2952
|
-
|
|
3768
|
+
type: 'controller',
|
|
2953
3769
|
name: "main_controller",
|
|
2954
3770
|
components: definedComponents
|
|
2955
3771
|
}
|
|
@@ -2958,25 +3774,27 @@
|
|
|
2958
3774
|
}
|
|
2959
3775
|
},
|
|
2960
3776
|
setupCollectionManager: function() {
|
|
2961
|
-
var collectionManagerOptions, _base, _ref, _ref2;
|
|
2962
|
-
if (this.useCollectionManager
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
3777
|
+
var collectionManagerOptions, _base, _ref, _ref2, _ref3;
|
|
3778
|
+
if (this.useCollectionManager !== true) return;
|
|
3779
|
+
if ((this.collectionManager != null) && (((_ref = this.collectionManager) != null ? _ref.get : void 0) != null)) {
|
|
3780
|
+
return;
|
|
3781
|
+
}
|
|
3782
|
+
if (_.isString(this.collectionManagerClass)) {
|
|
3783
|
+
this.collectionManagerClass = Luca.util.resolve(this.collectionManagerClass);
|
|
3784
|
+
}
|
|
3785
|
+
collectionManagerOptions = this.collectionManagerOptions || {};
|
|
3786
|
+
if (_.isObject(this.collectionManager) && !_.isFunction((_ref2 = this.collectionManager) != null ? _ref2.get : void 0)) {
|
|
3787
|
+
collectionManagerOptions = this.collectionManager;
|
|
3788
|
+
this.collectionManager = void 0;
|
|
3789
|
+
}
|
|
3790
|
+
if (_.isString(this.collectionManager)) {
|
|
3791
|
+
collectionManagerOptions = {
|
|
3792
|
+
name: this.collectionManager
|
|
3793
|
+
};
|
|
3794
|
+
}
|
|
3795
|
+
this.collectionManager = typeof (_base = Luca.CollectionManager).get === "function" ? _base.get(collectionManagerOptions.name) : void 0;
|
|
3796
|
+
if (!_.isFunction((_ref3 = this.collectionManager) != null ? _ref3.get : void 0)) {
|
|
3797
|
+
return this.collectionManager = new this.collectionManagerClass(collectionManagerOptions);
|
|
2980
3798
|
}
|
|
2981
3799
|
},
|
|
2982
3800
|
setupRouter: function() {
|
|
@@ -3072,23 +3890,31 @@
|
|
|
3072
3890
|
|
|
3073
3891
|
}).call(this);
|
|
3074
3892
|
(function() {
|
|
3075
|
-
var make;
|
|
3893
|
+
var collectionView, make;
|
|
3894
|
+
|
|
3895
|
+
collectionView = Luca.define("Luca.components.CollectionView");
|
|
3896
|
+
|
|
3897
|
+
collectionView["extends"]("Luca.components.Panel");
|
|
3076
3898
|
|
|
3077
|
-
|
|
3078
|
-
|
|
3899
|
+
collectionView.behavesAs("LoadMaskable", "Filterable", "Paginatable");
|
|
3900
|
+
|
|
3901
|
+
collectionView.triggers("before:refresh", "after:refresh", "refresh", "empty:results");
|
|
3902
|
+
|
|
3903
|
+
collectionView.defaults({
|
|
3904
|
+
tagName: "ol",
|
|
3079
3905
|
className: "luca-ui-collection-view",
|
|
3080
3906
|
bodyClassName: "collection-ui-panel",
|
|
3081
3907
|
itemTemplate: void 0,
|
|
3082
3908
|
itemRenderer: void 0,
|
|
3083
3909
|
itemTagName: 'li',
|
|
3084
3910
|
itemClassName: 'collection-item',
|
|
3085
|
-
hooks: ["empty:results"],
|
|
3086
3911
|
initialize: function(options) {
|
|
3087
3912
|
var _this = this;
|
|
3088
3913
|
this.options = options != null ? options : {};
|
|
3089
3914
|
_.extend(this, this.options);
|
|
3090
3915
|
_.bindAll(this, "refresh");
|
|
3091
3916
|
if (!((this.collection != null) || this.options.collection)) {
|
|
3917
|
+
console.log("Error on initialize of collection view", this);
|
|
3092
3918
|
throw "Collection Views must specify a collection";
|
|
3093
3919
|
}
|
|
3094
3920
|
if (!((this.itemTemplate != null) || (this.itemRenderer != null) || (this.itemProperty != null))) {
|
|
@@ -3098,65 +3924,113 @@
|
|
|
3098
3924
|
if (_.isString(this.collection) && Luca.CollectionManager.get()) {
|
|
3099
3925
|
this.collection = Luca.CollectionManager.get().getOrCreate(this.collection);
|
|
3100
3926
|
}
|
|
3101
|
-
if (Luca.isBackboneCollection(this.collection)) {
|
|
3927
|
+
if (!Luca.isBackboneCollection(this.collection)) {
|
|
3928
|
+
throw "Collection Views must have a valid backbone collection";
|
|
3102
3929
|
this.collection.on("before:fetch", function() {
|
|
3103
|
-
|
|
3930
|
+
return _this.trigger("enable:loadmask");
|
|
3104
3931
|
});
|
|
3105
3932
|
this.collection.bind("reset", function() {
|
|
3106
|
-
|
|
3933
|
+
_this.refresh();
|
|
3934
|
+
return _this.trigger("disable:loadmask");
|
|
3935
|
+
});
|
|
3936
|
+
this.collection.bind("remove", function() {
|
|
3107
3937
|
return _this.refresh();
|
|
3108
3938
|
});
|
|
3109
|
-
this.collection.bind("add",
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3939
|
+
this.collection.bind("add", function() {
|
|
3940
|
+
return _this.refresh();
|
|
3941
|
+
});
|
|
3942
|
+
if (this.observeChanges === true) {
|
|
3943
|
+
this.collection.on("change", this.refreshModel, this);
|
|
3944
|
+
}
|
|
3945
|
+
}
|
|
3946
|
+
if (this.autoRefreshOnModelsPresent !== false) {
|
|
3947
|
+
this.defer(function() {
|
|
3948
|
+
if (_this.collection.length > 0) return _this.refresh();
|
|
3949
|
+
}).until("after:render");
|
|
3113
3950
|
}
|
|
3114
|
-
|
|
3951
|
+
return this.on("collection:change", this.refresh, this);
|
|
3115
3952
|
},
|
|
3116
|
-
attributesForItem: function(item) {
|
|
3953
|
+
attributesForItem: function(item, model) {
|
|
3117
3954
|
return _.extend({}, {
|
|
3118
3955
|
"class": this.itemClassName,
|
|
3119
|
-
"data-index": item.index
|
|
3956
|
+
"data-index": item.index,
|
|
3957
|
+
"data-model-id": item.model.get('id')
|
|
3120
3958
|
});
|
|
3121
3959
|
},
|
|
3122
3960
|
contentForItem: function(item) {
|
|
3123
3961
|
var content, templateFn;
|
|
3124
3962
|
if (item == null) item = {};
|
|
3125
3963
|
if ((this.itemTemplate != null) && (templateFn = Luca.template(this.itemTemplate))) {
|
|
3126
|
-
content = templateFn.call(this, item);
|
|
3964
|
+
return content = templateFn.call(this, item);
|
|
3127
3965
|
}
|
|
3128
3966
|
if ((this.itemRenderer != null) && _.isFunction(this.itemRenderer)) {
|
|
3129
|
-
content = this.itemRenderer.call(this, item, item.model, item.index);
|
|
3967
|
+
return content = this.itemRenderer.call(this, item, item.model, item.index);
|
|
3130
3968
|
}
|
|
3131
|
-
if (this.itemProperty) {
|
|
3132
|
-
content = item.model.
|
|
3133
|
-
if (_.isFunction(content)) content = content();
|
|
3969
|
+
if (this.itemProperty && (item.model != null)) {
|
|
3970
|
+
return content = item.model.read(this.itemProperty);
|
|
3134
3971
|
}
|
|
3135
|
-
return
|
|
3972
|
+
return "";
|
|
3136
3973
|
},
|
|
3137
3974
|
makeItem: function(model, index) {
|
|
3138
|
-
var item;
|
|
3975
|
+
var attributes, content, item;
|
|
3139
3976
|
item = this.prepareItem != null ? this.prepareItem.call(this, model, index) : {
|
|
3140
3977
|
model: model,
|
|
3141
3978
|
index: index
|
|
3142
3979
|
};
|
|
3143
|
-
|
|
3980
|
+
attributes = this.attributesForItem(item, model);
|
|
3981
|
+
content = this.contentForItem(item);
|
|
3982
|
+
try {
|
|
3983
|
+
return make(this.itemTagName, attributes, content);
|
|
3984
|
+
} catch (e) {
|
|
3985
|
+
return console.log("Error generating DOM element for CollectionView", this, model, index);
|
|
3986
|
+
}
|
|
3987
|
+
},
|
|
3988
|
+
getCollection: function() {
|
|
3989
|
+
return this.collection;
|
|
3990
|
+
},
|
|
3991
|
+
getQuery: function() {
|
|
3992
|
+
return this.query || (this.query = {});
|
|
3144
3993
|
},
|
|
3145
|
-
|
|
3994
|
+
getQueryOptions: function() {
|
|
3995
|
+
return this.queryOptions || (this.queryOptions = {});
|
|
3996
|
+
},
|
|
3997
|
+
getModels: function(query, options) {
|
|
3146
3998
|
var _ref;
|
|
3147
|
-
if ((
|
|
3148
|
-
|
|
3999
|
+
if ((_ref = this.collection) != null ? _ref.query : void 0) {
|
|
4000
|
+
query || (query = this.getQuery());
|
|
4001
|
+
options || (options = this.getQueryOptions());
|
|
4002
|
+
return this.collection.query(query, options);
|
|
3149
4003
|
} else {
|
|
3150
4004
|
return this.collection.models;
|
|
3151
4005
|
}
|
|
3152
4006
|
},
|
|
3153
|
-
|
|
3154
|
-
|
|
4007
|
+
locateItemElement: function(id) {
|
|
4008
|
+
return this.$("." + this.itemClassName + "[data-model-id='" + id + "']");
|
|
4009
|
+
},
|
|
4010
|
+
refreshModel: function(model) {
|
|
4011
|
+
var index;
|
|
4012
|
+
index = this.collection.indexOf(model);
|
|
4013
|
+
this.locateItemElement(model.get('id')).empty().append(this.contentForItem({
|
|
4014
|
+
model: model,
|
|
4015
|
+
index: index
|
|
4016
|
+
}, model));
|
|
4017
|
+
return this.trigger("model:refreshed", index, model);
|
|
4018
|
+
},
|
|
4019
|
+
refresh: function(query, options) {
|
|
4020
|
+
var index, model, models, _i, _len;
|
|
4021
|
+
query || (query = this.getQuery());
|
|
4022
|
+
options || (options = this.getQueryOptions());
|
|
3155
4023
|
this.$bodyEl().empty();
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
4024
|
+
models = this.getModels(query, options);
|
|
4025
|
+
this.trigger("before:refresh", models, query, options);
|
|
4026
|
+
if (models.length === 0) this.trigger("empty:results");
|
|
4027
|
+
index = 0;
|
|
4028
|
+
for (_i = 0, _len = models.length; _i < _len; _i++) {
|
|
4029
|
+
model = models[_i];
|
|
4030
|
+
this.$append(this.makeItem(model, index++));
|
|
4031
|
+
}
|
|
4032
|
+
this.trigger("after:refresh", models, query, options);
|
|
4033
|
+
return this;
|
|
3160
4034
|
},
|
|
3161
4035
|
registerEvent: function(domEvent, selector, handler) {
|
|
3162
4036
|
var eventTrigger;
|
|
@@ -3442,10 +4316,10 @@
|
|
|
3442
4316
|
return this.label || (this.label = this.name);
|
|
3443
4317
|
},
|
|
3444
4318
|
setValue: function(checked) {
|
|
3445
|
-
return this.
|
|
4319
|
+
return this.getInputElement().attr('checked', checked);
|
|
3446
4320
|
},
|
|
3447
4321
|
getValue: function() {
|
|
3448
|
-
return this.
|
|
4322
|
+
return this.getInputElement().is(":checked");
|
|
3449
4323
|
}
|
|
3450
4324
|
});
|
|
3451
4325
|
|
|
@@ -3454,10 +4328,6 @@
|
|
|
3454
4328
|
|
|
3455
4329
|
_.def('Luca.fields.FileUploadField')["extends"]('Luca.core.Field')["with"]({
|
|
3456
4330
|
template: 'fields/file_upload_field',
|
|
3457
|
-
initialize: function(options) {
|
|
3458
|
-
this.options = options != null ? options : {};
|
|
3459
|
-
return Luca.core.Field.prototype.initialize.apply(this, arguments);
|
|
3460
|
-
},
|
|
3461
4331
|
afterInitialize: function() {
|
|
3462
4332
|
this.input_id || (this.input_id = _.uniqueId('field'));
|
|
3463
4333
|
this.input_name || (this.input_name = this.name);
|
|
@@ -3471,10 +4341,6 @@
|
|
|
3471
4341
|
|
|
3472
4342
|
_.def('Luca.fields.HiddenField')["extends"]('Luca.core.Field')["with"]({
|
|
3473
4343
|
template: 'fields/hidden_field',
|
|
3474
|
-
initialize: function(options) {
|
|
3475
|
-
this.options = options != null ? options : {};
|
|
3476
|
-
return Luca.core.Field.prototype.initialize.apply(this, arguments);
|
|
3477
|
-
},
|
|
3478
4344
|
afterInitialize: function() {
|
|
3479
4345
|
this.input_id || (this.input_id = _.uniqueId('field'));
|
|
3480
4346
|
this.input_name || (this.input_name = this.name);
|
|
@@ -3488,16 +4354,13 @@
|
|
|
3488
4354
|
|
|
3489
4355
|
_.def("Luca.components.LabelField")["extends"]("Luca.core.Field")["with"]({
|
|
3490
4356
|
className: "luca-ui-field luca-ui-label-field",
|
|
3491
|
-
getValue: function() {
|
|
3492
|
-
return this.$('input').attr('value');
|
|
3493
|
-
},
|
|
3494
4357
|
formatter: function(value) {
|
|
3495
4358
|
value || (value = this.getValue());
|
|
3496
4359
|
return _.str.titleize(value);
|
|
3497
4360
|
},
|
|
3498
4361
|
setValue: function(value) {
|
|
3499
4362
|
this.trigger("change", value, this.getValue());
|
|
3500
|
-
this
|
|
4363
|
+
this.getInputElement().attr('value', value);
|
|
3501
4364
|
return this.$('.value').html(this.formatter(value));
|
|
3502
4365
|
}
|
|
3503
4366
|
});
|
|
@@ -3552,9 +4415,11 @@
|
|
|
3552
4415
|
return hash;
|
|
3553
4416
|
});
|
|
3554
4417
|
},
|
|
4418
|
+
getInputElement: function() {
|
|
4419
|
+
return this.input || (this.input = this.$('select').eq(0));
|
|
4420
|
+
},
|
|
3555
4421
|
afterRender: function() {
|
|
3556
4422
|
var _ref, _ref2;
|
|
3557
|
-
this.input = $('select', this.el);
|
|
3558
4423
|
if (((_ref = this.collection) != null ? (_ref2 = _ref.models) != null ? _ref2.length : void 0 : void 0) > 0) {
|
|
3559
4424
|
return this.populateOptions();
|
|
3560
4425
|
} else {
|
|
@@ -3572,9 +4437,9 @@
|
|
|
3572
4437
|
return this.trigger("on:change", this, e);
|
|
3573
4438
|
},
|
|
3574
4439
|
resetOptions: function() {
|
|
3575
|
-
this.
|
|
4440
|
+
this.getInputElement().html('');
|
|
3576
4441
|
if (this.includeBlank) {
|
|
3577
|
-
return this.
|
|
4442
|
+
return this.getInputElement().append("<option value='" + this.blankValue + "'>" + this.blankText + "</option>");
|
|
3578
4443
|
}
|
|
3579
4444
|
},
|
|
3580
4445
|
populateOptions: function() {
|
|
@@ -3588,7 +4453,7 @@
|
|
|
3588
4453
|
display = model.get(_this.displayField);
|
|
3589
4454
|
if (_this.selected && value === _this.selected) selected = "selected";
|
|
3590
4455
|
option = "<option " + selected + " value='" + value + "'>" + display + "</option>";
|
|
3591
|
-
return _this.
|
|
4456
|
+
return _this.getInputElement().append(option);
|
|
3592
4457
|
});
|
|
3593
4458
|
}
|
|
3594
4459
|
this.trigger("after:populate:options", this);
|
|
@@ -3616,6 +4481,7 @@
|
|
|
3616
4481
|
this.input_name || (this.input_name = this.name);
|
|
3617
4482
|
this.label || (this.label = this.name);
|
|
3618
4483
|
this.input_class || (this.input_class = this["class"]);
|
|
4484
|
+
this.input_value || (this.input_value = "");
|
|
3619
4485
|
return this.inputStyles || (this.inputStyles = "height:" + this.height + ";width:" + this.width);
|
|
3620
4486
|
},
|
|
3621
4487
|
setValue: function(value) {
|
|
@@ -3661,6 +4527,7 @@
|
|
|
3661
4527
|
this.input_name || (this.input_name = this.name);
|
|
3662
4528
|
this.label || (this.label = this.name);
|
|
3663
4529
|
this.input_class || (this.input_class = this["class"]);
|
|
4530
|
+
this.input_value || (this.input_value = this.value || "");
|
|
3664
4531
|
if (this.prepend) {
|
|
3665
4532
|
this.$el.addClass('input-prepend');
|
|
3666
4533
|
this.addOn = this.prepend;
|
|
@@ -3691,19 +4558,18 @@
|
|
|
3691
4558
|
_.def('Luca.fields.TypeAheadField')["extends"]('Luca.fields.TextField')["with"]({
|
|
3692
4559
|
className: 'luca-ui-field',
|
|
3693
4560
|
getSource: function() {
|
|
3694
|
-
|
|
3695
|
-
return this.source || [];
|
|
4561
|
+
return Luca.util.read(this.source) || [];
|
|
3696
4562
|
},
|
|
3697
4563
|
matcher: function(item) {
|
|
3698
4564
|
return true;
|
|
3699
4565
|
},
|
|
3700
4566
|
beforeRender: function() {
|
|
3701
|
-
|
|
3702
|
-
return this
|
|
4567
|
+
Luca.fields.TextField.prototype.beforeRender.apply(this, arguments);
|
|
4568
|
+
return this.getInputElement().attr('data-provide', 'typeahead');
|
|
3703
4569
|
},
|
|
3704
4570
|
afterRender: function() {
|
|
3705
|
-
|
|
3706
|
-
return this
|
|
4571
|
+
Luca.fields.TextField.prototype.afterRender.apply(this, arguments);
|
|
4572
|
+
return this.getInputElement().typeahead({
|
|
3707
4573
|
matcher: this.matcher,
|
|
3708
4574
|
source: this.getSource()
|
|
3709
4575
|
});
|
|
@@ -3780,6 +4646,7 @@
|
|
|
3780
4646
|
this.options = options != null ? options : {};
|
|
3781
4647
|
if (this.loadMask == null) this.loadMask = Luca.enableBootstrap;
|
|
3782
4648
|
Luca.core.Container.prototype.initialize.apply(this, arguments);
|
|
4649
|
+
this.components || (this.components = this.fields);
|
|
3783
4650
|
_.bindAll(this, "submitHandler", "resetHandler", "renderToolbars", "applyLoadMask");
|
|
3784
4651
|
this.state || (this.state = new Backbone.Model);
|
|
3785
4652
|
this.setupHooks(this.hooks);
|
|
@@ -4258,6 +5125,93 @@
|
|
|
4258
5125
|
bodyTemplate: "components/load_mask"
|
|
4259
5126
|
});
|
|
4260
5127
|
|
|
5128
|
+
}).call(this);
|
|
5129
|
+
(function() {
|
|
5130
|
+
var bubbleCollectionEvents, multiView, propagateCollectionComponents, validateComponent;
|
|
5131
|
+
|
|
5132
|
+
multiView = Luca.define("Luca.components.MultiCollectionView");
|
|
5133
|
+
|
|
5134
|
+
multiView["extends"]("Luca.containers.CardView");
|
|
5135
|
+
|
|
5136
|
+
multiView.behavesAs("LoadMaskable", "Filterable", "Paginatable");
|
|
5137
|
+
|
|
5138
|
+
multiView.triggers("before:refresh", "after:refresh", "refresh", "empty:results");
|
|
5139
|
+
|
|
5140
|
+
multiView.defaultsTo({
|
|
5141
|
+
version: 1,
|
|
5142
|
+
stateful: true,
|
|
5143
|
+
defaultState: {
|
|
5144
|
+
activeView: 0
|
|
5145
|
+
},
|
|
5146
|
+
viewContainerClass: "luca-ui-multi-view-container",
|
|
5147
|
+
initialize: function(options) {
|
|
5148
|
+
var view, _i, _len, _ref;
|
|
5149
|
+
this.options = options != null ? options : {};
|
|
5150
|
+
this.components || (this.components = this.views);
|
|
5151
|
+
_ref = this.components;
|
|
5152
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
5153
|
+
view = _ref[_i];
|
|
5154
|
+
validateComponent(view);
|
|
5155
|
+
}
|
|
5156
|
+
this.on("collection:change", this.refresh, this);
|
|
5157
|
+
this.on("after:card:switch", this.refresh, this);
|
|
5158
|
+
this.on("before:components", propagateCollectionComponents, this);
|
|
5159
|
+
this.on("after:components", bubbleCollectionEvents, this);
|
|
5160
|
+
return Luca.containers.CardView.prototype.initialize.apply(this, arguments);
|
|
5161
|
+
},
|
|
5162
|
+
refresh: function() {
|
|
5163
|
+
var _ref;
|
|
5164
|
+
return (_ref = this.activeComponent()) != null ? _ref.trigger("refresh") : void 0;
|
|
5165
|
+
},
|
|
5166
|
+
getQuery: Luca.components.CollectionView.prototype.getQuery,
|
|
5167
|
+
getQueryOptions: Luca.components.CollectionView.prototype.getQueryOptions,
|
|
5168
|
+
getCollection: Luca.components.CollectionView.prototype.getCollection
|
|
5169
|
+
});
|
|
5170
|
+
|
|
5171
|
+
bubbleCollectionEvents = function() {
|
|
5172
|
+
var container;
|
|
5173
|
+
container = this;
|
|
5174
|
+
return container.eachComponent(function(component) {
|
|
5175
|
+
var eventId, _i, _len, _ref, _results;
|
|
5176
|
+
_ref = ['refresh', 'before:refresh', 'after:refresh', 'empty:results'];
|
|
5177
|
+
_results = [];
|
|
5178
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
5179
|
+
eventId = _ref[_i];
|
|
5180
|
+
_results.push(component.on(eventId, function() {
|
|
5181
|
+
if (component === container.activeComponent()) {
|
|
5182
|
+
return container.trigger(eventId);
|
|
5183
|
+
}
|
|
5184
|
+
}));
|
|
5185
|
+
}
|
|
5186
|
+
return _results;
|
|
5187
|
+
});
|
|
5188
|
+
};
|
|
5189
|
+
|
|
5190
|
+
propagateCollectionComponents = function() {
|
|
5191
|
+
var component, container, _i, _len, _ref, _results;
|
|
5192
|
+
container = this;
|
|
5193
|
+
_ref = this.components;
|
|
5194
|
+
_results = [];
|
|
5195
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
5196
|
+
component = _ref[_i];
|
|
5197
|
+
_results.push(_.extend(component, {
|
|
5198
|
+
collection: (typeof container.getCollection === "function" ? container.getCollection() : void 0) || this.collection,
|
|
5199
|
+
getQuery: container.getQuery,
|
|
5200
|
+
getQueryOptions: container.getQueryOptions
|
|
5201
|
+
}));
|
|
5202
|
+
}
|
|
5203
|
+
return _results;
|
|
5204
|
+
};
|
|
5205
|
+
|
|
5206
|
+
validateComponent = function(component) {
|
|
5207
|
+
var type;
|
|
5208
|
+
type = component.type || component.ctype;
|
|
5209
|
+
if (type === "collection" || type === "collection_view" || type === "table" || type === "table_view") {
|
|
5210
|
+
return;
|
|
5211
|
+
}
|
|
5212
|
+
throw "The MultiCollectionView expects to contain multiple collection views";
|
|
5213
|
+
};
|
|
5214
|
+
|
|
4261
5215
|
}).call(this);
|
|
4262
5216
|
(function() {
|
|
4263
5217
|
|
|
@@ -4292,6 +5246,119 @@
|
|
|
4292
5246
|
version: 2
|
|
4293
5247
|
});
|
|
4294
5248
|
|
|
5249
|
+
}).call(this);
|
|
5250
|
+
(function() {
|
|
5251
|
+
var paginationControl;
|
|
5252
|
+
|
|
5253
|
+
paginationControl = Luca.register("Luca.components.PaginationControl");
|
|
5254
|
+
|
|
5255
|
+
paginationControl["extends"]("Luca.View");
|
|
5256
|
+
|
|
5257
|
+
paginationControl.defines({
|
|
5258
|
+
template: "components/pagination",
|
|
5259
|
+
stateful: true,
|
|
5260
|
+
autoBindEventHandlers: true,
|
|
5261
|
+
events: {
|
|
5262
|
+
"click a[data-page-number]": "selectPage",
|
|
5263
|
+
"click a.next": "nextPage",
|
|
5264
|
+
"click a.prev": "previousPage"
|
|
5265
|
+
},
|
|
5266
|
+
afterInitialize: function() {
|
|
5267
|
+
_.bindAll(this, "refresh");
|
|
5268
|
+
return this.state.on("change", this.refresh, this);
|
|
5269
|
+
},
|
|
5270
|
+
limit: function() {
|
|
5271
|
+
var _ref;
|
|
5272
|
+
return parseInt(this.state.get('limit') || ((_ref = this.collection) != null ? _ref.length : void 0));
|
|
5273
|
+
},
|
|
5274
|
+
page: function() {
|
|
5275
|
+
return parseInt(this.state.get('page') || 1);
|
|
5276
|
+
},
|
|
5277
|
+
nextPage: function() {
|
|
5278
|
+
if (!this.nextEnabled()) return;
|
|
5279
|
+
return this.state.set('page', this.page() + 1);
|
|
5280
|
+
},
|
|
5281
|
+
previousPage: function() {
|
|
5282
|
+
if (!this.previousEnabled()) return;
|
|
5283
|
+
return this.state.set('page', this.page() - 1);
|
|
5284
|
+
},
|
|
5285
|
+
selectPage: function(e) {
|
|
5286
|
+
var me, my;
|
|
5287
|
+
me = my = this.$(e.target);
|
|
5288
|
+
if (!me.is('a.page')) me = my = my.closest('a.page');
|
|
5289
|
+
my.siblings().removeClass('is-selected');
|
|
5290
|
+
me.addClass('is-selected');
|
|
5291
|
+
return this.setPage(my.data('page-number'));
|
|
5292
|
+
},
|
|
5293
|
+
setPage: function(page, options) {
|
|
5294
|
+
if (page == null) page = 1;
|
|
5295
|
+
if (options == null) options = {};
|
|
5296
|
+
return this.state.set('page', page, options);
|
|
5297
|
+
},
|
|
5298
|
+
setLimit: function(limit, options) {
|
|
5299
|
+
if (limit == null) limit = 1;
|
|
5300
|
+
if (options == null) options = {};
|
|
5301
|
+
return this.state.set('limit', limit, options);
|
|
5302
|
+
},
|
|
5303
|
+
pageButtonContainer: function() {
|
|
5304
|
+
return this.$('.group');
|
|
5305
|
+
},
|
|
5306
|
+
previousEnabled: function() {
|
|
5307
|
+
return this.page() > 1;
|
|
5308
|
+
},
|
|
5309
|
+
nextEnabled: function() {
|
|
5310
|
+
return this.page() < this.totalPages();
|
|
5311
|
+
},
|
|
5312
|
+
previousButton: function() {
|
|
5313
|
+
return this.$('a.page.prev');
|
|
5314
|
+
},
|
|
5315
|
+
nextButton: function() {
|
|
5316
|
+
return this.$('a.page.next');
|
|
5317
|
+
},
|
|
5318
|
+
pageButtons: function() {
|
|
5319
|
+
return this.$('a[data-page-number]', this.pageButtonContainer());
|
|
5320
|
+
},
|
|
5321
|
+
refresh: function() {
|
|
5322
|
+
var button, page, _ref;
|
|
5323
|
+
this.pageButtonContainer().empty();
|
|
5324
|
+
for (page = 1, _ref = this.totalPages(); 1 <= _ref ? page <= _ref : page >= _ref; 1 <= _ref ? page++ : page--) {
|
|
5325
|
+
button = this.make("a", {
|
|
5326
|
+
"data-page-number": page,
|
|
5327
|
+
"class": "page"
|
|
5328
|
+
}, page);
|
|
5329
|
+
this.pageButtonContainer().append(button);
|
|
5330
|
+
}
|
|
5331
|
+
this.toggleNavigationButtons();
|
|
5332
|
+
this.selectActivePageButton();
|
|
5333
|
+
return this;
|
|
5334
|
+
},
|
|
5335
|
+
toggleNavigationButtons: function() {
|
|
5336
|
+
this.$('a.next, a.prev').addClass('disabled');
|
|
5337
|
+
if (this.nextEnabled()) this.nextButton().removeClass('disabled');
|
|
5338
|
+
if (this.previousEnabled()) {
|
|
5339
|
+
return this.previousButton().removeClass('disabled');
|
|
5340
|
+
}
|
|
5341
|
+
},
|
|
5342
|
+
selectActivePageButton: function() {
|
|
5343
|
+
return this.activePageButton().addClass('is-selected');
|
|
5344
|
+
},
|
|
5345
|
+
activePageButton: function() {
|
|
5346
|
+
return this.pageButtons().filter("[data-page-number='" + (this.page()) + "']");
|
|
5347
|
+
},
|
|
5348
|
+
totalPages: function() {
|
|
5349
|
+
return parseInt(Math.ceil(this.totalItems() / this.itemsPerPage()));
|
|
5350
|
+
},
|
|
5351
|
+
totalItems: function() {
|
|
5352
|
+
var _ref;
|
|
5353
|
+
return parseInt(((_ref = this.collection) != null ? _ref.length : void 0) || 0);
|
|
5354
|
+
},
|
|
5355
|
+
itemsPerPage: function(value, options) {
|
|
5356
|
+
if (options == null) options = {};
|
|
5357
|
+
if (value != null) this.state.set("limit", value, options);
|
|
5358
|
+
return parseInt(this.state.get("limit"));
|
|
5359
|
+
}
|
|
5360
|
+
});
|
|
5361
|
+
|
|
4295
5362
|
}).call(this);
|
|
4296
5363
|
(function() {
|
|
4297
5364
|
|
|
@@ -4535,6 +5602,102 @@
|
|
|
4535
5602
|
}
|
|
4536
5603
|
});
|
|
4537
5604
|
|
|
5605
|
+
}).call(this);
|
|
5606
|
+
(function() {
|
|
5607
|
+
var make;
|
|
5608
|
+
|
|
5609
|
+
_.def("Luca.components.TableView")["extends"]("Luca.components.CollectionView")["with"]({
|
|
5610
|
+
additionalClassNames: "table",
|
|
5611
|
+
tagName: "table",
|
|
5612
|
+
bodyTemplate: "table_view",
|
|
5613
|
+
bodyTagName: "tbody",
|
|
5614
|
+
bodyClassName: "table-body",
|
|
5615
|
+
itemTagName: "tr",
|
|
5616
|
+
stateful: true,
|
|
5617
|
+
observeChanges: true,
|
|
5618
|
+
columns: [],
|
|
5619
|
+
emptyText: "There are no results to display",
|
|
5620
|
+
itemRenderer: function(item, model) {
|
|
5621
|
+
return Luca.components.TableView.rowRenderer.call(this, item, model);
|
|
5622
|
+
},
|
|
5623
|
+
initialize: function(options) {
|
|
5624
|
+
var column,
|
|
5625
|
+
_this = this;
|
|
5626
|
+
this.options = options != null ? options : {};
|
|
5627
|
+
Luca.components.CollectionView.prototype.initialize.apply(this, arguments);
|
|
5628
|
+
this.columns = (function() {
|
|
5629
|
+
var _i, _len, _ref, _results;
|
|
5630
|
+
_ref = this.columns;
|
|
5631
|
+
_results = [];
|
|
5632
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
5633
|
+
column = _ref[_i];
|
|
5634
|
+
if (_.isString(column)) {
|
|
5635
|
+
column = {
|
|
5636
|
+
reader: column
|
|
5637
|
+
};
|
|
5638
|
+
}
|
|
5639
|
+
if (!(column.header != null)) {
|
|
5640
|
+
column.header = _.str.titleize(_.str.humanize(column.reader));
|
|
5641
|
+
}
|
|
5642
|
+
_results.push(column);
|
|
5643
|
+
}
|
|
5644
|
+
return _results;
|
|
5645
|
+
}).call(this);
|
|
5646
|
+
return this.defer(function() {
|
|
5647
|
+
return Luca.components.TableView.renderHeader.call(_this, _this.columns, _this.$('thead'));
|
|
5648
|
+
}).until("after:render");
|
|
5649
|
+
}
|
|
5650
|
+
});
|
|
5651
|
+
|
|
5652
|
+
make = Backbone.View.prototype.make;
|
|
5653
|
+
|
|
5654
|
+
Luca.components.TableView.renderHeader = function(columns, targetElement) {
|
|
5655
|
+
var column, content, index, _i, _len, _results;
|
|
5656
|
+
index = 0;
|
|
5657
|
+
content = (function() {
|
|
5658
|
+
var _i, _len, _results;
|
|
5659
|
+
_results = [];
|
|
5660
|
+
for (_i = 0, _len = columns.length; _i < _len; _i++) {
|
|
5661
|
+
column = columns[_i];
|
|
5662
|
+
_results.push("<th data-col-index='" + (index++) + "'>" + column.header + "</th>");
|
|
5663
|
+
}
|
|
5664
|
+
return _results;
|
|
5665
|
+
})();
|
|
5666
|
+
this.$(targetElement).append("<tr>" + (content.join('')) + "</tr>");
|
|
5667
|
+
index = 0;
|
|
5668
|
+
_results = [];
|
|
5669
|
+
for (_i = 0, _len = columns.length; _i < _len; _i++) {
|
|
5670
|
+
column = columns[_i];
|
|
5671
|
+
if (column.width != null) {
|
|
5672
|
+
_results.push(this.$("th[data-col-index='" + (index++) + "']", targetElement).css('width', column.width));
|
|
5673
|
+
}
|
|
5674
|
+
}
|
|
5675
|
+
return _results;
|
|
5676
|
+
};
|
|
5677
|
+
|
|
5678
|
+
Luca.components.TableView.rowRenderer = function(item, model, index) {
|
|
5679
|
+
var colIndex, columnConfig, _i, _len, _ref, _results;
|
|
5680
|
+
colIndex = 0;
|
|
5681
|
+
_ref = this.columns;
|
|
5682
|
+
_results = [];
|
|
5683
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
5684
|
+
columnConfig = _ref[_i];
|
|
5685
|
+
_results.push(Luca.components.TableView.renderColumn.call(this, columnConfig, item, model, colIndex++));
|
|
5686
|
+
}
|
|
5687
|
+
return _results;
|
|
5688
|
+
};
|
|
5689
|
+
|
|
5690
|
+
Luca.components.TableView.renderColumn = function(column, item, model, index) {
|
|
5691
|
+
var cellValue;
|
|
5692
|
+
cellValue = model.read(column.reader);
|
|
5693
|
+
if (_.isFunction(column.renderer)) {
|
|
5694
|
+
cellValue = column.renderer.call(this, cellValue, model, column);
|
|
5695
|
+
}
|
|
5696
|
+
return make("td", {
|
|
5697
|
+
"data-col-index": index
|
|
5698
|
+
}, cellValue);
|
|
5699
|
+
};
|
|
5700
|
+
|
|
4538
5701
|
}).call(this);
|
|
4539
5702
|
(function() {
|
|
4540
5703
|
|
|
@@ -4572,3 +5735,11 @@
|
|
|
4572
5735
|
|
|
4573
5736
|
|
|
4574
5737
|
}).call(this);
|
|
5738
|
+
(function() {
|
|
5739
|
+
|
|
5740
|
+
|
|
5741
|
+
|
|
5742
|
+
}).call(this);
|
|
5743
|
+
|
|
5744
|
+
|
|
5745
|
+
|