luca 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +77 -0
- data/Guardfile +22 -0
- data/README.md +291 -0
- data/Rakefile +28 -0
- data/app.rb +46 -0
- data/assets/images/glyphicons-halflings-white.png +0 -0
- data/assets/images/glyphicons-halflings.png +0 -0
- data/assets/javascripts/dependencies/backbone-min.js +37 -0
- data/assets/javascripts/dependencies/backbone-query.min.js +1 -0
- data/assets/javascripts/dependencies/bootstrap.min.js +1 -0
- data/assets/javascripts/dependencies/jasmine-html.js +190 -0
- data/assets/javascripts/dependencies/jasmine.js +2476 -0
- data/assets/javascripts/dependencies/jquery.js +4 -0
- data/assets/javascripts/dependencies/modal.js +698 -0
- data/assets/javascripts/dependencies/modernizr.min.js +30 -0
- data/assets/javascripts/dependencies/prettify.js +28 -0
- data/assets/javascripts/dependencies/sinon.js +3469 -0
- data/assets/javascripts/dependencies/spin-min.js +2 -0
- data/assets/javascripts/dependencies/underscore-min.js +31 -0
- data/assets/javascripts/dependencies/underscore-string.min.js +14 -0
- data/assets/javascripts/dependencies.coffee +7 -0
- data/assets/javascripts/luca-ui-base.coffee +12 -0
- data/assets/javascripts/luca-ui-spec.coffee +2 -0
- data/assets/javascripts/luca-ui.coffee +3 -0
- data/assets/javascripts/sandbox/collections/sample.coffee +0 -0
- data/assets/javascripts/sandbox/config.coffee +7 -0
- data/assets/javascripts/sandbox/sandbox.coffee +16 -0
- data/assets/javascripts/sandbox/templates/features/collection_helpers.luca +33 -0
- data/assets/javascripts/sandbox/templates/features/form_demo_code.luca +48 -0
- data/assets/javascripts/sandbox/templates/features/grid_demo_code.luca +24 -0
- data/assets/javascripts/sandbox/templates/features/introduction.luca +11 -0
- data/assets/javascripts/sandbox/templates/features/view_helpers.luca +43 -0
- data/assets/javascripts/sandbox/templates/navigation.luca +8 -0
- data/assets/javascripts/sandbox/views/form_demo.coffee +47 -0
- data/assets/javascripts/sandbox/views/grid_demo.coffee +23 -0
- data/assets/javascripts/sandbox/views/pages/collection_events_sample.coffee +1 -0
- data/assets/javascripts/sandbox/views/pages/pages_controller.coffee +28 -0
- data/assets/javascripts/sandbox.coffee +4 -0
- data/assets/javascripts/spec-dependencies.coffee +4 -0
- data/assets/stylesheets/bootstrap-responsive.min.css +3 -0
- data/assets/stylesheets/bootstrap.min.css +610 -0
- data/assets/stylesheets/jasmine.css +166 -0
- data/assets/stylesheets/luca-ui-bootstrap.css +5 -0
- data/assets/stylesheets/luca-ui-spec.css +3 -0
- data/assets/stylesheets/luca-ui.css +3 -0
- data/assets/stylesheets/prettify.css +40 -0
- data/assets/stylesheets/sandbox/sandbox.scss +4 -0
- data/assets/stylesheets/sandbox.css +3 -0
- data/config.ru +11 -0
- data/lib/luca/command_line.rb +69 -0
- data/lib/luca/rails/engine.rb +12 -0
- data/lib/luca/rails/version.rb +6 -0
- data/lib/luca/rails.rb +9 -0
- data/lib/luca/template.rb +51 -0
- data/lib/luca/test_harness.rb +106 -0
- data/lib/luca.rb +1 -0
- data/lib/sprockets/luca_template.rb +49 -0
- data/lib/templates/spec_manifest_javascripts.erb +7 -0
- data/lib/templates/spec_manifest_stylesheets.erb +11 -0
- data/luca.gemspec +26 -0
- data/public/jasmine/index.html +26 -0
- data/public/sandbox/api.js +1 -0
- data/spec/components/application_spec.coffee +0 -0
- data/spec/components/collection_loader_view_spec.coffee +0 -0
- data/spec/components/controller_spec.coffee +0 -0
- data/spec/components/form_view_spec.coffee +13 -0
- data/spec/components/grid_view_spec.coffee +0 -0
- data/spec/components/record_manager_spec.coffee +0 -0
- data/spec/components/template_spec.coffee +0 -0
- data/spec/containers/card_view_spec.coffee +1 -0
- data/spec/containers/column_view_spec.coffee +0 -0
- data/spec/containers/modal_view_spec.coffee +0 -0
- data/spec/containers/panel_view_spec.coffee +0 -0
- data/spec/containers/split_view_spec.coffee +0 -0
- data/spec/containers/tab_view_spec.coffee +0 -0
- data/spec/containers/viewport_spec.coffee +0 -0
- data/spec/core/collection_spec.coffee +215 -0
- data/spec/core/container_spec.coffee +0 -0
- data/spec/core/field_spec.coffee +0 -0
- data/spec/core/observer_spec.coffee +0 -0
- data/spec/core/view_spec.coffee +87 -0
- data/spec/framework_spec.coffee +48 -0
- data/spec/helper.coffee +120 -0
- data/spec/managers/collection_manager_spec.coffee +95 -0
- data/spec/managers/socket_manager_spec.coffee +0 -0
- data/src/components/application.coffee +83 -0
- data/src/components/base_toolbar.coffee +16 -0
- data/src/components/collection_loader_view.coffee +37 -0
- data/src/components/controller.coffee +41 -0
- data/src/components/fields/button_field.coffee +40 -0
- data/src/components/fields/checkbox_field.coffee +41 -0
- data/src/components/fields/file_upload_field.coffee +15 -0
- data/src/components/fields/hidden_field.coffee +18 -0
- data/src/components/fields/select_field.coffee +100 -0
- data/src/components/fields/text_area_field.coffee +43 -0
- data/src/components/fields/text_field.coffee +42 -0
- data/src/components/fields/type_ahead_field.coffee +10 -0
- data/src/components/form_button_toolbar.coffee +26 -0
- data/src/components/form_view.coffee +205 -0
- data/src/components/grid_view.coffee +208 -0
- data/src/components/record_manager.coffee +215 -0
- data/src/components/router.coffee +34 -0
- data/src/components/template.coffee +19 -0
- data/src/containers/card_view.coffee +89 -0
- data/src/containers/column_view.coffee +48 -0
- data/src/containers/modal_view.coffee +85 -0
- data/src/containers/panel_view.coffee +24 -0
- data/src/containers/split_view.coffee +12 -0
- data/src/containers/tab_view.coffee +77 -0
- data/src/containers/viewport.coffee +16 -0
- data/src/core/collection.coffee +319 -0
- data/src/core/container.coffee +256 -0
- data/src/core/field.coffee +68 -0
- data/src/core/observer.coffee +17 -0
- data/src/core/view.coffee +190 -0
- data/src/framework.coffee +110 -0
- data/src/index.coffee +255 -0
- data/src/managers/collection_manager.coffee +168 -0
- data/src/managers/socket_manager.coffee +54 -0
- data/src/modules/deferrable.coffee +18 -0
- data/src/modules/local_storage.coffee +50 -0
- data/src/stylesheets/base.scss +78 -0
- data/src/stylesheets/components/form_view.scss +54 -0
- data/src/stylesheets/components/grid_view.scss +111 -0
- data/src/stylesheets/components/toolbar.scss +15 -0
- data/src/stylesheets/containers/container.scss +7 -0
- data/src/stylesheets/containers/modal_view.scss +0 -0
- data/src/stylesheets/containers/tab_view.scss +33 -0
- data/src/stylesheets/normalize.scss +430 -0
- data/src/templates/components/bootstrap_form_controls.luca +7 -0
- data/src/templates/components/collection_loader_view.luca +5 -0
- data/src/templates/components/form_view.luca +15 -0
- data/src/templates/components/grid_view.luca +9 -0
- data/src/templates/components/grid_view_empty_text.luca +3 -0
- data/src/templates/containers/basic.luca +1 -0
- data/src/templates/containers/tab_selector_container.luca +8 -0
- data/src/templates/containers/tab_view.luca +1 -0
- data/src/templates/containers/toolbar_wrapper.luca +1 -0
- data/src/templates/fields/button_field.luca +2 -0
- data/src/templates/fields/button_field_link.luca +5 -0
- data/src/templates/fields/checkbox_field.luca +9 -0
- data/src/templates/fields/file_upload_field.luca +8 -0
- data/src/templates/fields/hidden_field.luca +1 -0
- data/src/templates/fields/select_field.luca +7 -0
- data/src/templates/fields/text_area_field.luca +8 -0
- data/src/templates/fields/text_field.luca +13 -0
- data/src/templates/sample/contents.luca +1 -0
- data/src/templates/sample/welcome.luca +1 -0
- data/vendor/assets/images/glyphicons-halflings-white.png +0 -0
- data/vendor/assets/images/glyphicons-halflings.png +0 -0
- data/vendor/assets/javascripts/luca-spec-dependencies.js +6135 -0
- data/vendor/assets/javascripts/luca-ui-base.js +1527 -0
- data/vendor/assets/javascripts/luca-ui-spec.js +3654 -0
- data/vendor/assets/javascripts/luca-ui.js +2763 -0
- data/vendor/assets/luca-ui/base.css +85 -0
- data/vendor/assets/luca-ui/components/application.js +91 -0
- data/vendor/assets/luca-ui/components/base_toolbar.js +23 -0
- data/vendor/assets/luca-ui/components/controller.js +38 -0
- data/vendor/assets/luca-ui/components/fields/button_field.js +45 -0
- data/vendor/assets/luca-ui/components/fields/checkbox_field.js +43 -0
- data/vendor/assets/luca-ui/components/fields/file_upload_field.js +20 -0
- data/vendor/assets/luca-ui/components/fields/hidden_field.js +20 -0
- data/vendor/assets/luca-ui/components/fields/select_field.js +97 -0
- data/vendor/assets/luca-ui/components/fields/text_area_field.js +48 -0
- data/vendor/assets/luca-ui/components/fields/text_field.js +46 -0
- data/vendor/assets/luca-ui/components/fields/type_ahead_field.js +13 -0
- data/vendor/assets/luca-ui/components/form_button_toolbar.js +32 -0
- data/vendor/assets/luca-ui/components/form_view.css +32 -0
- data/vendor/assets/luca-ui/components/form_view.js +207 -0
- data/vendor/assets/luca-ui/components/grid_view.css +76 -0
- data/vendor/assets/luca-ui/components/grid_view.js +202 -0
- data/vendor/assets/luca-ui/components/record_manager.js +207 -0
- data/vendor/assets/luca-ui/components/router.js +36 -0
- data/vendor/assets/luca-ui/components/template.js +26 -0
- data/vendor/assets/luca-ui/components/toolbar.css +11 -0
- data/vendor/assets/luca-ui/containers/card_view.js +98 -0
- data/vendor/assets/luca-ui/containers/column_view.js +52 -0
- data/vendor/assets/luca-ui/containers/container.css +3 -0
- data/vendor/assets/luca-ui/containers/modal_view.css +0 -0
- data/vendor/assets/luca-ui/containers/modal_view.js +87 -0
- data/vendor/assets/luca-ui/containers/panel_view.js +34 -0
- data/vendor/assets/luca-ui/containers/split_view.js +13 -0
- data/vendor/assets/luca-ui/containers/tab_view.css +16 -0
- data/vendor/assets/luca-ui/containers/tab_view.js +80 -0
- data/vendor/assets/luca-ui/containers/viewport.js +18 -0
- data/vendor/assets/luca-ui/core/collection.js +221 -0
- data/vendor/assets/luca-ui/core/container.js +205 -0
- data/vendor/assets/luca-ui/core/field.js +59 -0
- data/vendor/assets/luca-ui/core/observer.js +42 -0
- data/vendor/assets/luca-ui/core/view.js +127 -0
- data/vendor/assets/luca-ui/framework.js +110 -0
- data/vendor/assets/luca-ui/index.js +5 -0
- data/vendor/assets/luca-ui/managers/collection_manager.js +98 -0
- data/vendor/assets/luca-ui/managers/socket_manager.js +52 -0
- data/vendor/assets/luca-ui/modules/deferrable.js +21 -0
- data/vendor/assets/luca-ui/modules/local_storage.js +81 -0
- data/vendor/assets/luca-ui/normalize.css +359 -0
- data/vendor/assets/luca-ui/stylesheets/base.css +85 -0
- data/vendor/assets/luca-ui/stylesheets/components/form_view.css +32 -0
- data/vendor/assets/luca-ui/stylesheets/components/grid_view.css +76 -0
- data/vendor/assets/luca-ui/stylesheets/components/toolbar.css +11 -0
- data/vendor/assets/luca-ui/stylesheets/containers/container.css +3 -0
- data/vendor/assets/luca-ui/stylesheets/containers/modal_view.css +0 -0
- data/vendor/assets/luca-ui/stylesheets/containers/tab_view.css +16 -0
- data/vendor/assets/luca-ui/stylesheets/normalize.css +359 -0
- data/vendor/assets/luca-ui/templates/components/bootstrap_form_controls.js +4 -0
- data/vendor/assets/luca-ui/templates/components/form_view.js +4 -0
- data/vendor/assets/luca-ui/templates/components/grid_view.js +4 -0
- data/vendor/assets/luca-ui/templates/components/grid_view_empty_text.js +4 -0
- data/vendor/assets/luca-ui/templates/containers/basic.js +4 -0
- data/vendor/assets/luca-ui/templates/containers/tab_selector_container.js +4 -0
- data/vendor/assets/luca-ui/templates/containers/tab_view.js +4 -0
- data/vendor/assets/luca-ui/templates/containers/toolbar_wrapper.js +4 -0
- data/vendor/assets/luca-ui/templates/fields/button_field.js +4 -0
- data/vendor/assets/luca-ui/templates/fields/button_field_link.js +4 -0
- data/vendor/assets/luca-ui/templates/fields/checkbox_field.js +4 -0
- data/vendor/assets/luca-ui/templates/fields/file_upload_field.js +4 -0
- data/vendor/assets/luca-ui/templates/fields/hidden_field.js +4 -0
- data/vendor/assets/luca-ui/templates/fields/select_field.js +4 -0
- data/vendor/assets/luca-ui/templates/fields/text_area_field.js +4 -0
- data/vendor/assets/luca-ui/templates/fields/text_field.js +4 -0
- data/vendor/assets/luca-ui/templates/sample/contents.js +4 -0
- data/vendor/assets/luca-ui/templates/sample/welcome.js +4 -0
- data/vendor/assets/stylesheets/luca-spec-dependencies.css +166 -0
- data/vendor/assets/stylesheets/luca-ui-bootstrap.css +1201 -0
- data/vendor/assets/stylesheets/luca-ui-spec.css +586 -0
- data/vendor/assets/stylesheets/luca-ui.css +586 -0
- data/views/index.erb +20 -0
- data/views/jasmine.erb +22 -0
- data/views/spec_harness.erb +29 -0
- metadata +361 -0
@@ -0,0 +1,1527 @@
|
|
1
|
+
(function() {
|
2
|
+
|
3
|
+
_.mixin(_.string);
|
4
|
+
|
5
|
+
window.Luca = {
|
6
|
+
VERSION: "0.6.6",
|
7
|
+
core: {},
|
8
|
+
containers: {},
|
9
|
+
components: {},
|
10
|
+
modules: {},
|
11
|
+
fields: {},
|
12
|
+
util: {},
|
13
|
+
registry: {
|
14
|
+
classes: {},
|
15
|
+
namespaces: ["Luca.containers", "Luca.components"]
|
16
|
+
},
|
17
|
+
component_cache: {
|
18
|
+
cid_index: {},
|
19
|
+
name_index: {}
|
20
|
+
}
|
21
|
+
};
|
22
|
+
|
23
|
+
Luca.enableBootstrap = true;
|
24
|
+
|
25
|
+
Luca.registry.addNamespace = function(identifier) {
|
26
|
+
Luca.registry.namespaces.push(identifier);
|
27
|
+
return Luca.registry.namespaces = _(Luca.registry.namespaces).uniq();
|
28
|
+
};
|
29
|
+
|
30
|
+
Luca.cache = function(needle, component) {
|
31
|
+
var lookup_id;
|
32
|
+
if (component != null) Luca.component_cache.cid_index[needle] = component;
|
33
|
+
component = Luca.component_cache.cid_index[needle];
|
34
|
+
if ((component != null ? component.component_name : void 0) != null) {
|
35
|
+
Luca.component_cache.name_index[component.component_name] = component.cid;
|
36
|
+
} else if ((component != null ? component.name : void 0) != null) {
|
37
|
+
Luca.component_cache.name_index[component.name] = component.cid;
|
38
|
+
}
|
39
|
+
if (component != null) return component;
|
40
|
+
lookup_id = Luca.component_cache.name_index[needle];
|
41
|
+
return Luca.component_cache.cid_index[lookup_id];
|
42
|
+
};
|
43
|
+
|
44
|
+
Luca.util.nestedValue = function(accessor, source_object) {
|
45
|
+
return _(accessor.split(/\./)).inject(function(obj, key) {
|
46
|
+
return obj = obj != null ? obj[key] : void 0;
|
47
|
+
}, source_object);
|
48
|
+
};
|
49
|
+
|
50
|
+
Luca.registry.lookup = function(ctype) {
|
51
|
+
var c, className, parents;
|
52
|
+
c = Luca.registry.classes[ctype];
|
53
|
+
if (c != null) return c;
|
54
|
+
className = _.camelize(_.capitalize(ctype));
|
55
|
+
parents = _(Luca.registry.namespaces).map(function(namespace) {
|
56
|
+
return Luca.util.nestedValue(namespace, window || global);
|
57
|
+
});
|
58
|
+
return _.first(_.compact(_(parents).map(function(parent) {
|
59
|
+
return parent[className];
|
60
|
+
})));
|
61
|
+
};
|
62
|
+
|
63
|
+
Luca.util.lazyComponent = function(config) {
|
64
|
+
var componentClass, constructor, ctype;
|
65
|
+
ctype = config.ctype;
|
66
|
+
componentClass = Luca.registry.lookup(ctype);
|
67
|
+
if (!componentClass) {
|
68
|
+
throw "Invalid Component Type: " + ctype + ". Did you forget to register it?";
|
69
|
+
}
|
70
|
+
constructor = eval(componentClass);
|
71
|
+
return new constructor(config);
|
72
|
+
};
|
73
|
+
|
74
|
+
Luca.register = function(component, constructor_class) {
|
75
|
+
var exists;
|
76
|
+
exists = Luca.registry.classes[component];
|
77
|
+
if (exists != null) {
|
78
|
+
throw "Can not register component with the signature " + component + ". Already exists";
|
79
|
+
} else {
|
80
|
+
return Luca.registry.classes[component] = constructor_class;
|
81
|
+
}
|
82
|
+
};
|
83
|
+
|
84
|
+
Luca.available_templates = function(filter) {
|
85
|
+
var available;
|
86
|
+
if (filter == null) filter = "";
|
87
|
+
available = _(Luca.templates).keys();
|
88
|
+
if (filter.length > 0) {
|
89
|
+
return _(available).select(function(tmpl) {
|
90
|
+
return tmpl.match(filter);
|
91
|
+
});
|
92
|
+
} else {
|
93
|
+
return available;
|
94
|
+
}
|
95
|
+
};
|
96
|
+
|
97
|
+
Luca.util.isIE = function() {
|
98
|
+
try {
|
99
|
+
Object.defineProperty({}, '', {});
|
100
|
+
return false;
|
101
|
+
} catch (e) {
|
102
|
+
return true;
|
103
|
+
}
|
104
|
+
};
|
105
|
+
|
106
|
+
$((function() {
|
107
|
+
return $('body').addClass('luca-ui-enabled');
|
108
|
+
})());
|
109
|
+
|
110
|
+
}).call(this);
|
111
|
+
(function() {
|
112
|
+
|
113
|
+
Luca.modules.Deferrable = {
|
114
|
+
configure_collection: function(setAsDeferrable) {
|
115
|
+
var collectionManager, _ref, _ref2;
|
116
|
+
if (setAsDeferrable == null) setAsDeferrable = true;
|
117
|
+
if (!this.collection) return;
|
118
|
+
if (_.isString(this.collection) && (collectionManager = (_ref = Luca.CollectionManager) != null ? _ref.get() : void 0)) {
|
119
|
+
this.collection = collectionManager.getOrCreate(this.collection);
|
120
|
+
}
|
121
|
+
if (!(this.collection && _.isFunction(this.collection.fetch) && _.isFunction(this.collection.reset))) {
|
122
|
+
this.collection = new Luca.Collection(this.collection.initial_set, this.collection);
|
123
|
+
}
|
124
|
+
if ((_ref2 = this.collection) != null ? _ref2.deferrable_trigger : void 0) {
|
125
|
+
this.deferrable_trigger = this.collection.deferrable_trigger;
|
126
|
+
}
|
127
|
+
if (setAsDeferrable) return this.deferrable = this.collection;
|
128
|
+
}
|
129
|
+
};
|
130
|
+
|
131
|
+
}).call(this);
|
132
|
+
(function() {
|
133
|
+
|
134
|
+
Luca.LocalStore = (function() {
|
135
|
+
|
136
|
+
function LocalStore(name) {
|
137
|
+
var store;
|
138
|
+
this.name = name;
|
139
|
+
store = localStorage.getItem(this.name);
|
140
|
+
this.data = (store && JSON.parse(store)) || {};
|
141
|
+
}
|
142
|
+
|
143
|
+
LocalStore.prototype.guid = function() {
|
144
|
+
var S4;
|
145
|
+
S4 = function() {
|
146
|
+
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
|
147
|
+
};
|
148
|
+
return S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4();
|
149
|
+
};
|
150
|
+
|
151
|
+
LocalStore.prototype.save = function() {
|
152
|
+
return localStorage.setItem(this.name, JSON.stringify(this.data));
|
153
|
+
};
|
154
|
+
|
155
|
+
LocalStore.prototype.create = function(model) {
|
156
|
+
if (!model.id) model.id = model.attribtues.id = this.guid();
|
157
|
+
this.data[model.id] = model;
|
158
|
+
this.save();
|
159
|
+
return model;
|
160
|
+
};
|
161
|
+
|
162
|
+
LocalStore.prototype.update = function(model) {
|
163
|
+
this.data[model.id] = model;
|
164
|
+
this.save();
|
165
|
+
return model;
|
166
|
+
};
|
167
|
+
|
168
|
+
LocalStore.prototype.find = function(model) {
|
169
|
+
return this.data[model.id];
|
170
|
+
};
|
171
|
+
|
172
|
+
LocalStore.prototype.findAll = function() {
|
173
|
+
return _.values(this.data);
|
174
|
+
};
|
175
|
+
|
176
|
+
LocalStore.prototype.destroy = function(model) {
|
177
|
+
delete this.data[model.id];
|
178
|
+
this.save();
|
179
|
+
return model;
|
180
|
+
};
|
181
|
+
|
182
|
+
return LocalStore;
|
183
|
+
|
184
|
+
})();
|
185
|
+
|
186
|
+
Backbone.LocalSync = function(method, model, options) {
|
187
|
+
var resp, store;
|
188
|
+
store = model.localStorage || model.collection.localStorage;
|
189
|
+
resp = (function() {
|
190
|
+
switch (method) {
|
191
|
+
case "read":
|
192
|
+
if (model.id) {
|
193
|
+
return store.find(model);
|
194
|
+
} else {
|
195
|
+
return store.findAll();
|
196
|
+
}
|
197
|
+
case "create":
|
198
|
+
return store.create(model);
|
199
|
+
case "update":
|
200
|
+
return store.update(model);
|
201
|
+
case "delete":
|
202
|
+
return store.destroy(model);
|
203
|
+
}
|
204
|
+
})();
|
205
|
+
if (resp) {
|
206
|
+
return options.success(resp);
|
207
|
+
} else {
|
208
|
+
return options.error("Record not found");
|
209
|
+
}
|
210
|
+
};
|
211
|
+
|
212
|
+
}).call(this);
|
213
|
+
(function() {
|
214
|
+
Luca.templates || (Luca.templates = {});
|
215
|
+
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('');};
|
216
|
+
}).call(this);
|
217
|
+
(function() {
|
218
|
+
Luca.templates || (Luca.templates = {});
|
219
|
+
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('');};
|
220
|
+
}).call(this);
|
221
|
+
(function() {
|
222
|
+
Luca.templates || (Luca.templates = {});
|
223
|
+
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('');};
|
224
|
+
}).call(this);
|
225
|
+
(function() {
|
226
|
+
Luca.templates || (Luca.templates = {});
|
227
|
+
Luca.templates["components/grid_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'luca-ui-grid-view-wrapper\'>\n <div class=\'grid-view-header\'>\n <div class=\'toolbar-container top\'></div>\n </div>\n <div class=\'grid-view-body\'>\n <table cellpadding=\'0\' cellspacing=\'0\' class=\'luca-ui-grid-view scrollable-table\' width=\'100%\'>\n <thead class=\'fixed\'></thead>\n <tbody class=\'scrollable\'></tbody>\n </table>\n </div>\n <div class=\'grid-view-footer\'>\n <div class=\'toolbar-container bottom\'></div>\n </div>\n</div>\n');}return __p.join('');};
|
228
|
+
}).call(this);
|
229
|
+
(function() {
|
230
|
+
Luca.templates || (Luca.templates = {});
|
231
|
+
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('');};
|
232
|
+
}).call(this);
|
233
|
+
(function() {
|
234
|
+
Luca.templates || (Luca.templates = {});
|
235
|
+
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('');};
|
236
|
+
}).call(this);
|
237
|
+
(function() {
|
238
|
+
Luca.templates || (Luca.templates = {});
|
239
|
+
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('');};
|
240
|
+
}).call(this);
|
241
|
+
(function() {
|
242
|
+
Luca.templates || (Luca.templates = {});
|
243
|
+
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('');};
|
244
|
+
}).call(this);
|
245
|
+
(function() {
|
246
|
+
Luca.templates || (Luca.templates = {});
|
247
|
+
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('');};
|
248
|
+
}).call(this);
|
249
|
+
(function() {
|
250
|
+
Luca.templates || (Luca.templates = {});
|
251
|
+
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('');};
|
252
|
+
}).call(this);
|
253
|
+
(function() {
|
254
|
+
Luca.templates || (Luca.templates = {});
|
255
|
+
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('');};
|
256
|
+
}).call(this);
|
257
|
+
(function() {
|
258
|
+
Luca.templates || (Luca.templates = {});
|
259
|
+
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('');};
|
260
|
+
}).call(this);
|
261
|
+
(function() {
|
262
|
+
Luca.templates || (Luca.templates = {});
|
263
|
+
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('');};
|
264
|
+
}).call(this);
|
265
|
+
(function() {
|
266
|
+
Luca.templates || (Luca.templates = {});
|
267
|
+
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('');};
|
268
|
+
}).call(this);
|
269
|
+
(function() {
|
270
|
+
Luca.templates || (Luca.templates = {});
|
271
|
+
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('');};
|
272
|
+
}).call(this);
|
273
|
+
(function() {
|
274
|
+
Luca.templates || (Luca.templates = {});
|
275
|
+
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('');};
|
276
|
+
}).call(this);
|
277
|
+
(function() {
|
278
|
+
Luca.templates || (Luca.templates = {});
|
279
|
+
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 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('');};
|
280
|
+
}).call(this);
|
281
|
+
(function() {
|
282
|
+
Luca.templates || (Luca.templates = {});
|
283
|
+
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('');};
|
284
|
+
}).call(this);
|
285
|
+
(function() {
|
286
|
+
Luca.templates || (Luca.templates = {});
|
287
|
+
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('');};
|
288
|
+
}).call(this);
|
289
|
+
(function() {
|
290
|
+
var __slice = Array.prototype.slice;
|
291
|
+
|
292
|
+
Luca.Observer = (function() {
|
293
|
+
|
294
|
+
function Observer(options) {
|
295
|
+
var _this = this;
|
296
|
+
this.options = options != null ? options : {};
|
297
|
+
_.extend(this, Backbone.Events);
|
298
|
+
this.type = this.options.type;
|
299
|
+
if (this.options.debugAll) {
|
300
|
+
this.bind("event", function() {
|
301
|
+
var args, t;
|
302
|
+
t = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
303
|
+
return console.log("Observed " + _this.type + " " + (t.name || t.id || t.cid), t, _(args).flatten());
|
304
|
+
});
|
305
|
+
}
|
306
|
+
}
|
307
|
+
|
308
|
+
Observer.prototype.relay = function() {
|
309
|
+
var args, triggerer;
|
310
|
+
triggerer = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
311
|
+
this.trigger("event", triggerer, args);
|
312
|
+
return this.trigger("event:" + args[0], triggerer, args.slice(1));
|
313
|
+
};
|
314
|
+
|
315
|
+
return Observer;
|
316
|
+
|
317
|
+
})();
|
318
|
+
|
319
|
+
Luca.Observer.enableObservers = function(options) {
|
320
|
+
if (options == null) options = {};
|
321
|
+
Luca.enableGlobalObserver = true;
|
322
|
+
Luca.ViewObserver = new Luca.Observer(_.extend(options, {
|
323
|
+
type: "view"
|
324
|
+
}));
|
325
|
+
return Luca.CollectionObserver = new Luca.Observer(_.extend(options, {
|
326
|
+
type: "collection"
|
327
|
+
}));
|
328
|
+
};
|
329
|
+
|
330
|
+
}).call(this);
|
331
|
+
(function() {
|
332
|
+
|
333
|
+
Luca.View = Backbone.View.extend({
|
334
|
+
base: 'Luca.View'
|
335
|
+
});
|
336
|
+
|
337
|
+
Luca.View.originalExtend = Backbone.View.extend;
|
338
|
+
|
339
|
+
Luca.View.extend = function(definition) {
|
340
|
+
var _base;
|
341
|
+
_base = definition.render;
|
342
|
+
_base || (_base = function() {
|
343
|
+
var container;
|
344
|
+
container = _.isFunction(this.container) ? this.container() : this.container;
|
345
|
+
if (!($(container) && this.$el)) return this;
|
346
|
+
$(container).append(this.$el);
|
347
|
+
return this;
|
348
|
+
});
|
349
|
+
definition.render = function() {
|
350
|
+
var _this = this;
|
351
|
+
if (this.deferrable) {
|
352
|
+
this.trigger("before:render", this);
|
353
|
+
this.deferrable.bind(this.deferrable_event, _.once(function() {
|
354
|
+
_base.apply(_this, arguments);
|
355
|
+
return _this.trigger("after:render", _this);
|
356
|
+
}));
|
357
|
+
if (!this.deferrable_trigger) this.immediate_trigger = true;
|
358
|
+
if (this.immediate_trigger === true) {
|
359
|
+
return this.deferrable.fetch();
|
360
|
+
} else {
|
361
|
+
return this.bind(this.deferrable_trigger, _.once(function() {
|
362
|
+
return _this.deferrable.fetch();
|
363
|
+
}));
|
364
|
+
}
|
365
|
+
} else {
|
366
|
+
this.trigger("before:render", this);
|
367
|
+
_base.apply(this, arguments);
|
368
|
+
return this.trigger("after:render", this);
|
369
|
+
}
|
370
|
+
};
|
371
|
+
return Luca.View.originalExtend.apply(this, [definition]);
|
372
|
+
};
|
373
|
+
|
374
|
+
_.extend(Luca.View.prototype, {
|
375
|
+
debug: function() {
|
376
|
+
var message, _i, _len, _results;
|
377
|
+
if (!(this.debugMode || (window.LucaDebugMode != null))) return;
|
378
|
+
_results = [];
|
379
|
+
for (_i = 0, _len = arguments.length; _i < _len; _i++) {
|
380
|
+
message = arguments[_i];
|
381
|
+
_results.push(console.log([this.name || this.cid, message]));
|
382
|
+
}
|
383
|
+
return _results;
|
384
|
+
},
|
385
|
+
trigger: function() {
|
386
|
+
if (Luca.enableGlobalObserver) {
|
387
|
+
Luca.ViewObserver || (Luca.ViewObserver = new Luca.Observer({
|
388
|
+
type: "view"
|
389
|
+
}));
|
390
|
+
Luca.ViewObserver.relay(this, arguments);
|
391
|
+
}
|
392
|
+
return Backbone.View.prototype.trigger.apply(this, arguments);
|
393
|
+
},
|
394
|
+
hooks: ["after:initialize", "before:render", "after:render", "first:activation", "activation", "deactivation"],
|
395
|
+
deferrable_event: "reset",
|
396
|
+
initialize: function(options) {
|
397
|
+
var unique,
|
398
|
+
_this = this;
|
399
|
+
this.options = options != null ? options : {};
|
400
|
+
_.extend(this, this.options);
|
401
|
+
if (this.name != null) this.cid = _.uniqueId(this.name);
|
402
|
+
Luca.cache(this.cid, this);
|
403
|
+
unique = _(Luca.View.prototype.hooks.concat(this.hooks)).uniq();
|
404
|
+
this.setupHooks(unique);
|
405
|
+
if (this.autoBindEventHandlers === true) {
|
406
|
+
_(this.events).each(function(handler, event) {
|
407
|
+
if (_.isString(handler)) return _.bindAll(_this, handler);
|
408
|
+
});
|
409
|
+
}
|
410
|
+
this.trigger("after:initialize", this);
|
411
|
+
return this.registerCollectionEvents();
|
412
|
+
},
|
413
|
+
$container: function() {
|
414
|
+
return $(this.container);
|
415
|
+
},
|
416
|
+
setupHooks: function(set) {
|
417
|
+
var _this = this;
|
418
|
+
set || (set = this.hooks);
|
419
|
+
return _(set).each(function(event) {
|
420
|
+
var fn, parts, prefix;
|
421
|
+
parts = event.split(':');
|
422
|
+
prefix = parts.shift();
|
423
|
+
parts = _(parts).map(function(p) {
|
424
|
+
return _.capitalize(p);
|
425
|
+
});
|
426
|
+
fn = prefix + parts.join('');
|
427
|
+
return _this.bind(event, function() {
|
428
|
+
if (_this[fn]) return _this[fn].apply(_this, arguments);
|
429
|
+
});
|
430
|
+
});
|
431
|
+
},
|
432
|
+
getCollectionManager: function() {
|
433
|
+
var _ref;
|
434
|
+
return this.collectionManager || ((_ref = Luca.CollectionManager.get) != null ? _ref.call() : void 0);
|
435
|
+
},
|
436
|
+
registerCollectionEvents: function() {
|
437
|
+
var manager,
|
438
|
+
_this = this;
|
439
|
+
manager = this.getCollectionManager();
|
440
|
+
return _(this.collectionEvents).each(function(handler, signature) {
|
441
|
+
var collection, event, key, _ref;
|
442
|
+
_ref = signature.split(" "), key = _ref[0], event = _ref[1];
|
443
|
+
collection = _this["" + key + "Collection"] = manager.getOrCreate(key);
|
444
|
+
if (!collection) throw "Could not find collection specified by " + key;
|
445
|
+
if (_.isString(handler)) handler = _this[handler];
|
446
|
+
if (!_.isFunction(handler)) throw "invalid collectionEvents configuration";
|
447
|
+
try {
|
448
|
+
return collection.bind(event, handler);
|
449
|
+
} catch (e) {
|
450
|
+
console.log("Error Binding To Collection in registerCollectionEvents", _this);
|
451
|
+
throw e;
|
452
|
+
}
|
453
|
+
});
|
454
|
+
}
|
455
|
+
});
|
456
|
+
|
457
|
+
}).call(this);
|
458
|
+
(function() {
|
459
|
+
|
460
|
+
Luca.Collection = (Backbone.QueryCollection || Backbone.Collection).extend({
|
461
|
+
initialize: function(models, options) {
|
462
|
+
var table,
|
463
|
+
_this = this;
|
464
|
+
if (models == null) models = [];
|
465
|
+
this.options = options;
|
466
|
+
_.extend(this, this.options);
|
467
|
+
if (this.cached) {
|
468
|
+
this.bootstrap_cache_key = _.isFunction(this.cached) ? this.cached() : this.cached;
|
469
|
+
}
|
470
|
+
if (this.registerAs || this.registerWith) {
|
471
|
+
console.log("This configuration API is deprecated. use @name and @manager properties instead");
|
472
|
+
}
|
473
|
+
this.name || (this.name = this.registerAs);
|
474
|
+
this.manager || (this.manager = this.registerWith);
|
475
|
+
if (this.name && !this.manager) this.manager = Luca.CollectionManager.get();
|
476
|
+
if (this.manager) {
|
477
|
+
this.name || (this.name = this.cached());
|
478
|
+
this.name = _.isFunction(this.name) ? this.name() : this.name;
|
479
|
+
if (!(this.private || this.anonymous)) {
|
480
|
+
this.bind("after:initialize", function() {
|
481
|
+
return _this.register(_this.manager, _this.name, _this);
|
482
|
+
});
|
483
|
+
}
|
484
|
+
}
|
485
|
+
if (this.useLocalStorage === true && (window.localStorage != null)) {
|
486
|
+
table = this.bootstrap_cache_key || this.name;
|
487
|
+
throw "Must specify either a cached or registerAs property to use localStorage";
|
488
|
+
this.localStorage = new Luca.LocalStore(table);
|
489
|
+
}
|
490
|
+
if (_.isArray(this.data) && this.data.length > 0) {
|
491
|
+
this.memoryCollection = true;
|
492
|
+
}
|
493
|
+
if (this.useNormalUrl !== true) this.__wrapUrl();
|
494
|
+
Backbone.Collection.prototype.initialize.apply(this, [models, this.options]);
|
495
|
+
return this.trigger("after:initialize");
|
496
|
+
},
|
497
|
+
__wrapUrl: function() {
|
498
|
+
var params, url,
|
499
|
+
_this = this;
|
500
|
+
if (_.isFunction(this.url)) {
|
501
|
+
return this.url = _.wrap(this.url, function(fn) {
|
502
|
+
var existing_params, new_val, parts, queryString, val;
|
503
|
+
val = fn.apply(_this);
|
504
|
+
parts = val.split('?');
|
505
|
+
if (parts.length > 1) existing_params = _.last(parts);
|
506
|
+
queryString = _this.queryString();
|
507
|
+
if (existing_params && val.match(existing_params)) {
|
508
|
+
queryString = queryString.replace(existing_params, '');
|
509
|
+
}
|
510
|
+
new_val = "" + val + "?" + queryString;
|
511
|
+
if (new_val.match(/\?$/)) new_val = new_val.replace(/\?$/, '');
|
512
|
+
return new_val;
|
513
|
+
});
|
514
|
+
} else {
|
515
|
+
url = this.url;
|
516
|
+
params = this.queryString();
|
517
|
+
return this.url = _([url, params]).compact().join("?");
|
518
|
+
}
|
519
|
+
},
|
520
|
+
queryString: function() {
|
521
|
+
var parts,
|
522
|
+
_this = this;
|
523
|
+
parts = _(this.base_params || (this.base_params = Luca.Collection.baseParams())).inject(function(memo, value, key) {
|
524
|
+
var str;
|
525
|
+
str = "" + key + "=" + value;
|
526
|
+
memo.push(str);
|
527
|
+
return memo;
|
528
|
+
}, []);
|
529
|
+
return _.uniq(parts).join("&");
|
530
|
+
},
|
531
|
+
resetFilter: function() {
|
532
|
+
this.base_params = Luca.Collection.baseParams();
|
533
|
+
return this;
|
534
|
+
},
|
535
|
+
applyFilter: function(filter, options) {
|
536
|
+
if (filter == null) filter = {};
|
537
|
+
if (options == null) options = {};
|
538
|
+
this.applyParams(filter);
|
539
|
+
return this.fetch(_.extend(options, {
|
540
|
+
refresh: true
|
541
|
+
}));
|
542
|
+
},
|
543
|
+
applyParams: function(params) {
|
544
|
+
this.base_params || (this.base_params = Luca.Collection.baseParams());
|
545
|
+
return _.extend(this.base_params, params);
|
546
|
+
},
|
547
|
+
register: function(collectionManager, key, collection) {
|
548
|
+
if (collectionManager == null) {
|
549
|
+
collectionManager = Luca.CollectionManager.get();
|
550
|
+
}
|
551
|
+
if (key == null) key = "";
|
552
|
+
if (!(key.length >= 1)) {
|
553
|
+
throw "Can not register with a collection manager without a key";
|
554
|
+
}
|
555
|
+
if (collectionManager == null) {
|
556
|
+
throw "Can not register with a collection manager without a valid collection manager";
|
557
|
+
}
|
558
|
+
if (_.isString(collectionManager)) {
|
559
|
+
collectionManager = Luca.util.nestedValue(collectionManager, window || global);
|
560
|
+
}
|
561
|
+
if (!collectionManager) throw "Could not register with collection manager";
|
562
|
+
if (_.isFunction(collectionManager.add)) {
|
563
|
+
return collectionManager.add(key, collection);
|
564
|
+
}
|
565
|
+
if (_.isObject(collectionManager)) {
|
566
|
+
return collectionManager[key] = collection;
|
567
|
+
}
|
568
|
+
},
|
569
|
+
loadFromBootstrap: function() {
|
570
|
+
if (!this.bootstrap_cache_key) return;
|
571
|
+
this.reset(this.cached_models());
|
572
|
+
return this.trigger("bootstrapped", this);
|
573
|
+
},
|
574
|
+
bootstrap: function() {
|
575
|
+
return this.loadFromBootstrap();
|
576
|
+
},
|
577
|
+
cached_models: function() {
|
578
|
+
return Luca.Collection.cache(this.bootstrap_cache_key);
|
579
|
+
},
|
580
|
+
fetch: function(options) {
|
581
|
+
var url;
|
582
|
+
if (options == null) options = {};
|
583
|
+
this.trigger("before:fetch", this);
|
584
|
+
if (this.memoryCollection === true) return this.reset(this.data);
|
585
|
+
if (this.cached_models().length && !options.refresh) return this.bootstrap();
|
586
|
+
url = _.isFunction(this.url) ? this.url() : this.url;
|
587
|
+
if (!((url && url.length > 1) || this.localStorage)) return true;
|
588
|
+
this.fetching = true;
|
589
|
+
try {
|
590
|
+
return Backbone.Collection.prototype.fetch.apply(this, arguments);
|
591
|
+
} catch (e) {
|
592
|
+
console.log("Error in Collection.fetch", e);
|
593
|
+
throw e;
|
594
|
+
}
|
595
|
+
},
|
596
|
+
onceLoaded: function(fn, options) {
|
597
|
+
var wrapped,
|
598
|
+
_this = this;
|
599
|
+
if (options == null) {
|
600
|
+
options = {
|
601
|
+
autoFetch: true
|
602
|
+
};
|
603
|
+
}
|
604
|
+
if (this.length > 0 && !this.fetching) {
|
605
|
+
fn.apply(this, [this]);
|
606
|
+
return;
|
607
|
+
}
|
608
|
+
wrapped = function() {
|
609
|
+
return fn.apply(_this, [_this]);
|
610
|
+
};
|
611
|
+
this.bind("reset", function() {
|
612
|
+
wrapped();
|
613
|
+
return this.unbind("reset", this);
|
614
|
+
});
|
615
|
+
if (!(this.fetching || !options.autoFetch)) return this.fetch();
|
616
|
+
},
|
617
|
+
ifLoaded: function(fn, options) {
|
618
|
+
var scope,
|
619
|
+
_this = this;
|
620
|
+
if (options == null) {
|
621
|
+
options = {
|
622
|
+
scope: this,
|
623
|
+
autoFetch: true
|
624
|
+
};
|
625
|
+
}
|
626
|
+
scope = options.scope || this;
|
627
|
+
if (this.length > 0 && !this.fetching) fn.apply(scope, [this]);
|
628
|
+
this.bind("reset", function(collection) {
|
629
|
+
return fn.apply(scope, [collection]);
|
630
|
+
});
|
631
|
+
if (!(this.fetching === true || !options.autoFetch || this.length > 0)) {
|
632
|
+
return this.fetch();
|
633
|
+
}
|
634
|
+
},
|
635
|
+
parse: function(response) {
|
636
|
+
var models;
|
637
|
+
this.fetching = false;
|
638
|
+
this.trigger("after:response", response);
|
639
|
+
models = this.root != null ? response[this.root] : response;
|
640
|
+
if (this.bootstrap_cache_key) {
|
641
|
+
Luca.Collection.cache(this.bootstrap_cache_key, models);
|
642
|
+
}
|
643
|
+
return models;
|
644
|
+
}
|
645
|
+
});
|
646
|
+
|
647
|
+
_.extend(Luca.Collection.prototype, {
|
648
|
+
trigger: function() {
|
649
|
+
if (Luca.enableGlobalObserver) {
|
650
|
+
Luca.CollectionObserver || (Luca.CollectionObserver = new Luca.Observer({
|
651
|
+
type: "collection"
|
652
|
+
}));
|
653
|
+
Luca.CollectionObserver.relay(this, arguments);
|
654
|
+
}
|
655
|
+
return Backbone.View.prototype.trigger.apply(this, arguments);
|
656
|
+
}
|
657
|
+
});
|
658
|
+
|
659
|
+
Luca.Collection.baseParams = function(obj) {
|
660
|
+
if (obj) return Luca.Collection._baseParams = obj;
|
661
|
+
if (_.isFunction(Luca.Collection._baseParams)) {
|
662
|
+
return Luca.Collection._baseParams.call();
|
663
|
+
}
|
664
|
+
if (_.isObject(Luca.Collection._baseParams)) {
|
665
|
+
return Luca.Collection._baseParams;
|
666
|
+
}
|
667
|
+
};
|
668
|
+
|
669
|
+
Luca.Collection._bootstrapped_models = {};
|
670
|
+
|
671
|
+
Luca.Collection.bootstrap = function(obj) {
|
672
|
+
return _.extend(Luca.Collection._bootstrapped_models, obj);
|
673
|
+
};
|
674
|
+
|
675
|
+
Luca.Collection.cache = function(key, models) {
|
676
|
+
if (models) return Luca.Collection._bootstrapped_models[key] = models;
|
677
|
+
return Luca.Collection._bootstrapped_models[key] || [];
|
678
|
+
};
|
679
|
+
|
680
|
+
}).call(this);
|
681
|
+
(function() {
|
682
|
+
|
683
|
+
Luca.core.Field = Luca.View.extend({
|
684
|
+
className: 'luca-ui-text-field luca-ui-field',
|
685
|
+
isField: true,
|
686
|
+
template: 'fields/text_field',
|
687
|
+
labelAlign: 'top',
|
688
|
+
hooks: ["before:validation", "after:validation", "on:change"],
|
689
|
+
statuses: ["warning", "error", "success"],
|
690
|
+
initialize: function(options) {
|
691
|
+
var _ref;
|
692
|
+
this.options = options != null ? options : {};
|
693
|
+
_.extend(this, this.options);
|
694
|
+
Luca.View.prototype.initialize.apply(this, arguments);
|
695
|
+
this.input_id || (this.input_id = _.uniqueId('field'));
|
696
|
+
this.input_name || (this.input_name = this.name);
|
697
|
+
this.helperText || (this.helperText = "");
|
698
|
+
if (this.required && !((_ref = this.label) != null ? _ref.match(/^\*/) : void 0)) {
|
699
|
+
this.label || (this.label = "*" + this.label);
|
700
|
+
}
|
701
|
+
this.inputStyles || (this.inputStyles = "");
|
702
|
+
if (this.disabled) this.disable();
|
703
|
+
this.updateState(this.state);
|
704
|
+
return this.placeHolder || (this.placeHolder = "");
|
705
|
+
},
|
706
|
+
beforeRender: function() {
|
707
|
+
if (Luca.enableBootstrap) this.$el.addClass('control-group');
|
708
|
+
if (this.required) this.$el.addClass('required');
|
709
|
+
this.$el.html(Luca.templates[this.template](this));
|
710
|
+
return this.input = $('input', this.el);
|
711
|
+
},
|
712
|
+
change_handler: function(e) {
|
713
|
+
return this.trigger("on:change", this, e);
|
714
|
+
},
|
715
|
+
disable: function() {
|
716
|
+
return $("input", this.el).attr('disabled', true);
|
717
|
+
},
|
718
|
+
enable: function() {
|
719
|
+
return $("input", this.el).attr('disabled', false);
|
720
|
+
},
|
721
|
+
getValue: function() {
|
722
|
+
return this.input.attr('value');
|
723
|
+
},
|
724
|
+
render: function() {
|
725
|
+
return $(this.container).append(this.$el);
|
726
|
+
},
|
727
|
+
setValue: function(value) {
|
728
|
+
return this.input.attr('value', value);
|
729
|
+
},
|
730
|
+
updateState: function(state) {
|
731
|
+
var _this = this;
|
732
|
+
return _(this.statuses).each(function(cls) {
|
733
|
+
_this.$el.removeClass(cls);
|
734
|
+
return _this.$el.addClass(state);
|
735
|
+
});
|
736
|
+
}
|
737
|
+
});
|
738
|
+
|
739
|
+
}).call(this);
|
740
|
+
(function() {
|
741
|
+
|
742
|
+
Luca.core.Container = Luca.View.extend({
|
743
|
+
className: 'luca-ui-container',
|
744
|
+
componentClass: 'luca-ui-panel',
|
745
|
+
isContainer: true,
|
746
|
+
hooks: ["before:components", "before:layout", "after:components", "after:layout", "first:activation"],
|
747
|
+
rendered: false,
|
748
|
+
components: [],
|
749
|
+
initialize: function(options) {
|
750
|
+
this.options = options != null ? options : {};
|
751
|
+
_.extend(this, this.options);
|
752
|
+
this.setupHooks(Luca.core.Container.prototype.hooks);
|
753
|
+
return Luca.View.prototype.initialize.apply(this, arguments);
|
754
|
+
},
|
755
|
+
beforeRender: function() {
|
756
|
+
this.debug("container before render");
|
757
|
+
this.doLayout();
|
758
|
+
return this.doComponents();
|
759
|
+
},
|
760
|
+
doLayout: function() {
|
761
|
+
this.debug("container do layout");
|
762
|
+
this.trigger("before:layout", this);
|
763
|
+
this.prepareLayout();
|
764
|
+
return this.trigger("after:layout", this);
|
765
|
+
},
|
766
|
+
doComponents: function() {
|
767
|
+
this.debug("container do components");
|
768
|
+
this.trigger("before:components", this, this.components);
|
769
|
+
this.prepareComponents();
|
770
|
+
this.createComponents();
|
771
|
+
this.renderComponents();
|
772
|
+
return this.trigger("after:components", this, this.components);
|
773
|
+
},
|
774
|
+
applyPanelConfig: function(panel, panelIndex) {
|
775
|
+
var config, style_declarations;
|
776
|
+
style_declarations = [];
|
777
|
+
if (panel.height) {
|
778
|
+
style_declarations.push("height: " + (_.isNumber(panel.height) ? panel.height + 'px' : panel.height));
|
779
|
+
}
|
780
|
+
if (panel.width) {
|
781
|
+
style_declarations.push("width: " + (_.isNumber(panel.width) ? panel.width + 'px' : panel.width));
|
782
|
+
}
|
783
|
+
if (panel.float) style_declarations.push("float: " + panel.float);
|
784
|
+
return config = {
|
785
|
+
classes: (panel != null ? panel.classes : void 0) || this.componentClass,
|
786
|
+
id: "" + this.cid + "-" + panelIndex,
|
787
|
+
style: style_declarations.join(';')
|
788
|
+
};
|
789
|
+
},
|
790
|
+
prepareLayout: function() {
|
791
|
+
var _this = this;
|
792
|
+
this.debug("container prepare layout");
|
793
|
+
this.componentContainers = _(this.components).map(function(component, index) {
|
794
|
+
return _this.applyPanelConfig.apply(_this, [component, index]);
|
795
|
+
});
|
796
|
+
if (this.appendContainers) {
|
797
|
+
return _(this.componentContainers).each(function(container) {
|
798
|
+
return _this.$el.append(Luca.templates["containers/basic"](container));
|
799
|
+
});
|
800
|
+
}
|
801
|
+
},
|
802
|
+
prepareComponents: function() {
|
803
|
+
var _this = this;
|
804
|
+
this.debug("container prepare components");
|
805
|
+
return this.components = _(this.components).map(function(object, index) {
|
806
|
+
var panel;
|
807
|
+
panel = _this.componentContainers[index];
|
808
|
+
object.container = _this.appendContainers ? "#" + panel.id : _this.el;
|
809
|
+
return object;
|
810
|
+
});
|
811
|
+
},
|
812
|
+
createComponents: function() {
|
813
|
+
var map,
|
814
|
+
_this = this;
|
815
|
+
this.debug("container create components");
|
816
|
+
map = this.componentIndex = {
|
817
|
+
name_index: {},
|
818
|
+
cid_index: {}
|
819
|
+
};
|
820
|
+
this.components = _(this.components).map(function(object, index) {
|
821
|
+
var component;
|
822
|
+
component = _.isObject(object) && object.render && object.trigger ? object : (object.ctype || (object.ctype = Luca.defaultComponentType || "template"), Luca.util.lazyComponent(object));
|
823
|
+
if (!component.container && component.options.container) {
|
824
|
+
component.container = component.options.container;
|
825
|
+
}
|
826
|
+
if (map && (component.cid != null)) map.cid_index[component.cid] = index;
|
827
|
+
if (map && (component.name != null)) {
|
828
|
+
map.name_index[component.name] = index;
|
829
|
+
}
|
830
|
+
return component;
|
831
|
+
});
|
832
|
+
return this.debug("components created", this.components);
|
833
|
+
},
|
834
|
+
renderComponents: function(debugMode) {
|
835
|
+
var _this = this;
|
836
|
+
this.debugMode = debugMode != null ? debugMode : "";
|
837
|
+
this.debug("container render components");
|
838
|
+
return _(this.components).each(function(component) {
|
839
|
+
component.getParent = function() {
|
840
|
+
return _this;
|
841
|
+
};
|
842
|
+
$(component.container).append($(component.el));
|
843
|
+
try {
|
844
|
+
return component.render();
|
845
|
+
} catch (e) {
|
846
|
+
console.log("Error Rendering Component " + (component.name || component.cid), component);
|
847
|
+
console.log(e.message);
|
848
|
+
return console.log(e.stack);
|
849
|
+
}
|
850
|
+
});
|
851
|
+
},
|
852
|
+
firstActivation: function() {
|
853
|
+
var _this = this;
|
854
|
+
return _(this.components).each(function(component) {
|
855
|
+
var activator, _ref;
|
856
|
+
activator = _this;
|
857
|
+
if ((component != null ? component.previously_activated : void 0) !== true) {
|
858
|
+
if (component != null) {
|
859
|
+
if ((_ref = component.trigger) != null) {
|
860
|
+
_ref.apply(component, ["first:activation", [component, activator]]);
|
861
|
+
}
|
862
|
+
}
|
863
|
+
return component.previously_activated = true;
|
864
|
+
}
|
865
|
+
});
|
866
|
+
},
|
867
|
+
select: function(attribute, value, deep) {
|
868
|
+
var components;
|
869
|
+
if (deep == null) deep = false;
|
870
|
+
components = _(this.components).map(function(component) {
|
871
|
+
var matches, test;
|
872
|
+
matches = [];
|
873
|
+
test = component[attribute];
|
874
|
+
if (test === value) matches.push(component);
|
875
|
+
if (deep === true && component.isContainer === true) {
|
876
|
+
matches.push(component.select(attribute, value, true));
|
877
|
+
}
|
878
|
+
return _.compact(matches);
|
879
|
+
});
|
880
|
+
return _.flatten(components);
|
881
|
+
},
|
882
|
+
findComponentByName: function(name, deep) {
|
883
|
+
if (deep == null) deep = false;
|
884
|
+
return this.findComponent(name, "name_index", deep);
|
885
|
+
},
|
886
|
+
findComponentById: function(id, deep) {
|
887
|
+
if (deep == null) deep = false;
|
888
|
+
return this.findComponent(id, "cid_index", deep);
|
889
|
+
},
|
890
|
+
findComponent: function(needle, haystack, deep) {
|
891
|
+
var component, position, sub_container, _ref, _ref2;
|
892
|
+
if (haystack == null) haystack = "name";
|
893
|
+
if (deep == null) deep = false;
|
894
|
+
position = (_ref = this.componentIndex) != null ? _ref[haystack][needle] : void 0;
|
895
|
+
component = (_ref2 = this.components) != null ? _ref2[position] : void 0;
|
896
|
+
if (component) return component;
|
897
|
+
if (deep === true) {
|
898
|
+
sub_container = _(this.components).detect(function(component) {
|
899
|
+
return component != null ? typeof component.findComponent === "function" ? component.findComponent(needle, haystack, true) : void 0 : void 0;
|
900
|
+
});
|
901
|
+
return sub_container != null ? typeof sub_container.findComponent === "function" ? sub_container.findComponent(needle, haystack, true) : void 0 : void 0;
|
902
|
+
}
|
903
|
+
},
|
904
|
+
eachComponent: function(fn, deep) {
|
905
|
+
var _this = this;
|
906
|
+
if (deep == null) deep = true;
|
907
|
+
return _(this.components).each(function(component) {
|
908
|
+
var _ref;
|
909
|
+
fn.apply(component, [component]);
|
910
|
+
if (deep) {
|
911
|
+
return component != null ? (_ref = component.eachComponent) != null ? _ref.apply(component, [fn, deep]) : void 0 : void 0;
|
912
|
+
}
|
913
|
+
});
|
914
|
+
},
|
915
|
+
indexOf: function(name) {
|
916
|
+
var names;
|
917
|
+
names = _(this.components).pluck('name');
|
918
|
+
return _(names).indexOf(name);
|
919
|
+
},
|
920
|
+
activeComponent: function() {
|
921
|
+
if (!this.activeItem) return this;
|
922
|
+
return this.components[this.activeItem];
|
923
|
+
},
|
924
|
+
componentElements: function() {
|
925
|
+
return $("." + this.componentClass, this.el);
|
926
|
+
},
|
927
|
+
getComponent: function(needle) {
|
928
|
+
return this.components[needle];
|
929
|
+
},
|
930
|
+
rootComponent: function() {
|
931
|
+
return !(this.getParent != null);
|
932
|
+
},
|
933
|
+
getRootComponent: function() {
|
934
|
+
if (this.rootComponent()) {
|
935
|
+
return this;
|
936
|
+
} else {
|
937
|
+
return this.getParent().getRootComponent();
|
938
|
+
}
|
939
|
+
}
|
940
|
+
});
|
941
|
+
|
942
|
+
Luca.register("container", "Luca.core.Container");
|
943
|
+
|
944
|
+
}).call(this);
|
945
|
+
(function() {
|
946
|
+
var instances;
|
947
|
+
|
948
|
+
instances = [];
|
949
|
+
|
950
|
+
Luca.CollectionManager = (function() {
|
951
|
+
|
952
|
+
CollectionManager.prototype.__collections = {};
|
953
|
+
|
954
|
+
function CollectionManager(options) {
|
955
|
+
this.options = options != null ? options : {};
|
956
|
+
_.extend(this, this.options);
|
957
|
+
_.extend(this, Backbone.Events);
|
958
|
+
instances.push(this);
|
959
|
+
this.state = new Backbone.Model;
|
960
|
+
if (this.collectionNames) {
|
961
|
+
this.state.set({
|
962
|
+
loaded_collections_count: 0,
|
963
|
+
collections_count: this.collectionNames.length
|
964
|
+
});
|
965
|
+
this.state.bind("change:loaded_collections_count", this.collectionCountDidChange);
|
966
|
+
if (this.useProgressLoader) {
|
967
|
+
this.loader = new Luca.components.CollectionLoaderView({
|
968
|
+
manager: this,
|
969
|
+
name: "collection_loader_view"
|
970
|
+
});
|
971
|
+
}
|
972
|
+
this.loadInitialCollections();
|
973
|
+
}
|
974
|
+
this;
|
975
|
+
}
|
976
|
+
|
977
|
+
CollectionManager.prototype.add = function(key, collection) {
|
978
|
+
var _base;
|
979
|
+
return (_base = this.currentScope())[key] || (_base[key] = collection);
|
980
|
+
};
|
981
|
+
|
982
|
+
CollectionManager.prototype.allCollections = function() {
|
983
|
+
return _(this.currentScope()).values();
|
984
|
+
};
|
985
|
+
|
986
|
+
CollectionManager.prototype.create = function(key, collectionOptions, initialModels) {
|
987
|
+
var CollectionClass, collection;
|
988
|
+
if (collectionOptions == null) collectionOptions = {};
|
989
|
+
if (initialModels == null) initialModels = [];
|
990
|
+
CollectionClass = collectionOptions.base;
|
991
|
+
CollectionClass || (CollectionClass = this.guessCollectionClass(key));
|
992
|
+
if (collectionOptions.private) collectionOptions.name = "";
|
993
|
+
collection = new CollectionClass(initialModels, collectionOptions);
|
994
|
+
this.add(key, collection);
|
995
|
+
return collection;
|
996
|
+
};
|
997
|
+
|
998
|
+
CollectionManager.prototype.collectionNamespace = Luca.Collection.namespace;
|
999
|
+
|
1000
|
+
CollectionManager.prototype.currentScope = function() {
|
1001
|
+
var current_scope, _base;
|
1002
|
+
if (current_scope = this.getScope()) {
|
1003
|
+
return (_base = this.__collections)[current_scope] || (_base[current_scope] = {});
|
1004
|
+
} else {
|
1005
|
+
return this.__collections;
|
1006
|
+
}
|
1007
|
+
};
|
1008
|
+
|
1009
|
+
CollectionManager.prototype.each = function(fn) {
|
1010
|
+
return _(this.all()).each(fn);
|
1011
|
+
};
|
1012
|
+
|
1013
|
+
CollectionManager.prototype.get = function(key) {
|
1014
|
+
return this.currentScope()[key];
|
1015
|
+
};
|
1016
|
+
|
1017
|
+
CollectionManager.prototype.getScope = function() {
|
1018
|
+
return;
|
1019
|
+
};
|
1020
|
+
|
1021
|
+
CollectionManager.prototype.getOrCreate = function(key, collectionOptions, initialModels) {
|
1022
|
+
if (collectionOptions == null) collectionOptions = {};
|
1023
|
+
if (initialModels == null) initialModels = [];
|
1024
|
+
return this.get(key) || this.create(key, collectionOptions, initialModels, false);
|
1025
|
+
};
|
1026
|
+
|
1027
|
+
CollectionManager.prototype.guessCollectionClass = function(key) {
|
1028
|
+
var classified, guess;
|
1029
|
+
classified = _(key).chain().capitalize().camelize().value();
|
1030
|
+
guess = (this.collectionNamespace || (window || global))[classified];
|
1031
|
+
guess || (guess = (this.collectionNamespace || (window || global))["" + classified + "Collection"]);
|
1032
|
+
return guess;
|
1033
|
+
};
|
1034
|
+
|
1035
|
+
CollectionManager.prototype.loadInitialCollections = function() {
|
1036
|
+
var collectionDidLoad,
|
1037
|
+
_this = this;
|
1038
|
+
collectionDidLoad = function(collection) {
|
1039
|
+
collection.unbind("reset");
|
1040
|
+
return _this.trigger("collection_loaded", collection.name);
|
1041
|
+
};
|
1042
|
+
return _(this.collectionNames).each(function(name) {
|
1043
|
+
var collection;
|
1044
|
+
collection = _this.getOrCreate(name);
|
1045
|
+
collection.bind("reset", function() {
|
1046
|
+
return collectionDidLoad(collection);
|
1047
|
+
});
|
1048
|
+
return collection.fetch();
|
1049
|
+
});
|
1050
|
+
};
|
1051
|
+
|
1052
|
+
CollectionManager.prototype.collectionCountDidChange = function() {
|
1053
|
+
if (this.totalCollectionsCount() === this.loadedCollectionsCount()) {
|
1054
|
+
return this.trigger("all_collections_loaded");
|
1055
|
+
}
|
1056
|
+
};
|
1057
|
+
|
1058
|
+
CollectionManager.prototype.totalCollectionsCount = function() {
|
1059
|
+
return this.state.get("collections_count");
|
1060
|
+
};
|
1061
|
+
|
1062
|
+
CollectionManager.prototype.loadedCollectionsCount = function() {
|
1063
|
+
return this.state.get("loaded_collections_count");
|
1064
|
+
};
|
1065
|
+
|
1066
|
+
CollectionManager.prototype.private = function(key, collectionOptions, initialModels) {
|
1067
|
+
if (collectionOptions == null) collectionOptions = {};
|
1068
|
+
if (initialModels == null) initialModels = [];
|
1069
|
+
return this.create(key, collectionOptions, initialModels, true);
|
1070
|
+
};
|
1071
|
+
|
1072
|
+
return CollectionManager;
|
1073
|
+
|
1074
|
+
})();
|
1075
|
+
|
1076
|
+
Luca.CollectionManager.destroyAll = function() {
|
1077
|
+
return instances = [];
|
1078
|
+
};
|
1079
|
+
|
1080
|
+
Luca.CollectionManager.instances = function() {
|
1081
|
+
return instances;
|
1082
|
+
};
|
1083
|
+
|
1084
|
+
Luca.CollectionManager.get = function() {
|
1085
|
+
return _(instances).last();
|
1086
|
+
};
|
1087
|
+
|
1088
|
+
}).call(this);
|
1089
|
+
(function() {
|
1090
|
+
|
1091
|
+
Luca.SocketManager = (function() {
|
1092
|
+
|
1093
|
+
function SocketManager(options) {
|
1094
|
+
this.options = options != null ? options : {};
|
1095
|
+
_.extend(Backbone.Events);
|
1096
|
+
this.loadTransport();
|
1097
|
+
}
|
1098
|
+
|
1099
|
+
SocketManager.prototype.connect = function() {
|
1100
|
+
switch (this.options.provider) {
|
1101
|
+
case "socket.io":
|
1102
|
+
return this.socket = io.connect(this.options.socket_host);
|
1103
|
+
case "faye.js":
|
1104
|
+
return this.socket = new Faye.Client(this.options.socket_host);
|
1105
|
+
}
|
1106
|
+
};
|
1107
|
+
|
1108
|
+
SocketManager.prototype.transportLoaded = function() {
|
1109
|
+
return this.connect();
|
1110
|
+
};
|
1111
|
+
|
1112
|
+
SocketManager.prototype.transport_script = function() {
|
1113
|
+
switch (this.options.provider) {
|
1114
|
+
case "socket.io":
|
1115
|
+
return "" + this.options.transport_host + "/socket.io/socket.io.js";
|
1116
|
+
case "faye.js":
|
1117
|
+
return "" + this.options.transport_host + "/faye.js";
|
1118
|
+
}
|
1119
|
+
};
|
1120
|
+
|
1121
|
+
SocketManager.prototype.loadTransport = function() {
|
1122
|
+
var script,
|
1123
|
+
_this = this;
|
1124
|
+
script = document.createElement('script');
|
1125
|
+
script.setAttribute("type", "text/javascript");
|
1126
|
+
script.setAttribute("src", this.transport_script());
|
1127
|
+
script.onload = this.transportLoaded;
|
1128
|
+
if (Luca.util.isIE()) {
|
1129
|
+
script.onreadystatechange = function() {
|
1130
|
+
if (script.readyState === "loaded") return _this.transportLoaded();
|
1131
|
+
};
|
1132
|
+
}
|
1133
|
+
return document.getElementsByTagName('head')[0].appendChild(script);
|
1134
|
+
};
|
1135
|
+
|
1136
|
+
return SocketManager;
|
1137
|
+
|
1138
|
+
})();
|
1139
|
+
|
1140
|
+
}).call(this);
|
1141
|
+
(function() {
|
1142
|
+
|
1143
|
+
Luca.containers.SplitView = Luca.core.Container.extend({
|
1144
|
+
layout: '100',
|
1145
|
+
componentType: 'split_view',
|
1146
|
+
containerTemplate: 'containers/basic',
|
1147
|
+
className: 'luca-ui-split-view',
|
1148
|
+
componentClass: 'luca-ui-panel'
|
1149
|
+
});
|
1150
|
+
|
1151
|
+
Luca.register('split_view', "Luca.containers.SplitView");
|
1152
|
+
|
1153
|
+
}).call(this);
|
1154
|
+
(function() {
|
1155
|
+
|
1156
|
+
Luca.containers.ColumnView = Luca.core.Container.extend({
|
1157
|
+
componentType: 'column_view',
|
1158
|
+
className: 'luca-ui-column-view',
|
1159
|
+
components: [],
|
1160
|
+
initialize: function(options) {
|
1161
|
+
this.options = options != null ? options : {};
|
1162
|
+
Luca.core.Container.prototype.initialize.apply(this, arguments);
|
1163
|
+
return this.setColumnWidths();
|
1164
|
+
},
|
1165
|
+
componentClass: 'luca-ui-column',
|
1166
|
+
containerTemplate: "containers/basic",
|
1167
|
+
appendContainers: true,
|
1168
|
+
autoColumnWidths: function() {
|
1169
|
+
var widths,
|
1170
|
+
_this = this;
|
1171
|
+
widths = [];
|
1172
|
+
_(this.components.length).times(function() {
|
1173
|
+
return widths.push(parseInt(100 / _this.components.length));
|
1174
|
+
});
|
1175
|
+
return widths;
|
1176
|
+
},
|
1177
|
+
setColumnWidths: function() {
|
1178
|
+
this.columnWidths = this.layout != null ? _(this.layout.split('/')).map(function(v) {
|
1179
|
+
return parseInt(v);
|
1180
|
+
}) : this.autoColumnWidths();
|
1181
|
+
return this.columnWidths = _(this.columnWidths).map(function(val) {
|
1182
|
+
return "" + val + "%";
|
1183
|
+
});
|
1184
|
+
},
|
1185
|
+
beforeComponents: function() {
|
1186
|
+
this.debug("column_view before components");
|
1187
|
+
return _(this.components).each(function(component) {
|
1188
|
+
return component.ctype || (component.ctype = "panel_view");
|
1189
|
+
});
|
1190
|
+
},
|
1191
|
+
beforeLayout: function() {
|
1192
|
+
var _ref,
|
1193
|
+
_this = this;
|
1194
|
+
this.debug("column_view before layout");
|
1195
|
+
_(this.columnWidths).each(function(width, index) {
|
1196
|
+
_this.components[index].float = "left";
|
1197
|
+
return _this.components[index].width = width;
|
1198
|
+
});
|
1199
|
+
return (_ref = Luca.core.Container.prototype.beforeLayout) != null ? _ref.apply(this, arguments) : void 0;
|
1200
|
+
}
|
1201
|
+
});
|
1202
|
+
|
1203
|
+
Luca.register('column_view', "Luca.containers.ColumnView");
|
1204
|
+
|
1205
|
+
}).call(this);
|
1206
|
+
(function() {
|
1207
|
+
|
1208
|
+
Luca.containers.CardView = Luca.core.Container.extend({
|
1209
|
+
componentType: 'card_view',
|
1210
|
+
className: 'luca-ui-card-view-wrapper',
|
1211
|
+
activeCard: 0,
|
1212
|
+
components: [],
|
1213
|
+
hooks: ['before:card:switch', 'after:card:switch'],
|
1214
|
+
initialize: function(options) {
|
1215
|
+
this.options = options;
|
1216
|
+
Luca.core.Container.prototype.initialize.apply(this, arguments);
|
1217
|
+
return this.setupHooks(this.hooks);
|
1218
|
+
},
|
1219
|
+
componentClass: 'luca-ui-card',
|
1220
|
+
beforeLayout: function() {
|
1221
|
+
var _this = this;
|
1222
|
+
return this.cards = _(this.components).map(function(card, cardIndex) {
|
1223
|
+
return {
|
1224
|
+
classes: _this.componentClass,
|
1225
|
+
style: "display:" + (cardIndex === _this.activeCard ? 'block' : 'none'),
|
1226
|
+
id: "" + _this.cid + "-" + cardIndex
|
1227
|
+
};
|
1228
|
+
});
|
1229
|
+
},
|
1230
|
+
prepareLayout: function() {
|
1231
|
+
var _this = this;
|
1232
|
+
return this.card_containers = _(this.cards).map(function(card, index) {
|
1233
|
+
_this.$el.append(Luca.templates["containers/basic"](card));
|
1234
|
+
return $("#" + card.id);
|
1235
|
+
});
|
1236
|
+
},
|
1237
|
+
prepareComponents: function() {
|
1238
|
+
var _this = this;
|
1239
|
+
return this.components = _(this.components).map(function(object, index) {
|
1240
|
+
var card;
|
1241
|
+
card = _this.cards[index];
|
1242
|
+
object.container = "#" + card.id;
|
1243
|
+
return object;
|
1244
|
+
});
|
1245
|
+
},
|
1246
|
+
activeComponent: function() {
|
1247
|
+
return this.getComponent(this.activeCard);
|
1248
|
+
},
|
1249
|
+
cycle: function() {
|
1250
|
+
var nextIndex;
|
1251
|
+
nextIndex = this.activeCard < this.components.length - 1 ? this.activeCard + 1 : 0;
|
1252
|
+
return this.activate(nextIndex);
|
1253
|
+
},
|
1254
|
+
find: function(name) {
|
1255
|
+
return this.findComponentByName(name, true);
|
1256
|
+
},
|
1257
|
+
firstActivation: function() {
|
1258
|
+
return this.activeComponent().trigger("first:activation", this, this.activeComponent());
|
1259
|
+
},
|
1260
|
+
activate: function(index, silent, callback) {
|
1261
|
+
var current, previous, _ref;
|
1262
|
+
if (silent == null) silent = false;
|
1263
|
+
if (_.isFunction(silent)) {
|
1264
|
+
silent = false;
|
1265
|
+
callback = silent;
|
1266
|
+
}
|
1267
|
+
if (index === this.activeCard) return;
|
1268
|
+
previous = this.activeComponent();
|
1269
|
+
current = this.getComponent(index);
|
1270
|
+
if (!current) {
|
1271
|
+
index = this.indexOf(index);
|
1272
|
+
current = this.getComponent(index);
|
1273
|
+
}
|
1274
|
+
if (!current) return;
|
1275
|
+
if (!silent) this.trigger("before:card:switch", previous, current);
|
1276
|
+
_(this.card_containers).each(function(container) {
|
1277
|
+
var _ref;
|
1278
|
+
if ((_ref = container.trigger) != null) {
|
1279
|
+
_ref.apply(container, ["deactivation", this, previous, current]);
|
1280
|
+
}
|
1281
|
+
return container.hide();
|
1282
|
+
});
|
1283
|
+
if (!current.previously_activated) {
|
1284
|
+
current.trigger("first:activation");
|
1285
|
+
current.previously_activated = true;
|
1286
|
+
}
|
1287
|
+
$(current.container).show();
|
1288
|
+
this.activeCard = index;
|
1289
|
+
if (!silent) {
|
1290
|
+
this.trigger("after:card:switch", previous, current);
|
1291
|
+
if ((_ref = current.trigger) != null) {
|
1292
|
+
_ref.apply(current, ["activation", this, previous, current]);
|
1293
|
+
}
|
1294
|
+
}
|
1295
|
+
if (_.isFunction(callback)) {
|
1296
|
+
return callback.apply(this, [this, previous, current]);
|
1297
|
+
}
|
1298
|
+
}
|
1299
|
+
});
|
1300
|
+
|
1301
|
+
Luca.register('card_view', "Luca.containers.CardView");
|
1302
|
+
|
1303
|
+
}).call(this);
|
1304
|
+
(function() {
|
1305
|
+
|
1306
|
+
Luca.containers.ModalView = Luca.core.Container.extend({
|
1307
|
+
componentType: 'modal_view',
|
1308
|
+
className: 'luca-ui-modal-view',
|
1309
|
+
components: [],
|
1310
|
+
renderOnInitialize: true,
|
1311
|
+
showOnRender: false,
|
1312
|
+
hooks: ['before:show', 'before:hide'],
|
1313
|
+
defaultModalOptions: {
|
1314
|
+
minWidth: 375,
|
1315
|
+
maxWidth: 375,
|
1316
|
+
minHeight: 550,
|
1317
|
+
maxHeight: 550,
|
1318
|
+
opacity: 80,
|
1319
|
+
onOpen: function(modal) {
|
1320
|
+
this.onOpen.apply(this);
|
1321
|
+
return this.onModalOpen.apply(modal, [modal, this]);
|
1322
|
+
},
|
1323
|
+
onClose: function(modal) {
|
1324
|
+
this.onClose.apply(this);
|
1325
|
+
return this.onModalClose.apply(modal, [modal, this]);
|
1326
|
+
}
|
1327
|
+
},
|
1328
|
+
modalOptions: {},
|
1329
|
+
initialize: function(options) {
|
1330
|
+
var _this = this;
|
1331
|
+
this.options = options != null ? options : {};
|
1332
|
+
Luca.core.Container.prototype.initialize.apply(this, arguments);
|
1333
|
+
this.setupHooks(this.hooks);
|
1334
|
+
_(this.defaultModalOptions).each(function(value, setting) {
|
1335
|
+
var _base;
|
1336
|
+
return (_base = _this.modalOptions)[setting] || (_base[setting] = value);
|
1337
|
+
});
|
1338
|
+
this.modalOptions.onOpen = _.bind(this.modalOptions.onOpen, this);
|
1339
|
+
return this.modalOptions.onClose = _.bind(this.modalOptions.onClose, this);
|
1340
|
+
},
|
1341
|
+
onOpen: function() {
|
1342
|
+
return true;
|
1343
|
+
},
|
1344
|
+
onClose: function() {
|
1345
|
+
return true;
|
1346
|
+
},
|
1347
|
+
getModal: function() {
|
1348
|
+
return this.modal;
|
1349
|
+
},
|
1350
|
+
onModalOpen: function(modal, view) {
|
1351
|
+
view.modal = modal;
|
1352
|
+
modal.overlay.show();
|
1353
|
+
modal.container.show();
|
1354
|
+
return modal.data.show();
|
1355
|
+
},
|
1356
|
+
onModalClose: function(modal, view) {
|
1357
|
+
return $.modal.close();
|
1358
|
+
},
|
1359
|
+
prepareLayout: function() {
|
1360
|
+
return $('body').append(this.$el);
|
1361
|
+
},
|
1362
|
+
prepareComponents: function() {
|
1363
|
+
var _this = this;
|
1364
|
+
return this.components = _(this.components).map(function(object, index) {
|
1365
|
+
object.container = _this.el;
|
1366
|
+
return object;
|
1367
|
+
});
|
1368
|
+
},
|
1369
|
+
afterInitialize: function() {
|
1370
|
+
this.$el.hide();
|
1371
|
+
if (this.renderOnInitialize) return this.render();
|
1372
|
+
},
|
1373
|
+
afterRender: function() {
|
1374
|
+
if (this.showOnRender) return this.show();
|
1375
|
+
},
|
1376
|
+
wrapper: function() {
|
1377
|
+
return $(this.$el.parent());
|
1378
|
+
},
|
1379
|
+
show: function() {
|
1380
|
+
this.trigger("before:show", this);
|
1381
|
+
return this.$el.modal(this.modalOptions);
|
1382
|
+
},
|
1383
|
+
hide: function() {
|
1384
|
+
return this.trigger("before:hide", this);
|
1385
|
+
}
|
1386
|
+
});
|
1387
|
+
|
1388
|
+
Luca.register("modal_view", "Luca.containers.ModalView");
|
1389
|
+
|
1390
|
+
}).call(this);
|
1391
|
+
(function() {
|
1392
|
+
|
1393
|
+
Luca.containers.PanelView = Luca.core.Container.extend({
|
1394
|
+
className: 'luca-ui-panel',
|
1395
|
+
initialize: function(options) {
|
1396
|
+
this.options = options != null ? options : {};
|
1397
|
+
return Luca.core.Container.prototype.initialize.apply(this, arguments);
|
1398
|
+
},
|
1399
|
+
afterLayout: function() {
|
1400
|
+
var contents;
|
1401
|
+
if (this.template) {
|
1402
|
+
contents = (Luca.templates || JST)[this.template](this);
|
1403
|
+
return this.$el.html(contents);
|
1404
|
+
}
|
1405
|
+
},
|
1406
|
+
render: function() {
|
1407
|
+
return $(this.container).append(this.$el);
|
1408
|
+
},
|
1409
|
+
afterRender: function() {
|
1410
|
+
var _ref,
|
1411
|
+
_this = this;
|
1412
|
+
if ((_ref = Luca.core.Container.prototype.afterRender) != null) {
|
1413
|
+
_ref.apply(this, arguments);
|
1414
|
+
}
|
1415
|
+
if (this.css) {
|
1416
|
+
console.log("Yes Yes Yall", this.css, this.$el);
|
1417
|
+
return _(this.css).each(function(value, property) {
|
1418
|
+
return _this.$el.css(property, value);
|
1419
|
+
});
|
1420
|
+
}
|
1421
|
+
}
|
1422
|
+
});
|
1423
|
+
|
1424
|
+
}).call(this);
|
1425
|
+
(function() {
|
1426
|
+
|
1427
|
+
Luca.containers.TabView = Luca.containers.CardView.extend({
|
1428
|
+
events: {
|
1429
|
+
"click ul.nav-tabs li": "select"
|
1430
|
+
},
|
1431
|
+
hooks: ["before:select", "after:select"],
|
1432
|
+
componentType: 'tab_view',
|
1433
|
+
className: 'luca-ui-tab-view tabbable',
|
1434
|
+
tab_position: 'top',
|
1435
|
+
tabVerticalOffset: '50px',
|
1436
|
+
initialize: function(options) {
|
1437
|
+
this.options = options != null ? options : {};
|
1438
|
+
Luca.containers.CardView.prototype.initialize.apply(this, arguments);
|
1439
|
+
_.bindAll(this, "select", "highlightSelectedTab");
|
1440
|
+
this.setupHooks(this.hooks);
|
1441
|
+
return this.bind("after:card:switch", this.highlightSelectedTab);
|
1442
|
+
},
|
1443
|
+
activeTabSelector: function() {
|
1444
|
+
return this.tabSelectors().eq(this.activeCard);
|
1445
|
+
},
|
1446
|
+
prepareLayout: function() {
|
1447
|
+
var _this = this;
|
1448
|
+
return this.card_containers = _(this.cards).map(function(card, index) {
|
1449
|
+
_this.$('.tab-content').append(Luca.templates["containers/basic"](card));
|
1450
|
+
return $("#" + card.id);
|
1451
|
+
});
|
1452
|
+
},
|
1453
|
+
beforeLayout: function() {
|
1454
|
+
this.$el.addClass("tabs-" + this.tab_position);
|
1455
|
+
if (this.tab_position === "below") {
|
1456
|
+
this.$el.append(Luca.templates["containers/tab_view"](this));
|
1457
|
+
this.$el.append(Luca.templates["containers/tab_selector_container"](this));
|
1458
|
+
} else {
|
1459
|
+
this.$el.append(Luca.templates["containers/tab_selector_container"](this));
|
1460
|
+
this.$el.append(Luca.templates["containers/tab_view"](this));
|
1461
|
+
}
|
1462
|
+
return Luca.containers.CardView.prototype.beforeLayout.apply(this, arguments);
|
1463
|
+
},
|
1464
|
+
beforeRender: function() {
|
1465
|
+
var _ref;
|
1466
|
+
if ((_ref = Luca.containers.CardView.prototype.beforeRender) != null) {
|
1467
|
+
_ref.apply(this, arguments);
|
1468
|
+
}
|
1469
|
+
this.activeTabSelector().addClass('active');
|
1470
|
+
if (Luca.enableBootstrap && this.tab_position === "left" || this.tab_position === "right") {
|
1471
|
+
this.$el.addClass('grid-12');
|
1472
|
+
this.tabContainerWrapper().addClass('grid-3');
|
1473
|
+
this.tabContentWrapper().addClass('grid-9');
|
1474
|
+
if (this.tabVerticalOffset) {
|
1475
|
+
return this.tabContainerWrapper().css('padding-top', this.tabVerticalOffset);
|
1476
|
+
}
|
1477
|
+
}
|
1478
|
+
},
|
1479
|
+
highlightSelectedTab: function() {
|
1480
|
+
this.tabSelectors().removeClass('active');
|
1481
|
+
return this.activeTabSelector().addClass('active');
|
1482
|
+
},
|
1483
|
+
select: function(e) {
|
1484
|
+
var me, my;
|
1485
|
+
me = my = $(e.currentTarget);
|
1486
|
+
this.trigger("before:select", this);
|
1487
|
+
this.activate(my.data('target'));
|
1488
|
+
return this.trigger("after:select", this);
|
1489
|
+
},
|
1490
|
+
tabContentWrapper: function() {
|
1491
|
+
return $("#" + this.cid + "-tab-view-content");
|
1492
|
+
},
|
1493
|
+
tabContainerWrapper: function() {
|
1494
|
+
return $("#" + this.cid + "-tabs-selector");
|
1495
|
+
},
|
1496
|
+
tabContainer: function() {
|
1497
|
+
return $("ul#" + this.cid + "-tabs-nav");
|
1498
|
+
},
|
1499
|
+
tabSelectors: function() {
|
1500
|
+
return $('li.tab-selector', this.tabContainer());
|
1501
|
+
}
|
1502
|
+
});
|
1503
|
+
|
1504
|
+
}).call(this);
|
1505
|
+
(function() {
|
1506
|
+
|
1507
|
+
Luca.containers.Viewport = Luca.containers.CardView.extend({
|
1508
|
+
activeItem: 0,
|
1509
|
+
className: 'luca-ui-viewport',
|
1510
|
+
fullscreen: true,
|
1511
|
+
initialize: function(options) {
|
1512
|
+
this.options = options != null ? options : {};
|
1513
|
+
Luca.core.Container.prototype.initialize.apply(this, arguments);
|
1514
|
+
if (this.fullscreen) return $('html,body').addClass('luca-ui-fullscreen');
|
1515
|
+
},
|
1516
|
+
render: function() {
|
1517
|
+
console.log("Rendering Viewport");
|
1518
|
+
return this.$el.addClass('luca-ui-viewport');
|
1519
|
+
}
|
1520
|
+
});
|
1521
|
+
|
1522
|
+
}).call(this);
|
1523
|
+
(function() {
|
1524
|
+
|
1525
|
+
|
1526
|
+
|
1527
|
+
}).call(this);
|