luca 0.8.599 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/.rvmrc +1 -0
- data/CHANGELOG +51 -2
- data/README.md +10 -247
- data/ROADMAP +6 -2
- data/app.rb +16 -2
- data/assets/javascripts/dependencies/bootstrap.min.js +7 -1
- data/assets/javascripts/dependencies/codemirror-coffeescript.js +347 -0
- data/assets/javascripts/dependencies/codemirror-css.js +124 -0
- data/assets/javascripts/dependencies/codemirror-html.js +410 -0
- data/assets/javascripts/dependencies/codemirror-javascript.js +361 -0
- data/assets/javascripts/dependencies/codemirror-less.js +232 -0
- data/assets/javascripts/dependencies/codemirror-vim.js +500 -0
- data/assets/javascripts/dependencies/codemirror.js +3076 -0
- data/assets/javascripts/dependencies.coffee +0 -1
- data/assets/javascripts/luca-ui-base.coffee +10 -3
- data/assets/javascripts/luca-ui-bootstrap.js +1 -0
- data/assets/javascripts/luca-ui-development-tools.coffee +9 -0
- data/assets/javascripts/luca-ui.coffee +6 -1
- data/assets/javascripts/sandbox/application.coffee +51 -0
- data/assets/javascripts/sandbox/router.coffee +14 -0
- data/assets/javascripts/sandbox/templates/main.luca +33 -0
- data/assets/javascripts/sandbox/templates/sandbox/navigation.luca +1 -0
- data/assets/javascripts/sandbox/templates/sandbox.luca +1 -0
- data/assets/javascripts/sandbox/views/top_navigation.coffee +4 -0
- data/assets/javascripts/sandbox.coffee +2 -2
- data/assets/stylesheets/bootstrap.min.css +395 -297
- data/assets/stylesheets/codemirror-blackboard.css +25 -0
- data/assets/stylesheets/codemirror-monokai.css +33 -0
- data/assets/stylesheets/codemirror.css +126 -0
- data/assets/stylesheets/luca-ui-bootstrap.css +0 -1
- data/assets/stylesheets/luca-ui-development-tools.css +5 -0
- data/assets/stylesheets/sandbox/sandbox.scss +1 -3
- data/assets/stylesheets/themes/amelia-bootstrap.css +826 -0
- data/assets/stylesheets/themes/slate-bootstrap.css +797 -0
- data/assets/stylesheets/themes/superhero-bootstrap.css +830 -0
- data/lib/luca/code_browser.rb +55 -0
- data/lib/luca/rails/version.rb +1 -1
- data/lib/luca/rails.rb +1 -0
- data/spec/components/fields/checkbox_array_spec.coffee +46 -0
- data/spec/components/form_view_spec.coffee +10 -4
- data/spec/containers/card_view_spec.coffee +7 -0
- data/spec/core/collection_spec.coffee +58 -4
- data/spec/core/container_spec.coffee +6 -6
- data/spec/core/view_spec.coffee +93 -7
- data/spec/framework_spec.coffee +15 -12
- data/src/components/application.coffee +126 -18
- data/src/components/base_toolbar.coffee +2 -2
- data/src/components/collection_loader_view.coffee +1 -2
- data/src/components/collection_view.coffee +77 -0
- data/src/components/controller.coffee +1 -4
- data/src/components/fields/button_field.coffee +1 -1
- data/src/components/fields/checkbox_array.coffee +2 -2
- data/src/components/fields/checkbox_field.coffee +3 -1
- data/src/components/fields/file_upload_field.coffee +1 -1
- data/src/components/fields/hidden_field.coffee +1 -1
- data/src/components/fields/select_field.coffee +1 -1
- data/src/components/fields/text_area_field.coffee +1 -1
- data/src/components/fields/text_field.coffee +10 -6
- data/src/components/fields/type_ahead_field.coffee +18 -5
- data/src/components/form_button_toolbar.coffee +1 -2
- data/src/components/form_view.coffee +44 -62
- data/src/components/grid_view.coffee +27 -20
- data/src/components/load_mask.coffee +3 -0
- data/src/components/nav_bar.coffee +26 -0
- data/src/components/record_manager.coffee +1 -3
- data/src/components/router.coffee +1 -1
- data/src/components/template.coffee +3 -15
- data/src/components/toolbar_dialog.coffee +25 -0
- data/src/containers/card_view.coffee +22 -23
- data/src/containers/column_view.coffee +1 -6
- data/src/containers/modal_view.coffee +20 -71
- data/src/containers/panel_toolbar.coffee +156 -0
- data/src/containers/panel_view.coffee +1 -1
- data/src/containers/split_view.coffee +1 -3
- data/src/containers/tab_view.coffee +29 -29
- data/src/containers/viewport.coffee +38 -3
- data/src/core/collection.coffee +80 -48
- data/src/core/container.coffee +153 -72
- data/src/core/core.coffee +181 -0
- data/src/core/field.coffee +4 -2
- data/src/core/model.coffee +1 -1
- data/src/core/observer.coffee +3 -3
- data/src/core/panel.coffee +143 -0
- data/src/core/registry.coffee +104 -0
- data/src/core/util.coffee +82 -0
- data/src/core/view.coffee +158 -85
- data/src/framework.coffee +112 -178
- data/src/index.coffee +0 -255
- data/src/managers/collection_manager.coffee +1 -0
- data/src/samples/definition.coffee +49 -0
- data/src/stylesheets/base.scss +0 -78
- data/src/stylesheets/components/form_view.scss +8 -3
- data/src/stylesheets/components/grid_view.scss +3 -7
- data/src/stylesheets/components/load_mask.scss +14 -0
- data/src/stylesheets/components/toolbar.scss +0 -15
- data/src/stylesheets/containers/container.scss +14 -2
- data/src/stylesheets/containers/panels.scss +23 -0
- data/src/stylesheets/tools/class_browser.scss +32 -0
- data/src/stylesheets/tools/code_editor.scss +24 -0
- data/src/stylesheets/tools/component_tester.scss +8 -0
- data/src/stylesheets/tools/console.scss +26 -0
- data/src/templates/components/collection_loader_view.luca +1 -1
- data/src/templates/components/form_view.luca +2 -13
- data/src/templates/components/grid_view.luca +0 -2
- data/src/templates/components/load_mask.luca +3 -0
- data/src/templates/components/nav_bar.luca +2 -0
- data/src/templates/containers/tab_view.luca +1 -0
- data/src/templates/fields/text_field.luca +4 -1
- data/src/tools/class_browser.coffee +39 -0
- data/src/tools/code_editor.coffee +258 -0
- data/src/tools/code_mirror_field.coffee +57 -0
- data/src/tools/coffee_script_editor.coffee +60 -0
- data/src/tools/collection_inspector.coffee +4 -0
- data/src/tools/component_tester.coffee +472 -0
- data/src/tools/components/class_browser_detail.coffee +10 -0
- data/src/tools/components/class_browser_list.coffee +74 -0
- data/src/tools/console.coffee +147 -0
- data/src/tools/development_console.coffee +147 -0
- data/src/tools/models/components.coffee +63 -0
- data/src/tools/templates/component_tester/help.luca +14 -0
- data/vendor/assets/javascripts/luca-ui-base.js +1389 -611
- data/vendor/assets/javascripts/luca-ui-bootstrap.js +9 -0
- data/vendor/assets/javascripts/luca-ui-development-tools.js +18719 -0
- data/vendor/assets/javascripts/luca-ui-spec.js +2065 -878
- data/vendor/assets/javascripts/luca-ui.js +1759 -852
- data/vendor/assets/javascripts/luca-ui.min.js +3 -3
- data/vendor/assets/stylesheets/luca-ui-bootstrap.css +494 -440
- data/vendor/assets/stylesheets/luca-ui-development-tools.css +224 -0
- data/vendor/assets/stylesheets/luca-ui-spec.css +99 -140
- data/vendor/assets/stylesheets/luca-ui.css +99 -140
- data/views/index.erb +6 -3
- metadata +60 -18
- data/assets/javascripts/dependencies/jquery-console.js +0 -649
- data/assets/javascripts/development-console.coffee +0 -2
- data/assets/javascripts/sandbox/sandbox.coffee +0 -16
- data/assets/javascripts/sandbox/templates/features/collection_helpers.luca +0 -33
- data/assets/javascripts/sandbox/templates/features/form_demo_code.luca +0 -48
- data/assets/javascripts/sandbox/templates/features/grid_demo_code.luca +0 -24
- data/assets/javascripts/sandbox/templates/features/introduction.luca +0 -11
- data/assets/javascripts/sandbox/templates/features/view_helpers.luca +0 -43
- data/assets/javascripts/sandbox/templates/navigation.luca +0 -8
- data/assets/javascripts/sandbox/views/form_demo.coffee +0 -47
- data/assets/javascripts/sandbox/views/grid_demo.coffee +0 -23
- data/assets/javascripts/sandbox/views/pages/collection_events_sample.coffee +0 -1
- data/assets/javascripts/sandbox/views/pages/pages_controller.coffee +0 -38
- data/src/components/collection_inspector.coffee +0 -2
- data/src/components/development_console.coffee +0 -59
- data/src/stylesheets/components/development_console.scss +0 -47
@@ -1,28 +1,69 @@
|
|
1
1
|
(function() {
|
2
|
-
var
|
2
|
+
var UnderscoreExtensions,
|
3
|
+
__slice = Array.prototype.slice;
|
4
|
+
|
5
|
+
(window || global).Luca = function() {
|
6
|
+
var args, definition, fallback, inheritsFrom, payload, result;
|
7
|
+
payload = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
8
|
+
if (_.isString(payload) && (result = Luca.cache(payload))) return result;
|
9
|
+
if (_.isString(payload) && (result = Luca.find(payload))) return result;
|
10
|
+
if (_.isObject(payload) && (payload.ctype != null)) {
|
11
|
+
return Luca.util.lazyComponent(payload);
|
12
|
+
}
|
13
|
+
if (_.isObject(payload) && payload.defines && payload["extends"]) {
|
14
|
+
definition = payload.defines;
|
15
|
+
inheritsFrom = payload["extends"];
|
16
|
+
}
|
17
|
+
if (_.isFunction(fallback = _(args).last())) return fallback();
|
18
|
+
};
|
3
19
|
|
4
|
-
|
5
|
-
VERSION: "0.
|
20
|
+
_.extend(Luca, {
|
21
|
+
VERSION: "0.9.0",
|
6
22
|
core: {},
|
7
23
|
containers: {},
|
8
24
|
components: {},
|
9
25
|
modules: {},
|
10
26
|
util: {},
|
11
27
|
fields: {},
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
namespaces: ["Luca.containers", "Luca.components"]
|
19
|
-
}
|
20
|
-
};
|
28
|
+
registry: {}
|
29
|
+
});
|
30
|
+
|
31
|
+
_.extend(Luca, Backbone.Events);
|
32
|
+
|
33
|
+
Luca.developmentMode = false;
|
21
34
|
|
22
35
|
Luca.enableGlobalObserver = false;
|
23
36
|
|
24
37
|
Luca.enableBootstrap = true;
|
25
38
|
|
39
|
+
Luca.keys = {
|
40
|
+
ENTER: 13,
|
41
|
+
ESCAPE: 27,
|
42
|
+
KEYLEFT: 37,
|
43
|
+
KEYUP: 38,
|
44
|
+
KEYRIGHT: 39,
|
45
|
+
KEYDOWN: 40,
|
46
|
+
SPACEBAR: 32,
|
47
|
+
FORWARDSLASH: 191
|
48
|
+
};
|
49
|
+
|
50
|
+
Luca.keyMap = _(Luca.keys).inject(function(memo, value, symbol) {
|
51
|
+
memo[value] = symbol.toLowerCase();
|
52
|
+
return memo;
|
53
|
+
}, {});
|
54
|
+
|
55
|
+
Luca.find = function() {
|
56
|
+
return;
|
57
|
+
};
|
58
|
+
|
59
|
+
Luca.supportsEvents = Luca.supportsBackboneEvents = function(obj) {
|
60
|
+
return Luca.isComponent(obj) || (_.isFunction(obj != null ? obj.trigger : void 0) || _.isFunction(obj != null ? obj.bind : void 0));
|
61
|
+
};
|
62
|
+
|
63
|
+
Luca.isComponent = function(obj) {
|
64
|
+
return Luca.isBackboneModel(obj) || Luca.isBackboneView(obj) || Luca.isBackboneCollection(obj);
|
65
|
+
};
|
66
|
+
|
26
67
|
Luca.isBackboneModel = function(obj) {
|
27
68
|
return _.isFunction(obj != null ? obj.set : void 0) && _.isFunction(obj != null ? obj.get : void 0) && _.isObject(obj != null ? obj.attributes : void 0);
|
28
69
|
};
|
@@ -35,26 +76,103 @@
|
|
35
76
|
return _.isFunction(obj != null ? obj.fetch : void 0) && _.isFunction(obj != null ? obj.reset : void 0);
|
36
77
|
};
|
37
78
|
|
38
|
-
Luca.
|
39
|
-
|
40
|
-
|
79
|
+
Luca.template = function(template_name, variables) {
|
80
|
+
var jst, luca, needle, template, _ref;
|
81
|
+
window.JST || (window.JST = {});
|
82
|
+
if (_.isFunction(template_name)) return template_name(variables);
|
83
|
+
luca = (_ref = Luca.templates) != null ? _ref[template_name] : void 0;
|
84
|
+
jst = typeof JST !== "undefined" && JST !== null ? JST[template_name] : void 0;
|
85
|
+
if (!((luca != null) || (jst != null))) {
|
86
|
+
needle = new RegExp("" + template_name + "$");
|
87
|
+
luca = _(Luca.templates).detect(function(fn, template_id) {
|
88
|
+
return needle.exec(template_id);
|
89
|
+
});
|
90
|
+
jst = _(JST).detect(function(fn, template_id) {
|
91
|
+
return needle.exec(template_id);
|
92
|
+
});
|
93
|
+
}
|
94
|
+
if (!(luca || jst)) throw "Could not find template named " + template_name;
|
95
|
+
template = luca || jst;
|
96
|
+
if (variables != null) return template(variables);
|
97
|
+
return template;
|
41
98
|
};
|
42
99
|
|
43
|
-
Luca.
|
44
|
-
var
|
45
|
-
if (
|
46
|
-
|
47
|
-
if (
|
48
|
-
|
49
|
-
|
50
|
-
|
100
|
+
Luca.available_templates = function(filter) {
|
101
|
+
var available;
|
102
|
+
if (filter == null) filter = "";
|
103
|
+
available = _(Luca.templates).keys();
|
104
|
+
if (filter.length > 0) {
|
105
|
+
return _(available).select(function(tmpl) {
|
106
|
+
return tmpl.match(filter);
|
107
|
+
});
|
108
|
+
} else {
|
109
|
+
return available;
|
51
110
|
}
|
52
|
-
if (component != null) return component;
|
53
|
-
lookup_id = Luca.component_cache.name_index[needle];
|
54
|
-
return Luca.component_cache.cid_index[lookup_id];
|
55
111
|
};
|
56
112
|
|
113
|
+
UnderscoreExtensions = {
|
114
|
+
module: function(base, module) {
|
115
|
+
_.extend(base, module);
|
116
|
+
if (base.included && _(base.included).isFunction()) {
|
117
|
+
return base.included.apply(base);
|
118
|
+
}
|
119
|
+
},
|
120
|
+
"delete": function(object, key) {
|
121
|
+
var value;
|
122
|
+
value = object[key];
|
123
|
+
delete object[key];
|
124
|
+
return value;
|
125
|
+
},
|
126
|
+
idle: function(code, delay) {
|
127
|
+
var handle;
|
128
|
+
if (delay == null) delay = 1000;
|
129
|
+
if (window.DISABLE_IDLE) delay = 0;
|
130
|
+
handle = void 0;
|
131
|
+
return function() {
|
132
|
+
if (handle) window.clearTimeout(handle);
|
133
|
+
return handle = window.setTimeout(_.bind(code, this), delay);
|
134
|
+
};
|
135
|
+
},
|
136
|
+
idleShort: function(code, delay) {
|
137
|
+
var handle;
|
138
|
+
if (delay == null) delay = 100;
|
139
|
+
if (window.DISABLE_IDLE) delay = 0;
|
140
|
+
handle = void 0;
|
141
|
+
return function() {
|
142
|
+
if (handle) window.clearTimeout(handle);
|
143
|
+
return handle = window.setTimeout(_.bind(code, this), delay);
|
144
|
+
};
|
145
|
+
},
|
146
|
+
idleMedium: function(code, delay) {
|
147
|
+
var handle;
|
148
|
+
if (delay == null) delay = 2000;
|
149
|
+
if (window.DISABLE_IDLE) delay = 0;
|
150
|
+
handle = void 0;
|
151
|
+
return function() {
|
152
|
+
if (handle) window.clearTimeout(handle);
|
153
|
+
return handle = window.setTimeout(_.bind(code, this), delay);
|
154
|
+
};
|
155
|
+
},
|
156
|
+
idleLong: function(code, delay) {
|
157
|
+
var handle;
|
158
|
+
if (delay == null) delay = 5000;
|
159
|
+
if (window.DISABLE_IDLE) delay = 0;
|
160
|
+
handle = void 0;
|
161
|
+
return function() {
|
162
|
+
if (handle) window.clearTimeout(handle);
|
163
|
+
return handle = window.setTimeout(_.bind(code, this), delay);
|
164
|
+
};
|
165
|
+
}
|
166
|
+
};
|
167
|
+
|
168
|
+
_.mixin(UnderscoreExtensions);
|
169
|
+
|
170
|
+
}).call(this);
|
171
|
+
(function() {
|
172
|
+
var currentNamespace;
|
173
|
+
|
57
174
|
Luca.util.resolve = function(accessor, source_object) {
|
175
|
+
source_object || (source_object = window || global);
|
58
176
|
return _(accessor.split(/\./)).inject(function(obj, key) {
|
59
177
|
return obj = obj != null ? obj[key] : void 0;
|
60
178
|
}, source_object);
|
@@ -67,22 +185,39 @@
|
|
67
185
|
return _.string.camelize(_.string.capitalize(string));
|
68
186
|
};
|
69
187
|
|
70
|
-
Luca.
|
71
|
-
var
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
return
|
188
|
+
Luca.util.hook = function(eventId) {
|
189
|
+
var fn, parts, prefix;
|
190
|
+
if (eventId == null) eventId = "";
|
191
|
+
parts = eventId.split(':');
|
192
|
+
prefix = parts.shift();
|
193
|
+
parts = _(parts).map(function(p) {
|
194
|
+
return _.string.capitalize(p);
|
77
195
|
});
|
78
|
-
return
|
79
|
-
|
80
|
-
|
196
|
+
return fn = prefix + parts.join('');
|
197
|
+
};
|
198
|
+
|
199
|
+
Luca.util.isIE = function() {
|
200
|
+
try {
|
201
|
+
Object.defineProperty({}, '', {});
|
202
|
+
return false;
|
203
|
+
} catch (e) {
|
204
|
+
return true;
|
205
|
+
}
|
206
|
+
};
|
207
|
+
|
208
|
+
currentNamespace = window || global;
|
209
|
+
|
210
|
+
Luca.util.namespace = function(namespace) {
|
211
|
+
if (namespace == null) return currentNamespace;
|
212
|
+
currentNamespace = _.isString(namespace) ? Luca.util.resolve(namespace, window || global) : namespace;
|
213
|
+
if (currentNamespace != null) return currentNamespace;
|
214
|
+
return currentNamespace = eval("(window||global)." + namespace + " = {}");
|
81
215
|
};
|
82
216
|
|
83
217
|
Luca.util.lazyComponent = function(config) {
|
84
218
|
var componentClass, constructor, ctype;
|
85
|
-
ctype = config.ctype || config.type;
|
219
|
+
if (_.isObject(config)) ctype = config.ctype || config.type;
|
220
|
+
if (_.isString(config)) ctype = config;
|
86
221
|
componentClass = Luca.registry.lookup(ctype);
|
87
222
|
if (!componentClass) {
|
88
223
|
throw "Invalid Component Type: " + ctype + ". Did you forget to register it?";
|
@@ -91,63 +226,47 @@
|
|
91
226
|
return new constructor(config);
|
92
227
|
};
|
93
228
|
|
94
|
-
Luca.
|
95
|
-
var
|
96
|
-
|
97
|
-
|
98
|
-
return console.log("Attempting to register component with the signature " + component + ". Already exists");
|
99
|
-
} else {
|
100
|
-
return Luca.registry.classes[component] = constructor_class;
|
101
|
-
}
|
229
|
+
Luca.util.selectProperties = function(iterator, object, context) {
|
230
|
+
var values;
|
231
|
+
values = _(object).values();
|
232
|
+
return _(values).select(iterator);
|
102
233
|
};
|
103
234
|
|
104
|
-
Luca.
|
105
|
-
var
|
106
|
-
|
107
|
-
|
108
|
-
if (
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
235
|
+
Luca.util.loadScript = function(url, callback) {
|
236
|
+
var script;
|
237
|
+
script = document.createElement("script");
|
238
|
+
script.type = "text/javascript";
|
239
|
+
if (script.readyState) {
|
240
|
+
script.onreadystatechange = function() {
|
241
|
+
if (script.readyState === "loaded" || script.readyState === "complete") {
|
242
|
+
script.onreadystatechange = null;
|
243
|
+
return callback();
|
244
|
+
} else {
|
245
|
+
return script.onload = function() {
|
246
|
+
return callback();
|
247
|
+
};
|
248
|
+
}
|
249
|
+
};
|
114
250
|
}
|
251
|
+
script.src = url;
|
252
|
+
return document.body.appendChild(script);
|
115
253
|
};
|
116
254
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
return false;
|
121
|
-
} catch (e) {
|
122
|
-
return true;
|
123
|
-
}
|
124
|
-
};
|
255
|
+
}).call(this);
|
256
|
+
(function() {
|
257
|
+
var DeferredBindingProxy, DefineProxy;
|
125
258
|
|
126
|
-
Luca.
|
127
|
-
|
128
|
-
window.JST || (window.JST = {});
|
129
|
-
luca = (_ref = Luca.templates) != null ? _ref[template_name] : void 0;
|
130
|
-
jst = typeof JST !== "undefined" && JST !== null ? JST[template_name] : void 0;
|
131
|
-
if (!((luca != null) || (jst != null))) {
|
132
|
-
needle = new RegExp("" + template_name + "$");
|
133
|
-
luca = _(Luca.templates).detect(function(fn, template_id) {
|
134
|
-
return needle.exec(template_id);
|
135
|
-
});
|
136
|
-
jst = _(JST).detect(function(fn, template_id) {
|
137
|
-
return needle.exec(template_id);
|
138
|
-
});
|
139
|
-
}
|
140
|
-
if (!(luca || jst)) throw "Could not find template with " + template_name;
|
141
|
-
template = luca || jst;
|
142
|
-
if (variables != null) return template(variables);
|
143
|
-
return template;
|
259
|
+
Luca.define = function(componentName) {
|
260
|
+
return new DefineProxy(componentName);
|
144
261
|
};
|
145
262
|
|
263
|
+
Luca.component = Luca.define;
|
264
|
+
|
146
265
|
DefineProxy = (function() {
|
147
266
|
|
148
267
|
function DefineProxy(componentName) {
|
149
268
|
var parts;
|
150
|
-
this.namespace =
|
269
|
+
this.namespace = Luca.util.namespace();
|
151
270
|
this.componentId = this.componentName = componentName;
|
152
271
|
if (componentName.match(/\./)) {
|
153
272
|
this.namespaced = true;
|
@@ -178,11 +297,16 @@
|
|
178
297
|
return this;
|
179
298
|
};
|
180
299
|
|
300
|
+
DefineProxy.prototype.enhance = function(properties) {
|
301
|
+
if (properties != null) return this["with"](properties);
|
302
|
+
return this;
|
303
|
+
};
|
304
|
+
|
181
305
|
DefineProxy.prototype["with"] = function(properties) {
|
182
306
|
var at;
|
183
307
|
at = this.namespaced ? Luca.util.resolve(this.namespace, window || global) : window || global;
|
184
|
-
if (this.namespaced &&
|
185
|
-
eval("window." + this.namespace + " = {}");
|
308
|
+
if (this.namespaced && !(at != null)) {
|
309
|
+
eval("(window||global)." + this.namespace + " = {}");
|
186
310
|
at = Luca.util.resolve(this.namespace, window || global);
|
187
311
|
}
|
188
312
|
at[this.componentId] = Luca.extend(this.superClassName, this.componentName, properties);
|
@@ -194,12 +318,6 @@
|
|
194
318
|
|
195
319
|
})();
|
196
320
|
|
197
|
-
Luca.define = function(componentName) {
|
198
|
-
return new DefineProxy(componentName);
|
199
|
-
};
|
200
|
-
|
201
|
-
Luca.component = Luca.define;
|
202
|
-
|
203
321
|
Luca.extend = function(superClassName, childName, properties) {
|
204
322
|
var superClass;
|
205
323
|
if (properties == null) properties = {};
|
@@ -207,307 +325,230 @@
|
|
207
325
|
if (!_.isFunction(superClass != null ? superClass.extend : void 0)) {
|
208
326
|
throw "" + superClassName + " is not a valid component to extend from";
|
209
327
|
}
|
210
|
-
properties.
|
328
|
+
properties.displayName = childName;
|
211
329
|
properties._superClass = function() {
|
212
|
-
superClass.
|
330
|
+
superClass.displayName || (superClass.displayName = superClassName);
|
213
331
|
return superClass;
|
214
332
|
};
|
333
|
+
properties._super = function(method, context, args) {
|
334
|
+
var _ref;
|
335
|
+
return (_ref = this._superClass().prototype[method]) != null ? _ref.apply(context, args) : void 0;
|
336
|
+
};
|
215
337
|
return superClass.extend(properties);
|
216
338
|
};
|
217
339
|
|
218
340
|
_.mixin({
|
219
|
-
|
341
|
+
def: Luca.define
|
220
342
|
});
|
221
343
|
|
222
|
-
|
223
|
-
return $('body').addClass('luca-ui-enabled');
|
224
|
-
})());
|
225
|
-
|
226
|
-
}).call(this);
|
227
|
-
(function() {
|
344
|
+
DeferredBindingProxy = (function() {
|
228
345
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
if (
|
234
|
-
if (_.
|
235
|
-
|
236
|
-
}
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
346
|
+
function DeferredBindingProxy(object, operation, wrapWithUnderscore) {
|
347
|
+
var fn,
|
348
|
+
_this = this;
|
349
|
+
this.object = object;
|
350
|
+
if (wrapWithUnderscore == null) wrapWithUnderscore = true;
|
351
|
+
if (_.isFunction(operation)) {
|
352
|
+
fn = operation;
|
353
|
+
} else if (_.isString(operation) && _.isFunction(this.object[operation])) {
|
354
|
+
fn = this.object[operation];
|
355
|
+
}
|
356
|
+
if (!_.isFunction(fn)) {
|
357
|
+
throw "Must pass a function or a string representing one";
|
358
|
+
}
|
359
|
+
if (wrapWithUnderscore === true) {
|
360
|
+
this.fn = function() {
|
361
|
+
return _.defer(fn);
|
362
|
+
};
|
363
|
+
} else {
|
364
|
+
this.fn = fn;
|
242
365
|
}
|
243
|
-
|
366
|
+
this;
|
244
367
|
}
|
245
|
-
};
|
246
368
|
|
247
|
-
|
248
|
-
(
|
369
|
+
DeferredBindingProxy.prototype.until = function(watch, trigger) {
|
370
|
+
if ((watch != null) && !(trigger != null)) {
|
371
|
+
trigger = watch;
|
372
|
+
watch = this.object;
|
373
|
+
}
|
374
|
+
watch.once(trigger, this.fn);
|
375
|
+
return this.object;
|
376
|
+
};
|
249
377
|
|
250
|
-
|
378
|
+
return DeferredBindingProxy;
|
251
379
|
|
252
|
-
|
253
|
-
var store;
|
254
|
-
this.name = name;
|
255
|
-
store = localStorage.getItem(this.name);
|
256
|
-
this.data = (store && JSON.parse(store)) || {};
|
257
|
-
}
|
380
|
+
})();
|
258
381
|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
382
|
+
Luca.Events = {
|
383
|
+
defer: function(operation, wrapWithUnderscore) {
|
384
|
+
if (wrapWithUnderscore == null) wrapWithUnderscore = true;
|
385
|
+
return new DeferredBindingProxy(this, operation, wrapWithUnderscore);
|
386
|
+
},
|
387
|
+
once: function(trigger, callback, context) {
|
388
|
+
var onceFn;
|
389
|
+
context || (context = this);
|
390
|
+
onceFn = function() {
|
391
|
+
callback.apply(context, arguments);
|
392
|
+
return this.unbind(trigger, onceFn);
|
263
393
|
};
|
264
|
-
return
|
265
|
-
}
|
394
|
+
return this.bind(trigger, onceFn);
|
395
|
+
}
|
396
|
+
};
|
266
397
|
|
267
|
-
|
268
|
-
return localStorage.setItem(this.name, JSON.stringify(this.data));
|
269
|
-
};
|
398
|
+
Luca.ScriptLoader = (function() {
|
270
399
|
|
271
|
-
|
272
|
-
if (!model.id) model.id = model.attribtues.id = this.guid();
|
273
|
-
this.data[model.id] = model;
|
274
|
-
this.save();
|
275
|
-
return model;
|
276
|
-
};
|
400
|
+
ScriptLoader.loaded = {};
|
277
401
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
402
|
+
function ScriptLoader(options) {
|
403
|
+
var ready;
|
404
|
+
if (options == null) options = {};
|
405
|
+
_.extend(this, Backbone.Events, Luca.Events);
|
406
|
+
this.autoStart = options.autoStart === true;
|
407
|
+
this.scripts = options.scripts;
|
408
|
+
ready = function() {
|
409
|
+
return this.trigger("ready");
|
410
|
+
};
|
411
|
+
this.ready = _.after(this.scripts.length, ready);
|
412
|
+
_.bindAll(this, "load", "ready");
|
413
|
+
this.defer("load").until(this, "start");
|
414
|
+
if (this.autoStart === true) this.trigger("start");
|
415
|
+
this.bind("ready", this.onReady);
|
416
|
+
}
|
417
|
+
|
418
|
+
ScriptLoader.prototype.applyPrefix = function(script) {
|
419
|
+
return script;
|
282
420
|
};
|
283
421
|
|
284
|
-
|
285
|
-
return
|
422
|
+
ScriptLoader.prototype.onReady = function() {
|
423
|
+
return console.log("All dependencies loaded");
|
286
424
|
};
|
287
425
|
|
288
|
-
|
289
|
-
return
|
426
|
+
ScriptLoader.prototype.start = function() {
|
427
|
+
return this.trigger("start");
|
290
428
|
};
|
291
429
|
|
292
|
-
|
293
|
-
|
294
|
-
this.
|
295
|
-
|
430
|
+
ScriptLoader.prototype.load = function() {
|
431
|
+
var script, _i, _len, _ref, _results;
|
432
|
+
_ref = this.scripts;
|
433
|
+
_results = [];
|
434
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
435
|
+
script = _ref[_i];
|
436
|
+
_results.push(Luca.util.loadScript(this.applyPrefix(script), this.ready));
|
437
|
+
}
|
438
|
+
return _results;
|
296
439
|
};
|
297
440
|
|
298
|
-
return
|
441
|
+
return ScriptLoader;
|
299
442
|
|
300
443
|
})();
|
301
444
|
|
302
|
-
Backbone.LocalSync = function(method, model, options) {
|
303
|
-
var resp, store;
|
304
|
-
store = model.localStorage || model.collection.localStorage;
|
305
|
-
resp = (function() {
|
306
|
-
switch (method) {
|
307
|
-
case "read":
|
308
|
-
if (model.id) {
|
309
|
-
return store.find(model);
|
310
|
-
} else {
|
311
|
-
return store.findAll();
|
312
|
-
}
|
313
|
-
case "create":
|
314
|
-
return store.create(model);
|
315
|
-
case "update":
|
316
|
-
return store.update(model);
|
317
|
-
case "delete":
|
318
|
-
return store.destroy(model);
|
319
|
-
}
|
320
|
-
})();
|
321
|
-
if (resp) {
|
322
|
-
return options.success(resp);
|
323
|
-
} else {
|
324
|
-
return options.error("Record not found");
|
325
|
-
}
|
326
|
-
};
|
327
|
-
|
328
445
|
}).call(this);
|
329
446
|
(function() {
|
330
|
-
|
331
|
-
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('');};
|
332
|
-
}).call(this);
|
333
|
-
(function() {
|
334
|
-
Luca.templates || (Luca.templates = {});
|
335
|
-
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\' stype=\'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('');};
|
336
|
-
}).call(this);
|
337
|
-
(function() {
|
338
|
-
Luca.templates || (Luca.templates = {});
|
339
|
-
Luca.templates["components/form_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'luca-ui-form-view-wrapper\' id=\'', cid ,'-wrapper\'>\n <div class=\'form-view-header\'>\n <div class=\'toolbar-container top\' id=\'', cid ,'-top-toolbar-container\'></div>\n </div>\n '); if(legend){ __p.push('\n <fieldset>\n <legend>\n ', legend ,'\n </legend>\n <div class=\'form-view-flash-container\'></div>\n <div class=\'form-view-body\'></div>\n </fieldset>\n '); } else { __p.push('\n <ul class=\'form-view-flash-container\'></ul>\n <div class=\'form-view-body\'></div>\n '); } __p.push('\n <div class=\'form-view-footer\'>\n <div class=\'toolbar-container bottom\' id=\'', cid ,'-bottom-toolbar-container\'></div>\n </div>\n</div>\n');}return __p.join('');};
|
340
|
-
}).call(this);
|
341
|
-
(function() {
|
342
|
-
Luca.templates || (Luca.templates = {});
|
343
|
-
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\'>\n <div class=\'toolbar-container top\'></div>\n </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\'>\n <div class=\'toolbar-container bottom\'></div>\n </div>\n</div>\n');}return __p.join('');};
|
344
|
-
}).call(this);
|
345
|
-
(function() {
|
346
|
-
Luca.templates || (Luca.templates = {});
|
347
|
-
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('');};
|
348
|
-
}).call(this);
|
349
|
-
(function() {
|
350
|
-
Luca.templates || (Luca.templates = {});
|
351
|
-
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('');};
|
352
|
-
}).call(this);
|
353
|
-
(function() {
|
354
|
-
Luca.templates || (Luca.templates = {});
|
355
|
-
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('');};
|
356
|
-
}).call(this);
|
357
|
-
(function() {
|
358
|
-
Luca.templates || (Luca.templates = {});
|
359
|
-
Luca.templates["containers/tab_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'tab-content\' id=\'', cid ,'-tab-view-content\'></div>\n');}return __p.join('');};
|
360
|
-
}).call(this);
|
361
|
-
(function() {
|
362
|
-
Luca.templates || (Luca.templates = {});
|
363
|
-
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('');};
|
364
|
-
}).call(this);
|
365
|
-
(function() {
|
366
|
-
Luca.templates || (Luca.templates = {});
|
367
|
-
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('');};
|
368
|
-
}).call(this);
|
369
|
-
(function() {
|
370
|
-
Luca.templates || (Luca.templates = {});
|
371
|
-
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('');};
|
372
|
-
}).call(this);
|
373
|
-
(function() {
|
374
|
-
Luca.templates || (Luca.templates = {});
|
375
|
-
Luca.templates["fields/checkbox_array"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'form-horizontal\'>\n <div class=\'control-group\'>\n <label for=\'', input_id ,'\'>\n ', label ,'\n </label>\n <div class=\'controls\'></div>\n </div>\n</div>\n');}return __p.join('');};
|
376
|
-
}).call(this);
|
377
|
-
(function() {
|
378
|
-
Luca.templates || (Luca.templates = {});
|
379
|
-
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('');};
|
380
|
-
}).call(this);
|
381
|
-
(function() {
|
382
|
-
Luca.templates || (Luca.templates = {});
|
383
|
-
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('');};
|
384
|
-
}).call(this);
|
385
|
-
(function() {
|
386
|
-
Luca.templates || (Luca.templates = {});
|
387
|
-
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('');};
|
388
|
-
}).call(this);
|
389
|
-
(function() {
|
390
|
-
Luca.templates || (Luca.templates = {});
|
391
|
-
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('');};
|
392
|
-
}).call(this);
|
393
|
-
(function() {
|
394
|
-
Luca.templates || (Luca.templates = {});
|
395
|
-
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<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');}return __p.join('');};
|
396
|
-
}).call(this);
|
397
|
-
(function() {
|
398
|
-
Luca.templates || (Luca.templates = {});
|
399
|
-
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('');};
|
400
|
-
}).call(this);
|
401
|
-
(function() {
|
402
|
-
Luca.templates || (Luca.templates = {});
|
403
|
-
Luca.templates["fields/text_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label class=\'control-label\' for=\'', input_id ,'\'>\n ', label ,'\n</label>\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');}return __p.join('');};
|
404
|
-
}).call(this);
|
405
|
-
(function() {
|
406
|
-
Luca.templates || (Luca.templates = {});
|
407
|
-
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('');};
|
408
|
-
}).call(this);
|
409
|
-
(function() {
|
410
|
-
Luca.templates || (Luca.templates = {});
|
411
|
-
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('');};
|
412
|
-
}).call(this);
|
413
|
-
(function() {
|
414
|
-
var __slice = Array.prototype.slice;
|
415
|
-
|
416
|
-
Luca.Observer = (function() {
|
447
|
+
var component_cache, registry;
|
417
448
|
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
this.type = this.options.type;
|
423
|
-
if (this.options.debugAll) {
|
424
|
-
this.bind("event", function() {
|
425
|
-
var args, t;
|
426
|
-
t = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
427
|
-
return console.log("Observed " + _this.type + " " + (t.name || t.id || t.cid), t, _(args).flatten());
|
428
|
-
});
|
429
|
-
}
|
430
|
-
}
|
449
|
+
registry = {
|
450
|
+
classes: {},
|
451
|
+
namespaces: ['Luca.containers', 'Luca.components']
|
452
|
+
};
|
431
453
|
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
return this.trigger("event:" + args[0], triggerer, args.slice(1));
|
437
|
-
};
|
454
|
+
component_cache = {
|
455
|
+
cid_index: {},
|
456
|
+
name_index: {}
|
457
|
+
};
|
438
458
|
|
439
|
-
|
459
|
+
Luca.defaultComponentType = 'view';
|
440
460
|
|
441
|
-
|
461
|
+
Luca.register = function(component, prototypeName) {
|
462
|
+
Luca.trigger("component:registered", component, prototypeName);
|
463
|
+
return registry.classes[component] = prototypeName;
|
464
|
+
};
|
442
465
|
|
443
|
-
Luca.
|
444
|
-
|
445
|
-
|
446
|
-
Luca.
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
466
|
+
Luca.development_mode_register = function(component, prototypeName) {
|
467
|
+
var existing, liveInstances, prototypeDefinition;
|
468
|
+
existing = registry.classes[component];
|
469
|
+
if (Luca.enableDevelopmentTools === true && (existing != null)) {
|
470
|
+
prototypeDefinition = Luca.util.resolve(existing, window);
|
471
|
+
liveInstances = Luca.registry.findInstancesByClassName(prototypeName);
|
472
|
+
_(liveInstances).each(function(instance) {
|
473
|
+
var _ref;
|
474
|
+
return instance != null ? (_ref = instance.refreshCode) != null ? _ref.call(instance, prototypeDefinition) : void 0 : void 0;
|
475
|
+
});
|
476
|
+
}
|
477
|
+
return Luca.register(component, prototypeName);
|
452
478
|
};
|
453
479
|
|
454
|
-
|
455
|
-
(
|
480
|
+
Luca.registry.addNamespace = function(identifier) {
|
481
|
+
registry.namespaces.push(identifier);
|
482
|
+
return registry.namespaces = _(registry.namespaces).uniq();
|
483
|
+
};
|
456
484
|
|
457
|
-
Luca.
|
458
|
-
|
459
|
-
|
485
|
+
Luca.registry.namespaces = function(resolve) {
|
486
|
+
if (resolve == null) resolve = true;
|
487
|
+
return _(registry.namespaces).map(function(namespace) {
|
488
|
+
if (resolve) {
|
489
|
+
return Luca.util.resolve(namespace);
|
490
|
+
} else {
|
491
|
+
return namespace;
|
492
|
+
}
|
493
|
+
});
|
494
|
+
};
|
460
495
|
|
461
|
-
Luca.
|
496
|
+
Luca.registry.lookup = function(ctype) {
|
497
|
+
var c, className, fullPath, parents, _ref;
|
498
|
+
c = registry.classes[ctype];
|
499
|
+
if (c != null) return c;
|
500
|
+
className = Luca.util.classify(ctype);
|
501
|
+
parents = Luca.registry.namespaces();
|
502
|
+
return fullPath = (_ref = _(parents).chain().map(function(parent) {
|
503
|
+
return parent[className];
|
504
|
+
}).compact().value()) != null ? _ref[0] : void 0;
|
505
|
+
};
|
462
506
|
|
463
|
-
Luca.
|
464
|
-
var
|
465
|
-
|
466
|
-
|
467
|
-
var
|
468
|
-
|
469
|
-
if (!($(container) && this.$el)) return this;
|
470
|
-
$(container).append(this.$el);
|
471
|
-
return this;
|
507
|
+
Luca.registry.findInstancesByClassName = function(className) {
|
508
|
+
var instances;
|
509
|
+
instances = _(component_cache.cid_index).values();
|
510
|
+
return _(instances).select(function(instance) {
|
511
|
+
var _ref;
|
512
|
+
return instance.displayName === className || (typeof instance._superClass === "function" ? (_ref = instance._superClass()) != null ? _ref.displayName : void 0 : void 0) === className;
|
472
513
|
});
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
return _this.trigger("after:render", _this);
|
481
|
-
}));
|
482
|
-
if (!this.deferrable_trigger) this.immediate_trigger = true;
|
483
|
-
if (this.immediate_trigger === true) {
|
484
|
-
this.deferrable.fetch();
|
485
|
-
} else {
|
486
|
-
this.bind(this.deferrable_trigger, _.once(function() {
|
487
|
-
return _this.deferrable.fetch();
|
488
|
-
}));
|
489
|
-
}
|
490
|
-
return this;
|
514
|
+
};
|
515
|
+
|
516
|
+
Luca.registry.classes = function(toString) {
|
517
|
+
if (toString == null) toString = false;
|
518
|
+
return _(registry.classes).map(function(className, ctype) {
|
519
|
+
if (toString) {
|
520
|
+
return className;
|
491
521
|
} else {
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
522
|
+
return {
|
523
|
+
className: className,
|
524
|
+
ctype: ctype
|
525
|
+
};
|
496
526
|
}
|
497
|
-
};
|
498
|
-
return Luca.View.originalExtend.call(this, definition);
|
527
|
+
});
|
499
528
|
};
|
500
529
|
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
530
|
+
Luca.cache = function(needle, component) {
|
531
|
+
var lookup_id;
|
532
|
+
if (component != null) component_cache.cid_index[needle] = component;
|
533
|
+
component = component_cache.cid_index[needle];
|
534
|
+
if ((component != null ? component.component_name : void 0) != null) {
|
535
|
+
Luca.trigger("component:created:" + component.component_name, component);
|
536
|
+
component_cache.name_index[component.component_name] = component.cid;
|
537
|
+
} else if ((component != null ? component.name : void 0) != null) {
|
538
|
+
Luca.trigger("component:created:" + component.component_name, component);
|
539
|
+
component_cache.name_index[component.name] = component.cid;
|
540
|
+
}
|
541
|
+
if (component != null) return component;
|
542
|
+
lookup_id = component_cache.name_index[needle];
|
543
|
+
return component_cache.cid_index[lookup_id];
|
544
|
+
};
|
545
|
+
|
546
|
+
}).call(this);
|
547
|
+
(function() {
|
548
|
+
var customizeRender, originalExtend;
|
549
|
+
|
550
|
+
_.def("Luca.View")["extends"]("Backbone.View")["with"]({
|
551
|
+
additionalClassNames: [],
|
511
552
|
debug: function() {
|
512
553
|
var message, _i, _len, _results;
|
513
554
|
if (!(this.debugMode || (window.LucaDebugMode != null))) return;
|
@@ -519,34 +560,65 @@
|
|
519
560
|
return _results;
|
520
561
|
},
|
521
562
|
trigger: function() {
|
522
|
-
if (Luca.enableGlobalObserver
|
523
|
-
Luca.
|
524
|
-
|
525
|
-
|
526
|
-
|
563
|
+
if (Luca.enableGlobalObserver) {
|
564
|
+
if (Luca.developmentMode === true || this.observeEvents === true) {
|
565
|
+
Luca.ViewObserver || (Luca.ViewObserver = new Luca.Observer({
|
566
|
+
type: "view"
|
567
|
+
}));
|
568
|
+
Luca.ViewObserver.relay(this, arguments);
|
569
|
+
}
|
527
570
|
}
|
528
571
|
return Backbone.View.prototype.trigger.apply(this, arguments);
|
529
572
|
},
|
530
573
|
hooks: ["after:initialize", "before:render", "after:render", "first:activation", "activation", "deactivation"],
|
531
|
-
deferrable_event: "reset",
|
532
574
|
initialize: function(options) {
|
533
|
-
var unique,
|
534
|
-
_this = this;
|
575
|
+
var additional, template, unique, _i, _len, _ref;
|
535
576
|
this.options = options != null ? options : {};
|
536
577
|
_.extend(this, this.options);
|
537
578
|
if (this.name != null) this.cid = _.uniqueId(this.name);
|
579
|
+
if (template = this.bodyTemplate) {
|
580
|
+
this.$el.empty();
|
581
|
+
Luca.View.prototype.$html.call(this, Luca.template(template, this));
|
582
|
+
}
|
538
583
|
Luca.cache(this.cid, this);
|
539
584
|
unique = _(Luca.View.prototype.hooks.concat(this.hooks)).uniq();
|
540
585
|
this.setupHooks(unique);
|
541
|
-
if (this.autoBindEventHandlers === true)
|
542
|
-
|
543
|
-
|
544
|
-
|
586
|
+
if (this.autoBindEventHandlers === true) this.bindAllEventHandlers();
|
587
|
+
if (this.additionalClassNames) {
|
588
|
+
if (_.isString(this.additionalClassNames)) {
|
589
|
+
this.additionalClassNames = this.additionalClassNames.split(" ");
|
590
|
+
}
|
591
|
+
_ref = this.additionalClassNames;
|
592
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
593
|
+
additional = _ref[_i];
|
594
|
+
this.$el.addClass(additional);
|
595
|
+
}
|
545
596
|
}
|
546
597
|
this.trigger("after:initialize", this);
|
547
598
|
this.registerCollectionEvents();
|
548
599
|
return this.delegateEvents();
|
549
600
|
},
|
601
|
+
$wrap: function(wrapper) {
|
602
|
+
if (!wrapper.match(/[<>]/)) {
|
603
|
+
wrapper = this.make("div", {
|
604
|
+
"class": wrapper
|
605
|
+
});
|
606
|
+
}
|
607
|
+
return this.$el.wrap(wrapper);
|
608
|
+
},
|
609
|
+
$template: function(template, variables) {
|
610
|
+
if (variables == null) variables = {};
|
611
|
+
return this.$el.html(Luca.template(template, variables));
|
612
|
+
},
|
613
|
+
$html: function(content) {
|
614
|
+
return this.$el.html(content);
|
615
|
+
},
|
616
|
+
$append: function(content) {
|
617
|
+
return this.$el.append(content);
|
618
|
+
},
|
619
|
+
$attach: function() {
|
620
|
+
return this.$container().append(this.el);
|
621
|
+
},
|
550
622
|
$container: function() {
|
551
623
|
return $(this.container);
|
552
624
|
},
|
@@ -554,16 +626,16 @@
|
|
554
626
|
var _this = this;
|
555
627
|
set || (set = this.hooks);
|
556
628
|
return _(set).each(function(eventId) {
|
557
|
-
var
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
return
|
562
|
-
}
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
629
|
+
var callback, fn;
|
630
|
+
fn = Luca.util.hook(eventId);
|
631
|
+
callback = function() {
|
632
|
+
var _ref;
|
633
|
+
return (_ref = _this[fn]) != null ? _ref.apply(_this, arguments) : void 0;
|
634
|
+
};
|
635
|
+
if (eventId != null ? eventId.match(/once:/) : void 0) {
|
636
|
+
callback = _.once(callback);
|
637
|
+
}
|
638
|
+
return _this.bind(eventId, callback);
|
567
639
|
});
|
568
640
|
},
|
569
641
|
getCollectionManager: function() {
|
@@ -593,13 +665,108 @@
|
|
593
665
|
this.events || (this.events = {});
|
594
666
|
this.events[selector] = handler;
|
595
667
|
return this.delegateEvents();
|
668
|
+
},
|
669
|
+
bindAllEventHandlers: function() {
|
670
|
+
var _this = this;
|
671
|
+
return _(this.events).each(function(handler, event) {
|
672
|
+
if (_.isString(handler)) return _.bindAll(_this, handler);
|
673
|
+
});
|
674
|
+
},
|
675
|
+
definitionClass: function() {
|
676
|
+
var _ref;
|
677
|
+
return (_ref = Luca.util.resolve(this.displayName, window)) != null ? _ref.prototype : void 0;
|
678
|
+
},
|
679
|
+
refreshCode: function() {
|
680
|
+
var view;
|
681
|
+
view = this;
|
682
|
+
_(this.eventHandlerProperties()).each(function(prop) {
|
683
|
+
return view[prop] = view.definitionClass()[prop];
|
684
|
+
});
|
685
|
+
if (this.autoBindEventHandlers === true) this.bindAllEventHandlers();
|
686
|
+
return this.delegateEvents();
|
687
|
+
},
|
688
|
+
eventHandlerProperties: function() {
|
689
|
+
var handlerIds;
|
690
|
+
handlerIds = _(this.events).values();
|
691
|
+
return _(handlerIds).select(function(v) {
|
692
|
+
return _.isString(v);
|
693
|
+
});
|
694
|
+
},
|
695
|
+
eventHandlerFunctions: function() {
|
696
|
+
var handlerIds,
|
697
|
+
_this = this;
|
698
|
+
handlerIds = _(this.events).values();
|
699
|
+
return _(handlerIds).map(function(handlerId) {
|
700
|
+
if (_.isFunction(handlerId)) {
|
701
|
+
return handlerId;
|
702
|
+
} else {
|
703
|
+
return _this[handlerId];
|
704
|
+
}
|
705
|
+
});
|
706
|
+
},
|
707
|
+
collections: function() {
|
708
|
+
return Luca.util.selectProperties(Luca.isBackboneCollection, this);
|
709
|
+
},
|
710
|
+
models: function() {
|
711
|
+
return Luca.util.selectProperties(Luca.isBackboneModel, this);
|
712
|
+
},
|
713
|
+
views: function() {
|
714
|
+
return Luca.util.selectProperties(Luca.isBackboneView, this);
|
596
715
|
}
|
597
716
|
});
|
598
717
|
|
718
|
+
originalExtend = Backbone.View.extend;
|
719
|
+
|
720
|
+
customizeRender = function(definition) {
|
721
|
+
var _base;
|
722
|
+
_base = definition.render;
|
723
|
+
_base || (_base = Luca.View.prototype.$attach);
|
724
|
+
definition.render = function() {
|
725
|
+
var autoTrigger, fn, target, trigger, view,
|
726
|
+
_this = this;
|
727
|
+
view = this;
|
728
|
+
if (this.deferrable) {
|
729
|
+
target = this.deferrable_target;
|
730
|
+
if (!Luca.isBackboneCollection(this.deferrable)) {
|
731
|
+
this.deferrable = this.collection;
|
732
|
+
}
|
733
|
+
target || (target = this.deferrable);
|
734
|
+
trigger = this.deferrable_event ? this.deferrable_event : "reset";
|
735
|
+
view.defer(function() {
|
736
|
+
_base.call(view);
|
737
|
+
return view.trigger("after:render", view);
|
738
|
+
}).until(target, trigger);
|
739
|
+
view.trigger("before:render", this);
|
740
|
+
autoTrigger = this.deferrable_trigger || this.deferUntil;
|
741
|
+
if (!(autoTrigger != null)) {
|
742
|
+
target[this.deferrable_method || "fetch"].call(target);
|
743
|
+
} else {
|
744
|
+
fn = _.once(function() {
|
745
|
+
var _base2, _name;
|
746
|
+
return typeof (_base2 = _this.deferrable)[_name = _this.deferrable_method || "fetch"] === "function" ? _base2[_name]() : void 0;
|
747
|
+
});
|
748
|
+
(this.deferrable_target || this).bind(this.deferrable_trigger, fn);
|
749
|
+
}
|
750
|
+
return this;
|
751
|
+
} else {
|
752
|
+
this.trigger("before:render", this);
|
753
|
+
_base.apply(this, arguments);
|
754
|
+
this.trigger("after:render", this);
|
755
|
+
return this;
|
756
|
+
}
|
757
|
+
};
|
758
|
+
return definition;
|
759
|
+
};
|
760
|
+
|
761
|
+
Luca.View.extend = function(definition) {
|
762
|
+
definition = customizeRender(definition);
|
763
|
+
return originalExtend.call(this, definition);
|
764
|
+
};
|
765
|
+
|
599
766
|
}).call(this);
|
600
767
|
(function() {
|
601
768
|
|
602
|
-
_.
|
769
|
+
_.def('Luca.Model')["extends"]('Backbone.Model')["with"]({
|
603
770
|
initialize: function() {
|
604
771
|
var attr, dependencies, _ref, _results,
|
605
772
|
_this = this;
|
@@ -634,17 +801,93 @@
|
|
634
801
|
|
635
802
|
}).call(this);
|
636
803
|
(function() {
|
804
|
+
var source;
|
805
|
+
|
806
|
+
source = 'Backbone.Collection';
|
807
|
+
|
808
|
+
if (Backbone.QueryCollection != null) source = 'Backbone.QueryCollection';
|
637
809
|
|
638
|
-
|
810
|
+
_.def("Luca.Collection")["extends"](source)["with"]({
|
811
|
+
cachedMethods: [],
|
812
|
+
restoreMethodCache: function() {
|
813
|
+
var config, name, _ref, _results;
|
814
|
+
_ref = this._methodCache;
|
815
|
+
_results = [];
|
816
|
+
for (name in _ref) {
|
817
|
+
config = _ref[name];
|
818
|
+
if (config.original != null) {
|
819
|
+
config.args = void 0;
|
820
|
+
_results.push(this[name] = config.original);
|
821
|
+
} else {
|
822
|
+
_results.push(void 0);
|
823
|
+
}
|
824
|
+
}
|
825
|
+
return _results;
|
826
|
+
},
|
827
|
+
clearMethodCache: function(method) {
|
828
|
+
return this._methodCache[method].value = void 0;
|
829
|
+
},
|
830
|
+
clearAllMethodsCache: function() {
|
831
|
+
var config, name, _ref, _results;
|
832
|
+
_ref = this._methodCache;
|
833
|
+
_results = [];
|
834
|
+
for (name in _ref) {
|
835
|
+
config = _ref[name];
|
836
|
+
_results.push(this.clearMethodCache(name));
|
837
|
+
}
|
838
|
+
return _results;
|
839
|
+
},
|
840
|
+
setupMethodCaching: function() {
|
841
|
+
var cache, collection, membershipEvents;
|
842
|
+
collection = this;
|
843
|
+
membershipEvents = ["reset", "add", "remove"];
|
844
|
+
cache = this._methodCache = {};
|
845
|
+
return _(this.cachedMethods).each(function(method) {
|
846
|
+
var dependencies, dependency, membershipEvent, _i, _j, _len, _len2, _ref, _results;
|
847
|
+
cache[method] = {
|
848
|
+
name: method,
|
849
|
+
original: collection[method],
|
850
|
+
value: void 0
|
851
|
+
};
|
852
|
+
collection[method] = function() {
|
853
|
+
var _base;
|
854
|
+
return (_base = cache[method]).value || (_base.value = cache[method].original.apply(collection, arguments));
|
855
|
+
};
|
856
|
+
for (_i = 0, _len = membershipEvents.length; _i < _len; _i++) {
|
857
|
+
membershipEvent = membershipEvents[_i];
|
858
|
+
collection.bind(membershipEvent, function() {
|
859
|
+
return collection.clearAllMethodsCache();
|
860
|
+
});
|
861
|
+
}
|
862
|
+
dependencies = method.split(':')[1];
|
863
|
+
if (dependencies) {
|
864
|
+
_ref = dependencies.split(",");
|
865
|
+
_results = [];
|
866
|
+
for (_j = 0, _len2 = _ref.length; _j < _len2; _j++) {
|
867
|
+
dependency = _ref[_j];
|
868
|
+
_results.push(collection.bind("change:" + dependency, function() {
|
869
|
+
return collection.clearMethodCache({
|
870
|
+
method: method
|
871
|
+
});
|
872
|
+
}));
|
873
|
+
}
|
874
|
+
return _results;
|
875
|
+
}
|
876
|
+
});
|
877
|
+
},
|
639
878
|
initialize: function(models, options) {
|
640
879
|
var table,
|
641
880
|
_this = this;
|
642
881
|
if (models == null) models = [];
|
643
882
|
this.options = options;
|
644
883
|
_.extend(this, this.options);
|
884
|
+
this.setupMethodCaching();
|
645
885
|
this._reset();
|
646
886
|
if (this.cached) {
|
647
|
-
|
887
|
+
console.log('The @cached property of Luca.Collection is being deprecated. Please change to cache_key');
|
888
|
+
}
|
889
|
+
if (this.cache_key || (this.cache_key = this.cached)) {
|
890
|
+
this.bootstrap_cache_key = _.isFunction(this.cache_key) ? this.cache_key() : this.cache_key;
|
648
891
|
}
|
649
892
|
if (this.registerAs || this.registerWith) {
|
650
893
|
console.log("This configuration API is deprecated. use @name and @manager properties instead");
|
@@ -653,7 +896,7 @@
|
|
653
896
|
this.manager || (this.manager = this.registerWith);
|
654
897
|
if (this.name && !this.manager) this.manager = Luca.CollectionManager.get();
|
655
898
|
if (this.manager) {
|
656
|
-
this.name || (this.name = this.
|
899
|
+
this.name || (this.name = this.cache_key());
|
657
900
|
this.name = _.isFunction(this.name) ? this.name() : this.name;
|
658
901
|
if (!(this.private || this.anonymous)) {
|
659
902
|
this.bind("after:initialize", function() {
|
@@ -717,13 +960,18 @@
|
|
717
960
|
this.base_params = Luca.Collection.baseParams();
|
718
961
|
return this;
|
719
962
|
},
|
963
|
+
remoteFilter: true,
|
720
964
|
applyFilter: function(filter, options) {
|
721
965
|
if (filter == null) filter = {};
|
722
966
|
if (options == null) options = {};
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
967
|
+
if ((options.remote != null) === true) {
|
968
|
+
this.applyParams(filter);
|
969
|
+
return this.fetch(_.extend(options, {
|
970
|
+
refresh: true
|
971
|
+
}));
|
972
|
+
} else {
|
973
|
+
return this.reset(this.query(filter));
|
974
|
+
}
|
727
975
|
},
|
728
976
|
applyParams: function(params) {
|
729
977
|
this.base_params || (this.base_params = _(Luca.Collection.baseParams()).clone());
|
@@ -825,47 +1073,442 @@
|
|
825
1073
|
if (this.bootstrap_cache_key) {
|
826
1074
|
Luca.Collection.cache(this.bootstrap_cache_key, models);
|
827
1075
|
}
|
828
|
-
return models;
|
1076
|
+
return models;
|
1077
|
+
}
|
1078
|
+
});
|
1079
|
+
|
1080
|
+
_.extend(Luca.Collection.prototype, {
|
1081
|
+
trigger: function() {
|
1082
|
+
if (Luca.enableGlobalObserver) {
|
1083
|
+
Luca.CollectionObserver || (Luca.CollectionObserver = new Luca.Observer({
|
1084
|
+
type: "collection"
|
1085
|
+
}));
|
1086
|
+
Luca.CollectionObserver.relay(this, arguments);
|
1087
|
+
}
|
1088
|
+
return Backbone.View.prototype.trigger.apply(this, arguments);
|
1089
|
+
}
|
1090
|
+
});
|
1091
|
+
|
1092
|
+
Luca.Collection.baseParams = function(obj) {
|
1093
|
+
if (obj) return Luca.Collection._baseParams = obj;
|
1094
|
+
if (_.isFunction(Luca.Collection._baseParams)) {
|
1095
|
+
return Luca.Collection._baseParams.call();
|
1096
|
+
}
|
1097
|
+
if (_.isObject(Luca.Collection._baseParams)) {
|
1098
|
+
return Luca.Collection._baseParams;
|
1099
|
+
}
|
1100
|
+
};
|
1101
|
+
|
1102
|
+
Luca.Collection._bootstrapped_models = {};
|
1103
|
+
|
1104
|
+
Luca.Collection.bootstrap = function(obj) {
|
1105
|
+
return _.extend(Luca.Collection._bootstrapped_models, obj);
|
1106
|
+
};
|
1107
|
+
|
1108
|
+
Luca.Collection.cache = function(key, models) {
|
1109
|
+
if (models) return Luca.Collection._bootstrapped_models[key] = models;
|
1110
|
+
return Luca.Collection._bootstrapped_models[key] || [];
|
1111
|
+
};
|
1112
|
+
|
1113
|
+
}).call(this);
|
1114
|
+
(function() {
|
1115
|
+
var attachToolbar;
|
1116
|
+
|
1117
|
+
attachToolbar = function(config) {
|
1118
|
+
var action, container, hasBody, id, toolbar;
|
1119
|
+
if (config == null) config = {};
|
1120
|
+
config.orientation || (config.orientation = "top");
|
1121
|
+
config.ctype || (config.ctype = this.toolbarType || "panel_toolbar");
|
1122
|
+
id = "" + this.cid + "-tbc-" + config.orientation;
|
1123
|
+
toolbar = Luca.util.lazyComponent(config);
|
1124
|
+
container = this.make("div", {
|
1125
|
+
"class": "toolbar-container " + config.orientation,
|
1126
|
+
id: id
|
1127
|
+
}, toolbar.render().el);
|
1128
|
+
hasBody = this.bodyClassName || this.bodyTagName;
|
1129
|
+
action = (function() {
|
1130
|
+
switch (config.orientation) {
|
1131
|
+
case "top":
|
1132
|
+
case "left":
|
1133
|
+
if (hasBody) {
|
1134
|
+
return "before";
|
1135
|
+
} else {
|
1136
|
+
return "prepend";
|
1137
|
+
}
|
1138
|
+
break;
|
1139
|
+
case "bottom":
|
1140
|
+
case "right":
|
1141
|
+
if (hasBody) {
|
1142
|
+
return "after";
|
1143
|
+
} else {
|
1144
|
+
return "append";
|
1145
|
+
}
|
1146
|
+
}
|
1147
|
+
})();
|
1148
|
+
return this.$bodyEl()[action](container);
|
1149
|
+
};
|
1150
|
+
|
1151
|
+
_.def("Luca.components.Panel")["extends"]("Luca.View")["with"]({
|
1152
|
+
topToolbar: void 0,
|
1153
|
+
bottomToolbar: void 0,
|
1154
|
+
loadMask: false,
|
1155
|
+
loadMaskTemplate: ["components/load_mask"],
|
1156
|
+
initialize: function(options) {
|
1157
|
+
var _this = this;
|
1158
|
+
this.options = options != null ? options : {};
|
1159
|
+
Luca.View.prototype.initialize.apply(this, arguments);
|
1160
|
+
if (this.loadMask === true) {
|
1161
|
+
this.defer(function() {
|
1162
|
+
_this.$el.addClass('with-mask');
|
1163
|
+
if (_this.$('.load-mask').length === 0) {
|
1164
|
+
_this.loadMaskTarget().prepend(Luca.template(_this.loadMaskTemplate, _this));
|
1165
|
+
return _this.$('.load-mask').hide();
|
1166
|
+
}
|
1167
|
+
}).until("after:render");
|
1168
|
+
this.on("enable:loadmask", this.applyLoadMask);
|
1169
|
+
return this.on("disable:loadmask", this.applyLoadMask);
|
1170
|
+
}
|
1171
|
+
},
|
1172
|
+
loadMaskTarget: function() {
|
1173
|
+
if (this.loadMaskEl != null) {
|
1174
|
+
return this.$(this.loadMaskEl);
|
1175
|
+
} else {
|
1176
|
+
return this.$bodyEl();
|
1177
|
+
}
|
1178
|
+
},
|
1179
|
+
applyLoadMask: function() {
|
1180
|
+
var maxWidth,
|
1181
|
+
_this = this;
|
1182
|
+
if (this.$('.load-mask').is(":visible")) {
|
1183
|
+
this.$('.load-mask .bar').css("width", "100%");
|
1184
|
+
this.$('.load-mask').hide();
|
1185
|
+
return clearInterval(this.loadMaskInterval);
|
1186
|
+
} else {
|
1187
|
+
this.$('.load-mask').show().find('.bar').css("width", "0%");
|
1188
|
+
maxWidth = this.$('.load-mask .progress').width();
|
1189
|
+
if (maxWidth < 20 && (maxWidth = this.$el.width()) < 20) {
|
1190
|
+
maxWidth = this.$el.parent().width();
|
1191
|
+
}
|
1192
|
+
return this.loadMaskInterval = setInterval(function() {
|
1193
|
+
var currentWidth, newWidth;
|
1194
|
+
currentWidth = _this.$('.load-mask .bar').width();
|
1195
|
+
newWidth = currentWidth + 12;
|
1196
|
+
return _this.$('.load-mask .bar').css('width', newWidth);
|
1197
|
+
}, 200);
|
1198
|
+
}
|
1199
|
+
},
|
1200
|
+
applyStyles: function(styles, body) {
|
1201
|
+
var setting, target, value;
|
1202
|
+
if (styles == null) styles = {};
|
1203
|
+
if (body == null) body = false;
|
1204
|
+
target = body ? this.$bodyEl() : this.$el;
|
1205
|
+
for (setting in styles) {
|
1206
|
+
value = styles[setting];
|
1207
|
+
target.css(setting, value);
|
1208
|
+
}
|
1209
|
+
return this;
|
1210
|
+
},
|
1211
|
+
beforeRender: function() {
|
1212
|
+
var _ref;
|
1213
|
+
if ((_ref = Luca.View.prototype.beforeRender) != null) {
|
1214
|
+
_ref.apply(this, arguments);
|
1215
|
+
}
|
1216
|
+
if (this.styles != null) this.applyStyles(this.styles);
|
1217
|
+
if (this.bodyStyles != null) this.applyStyles(this.bodyStyles, true);
|
1218
|
+
return typeof this.renderToolbars === "function" ? this.renderToolbars() : void 0;
|
1219
|
+
},
|
1220
|
+
$bodyEl: function() {
|
1221
|
+
var bodyEl, className, element, newElement;
|
1222
|
+
element = this.bodyTagName || "div";
|
1223
|
+
className = this.bodyClassName || "view-body";
|
1224
|
+
this.bodyEl || (this.bodyEl = "" + element + "." + className);
|
1225
|
+
bodyEl = this.$(this.bodyEl);
|
1226
|
+
if (bodyEl.length > 0) return bodyEl;
|
1227
|
+
if (bodyEl.length === 0 && ((this.bodyClassName != null) || (this.bodyTagName != null))) {
|
1228
|
+
newElement = this.make(element, {
|
1229
|
+
"class": className,
|
1230
|
+
"data-auto-appended": true
|
1231
|
+
});
|
1232
|
+
$(this.el).append(newElement);
|
1233
|
+
return this.$(this.bodyEl);
|
1234
|
+
}
|
1235
|
+
return $(this.el);
|
1236
|
+
},
|
1237
|
+
$wrap: function(wrapper) {
|
1238
|
+
if (!wrapper.match(/[<>]/)) {
|
1239
|
+
wrapper = this.make("div", {
|
1240
|
+
"class": wrapper
|
1241
|
+
});
|
1242
|
+
}
|
1243
|
+
return this.$el.wrap(wrapper);
|
1244
|
+
},
|
1245
|
+
$template: function(template, variables) {
|
1246
|
+
if (variables == null) variables = {};
|
1247
|
+
return this.$html(Luca.template(template, variables));
|
1248
|
+
},
|
1249
|
+
$html: function(content) {
|
1250
|
+
return this.$bodyEl().html(content);
|
1251
|
+
},
|
1252
|
+
$append: function(content) {
|
1253
|
+
return this.$bodyEl().append(content);
|
1254
|
+
},
|
1255
|
+
renderToolbars: function() {
|
1256
|
+
var _this = this;
|
1257
|
+
return _(["top", "left", "right", "bottom"]).each(function(orientation) {
|
1258
|
+
var config;
|
1259
|
+
if (config = _this["" + orientation + "Toolbar"]) {
|
1260
|
+
return _this.renderToolbar(orientation, config);
|
1261
|
+
}
|
1262
|
+
});
|
1263
|
+
},
|
1264
|
+
renderToolbar: function(orientation, config) {
|
1265
|
+
if (orientation == null) orientation = "top";
|
1266
|
+
if (config == null) config = {};
|
1267
|
+
config.parent = this;
|
1268
|
+
config.orientation = orientation;
|
1269
|
+
return attachToolbar.call(this, config);
|
1270
|
+
}
|
1271
|
+
});
|
1272
|
+
|
1273
|
+
}).call(this);
|
1274
|
+
(function() {
|
1275
|
+
|
1276
|
+
Luca.modules.Deferrable = {
|
1277
|
+
configure_collection: function(setAsDeferrable) {
|
1278
|
+
var collectionManager, _ref, _ref2;
|
1279
|
+
if (setAsDeferrable == null) setAsDeferrable = true;
|
1280
|
+
if (!this.collection) return;
|
1281
|
+
if (_.isString(this.collection) && (collectionManager = (_ref = Luca.CollectionManager) != null ? _ref.get() : void 0)) {
|
1282
|
+
this.collection = collectionManager.getOrCreate(this.collection);
|
1283
|
+
}
|
1284
|
+
if (!(this.collection && _.isFunction(this.collection.fetch) && _.isFunction(this.collection.reset))) {
|
1285
|
+
this.collection = new Luca.Collection(this.collection.initial_set, this.collection);
|
1286
|
+
}
|
1287
|
+
if ((_ref2 = this.collection) != null ? _ref2.deferrable_trigger : void 0) {
|
1288
|
+
this.deferrable_trigger = this.collection.deferrable_trigger;
|
1289
|
+
}
|
1290
|
+
if (setAsDeferrable) return this.deferrable = this.collection;
|
1291
|
+
}
|
1292
|
+
};
|
1293
|
+
|
1294
|
+
}).call(this);
|
1295
|
+
(function() {
|
1296
|
+
|
1297
|
+
Luca.LocalStore = (function() {
|
1298
|
+
|
1299
|
+
function LocalStore(name) {
|
1300
|
+
var store;
|
1301
|
+
this.name = name;
|
1302
|
+
store = localStorage.getItem(this.name);
|
1303
|
+
this.data = (store && JSON.parse(store)) || {};
|
1304
|
+
}
|
1305
|
+
|
1306
|
+
LocalStore.prototype.guid = function() {
|
1307
|
+
var S4;
|
1308
|
+
S4 = function() {
|
1309
|
+
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
|
1310
|
+
};
|
1311
|
+
return S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4();
|
1312
|
+
};
|
1313
|
+
|
1314
|
+
LocalStore.prototype.save = function() {
|
1315
|
+
return localStorage.setItem(this.name, JSON.stringify(this.data));
|
1316
|
+
};
|
1317
|
+
|
1318
|
+
LocalStore.prototype.create = function(model) {
|
1319
|
+
if (!model.id) model.id = model.attribtues.id = this.guid();
|
1320
|
+
this.data[model.id] = model;
|
1321
|
+
this.save();
|
1322
|
+
return model;
|
1323
|
+
};
|
1324
|
+
|
1325
|
+
LocalStore.prototype.update = function(model) {
|
1326
|
+
this.data[model.id] = model;
|
1327
|
+
this.save();
|
1328
|
+
return model;
|
1329
|
+
};
|
1330
|
+
|
1331
|
+
LocalStore.prototype.find = function(model) {
|
1332
|
+
return this.data[model.id];
|
1333
|
+
};
|
1334
|
+
|
1335
|
+
LocalStore.prototype.findAll = function() {
|
1336
|
+
return _.values(this.data);
|
1337
|
+
};
|
1338
|
+
|
1339
|
+
LocalStore.prototype.destroy = function(model) {
|
1340
|
+
delete this.data[model.id];
|
1341
|
+
this.save();
|
1342
|
+
return model;
|
1343
|
+
};
|
1344
|
+
|
1345
|
+
return LocalStore;
|
1346
|
+
|
1347
|
+
})();
|
1348
|
+
|
1349
|
+
Backbone.LocalSync = function(method, model, options) {
|
1350
|
+
var resp, store;
|
1351
|
+
store = model.localStorage || model.collection.localStorage;
|
1352
|
+
resp = (function() {
|
1353
|
+
switch (method) {
|
1354
|
+
case "read":
|
1355
|
+
if (model.id) {
|
1356
|
+
return store.find(model);
|
1357
|
+
} else {
|
1358
|
+
return store.findAll();
|
1359
|
+
}
|
1360
|
+
case "create":
|
1361
|
+
return store.create(model);
|
1362
|
+
case "update":
|
1363
|
+
return store.update(model);
|
1364
|
+
case "delete":
|
1365
|
+
return store.destroy(model);
|
1366
|
+
}
|
1367
|
+
})();
|
1368
|
+
if (resp) {
|
1369
|
+
return options.success(resp);
|
1370
|
+
} else {
|
1371
|
+
return options.error("Record not found");
|
829
1372
|
}
|
830
|
-
}
|
1373
|
+
};
|
831
1374
|
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
1375
|
+
}).call(this);
|
1376
|
+
(function() {
|
1377
|
+
Luca.templates || (Luca.templates = {});
|
1378
|
+
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('');};
|
1379
|
+
}).call(this);
|
1380
|
+
(function() {
|
1381
|
+
Luca.templates || (Luca.templates = {});
|
1382
|
+
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('');};
|
1383
|
+
}).call(this);
|
1384
|
+
(function() {
|
1385
|
+
Luca.templates || (Luca.templates = {});
|
1386
|
+
Luca.templates["components/form_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'form-view-panel\'>\n <ul class=\'form-view-flash-container\'></ul>\n <div class=\'form-view-body\'></div>\n</div>\n');}return __p.join('');};
|
1387
|
+
}).call(this);
|
1388
|
+
(function() {
|
1389
|
+
Luca.templates || (Luca.templates = {});
|
1390
|
+
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('');};
|
1391
|
+
}).call(this);
|
1392
|
+
(function() {
|
1393
|
+
Luca.templates || (Luca.templates = {});
|
1394
|
+
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('');};
|
1395
|
+
}).call(this);
|
1396
|
+
(function() {
|
1397
|
+
Luca.templates || (Luca.templates = {});
|
1398
|
+
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('');};
|
1399
|
+
}).call(this);
|
1400
|
+
(function() {
|
1401
|
+
Luca.templates || (Luca.templates = {});
|
1402
|
+
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('');};
|
1403
|
+
}).call(this);
|
1404
|
+
(function() {
|
1405
|
+
Luca.templates || (Luca.templates = {});
|
1406
|
+
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('');};
|
1407
|
+
}).call(this);
|
1408
|
+
(function() {
|
1409
|
+
Luca.templates || (Luca.templates = {});
|
1410
|
+
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('');};
|
1411
|
+
}).call(this);
|
1412
|
+
(function() {
|
1413
|
+
Luca.templates || (Luca.templates = {});
|
1414
|
+
Luca.templates["containers/tab_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<ul class=\'nav nav-tabs\' id=\'', cid ,'-tabs-selector\'></ul>\n<div class=\'tab-content\' id=\'', cid ,'-tab-view-content\'></div>\n');}return __p.join('');};
|
1415
|
+
}).call(this);
|
1416
|
+
(function() {
|
1417
|
+
Luca.templates || (Luca.templates = {});
|
1418
|
+
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('');};
|
1419
|
+
}).call(this);
|
1420
|
+
(function() {
|
1421
|
+
Luca.templates || (Luca.templates = {});
|
1422
|
+
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('');};
|
1423
|
+
}).call(this);
|
1424
|
+
(function() {
|
1425
|
+
Luca.templates || (Luca.templates = {});
|
1426
|
+
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('');};
|
1427
|
+
}).call(this);
|
1428
|
+
(function() {
|
1429
|
+
Luca.templates || (Luca.templates = {});
|
1430
|
+
Luca.templates["fields/checkbox_array"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'form-horizontal\'>\n <div class=\'control-group\'>\n <label for=\'', input_id ,'\'>\n ', label ,'\n </label>\n <div class=\'controls\'></div>\n </div>\n</div>\n');}return __p.join('');};
|
1431
|
+
}).call(this);
|
1432
|
+
(function() {
|
1433
|
+
Luca.templates || (Luca.templates = {});
|
1434
|
+
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('');};
|
1435
|
+
}).call(this);
|
1436
|
+
(function() {
|
1437
|
+
Luca.templates || (Luca.templates = {});
|
1438
|
+
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('');};
|
1439
|
+
}).call(this);
|
1440
|
+
(function() {
|
1441
|
+
Luca.templates || (Luca.templates = {});
|
1442
|
+
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('');};
|
1443
|
+
}).call(this);
|
1444
|
+
(function() {
|
1445
|
+
Luca.templates || (Luca.templates = {});
|
1446
|
+
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('');};
|
1447
|
+
}).call(this);
|
1448
|
+
(function() {
|
1449
|
+
Luca.templates || (Luca.templates = {});
|
1450
|
+
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<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');}return __p.join('');};
|
1451
|
+
}).call(this);
|
1452
|
+
(function() {
|
1453
|
+
Luca.templates || (Luca.templates = {});
|
1454
|
+
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('');};
|
1455
|
+
}).call(this);
|
1456
|
+
(function() {
|
1457
|
+
Luca.templates || (Luca.templates = {});
|
1458
|
+
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'); 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');}return __p.join('');};
|
1459
|
+
}).call(this);
|
1460
|
+
(function() {
|
1461
|
+
Luca.templates || (Luca.templates = {});
|
1462
|
+
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('');};
|
1463
|
+
}).call(this);
|
1464
|
+
(function() {
|
1465
|
+
Luca.templates || (Luca.templates = {});
|
1466
|
+
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('');};
|
1467
|
+
}).call(this);
|
1468
|
+
(function() {
|
1469
|
+
var __slice = Array.prototype.slice;
|
1470
|
+
|
1471
|
+
Luca.Observer = (function() {
|
1472
|
+
|
1473
|
+
function Observer(options) {
|
1474
|
+
var _this = this;
|
1475
|
+
this.options = options != null ? options : {};
|
1476
|
+
_.extend(this, Backbone.Events);
|
1477
|
+
this.type = this.options.type;
|
1478
|
+
if (this.options.debugAll) {
|
1479
|
+
this.bind("all", function(trigger, one, two) {
|
1480
|
+
return console.log("ALL", trigger, one, two);
|
1481
|
+
});
|
839
1482
|
}
|
840
|
-
return Backbone.View.prototype.trigger.apply(this, arguments);
|
841
1483
|
}
|
842
|
-
});
|
843
1484
|
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
}
|
852
|
-
};
|
1485
|
+
Observer.prototype.relay = function() {
|
1486
|
+
var args, triggerer;
|
1487
|
+
triggerer = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
1488
|
+
console.log("Relaying", trigger, args);
|
1489
|
+
this.trigger("event", triggerer, args);
|
1490
|
+
return this.trigger("event:" + args[0], triggerer, args.slice(1));
|
1491
|
+
};
|
853
1492
|
|
854
|
-
|
1493
|
+
return Observer;
|
855
1494
|
|
856
|
-
|
857
|
-
return _.extend(Luca.Collection._bootstrapped_models, obj);
|
858
|
-
};
|
1495
|
+
})();
|
859
1496
|
|
860
|
-
Luca.
|
861
|
-
if (
|
862
|
-
|
1497
|
+
Luca.Observer.enableObservers = function(options) {
|
1498
|
+
if (options == null) options = {};
|
1499
|
+
Luca.enableGlobalObserver = true;
|
1500
|
+
Luca.ViewObserver = new Luca.Observer(_.extend(options, {
|
1501
|
+
type: "view"
|
1502
|
+
}));
|
1503
|
+
return Luca.CollectionObserver = new Luca.Observer(_.extend(options, {
|
1504
|
+
type: "collection"
|
1505
|
+
}));
|
863
1506
|
};
|
864
1507
|
|
865
1508
|
}).call(this);
|
866
1509
|
(function() {
|
867
1510
|
|
868
|
-
_.
|
1511
|
+
_.def('Luca.core.Field')["extends"]('Luca.View')["with"]({
|
869
1512
|
className: 'luca-ui-text-field luca-ui-field',
|
870
1513
|
isField: true,
|
871
1514
|
template: 'fields/text_field',
|
@@ -876,9 +1519,9 @@
|
|
876
1519
|
var _ref;
|
877
1520
|
this.options = options != null ? options : {};
|
878
1521
|
_.extend(this, this.options);
|
879
|
-
Luca.View.prototype.initialize.apply(this, arguments);
|
880
1522
|
this.input_id || (this.input_id = _.uniqueId('field'));
|
881
1523
|
this.input_name || (this.input_name = this.name);
|
1524
|
+
this.input_class || (this.input_class = "");
|
882
1525
|
this.helperText || (this.helperText = "");
|
883
1526
|
if (this.required && !((_ref = this.label) != null ? _ref.match(/^\*/) : void 0)) {
|
884
1527
|
this.label || (this.label = "*" + this.label);
|
@@ -886,7 +1529,8 @@
|
|
886
1529
|
this.inputStyles || (this.inputStyles = "");
|
887
1530
|
if (this.disabled) this.disable();
|
888
1531
|
this.updateState(this.state);
|
889
|
-
|
1532
|
+
this.placeHolder || (this.placeHolder = "");
|
1533
|
+
return Luca.View.prototype.initialize.apply(this, arguments);
|
890
1534
|
},
|
891
1535
|
beforeRender: function() {
|
892
1536
|
if (Luca.enableBootstrap) this.$el.addClass('control-group');
|
@@ -923,9 +1567,48 @@
|
|
923
1567
|
|
924
1568
|
}).call(this);
|
925
1569
|
(function() {
|
1570
|
+
var applyDOMConfig, doComponents, doLayout;
|
1571
|
+
|
1572
|
+
doLayout = function() {
|
1573
|
+
this.trigger("before:layout", this);
|
1574
|
+
this.prepareLayout();
|
1575
|
+
return this.trigger("after:layout", this);
|
1576
|
+
};
|
1577
|
+
|
1578
|
+
applyDOMConfig = function(panel, panelIndex) {
|
1579
|
+
var config, style_declarations;
|
1580
|
+
style_declarations = [];
|
1581
|
+
if (panel.height != null) {
|
1582
|
+
style_declarations.push("height: " + (_.isNumber(panel.height) ? panel.height + 'px' : panel.height));
|
1583
|
+
}
|
1584
|
+
if (panel.width != null) {
|
1585
|
+
style_declarations.push("width: " + (_.isNumber(panel.width) ? panel.width + 'px' : panel.width));
|
1586
|
+
}
|
1587
|
+
if (panel.float) style_declarations.push("float: " + panel.float);
|
1588
|
+
config = {
|
1589
|
+
"class": (panel != null ? panel.classes : void 0) || this.componentClass,
|
1590
|
+
id: "" + this.cid + "-" + panelIndex,
|
1591
|
+
style: style_declarations.join(';'),
|
1592
|
+
"data-luca-owner": this.name || this.cid
|
1593
|
+
};
|
1594
|
+
if (this.customizeContainerEl != null) {
|
1595
|
+
config = this.customizeContainerEl(config, panel, panelIndex);
|
1596
|
+
}
|
1597
|
+
return config;
|
1598
|
+
};
|
1599
|
+
|
1600
|
+
doComponents = function() {
|
1601
|
+
this.trigger("before:components", this, this.components);
|
1602
|
+
this.prepareComponents();
|
1603
|
+
this.createComponents();
|
1604
|
+
this.trigger("before:render:components", this, this.components);
|
1605
|
+
this.renderComponents();
|
1606
|
+
return this.trigger("after:components", this, this.components);
|
1607
|
+
};
|
926
1608
|
|
927
|
-
_.
|
1609
|
+
_.def('Luca.core.Container')["extends"]('Luca.components.Panel')["with"]({
|
928
1610
|
className: 'luca-ui-container',
|
1611
|
+
componentTag: 'div',
|
929
1612
|
componentClass: 'luca-ui-panel',
|
930
1613
|
isContainer: true,
|
931
1614
|
hooks: ["before:components", "before:render:components", "before:layout", "after:components", "after:layout", "first:activation"],
|
@@ -934,68 +1617,49 @@
|
|
934
1617
|
initialize: function(options) {
|
935
1618
|
this.options = options != null ? options : {};
|
936
1619
|
_.extend(this, this.options);
|
937
|
-
this.setupHooks(
|
1620
|
+
this.setupHooks(["before:components", "before:render:components", "before:layout", "after:components", "after:layout", "first:activation"]);
|
938
1621
|
return Luca.View.prototype.initialize.apply(this, arguments);
|
939
1622
|
},
|
940
1623
|
beforeRender: function() {
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
this.prepareLayout();
|
949
|
-
return this.trigger("after:layout", this);
|
950
|
-
},
|
951
|
-
doComponents: function() {
|
952
|
-
this.debug("container do components");
|
953
|
-
this.trigger("before:components", this, this.components);
|
954
|
-
this.prepareComponents();
|
955
|
-
this.createComponents();
|
956
|
-
this.trigger("before:render:components", this, this.components);
|
957
|
-
this.renderComponents();
|
958
|
-
return this.trigger("after:components", this, this.components);
|
959
|
-
},
|
960
|
-
applyPanelConfig: function(panel, panelIndex) {
|
961
|
-
var config, style_declarations;
|
962
|
-
style_declarations = [];
|
963
|
-
if (panel.height) {
|
964
|
-
style_declarations.push("height: " + (_.isNumber(panel.height) ? panel.height + 'px' : panel.height));
|
965
|
-
}
|
966
|
-
if (panel.width) {
|
967
|
-
style_declarations.push("width: " + (_.isNumber(panel.width) ? panel.width + 'px' : panel.width));
|
968
|
-
}
|
969
|
-
if (panel.float) style_declarations.push("float: " + panel.float);
|
970
|
-
return config = {
|
971
|
-
classes: (panel != null ? panel.classes : void 0) || this.componentClass,
|
972
|
-
id: "" + this.cid + "-" + panelIndex,
|
973
|
-
style: style_declarations.join(';')
|
974
|
-
};
|
1624
|
+
var _ref;
|
1625
|
+
doLayout.call(this);
|
1626
|
+
doComponents.call(this);
|
1627
|
+
return (_ref = Luca.components.Panel.prototype.beforeRender) != null ? _ref.apply(this, arguments) : void 0;
|
1628
|
+
},
|
1629
|
+
customizeContainerEl: function(containerEl, panel, panelIndex) {
|
1630
|
+
return containerEl;
|
975
1631
|
},
|
976
1632
|
prepareLayout: function() {
|
977
|
-
var
|
978
|
-
|
979
|
-
this.componentContainers = _(this.components).map(function(component, index) {
|
980
|
-
return
|
981
|
-
});
|
982
|
-
if (this.appendContainers) {
|
983
|
-
return _(this.componentContainers).each(function(container) {
|
984
|
-
if (container.appended == null) {
|
985
|
-
_this.$el.append(Luca.templates["containers/basic"](container));
|
986
|
-
}
|
987
|
-
return container.appended = true;
|
988
|
-
});
|
989
|
-
}
|
1633
|
+
var container;
|
1634
|
+
container = this;
|
1635
|
+
return this.componentContainers = _(this.components).map(function(component, index) {
|
1636
|
+
return applyDOMConfig.call(container, component, index);
|
1637
|
+
});
|
990
1638
|
},
|
991
1639
|
prepareComponents: function() {
|
992
|
-
var
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
1640
|
+
var component, _i, _len, _ref,
|
1641
|
+
_this = this;
|
1642
|
+
_ref = this.components;
|
1643
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1644
|
+
component = _ref[_i];
|
1645
|
+
if (_.isString(component)) {
|
1646
|
+
component = {
|
1647
|
+
type: component
|
1648
|
+
};
|
1649
|
+
}
|
1650
|
+
}
|
1651
|
+
return _(this.components).each(function(component, index) {
|
1652
|
+
var container, panel, _ref2;
|
1653
|
+
container = (_ref2 = _this.componentContainers) != null ? _ref2[index] : void 0;
|
1654
|
+
container["class"] = container["class"] || container.className || container.classes;
|
1655
|
+
if (_this.appendContainers) {
|
1656
|
+
panel = _this.make(_this.componentTag, container, '');
|
1657
|
+
_this.$append(panel);
|
1658
|
+
}
|
1659
|
+
if (component.container == null) {
|
1660
|
+
if (_this.appendContainers) component.container = "#" + container.id;
|
1661
|
+
return component.container || (component.container = _this.$bodyEl());
|
1662
|
+
}
|
999
1663
|
});
|
1000
1664
|
},
|
1001
1665
|
createComponents: function() {
|
@@ -1008,7 +1672,7 @@
|
|
1008
1672
|
};
|
1009
1673
|
this.components = _(this.components).map(function(object, index) {
|
1010
1674
|
var component;
|
1011
|
-
component =
|
1675
|
+
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));
|
1012
1676
|
if (!component.container && component.options.container) {
|
1013
1677
|
component.container = component.options.container;
|
1014
1678
|
}
|
@@ -1019,6 +1683,7 @@
|
|
1019
1683
|
return component;
|
1020
1684
|
});
|
1021
1685
|
this.componentsCreated = true;
|
1686
|
+
if (!_.isEmpty(this.componentEvents)) this.registerComponentEvents();
|
1022
1687
|
return map;
|
1023
1688
|
},
|
1024
1689
|
renderComponents: function(debugMode) {
|
@@ -1034,21 +1699,23 @@
|
|
1034
1699
|
return component.render();
|
1035
1700
|
} catch (e) {
|
1036
1701
|
console.log("Error Rendering Component " + (component.name || component.cid), component);
|
1037
|
-
|
1038
|
-
|
1702
|
+
if (_.isObject(e)) {
|
1703
|
+
console.log(e.message);
|
1704
|
+
console.log(e.stack);
|
1705
|
+
}
|
1039
1706
|
if ((Luca.silenceRenderErrors != null) !== true) throw e;
|
1040
1707
|
}
|
1041
1708
|
});
|
1042
1709
|
},
|
1043
1710
|
firstActivation: function() {
|
1044
|
-
var
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1711
|
+
var activator;
|
1712
|
+
activator = this;
|
1713
|
+
return this.each(function(component, index) {
|
1714
|
+
var _ref;
|
1048
1715
|
if ((component != null ? component.previously_activated : void 0) !== true) {
|
1049
1716
|
if (component != null) {
|
1050
1717
|
if ((_ref = component.trigger) != null) {
|
1051
|
-
_ref.
|
1718
|
+
_ref.call(component, "first:activation", component, activator);
|
1052
1719
|
}
|
1053
1720
|
}
|
1054
1721
|
return component.previously_activated = true;
|
@@ -1070,6 +1737,19 @@
|
|
1070
1737
|
});
|
1071
1738
|
return _.flatten(components);
|
1072
1739
|
},
|
1740
|
+
componentEvents: {},
|
1741
|
+
registerComponentEvents: function() {
|
1742
|
+
var component, componentName, handler, listener, trigger, _ref, _ref2, _results;
|
1743
|
+
_ref = this.componentEvents;
|
1744
|
+
_results = [];
|
1745
|
+
for (listener in _ref) {
|
1746
|
+
handler = _ref[listener];
|
1747
|
+
_ref2 = listener.split(' '), componentName = _ref2[0], trigger = _ref2[1];
|
1748
|
+
component = this.findComponentByName(componentName);
|
1749
|
+
_results.push(component != null ? component.bind(trigger, this[handler]) : void 0);
|
1750
|
+
}
|
1751
|
+
return _results;
|
1752
|
+
},
|
1073
1753
|
findComponentByName: function(name, deep) {
|
1074
1754
|
if (deep == null) deep = false;
|
1075
1755
|
return this.findComponent(name, "name_index", deep);
|
@@ -1093,12 +1773,15 @@
|
|
1093
1773
|
return sub_container != null ? typeof sub_container.findComponent === "function" ? sub_container.findComponent(needle, haystack, true) : void 0 : void 0;
|
1094
1774
|
}
|
1095
1775
|
},
|
1776
|
+
each: function(fn) {
|
1777
|
+
return this.eachComponent(fn, false);
|
1778
|
+
},
|
1096
1779
|
eachComponent: function(fn, deep) {
|
1097
1780
|
var _this = this;
|
1098
1781
|
if (deep == null) deep = true;
|
1099
|
-
return _(this.components).each(function(component) {
|
1782
|
+
return _(this.components).each(function(component, index) {
|
1100
1783
|
var _ref;
|
1101
|
-
fn.
|
1784
|
+
fn.call(component, component, index);
|
1102
1785
|
if (deep) {
|
1103
1786
|
return component != null ? (_ref = component.eachComponent) != null ? _ref.apply(component, [fn, deep]) : void 0 : void 0;
|
1104
1787
|
}
|
@@ -1114,7 +1797,7 @@
|
|
1114
1797
|
return this.components[this.activeItem];
|
1115
1798
|
},
|
1116
1799
|
componentElements: function() {
|
1117
|
-
return $("
|
1800
|
+
return $(">." + this.componentClass, this.el);
|
1118
1801
|
},
|
1119
1802
|
getComponent: function(needle) {
|
1120
1803
|
return this.components[needle];
|
@@ -1330,8 +2013,7 @@
|
|
1330
2013
|
}).call(this);
|
1331
2014
|
(function() {
|
1332
2015
|
|
1333
|
-
_.
|
1334
|
-
layout: '100',
|
2016
|
+
_.def('Luca.containers.SplitView')["extends"]('Luca.core.Container')["with"]({
|
1335
2017
|
componentType: 'split_view',
|
1336
2018
|
containerTemplate: 'containers/basic',
|
1337
2019
|
className: 'luca-ui-split-view',
|
@@ -1341,7 +2023,7 @@
|
|
1341
2023
|
}).call(this);
|
1342
2024
|
(function() {
|
1343
2025
|
|
1344
|
-
_.
|
2026
|
+
_.def('Luca.containers.ColumnView')["extends"]('Luca.core.Container')["with"]({
|
1345
2027
|
componentType: 'column_view',
|
1346
2028
|
className: 'luca-ui-column-view',
|
1347
2029
|
components: [],
|
@@ -1370,12 +2052,6 @@
|
|
1370
2052
|
return "" + val + "%";
|
1371
2053
|
});
|
1372
2054
|
},
|
1373
|
-
beforeComponents: function() {
|
1374
|
-
this.debug("column_view before components");
|
1375
|
-
return _(this.components).each(function(component) {
|
1376
|
-
return component.ctype || (component.ctype = "panel_view");
|
1377
|
-
});
|
1378
|
-
},
|
1379
2055
|
beforeLayout: function() {
|
1380
2056
|
var _ref,
|
1381
2057
|
_this = this;
|
@@ -1391,47 +2067,43 @@
|
|
1391
2067
|
}).call(this);
|
1392
2068
|
(function() {
|
1393
2069
|
|
1394
|
-
_.
|
2070
|
+
_.def("Luca.containers.CardView")["extends"]("Luca.core.Container")["with"]({
|
1395
2071
|
componentType: 'card_view',
|
1396
2072
|
className: 'luca-ui-card-view-wrapper',
|
1397
2073
|
activeCard: 0,
|
1398
2074
|
components: [],
|
1399
2075
|
hooks: ['before:card:switch', 'after:card:switch'],
|
2076
|
+
componentClass: 'luca-ui-card',
|
2077
|
+
appendContainers: true,
|
1400
2078
|
initialize: function(options) {
|
1401
2079
|
this.options = options;
|
1402
2080
|
Luca.core.Container.prototype.initialize.apply(this, arguments);
|
1403
2081
|
return this.setupHooks(this.hooks);
|
1404
2082
|
},
|
1405
|
-
componentClass: 'luca-ui-card',
|
1406
|
-
beforeLayout: function() {
|
1407
|
-
var _this = this;
|
1408
|
-
return this.cards = _(this.components).map(function(card, cardIndex) {
|
1409
|
-
return {
|
1410
|
-
classes: _this.componentClass,
|
1411
|
-
style: "display:" + (cardIndex === _this.activeCard ? 'block' : 'none'),
|
1412
|
-
id: "" + _this.cid + "-" + cardIndex
|
1413
|
-
};
|
1414
|
-
});
|
1415
|
-
},
|
1416
|
-
prepareLayout: function() {
|
1417
|
-
var _this = this;
|
1418
|
-
return this.card_containers = _(this.cards).map(function(card, index) {
|
1419
|
-
_this.$el.append(Luca.templates["containers/basic"](card));
|
1420
|
-
return $("#" + card.id);
|
1421
|
-
});
|
1422
|
-
},
|
1423
2083
|
prepareComponents: function() {
|
1424
|
-
var
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
2084
|
+
var _ref,
|
2085
|
+
_this = this;
|
2086
|
+
if ((_ref = Luca.core.Container.prototype.prepareComponents) != null) {
|
2087
|
+
_ref.apply(this, arguments);
|
2088
|
+
}
|
2089
|
+
return _(this.components).each(function(component, index) {
|
2090
|
+
if (index === _this.activeCard) {
|
2091
|
+
return $(component.container).show();
|
2092
|
+
} else {
|
2093
|
+
return $(component.container).hide();
|
2094
|
+
}
|
1430
2095
|
});
|
1431
2096
|
},
|
2097
|
+
activeComponentElement: function() {
|
2098
|
+
return this.componentElements().eq(this.activeCard);
|
2099
|
+
},
|
1432
2100
|
activeComponent: function() {
|
1433
2101
|
return this.getComponent(this.activeCard);
|
1434
2102
|
},
|
2103
|
+
customizeContainerEl: function(containerEl, panel, panelIndex) {
|
2104
|
+
containerEl.style += panelIndex === this.activeCard ? "display:block;" : "display:none;";
|
2105
|
+
return containerEl;
|
2106
|
+
},
|
1435
2107
|
cycle: function() {
|
1436
2108
|
var nextIndex;
|
1437
2109
|
nextIndex = this.activeCard < this.components.length - 1 ? this.activeCard + 1 : 0;
|
@@ -1471,15 +2143,13 @@
|
|
1471
2143
|
}
|
1472
2144
|
}
|
1473
2145
|
}
|
1474
|
-
|
1475
|
-
return container.hide();
|
1476
|
-
});
|
2146
|
+
this.componentElements().hide();
|
1477
2147
|
if (!current.previously_activated) {
|
1478
2148
|
current.trigger("first:activation");
|
1479
2149
|
current.previously_activated = true;
|
1480
2150
|
}
|
1481
|
-
$(current.container).show();
|
1482
2151
|
this.activeCard = index;
|
2152
|
+
this.activeComponentElement().show();
|
1483
2153
|
if (!silent) {
|
1484
2154
|
this.trigger("after:card:switch", previous, current);
|
1485
2155
|
if ((_ref3 = previous.trigger) != null) {
|
@@ -1498,92 +2168,171 @@
|
|
1498
2168
|
}).call(this);
|
1499
2169
|
(function() {
|
1500
2170
|
|
1501
|
-
_.
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
hooks: ['before:show', 'before:hide'],
|
1508
|
-
defaultModalOptions: {
|
1509
|
-
minWidth: 375,
|
1510
|
-
maxWidth: 375,
|
1511
|
-
minHeight: 550,
|
1512
|
-
maxHeight: 550,
|
1513
|
-
opacity: 80,
|
1514
|
-
onOpen: function(modal) {
|
1515
|
-
this.onOpen.apply(this);
|
1516
|
-
return this.onModalOpen.apply(modal, [modal, this]);
|
1517
|
-
},
|
1518
|
-
onClose: function(modal) {
|
1519
|
-
this.onClose.apply(this);
|
1520
|
-
return this.onModalClose.apply(modal, [modal, this]);
|
1521
|
-
}
|
1522
|
-
},
|
1523
|
-
modalOptions: {},
|
1524
|
-
initialize: function(options) {
|
1525
|
-
var _this = this;
|
1526
|
-
this.options = options != null ? options : {};
|
1527
|
-
Luca.core.Container.prototype.initialize.apply(this, arguments);
|
1528
|
-
this.setupHooks(this.hooks);
|
1529
|
-
_(this.defaultModalOptions).each(function(value, setting) {
|
1530
|
-
var _base;
|
1531
|
-
return (_base = _this.modalOptions)[setting] || (_base[setting] = value);
|
1532
|
-
});
|
1533
|
-
this.modalOptions.onOpen = _.bind(this.modalOptions.onOpen, this);
|
1534
|
-
return this.modalOptions.onClose = _.bind(this.modalOptions.onClose, this);
|
1535
|
-
},
|
1536
|
-
onOpen: function() {
|
1537
|
-
return true;
|
2171
|
+
_.def("Luca.ModalView")["extends"]("Luca.View")["with"]({
|
2172
|
+
closeOnEscape: true,
|
2173
|
+
showOnInitialize: false,
|
2174
|
+
backdrop: false,
|
2175
|
+
container: function() {
|
2176
|
+
return $('body');
|
1538
2177
|
},
|
1539
|
-
|
1540
|
-
return
|
2178
|
+
toggle: function() {
|
2179
|
+
return this.$el.modal('toggle');
|
1541
2180
|
},
|
1542
|
-
|
1543
|
-
return this.modal;
|
2181
|
+
show: function() {
|
2182
|
+
return this.$el.modal('show');
|
1544
2183
|
},
|
1545
|
-
|
1546
|
-
|
1547
|
-
modal.overlay.show();
|
1548
|
-
modal.container.show();
|
1549
|
-
return modal.data.show();
|
2184
|
+
hide: function() {
|
2185
|
+
return this.$el.modal('hide');
|
1550
2186
|
},
|
1551
|
-
|
1552
|
-
|
2187
|
+
render: function() {
|
2188
|
+
this.$el.addClass('modal');
|
2189
|
+
if (this.fade === true) this.$el.addClass('fade');
|
2190
|
+
$('body').append(this.$el);
|
2191
|
+
return this.$el.modal({
|
2192
|
+
backdrop: this.backdrop === true,
|
2193
|
+
keyboard: this.closeOnEscape === true,
|
2194
|
+
show: this.showOnInitialize === true
|
2195
|
+
});
|
2196
|
+
}
|
2197
|
+
});
|
2198
|
+
|
2199
|
+
_.def("Luca.containers.ModalView")["extends"]("Luca.ModalView")["with"]();
|
2200
|
+
|
2201
|
+
}).call(this);
|
2202
|
+
(function() {
|
2203
|
+
var buildButton, make, prepareButtons;
|
2204
|
+
|
2205
|
+
make = Backbone.View.prototype.make;
|
2206
|
+
|
2207
|
+
buildButton = function(config, wrap) {
|
2208
|
+
var autoWrapClass, buttonAttributes, buttonEl, buttons, dropdownEl, dropdownItems, label, object, white, wrapper,
|
2209
|
+
_this = this;
|
2210
|
+
if (wrap == null) wrap = true;
|
2211
|
+
if (config.ctype != null) {
|
2212
|
+
config.className || (config.className = "");
|
2213
|
+
config.className += 'toolbar-component';
|
2214
|
+
object = Luca(config).render();
|
2215
|
+
if (Luca.isBackboneView(object)) {
|
2216
|
+
console.log("Adding toolbar component", object);
|
2217
|
+
return object.el;
|
2218
|
+
}
|
2219
|
+
}
|
2220
|
+
if (config.spacer) {
|
2221
|
+
return make("div", {
|
2222
|
+
"class": "spacer " + config.spacer
|
2223
|
+
});
|
2224
|
+
}
|
2225
|
+
if (config.text) {
|
2226
|
+
return make("div", {
|
2227
|
+
"class": "toolbar-text"
|
2228
|
+
}, config.text);
|
2229
|
+
}
|
2230
|
+
wrapper = 'btn-group';
|
2231
|
+
if (config.wrapper != null) wrapper += " " + config.wrapper;
|
2232
|
+
if (config.align != null) wrapper += " align-" + config.align;
|
2233
|
+
if ((config.group != null) && (config.buttons != null)) {
|
2234
|
+
buttons = prepareButtons(config.buttons, false);
|
2235
|
+
return make("div", {
|
2236
|
+
"class": wrapper
|
2237
|
+
}, buttons);
|
2238
|
+
} else {
|
2239
|
+
label = config.label || (config.label = "");
|
2240
|
+
config.eventId || (config.eventId = _.string.dasherize(config.label.toLowerCase()));
|
2241
|
+
if (config.icon) {
|
2242
|
+
if (_.string.isBlank(label)) label = " ";
|
2243
|
+
if (config.white) white = "icon-white";
|
2244
|
+
label = "<i class='" + (white || "") + " icon-" + config.icon + "' /> " + label;
|
2245
|
+
}
|
2246
|
+
buttonAttributes = {
|
2247
|
+
"class": _.compact(["btn", config.classes, config.className]).join(" "),
|
2248
|
+
"data-eventId": config.eventId,
|
2249
|
+
title: config.title || config.description
|
2250
|
+
};
|
2251
|
+
if (config.color != null) {
|
2252
|
+
buttonAttributes["class"] += " btn-" + config.color;
|
2253
|
+
}
|
2254
|
+
if (config.dropdown) {
|
2255
|
+
label = "" + label + " <span class='caret'></span>";
|
2256
|
+
buttonAttributes["class"] += " dropdown-toggle";
|
2257
|
+
buttonAttributes["data-toggle"] = "dropdown";
|
2258
|
+
dropdownItems = _(config.dropdown).map(function(dropdownItem) {
|
2259
|
+
var link;
|
2260
|
+
link = make("a", {}, dropdownItem[1]);
|
2261
|
+
return make("li", {
|
2262
|
+
"data-eventId": dropdownItem[0]
|
2263
|
+
}, link);
|
2264
|
+
});
|
2265
|
+
dropdownEl = make("ul", {
|
2266
|
+
"class": "dropdown-menu"
|
2267
|
+
}, dropdownItems);
|
2268
|
+
}
|
2269
|
+
buttonEl = make("a", buttonAttributes, label);
|
2270
|
+
autoWrapClass = "btn-group";
|
2271
|
+
if (config.align != null) autoWrapClass += " align-" + config.align;
|
2272
|
+
if (wrap === true) {
|
2273
|
+
return make("div", {
|
2274
|
+
"class": autoWrapClass
|
2275
|
+
}, [buttonEl, dropdownEl]);
|
2276
|
+
} else {
|
2277
|
+
return buttonEl;
|
2278
|
+
}
|
2279
|
+
}
|
2280
|
+
};
|
2281
|
+
|
2282
|
+
prepareButtons = function(buttons, wrap) {
|
2283
|
+
if (wrap == null) wrap = true;
|
2284
|
+
return _(buttons).map(function(button) {
|
2285
|
+
return buildButton(button, wrap);
|
2286
|
+
});
|
2287
|
+
};
|
2288
|
+
|
2289
|
+
_.def("Luca.containers.PanelToolbar")["extends"]("Luca.View")["with"]({
|
2290
|
+
className: "luca-ui-toolbar btn-toolbar",
|
2291
|
+
buttons: [],
|
2292
|
+
well: true,
|
2293
|
+
orientation: 'top',
|
2294
|
+
autoBindEventHandlers: true,
|
2295
|
+
events: {
|
2296
|
+
"click a.btn, click .dropdown-menu li": "clickHandler"
|
2297
|
+
},
|
2298
|
+
clickHandler: function(e) {
|
2299
|
+
var eventId, hook, me, my, source;
|
2300
|
+
me = my = $(e.target);
|
2301
|
+
if (me.is('i')) me = my = $(e.target).parent();
|
2302
|
+
eventId = my.data('eventid');
|
2303
|
+
if (eventId == null) return;
|
2304
|
+
hook = Luca.util.hook(eventId);
|
2305
|
+
source = this.parent || this;
|
2306
|
+
if (_.isFunction(source[hook])) {
|
2307
|
+
return source[hook].call(this, me, e);
|
2308
|
+
} else {
|
2309
|
+
return source.trigger(eventId, me, e);
|
2310
|
+
}
|
1553
2311
|
},
|
1554
|
-
|
1555
|
-
|
2312
|
+
beforeRender: function() {
|
2313
|
+
this._super("beforeRender", this, arguments);
|
2314
|
+
if (this.well === true) this.$el.addClass('well');
|
2315
|
+
this.$el.addClass("toolbar-" + this.orientation);
|
2316
|
+
if (this.styles != null) return this.applyStyles(this.styles);
|
1556
2317
|
},
|
1557
|
-
|
1558
|
-
var
|
1559
|
-
|
1560
|
-
|
1561
|
-
|
2318
|
+
render: function() {
|
2319
|
+
var elements,
|
2320
|
+
_this = this;
|
2321
|
+
this.$el.empty();
|
2322
|
+
elements = prepareButtons(this.buttons);
|
2323
|
+
return _(elements).each(function(element) {
|
2324
|
+
return _this.$el.append(element);
|
1562
2325
|
});
|
1563
2326
|
},
|
1564
|
-
afterInitialize: function() {
|
1565
|
-
this.$el.hide();
|
1566
|
-
if (this.renderOnInitialize) return this.render();
|
1567
|
-
},
|
1568
2327
|
afterRender: function() {
|
1569
|
-
|
1570
|
-
},
|
1571
|
-
wrapper: function() {
|
1572
|
-
return $(this.$el.parent());
|
1573
|
-
},
|
1574
|
-
show: function() {
|
1575
|
-
this.trigger("before:show", this);
|
1576
|
-
return this.$el.modal(this.modalOptions);
|
1577
|
-
},
|
1578
|
-
hide: function() {
|
1579
|
-
return this.trigger("before:hide", this);
|
2328
|
+
return this._super("afterRender", this, arguments);
|
1580
2329
|
}
|
1581
2330
|
});
|
1582
2331
|
|
1583
2332
|
}).call(this);
|
1584
2333
|
(function() {
|
1585
2334
|
|
1586
|
-
_.
|
2335
|
+
_.def('Luca.containers.PanelView')["extends"]('Luca.core.Container')["with"]({
|
1587
2336
|
className: 'luca-ui-panel',
|
1588
2337
|
initialize: function(options) {
|
1589
2338
|
this.options = options != null ? options : {};
|
@@ -1616,15 +2365,14 @@
|
|
1616
2365
|
}).call(this);
|
1617
2366
|
(function() {
|
1618
2367
|
|
1619
|
-
_.
|
1620
|
-
events: {
|
1621
|
-
"click ul.nav-tabs li": "select"
|
1622
|
-
},
|
2368
|
+
_.def('Luca.containers.TabView')["extends"]('Luca.containers.CardView')["with"]({
|
1623
2369
|
hooks: ["before:select", "after:select"],
|
1624
2370
|
componentType: 'tab_view',
|
1625
2371
|
className: 'luca-ui-tab-view tabbable',
|
1626
2372
|
tab_position: 'top',
|
1627
2373
|
tabVerticalOffset: '50px',
|
2374
|
+
bodyTemplate: "containers/tab_view",
|
2375
|
+
bodyEl: "div.tab-content",
|
1628
2376
|
initialize: function(options) {
|
1629
2377
|
this.options = options != null ? options : {};
|
1630
2378
|
Luca.containers.CardView.prototype.initialize.apply(this, arguments);
|
@@ -1635,50 +2383,50 @@
|
|
1635
2383
|
activeTabSelector: function() {
|
1636
2384
|
return this.tabSelectors().eq(this.activeCard || this.activeTab || this.activeItem);
|
1637
2385
|
},
|
1638
|
-
prepareLayout: function() {
|
1639
|
-
var _this = this;
|
1640
|
-
return this.card_containers = _(this.cards).map(function(card, index) {
|
1641
|
-
_this.$('.tab-content').append(Luca.templates["containers/basic"](card));
|
1642
|
-
return $("#" + card.id);
|
1643
|
-
});
|
1644
|
-
},
|
1645
2386
|
beforeLayout: function() {
|
2387
|
+
var _ref;
|
1646
2388
|
this.$el.addClass("tabs-" + this.tab_position);
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
} else {
|
1651
|
-
this.$el.append(Luca.templates["containers/tab_selector_container"](this));
|
1652
|
-
this.$el.append(Luca.templates["containers/tab_view"](this));
|
1653
|
-
}
|
1654
|
-
return Luca.containers.CardView.prototype.beforeLayout.apply(this, arguments);
|
2389
|
+
this.activeTabSelector().addClass('active');
|
2390
|
+
this.createTabSelectors();
|
2391
|
+
return (_ref = Luca.containers.CardView.prototype.beforeLayout) != null ? _ref.apply(this, arguments) : void 0;
|
1655
2392
|
},
|
1656
|
-
|
2393
|
+
afterRender: function() {
|
1657
2394
|
var _ref;
|
1658
|
-
if ((_ref = Luca.containers.CardView.prototype.
|
2395
|
+
if ((_ref = Luca.containers.CardView.prototype.afterRender) != null) {
|
1659
2396
|
_ref.apply(this, arguments);
|
1660
2397
|
}
|
1661
|
-
this.
|
1662
|
-
if (Luca.enableBootstrap && this.tab_position === "left" || this.tab_position === "right") {
|
1663
|
-
this
|
1664
|
-
this.
|
1665
|
-
this.tabContentWrapper().addClass('grid-9');
|
1666
|
-
if (this.tabVerticalOffset) {
|
1667
|
-
return this.tabContainerWrapper().css('padding-top', this.tabVerticalOffset);
|
1668
|
-
}
|
2398
|
+
this.registerEvent("click #" + this.cid + "-tabs-selector li a", "select");
|
2399
|
+
if (Luca.enableBootstrap && (this.tab_position === "left" || this.tab_position === "right")) {
|
2400
|
+
this.tabContainerWrapper().addClass("span2");
|
2401
|
+
return this.tabContentWrapper().addClass("span9");
|
1669
2402
|
}
|
1670
2403
|
},
|
2404
|
+
createTabSelectors: function() {
|
2405
|
+
var tabView;
|
2406
|
+
tabView = this;
|
2407
|
+
return this.each(function(component, index) {
|
2408
|
+
var selector;
|
2409
|
+
selector = tabView.make("li", {
|
2410
|
+
"class": "tab-selector",
|
2411
|
+
"data-target": index
|
2412
|
+
}, "<a>" + component.title + "</a>");
|
2413
|
+
return tabView.tabContainer().append(selector);
|
2414
|
+
});
|
2415
|
+
},
|
1671
2416
|
highlightSelectedTab: function() {
|
1672
2417
|
this.tabSelectors().removeClass('active');
|
1673
2418
|
return this.activeTabSelector().addClass('active');
|
1674
2419
|
},
|
1675
2420
|
select: function(e) {
|
1676
2421
|
var me, my;
|
1677
|
-
me = my = $(e.
|
2422
|
+
me = my = $(e.target);
|
1678
2423
|
this.trigger("before:select", this);
|
1679
|
-
this.activate(my.data('target'));
|
2424
|
+
this.activate(my.parent().data('target'));
|
1680
2425
|
return this.trigger("after:select", this);
|
1681
2426
|
},
|
2427
|
+
componentElements: function() {
|
2428
|
+
return this.$(">.tab-content >." + this.componentClass);
|
2429
|
+
},
|
1682
2430
|
tabContentWrapper: function() {
|
1683
2431
|
return $("#" + this.cid + "-tab-view-content");
|
1684
2432
|
},
|
@@ -1686,28 +2434,58 @@
|
|
1686
2434
|
return $("#" + this.cid + "-tabs-selector");
|
1687
2435
|
},
|
1688
2436
|
tabContainer: function() {
|
1689
|
-
return
|
2437
|
+
return this.$('ul.nav-tabs', this.tabContainerWrapper());
|
1690
2438
|
},
|
1691
2439
|
tabSelectors: function() {
|
1692
|
-
return
|
2440
|
+
return this.$('li.tab-selector', this.tabContainer());
|
1693
2441
|
}
|
1694
2442
|
});
|
1695
2443
|
|
1696
2444
|
}).call(this);
|
1697
2445
|
(function() {
|
1698
2446
|
|
1699
|
-
_.
|
2447
|
+
_.def('Luca.containers.Viewport').extend('Luca.containers.CardView')["with"]({
|
1700
2448
|
activeItem: 0,
|
1701
2449
|
className: 'luca-ui-viewport',
|
1702
2450
|
fullscreen: true,
|
2451
|
+
fluid: false,
|
2452
|
+
wrapperClass: 'row',
|
1703
2453
|
initialize: function(options) {
|
1704
2454
|
this.options = options != null ? options : {};
|
1705
2455
|
Luca.core.Container.prototype.initialize.apply(this, arguments);
|
2456
|
+
if (Luca.enableBootstrap === true) {
|
2457
|
+
if (this.fluid === true) this.wrapperClass = "row-fluid";
|
2458
|
+
this.$el.wrap("<div class='" + this.wrapperClass + "' />").addClass('span12');
|
2459
|
+
}
|
1706
2460
|
if (this.fullscreen) return $('html,body').addClass('luca-ui-fullscreen');
|
1707
2461
|
},
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
2462
|
+
beforeRender: function() {
|
2463
|
+
var _ref;
|
2464
|
+
if ((_ref = Luca.containers.CardView.prototype.beforeRender) != null) {
|
2465
|
+
_ref.apply(this, arguments);
|
2466
|
+
}
|
2467
|
+
if (Luca.enableBootstrap && this.topNav && this.fullscreen) {
|
2468
|
+
$('body').css('padding', '40px');
|
2469
|
+
}
|
2470
|
+
if (this.topNav != null) this.renderTopNavigation();
|
2471
|
+
if (this.bottomNav != null) return this.renderBottomNavigation();
|
2472
|
+
},
|
2473
|
+
renderTopNavigation: function() {
|
2474
|
+
var _base;
|
2475
|
+
if (this.topNav == null) return;
|
2476
|
+
if (_.isString(this.topNav)) {
|
2477
|
+
this.topNav = Luca.util.lazyComponent(this.topNav);
|
2478
|
+
}
|
2479
|
+
if (_.isObject(this.topNav)) {
|
2480
|
+
(_base = this.topNav).ctype || (_base.ctype = this.topNav.type || "nav_bar");
|
2481
|
+
if (!Luca.isBackboneView(this.topNav)) {
|
2482
|
+
this.topNav = Luca.util.lazyComponent(this.topNav);
|
2483
|
+
}
|
2484
|
+
}
|
2485
|
+
this.topNav.app = this;
|
2486
|
+
return $('body').prepend(this.topNav.render().el);
|
2487
|
+
},
|
2488
|
+
renderBottomNavigation: function() {}
|
1711
2489
|
});
|
1712
2490
|
|
1713
2491
|
}).call(this);
|
@@ -1718,56 +2496,59 @@
|
|
1718
2496
|
}).call(this);
|
1719
2497
|
(function() {
|
1720
2498
|
|
1721
|
-
_.
|
1722
|
-
templateContainer: "Luca.templates",
|
2499
|
+
_.def('Luca.components.Template')["extends"]('Luca.View')["with"]({
|
1723
2500
|
initialize: function(options) {
|
1724
2501
|
this.options = options != null ? options : {};
|
1725
|
-
Luca.
|
1726
|
-
|
1727
|
-
throw "Templates must specify which template / markup to use";
|
1728
|
-
}
|
1729
|
-
if (_.isString(this.templateContainer)) {
|
1730
|
-
return this.templateContainer = eval("(window || global)." + this.templateContainer);
|
1731
|
-
}
|
1732
|
-
},
|
1733
|
-
beforeRender: function() {
|
1734
|
-
if (_.isUndefined(this.templateContainer)) this.templateContainer = JST;
|
1735
|
-
return this.$el.html(this.markup || this.templateContainer[this.template](this.options));
|
1736
|
-
},
|
1737
|
-
render: function() {
|
1738
|
-
return $(this.container).append(this.$el);
|
2502
|
+
console.log("The Use of Luca.components.Template directly is being DEPRECATED");
|
2503
|
+
return Luca.View.prototype.initialize.apply(this, arguments);
|
1739
2504
|
}
|
1740
2505
|
});
|
1741
2506
|
|
1742
2507
|
}).call(this);
|
1743
2508
|
(function() {
|
1744
2509
|
|
1745
|
-
_.
|
2510
|
+
_.def('Luca.Application')["extends"]('Luca.containers.Viewport')["with"]({
|
2511
|
+
autoStartHistory: true,
|
2512
|
+
useCollectionManager: true,
|
2513
|
+
plugin: false,
|
2514
|
+
useController: true,
|
1746
2515
|
components: [
|
1747
2516
|
{
|
1748
|
-
ctype: '
|
1749
|
-
name: '
|
1750
|
-
|
1751
|
-
|
1752
|
-
{
|
1753
|
-
ctype: 'template',
|
1754
|
-
name: 'welcome',
|
1755
|
-
template: 'sample/welcome',
|
1756
|
-
templateContainer: "Luca.templates"
|
1757
|
-
}
|
1758
|
-
]
|
2517
|
+
ctype: 'template',
|
2518
|
+
name: 'welcome',
|
2519
|
+
template: 'sample/welcome',
|
2520
|
+
templateContainer: "Luca.templates"
|
1759
2521
|
}
|
1760
2522
|
],
|
1761
2523
|
initialize: function(options) {
|
1762
|
-
var _base,
|
2524
|
+
var definedComponents, _base,
|
1763
2525
|
_this = this;
|
1764
2526
|
this.options = options != null ? options : {};
|
1765
2527
|
Luca.containers.Viewport.prototype.initialize.apply(this, arguments);
|
1766
|
-
|
2528
|
+
if (this.useController === true) definedComponents = this.components || [];
|
2529
|
+
this.components = [
|
2530
|
+
{
|
2531
|
+
ctype: 'controller',
|
2532
|
+
name: "main_controller",
|
2533
|
+
components: definedComponents
|
2534
|
+
}
|
2535
|
+
];
|
2536
|
+
if (this.useCollectionManager === true) {
|
2537
|
+
this.collectionManager || (this.collectionManager = typeof (_base = Luca.CollectionManager).get === "function" ? _base.get() : void 0);
|
2538
|
+
this.collectionManager || (this.collectionManager = new Luca.CollectionManager(this.collectionManagerOptions || (this.collectionManagerOptions = {})));
|
2539
|
+
}
|
1767
2540
|
this.state = new Backbone.Model(this.defaultState);
|
1768
|
-
|
2541
|
+
this.bind("ready", function() {
|
1769
2542
|
return _this.render();
|
1770
2543
|
});
|
2544
|
+
if (this.useKeyRouter === true && (this.keyEvents != null)) {
|
2545
|
+
this.setupKeyRouter();
|
2546
|
+
}
|
2547
|
+
if (this.plugin !== true) {
|
2548
|
+
return Luca.getApplication = function() {
|
2549
|
+
return _this;
|
2550
|
+
};
|
2551
|
+
}
|
1771
2552
|
},
|
1772
2553
|
activeView: function() {
|
1773
2554
|
var active;
|
@@ -1783,6 +2564,22 @@
|
|
1783
2564
|
activeSection: function() {
|
1784
2565
|
return this.get("active_section");
|
1785
2566
|
},
|
2567
|
+
beforeRender: function() {
|
2568
|
+
var routerStartEvent, _ref;
|
2569
|
+
if ((_ref = Luca.containers.Viewport.prototype.beforeRender) != null) {
|
2570
|
+
_ref.apply(this, arguments);
|
2571
|
+
}
|
2572
|
+
if ((this.router != null) && this.autoStartHistory === true) {
|
2573
|
+
routerStartEvent = this.startRouterOn || "after:render";
|
2574
|
+
if (routerStartEvent === "before:render") {
|
2575
|
+
return Backbone.history.start();
|
2576
|
+
} else {
|
2577
|
+
return this.bind(routerStartEvent, function() {
|
2578
|
+
return Backbone.history.start();
|
2579
|
+
});
|
2580
|
+
}
|
2581
|
+
}
|
2582
|
+
},
|
1786
2583
|
afterComponents: function() {
|
1787
2584
|
var _ref, _ref2, _ref3,
|
1788
2585
|
_this = this;
|
@@ -1806,10 +2603,6 @@
|
|
1806
2603
|
}
|
1807
2604
|
}) : void 0;
|
1808
2605
|
},
|
1809
|
-
beforeRender: function() {
|
1810
|
-
var _ref;
|
1811
|
-
return (_ref = Luca.containers.Viewport.prototype.beforeRender) != null ? _ref.apply(this, arguments) : void 0;
|
1812
|
-
},
|
1813
2606
|
boot: function() {
|
1814
2607
|
return this.trigger("ready");
|
1815
2608
|
},
|
@@ -1820,20 +2613,55 @@
|
|
1820
2613
|
return this.state.get(attribute);
|
1821
2614
|
},
|
1822
2615
|
getMainController: function() {
|
1823
|
-
return this.
|
2616
|
+
if (this.useController === true) return this.components[0];
|
2617
|
+
return Luca.cache('main_controller');
|
1824
2618
|
},
|
1825
2619
|
set: function(attributes) {
|
1826
2620
|
return this.state.set(attributes);
|
1827
2621
|
},
|
1828
2622
|
view: function(name) {
|
1829
2623
|
return Luca.cache(name);
|
2624
|
+
},
|
2625
|
+
navigate_to: function(component_name, callback) {
|
2626
|
+
return this.getMainController().navigate_to(component_name, callback);
|
2627
|
+
},
|
2628
|
+
setupKeyRouter: function() {
|
2629
|
+
var router, _base;
|
2630
|
+
if (!this.keyEvents) return;
|
2631
|
+
(_base = this.keyEvents).control_meta || (_base.control_meta = {});
|
2632
|
+
if (this.keyEvents.meta_control) {
|
2633
|
+
_.extend(this.keyEvents.control_meta, this.keyEvents.meta_control);
|
2634
|
+
}
|
2635
|
+
router = _.bind(this.keyRouter, this);
|
2636
|
+
return $(document).keydown(router);
|
2637
|
+
},
|
2638
|
+
keyRouter: function(e) {
|
2639
|
+
var control, isInputEvent, keyEvent, keyname, meta, source, _ref;
|
2640
|
+
if (!(e && this.keyEvents)) return;
|
2641
|
+
isInputEvent = $(e.target).is('input') || $(e.target).is('textarea');
|
2642
|
+
if (isInputEvent) return;
|
2643
|
+
keyname = Luca.keyMap[e.keyCode];
|
2644
|
+
if (!keyname) return;
|
2645
|
+
meta = (e != null ? e.metaKey : void 0) === true;
|
2646
|
+
control = (e != null ? e.ctrlKey : void 0) === true;
|
2647
|
+
source = this.keyEvents;
|
2648
|
+
source = meta ? this.keyEvents.meta : source;
|
2649
|
+
source = control ? this.keyEvents.control : source;
|
2650
|
+
source = meta && control ? this.keyEvents.meta_control : source;
|
2651
|
+
if (keyEvent = source != null ? source[keyname] : void 0) {
|
2652
|
+
if (this[keyEvent] != null) {
|
2653
|
+
return (_ref = this[keyEvent]) != null ? _ref.call(this) : void 0;
|
2654
|
+
} else {
|
2655
|
+
return this.trigger(keyEvent);
|
2656
|
+
}
|
2657
|
+
}
|
1830
2658
|
}
|
1831
2659
|
});
|
1832
2660
|
|
1833
2661
|
}).call(this);
|
1834
2662
|
(function() {
|
1835
2663
|
|
1836
|
-
_.
|
2664
|
+
_.def('Luca.components.Toolbar')["extends"]('Luca.core.Container')["with"]({
|
1837
2665
|
className: 'luca-ui-toolbar',
|
1838
2666
|
position: 'bottom',
|
1839
2667
|
initialize: function(options) {
|
@@ -1843,7 +2671,7 @@
|
|
1843
2671
|
prepareComponents: function() {
|
1844
2672
|
var _this = this;
|
1845
2673
|
return _(this.components).each(function(component) {
|
1846
|
-
return component.container = _this
|
2674
|
+
return component.container = _this.$el;
|
1847
2675
|
});
|
1848
2676
|
},
|
1849
2677
|
render: function() {
|
@@ -1854,14 +2682,7 @@
|
|
1854
2682
|
}).call(this);
|
1855
2683
|
(function() {
|
1856
2684
|
|
1857
|
-
_.
|
1858
|
-
name: "collection_inspector"
|
1859
|
-
});
|
1860
|
-
|
1861
|
-
}).call(this);
|
1862
|
-
(function() {
|
1863
|
-
|
1864
|
-
_.component('Luca.components.CollectionLoaderView')["extends"]('Luca.components.Template')["with"]({
|
2685
|
+
_.def('Luca.components.CollectionLoaderView')["extends"]('Luca.components.Template')["with"]({
|
1865
2686
|
className: 'luca-ui-collection-loader-view',
|
1866
2687
|
template: "components/collection_loader_view",
|
1867
2688
|
initialize: function(options) {
|
@@ -1894,10 +2715,94 @@
|
|
1894
2715
|
}
|
1895
2716
|
});
|
1896
2717
|
|
2718
|
+
}).call(this);
|
2719
|
+
(function() {
|
2720
|
+
var make;
|
2721
|
+
|
2722
|
+
make = Luca.View.prototype.make;
|
2723
|
+
|
2724
|
+
_.def("Luca.components.CollectionView")["extends"]("Luca.components.Panel")["with"]({
|
2725
|
+
tagName: "div",
|
2726
|
+
className: "luca-ui-collection-view",
|
2727
|
+
bodyClassName: "collection-ui-panel",
|
2728
|
+
itemTemplate: void 0,
|
2729
|
+
itemRenderer: void 0,
|
2730
|
+
itemTagName: 'li',
|
2731
|
+
itemClassName: 'collection-item',
|
2732
|
+
initialize: function(options) {
|
2733
|
+
this.options = options != null ? options : {};
|
2734
|
+
_.extend(this, this.options);
|
2735
|
+
_.bindAll(this, "refresh");
|
2736
|
+
if (this.collection == null) {
|
2737
|
+
throw "Collection Views must specify a collection";
|
2738
|
+
}
|
2739
|
+
if (!((this.itemTemplate != null) || (this.itemRenderer != null))) {
|
2740
|
+
throw "Collection Views must specify an item template or item renderer function";
|
2741
|
+
}
|
2742
|
+
Luca.components.Panel.prototype.initialize.apply(this, arguments);
|
2743
|
+
if (Luca.isBackboneCollection(this.collection)) {
|
2744
|
+
this.collection.bind("reset", this.refresh);
|
2745
|
+
this.collection.bind("add", this.refresh);
|
2746
|
+
return this.collection.bind("remove", this.refresh);
|
2747
|
+
}
|
2748
|
+
},
|
2749
|
+
attributesForItem: function(item) {
|
2750
|
+
return _.extend({}, {
|
2751
|
+
"class": this.itemClassName,
|
2752
|
+
"data-index": item.index
|
2753
|
+
});
|
2754
|
+
},
|
2755
|
+
contentForItem: function(item) {
|
2756
|
+
var content, templateFn;
|
2757
|
+
if (item == null) item = {};
|
2758
|
+
if ((this.itemTemplate != null) && (templateFn = Luca.template(this.itemTemplate))) {
|
2759
|
+
content = templateFn.call(this, item);
|
2760
|
+
}
|
2761
|
+
if ((this.itemRenderer != null) && _.isFunction(this.itemRenderer)) {
|
2762
|
+
content = this.itemRenderer.call(this, item);
|
2763
|
+
}
|
2764
|
+
return content || "";
|
2765
|
+
},
|
2766
|
+
makeItem: function(model, index) {
|
2767
|
+
var item;
|
2768
|
+
item = this.prepareItem != null ? this.prepareItem.call(this, model, index) : {
|
2769
|
+
model: model,
|
2770
|
+
index: index
|
2771
|
+
};
|
2772
|
+
return make(this.itemTagName, this.attributesForItem(item), this.contentForItem(item));
|
2773
|
+
},
|
2774
|
+
getModels: function() {
|
2775
|
+
return this.collection.models;
|
2776
|
+
},
|
2777
|
+
refresh: function() {
|
2778
|
+
var panel;
|
2779
|
+
panel = this;
|
2780
|
+
this.$bodyEl().empty();
|
2781
|
+
return _(this.getModels()).each(function(model, index) {
|
2782
|
+
return panel.$append(panel.makeItem(model, index));
|
2783
|
+
});
|
2784
|
+
},
|
2785
|
+
registerEvent: function(domEvent, selector, handler) {
|
2786
|
+
var eventTrigger;
|
2787
|
+
if (!(handler != null) && _.isFunction(selector)) {
|
2788
|
+
handler = selector;
|
2789
|
+
selector = void 0;
|
2790
|
+
}
|
2791
|
+
eventTrigger = _([domEvent, "" + this.itemTagName + "." + this.itemClassName, selector]).compact().join(" ");
|
2792
|
+
return Luca.View.prototype.registerEvent(eventTrigger, handler);
|
2793
|
+
},
|
2794
|
+
render: function() {
|
2795
|
+
this.refresh();
|
2796
|
+
if (this.$el.parent().length > 0 && (this.container != null)) {
|
2797
|
+
return this.$attach();
|
2798
|
+
}
|
2799
|
+
}
|
2800
|
+
});
|
2801
|
+
|
1897
2802
|
}).call(this);
|
1898
2803
|
(function() {
|
1899
2804
|
|
1900
|
-
_.
|
2805
|
+
_.def('Luca.components.Controller')["extends"]('Luca.containers.CardView')["with"]({
|
1901
2806
|
initialize: function(options) {
|
1902
2807
|
var _ref;
|
1903
2808
|
this.options = options;
|
@@ -1935,70 +2840,7 @@
|
|
1935
2840
|
}).call(this);
|
1936
2841
|
(function() {
|
1937
2842
|
|
1938
|
-
_.
|
1939
|
-
name: "development_console",
|
1940
|
-
className: 'luca-ui-development-console',
|
1941
|
-
initialize: function(options) {
|
1942
|
-
this.options = options != null ? options : {};
|
1943
|
-
Luca.View.prototype.initialize.apply(this, arguments);
|
1944
|
-
if (this.modal) return this.$el.addClass('luca-ui-modal');
|
1945
|
-
},
|
1946
|
-
beforeRender: function() {
|
1947
|
-
this.$el.append(this.make("div", {
|
1948
|
-
"class": "console-inner"
|
1949
|
-
}));
|
1950
|
-
this.console_el = this.$('.console-inner');
|
1951
|
-
return this.console = this.console_el.console({
|
1952
|
-
promptLabel: "Coffee> ",
|
1953
|
-
animateScroll: true,
|
1954
|
-
promptHistory: true,
|
1955
|
-
autoFocus: true,
|
1956
|
-
commandValidate: function(line) {
|
1957
|
-
var valid;
|
1958
|
-
valid = true;
|
1959
|
-
if (line === "") valid = false;
|
1960
|
-
try {
|
1961
|
-
if (CoffeeScript.compile(line)) {
|
1962
|
-
valid = true;
|
1963
|
-
} else {
|
1964
|
-
valid = false;
|
1965
|
-
}
|
1966
|
-
} catch (error) {
|
1967
|
-
valid = false;
|
1968
|
-
}
|
1969
|
-
return valid;
|
1970
|
-
},
|
1971
|
-
returnValue: function(val) {
|
1972
|
-
if (val == null) return "undefined";
|
1973
|
-
return (val != null ? val.toString() : void 0) || "";
|
1974
|
-
},
|
1975
|
-
parseLine: function(line) {
|
1976
|
-
line = _.string.strip(line);
|
1977
|
-
line = line.replace(/^return/, ' ');
|
1978
|
-
return "return " + line;
|
1979
|
-
},
|
1980
|
-
commandHandle: function(line) {
|
1981
|
-
var compiled, ret;
|
1982
|
-
if (line === "") return;
|
1983
|
-
compiled = CoffeeScript.compile(this.parseLine(line));
|
1984
|
-
try {
|
1985
|
-
ret = eval(compiled);
|
1986
|
-
return this.returnValue(ret);
|
1987
|
-
} catch (error) {
|
1988
|
-
if (error.message.match(/circular structure to JSON/)) {
|
1989
|
-
return ret.toString();
|
1990
|
-
}
|
1991
|
-
return error.toString();
|
1992
|
-
}
|
1993
|
-
}
|
1994
|
-
});
|
1995
|
-
}
|
1996
|
-
});
|
1997
|
-
|
1998
|
-
}).call(this);
|
1999
|
-
(function() {
|
2000
|
-
|
2001
|
-
_.component('Luca.fields.ButtonField')["extends"]('Luca.core.Field')["with"]({
|
2843
|
+
_.def('Luca.fields.ButtonField')["extends"]('Luca.core.Field')["with"]({
|
2002
2844
|
readOnly: true,
|
2003
2845
|
events: {
|
2004
2846
|
"click input": "click_handler"
|
@@ -2041,7 +2883,7 @@
|
|
2041
2883
|
}).call(this);
|
2042
2884
|
(function() {
|
2043
2885
|
|
2044
|
-
_.
|
2886
|
+
_.def('Luca.fields.CheckboxArray')["extends"]('Luca.core.Field')["with"]({
|
2045
2887
|
template: "fields/checkbox_array",
|
2046
2888
|
events: {
|
2047
2889
|
"click input": "clickHandler"
|
@@ -2069,8 +2911,8 @@
|
|
2069
2911
|
return this.collection.bind("reset", this.populateCheckboxes);
|
2070
2912
|
},
|
2071
2913
|
afterRender: function() {
|
2072
|
-
var _ref
|
2073
|
-
if (((_ref = this.collection) != null ?
|
2914
|
+
var _ref;
|
2915
|
+
if (((_ref = this.collection) != null ? _ref.length : void 0) > 0) {
|
2074
2916
|
return this.populateCheckboxes();
|
2075
2917
|
} else {
|
2076
2918
|
return this.collection.trigger("reset");
|
@@ -2124,7 +2966,7 @@
|
|
2124
2966
|
}).call(this);
|
2125
2967
|
(function() {
|
2126
2968
|
|
2127
|
-
_.
|
2969
|
+
_.def('Luca.fields.CheckboxField')["extends"]('Luca.core.Field')["with"]({
|
2128
2970
|
events: {
|
2129
2971
|
"change input": "change_handler"
|
2130
2972
|
},
|
@@ -2141,6 +2983,7 @@
|
|
2141
2983
|
className: 'luca-ui-checkbox-field luca-ui-field',
|
2142
2984
|
template: 'fields/checkbox_field',
|
2143
2985
|
hooks: ["checked", "unchecked"],
|
2986
|
+
send_blanks: true,
|
2144
2987
|
initialize: function(options) {
|
2145
2988
|
this.options = options != null ? options : {};
|
2146
2989
|
_.extend(this, this.options);
|
@@ -2164,7 +3007,7 @@
|
|
2164
3007
|
}).call(this);
|
2165
3008
|
(function() {
|
2166
3009
|
|
2167
|
-
_.
|
3010
|
+
_.def('Luca.fields.FileUploadField')["extends"]('Luca.core.Field')["with"]({
|
2168
3011
|
template: 'fields/file_upload_field',
|
2169
3012
|
initialize: function(options) {
|
2170
3013
|
this.options = options != null ? options : {};
|
@@ -2181,7 +3024,7 @@
|
|
2181
3024
|
}).call(this);
|
2182
3025
|
(function() {
|
2183
3026
|
|
2184
|
-
_.
|
3027
|
+
_.def('Luca.fields.HiddenField')["extends"]('Luca.core.Field')["with"]({
|
2185
3028
|
template: 'fields/hidden_field',
|
2186
3029
|
initialize: function(options) {
|
2187
3030
|
this.options = options != null ? options : {};
|
@@ -2198,7 +3041,7 @@
|
|
2198
3041
|
}).call(this);
|
2199
3042
|
(function() {
|
2200
3043
|
|
2201
|
-
_.
|
3044
|
+
_.def('Luca.fields.SelectField')["extends"]('Luca.core.Field')["with"]({
|
2202
3045
|
events: {
|
2203
3046
|
"change select": "change_handler"
|
2204
3047
|
},
|
@@ -2292,7 +3135,7 @@
|
|
2292
3135
|
}).call(this);
|
2293
3136
|
(function() {
|
2294
3137
|
|
2295
|
-
_.
|
3138
|
+
_.def('Luca.fields.TextAreaField')["extends"]('Luca.core.Field')["with"]({
|
2296
3139
|
events: {
|
2297
3140
|
"keydown input": "keydown_handler",
|
2298
3141
|
"blur input": "blur_handler",
|
@@ -2336,18 +3179,23 @@
|
|
2336
3179
|
|
2337
3180
|
}).call(this);
|
2338
3181
|
(function() {
|
3182
|
+
var change_handler;
|
3183
|
+
|
3184
|
+
change_handler = function(e) {
|
3185
|
+
return this.trigger("on:change", this, e);
|
3186
|
+
};
|
2339
3187
|
|
2340
|
-
_.
|
3188
|
+
_.def('Luca.fields.TextField')["extends"]('Luca.core.Field')["with"]({
|
2341
3189
|
events: {
|
2342
|
-
"keydown input": "keydown_handler",
|
2343
3190
|
"blur input": "blur_handler",
|
2344
3191
|
"focus input": "focus_handler",
|
2345
3192
|
"change input": "change_handler"
|
2346
3193
|
},
|
2347
3194
|
template: 'fields/text_field',
|
3195
|
+
autoBindEventHandlers: true,
|
3196
|
+
send_blanks: true,
|
2348
3197
|
initialize: function(options) {
|
2349
3198
|
this.options = options != null ? options : {};
|
2350
|
-
_.bindAll(this, "keydown_handler", "blur_handler", "focus_handler");
|
2351
3199
|
Luca.core.Field.prototype.initialize.apply(this, arguments);
|
2352
3200
|
this.input_id || (this.input_id = _.uniqueId('field'));
|
2353
3201
|
this.input_name || (this.input_name = this.name);
|
@@ -2359,12 +3207,12 @@
|
|
2359
3207
|
}
|
2360
3208
|
if (this.append) {
|
2361
3209
|
this.$el.addClass('input-append');
|
2362
|
-
|
3210
|
+
this.addOn = this.append;
|
3211
|
+
}
|
3212
|
+
if (this.enableKeyEvents) {
|
3213
|
+
return this.registerEvent("keydown input", "keydown_handler");
|
2363
3214
|
}
|
2364
3215
|
},
|
2365
|
-
keydown_handler: _.throttle((function(e) {
|
2366
|
-
return this.change_handler.apply(this, arguments);
|
2367
|
-
}), 300),
|
2368
3216
|
blur_handler: function(e) {
|
2369
3217
|
var me, my;
|
2370
3218
|
return me = my = $(e.currentTarget);
|
@@ -2373,27 +3221,40 @@
|
|
2373
3221
|
var me, my;
|
2374
3222
|
return me = my = $(e.currentTarget);
|
2375
3223
|
},
|
2376
|
-
change_handler:
|
2377
|
-
|
2378
|
-
|
3224
|
+
change_handler: change_handler,
|
3225
|
+
keydown_handler: _.throttle((function(e) {
|
3226
|
+
return change_handler.apply(this, arguments);
|
3227
|
+
}), 300)
|
2379
3228
|
});
|
2380
3229
|
|
2381
3230
|
}).call(this);
|
2382
3231
|
(function() {
|
2383
3232
|
|
2384
|
-
_.
|
3233
|
+
_.def('Luca.fields.TypeAheadField')["extends"]('Luca.fields.TextField')["with"]({
|
2385
3234
|
className: 'luca-ui-field',
|
2386
|
-
|
2387
|
-
this.
|
2388
|
-
|
2389
|
-
|
3235
|
+
getSource: function() {
|
3236
|
+
return this.source || [];
|
3237
|
+
},
|
3238
|
+
matcher: function(item) {
|
3239
|
+
return true;
|
3240
|
+
},
|
3241
|
+
beforeRender: function() {
|
3242
|
+
this._super("beforeRender", this, arguments);
|
3243
|
+
return this.$('input').attr('data-provide', 'typeahead');
|
3244
|
+
},
|
3245
|
+
afterRender: function() {
|
3246
|
+
this._super("afterRender", this, arguments);
|
3247
|
+
return this.$('input').typeahead({
|
3248
|
+
matcher: this.matcher,
|
3249
|
+
source: this.getSource()
|
3250
|
+
});
|
2390
3251
|
}
|
2391
3252
|
});
|
2392
3253
|
|
2393
3254
|
}).call(this);
|
2394
3255
|
(function() {
|
2395
3256
|
|
2396
|
-
_.
|
3257
|
+
_.def('Luca.components.FormButtonToolbar')["extends"]('Luca.components.Toolbar')["with"]({
|
2397
3258
|
className: 'luca-ui-form-toolbar form-actions',
|
2398
3259
|
position: 'bottom',
|
2399
3260
|
includeReset: false,
|
@@ -2423,7 +3284,7 @@
|
|
2423
3284
|
}).call(this);
|
2424
3285
|
(function() {
|
2425
3286
|
|
2426
|
-
_.
|
3287
|
+
_.def("Luca.components.FormView")["extends"]('Luca.core.Container')["with"]({
|
2427
3288
|
tagName: 'form',
|
2428
3289
|
className: 'luca-ui-form-view',
|
2429
3290
|
hooks: ["before:submit", "before:reset", "before:load", "before:load:new", "before:load:existing", "after:submit", "after:reset", "after:load", "after:load:new", "after:load:existing", "after:submit:success", "after:submit:fatal_error", "after:submit:error"],
|
@@ -2432,54 +3293,51 @@
|
|
2432
3293
|
"click .reset-button": "resetHandler"
|
2433
3294
|
},
|
2434
3295
|
toolbar: true,
|
3296
|
+
legend: "",
|
3297
|
+
bodyClassName: "form-view-body",
|
3298
|
+
bodyTemplate: ["components/form_view"],
|
2435
3299
|
initialize: function(options) {
|
2436
3300
|
this.options = options != null ? options : {};
|
3301
|
+
if (this.loadMask == null) this.loadMask = Luca.enableBootstrap;
|
2437
3302
|
Luca.core.Container.prototype.initialize.apply(this, arguments);
|
2438
|
-
_.bindAll(this, "submitHandler", "resetHandler", "renderToolbars");
|
3303
|
+
_.bindAll(this, "submitHandler", "resetHandler", "renderToolbars", "applyLoadMask");
|
2439
3304
|
this.state || (this.state = new Backbone.Model);
|
2440
3305
|
this.setupHooks(this.hooks);
|
2441
|
-
this.
|
2442
|
-
this.
|
2443
|
-
|
2444
|
-
|
2445
|
-
|
2446
|
-
|
2447
|
-
|
2448
|
-
|
2449
|
-
|
2450
|
-
|
2451
|
-
|
2452
|
-
|
3306
|
+
this.applyStyleClasses();
|
3307
|
+
if (this.toolbar === true && !((this.bottomToolbar != null) || (this.topToolbar != null))) {
|
3308
|
+
return this.bottomToolbar = {
|
3309
|
+
buttons: [
|
3310
|
+
{
|
3311
|
+
icon: "remove-sign",
|
3312
|
+
label: "Reset",
|
3313
|
+
eventId: "click:reset",
|
3314
|
+
className: "reset-button",
|
3315
|
+
align: 'right'
|
3316
|
+
}, {
|
3317
|
+
icon: "ok-sign",
|
3318
|
+
white: true,
|
3319
|
+
label: "Save Changes",
|
3320
|
+
eventId: "click:submit",
|
3321
|
+
color: "success",
|
3322
|
+
className: 'submit-button',
|
3323
|
+
align: 'right'
|
3324
|
+
}
|
3325
|
+
]
|
3326
|
+
};
|
3327
|
+
}
|
2453
3328
|
},
|
2454
|
-
|
2455
|
-
if (Luca.enableBootstrap) this.
|
3329
|
+
applyStyleClasses: function() {
|
3330
|
+
if (Luca.enableBootstrap) this.applyBootstrapStyleClasses();
|
2456
3331
|
if (this.labelAlign) this.$el.addClass("label-align-" + this.labelAlign);
|
2457
3332
|
if (this.fieldLayoutClass) return this.$el.addClass(this.fieldLayoutClass);
|
2458
3333
|
},
|
2459
|
-
|
3334
|
+
applyBootstrapStyleClasses: function() {
|
2460
3335
|
if (this.labelAlign === "left") this.inlineForm = true;
|
2461
3336
|
if (this.well) this.$el.addClass('well');
|
2462
3337
|
if (this.searchForm) this.$el.addClass('form-search');
|
2463
3338
|
if (this.horizontalForm) this.$el.addClass('form-horizontal');
|
2464
3339
|
if (this.inlineForm) return this.$el.addClass('form-inline');
|
2465
3340
|
},
|
2466
|
-
configureToolbars: function() {
|
2467
|
-
if (Luca.enableBootstrap && this.toolbar === true) {
|
2468
|
-
return this.addBootstrapFormControls();
|
2469
|
-
}
|
2470
|
-
if (this.toolbar === true) {
|
2471
|
-
this.toolbars = [
|
2472
|
-
{
|
2473
|
-
ctype: 'form_button_toolbar',
|
2474
|
-
includeReset: true,
|
2475
|
-
position: 'bottom'
|
2476
|
-
}
|
2477
|
-
];
|
2478
|
-
}
|
2479
|
-
if (this.toolbars && this.toolbars.length) {
|
2480
|
-
return this.bind("after:render", _.once(this.renderToolbars));
|
2481
|
-
}
|
2482
|
-
},
|
2483
3341
|
resetHandler: function(e) {
|
2484
3342
|
var me, my;
|
2485
3343
|
me = my = $(e.currentTarget);
|
@@ -2491,21 +3349,8 @@
|
|
2491
3349
|
var me, my;
|
2492
3350
|
me = my = $(e.currentTarget);
|
2493
3351
|
this.trigger("before:submit", this);
|
2494
|
-
|
2495
|
-
|
2496
|
-
beforeLayout: function() {
|
2497
|
-
var _ref;
|
2498
|
-
if ((_ref = Luca.core.Container.prototype.beforeLayout) != null) {
|
2499
|
-
_ref.apply(this, arguments);
|
2500
|
-
}
|
2501
|
-
return this.$el.html(Luca.templates["components/form_view"](this));
|
2502
|
-
},
|
2503
|
-
prepareComponents: function() {
|
2504
|
-
var container;
|
2505
|
-
container = $('.form-view-body', this.el);
|
2506
|
-
return _(this.components).each(function(component) {
|
2507
|
-
return component.container = container;
|
2508
|
-
});
|
3352
|
+
if (this.loadMask === true) this.trigger("enable:loadmask", this);
|
3353
|
+
if (this.hasModel()) return this.submit();
|
2509
3354
|
},
|
2510
3355
|
afterComponents: function() {
|
2511
3356
|
var _ref,
|
@@ -2522,25 +3367,6 @@
|
|
2522
3367
|
};
|
2523
3368
|
});
|
2524
3369
|
},
|
2525
|
-
render: function() {
|
2526
|
-
$(this.container).append(this.$el);
|
2527
|
-
return this;
|
2528
|
-
},
|
2529
|
-
wrapper: function() {
|
2530
|
-
return this.$el.parents('.luca-ui-form-view-wrapper');
|
2531
|
-
},
|
2532
|
-
toolbarContainers: function(position) {
|
2533
|
-
if (position == null) position = "bottom";
|
2534
|
-
return $(".toolbar-container." + position, this.wrapper()).first();
|
2535
|
-
},
|
2536
|
-
renderToolbars: function() {
|
2537
|
-
var _this = this;
|
2538
|
-
return _(this.toolbars).each(function(toolbar) {
|
2539
|
-
toolbar.container = $("#" + _this.cid + "-" + toolbar.position + "-toolbar-container");
|
2540
|
-
toolbar = Luca.util.lazyComponent(toolbar);
|
2541
|
-
return toolbar.render();
|
2542
|
-
});
|
2543
|
-
},
|
2544
3370
|
eachField: function(iterator) {
|
2545
3371
|
return _(this.getFields()).map(iterator);
|
2546
3372
|
},
|
@@ -2550,15 +3376,12 @@
|
|
2550
3376
|
getFields: function(attr, value) {
|
2551
3377
|
var fields;
|
2552
3378
|
fields = this.select("isField", true, true);
|
2553
|
-
if (
|
2554
|
-
|
2555
|
-
|
2556
|
-
|
2557
|
-
|
2558
|
-
|
2559
|
-
return value === propvalue;
|
2560
|
-
});
|
2561
|
-
}
|
3379
|
+
if (!(attr && value)) return fields;
|
3380
|
+
_(fields).select(function(field) {
|
3381
|
+
var property;
|
3382
|
+
property = field[attr];
|
3383
|
+
return (property != null) && value === (_.isFunction(property) ? property() : property);
|
3384
|
+
});
|
2562
3385
|
return fields;
|
2563
3386
|
},
|
2564
3387
|
loadModel: function(current_model) {
|
@@ -2633,6 +3456,7 @@
|
|
2633
3456
|
},
|
2634
3457
|
submit_success_handler: function(model, response, xhr) {
|
2635
3458
|
this.trigger("after:submit", this, model, response);
|
3459
|
+
if (this.loadMask === true) this.trigger("disable:loadmask", this);
|
2636
3460
|
if (response && (response != null ? response.success : void 0) === true) {
|
2637
3461
|
return this.trigger("after:submit:success", this, model, response);
|
2638
3462
|
} else {
|
@@ -2653,6 +3477,9 @@
|
|
2653
3477
|
if (!save) return;
|
2654
3478
|
return this.current_model.save(this.current_model.toJSON(), saveOptions);
|
2655
3479
|
},
|
3480
|
+
hasModel: function() {
|
3481
|
+
return this.current_model != null;
|
3482
|
+
},
|
2656
3483
|
currentModel: function(options) {
|
2657
3484
|
if (options == null) options = {};
|
2658
3485
|
if (options === true || (options != null ? options.refresh : void 0) === true) {
|
@@ -2673,7 +3500,8 @@
|
|
2673
3500
|
}).call(this);
|
2674
3501
|
(function() {
|
2675
3502
|
|
2676
|
-
_.
|
3503
|
+
_.def('Luca.components.GridView').extend('Luca.components.Panel')["with"]({
|
3504
|
+
bodyTemplate: "components/grid_view",
|
2677
3505
|
autoBindEventHandlers: true,
|
2678
3506
|
events: {
|
2679
3507
|
"dblclick table tbody tr": "double_click_handler",
|
@@ -2696,14 +3524,25 @@
|
|
2696
3524
|
this.options = options != null ? options : {};
|
2697
3525
|
_.extend(this, this.options);
|
2698
3526
|
_.extend(this, Luca.modules.Deferrable);
|
2699
|
-
|
2700
|
-
this.
|
3527
|
+
if (this.loadMask == null) this.loadMask = Luca.enableBootstrap;
|
3528
|
+
if (this.loadMask === true) {
|
3529
|
+
this.loadMaskEl || (this.loadMaskEl = ".luca-ui-g-view-body");
|
3530
|
+
}
|
3531
|
+
Luca.components.Panel.prototype.initialize.apply(this, arguments);
|
3532
|
+
this.configure_collection(true);
|
3533
|
+
this.collection.bind("before:fetch", function() {
|
3534
|
+
console.log("Triggering Enable Load Mask");
|
3535
|
+
if (_this.loadMask === true) return _this.trigger("enable:loadmask");
|
3536
|
+
});
|
2701
3537
|
this.collection.bind("reset", function(collection) {
|
2702
3538
|
_this.refresh();
|
3539
|
+
console.log("Triggering Disable LoadMask");
|
3540
|
+
if (_this.loadMask === true) _this.trigger("disable:loadmask");
|
2703
3541
|
return _this.trigger("after:collection:load", collection);
|
2704
3542
|
});
|
2705
3543
|
return this.collection.bind("change", function(model) {
|
2706
3544
|
var cells, rowEl;
|
3545
|
+
if (_this.rendered !== true) return;
|
2707
3546
|
try {
|
2708
3547
|
rowEl = _this.getRowEl(model.id || model.get('id') || model.cid);
|
2709
3548
|
cells = _this.render_row(model, _this.collection.indexOf(model), {
|
@@ -2711,13 +3550,16 @@
|
|
2711
3550
|
});
|
2712
3551
|
return $(rowEl).html(cells);
|
2713
3552
|
} catch (error) {
|
2714
|
-
return console.log("Error in change handler for GridView.collection", error, _this);
|
3553
|
+
return console.log("Error in change handler for GridView.collection", error, _this, model, rowEl, cells);
|
2715
3554
|
}
|
2716
3555
|
});
|
2717
3556
|
},
|
2718
3557
|
beforeRender: function() {
|
3558
|
+
var _ref;
|
3559
|
+
if ((_ref = Luca.components.Panel.prototype.beforeRender) != null) {
|
3560
|
+
_ref.apply(this, arguments);
|
3561
|
+
}
|
2719
3562
|
this.trigger("before:grid:render", this);
|
2720
|
-
this.$el.html(Luca.templates["components/grid_view"]());
|
2721
3563
|
this.table = this.$('table.luca-ui-g-view');
|
2722
3564
|
this.header = this.$("thead");
|
2723
3565
|
this.body = this.$("tbody");
|
@@ -2727,9 +3569,17 @@
|
|
2727
3569
|
if (this.scrollable) this.setDimensions();
|
2728
3570
|
this.renderHeader();
|
2729
3571
|
this.emptyMessage();
|
2730
|
-
this.renderToolbars();
|
2731
3572
|
return $(this.container).append(this.$el);
|
2732
3573
|
},
|
3574
|
+
afterRender: function() {
|
3575
|
+
var _ref;
|
3576
|
+
if ((_ref = Luca.components.Panel.prototype.afterRender) != null) {
|
3577
|
+
_ref.apply(this, arguments);
|
3578
|
+
}
|
3579
|
+
this.rendered = true;
|
3580
|
+
this.refresh();
|
3581
|
+
return this.trigger("after:grid:render", this);
|
3582
|
+
},
|
2733
3583
|
applyCssClasses: function() {
|
2734
3584
|
var _ref,
|
2735
3585
|
_this = this;
|
@@ -2743,18 +3593,6 @@
|
|
2743
3593
|
return _this.table.addClass("table-" + style);
|
2744
3594
|
});
|
2745
3595
|
},
|
2746
|
-
toolbarContainers: function(position) {
|
2747
|
-
if (position == null) position = "bottom";
|
2748
|
-
return $(".toolbar-container." + position, this.el);
|
2749
|
-
},
|
2750
|
-
renderToolbars: function() {
|
2751
|
-
var _this = this;
|
2752
|
-
return _(this.toolbars).each(function(toolbar) {
|
2753
|
-
toolbar = Luca.util.lazyComponent(toolbar);
|
2754
|
-
toolbar.container = _this.toolbarContainers(toolbar.position);
|
2755
|
-
return toolbar.render();
|
2756
|
-
});
|
2757
|
-
},
|
2758
3596
|
setDimensions: function(offset) {
|
2759
3597
|
var _this = this;
|
2760
3598
|
this.height || (this.height = this.defaultHeight);
|
@@ -2804,10 +3642,6 @@
|
|
2804
3642
|
lastColumn: function() {
|
2805
3643
|
return this.columns[this.columns.length - 1];
|
2806
3644
|
},
|
2807
|
-
afterRender: function() {
|
2808
|
-
this.refresh();
|
2809
|
-
return this.trigger("after:grid:render", this);
|
2810
|
-
},
|
2811
3645
|
emptyMessage: function(text) {
|
2812
3646
|
if (text == null) text = "";
|
2813
3647
|
text || (text = this.emptyText);
|
@@ -2910,7 +3744,43 @@
|
|
2910
3744
|
}).call(this);
|
2911
3745
|
(function() {
|
2912
3746
|
|
2913
|
-
_.
|
3747
|
+
_.def("Luca.components.LoadMask")["extends"]("Luca.View")["with"]({
|
3748
|
+
className: "luca-ui-load-mask",
|
3749
|
+
bodyTemplate: "components/load_mask"
|
3750
|
+
});
|
3751
|
+
|
3752
|
+
}).call(this);
|
3753
|
+
(function() {
|
3754
|
+
|
3755
|
+
_.def("Luca.components.NavBar")["extends"]("Luca.View")["with"]({
|
3756
|
+
fixed: true,
|
3757
|
+
position: 'top',
|
3758
|
+
className: 'navbar',
|
3759
|
+
initialize: function(options) {
|
3760
|
+
this.options = options != null ? options : {};
|
3761
|
+
return Luca.View.prototype.initialize.apply(this, arguments);
|
3762
|
+
},
|
3763
|
+
brand: "Luca.js",
|
3764
|
+
bodyTemplate: 'nav_bar',
|
3765
|
+
bodyClassName: 'luca-ui-navbar-body',
|
3766
|
+
beforeRender: function() {
|
3767
|
+
if (this.fixed) this.$el.addClass("navbar-fixed-" + this.position);
|
3768
|
+
if (this.brand != null) {
|
3769
|
+
return this.content().append("<a class='brand' href='#'>" + this.brand + "</a>");
|
3770
|
+
}
|
3771
|
+
},
|
3772
|
+
render: function() {
|
3773
|
+
return this;
|
3774
|
+
},
|
3775
|
+
content: function() {
|
3776
|
+
return this.$('.container').eq(0);
|
3777
|
+
}
|
3778
|
+
});
|
3779
|
+
|
3780
|
+
}).call(this);
|
3781
|
+
(function() {
|
3782
|
+
|
3783
|
+
_.def('Luca.components.RecordManager')["extends"]('Luca.containers.CardView')["with"]({
|
2914
3784
|
events: {
|
2915
3785
|
"click .record-manager-grid .edit-link": "edit_handler",
|
2916
3786
|
"click .record-manager-filter .filter-button": "filter_handler",
|
@@ -3117,7 +3987,7 @@
|
|
3117
3987
|
}).call(this);
|
3118
3988
|
(function() {
|
3119
3989
|
|
3120
|
-
Luca.Router
|
3990
|
+
_.def("Luca.Router")["extends"]("Backbone.Router")["with"]({
|
3121
3991
|
routes: {
|
3122
3992
|
"": "default"
|
3123
3993
|
},
|
@@ -3153,6 +4023,43 @@
|
|
3153
4023
|
}).call(this);
|
3154
4024
|
(function() {
|
3155
4025
|
|
4026
|
+
_.def("Luca.components.ToolbarDialog")["extends"]("Luca.View")["with"]({
|
4027
|
+
className: "luca-ui-toolbar-dialog span well",
|
4028
|
+
styles: {
|
4029
|
+
"position": "absolute",
|
4030
|
+
"z-Index": "3000",
|
4031
|
+
"float": "left"
|
4032
|
+
},
|
4033
|
+
initialize: function(options) {
|
4034
|
+
this.options = options != null ? options : {};
|
4035
|
+
return this._super("initialize", this, arguments);
|
4036
|
+
},
|
4037
|
+
createWrapper: function() {
|
4038
|
+
return this.make("div", {
|
4039
|
+
"class": "component-picker span4 well",
|
4040
|
+
style: "position: absolute; z-index:12000"
|
4041
|
+
});
|
4042
|
+
},
|
4043
|
+
show: function() {
|
4044
|
+
return this.$el.parent().show();
|
4045
|
+
},
|
4046
|
+
hide: function() {
|
4047
|
+
return this.$el.parent().hide();
|
4048
|
+
},
|
4049
|
+
toggle: function() {
|
4050
|
+
return this.$el.parent().toggle();
|
4051
|
+
}
|
4052
|
+
});
|
4053
|
+
|
4054
|
+
}).call(this);
|
4055
|
+
(function() {
|
4056
|
+
|
4057
|
+
_.extend(Luca, Luca.Events);
|
4058
|
+
|
4059
|
+
_.extend(Luca.View.prototype, Luca.Events);
|
4060
|
+
|
4061
|
+
_.extend(Luca.Collection.prototype, Luca.Events);
|
3156
4062
|
|
4063
|
+
_.extend(Luca.Model.prototype, Luca.Events);
|
3157
4064
|
|
3158
4065
|
}).call(this);
|