joosy 1.2.0.alpha.73 → 1.2.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gruntfile.coffee +56 -18
- data/bower.json +1 -1
- data/build/joosy/form.js +1 -0
- data/build/joosy/resources.js +1 -0
- data/build/joosy.js +2 -2774
- data/package.json +5 -4
- data/source/joosy/application.coffee +9 -7
- data/source/joosy/{extensions/resources-form/form.coffee → form.coffee} +58 -51
- data/source/joosy/helpers/form.coffee +241 -0
- data/source/joosy/helpers/index.coffee +3 -0
- data/source/joosy/helpers/routes.coffee +3 -1
- data/source/joosy/helpers/view.coffee +9 -9
- data/source/joosy/joosy.coffee +3 -5
- data/source/joosy/module.coffee +9 -4
- data/source/joosy/modules/dom.coffee +33 -31
- data/source/joosy/modules/events.coffee +24 -20
- data/source/joosy/modules/filters.coffee +38 -35
- data/source/joosy/modules/page/title.coffee +3 -3
- data/source/joosy/modules/renderer.coffee +23 -18
- data/source/joosy/modules/resources/identity_map.coffee +45 -0
- data/source/joosy/modules/resources/model.coffee +146 -0
- data/source/joosy/modules/widgets_manager.coffee +8 -8
- data/source/joosy/resources/array.coffee +0 -5
- data/source/joosy/resources/hash.coffee +8 -13
- data/source/joosy/resources/index.coffee +2 -0
- data/source/joosy/{extensions/resources → resources}/rest.coffee +48 -19
- data/source/joosy/resources/scalar.coffee +8 -10
- data/source/joosy/router.coffee +13 -12
- data/source/joosy/templaters/jst.coffee +3 -2
- data/source/joosy/widget.coffee +17 -15
- data/source/joosy.coffee +2 -0
- data/source/vendor/es5-shim.js +1316 -0
- data/source/vendor/inflections.js +598 -0
- data/source/vendor/metamorph.js +457 -0
- data/spec/helpers/matchers.coffee +4 -4
- data/spec/joosy/core/application_spec.coffee +1 -1
- data/spec/joosy/core/helpers/view_spec.coffee +2 -2
- data/spec/joosy/core/joosy_spec.coffee +8 -4
- data/spec/joosy/core/modules/dom_spec.coffee +7 -7
- data/spec/joosy/core/modules/events_spec.coffee +2 -2
- data/spec/joosy/core/modules/filters_spec.coffee +7 -8
- data/spec/joosy/core/modules/module_spec.coffee +5 -5
- data/spec/joosy/core/router_spec.coffee +3 -3
- data/spec/joosy/core/widget_spec.coffee +6 -6
- data/spec/joosy/environments/amd_spec.coffee +4 -2
- data/spec/joosy/environments/global_spec.coffee +1 -1
- data/spec/joosy/{extensions/form → form}/form_spec.coffee +9 -16
- data/spec/joosy/{extensions/form → form}/helpers/forms_spec.coffee +5 -5
- data/spec/joosy/{core/resources → resources}/array_spec.coffee +2 -2
- data/spec/joosy/{core/resources → resources}/hash_spec.coffee +0 -8
- data/spec/joosy/{core/modules/resources → resources/modules}/cacher_spec.coffee +0 -0
- data/spec/joosy/resources/modules/identity_map_spec.coffee +47 -0
- data/spec/joosy/{extensions/resources/base_spec.coffee → resources/modules/model_spec.coffee} +28 -48
- data/spec/joosy/{extensions/resources → resources}/rest_spec.coffee +29 -22
- data/spec/joosy/{core/resources → resources}/scalar_spec.coffee +8 -8
- data/templates/application/application.coffee.tt +0 -2
- data/templates/environment/app/haml/index.haml +2 -2
- data/templates/environment/package.json +1 -1
- metadata +23 -19
- data/build/joosy/extensions/resources-form.js +0 -590
- data/build/joosy/extensions/resources.js +0 -561
- data/source/joosy/extensions/resources/base.coffee +0 -282
- data/source/joosy/extensions/resources/index.coffee +0 -1
- data/source/joosy/extensions/resources-form/helpers/form.coffee +0 -104
- data/source/joosy/extensions/resources-form/index.coffee +0 -1
- data/source/metamorph.coffee +0 -410
data/build/joosy.js
CHANGED
@@ -1,2774 +1,2 @@
|
|
1
|
-
(function() {
|
2
|
-
this.Joosy = {
|
3
|
-
Modules: {},
|
4
|
-
Resources: {},
|
5
|
-
Templaters: {},
|
6
|
-
Helpers: {},
|
7
|
-
Events: {},
|
8
|
-
/* Global settings*/
|
9
|
-
|
10
|
-
debug: function(value) {
|
11
|
-
if (value != null) {
|
12
|
-
return this.__debug = value;
|
13
|
-
} else {
|
14
|
-
return !!this.__debug;
|
15
|
-
}
|
16
|
-
},
|
17
|
-
templater: function(value) {
|
18
|
-
if (value != null) {
|
19
|
-
return this.__templater = value;
|
20
|
-
} else {
|
21
|
-
if (!this.__templater) {
|
22
|
-
throw new Error("No templater registered");
|
23
|
-
}
|
24
|
-
return this.__templater;
|
25
|
-
}
|
26
|
-
},
|
27
|
-
/* Global helpers*/
|
28
|
-
|
29
|
-
namespace: function(name, generator) {
|
30
|
-
var key, klass, part, space, _i, _len, _results;
|
31
|
-
if (generator == null) {
|
32
|
-
generator = false;
|
33
|
-
}
|
34
|
-
name = name.split('.');
|
35
|
-
space = window;
|
36
|
-
for (_i = 0, _len = name.length; _i < _len; _i++) {
|
37
|
-
part = name[_i];
|
38
|
-
if (part.length > 0) {
|
39
|
-
space = space[part] != null ? space[part] : space[part] = {};
|
40
|
-
}
|
41
|
-
}
|
42
|
-
if (generator) {
|
43
|
-
generator = generator.apply(space);
|
44
|
-
}
|
45
|
-
_results = [];
|
46
|
-
for (key in space) {
|
47
|
-
klass = space[key];
|
48
|
-
if (space.hasOwnProperty(key) && Joosy.Module.hasAncestor(klass, Joosy.Module)) {
|
49
|
-
_results.push(klass.__namespace__ = name);
|
50
|
-
} else {
|
51
|
-
_results.push(void 0);
|
52
|
-
}
|
53
|
-
}
|
54
|
-
return _results;
|
55
|
-
},
|
56
|
-
helpers: function(name, generator) {
|
57
|
-
var _base;
|
58
|
-
(_base = Joosy.Helpers)[name] || (_base[name] = {});
|
59
|
-
return generator.apply(Joosy.Helpers[name]);
|
60
|
-
},
|
61
|
-
uid: function() {
|
62
|
-
this.__uid || (this.__uid = 0);
|
63
|
-
return "__joosy" + (this.__uid++);
|
64
|
-
},
|
65
|
-
uuid: function() {
|
66
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
67
|
-
var r, v;
|
68
|
-
r = Math.random() * 16 | 0;
|
69
|
-
v = c === 'x' ? r : r & 3 | 8;
|
70
|
-
return v.toString(16);
|
71
|
-
}).toUpperCase();
|
72
|
-
},
|
73
|
-
/* Shortcuts*/
|
74
|
-
|
75
|
-
synchronize: function() {
|
76
|
-
var _ref;
|
77
|
-
if (!Joosy.Modules.Events) {
|
78
|
-
return console.error("Events module is required to use `Joosy.synchronize'!");
|
79
|
-
} else {
|
80
|
-
return (_ref = Joosy.Modules.Events).synchronize.apply(_ref, arguments);
|
81
|
-
}
|
82
|
-
},
|
83
|
-
buildUrl: function(url, params) {
|
84
|
-
var hash, paramsString;
|
85
|
-
paramsString = [];
|
86
|
-
Object.each(params, function(key, value) {
|
87
|
-
return paramsString.push("" + key + "=" + value);
|
88
|
-
});
|
89
|
-
hash = url.match(/(\#.*)?$/)[0];
|
90
|
-
url = url.replace(/\#.*$/, '');
|
91
|
-
if (!paramsString.isEmpty() && !url.has(/\?/)) {
|
92
|
-
url = url + "?";
|
93
|
-
}
|
94
|
-
paramsString = paramsString.join('&');
|
95
|
-
if (!paramsString.isBlank() && url.last() !== '?') {
|
96
|
-
paramsString = '&' + paramsString;
|
97
|
-
}
|
98
|
-
return url + paramsString + hash;
|
99
|
-
}
|
100
|
-
};
|
101
|
-
|
102
|
-
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
|
103
|
-
define('joosy', function() {
|
104
|
-
return Joosy;
|
105
|
-
});
|
106
|
-
}
|
107
|
-
|
108
|
-
}).call(this);
|
109
|
-
(function() {
|
110
|
-
var __hasProp = {}.hasOwnProperty,
|
111
|
-
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
112
|
-
|
113
|
-
Joosy.Module = (function() {
|
114
|
-
function Module() {}
|
115
|
-
|
116
|
-
Module.__namespace__ = [];
|
117
|
-
|
118
|
-
Module.__className = function(klass) {
|
119
|
-
if (!Object.isFunction(klass)) {
|
120
|
-
klass = klass.constructor;
|
121
|
-
}
|
122
|
-
if (klass.name != null) {
|
123
|
-
return klass.name;
|
124
|
-
} else {
|
125
|
-
return klass.toString().replace(/^function ([a-zA-Z]+)\([\s\S]+/, '$1');
|
126
|
-
}
|
127
|
-
};
|
128
|
-
|
129
|
-
Module.hasAncestor = function(what, klass) {
|
130
|
-
var _ref;
|
131
|
-
if (!((what != null) && (klass != null))) {
|
132
|
-
return false;
|
133
|
-
}
|
134
|
-
what = what.prototype;
|
135
|
-
klass = klass.prototype;
|
136
|
-
while (what) {
|
137
|
-
if (what === klass) {
|
138
|
-
return true;
|
139
|
-
}
|
140
|
-
what = (_ref = what.constructor) != null ? _ref.__super__ : void 0;
|
141
|
-
}
|
142
|
-
return false;
|
143
|
-
};
|
144
|
-
|
145
|
-
Module.aliasMethodChain = function(method, feature, action) {
|
146
|
-
var camelized, chained;
|
147
|
-
camelized = feature.charAt(0).toUpperCase() + feature.slice(1);
|
148
|
-
chained = "" + method + "Without" + camelized;
|
149
|
-
if (!Object.isFunction(action)) {
|
150
|
-
action = this.prototype[action];
|
151
|
-
}
|
152
|
-
this.prototype[chained] = this.prototype[method];
|
153
|
-
return this.prototype[method] = action;
|
154
|
-
};
|
155
|
-
|
156
|
-
Module.aliasStaticMethodChain = function(method, feature, action) {
|
157
|
-
var camelized, chained;
|
158
|
-
camelized = feature.charAt(0).toUpperCase() + feature.slice(1);
|
159
|
-
chained = "" + method + "Without" + camelized;
|
160
|
-
this[chained] = this[method];
|
161
|
-
return this[method] = action;
|
162
|
-
};
|
163
|
-
|
164
|
-
Module.merge = function(destination, source, unsafe) {
|
165
|
-
var key, value;
|
166
|
-
if (unsafe == null) {
|
167
|
-
unsafe = true;
|
168
|
-
}
|
169
|
-
for (key in source) {
|
170
|
-
value = source[key];
|
171
|
-
if (source.hasOwnProperty(key)) {
|
172
|
-
if (unsafe || !destination.hasOwnProperty(key)) {
|
173
|
-
destination[key] = value;
|
174
|
-
}
|
175
|
-
}
|
176
|
-
}
|
177
|
-
return destination;
|
178
|
-
};
|
179
|
-
|
180
|
-
Module.include = function(object) {
|
181
|
-
var key, value, _ref;
|
182
|
-
if (!object) {
|
183
|
-
throw new Error('include(object) requires obj');
|
184
|
-
}
|
185
|
-
for (key in object) {
|
186
|
-
value = object[key];
|
187
|
-
if (key !== 'included' && key !== 'extended') {
|
188
|
-
this.prototype[key] = value;
|
189
|
-
}
|
190
|
-
}
|
191
|
-
if ((_ref = object.included) != null) {
|
192
|
-
_ref.apply(this);
|
193
|
-
}
|
194
|
-
return null;
|
195
|
-
};
|
196
|
-
|
197
|
-
Module.extend = function(object) {
|
198
|
-
var _ref;
|
199
|
-
if (!object) {
|
200
|
-
throw new Error('extend(object) requires object');
|
201
|
-
}
|
202
|
-
this.merge(this, object);
|
203
|
-
if ((_ref = object.extended) != null) {
|
204
|
-
_ref.apply(this);
|
205
|
-
}
|
206
|
-
return null;
|
207
|
-
};
|
208
|
-
|
209
|
-
return Module;
|
210
|
-
|
211
|
-
})();
|
212
|
-
|
213
|
-
Joosy.Function = (function(_super) {
|
214
|
-
__extends(Function, _super);
|
215
|
-
|
216
|
-
function Function(setup) {
|
217
|
-
var key, shim, value;
|
218
|
-
shim = function() {
|
219
|
-
return shim.__call.apply(shim, arguments);
|
220
|
-
};
|
221
|
-
if (shim.__proto__) {
|
222
|
-
shim.__proto__ = this;
|
223
|
-
} else {
|
224
|
-
for (key in this) {
|
225
|
-
value = this[key];
|
226
|
-
shim[key] = value;
|
227
|
-
}
|
228
|
-
}
|
229
|
-
shim.constructor = this.constructor;
|
230
|
-
if (setup != null) {
|
231
|
-
setup.call(shim);
|
232
|
-
}
|
233
|
-
return shim;
|
234
|
-
}
|
235
|
-
|
236
|
-
return Function;
|
237
|
-
|
238
|
-
})(Joosy.Module);
|
239
|
-
|
240
|
-
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
|
241
|
-
define('joosy/module', function() {
|
242
|
-
return Joosy.Module;
|
243
|
-
});
|
244
|
-
}
|
245
|
-
|
246
|
-
}).call(this);
|
247
|
-
(function() {
|
248
|
-
var Namespace, SynchronizationContext,
|
249
|
-
__slice = [].slice;
|
250
|
-
|
251
|
-
SynchronizationContext = (function() {
|
252
|
-
function SynchronizationContext() {
|
253
|
-
this.actions = [];
|
254
|
-
}
|
255
|
-
|
256
|
-
SynchronizationContext.prototype["do"] = function(action) {
|
257
|
-
return this.actions.push(action);
|
258
|
-
};
|
259
|
-
|
260
|
-
SynchronizationContext.prototype.after = function(after) {
|
261
|
-
this.after = after;
|
262
|
-
};
|
263
|
-
|
264
|
-
return SynchronizationContext;
|
265
|
-
|
266
|
-
})();
|
267
|
-
|
268
|
-
Namespace = (function() {
|
269
|
-
function Namespace(parent) {
|
270
|
-
this.parent = parent;
|
271
|
-
this.bindings = [];
|
272
|
-
}
|
273
|
-
|
274
|
-
Namespace.prototype.bind = function() {
|
275
|
-
var args, _ref;
|
276
|
-
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
277
|
-
return this.bindings.push((_ref = this.parent).bind.apply(_ref, args));
|
278
|
-
};
|
279
|
-
|
280
|
-
Namespace.prototype.unbind = function() {
|
281
|
-
var b, _i, _len, _ref;
|
282
|
-
_ref = this.bindings;
|
283
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
284
|
-
b = _ref[_i];
|
285
|
-
this.parent.unbind(b);
|
286
|
-
}
|
287
|
-
return this.bindings = [];
|
288
|
-
};
|
289
|
-
|
290
|
-
return Namespace;
|
291
|
-
|
292
|
-
})();
|
293
|
-
|
294
|
-
Joosy.Modules.Events = {
|
295
|
-
eventsNamespace: function(actions) {
|
296
|
-
var namespace;
|
297
|
-
namespace = new Namespace(this);
|
298
|
-
if (actions != null) {
|
299
|
-
if (typeof actions.call === "function") {
|
300
|
-
actions.call(namespace);
|
301
|
-
}
|
302
|
-
}
|
303
|
-
return namespace;
|
304
|
-
},
|
305
|
-
wait: function(name, events, callback) {
|
306
|
-
if (!this.hasOwnProperty('__oneShotEvents')) {
|
307
|
-
this.__oneShotEvents = {};
|
308
|
-
}
|
309
|
-
if (Object.isFunction(events)) {
|
310
|
-
callback = events;
|
311
|
-
events = name;
|
312
|
-
name = Object.keys(this.__oneShotEvents).length.toString();
|
313
|
-
}
|
314
|
-
events = this.__splitEvents(events);
|
315
|
-
if (events.length > 0) {
|
316
|
-
this.__oneShotEvents[name] = [events, callback];
|
317
|
-
} else {
|
318
|
-
callback();
|
319
|
-
}
|
320
|
-
return name;
|
321
|
-
},
|
322
|
-
unwait: function(target) {
|
323
|
-
if (this.hasOwnProperty('__oneShotEvents')) {
|
324
|
-
return delete this.__oneShotEvents[target];
|
325
|
-
}
|
326
|
-
},
|
327
|
-
bind: function(name, events, callback) {
|
328
|
-
if (!this.hasOwnProperty('__boundEvents')) {
|
329
|
-
this.__boundEvents = {};
|
330
|
-
}
|
331
|
-
if (Object.isFunction(events)) {
|
332
|
-
callback = events;
|
333
|
-
events = name;
|
334
|
-
name = Object.keys(this.__boundEvents).length.toString();
|
335
|
-
}
|
336
|
-
events = this.__splitEvents(events);
|
337
|
-
if (events.length > 0) {
|
338
|
-
this.__boundEvents[name] = [events, callback];
|
339
|
-
} else {
|
340
|
-
callback();
|
341
|
-
}
|
342
|
-
return name;
|
343
|
-
},
|
344
|
-
unbind: function(target) {
|
345
|
-
if (this.hasOwnProperty('__boundEvents')) {
|
346
|
-
return delete this.__boundEvents[target];
|
347
|
-
}
|
348
|
-
},
|
349
|
-
trigger: function() {
|
350
|
-
var callback, data, event, events, fire, name, remember, _ref, _ref1, _ref2, _ref3,
|
351
|
-
_this = this;
|
352
|
-
event = arguments[0], data = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
353
|
-
Joosy.Modules.Log.debugAs(this, "Event " + event + " triggered");
|
354
|
-
if (Object.isObject(event)) {
|
355
|
-
remember = event.remember;
|
356
|
-
event = event.name;
|
357
|
-
} else {
|
358
|
-
remember = false;
|
359
|
-
}
|
360
|
-
if (this.hasOwnProperty('__oneShotEvents')) {
|
361
|
-
fire = [];
|
362
|
-
_ref = this.__oneShotEvents;
|
363
|
-
for (name in _ref) {
|
364
|
-
_ref1 = _ref[name], events = _ref1[0], callback = _ref1[1];
|
365
|
-
events.remove(event);
|
366
|
-
if (events.length === 0) {
|
367
|
-
fire.push(name);
|
368
|
-
}
|
369
|
-
}
|
370
|
-
fire.each(function(name) {
|
371
|
-
callback = _this.__oneShotEvents[name][1];
|
372
|
-
delete _this.__oneShotEvents[name];
|
373
|
-
return callback.apply(null, data);
|
374
|
-
});
|
375
|
-
}
|
376
|
-
if (this.hasOwnProperty('__boundEvents')) {
|
377
|
-
_ref2 = this.__boundEvents;
|
378
|
-
for (name in _ref2) {
|
379
|
-
_ref3 = _ref2[name], events = _ref3[0], callback = _ref3[1];
|
380
|
-
if (events.any(event)) {
|
381
|
-
callback.apply(null, data);
|
382
|
-
}
|
383
|
-
}
|
384
|
-
}
|
385
|
-
if (remember) {
|
386
|
-
if (!this.hasOwnProperty('__triggeredEvents')) {
|
387
|
-
this.__triggeredEvents = {};
|
388
|
-
}
|
389
|
-
return this.__triggeredEvents[event] = true;
|
390
|
-
}
|
391
|
-
},
|
392
|
-
synchronize: function(block) {
|
393
|
-
var context, counter,
|
394
|
-
_this = this;
|
395
|
-
context = new SynchronizationContext;
|
396
|
-
counter = 0;
|
397
|
-
block(context);
|
398
|
-
if (context.actions.length === 0) {
|
399
|
-
return context.after.call(this);
|
400
|
-
} else {
|
401
|
-
return context.actions.each(function(action) {
|
402
|
-
return action.call(_this, function() {
|
403
|
-
if (++counter >= context.actions.length) {
|
404
|
-
return context.after.call(this);
|
405
|
-
}
|
406
|
-
});
|
407
|
-
});
|
408
|
-
}
|
409
|
-
},
|
410
|
-
__splitEvents: function(events) {
|
411
|
-
var _this = this;
|
412
|
-
if (Object.isString(events)) {
|
413
|
-
if (events.isBlank()) {
|
414
|
-
events = [];
|
415
|
-
} else {
|
416
|
-
events = events.trim().split(/\s+/);
|
417
|
-
}
|
418
|
-
}
|
419
|
-
if (this.hasOwnProperty('__triggeredEvents')) {
|
420
|
-
events = events.findAll(function(e) {
|
421
|
-
return !_this.__triggeredEvents[e];
|
422
|
-
});
|
423
|
-
}
|
424
|
-
return events;
|
425
|
-
}
|
426
|
-
};
|
427
|
-
|
428
|
-
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
|
429
|
-
define('joosy/modules/events', function() {
|
430
|
-
return Joosy.Modules.Events;
|
431
|
-
});
|
432
|
-
}
|
433
|
-
|
434
|
-
}).call(this);
|
435
|
-
(function() {
|
436
|
-
var __slice = [].slice;
|
437
|
-
|
438
|
-
Joosy.Modules.Log = {
|
439
|
-
log: function() {
|
440
|
-
var args;
|
441
|
-
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
442
|
-
if (typeof console === "undefined" || console === null) {
|
443
|
-
return;
|
444
|
-
}
|
445
|
-
if (console.log.apply != null) {
|
446
|
-
args.unshift("Joosy>");
|
447
|
-
return console.log.apply(console, args);
|
448
|
-
} else {
|
449
|
-
return console.log(args.first());
|
450
|
-
}
|
451
|
-
},
|
452
|
-
debug: function() {
|
453
|
-
var args;
|
454
|
-
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
455
|
-
if (!Joosy.debug()) {
|
456
|
-
return;
|
457
|
-
}
|
458
|
-
return this.log.apply(this, args);
|
459
|
-
},
|
460
|
-
debugAs: function() {
|
461
|
-
var args, context, string;
|
462
|
-
context = arguments[0], string = arguments[1], args = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
|
463
|
-
if (!Joosy.debug()) {
|
464
|
-
return;
|
465
|
-
}
|
466
|
-
context = Joosy.Module.__className(context) || 'unknown context';
|
467
|
-
return this.debug.apply(this, ["" + context + "> " + string].concat(__slice.call(args)));
|
468
|
-
}
|
469
|
-
};
|
470
|
-
|
471
|
-
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
|
472
|
-
define('joosy/modules/log', function() {
|
473
|
-
return Joosy.Modules.Log;
|
474
|
-
});
|
475
|
-
}
|
476
|
-
|
477
|
-
}).call(this);
|
478
|
-
(function() {
|
479
|
-
Joosy.Modules.DOM = {
|
480
|
-
eventSplitter: /^(\S+)\s*(.*)$/,
|
481
|
-
included: function() {
|
482
|
-
this.mapElements = function(map) {
|
483
|
-
if (!this.prototype.hasOwnProperty("__elements")) {
|
484
|
-
this.prototype.__elements = Object.clone(this.__super__.__elements) || {};
|
485
|
-
}
|
486
|
-
return Object.merge(this.prototype.__elements, map);
|
487
|
-
};
|
488
|
-
return this.mapEvents = function(map) {
|
489
|
-
if (!this.prototype.hasOwnProperty("__events")) {
|
490
|
-
this.prototype.__events = Object.clone(this.__super__.__events) || {};
|
491
|
-
}
|
492
|
-
return Object.merge(this.prototype.__events, map);
|
493
|
-
};
|
494
|
-
},
|
495
|
-
$: function(selector, context) {
|
496
|
-
return $(selector, context || this.$container);
|
497
|
-
},
|
498
|
-
__extractSelector: function(selector) {
|
499
|
-
var _this = this;
|
500
|
-
selector = selector.replace(/(\$[A-z0-9\.\$]+)/g, function(path) {
|
501
|
-
var keyword, part, target, _i, _len, _ref;
|
502
|
-
path = path.split('.');
|
503
|
-
keyword = path.pop();
|
504
|
-
target = _this;
|
505
|
-
for (_i = 0, _len = path.length; _i < _len; _i++) {
|
506
|
-
part = path[_i];
|
507
|
-
target = target != null ? target[part] : void 0;
|
508
|
-
}
|
509
|
-
return target != null ? (_ref = target[keyword]) != null ? _ref.selector : void 0 : void 0;
|
510
|
-
});
|
511
|
-
return selector.trim();
|
512
|
-
},
|
513
|
-
__assignElements: function(root, entries) {
|
514
|
-
var key, value, _results;
|
515
|
-
root || (root = this);
|
516
|
-
entries || (entries = this.__elements);
|
517
|
-
if (!entries) {
|
518
|
-
return;
|
519
|
-
}
|
520
|
-
_results = [];
|
521
|
-
for (key in entries) {
|
522
|
-
value = entries[key];
|
523
|
-
if (Object.isObject(value)) {
|
524
|
-
_results.push(this.__assignElements(root['$' + key] = {}, value));
|
525
|
-
} else {
|
526
|
-
value = this.__extractSelector(value);
|
527
|
-
root['$' + key] = this.__wrapElement(value);
|
528
|
-
_results.push(root['$' + key].selector = value);
|
529
|
-
}
|
530
|
-
}
|
531
|
-
return _results;
|
532
|
-
},
|
533
|
-
__wrapElement: function(value) {
|
534
|
-
var _this = this;
|
535
|
-
return function(context) {
|
536
|
-
if (!context) {
|
537
|
-
return _this.$(value);
|
538
|
-
}
|
539
|
-
return _this.$(value, context);
|
540
|
-
};
|
541
|
-
},
|
542
|
-
__delegateEvents: function() {
|
543
|
-
var events, module,
|
544
|
-
_this = this;
|
545
|
-
module = this;
|
546
|
-
events = this.__events;
|
547
|
-
if (!events) {
|
548
|
-
return;
|
549
|
-
}
|
550
|
-
return Object.each(events, function(keys, method) {
|
551
|
-
var callback, eventName, key, match, selector, _i, _len, _ref, _results;
|
552
|
-
_ref = keys.split(',');
|
553
|
-
_results = [];
|
554
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
555
|
-
key = _ref[_i];
|
556
|
-
key = key.replace(/^\s+/, '');
|
557
|
-
if (!Object.isFunction(method)) {
|
558
|
-
method = _this[method];
|
559
|
-
}
|
560
|
-
callback = function(event) {
|
561
|
-
return method.call(module, $(this), event);
|
562
|
-
};
|
563
|
-
match = key.match(_this.eventSplitter);
|
564
|
-
eventName = match[1];
|
565
|
-
selector = _this.__extractSelector(match[2]);
|
566
|
-
if (selector === "") {
|
567
|
-
_this.$container.bind(eventName, callback);
|
568
|
-
_results.push(Joosy.Modules.Log.debugAs(_this, "" + eventName + " binded on container"));
|
569
|
-
} else if (selector === void 0) {
|
570
|
-
throw new Error("Unknown element " + match[2] + " in " + (Joosy.Module.__className(_this.constructor)) + " (maybe typo?)");
|
571
|
-
} else {
|
572
|
-
_this.$container.on(eventName, selector, callback);
|
573
|
-
_results.push(Joosy.Modules.Log.debugAs(_this, "" + eventName + " binded on " + selector));
|
574
|
-
}
|
575
|
-
}
|
576
|
-
return _results;
|
577
|
-
});
|
578
|
-
},
|
579
|
-
__clearContainer: function() {
|
580
|
-
this.$container.unbind().off();
|
581
|
-
return this.$container = $();
|
582
|
-
}
|
583
|
-
};
|
584
|
-
|
585
|
-
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
|
586
|
-
define('joosy/modules/dom', function() {
|
587
|
-
return Joosy.Modules.DOM;
|
588
|
-
});
|
589
|
-
}
|
590
|
-
|
591
|
-
}).call(this);
|
592
|
-
(function() {
|
593
|
-
(function(window) {
|
594
|
-
var K, Metamorph, afterFunc, appendToFunc, document, endTagFunc, findChildById, firstNodeFor, fixParentage, guid, htmlFunc, movesWhitespace, needsShy, outerHTMLFunc, prependFunc, rangeFor, realNode, removeFunc, setInnerHTML, startTagFunc, supportsRange, wrapMap;
|
595
|
-
K = function() {};
|
596
|
-
guid = 0;
|
597
|
-
document = window.document;
|
598
|
-
supportsRange = document && ("createRange" in document) && (typeof Range !== "undefined") && Range.prototype.createContextualFragment;
|
599
|
-
needsShy = document && (function() {
|
600
|
-
var testEl;
|
601
|
-
testEl = document.createElement("div");
|
602
|
-
testEl.innerHTML = "<div></div>";
|
603
|
-
testEl.firstChild.innerHTML = "<script></script>";
|
604
|
-
return testEl.firstChild.innerHTML === "";
|
605
|
-
})();
|
606
|
-
movesWhitespace = document && (function() {
|
607
|
-
var testEl;
|
608
|
-
testEl = document.createElement("div");
|
609
|
-
testEl.innerHTML = "Test: <script type='text/x-placeholder'></script>Value";
|
610
|
-
return testEl.childNodes[0].nodeValue === "Test:" && testEl.childNodes[2].nodeValue === " Value";
|
611
|
-
})();
|
612
|
-
Metamorph = function(html) {
|
613
|
-
var myGuid, self;
|
614
|
-
self = void 0;
|
615
|
-
if (this instanceof Metamorph) {
|
616
|
-
self = this;
|
617
|
-
} else {
|
618
|
-
self = new K();
|
619
|
-
}
|
620
|
-
self.innerHTML = html;
|
621
|
-
myGuid = "metamorph-" + (guid++);
|
622
|
-
self.start = myGuid + "-start";
|
623
|
-
self.end = myGuid + "-end";
|
624
|
-
return self;
|
625
|
-
};
|
626
|
-
K.prototype = Metamorph.prototype;
|
627
|
-
rangeFor = void 0;
|
628
|
-
htmlFunc = void 0;
|
629
|
-
removeFunc = void 0;
|
630
|
-
outerHTMLFunc = void 0;
|
631
|
-
appendToFunc = void 0;
|
632
|
-
afterFunc = void 0;
|
633
|
-
prependFunc = void 0;
|
634
|
-
startTagFunc = void 0;
|
635
|
-
endTagFunc = void 0;
|
636
|
-
outerHTMLFunc = function() {
|
637
|
-
return this.startTag() + this.innerHTML + this.endTag();
|
638
|
-
};
|
639
|
-
startTagFunc = function() {
|
640
|
-
return "<script id='" + this.start + "' type='text/x-placeholder'></script>";
|
641
|
-
};
|
642
|
-
endTagFunc = function() {
|
643
|
-
return "<script id='" + this.end + "' type='text/x-placeholder'></script>";
|
644
|
-
};
|
645
|
-
if (supportsRange) {
|
646
|
-
rangeFor = function(morph, outerToo) {
|
647
|
-
var after, before, range;
|
648
|
-
range = document.createRange();
|
649
|
-
before = document.getElementById(morph.start);
|
650
|
-
after = document.getElementById(morph.end);
|
651
|
-
if (outerToo) {
|
652
|
-
range.setStartBefore(before);
|
653
|
-
range.setEndAfter(after);
|
654
|
-
} else {
|
655
|
-
range.setStartAfter(before);
|
656
|
-
range.setEndBefore(after);
|
657
|
-
}
|
658
|
-
return range;
|
659
|
-
};
|
660
|
-
htmlFunc = function(html, outerToo) {
|
661
|
-
var fragment, range;
|
662
|
-
range = rangeFor(this, outerToo);
|
663
|
-
range.deleteContents();
|
664
|
-
fragment = range.createContextualFragment(html);
|
665
|
-
return range.insertNode(fragment);
|
666
|
-
};
|
667
|
-
removeFunc = function() {
|
668
|
-
var range;
|
669
|
-
range = rangeFor(this, true);
|
670
|
-
return range.deleteContents();
|
671
|
-
};
|
672
|
-
appendToFunc = function(node) {
|
673
|
-
var frag, range;
|
674
|
-
range = document.createRange();
|
675
|
-
range.setStart(node);
|
676
|
-
range.collapse(false);
|
677
|
-
frag = range.createContextualFragment(this.outerHTML());
|
678
|
-
return node.appendChild(frag);
|
679
|
-
};
|
680
|
-
afterFunc = function(html) {
|
681
|
-
var after, fragment, range;
|
682
|
-
range = document.createRange();
|
683
|
-
after = document.getElementById(this.end);
|
684
|
-
range.setStartAfter(after);
|
685
|
-
range.setEndAfter(after);
|
686
|
-
fragment = range.createContextualFragment(html);
|
687
|
-
return range.insertNode(fragment);
|
688
|
-
};
|
689
|
-
prependFunc = function(html) {
|
690
|
-
var fragment, range, start;
|
691
|
-
range = document.createRange();
|
692
|
-
start = document.getElementById(this.start);
|
693
|
-
range.setStartAfter(start);
|
694
|
-
range.setEndAfter(start);
|
695
|
-
fragment = range.createContextualFragment(html);
|
696
|
-
return range.insertNode(fragment);
|
697
|
-
};
|
698
|
-
} else {
|
699
|
-
/*
|
700
|
-
This code is mostly taken from jQuery, with one exception. In jQuery's case, we
|
701
|
-
have some HTML and we need to figure out how to convert it into some nodes.
|
702
|
-
|
703
|
-
In this case, jQuery needs to scan the HTML looking for an opening tag and use
|
704
|
-
that as the key for the wrap map. In our case, we know the parent node, and
|
705
|
-
can use its type as the key for the wrap map.
|
706
|
-
*/
|
707
|
-
|
708
|
-
wrapMap = {
|
709
|
-
select: [1, "<select multiple='multiple'>", "</select>"],
|
710
|
-
fieldset: [1, "<fieldset>", "</fieldset>"],
|
711
|
-
table: [1, "<table>", "</table>"],
|
712
|
-
tbody: [2, "<table><tbody>", "</tbody></table>"],
|
713
|
-
tr: [3, "<table><tbody><tr>", "</tr></tbody></table>"],
|
714
|
-
colgroup: [2, "<table><tbody></tbody><colgroup>", "</colgroup></table>"],
|
715
|
-
map: [1, "<map>", "</map>"],
|
716
|
-
_default: [0, "", ""]
|
717
|
-
};
|
718
|
-
findChildById = function(element, id) {
|
719
|
-
var found, idx, len, node;
|
720
|
-
if (element.getAttribute("id") === id) {
|
721
|
-
return element;
|
722
|
-
}
|
723
|
-
len = element.childNodes.length;
|
724
|
-
idx = void 0;
|
725
|
-
node = void 0;
|
726
|
-
found = void 0;
|
727
|
-
idx = 0;
|
728
|
-
while (idx < len) {
|
729
|
-
node = element.childNodes[idx];
|
730
|
-
found = node.nodeType === 1 && findChildById(node, id);
|
731
|
-
if (found) {
|
732
|
-
return found;
|
733
|
-
}
|
734
|
-
idx++;
|
735
|
-
}
|
736
|
-
};
|
737
|
-
setInnerHTML = function(element, html) {
|
738
|
-
var idx, len, matches, node, script, _results;
|
739
|
-
matches = [];
|
740
|
-
if (movesWhitespace) {
|
741
|
-
html = html.replace(/(\s+)(<script id='([^']+)')/g, function(match, spaces, tag, id) {
|
742
|
-
matches.push([id, spaces]);
|
743
|
-
return tag;
|
744
|
-
});
|
745
|
-
}
|
746
|
-
element.innerHTML = html;
|
747
|
-
if (matches.length > 0) {
|
748
|
-
len = matches.length;
|
749
|
-
idx = void 0;
|
750
|
-
idx = 0;
|
751
|
-
_results = [];
|
752
|
-
while (idx < len) {
|
753
|
-
script = findChildById(element, matches[idx][0]);
|
754
|
-
node = document.createTextNode(matches[idx][1]);
|
755
|
-
script.parentNode.insertBefore(node, script);
|
756
|
-
_results.push(idx++);
|
757
|
-
}
|
758
|
-
return _results;
|
759
|
-
}
|
760
|
-
};
|
761
|
-
/*
|
762
|
-
Given a parent node and some HTML, generate a set of nodes. Return the first
|
763
|
-
node, which will allow us to traverse the rest using nextSibling.
|
764
|
-
|
765
|
-
We need to do this because innerHTML in IE does not really parse the nodes.
|
766
|
-
*/
|
767
|
-
|
768
|
-
firstNodeFor = function(parentNode, html) {
|
769
|
-
var arr, depth, element, end, i, shyElement, start;
|
770
|
-
arr = wrapMap[parentNode.tagName.toLowerCase()] || wrapMap._default;
|
771
|
-
depth = arr[0];
|
772
|
-
start = arr[1];
|
773
|
-
end = arr[2];
|
774
|
-
if (needsShy) {
|
775
|
-
html = "­" + html;
|
776
|
-
}
|
777
|
-
element = document.createElement("div");
|
778
|
-
setInnerHTML(element, start + html + end);
|
779
|
-
i = 0;
|
780
|
-
while (i <= depth) {
|
781
|
-
element = element.firstChild;
|
782
|
-
i++;
|
783
|
-
}
|
784
|
-
if (needsShy) {
|
785
|
-
shyElement = element;
|
786
|
-
while (shyElement.nodeType === 1 && !shyElement.nodeName) {
|
787
|
-
shyElement = shyElement.firstChild;
|
788
|
-
}
|
789
|
-
if (shyElement.nodeType === 3 && shyElement.nodeValue.charAt(0) === "") {
|
790
|
-
shyElement.nodeValue = shyElement.nodeValue.slice(1);
|
791
|
-
}
|
792
|
-
}
|
793
|
-
return element;
|
794
|
-
};
|
795
|
-
/*
|
796
|
-
In some cases, Internet Explorer can create an anonymous node in
|
797
|
-
the hierarchy with no tagName. You can create this scenario via:
|
798
|
-
|
799
|
-
div = document.createElement("div");
|
800
|
-
div.innerHTML = "<table>­<script></script><tr><td>hi</td></tr></table>";
|
801
|
-
div.firstChild.firstChild.tagName //=> ""
|
802
|
-
|
803
|
-
If our script markers are inside such a node, we need to find that
|
804
|
-
node and use *it* as the marker.
|
805
|
-
*/
|
806
|
-
|
807
|
-
realNode = function(start) {
|
808
|
-
while (start.parentNode.tagName === "") {
|
809
|
-
start = start.parentNode;
|
810
|
-
}
|
811
|
-
return start;
|
812
|
-
};
|
813
|
-
/*
|
814
|
-
When automatically adding a tbody, Internet Explorer inserts the
|
815
|
-
tbody immediately before the first <tr>. Other browsers create it
|
816
|
-
before the first node, no matter what.
|
817
|
-
|
818
|
-
This means the the following code:
|
819
|
-
|
820
|
-
div = document.createElement("div");
|
821
|
-
div.innerHTML = "<table><script id='first'></script><tr><td>hi</td></tr><script id='last'></script></table>
|
822
|
-
|
823
|
-
Generates the following DOM in IE:
|
824
|
-
|
825
|
-
+ div
|
826
|
-
+ table
|
827
|
-
- script id='first'
|
828
|
-
+ tbody
|
829
|
-
+ tr
|
830
|
-
+ td
|
831
|
-
- "hi"
|
832
|
-
- script id='last'
|
833
|
-
|
834
|
-
Which means that the two script tags, even though they were
|
835
|
-
inserted at the same point in the hierarchy in the original
|
836
|
-
HTML, now have different parents.
|
837
|
-
|
838
|
-
This code reparents the first script tag by making it the tbody's
|
839
|
-
first child.
|
840
|
-
*/
|
841
|
-
|
842
|
-
fixParentage = function(start, end) {
|
843
|
-
if (start.parentNode !== end.parentNode) {
|
844
|
-
return end.parentNode.insertBefore(start, end.parentNode.firstChild);
|
845
|
-
}
|
846
|
-
};
|
847
|
-
htmlFunc = function(html, outerToo) {
|
848
|
-
var end, last, nextSibling, node, parentNode, start, _results;
|
849
|
-
start = realNode(document.getElementById(this.start));
|
850
|
-
end = document.getElementById(this.end);
|
851
|
-
parentNode = end.parentNode;
|
852
|
-
node = void 0;
|
853
|
-
nextSibling = void 0;
|
854
|
-
last = void 0;
|
855
|
-
fixParentage(start, end);
|
856
|
-
node = start.nextSibling;
|
857
|
-
while (node) {
|
858
|
-
nextSibling = node.nextSibling;
|
859
|
-
last = node === end;
|
860
|
-
if (last) {
|
861
|
-
if (outerToo) {
|
862
|
-
end = node.nextSibling;
|
863
|
-
} else {
|
864
|
-
break;
|
865
|
-
}
|
866
|
-
}
|
867
|
-
node.parentNode.removeChild(node);
|
868
|
-
if (last) {
|
869
|
-
break;
|
870
|
-
}
|
871
|
-
node = nextSibling;
|
872
|
-
}
|
873
|
-
node = firstNodeFor(start.parentNode, html);
|
874
|
-
_results = [];
|
875
|
-
while (node) {
|
876
|
-
nextSibling = node.nextSibling;
|
877
|
-
parentNode.insertBefore(node, end);
|
878
|
-
_results.push(node = nextSibling);
|
879
|
-
}
|
880
|
-
return _results;
|
881
|
-
};
|
882
|
-
removeFunc = function() {
|
883
|
-
var end, start;
|
884
|
-
start = realNode(document.getElementById(this.start));
|
885
|
-
end = document.getElementById(this.end);
|
886
|
-
this.html("");
|
887
|
-
start.parentNode.removeChild(start);
|
888
|
-
return end.parentNode.removeChild(end);
|
889
|
-
};
|
890
|
-
appendToFunc = function(parentNode) {
|
891
|
-
var nextSibling, node, _results;
|
892
|
-
node = firstNodeFor(parentNode, this.outerHTML());
|
893
|
-
nextSibling = void 0;
|
894
|
-
_results = [];
|
895
|
-
while (node) {
|
896
|
-
nextSibling = node.nextSibling;
|
897
|
-
parentNode.appendChild(node);
|
898
|
-
_results.push(node = nextSibling);
|
899
|
-
}
|
900
|
-
return _results;
|
901
|
-
};
|
902
|
-
afterFunc = function(html) {
|
903
|
-
var end, insertBefore, nextSibling, node, parentNode, _results;
|
904
|
-
end = document.getElementById(this.end);
|
905
|
-
insertBefore = end.nextSibling;
|
906
|
-
parentNode = end.parentNode;
|
907
|
-
nextSibling = void 0;
|
908
|
-
node = void 0;
|
909
|
-
node = firstNodeFor(parentNode, html);
|
910
|
-
_results = [];
|
911
|
-
while (node) {
|
912
|
-
nextSibling = node.nextSibling;
|
913
|
-
parentNode.insertBefore(node, insertBefore);
|
914
|
-
_results.push(node = nextSibling);
|
915
|
-
}
|
916
|
-
return _results;
|
917
|
-
};
|
918
|
-
prependFunc = function(html) {
|
919
|
-
var insertBefore, nextSibling, node, parentNode, start, _results;
|
920
|
-
start = document.getElementById(this.start);
|
921
|
-
parentNode = start.parentNode;
|
922
|
-
nextSibling = void 0;
|
923
|
-
node = void 0;
|
924
|
-
node = firstNodeFor(parentNode, html);
|
925
|
-
insertBefore = start.nextSibling;
|
926
|
-
_results = [];
|
927
|
-
while (node) {
|
928
|
-
nextSibling = node.nextSibling;
|
929
|
-
parentNode.insertBefore(node, insertBefore);
|
930
|
-
_results.push(node = nextSibling);
|
931
|
-
}
|
932
|
-
return _results;
|
933
|
-
};
|
934
|
-
}
|
935
|
-
Metamorph.prototype.html = function(html) {
|
936
|
-
this.checkRemoved();
|
937
|
-
if (html === undefined) {
|
938
|
-
return this.innerHTML;
|
939
|
-
}
|
940
|
-
htmlFunc.call(this, html);
|
941
|
-
return this.innerHTML = html;
|
942
|
-
};
|
943
|
-
Metamorph.prototype.replaceWith = function(html) {
|
944
|
-
this.checkRemoved();
|
945
|
-
return htmlFunc.call(this, html, true);
|
946
|
-
};
|
947
|
-
Metamorph.prototype.remove = removeFunc;
|
948
|
-
Metamorph.prototype.outerHTML = outerHTMLFunc;
|
949
|
-
Metamorph.prototype.appendTo = appendToFunc;
|
950
|
-
Metamorph.prototype.after = afterFunc;
|
951
|
-
Metamorph.prototype.prepend = prependFunc;
|
952
|
-
Metamorph.prototype.startTag = startTagFunc;
|
953
|
-
Metamorph.prototype.endTag = endTagFunc;
|
954
|
-
Metamorph.prototype.isRemoved = function() {
|
955
|
-
var after, before;
|
956
|
-
before = document.getElementById(this.start);
|
957
|
-
after = document.getElementById(this.end);
|
958
|
-
return !before || !after;
|
959
|
-
};
|
960
|
-
Metamorph.prototype.checkRemoved = function() {
|
961
|
-
if (this.isRemoved()) {
|
962
|
-
throw new Error("Cannot perform operations on a Metamorph that is not in the DOM.");
|
963
|
-
}
|
964
|
-
};
|
965
|
-
return window.Metamorph = Metamorph;
|
966
|
-
})(this);
|
967
|
-
|
968
|
-
}).call(this);
|
969
|
-
(function() {
|
970
|
-
var __slice = [].slice;
|
971
|
-
|
972
|
-
Joosy.Modules.Renderer = {
|
973
|
-
included: function() {
|
974
|
-
this.view = function(template, options) {
|
975
|
-
if (options == null) {
|
976
|
-
options = {};
|
977
|
-
}
|
978
|
-
this.prototype.__view = template;
|
979
|
-
return this.prototype.__renderDefault = function(locals) {
|
980
|
-
if (locals == null) {
|
981
|
-
locals = {};
|
982
|
-
}
|
983
|
-
if (options.dynamic) {
|
984
|
-
return this.renderDynamic(template, locals);
|
985
|
-
} else {
|
986
|
-
return this.render(template, locals);
|
987
|
-
}
|
988
|
-
};
|
989
|
-
};
|
990
|
-
return this.helper = function() {
|
991
|
-
var helpers, _ref;
|
992
|
-
helpers = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
993
|
-
if (!this.prototype.hasOwnProperty("__helpers")) {
|
994
|
-
this.prototype.__helpers = ((_ref = this.__super__.__helpers) != null ? _ref.clone() : void 0) || [];
|
995
|
-
}
|
996
|
-
this.prototype.__helpers = this.prototype.__helpers.add(helpers).unique();
|
997
|
-
return this.prototype.__helpers = this.prototype.__helpers.unique();
|
998
|
-
};
|
999
|
-
},
|
1000
|
-
render: function(template, locals, parentStackPointer) {
|
1001
|
-
if (locals == null) {
|
1002
|
-
locals = {};
|
1003
|
-
}
|
1004
|
-
if (parentStackPointer == null) {
|
1005
|
-
parentStackPointer = false;
|
1006
|
-
}
|
1007
|
-
return this.__render(false, template, locals, parentStackPointer);
|
1008
|
-
},
|
1009
|
-
renderDynamic: function(template, locals, parentStackPointer) {
|
1010
|
-
if (locals == null) {
|
1011
|
-
locals = {};
|
1012
|
-
}
|
1013
|
-
if (parentStackPointer == null) {
|
1014
|
-
parentStackPointer = false;
|
1015
|
-
}
|
1016
|
-
return this.__render(true, template, locals, parentStackPointer);
|
1017
|
-
},
|
1018
|
-
__assignHelpers: function() {
|
1019
|
-
var _this = this;
|
1020
|
-
if (this.__helpers == null) {
|
1021
|
-
return;
|
1022
|
-
}
|
1023
|
-
if (!this.hasOwnProperty("__helpers")) {
|
1024
|
-
this.__helpers = this.__helpers.clone();
|
1025
|
-
}
|
1026
|
-
return this.__helpers.each(function(helper, i) {
|
1027
|
-
if (!Object.isObject(helper)) {
|
1028
|
-
if (_this[helper] == null) {
|
1029
|
-
throw new Error("Cannot find method '" + helper + "' to use as helper");
|
1030
|
-
}
|
1031
|
-
_this.__helpers[i] = {};
|
1032
|
-
return _this.__helpers[i][helper] = function() {
|
1033
|
-
return _this[helper].apply(_this, arguments);
|
1034
|
-
};
|
1035
|
-
}
|
1036
|
-
});
|
1037
|
-
},
|
1038
|
-
__instantiateHelpers: function() {
|
1039
|
-
var helper, _i, _len, _ref;
|
1040
|
-
if (!this.__helpersInstance) {
|
1041
|
-
this.__assignHelpers();
|
1042
|
-
this.__helpersInstance = {};
|
1043
|
-
this.__helpersInstance.__renderer = this;
|
1044
|
-
Joosy.Module.merge(this.__helpersInstance, Joosy.Helpers.Application);
|
1045
|
-
if (Joosy.Helpers.Routes != null) {
|
1046
|
-
Joosy.Module.merge(this.__helpersInstance, Joosy.Helpers.Routes);
|
1047
|
-
}
|
1048
|
-
if (this.__helpers) {
|
1049
|
-
_ref = this.__helpers;
|
1050
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1051
|
-
helper = _ref[_i];
|
1052
|
-
Joosy.Module.merge(this.__helpersInstance, helper);
|
1053
|
-
}
|
1054
|
-
}
|
1055
|
-
}
|
1056
|
-
return this.__helpersInstance;
|
1057
|
-
},
|
1058
|
-
__instantiateRenderers: function(parentStackPointer) {
|
1059
|
-
var _this = this;
|
1060
|
-
return {
|
1061
|
-
render: function(template, locals) {
|
1062
|
-
if (locals == null) {
|
1063
|
-
locals = {};
|
1064
|
-
}
|
1065
|
-
return _this.render(template, locals, parentStackPointer);
|
1066
|
-
},
|
1067
|
-
renderDynamic: function(template, locals) {
|
1068
|
-
if (locals == null) {
|
1069
|
-
locals = {};
|
1070
|
-
}
|
1071
|
-
return _this.renderDynamic(template, locals, parentStackPointer);
|
1072
|
-
},
|
1073
|
-
renderInline: function(locals, partial) {
|
1074
|
-
var template;
|
1075
|
-
if (locals == null) {
|
1076
|
-
locals = {};
|
1077
|
-
}
|
1078
|
-
template = function(params) {
|
1079
|
-
return partial.apply(params);
|
1080
|
-
};
|
1081
|
-
return _this.renderDynamic(template, locals, parentStackPointer);
|
1082
|
-
}
|
1083
|
-
};
|
1084
|
-
},
|
1085
|
-
__render: function(dynamic, template, locals, parentStackPointer) {
|
1086
|
-
var binding, context, key, morph, object, result, stack, update,
|
1087
|
-
_this = this;
|
1088
|
-
if (locals == null) {
|
1089
|
-
locals = {};
|
1090
|
-
}
|
1091
|
-
if (parentStackPointer == null) {
|
1092
|
-
parentStackPointer = false;
|
1093
|
-
}
|
1094
|
-
stack = this.__renderingStackChildFor(parentStackPointer);
|
1095
|
-
stack.template = template;
|
1096
|
-
stack.locals = locals;
|
1097
|
-
if (Object.isString(template)) {
|
1098
|
-
if (this.__renderSection != null) {
|
1099
|
-
template = Joosy.templater().resolveTemplate(this.__renderSection(), template, this);
|
1100
|
-
}
|
1101
|
-
template = Joosy.templater().buildView(template);
|
1102
|
-
} else if (!Object.isFunction(template)) {
|
1103
|
-
throw new Error("" + (Joosy.Module.__className(this)) + "> template (maybe @view) does not look like a string or lambda");
|
1104
|
-
}
|
1105
|
-
if (!Object.isObject(locals) && Object.extended().constructor !== locals.constructor) {
|
1106
|
-
throw new Error("" + (Joosy.Module.__className(this)) + "> locals (maybe @data?) is not a hash");
|
1107
|
-
}
|
1108
|
-
context = function() {
|
1109
|
-
var data;
|
1110
|
-
data = {};
|
1111
|
-
Joosy.Module.merge(data, stack.locals);
|
1112
|
-
Joosy.Module.merge(data, _this.__instantiateHelpers(), false);
|
1113
|
-
Joosy.Module.merge(data, _this.__instantiateRenderers(stack));
|
1114
|
-
return data;
|
1115
|
-
};
|
1116
|
-
result = function() {
|
1117
|
-
return template(context());
|
1118
|
-
};
|
1119
|
-
if (dynamic) {
|
1120
|
-
morph = Metamorph(result());
|
1121
|
-
update = function() {
|
1122
|
-
var binding, child, object, _i, _j, _len, _len1, _ref, _ref1, _ref2, _results;
|
1123
|
-
if (morph.isRemoved()) {
|
1124
|
-
_ref = morph.__bindings;
|
1125
|
-
_results = [];
|
1126
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1127
|
-
_ref1 = _ref[_i], object = _ref1[0], binding = _ref1[1];
|
1128
|
-
_results.push(object.unbind(binding));
|
1129
|
-
}
|
1130
|
-
return _results;
|
1131
|
-
} else {
|
1132
|
-
_ref2 = stack.children;
|
1133
|
-
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
|
1134
|
-
child = _ref2[_j];
|
1135
|
-
_this.__removeMetamorphs(child);
|
1136
|
-
}
|
1137
|
-
stack.children = [];
|
1138
|
-
return morph.html(result());
|
1139
|
-
}
|
1140
|
-
};
|
1141
|
-
update = update.debounce(0);
|
1142
|
-
for (key in locals) {
|
1143
|
-
object = locals[key];
|
1144
|
-
if (locals.hasOwnProperty(key)) {
|
1145
|
-
if (((object != null ? object.bind : void 0) != null) && ((object != null ? object.unbind : void 0) != null)) {
|
1146
|
-
binding = [object, object.bind('changed', update)];
|
1147
|
-
stack.metamorphBindings.push(binding);
|
1148
|
-
}
|
1149
|
-
}
|
1150
|
-
}
|
1151
|
-
morph.__bindings = stack.metamorphBindings;
|
1152
|
-
return morph.outerHTML();
|
1153
|
-
} else {
|
1154
|
-
return result();
|
1155
|
-
}
|
1156
|
-
},
|
1157
|
-
__renderingStackElement: function(parent) {
|
1158
|
-
if (parent == null) {
|
1159
|
-
parent = null;
|
1160
|
-
}
|
1161
|
-
return {
|
1162
|
-
metamorphBindings: [],
|
1163
|
-
locals: null,
|
1164
|
-
template: null,
|
1165
|
-
children: [],
|
1166
|
-
parent: parent
|
1167
|
-
};
|
1168
|
-
},
|
1169
|
-
__renderingStackChildFor: function(parentPointer) {
|
1170
|
-
var element;
|
1171
|
-
if (!this.__renderingStack) {
|
1172
|
-
this.__renderingStack = [];
|
1173
|
-
}
|
1174
|
-
if (!parentPointer) {
|
1175
|
-
element = this.__renderingStackElement();
|
1176
|
-
this.__renderingStack.push(element);
|
1177
|
-
return element;
|
1178
|
-
} else {
|
1179
|
-
element = this.__renderingStackElement(parentPointer);
|
1180
|
-
parentPointer.children.push(element);
|
1181
|
-
return element;
|
1182
|
-
}
|
1183
|
-
},
|
1184
|
-
__removeMetamorphs: function(stackPointer) {
|
1185
|
-
var remove, _ref,
|
1186
|
-
_this = this;
|
1187
|
-
if (stackPointer == null) {
|
1188
|
-
stackPointer = false;
|
1189
|
-
}
|
1190
|
-
remove = function(stackPointer) {
|
1191
|
-
var callback, child, object, _i, _j, _len, _len1, _ref, _ref1, _ref2;
|
1192
|
-
if (stackPointer != null ? stackPointer.children : void 0) {
|
1193
|
-
_ref = stackPointer.children;
|
1194
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1195
|
-
child = _ref[_i];
|
1196
|
-
_this.__removeMetamorphs(child);
|
1197
|
-
}
|
1198
|
-
}
|
1199
|
-
if (stackPointer != null ? stackPointer.metamorphBindings : void 0) {
|
1200
|
-
_ref1 = stackPointer.metamorphBindings;
|
1201
|
-
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
1202
|
-
_ref2 = _ref1[_j], object = _ref2[0], callback = _ref2[1];
|
1203
|
-
object.unbind(callback);
|
1204
|
-
}
|
1205
|
-
return stackPointer.metamorphBindings = [];
|
1206
|
-
}
|
1207
|
-
};
|
1208
|
-
if (!stackPointer) {
|
1209
|
-
return (_ref = this.__renderingStack) != null ? _ref.each(function(stackPointer) {
|
1210
|
-
return remove(stackPointer);
|
1211
|
-
}) : void 0;
|
1212
|
-
} else {
|
1213
|
-
return remove(stackPointer);
|
1214
|
-
}
|
1215
|
-
}
|
1216
|
-
};
|
1217
|
-
|
1218
|
-
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
|
1219
|
-
define('joosy/modules/renderer', function() {
|
1220
|
-
return Joosy.Modules.Renderer;
|
1221
|
-
});
|
1222
|
-
}
|
1223
|
-
|
1224
|
-
}).call(this);
|
1225
|
-
(function() {
|
1226
|
-
Joosy.Modules.TimeManager = {
|
1227
|
-
setTimeout: function(timeout, action) {
|
1228
|
-
var timer,
|
1229
|
-
_this = this;
|
1230
|
-
this.__timeouts || (this.__timeouts = []);
|
1231
|
-
timer = window.setTimeout((function() {
|
1232
|
-
return action();
|
1233
|
-
}), timeout);
|
1234
|
-
this.__timeouts.push(timer);
|
1235
|
-
return timer;
|
1236
|
-
},
|
1237
|
-
setInterval: function(delay, action) {
|
1238
|
-
var timer,
|
1239
|
-
_this = this;
|
1240
|
-
this.__intervals || (this.__intervals = []);
|
1241
|
-
timer = window.setInterval((function() {
|
1242
|
-
return action();
|
1243
|
-
}), delay);
|
1244
|
-
this.__intervals.push(timer);
|
1245
|
-
return timer;
|
1246
|
-
},
|
1247
|
-
clearTimeout: function(timer) {
|
1248
|
-
return window.clearTimeout(timer);
|
1249
|
-
},
|
1250
|
-
clearInterval: function(timer) {
|
1251
|
-
return window.clearInterval(timer);
|
1252
|
-
},
|
1253
|
-
__clearTime: function() {
|
1254
|
-
var entry, _i, _j, _len, _len1, _ref, _ref1, _results;
|
1255
|
-
if (this.__intervals) {
|
1256
|
-
_ref = this.__intervals;
|
1257
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1258
|
-
entry = _ref[_i];
|
1259
|
-
window.clearInterval(entry);
|
1260
|
-
}
|
1261
|
-
}
|
1262
|
-
if (this.__timeouts) {
|
1263
|
-
_ref1 = this.__timeouts;
|
1264
|
-
_results = [];
|
1265
|
-
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
1266
|
-
entry = _ref1[_j];
|
1267
|
-
_results.push(window.clearTimeout(entry));
|
1268
|
-
}
|
1269
|
-
return _results;
|
1270
|
-
}
|
1271
|
-
}
|
1272
|
-
};
|
1273
|
-
|
1274
|
-
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
|
1275
|
-
define('joosy/modules/time_manager', function() {
|
1276
|
-
return Joosy.Modules.TimeManager;
|
1277
|
-
});
|
1278
|
-
}
|
1279
|
-
|
1280
|
-
}).call(this);
|
1281
|
-
(function() {
|
1282
|
-
var __slice = [].slice;
|
1283
|
-
|
1284
|
-
Joosy.Modules.Filters = {
|
1285
|
-
included: function() {
|
1286
|
-
var _this = this;
|
1287
|
-
this.__registerFilterCollector = function(filter) {
|
1288
|
-
_this[filter] = function(callback) {
|
1289
|
-
if (!this.prototype.hasOwnProperty("__" + filter + "s")) {
|
1290
|
-
this.prototype["__" + filter + "s"] = [].concat(this.__super__["__" + filter + "s"] || []);
|
1291
|
-
}
|
1292
|
-
return this.prototype["__" + filter + "s"].push(callback);
|
1293
|
-
};
|
1294
|
-
return filter.charAt(0).toUpperCase() + filter.slice(1);
|
1295
|
-
};
|
1296
|
-
this.registerPlainFilters = function() {
|
1297
|
-
var filters;
|
1298
|
-
filters = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
1299
|
-
return filters.each(function(filter) {
|
1300
|
-
var camelized;
|
1301
|
-
camelized = _this.__registerFilterCollector(filter);
|
1302
|
-
_this.prototype["__run" + camelized + "s"] = function() {
|
1303
|
-
var callback, params, _i, _len, _ref, _results;
|
1304
|
-
params = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
1305
|
-
if (!this["__" + filter + "s"]) {
|
1306
|
-
return;
|
1307
|
-
}
|
1308
|
-
_ref = this["__" + filter + "s"];
|
1309
|
-
_results = [];
|
1310
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1311
|
-
callback = _ref[_i];
|
1312
|
-
if (typeof callback !== 'function') {
|
1313
|
-
callback = this[callback];
|
1314
|
-
}
|
1315
|
-
_results.push(callback.apply(this, params));
|
1316
|
-
}
|
1317
|
-
return _results;
|
1318
|
-
};
|
1319
|
-
_this.prototype["__confirm" + camelized + "s"] = function() {
|
1320
|
-
var params,
|
1321
|
-
_this = this;
|
1322
|
-
params = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
1323
|
-
if (!this["__" + filter + "s"]) {
|
1324
|
-
return true;
|
1325
|
-
}
|
1326
|
-
return this["__" + filter + "s"].reduce(function(flag, callback) {
|
1327
|
-
if (typeof callback !== 'function') {
|
1328
|
-
callback = _this[callback];
|
1329
|
-
}
|
1330
|
-
return flag && callback.apply(_this, params) !== false;
|
1331
|
-
}, true);
|
1332
|
-
};
|
1333
|
-
return _this.prototype["__apply" + camelized + "s"] = function() {
|
1334
|
-
var callback, data, params, _i, _len, _ref;
|
1335
|
-
data = arguments[0], params = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
1336
|
-
if (!this["__" + filter + "s"]) {
|
1337
|
-
return data;
|
1338
|
-
}
|
1339
|
-
_ref = this["__" + filter + "s"];
|
1340
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1341
|
-
callback = _ref[_i];
|
1342
|
-
if (typeof callback !== 'function') {
|
1343
|
-
callback = this[callback];
|
1344
|
-
}
|
1345
|
-
data = callback.apply(this, [data].concat(params));
|
1346
|
-
}
|
1347
|
-
return data;
|
1348
|
-
};
|
1349
|
-
});
|
1350
|
-
};
|
1351
|
-
return this.registerSequencedFilters = function() {
|
1352
|
-
var filters;
|
1353
|
-
filters = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
1354
|
-
return filters.each(function(filter) {
|
1355
|
-
var camelized;
|
1356
|
-
camelized = _this.__registerFilterCollector(filter);
|
1357
|
-
return _this.prototype["__run" + camelized + "s"] = function(params, callback) {
|
1358
|
-
var filterer, runners;
|
1359
|
-
if (!this["__" + filter + "s"]) {
|
1360
|
-
return callback();
|
1361
|
-
}
|
1362
|
-
runners = this["__" + filter + "s"];
|
1363
|
-
filterer = this;
|
1364
|
-
if (runners.length === 1) {
|
1365
|
-
return runners[0].apply(this, params.include(callback));
|
1366
|
-
}
|
1367
|
-
return Joosy.synchronize(function(context) {
|
1368
|
-
runners.each(function(runner) {
|
1369
|
-
return context["do"](function(done) {
|
1370
|
-
return runner.apply(filterer, params.include(done));
|
1371
|
-
});
|
1372
|
-
});
|
1373
|
-
return context.after(callback);
|
1374
|
-
});
|
1375
|
-
};
|
1376
|
-
});
|
1377
|
-
};
|
1378
|
-
}
|
1379
|
-
};
|
1380
|
-
|
1381
|
-
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
|
1382
|
-
define('joosy/modules/filters', function() {
|
1383
|
-
return Joosy.Modules.Filters;
|
1384
|
-
});
|
1385
|
-
}
|
1386
|
-
|
1387
|
-
}).call(this);
|
1388
|
-
(function() {
|
1389
|
-
var __hasProp = {}.hasOwnProperty,
|
1390
|
-
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
1391
|
-
|
1392
|
-
Joosy.Widget = (function(_super) {
|
1393
|
-
__extends(Widget, _super);
|
1394
|
-
|
1395
|
-
Widget.include(Joosy.Modules.Log);
|
1396
|
-
|
1397
|
-
Widget.include(Joosy.Modules.Events);
|
1398
|
-
|
1399
|
-
Widget.include(Joosy.Modules.DOM);
|
1400
|
-
|
1401
|
-
Widget.include(Joosy.Modules.Renderer);
|
1402
|
-
|
1403
|
-
Widget.include(Joosy.Modules.TimeManager);
|
1404
|
-
|
1405
|
-
Widget.include(Joosy.Modules.Filters);
|
1406
|
-
|
1407
|
-
Widget.mapWidgets = function(map) {
|
1408
|
-
if (!this.prototype.hasOwnProperty("__widgets")) {
|
1409
|
-
this.prototype.__widgets = Object.clone(this.__super__.__widgets) || {};
|
1410
|
-
}
|
1411
|
-
return Object.merge(this.prototype.__widgets, map);
|
1412
|
-
};
|
1413
|
-
|
1414
|
-
Widget.independent = function() {
|
1415
|
-
return this.prototype.__independent = true;
|
1416
|
-
};
|
1417
|
-
|
1418
|
-
Widget.registerPlainFilters('beforeLoad', 'afterLoad', 'afterUnload');
|
1419
|
-
|
1420
|
-
Widget.registerSequencedFilters('beforePaint', 'paint', 'erase', 'fetch');
|
1421
|
-
|
1422
|
-
function Widget(params, previous) {
|
1423
|
-
this.params = params;
|
1424
|
-
this.previous = previous;
|
1425
|
-
}
|
1426
|
-
|
1427
|
-
Widget.prototype.registerWidget = function($container, widget) {
|
1428
|
-
if (Object.isString($container)) {
|
1429
|
-
$container = this.__normalizeSelector($container);
|
1430
|
-
}
|
1431
|
-
widget = this.__normalizeWidget(widget);
|
1432
|
-
widget.__bootstrapDefault(this, $container);
|
1433
|
-
return widget;
|
1434
|
-
};
|
1435
|
-
|
1436
|
-
Widget.prototype.unregisterWidget = function(widget) {
|
1437
|
-
return widget.__unload();
|
1438
|
-
};
|
1439
|
-
|
1440
|
-
Widget.prototype.replaceWidget = function(widget, replacement) {
|
1441
|
-
replacement = this.__normalizeWidget(replacement);
|
1442
|
-
replacement.previous = widget;
|
1443
|
-
replacement.__bootstrapDefault(this, widget.$container);
|
1444
|
-
return replacement;
|
1445
|
-
};
|
1446
|
-
|
1447
|
-
Widget.prototype.navigate = function() {
|
1448
|
-
var _ref;
|
1449
|
-
return (_ref = Joosy.Router) != null ? _ref.navigate.apply(_ref, arguments) : void 0;
|
1450
|
-
};
|
1451
|
-
|
1452
|
-
Widget.prototype.__renderSection = function() {
|
1453
|
-
return 'widgets';
|
1454
|
-
};
|
1455
|
-
|
1456
|
-
Widget.prototype.__nestingMap = function() {
|
1457
|
-
var map, selector, widget, _ref;
|
1458
|
-
map = {};
|
1459
|
-
_ref = this.__widgets;
|
1460
|
-
for (selector in _ref) {
|
1461
|
-
widget = _ref[selector];
|
1462
|
-
widget = this.__normalizeWidget(widget);
|
1463
|
-
map[selector] = {
|
1464
|
-
instance: widget,
|
1465
|
-
nested: widget.__nestingMap()
|
1466
|
-
};
|
1467
|
-
}
|
1468
|
-
return map;
|
1469
|
-
};
|
1470
|
-
|
1471
|
-
Widget.prototype.__bootstrapDefault = function(parent, $container) {
|
1472
|
-
return this.__bootstrap(parent, this.__nestingMap(), $container);
|
1473
|
-
};
|
1474
|
-
|
1475
|
-
Widget.prototype.__bootstrap = function(parent, nestingMap, $container, fetch) {
|
1476
|
-
var _this = this;
|
1477
|
-
this.$container = $container;
|
1478
|
-
if (fetch == null) {
|
1479
|
-
fetch = true;
|
1480
|
-
}
|
1481
|
-
this.wait('section:fetched section:erased', function() {
|
1482
|
-
return _this.__runPaints([], function() {
|
1483
|
-
return _this.__paint(parent, nestingMap, _this.$container);
|
1484
|
-
});
|
1485
|
-
});
|
1486
|
-
this.__erase();
|
1487
|
-
if (fetch) {
|
1488
|
-
return this.__fetch(nestingMap);
|
1489
|
-
}
|
1490
|
-
};
|
1491
|
-
|
1492
|
-
Widget.prototype.__fetch = function(nestingMap) {
|
1493
|
-
var _this = this;
|
1494
|
-
this.data = {};
|
1495
|
-
return this.synchronize(function(context) {
|
1496
|
-
Object.each(nestingMap, function(selector, section) {
|
1497
|
-
section.instance.__fetch(section.nested);
|
1498
|
-
if (!section.instance.__independent) {
|
1499
|
-
return context["do"](function(done) {
|
1500
|
-
return section.instance.wait('section:fetched', done);
|
1501
|
-
});
|
1502
|
-
}
|
1503
|
-
});
|
1504
|
-
context["do"](function(done) {
|
1505
|
-
return _this.__runFetchs([], done);
|
1506
|
-
});
|
1507
|
-
return context.after(function() {
|
1508
|
-
return _this.trigger({
|
1509
|
-
name: 'section:fetched',
|
1510
|
-
remember: true
|
1511
|
-
});
|
1512
|
-
});
|
1513
|
-
});
|
1514
|
-
};
|
1515
|
-
|
1516
|
-
Widget.prototype.__erase = function(parent) {
|
1517
|
-
var _this = this;
|
1518
|
-
if (this.previous != null) {
|
1519
|
-
return this.previous.__runErases([], function() {
|
1520
|
-
_this.previous.__unload();
|
1521
|
-
return _this.__runBeforePaints([], function() {
|
1522
|
-
return _this.trigger({
|
1523
|
-
name: 'section:erased',
|
1524
|
-
remember: true
|
1525
|
-
});
|
1526
|
-
});
|
1527
|
-
});
|
1528
|
-
} else {
|
1529
|
-
return this.__runBeforePaints([], function() {
|
1530
|
-
return _this.trigger({
|
1531
|
-
name: 'section:erased',
|
1532
|
-
remember: true
|
1533
|
-
});
|
1534
|
-
});
|
1535
|
-
}
|
1536
|
-
};
|
1537
|
-
|
1538
|
-
Widget.prototype.__paint = function(parent, nestingMap, $container) {
|
1539
|
-
var _this = this;
|
1540
|
-
this.parent = parent;
|
1541
|
-
this.$container = $container;
|
1542
|
-
this.__nestedSections = [];
|
1543
|
-
this.$container.html(typeof this.__renderDefault === "function" ? this.__renderDefault(this.data || {}) : void 0);
|
1544
|
-
this.__load();
|
1545
|
-
return Object.each(nestingMap, function(selector, section) {
|
1546
|
-
var _ref;
|
1547
|
-
$container = _this.__normalizeSelector(selector);
|
1548
|
-
if (!section.instance.__independent || ((_ref = section.instance.__triggeredEvents) != null ? _ref['section:fetched'] : void 0)) {
|
1549
|
-
return section.instance.__paint(_this, section.nested, $container);
|
1550
|
-
} else {
|
1551
|
-
return section.instance.__bootstrap(_this, section.nested, $container, false);
|
1552
|
-
}
|
1553
|
-
});
|
1554
|
-
};
|
1555
|
-
|
1556
|
-
Widget.prototype.__load = function() {
|
1557
|
-
var _base;
|
1558
|
-
if (this.parent) {
|
1559
|
-
(_base = this.parent).__nestedSections || (_base.__nestedSections = []);
|
1560
|
-
this.parent.__nestedSections.push(this);
|
1561
|
-
}
|
1562
|
-
this.__assignElements();
|
1563
|
-
this.__delegateEvents();
|
1564
|
-
return this.__runAfterLoads();
|
1565
|
-
};
|
1566
|
-
|
1567
|
-
Widget.prototype.__unload = function(modifyParent) {
|
1568
|
-
var section, _i, _len, _ref;
|
1569
|
-
if (modifyParent == null) {
|
1570
|
-
modifyParent = true;
|
1571
|
-
}
|
1572
|
-
if (this.__nestedSections) {
|
1573
|
-
_ref = this.__nestedSections;
|
1574
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1575
|
-
section = _ref[_i];
|
1576
|
-
section.__unload(false);
|
1577
|
-
}
|
1578
|
-
delete this.__nestedSections;
|
1579
|
-
}
|
1580
|
-
this.__clearContainer();
|
1581
|
-
this.__clearTime();
|
1582
|
-
this.__removeMetamorphs();
|
1583
|
-
this.__runAfterUnloads();
|
1584
|
-
if (this.parent && modifyParent) {
|
1585
|
-
this.parent.__nestedSections.splice(this.parent.__nestedSections.indexOf(this), 1);
|
1586
|
-
}
|
1587
|
-
delete this.previous;
|
1588
|
-
return delete this.parent;
|
1589
|
-
};
|
1590
|
-
|
1591
|
-
Widget.prototype.__normalizeSelector = function(selector) {
|
1592
|
-
if (selector === '$container') {
|
1593
|
-
return this.$container;
|
1594
|
-
} else {
|
1595
|
-
return $(this.__extractSelector(selector), this.$container);
|
1596
|
-
}
|
1597
|
-
};
|
1598
|
-
|
1599
|
-
Widget.prototype.__normalizeWidget = function(widget) {
|
1600
|
-
if (Object.isFunction(widget) && !Joosy.Module.hasAncestor(widget, Joosy.Widget)) {
|
1601
|
-
widget = widget.call(this);
|
1602
|
-
}
|
1603
|
-
if (Joosy.Module.hasAncestor(widget, Joosy.Widget)) {
|
1604
|
-
widget = new widget;
|
1605
|
-
}
|
1606
|
-
return widget;
|
1607
|
-
};
|
1608
|
-
|
1609
|
-
return Widget;
|
1610
|
-
|
1611
|
-
})(Joosy.Module);
|
1612
|
-
|
1613
|
-
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
|
1614
|
-
define('joosy/widget', function() {
|
1615
|
-
return Joosy.Widget;
|
1616
|
-
});
|
1617
|
-
}
|
1618
|
-
|
1619
|
-
}).call(this);
|
1620
|
-
(function() {
|
1621
|
-
Joosy.helpers('Application', function() {
|
1622
|
-
var DOMnative, DOMtext;
|
1623
|
-
DOMtext = document.createTextNode("test");
|
1624
|
-
DOMnative = document.createElement("span");
|
1625
|
-
DOMnative.appendChild(DOMtext);
|
1626
|
-
this.escapeOnce = function(html) {
|
1627
|
-
DOMtext.nodeValue = html;
|
1628
|
-
return DOMnative.innerHTML;
|
1629
|
-
};
|
1630
|
-
this.tag = function(name, options, open, escape) {
|
1631
|
-
var element, tag, temp, value;
|
1632
|
-
if (options == null) {
|
1633
|
-
options = {};
|
1634
|
-
}
|
1635
|
-
if (open == null) {
|
1636
|
-
open = false;
|
1637
|
-
}
|
1638
|
-
if (escape == null) {
|
1639
|
-
escape = true;
|
1640
|
-
}
|
1641
|
-
element = document.createElement(name);
|
1642
|
-
temp = document.createElement('div');
|
1643
|
-
for (name in options) {
|
1644
|
-
value = options[name];
|
1645
|
-
if (escape) {
|
1646
|
-
value = this.escapeOnce(value);
|
1647
|
-
}
|
1648
|
-
element.setAttribute(name, value);
|
1649
|
-
}
|
1650
|
-
temp.appendChild(element);
|
1651
|
-
tag = temp.innerHTML;
|
1652
|
-
if (open) {
|
1653
|
-
tag = tag.replace('/>', '>');
|
1654
|
-
}
|
1655
|
-
return tag;
|
1656
|
-
};
|
1657
|
-
this.contentTag = function(name, contentOrOptions, options, escape) {
|
1658
|
-
var content, e, element, temp, value;
|
1659
|
-
if (contentOrOptions == null) {
|
1660
|
-
contentOrOptions = null;
|
1661
|
-
}
|
1662
|
-
if (options == null) {
|
1663
|
-
options = null;
|
1664
|
-
}
|
1665
|
-
if (escape == null) {
|
1666
|
-
escape = true;
|
1667
|
-
}
|
1668
|
-
if (Object.isString(contentOrOptions)) {
|
1669
|
-
options || (options = {});
|
1670
|
-
content = contentOrOptions;
|
1671
|
-
} else if (Object.isObject(contentOrOptions)) {
|
1672
|
-
if (Object.isFunction(options)) {
|
1673
|
-
escape = true;
|
1674
|
-
content = options();
|
1675
|
-
} else {
|
1676
|
-
escape = options;
|
1677
|
-
content = escape();
|
1678
|
-
}
|
1679
|
-
options = contentOrOptions;
|
1680
|
-
} else {
|
1681
|
-
options = {};
|
1682
|
-
content = contentOrOptions();
|
1683
|
-
}
|
1684
|
-
element = document.createElement(name);
|
1685
|
-
temp = document.createElement('div');
|
1686
|
-
for (name in options) {
|
1687
|
-
value = options[name];
|
1688
|
-
if (escape) {
|
1689
|
-
value = this.escapeOnce(value);
|
1690
|
-
}
|
1691
|
-
element.setAttribute(name, value);
|
1692
|
-
}
|
1693
|
-
try {
|
1694
|
-
element.innerHTML = content;
|
1695
|
-
} catch (_error) {
|
1696
|
-
e = _error;
|
1697
|
-
if (content) {
|
1698
|
-
throw e;
|
1699
|
-
}
|
1700
|
-
}
|
1701
|
-
temp.appendChild(element);
|
1702
|
-
return temp.innerHTML;
|
1703
|
-
};
|
1704
|
-
return this.renderWrapped = function(template, lambda) {
|
1705
|
-
return this.render(template, Joosy.Module.merge(this, {
|
1706
|
-
"yield": lambda()
|
1707
|
-
}));
|
1708
|
-
};
|
1709
|
-
});
|
1710
|
-
|
1711
|
-
}).call(this);
|
1712
|
-
(function() {
|
1713
|
-
var __hasProp = {}.hasOwnProperty,
|
1714
|
-
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
1715
|
-
|
1716
|
-
Joosy.Layout = (function(_super) {
|
1717
|
-
__extends(Layout, _super);
|
1718
|
-
|
1719
|
-
Layout.helper('page');
|
1720
|
-
|
1721
|
-
function Layout(params, previous) {
|
1722
|
-
this.params = params;
|
1723
|
-
this.previous = previous;
|
1724
|
-
this.uid = Joosy.uid();
|
1725
|
-
}
|
1726
|
-
|
1727
|
-
Layout.prototype.page = function(tag, options) {
|
1728
|
-
if (options == null) {
|
1729
|
-
options = {};
|
1730
|
-
}
|
1731
|
-
options.id = this.uid;
|
1732
|
-
return Joosy.Helpers.Application.tag(tag, options);
|
1733
|
-
};
|
1734
|
-
|
1735
|
-
Layout.prototype.content = function() {
|
1736
|
-
return $("#" + this.uid);
|
1737
|
-
};
|
1738
|
-
|
1739
|
-
Layout.prototype.__renderSection = function() {
|
1740
|
-
return 'layouts';
|
1741
|
-
};
|
1742
|
-
|
1743
|
-
Layout.prototype.__nestingMap = function(page) {
|
1744
|
-
var map;
|
1745
|
-
map = Layout.__super__.__nestingMap.call(this);
|
1746
|
-
map["#" + this.uid] = {
|
1747
|
-
instance: page,
|
1748
|
-
nested: page.__nestingMap()
|
1749
|
-
};
|
1750
|
-
return map;
|
1751
|
-
};
|
1752
|
-
|
1753
|
-
Layout.prototype.__bootstrapDefault = function(page, applicationContainer) {
|
1754
|
-
return this.__bootstrap(null, this.__nestingMap(page), applicationContainer);
|
1755
|
-
};
|
1756
|
-
|
1757
|
-
return Layout;
|
1758
|
-
|
1759
|
-
})(Joosy.Widget);
|
1760
|
-
|
1761
|
-
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
|
1762
|
-
define('joosy/layout', function() {
|
1763
|
-
return Joosy.Layout;
|
1764
|
-
});
|
1765
|
-
}
|
1766
|
-
|
1767
|
-
}).call(this);
|
1768
|
-
(function() {
|
1769
|
-
Joosy.Modules.Page = {};
|
1770
|
-
|
1771
|
-
}).call(this);
|
1772
|
-
(function() {
|
1773
|
-
Joosy.Modules.Page.Scrolling = {
|
1774
|
-
included: function() {
|
1775
|
-
this.scroll = function(element, options) {
|
1776
|
-
if (options == null) {
|
1777
|
-
options = {};
|
1778
|
-
}
|
1779
|
-
this.prototype.__scrollElement = element;
|
1780
|
-
this.prototype.__scrollSpeed = options.speed || 500;
|
1781
|
-
return this.prototype.__scrollMargin = options.margin || 0;
|
1782
|
-
};
|
1783
|
-
this.paint(function(complete) {
|
1784
|
-
if (this.__scrollElement && this.__scrollSpeed !== 0) {
|
1785
|
-
this.__fixHeight();
|
1786
|
-
}
|
1787
|
-
return complete();
|
1788
|
-
});
|
1789
|
-
return this.afterLoad(function() {
|
1790
|
-
if (this.__scrollElement) {
|
1791
|
-
return this.__performScrolling();
|
1792
|
-
}
|
1793
|
-
});
|
1794
|
-
},
|
1795
|
-
__performScrolling: function() {
|
1796
|
-
var scroll, _ref,
|
1797
|
-
_this = this;
|
1798
|
-
scroll = ((_ref = $(this.__extractSelector(this.__scrollElement)).offset()) != null ? _ref.top : void 0) + this.__scrollMargin;
|
1799
|
-
Joosy.Modules.Log.debugAs(this, "Scrolling to " + (this.__extractSelector(this.__scrollElement)));
|
1800
|
-
return $('html, body').animate({
|
1801
|
-
scrollTop: scroll
|
1802
|
-
}, this.__scrollSpeed, function() {
|
1803
|
-
if (_this.__scrollSpeed !== 0) {
|
1804
|
-
return _this.__releaseHeight();
|
1805
|
-
}
|
1806
|
-
});
|
1807
|
-
},
|
1808
|
-
__fixHeight: function() {
|
1809
|
-
return $('html').css('min-height', $(document).height());
|
1810
|
-
},
|
1811
|
-
__releaseHeight: function() {
|
1812
|
-
return $('html').css('min-height', '');
|
1813
|
-
}
|
1814
|
-
};
|
1815
|
-
|
1816
|
-
}).call(this);
|
1817
|
-
(function() {
|
1818
|
-
Joosy.Modules.Page.Title = {
|
1819
|
-
title: function(title, separator) {
|
1820
|
-
if (separator == null) {
|
1821
|
-
separator = ' / ';
|
1822
|
-
}
|
1823
|
-
this.afterLoad(function() {
|
1824
|
-
var titleStr;
|
1825
|
-
titleStr = Object.isFunction(title) ? title.apply(this) : title;
|
1826
|
-
if (Object.isArray(titleStr)) {
|
1827
|
-
titleStr = titleStr.join(separator);
|
1828
|
-
}
|
1829
|
-
this.__previousTitle = document.title;
|
1830
|
-
return document.title = titleStr;
|
1831
|
-
});
|
1832
|
-
return this.afterUnload(function() {
|
1833
|
-
return document.title = this.__previousTitle;
|
1834
|
-
});
|
1835
|
-
}
|
1836
|
-
};
|
1837
|
-
|
1838
|
-
}).call(this);
|
1839
|
-
(function() {
|
1840
|
-
var __hasProp = {}.hasOwnProperty,
|
1841
|
-
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
1842
|
-
|
1843
|
-
Joosy.Page = (function(_super) {
|
1844
|
-
__extends(Page, _super);
|
1845
|
-
|
1846
|
-
Page.layout = function(layoutClass) {
|
1847
|
-
return this.prototype.__layoutClass = layoutClass;
|
1848
|
-
};
|
1849
|
-
|
1850
|
-
Page.include(Joosy.Modules.Page.Scrolling);
|
1851
|
-
|
1852
|
-
Page.extend(Joosy.Modules.Page.Title);
|
1853
|
-
|
1854
|
-
function Page(params, previous) {
|
1855
|
-
var _ref;
|
1856
|
-
this.params = params;
|
1857
|
-
this.previous = previous;
|
1858
|
-
this.layoutShouldChange = ((_ref = this.previous) != null ? _ref.__layoutClass : void 0) !== this.__layoutClass;
|
1859
|
-
this.halted = !this.__confirmBeforeLoads();
|
1860
|
-
this.layout = (function() {
|
1861
|
-
var _ref1, _ref2;
|
1862
|
-
switch (false) {
|
1863
|
-
case !(this.layoutShouldChange && this.__layoutClass):
|
1864
|
-
return new this.__layoutClass(params, (_ref1 = this.previous) != null ? _ref1.layout : void 0);
|
1865
|
-
case !!this.layoutShouldChange:
|
1866
|
-
return (_ref2 = this.previous) != null ? _ref2.layout : void 0;
|
1867
|
-
}
|
1868
|
-
}).call(this);
|
1869
|
-
if (this.layoutShouldChange && !this.layout) {
|
1870
|
-
this.previous = this.previous.layout;
|
1871
|
-
}
|
1872
|
-
}
|
1873
|
-
|
1874
|
-
Page.prototype.__renderSection = function() {
|
1875
|
-
return 'pages';
|
1876
|
-
};
|
1877
|
-
|
1878
|
-
Page.prototype.__bootstrapDefault = function(applicationContainer) {
|
1879
|
-
var _ref;
|
1880
|
-
return this.__bootstrap(this.layout, this.__nestingMap(), ((_ref = this.layout) != null ? _ref.content() : void 0) || applicationContainer);
|
1881
|
-
};
|
1882
|
-
|
1883
|
-
return Page;
|
1884
|
-
|
1885
|
-
})(Joosy.Widget);
|
1886
|
-
|
1887
|
-
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
|
1888
|
-
define('joosy/page', function() {
|
1889
|
-
return Joosy.Page;
|
1890
|
-
});
|
1891
|
-
}
|
1892
|
-
|
1893
|
-
}).call(this);
|
1894
|
-
(function() {
|
1895
|
-
Joosy.helpers('Routes', function() {
|
1896
|
-
return this.linkTo = function(name, url, tagOptions) {
|
1897
|
-
var block, _ref;
|
1898
|
-
if (name == null) {
|
1899
|
-
name = '';
|
1900
|
-
}
|
1901
|
-
if (url == null) {
|
1902
|
-
url = '';
|
1903
|
-
}
|
1904
|
-
if (tagOptions == null) {
|
1905
|
-
tagOptions = {};
|
1906
|
-
}
|
1907
|
-
if (Object.isFunction(tagOptions)) {
|
1908
|
-
block = tagOptions;
|
1909
|
-
_ref = [name, url], url = _ref[0], tagOptions = _ref[1];
|
1910
|
-
name = block();
|
1911
|
-
}
|
1912
|
-
return Joosy.Helpers.Application.contentTag('a', name, Joosy.Module.merge(tagOptions, {
|
1913
|
-
'data-joosy': true,
|
1914
|
-
href: url
|
1915
|
-
}));
|
1916
|
-
};
|
1917
|
-
});
|
1918
|
-
|
1919
|
-
}).call(this);
|
1920
|
-
(function() {
|
1921
|
-
var _ref,
|
1922
|
-
__hasProp = {}.hasOwnProperty,
|
1923
|
-
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
1924
|
-
|
1925
|
-
Joosy.Router = (function(_super) {
|
1926
|
-
var Drawer,
|
1927
|
-
_this = this;
|
1928
|
-
|
1929
|
-
__extends(Router, _super);
|
1930
|
-
|
1931
|
-
function Router() {
|
1932
|
-
_ref = Router.__super__.constructor.apply(this, arguments);
|
1933
|
-
return _ref;
|
1934
|
-
}
|
1935
|
-
|
1936
|
-
Router.extend(Joosy.Modules.Events);
|
1937
|
-
|
1938
|
-
$(window).bind('popstate', function(event) {
|
1939
|
-
if (window.history.loaded != null) {
|
1940
|
-
return Router.trigger('popstate', event);
|
1941
|
-
} else {
|
1942
|
-
return window.history.loaded = true;
|
1943
|
-
}
|
1944
|
-
});
|
1945
|
-
|
1946
|
-
$(document).on('click', 'a[data-joosy]', function(event) {
|
1947
|
-
event.preventDefault();
|
1948
|
-
return Joosy.Router.navigate(this.getAttribute('href'));
|
1949
|
-
});
|
1950
|
-
|
1951
|
-
Drawer = (function() {
|
1952
|
-
Drawer.run = function(block, namespace, alias) {
|
1953
|
-
var context;
|
1954
|
-
if (namespace == null) {
|
1955
|
-
namespace = '';
|
1956
|
-
}
|
1957
|
-
if (alias == null) {
|
1958
|
-
alias = '';
|
1959
|
-
}
|
1960
|
-
context = new Drawer(namespace, alias);
|
1961
|
-
return block.call(context);
|
1962
|
-
};
|
1963
|
-
|
1964
|
-
function Drawer(__namespace, __alias) {
|
1965
|
-
this.__namespace = __namespace;
|
1966
|
-
this.__alias = __alias;
|
1967
|
-
}
|
1968
|
-
|
1969
|
-
Drawer.prototype.match = function(route, options) {
|
1970
|
-
var as;
|
1971
|
-
if (options == null) {
|
1972
|
-
options = {};
|
1973
|
-
}
|
1974
|
-
if (options.as != null) {
|
1975
|
-
if (this.__alias) {
|
1976
|
-
as = this.__alias + options.as.charAt(0).toUpperCase() + options.as.slice(1);
|
1977
|
-
} else {
|
1978
|
-
as = options.as;
|
1979
|
-
}
|
1980
|
-
}
|
1981
|
-
route = this.__namespace + route;
|
1982
|
-
return Joosy.Router.compileRoute(route, options.to, as);
|
1983
|
-
};
|
1984
|
-
|
1985
|
-
Drawer.prototype.root = function(options) {
|
1986
|
-
if (options == null) {
|
1987
|
-
options = {};
|
1988
|
-
}
|
1989
|
-
return this.match("/", {
|
1990
|
-
to: options.to,
|
1991
|
-
as: options.as || 'root'
|
1992
|
-
});
|
1993
|
-
};
|
1994
|
-
|
1995
|
-
Drawer.prototype.notFound = function(options) {
|
1996
|
-
if (options == null) {
|
1997
|
-
options = {};
|
1998
|
-
}
|
1999
|
-
return this.match(404, {
|
2000
|
-
to: options.to
|
2001
|
-
});
|
2002
|
-
};
|
2003
|
-
|
2004
|
-
Drawer.prototype.namespace = function(name, options, block) {
|
2005
|
-
var _ref1;
|
2006
|
-
if (options == null) {
|
2007
|
-
options = {};
|
2008
|
-
}
|
2009
|
-
if (Object.isFunction(options)) {
|
2010
|
-
block = options;
|
2011
|
-
options = {};
|
2012
|
-
}
|
2013
|
-
return Drawer.run(block, this.__namespace + name, (_ref1 = options.as) != null ? _ref1.toString() : void 0);
|
2014
|
-
};
|
2015
|
-
|
2016
|
-
return Drawer;
|
2017
|
-
|
2018
|
-
})();
|
2019
|
-
|
2020
|
-
Router.map = function(routes, namespace) {
|
2021
|
-
var _this = this;
|
2022
|
-
return Object.each(routes, function(path, to) {
|
2023
|
-
if (namespace != null) {
|
2024
|
-
path = namespace + '/' + path;
|
2025
|
-
}
|
2026
|
-
if (Object.isFunction(to) || to.prototype) {
|
2027
|
-
return _this.compileRoute(path, to);
|
2028
|
-
} else {
|
2029
|
-
return _this.map(to, path);
|
2030
|
-
}
|
2031
|
-
});
|
2032
|
-
};
|
2033
|
-
|
2034
|
-
Router.draw = function(block) {
|
2035
|
-
return Drawer.run(block);
|
2036
|
-
};
|
2037
|
-
|
2038
|
-
Router.setup = function(config, responder, respond) {
|
2039
|
-
var _base,
|
2040
|
-
_this = this;
|
2041
|
-
this.config = config;
|
2042
|
-
this.responder = responder;
|
2043
|
-
if (respond == null) {
|
2044
|
-
respond = true;
|
2045
|
-
}
|
2046
|
-
if (!history.pushState) {
|
2047
|
-
this.config.prefix = this.config.hashSuffix;
|
2048
|
-
this.config.html5 = false;
|
2049
|
-
}
|
2050
|
-
if (!this.config.html5) {
|
2051
|
-
this.config.prefix = this.config.hashSuffix;
|
2052
|
-
}
|
2053
|
-
(_base = this.config).prefix || (_base.prefix = '');
|
2054
|
-
if (this.config.html5) {
|
2055
|
-
this.config.prefix = ('/' + this.config.prefix + '/').replace(/\/{2,}/g, '/');
|
2056
|
-
this.listener = this.bind('popstate pushstate', function() {
|
2057
|
-
return _this.respond(_this.canonizeLocation());
|
2058
|
-
});
|
2059
|
-
} else {
|
2060
|
-
this.config.prefix = this.config.prefix.replace(/^\#?\/?/, '').replace(/\/?$/, '');
|
2061
|
-
$(window).bind('hashchange.JoosyRouter', function() {
|
2062
|
-
return _this.respond(_this.canonizeLocation());
|
2063
|
-
});
|
2064
|
-
}
|
2065
|
-
if (respond) {
|
2066
|
-
return this.respond(this.canonizeLocation());
|
2067
|
-
}
|
2068
|
-
};
|
2069
|
-
|
2070
|
-
Router.reset = function() {
|
2071
|
-
this.unbind(this.listener);
|
2072
|
-
$(window).unbind('.JoosyRouter');
|
2073
|
-
this.restriction = false;
|
2074
|
-
return this.routes = {};
|
2075
|
-
};
|
2076
|
-
|
2077
|
-
Router.restrict = function(restriction) {
|
2078
|
-
this.restriction = restriction;
|
2079
|
-
};
|
2080
|
-
|
2081
|
-
Router.navigate = function(to, options) {
|
2082
|
-
var path;
|
2083
|
-
if (options == null) {
|
2084
|
-
options = {};
|
2085
|
-
}
|
2086
|
-
path = to;
|
2087
|
-
if (this.config.html5) {
|
2088
|
-
if (this.config.prefix && path[0] === '/' && !path.match(RegExp("^" + (this.config.prefix.replace(/\/$/, '')) + "(/|$)"))) {
|
2089
|
-
path = path.replace(/^\//, this.config.prefix);
|
2090
|
-
}
|
2091
|
-
history.pushState({}, '', path);
|
2092
|
-
this.trigger('pushstate');
|
2093
|
-
} else {
|
2094
|
-
if (this.config.prefix && !path.match(RegExp("^#?/?" + this.config.prefix + "(/|$)"))) {
|
2095
|
-
path = path.replace(/^\#?\/?/, "" + this.config.prefix + "/");
|
2096
|
-
}
|
2097
|
-
location.hash = path;
|
2098
|
-
}
|
2099
|
-
};
|
2100
|
-
|
2101
|
-
Router.canonizeLocation = function() {
|
2102
|
-
if (this.config.html5) {
|
2103
|
-
return location.pathname.replace(RegExp("^(" + this.config.prefix + "?)?/?"), '/') + location.search;
|
2104
|
-
} else {
|
2105
|
-
return location.hash.replace(RegExp("^#?/?(" + this.config.prefix + "(/|$))?"), '/');
|
2106
|
-
}
|
2107
|
-
};
|
2108
|
-
|
2109
|
-
Router.compileRoute = function(path, to, as) {
|
2110
|
-
var matcher, params, result;
|
2111
|
-
if (path.toString() === '404') {
|
2112
|
-
this.wildcardAction = to;
|
2113
|
-
return;
|
2114
|
-
}
|
2115
|
-
if (path[0] === '/') {
|
2116
|
-
path = path.substr(1);
|
2117
|
-
}
|
2118
|
-
matcher = path.replace(/\/{2,}/g, '/');
|
2119
|
-
result = {};
|
2120
|
-
matcher = matcher.replace(/\/:([^\/]+)/g, '/([^/]+)');
|
2121
|
-
matcher = matcher.replace(/^\/?/, '^/?');
|
2122
|
-
matcher = matcher.replace(/\/?$/, '/?$');
|
2123
|
-
params = (path.match(/\/:[^\/]+/g) || []).map(function(str) {
|
2124
|
-
return str.substr(2);
|
2125
|
-
});
|
2126
|
-
this.routes || (this.routes = {});
|
2127
|
-
this.routes[matcher] = {
|
2128
|
-
to: to,
|
2129
|
-
capture: params,
|
2130
|
-
as: as
|
2131
|
-
};
|
2132
|
-
if (as != null) {
|
2133
|
-
return this.defineHelpers(path, as);
|
2134
|
-
}
|
2135
|
-
};
|
2136
|
-
|
2137
|
-
Router.respond = function(path) {
|
2138
|
-
var match, query, regex, route, _ref1, _ref2;
|
2139
|
-
Joosy.Modules.Log.debug("Router> Answering '" + path + "'");
|
2140
|
-
if (this.restriction && path.match(this.restriction) === null) {
|
2141
|
-
this.trigger('restricted', path);
|
2142
|
-
return;
|
2143
|
-
}
|
2144
|
-
_ref1 = path.split('?'), path = _ref1[0], query = _ref1[1];
|
2145
|
-
query = (query != null ? typeof query.split === "function" ? query.split('&') : void 0 : void 0) || [];
|
2146
|
-
_ref2 = this.routes;
|
2147
|
-
for (regex in _ref2) {
|
2148
|
-
route = _ref2[regex];
|
2149
|
-
if (this.routes.hasOwnProperty(regex)) {
|
2150
|
-
if (match = path.match(new RegExp(regex))) {
|
2151
|
-
this.responder(route.to, this.__grabParams(query, route, match));
|
2152
|
-
this.trigger('responded', path);
|
2153
|
-
return;
|
2154
|
-
}
|
2155
|
-
}
|
2156
|
-
}
|
2157
|
-
if (this.wildcardAction != null) {
|
2158
|
-
this.responder(this.wildcardAction, path);
|
2159
|
-
return this.trigger('responded');
|
2160
|
-
} else {
|
2161
|
-
return this.trigger('missed');
|
2162
|
-
}
|
2163
|
-
};
|
2164
|
-
|
2165
|
-
Router.defineHelpers = function(path, as) {
|
2166
|
-
var helper;
|
2167
|
-
helper = function(options) {
|
2168
|
-
var result, _ref1;
|
2169
|
-
result = path;
|
2170
|
-
if ((_ref1 = path.match(/\/:[^\/]+/g)) != null) {
|
2171
|
-
if (typeof _ref1.each === "function") {
|
2172
|
-
_ref1.each(function(param) {
|
2173
|
-
return result = result.replace(param.substr(1), options[param.substr(2)]);
|
2174
|
-
});
|
2175
|
-
}
|
2176
|
-
}
|
2177
|
-
if (Joosy.Router.config.html5) {
|
2178
|
-
return "" + Joosy.Router.config.prefix + result;
|
2179
|
-
} else {
|
2180
|
-
return "#" + Joosy.Router.config.prefix + result;
|
2181
|
-
}
|
2182
|
-
};
|
2183
|
-
return Joosy.helpers('Routes', function() {
|
2184
|
-
this["" + as + "Path"] = helper;
|
2185
|
-
return this["" + as + "Url"] = function(options) {
|
2186
|
-
if (Joosy.Router.config.html5) {
|
2187
|
-
return "" + location.origin + (helper(options));
|
2188
|
-
} else {
|
2189
|
-
return "" + location.origin + location.pathname + (helper(options));
|
2190
|
-
}
|
2191
|
-
};
|
2192
|
-
});
|
2193
|
-
};
|
2194
|
-
|
2195
|
-
Router.__grabParams = function(query, route, match) {
|
2196
|
-
var params, _ref1;
|
2197
|
-
if (route == null) {
|
2198
|
-
route = null;
|
2199
|
-
}
|
2200
|
-
if (match == null) {
|
2201
|
-
match = [];
|
2202
|
-
}
|
2203
|
-
params = {};
|
2204
|
-
match.shift();
|
2205
|
-
if (route != null) {
|
2206
|
-
if ((_ref1 = route.capture) != null) {
|
2207
|
-
_ref1.each(function(key) {
|
2208
|
-
return params[key] = decodeURIComponent(match.shift());
|
2209
|
-
});
|
2210
|
-
}
|
2211
|
-
}
|
2212
|
-
query.each(function(entry) {
|
2213
|
-
var key, value, _ref2;
|
2214
|
-
if (!entry.isBlank()) {
|
2215
|
-
_ref2 = entry.split('='), key = _ref2[0], value = _ref2[1];
|
2216
|
-
return params[key] = value;
|
2217
|
-
}
|
2218
|
-
});
|
2219
|
-
return params;
|
2220
|
-
};
|
2221
|
-
|
2222
|
-
return Router;
|
2223
|
-
|
2224
|
-
}).call(this, Joosy.Module);
|
2225
|
-
|
2226
|
-
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
|
2227
|
-
define('joosy/router', function() {
|
2228
|
-
return Joosy.Router;
|
2229
|
-
});
|
2230
|
-
}
|
2231
|
-
|
2232
|
-
}).call(this);
|
2233
|
-
(function() {
|
2234
|
-
Joosy.Templaters.JST = (function() {
|
2235
|
-
function JST(config) {
|
2236
|
-
this.config = config != null ? config : {};
|
2237
|
-
if ((this.config.prefix != null) && this.config.prefix.length > 0) {
|
2238
|
-
this.prefix = this.config.prefix;
|
2239
|
-
}
|
2240
|
-
}
|
2241
|
-
|
2242
|
-
JST.prototype.buildView = function(name) {
|
2243
|
-
var haystack, path, template, _i, _len;
|
2244
|
-
template = false;
|
2245
|
-
if (this.prefix) {
|
2246
|
-
haystack = ["" + this.prefix + "/templates/" + name + "-" + (typeof I18n !== "undefined" && I18n !== null ? I18n.locale : void 0), "" + this.prefix + "/templates/" + name];
|
2247
|
-
} else {
|
2248
|
-
haystack = ["templates/" + name + "-" + (typeof I18n !== "undefined" && I18n !== null ? I18n.locale : void 0), "templates/" + name];
|
2249
|
-
}
|
2250
|
-
for (_i = 0, _len = haystack.length; _i < _len; _i++) {
|
2251
|
-
path = haystack[_i];
|
2252
|
-
if (window.JST[path]) {
|
2253
|
-
return window.JST[path];
|
2254
|
-
}
|
2255
|
-
}
|
2256
|
-
throw new Error("Template '" + name + "' not found. Checked at: '" + (haystack.join(', ')) + "'");
|
2257
|
-
};
|
2258
|
-
|
2259
|
-
JST.prototype.resolveTemplate = function(section, template, entity) {
|
2260
|
-
var path, _ref, _ref1;
|
2261
|
-
if (template.startsWith('/')) {
|
2262
|
-
return template.substr(1);
|
2263
|
-
}
|
2264
|
-
path = ((_ref = entity.constructor) != null ? (_ref1 = _ref.__namespace__) != null ? _ref1.map('underscore') : void 0 : void 0) || [];
|
2265
|
-
path.unshift(section);
|
2266
|
-
return "" + (path.join('/')) + "/" + template;
|
2267
|
-
};
|
2268
|
-
|
2269
|
-
return JST;
|
2270
|
-
|
2271
|
-
})();
|
2272
|
-
|
2273
|
-
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
|
2274
|
-
define('joosy/templaters/jst', function() {
|
2275
|
-
return Joosy.Templaters.JST;
|
2276
|
-
});
|
2277
|
-
}
|
2278
|
-
|
2279
|
-
}).call(this);
|
2280
|
-
(function() {
|
2281
|
-
Joosy.Modules.Resources = {};
|
2282
|
-
|
2283
|
-
}).call(this);
|
2284
|
-
(function() {
|
2285
|
-
var __slice = [].slice;
|
2286
|
-
|
2287
|
-
Joosy.Modules.Resources.Cacher = {
|
2288
|
-
included: function() {
|
2289
|
-
this.cache = function(cacheKey) {
|
2290
|
-
return this.prototype.__cacheKey = cacheKey;
|
2291
|
-
};
|
2292
|
-
this.fetcher = function(fetcher) {
|
2293
|
-
return this.prototype.__fetcher = fetcher;
|
2294
|
-
};
|
2295
|
-
this.cached = function(callback, cacheKey, fetcher) {
|
2296
|
-
var instance,
|
2297
|
-
_this = this;
|
2298
|
-
if (cacheKey == null) {
|
2299
|
-
cacheKey = false;
|
2300
|
-
}
|
2301
|
-
if (fetcher == null) {
|
2302
|
-
fetcher = false;
|
2303
|
-
}
|
2304
|
-
if (typeof cacheKey === 'function') {
|
2305
|
-
fetcher = cacheKey;
|
2306
|
-
cacheKey = void 0;
|
2307
|
-
}
|
2308
|
-
cacheKey || (cacheKey = this.prototype.__cacheKey);
|
2309
|
-
fetcher || (fetcher = this.prototype.__fetcher);
|
2310
|
-
if (cacheKey && localStorage && localStorage[cacheKey]) {
|
2311
|
-
instance = (function(func, args, ctor) {
|
2312
|
-
ctor.prototype = func.prototype;
|
2313
|
-
var child = new ctor, result = func.apply(child, args);
|
2314
|
-
return Object(result) === result ? result : child;
|
2315
|
-
})(this, JSON.parse(localStorage[cacheKey]), function(){});
|
2316
|
-
if (typeof callback === "function") {
|
2317
|
-
callback(instance);
|
2318
|
-
}
|
2319
|
-
return instance.refresh();
|
2320
|
-
} else {
|
2321
|
-
return this.fetch(function(results) {
|
2322
|
-
instance = (function(func, args, ctor) {
|
2323
|
-
ctor.prototype = func.prototype;
|
2324
|
-
var child = new ctor, result = func.apply(child, args);
|
2325
|
-
return Object(result) === result ? result : child;
|
2326
|
-
})(_this, results, function(){});
|
2327
|
-
return typeof callback === "function" ? callback(instance) : void 0;
|
2328
|
-
});
|
2329
|
-
}
|
2330
|
-
};
|
2331
|
-
return this.fetch = function(callback) {
|
2332
|
-
var _this = this;
|
2333
|
-
return this.prototype.__fetcher(function() {
|
2334
|
-
var results;
|
2335
|
-
results = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
2336
|
-
if (_this.prototype.__cacheKey && localStorage) {
|
2337
|
-
localStorage[_this.prototype.__cacheKey] = JSON.stringify(results);
|
2338
|
-
}
|
2339
|
-
return callback(results);
|
2340
|
-
});
|
2341
|
-
};
|
2342
|
-
},
|
2343
|
-
refresh: function(callback) {
|
2344
|
-
var _this = this;
|
2345
|
-
return this.constructor.fetch(function(results) {
|
2346
|
-
_this.load.apply(_this, results);
|
2347
|
-
return typeof callback === "function" ? callback(_this) : void 0;
|
2348
|
-
});
|
2349
|
-
}
|
2350
|
-
};
|
2351
|
-
|
2352
|
-
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
|
2353
|
-
define('joosy/modules/resources/cacher', function() {
|
2354
|
-
return Joosy.Modules.Resources.Cacher;
|
2355
|
-
});
|
2356
|
-
}
|
2357
|
-
|
2358
|
-
}).call(this);
|
2359
|
-
(function() {
|
2360
|
-
var __hasProp = {}.hasOwnProperty,
|
2361
|
-
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
2362
|
-
|
2363
|
-
Joosy.Resources.Array = (function(_super) {
|
2364
|
-
__extends(Array, _super);
|
2365
|
-
|
2366
|
-
Joosy.Module.merge(Array, Joosy.Module);
|
2367
|
-
|
2368
|
-
Array.include(Joosy.Modules.Events);
|
2369
|
-
|
2370
|
-
Array.include(Joosy.Modules.Filters);
|
2371
|
-
|
2372
|
-
Array.registerPlainFilters('beforeLoad');
|
2373
|
-
|
2374
|
-
function Array() {
|
2375
|
-
this.__fillData(arguments, false);
|
2376
|
-
}
|
2377
|
-
|
2378
|
-
Array.prototype.get = function(index) {
|
2379
|
-
return this[index];
|
2380
|
-
};
|
2381
|
-
|
2382
|
-
Array.prototype.set = function(index, value) {
|
2383
|
-
this[index] = value;
|
2384
|
-
this.trigger('changed');
|
2385
|
-
return value;
|
2386
|
-
};
|
2387
|
-
|
2388
|
-
Array.prototype.load = function() {
|
2389
|
-
return this.__fillData(arguments);
|
2390
|
-
};
|
2391
|
-
|
2392
|
-
Array.prototype.clone = function(callback) {
|
2393
|
-
var clone;
|
2394
|
-
clone = new this.constructor;
|
2395
|
-
clone.data = this.slice(0);
|
2396
|
-
return clone;
|
2397
|
-
};
|
2398
|
-
|
2399
|
-
Array.prototype.push = function() {
|
2400
|
-
var result;
|
2401
|
-
result = Array.__super__.push.apply(this, arguments);
|
2402
|
-
this.trigger('changed');
|
2403
|
-
return result;
|
2404
|
-
};
|
2405
|
-
|
2406
|
-
Array.prototype.pop = function() {
|
2407
|
-
var result;
|
2408
|
-
result = Array.__super__.pop.apply(this, arguments);
|
2409
|
-
this.trigger('changed');
|
2410
|
-
return result;
|
2411
|
-
};
|
2412
|
-
|
2413
|
-
Array.prototype.shift = function() {
|
2414
|
-
var result;
|
2415
|
-
result = Array.__super__.shift.apply(this, arguments);
|
2416
|
-
this.trigger('changed');
|
2417
|
-
return result;
|
2418
|
-
};
|
2419
|
-
|
2420
|
-
Array.prototype.unshift = function() {
|
2421
|
-
var result;
|
2422
|
-
result = Array.__super__.unshift.apply(this, arguments);
|
2423
|
-
this.trigger('changed');
|
2424
|
-
return result;
|
2425
|
-
};
|
2426
|
-
|
2427
|
-
Array.prototype.splice = function() {
|
2428
|
-
var result;
|
2429
|
-
result = Array.__super__.splice.apply(this, arguments);
|
2430
|
-
this.trigger('changed');
|
2431
|
-
return result;
|
2432
|
-
};
|
2433
|
-
|
2434
|
-
Array.prototype.__fillData = function(data, notify) {
|
2435
|
-
var entry, _i, _len, _ref;
|
2436
|
-
if (notify == null) {
|
2437
|
-
notify = true;
|
2438
|
-
}
|
2439
|
-
data = this.slice.call(data, 0);
|
2440
|
-
if (this.length > 0) {
|
2441
|
-
this.splice(0, this.length);
|
2442
|
-
}
|
2443
|
-
_ref = this.__applyBeforeLoads(data);
|
2444
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
2445
|
-
entry = _ref[_i];
|
2446
|
-
this.push(entry);
|
2447
|
-
}
|
2448
|
-
if (notify) {
|
2449
|
-
this.trigger('changed');
|
2450
|
-
}
|
2451
|
-
return null;
|
2452
|
-
};
|
2453
|
-
|
2454
|
-
return Array;
|
2455
|
-
|
2456
|
-
})(Array);
|
2457
|
-
|
2458
|
-
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
|
2459
|
-
define('joosy/resources/array', function() {
|
2460
|
-
return Joosy.Resources.Array;
|
2461
|
-
});
|
2462
|
-
}
|
2463
|
-
|
2464
|
-
}).call(this);
|
2465
|
-
(function() {
|
2466
|
-
var __hasProp = {}.hasOwnProperty,
|
2467
|
-
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
2468
|
-
|
2469
|
-
Joosy.Resources.Hash = (function(_super) {
|
2470
|
-
__extends(Hash, _super);
|
2471
|
-
|
2472
|
-
Hash.include(Joosy.Modules.Events);
|
2473
|
-
|
2474
|
-
Hash.include(Joosy.Modules.Filters);
|
2475
|
-
|
2476
|
-
Hash.registerPlainFilters('beforeLoad');
|
2477
|
-
|
2478
|
-
function Hash(data) {
|
2479
|
-
if (data == null) {
|
2480
|
-
data = {};
|
2481
|
-
}
|
2482
|
-
return Hash.__super__.constructor.call(this, function() {
|
2483
|
-
return this.__fillData(data, false);
|
2484
|
-
});
|
2485
|
-
}
|
2486
|
-
|
2487
|
-
Hash.prototype.get = function(path) {
|
2488
|
-
var instance, property, _ref;
|
2489
|
-
_ref = this.__callTarget(path, true), instance = _ref[0], property = _ref[1];
|
2490
|
-
if (!instance) {
|
2491
|
-
return void 0;
|
2492
|
-
}
|
2493
|
-
if (instance instanceof Joosy.Resources.Hash) {
|
2494
|
-
return instance(property);
|
2495
|
-
} else {
|
2496
|
-
return instance[property];
|
2497
|
-
}
|
2498
|
-
};
|
2499
|
-
|
2500
|
-
Hash.prototype.set = function(path, value) {
|
2501
|
-
var instance, property, _ref;
|
2502
|
-
_ref = this.__callTarget(path), instance = _ref[0], property = _ref[1];
|
2503
|
-
if (instance instanceof Joosy.Resources.Hash) {
|
2504
|
-
instance(property, value);
|
2505
|
-
} else {
|
2506
|
-
instance[property] = value;
|
2507
|
-
}
|
2508
|
-
this.trigger('changed');
|
2509
|
-
return value;
|
2510
|
-
};
|
2511
|
-
|
2512
|
-
Hash.prototype.load = function(data) {
|
2513
|
-
this.__fillData(data);
|
2514
|
-
return this;
|
2515
|
-
};
|
2516
|
-
|
2517
|
-
Hash.prototype.clone = function(callback) {
|
2518
|
-
return new this.constructor(Object.clone(this.data, true));
|
2519
|
-
};
|
2520
|
-
|
2521
|
-
Hash.prototype.__call = function(path, value) {
|
2522
|
-
if (arguments.length > 1) {
|
2523
|
-
return this.set(path, value);
|
2524
|
-
} else {
|
2525
|
-
return this.get(path);
|
2526
|
-
}
|
2527
|
-
};
|
2528
|
-
|
2529
|
-
Hash.prototype.__callTarget = function(path, safe) {
|
2530
|
-
var keyword, part, target, _i, _len;
|
2531
|
-
if (safe == null) {
|
2532
|
-
safe = false;
|
2533
|
-
}
|
2534
|
-
if (path.indexOf('.') !== -1 && (this.data[path] == null)) {
|
2535
|
-
path = path.split('.');
|
2536
|
-
keyword = path.pop();
|
2537
|
-
target = this.data;
|
2538
|
-
for (_i = 0, _len = path.length; _i < _len; _i++) {
|
2539
|
-
part = path[_i];
|
2540
|
-
if (safe && (target[part] == null)) {
|
2541
|
-
return false;
|
2542
|
-
}
|
2543
|
-
if (target[part] == null) {
|
2544
|
-
target[part] = {};
|
2545
|
-
}
|
2546
|
-
target = target instanceof Joosy.Resources.Hash ? target(part) : target[part];
|
2547
|
-
}
|
2548
|
-
return [target, keyword];
|
2549
|
-
} else {
|
2550
|
-
return [this.data, path];
|
2551
|
-
}
|
2552
|
-
};
|
2553
|
-
|
2554
|
-
Hash.prototype.__fillData = function(data, notify) {
|
2555
|
-
if (notify == null) {
|
2556
|
-
notify = true;
|
2557
|
-
}
|
2558
|
-
this.data = this.__applyBeforeLoads(data);
|
2559
|
-
if (notify) {
|
2560
|
-
this.trigger('changed');
|
2561
|
-
}
|
2562
|
-
return null;
|
2563
|
-
};
|
2564
|
-
|
2565
|
-
Hash.prototype.toString = function() {
|
2566
|
-
return JSON.stringify(this.data);
|
2567
|
-
};
|
2568
|
-
|
2569
|
-
return Hash;
|
2570
|
-
|
2571
|
-
})(Joosy.Function);
|
2572
|
-
|
2573
|
-
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
|
2574
|
-
define('joosy/resources/hash', function() {
|
2575
|
-
return Joosy.Resources.Hash;
|
2576
|
-
});
|
2577
|
-
}
|
2578
|
-
|
2579
|
-
}).call(this);
|
2580
|
-
(function() {
|
2581
|
-
var __hasProp = {}.hasOwnProperty,
|
2582
|
-
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
2583
|
-
|
2584
|
-
Joosy.Resources.Scalar = (function(_super) {
|
2585
|
-
__extends(Scalar, _super);
|
2586
|
-
|
2587
|
-
Scalar.include(Joosy.Modules.Events);
|
2588
|
-
|
2589
|
-
Scalar.include(Joosy.Modules.Filters);
|
2590
|
-
|
2591
|
-
Scalar.registerPlainFilters('beforeLoad');
|
2592
|
-
|
2593
|
-
function Scalar(value) {
|
2594
|
-
return Scalar.__super__.constructor.call(this, function() {
|
2595
|
-
return this.load(value);
|
2596
|
-
});
|
2597
|
-
}
|
2598
|
-
|
2599
|
-
Scalar.prototype.get = function() {
|
2600
|
-
return this.value;
|
2601
|
-
};
|
2602
|
-
|
2603
|
-
Scalar.prototype.set = function(value) {
|
2604
|
-
this.value = value;
|
2605
|
-
return this.trigger('changed');
|
2606
|
-
};
|
2607
|
-
|
2608
|
-
Scalar.prototype.load = function(value) {
|
2609
|
-
this.value = this.__applyBeforeLoads(value);
|
2610
|
-
this.trigger('changed');
|
2611
|
-
return this.value;
|
2612
|
-
};
|
2613
|
-
|
2614
|
-
Scalar.prototype.clone = function(callback) {
|
2615
|
-
return new this.constructor(this.value);
|
2616
|
-
};
|
2617
|
-
|
2618
|
-
Scalar.prototype.__call = function() {
|
2619
|
-
if (arguments.length > 0) {
|
2620
|
-
return this.set(arguments[0]);
|
2621
|
-
} else {
|
2622
|
-
return this.get();
|
2623
|
-
}
|
2624
|
-
};
|
2625
|
-
|
2626
|
-
Scalar.prototype.valueOf = function() {
|
2627
|
-
return this.value.valueOf();
|
2628
|
-
};
|
2629
|
-
|
2630
|
-
Scalar.prototype.toString = function() {
|
2631
|
-
return this.value.toString();
|
2632
|
-
};
|
2633
|
-
|
2634
|
-
return Scalar;
|
2635
|
-
|
2636
|
-
})(Joosy.Function);
|
2637
|
-
|
2638
|
-
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
|
2639
|
-
define('joosy/resources/scalar', function() {
|
2640
|
-
return Joosy.Resources.Scalar;
|
2641
|
-
});
|
2642
|
-
}
|
2643
|
-
|
2644
|
-
}).call(this);
|
2645
|
-
(function() {
|
2646
|
-
Joosy.helpers('Application', function() {
|
2647
|
-
return this.widget = function(tag, options, widget) {
|
2648
|
-
var _this = this;
|
2649
|
-
if (widget == null) {
|
2650
|
-
widget = options;
|
2651
|
-
options = {};
|
2652
|
-
}
|
2653
|
-
options.id = Joosy.uid();
|
2654
|
-
this.__renderer.setTimeout(0, function() {
|
2655
|
-
return _this.__renderer.registerWidget($('#' + options.id), widget);
|
2656
|
-
});
|
2657
|
-
return this.tag(tag, options);
|
2658
|
-
};
|
2659
|
-
});
|
2660
|
-
|
2661
|
-
}).call(this);
|
2662
|
-
(function() {
|
2663
|
-
Joosy.Application = (function() {
|
2664
|
-
function Application() {}
|
2665
|
-
|
2666
|
-
Application.Pages = {};
|
2667
|
-
|
2668
|
-
Application.Layouts = {};
|
2669
|
-
|
2670
|
-
Application.Controls = {};
|
2671
|
-
|
2672
|
-
Application.initialized = false;
|
2673
|
-
|
2674
|
-
Application.loading = true;
|
2675
|
-
|
2676
|
-
Application.config = {
|
2677
|
-
test: false,
|
2678
|
-
debug: false,
|
2679
|
-
templater: {
|
2680
|
-
prefix: ''
|
2681
|
-
},
|
2682
|
-
router: {
|
2683
|
-
html5: false,
|
2684
|
-
base: '',
|
2685
|
-
prefix: ''
|
2686
|
-
}
|
2687
|
-
};
|
2688
|
-
|
2689
|
-
Application.initialize = function(selector, options) {
|
2690
|
-
var _this = this;
|
2691
|
-
this.selector = selector;
|
2692
|
-
if (options == null) {
|
2693
|
-
options = {};
|
2694
|
-
}
|
2695
|
-
if (this.initialized) {
|
2696
|
-
throw new Error('Attempted to initialize Application twice');
|
2697
|
-
}
|
2698
|
-
if (window.JoosyEnvironment != null) {
|
2699
|
-
Object.merge(this.config, window.JoosyEnvironment, true);
|
2700
|
-
}
|
2701
|
-
Object.merge(this.config, options, true);
|
2702
|
-
if (this.config.test) {
|
2703
|
-
this.forceSandbox();
|
2704
|
-
}
|
2705
|
-
Joosy.templater(new Joosy.Templaters.JST(this.config.templater));
|
2706
|
-
Joosy.debug(this.config.debug);
|
2707
|
-
Joosy.Router.setup(this.config.router, function(action, params) {
|
2708
|
-
if (Joosy.Module.hasAncestor(action, Joosy.Page)) {
|
2709
|
-
return _this.changePage(action, params);
|
2710
|
-
} else if (Object.isFunction(action)) {
|
2711
|
-
return action(params);
|
2712
|
-
} else {
|
2713
|
-
throw new Error("Unknown kind of route action: " + action);
|
2714
|
-
}
|
2715
|
-
});
|
2716
|
-
return this.initialized = true;
|
2717
|
-
};
|
2718
|
-
|
2719
|
-
Application.reset = function() {
|
2720
|
-
var _ref;
|
2721
|
-
Joosy.Router.reset();
|
2722
|
-
Joosy.templater(false);
|
2723
|
-
Joosy.debug(false);
|
2724
|
-
if ((_ref = this.page) != null) {
|
2725
|
-
_ref.__unload();
|
2726
|
-
}
|
2727
|
-
delete this.page;
|
2728
|
-
this.loading = true;
|
2729
|
-
return this.initialized = false;
|
2730
|
-
};
|
2731
|
-
|
2732
|
-
Application.content = function() {
|
2733
|
-
return $(this.selector);
|
2734
|
-
};
|
2735
|
-
|
2736
|
-
Application.changePage = function(page, params) {
|
2737
|
-
var attempt;
|
2738
|
-
attempt = new page(params, this.page);
|
2739
|
-
if (!attempt.halted) {
|
2740
|
-
if (attempt.layoutShouldChange && attempt.layout) {
|
2741
|
-
attempt.layout.__bootstrapDefault(attempt, this.content());
|
2742
|
-
} else {
|
2743
|
-
attempt.__bootstrapDefault(this.content());
|
2744
|
-
}
|
2745
|
-
return this.page = attempt;
|
2746
|
-
}
|
2747
|
-
};
|
2748
|
-
|
2749
|
-
Application.forceSandbox = function() {
|
2750
|
-
var sandbox;
|
2751
|
-
sandbox = Joosy.uid();
|
2752
|
-
this.selector = "#" + sandbox;
|
2753
|
-
return $('body').append($('<div/>').attr('id', sandbox).css({
|
2754
|
-
height: '0px',
|
2755
|
-
width: '0px',
|
2756
|
-
overflow: 'hidden'
|
2757
|
-
}));
|
2758
|
-
};
|
2759
|
-
|
2760
|
-
return Application;
|
2761
|
-
|
2762
|
-
})();
|
2763
|
-
|
2764
|
-
if ((typeof define !== "undefined" && define !== null ? define.amd : void 0) != null) {
|
2765
|
-
define('joosy/application', function() {
|
2766
|
-
return Joosy.Application;
|
2767
|
-
});
|
2768
|
-
}
|
2769
|
-
|
2770
|
-
}).call(this);
|
2771
|
-
(function() {
|
2772
|
-
|
2773
|
-
|
2774
|
-
}).call(this);
|
1
|
+
!function(a){"function"==typeof YUI?YUI.add("es5",a):a()}(function(){function a(){}function b(a){return a=+a,a!==a?a=0:0!==a&&a!==1/0&&a!==-(1/0)&&(a=(a>0||-1)*Math.floor(Math.abs(a))),a}function c(a){var b=typeof a;return null===a||"undefined"===b||"boolean"===b||"number"===b||"string"===b}function d(a){var b,d,e;if(c(a))return a;if(d=a.valueOf,"function"==typeof d&&(b=d.call(a),c(b)))return b;if(e=a.toString,"function"==typeof e&&(b=e.call(a),c(b)))return b;throw new TypeError}Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if("function"!=typeof c)throw new TypeError("Function.prototype.bind called on incompatible "+c);var d=m.call(arguments,1),e=function(){if(this instanceof e){var a=c.apply(this,d.concat(m.call(arguments)));return Object(a)===a?a:this}return c.apply(b,d.concat(m.call(arguments)))};return c.prototype&&(a.prototype=c.prototype,e.prototype=new a,a.prototype=null),e});var e,f,g,h,i,j=Function.prototype.call,k=Array.prototype,l=Object.prototype,m=k.slice,n=j.bind(l.toString),o=j.bind(l.hasOwnProperty);if((i=o(l,"__defineGetter__"))&&(e=j.bind(l.__defineGetter__),f=j.bind(l.__defineSetter__),g=j.bind(l.__lookupGetter__),h=j.bind(l.__lookupSetter__)),2!=[1,2].splice(0).length){var p=Array.prototype.splice;Array.prototype.splice=function(){function a(a){for(var b=[];a--;)b.unshift(a);return b}var b,c=[];return c.splice.bind(c,0,0).apply(null,a(20)),c.splice.bind(c,0,0).apply(null,a(26)),b=c.length,c.splice(5,0,"XXX"),b+1==c.length?!0:void 0}()?function(a,b){return arguments.length?p.apply(this,[void 0===a?0:a,void 0===b?this.length-a:b].concat(m.call(arguments,2))):[]}:function(a,b){var c,d=m.call(arguments,2),e=d.length;if(!arguments.length)return[];if(void 0===a&&(a=0),void 0===b&&(b=this.length-a),e>0){if(0>=b){if(a==this.length)return this.push.apply(this,d),[];if(0==a)return this.unshift.apply(this,d),[]}return c=m.call(this,a,a+b),d.push.apply(d,m.call(this,a+b,this.length)),d.unshift.apply(d,m.call(this,0,a)),d.unshift(0,this.length),p.apply(this,d),c}return p.call(this,a,b)}}if(1!=[].unshift(0)){var q=Array.prototype.unshift;Array.prototype.unshift=function(){return q.apply(this,arguments),this.length}}Array.isArray||(Array.isArray=function(a){return"[object Array]"==n(a)});var r=Object("a"),s="a"!=r[0]||!(0 in r);if(Array.prototype.forEach||(Array.prototype.forEach=function(a){var b=G(this),c=s&&"[object String]"==n(this)?this.split(""):b,d=arguments[1],e=-1,f=c.length>>>0;if("[object Function]"!=n(a))throw new TypeError;for(;++e<f;)e in c&&a.call(d,c[e],e,b)}),Array.prototype.map||(Array.prototype.map=function(a){var b=G(this),c=s&&"[object String]"==n(this)?this.split(""):b,d=c.length>>>0,e=Array(d),f=arguments[1];if("[object Function]"!=n(a))throw new TypeError(a+" is not a function");for(var g=0;d>g;g++)g in c&&(e[g]=a.call(f,c[g],g,b));return e}),Array.prototype.filter||(Array.prototype.filter=function(a){var b,c=G(this),d=s&&"[object String]"==n(this)?this.split(""):c,e=d.length>>>0,f=[],g=arguments[1];if("[object Function]"!=n(a))throw new TypeError(a+" is not a function");for(var h=0;e>h;h++)h in d&&(b=d[h],a.call(g,b,h,c)&&f.push(b));return f}),Array.prototype.every||(Array.prototype.every=function(a){var b=G(this),c=s&&"[object String]"==n(this)?this.split(""):b,d=c.length>>>0,e=arguments[1];if("[object Function]"!=n(a))throw new TypeError(a+" is not a function");for(var f=0;d>f;f++)if(f in c&&!a.call(e,c[f],f,b))return!1;return!0}),Array.prototype.some||(Array.prototype.some=function(a){var b=G(this),c=s&&"[object String]"==n(this)?this.split(""):b,d=c.length>>>0,e=arguments[1];if("[object Function]"!=n(a))throw new TypeError(a+" is not a function");for(var f=0;d>f;f++)if(f in c&&a.call(e,c[f],f,b))return!0;return!1}),Array.prototype.reduce||(Array.prototype.reduce=function(a){var b=G(this),c=s&&"[object String]"==n(this)?this.split(""):b,d=c.length>>>0;if("[object Function]"!=n(a))throw new TypeError(a+" is not a function");if(!d&&1==arguments.length)throw new TypeError("reduce of empty array with no initial value");var e,f=0;if(arguments.length>=2)e=arguments[1];else for(;;){if(f in c){e=c[f++];break}if(++f>=d)throw new TypeError("reduce of empty array with no initial value")}for(;d>f;f++)f in c&&(e=a.call(void 0,e,c[f],f,b));return e}),Array.prototype.reduceRight||(Array.prototype.reduceRight=function(a){var b=G(this),c=s&&"[object String]"==n(this)?this.split(""):b,d=c.length>>>0;if("[object Function]"!=n(a))throw new TypeError(a+" is not a function");if(!d&&1==arguments.length)throw new TypeError("reduceRight of empty array with no initial value");var e,f=d-1;if(arguments.length>=2)e=arguments[1];else for(;;){if(f in c){e=c[f--];break}if(--f<0)throw new TypeError("reduceRight of empty array with no initial value")}if(0>f)return e;do f in this&&(e=a.call(void 0,e,c[f],f,b));while(f--);return e}),Array.prototype.indexOf&&-1==[0,1].indexOf(1,2)||(Array.prototype.indexOf=function(a){var c=s&&"[object String]"==n(this)?this.split(""):G(this),d=c.length>>>0;if(!d)return-1;var e=0;for(arguments.length>1&&(e=b(arguments[1])),e=e>=0?e:Math.max(0,d+e);d>e;e++)if(e in c&&c[e]===a)return e;return-1}),Array.prototype.lastIndexOf&&-1==[0,1].lastIndexOf(0,-3)||(Array.prototype.lastIndexOf=function(a){var c=s&&"[object String]"==n(this)?this.split(""):G(this),d=c.length>>>0;if(!d)return-1;var e=d-1;for(arguments.length>1&&(e=Math.min(e,b(arguments[1]))),e=e>=0?e:d-Math.abs(e);e>=0;e--)if(e in c&&a===c[e])return e;return-1}),!Object.keys){var t=!0,u=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],v=u.length;for(var w in{toString:null})t=!1;Object.keys=function H(a){if("object"!=typeof a&&"function"!=typeof a||null===a)throw new TypeError("Object.keys called on a non-object");var H=[];for(var b in a)o(a,b)&&H.push(b);if(t)for(var c=0,d=v;d>c;c++){var e=u[c];o(a,e)&&H.push(e)}return H}}var x=-621987552e5,y="-000001";Date.prototype.toISOString&&-1!==new Date(x).toISOString().indexOf(y)||(Date.prototype.toISOString=function(){var a,b,c,d,e;if(!isFinite(this))throw new RangeError("Date.prototype.toISOString called on non-finite value.");for(d=this.getUTCFullYear(),e=this.getUTCMonth(),d+=Math.floor(e/12),e=(e%12+12)%12,a=[e+1,this.getUTCDate(),this.getUTCHours(),this.getUTCMinutes(),this.getUTCSeconds()],d=(0>d?"-":d>9999?"+":"")+("00000"+Math.abs(d)).slice(d>=0&&9999>=d?-4:-6),b=a.length;b--;)c=a[b],10>c&&(a[b]="0"+c);return d+"-"+a.slice(0,2).join("-")+"T"+a.slice(2).join(":")+"."+("000"+this.getUTCMilliseconds()).slice(-3)+"Z"});var z=!1;try{z=Date.prototype.toJSON&&null===new Date(0/0).toJSON()&&-1!==new Date(x).toJSON().indexOf(y)&&Date.prototype.toJSON.call({toISOString:function(){return!0}})}catch(A){}z||(Date.prototype.toJSON=function(){var a,b=Object(this),c=d(b);if("number"==typeof c&&!isFinite(c))return null;if(a=b.toISOString,"function"!=typeof a)throw new TypeError("toISOString property is not callable");return a.call(b)}),Date=function(a){function b(c,d,e,f,g,h,i){var j=arguments.length;if(this instanceof a){var k=1==j&&String(c)===c?new a(b.parse(c)):j>=7?new a(c,d,e,f,g,h,i):j>=6?new a(c,d,e,f,g,h):j>=5?new a(c,d,e,f,g):j>=4?new a(c,d,e,f):j>=3?new a(c,d,e):j>=2?new a(c,d):j>=1?new a(c):new a;return k.constructor=b,k}return a.apply(this,arguments)}function c(a,b){var c=b>1?1:0;return f[b]+Math.floor((a-1969+c)/4)-Math.floor((a-1901+c)/100)+Math.floor((a-1601+c)/400)+365*(a-1970)}function d(b){return Number(new a(1970,0,1,0,0,0,b))}var e=new RegExp("^(\\d{4}|[+-]\\d{6})(?:-(\\d{2})(?:-(\\d{2})(?:T(\\d{2}):(\\d{2})(?::(\\d{2})(?:(\\.\\d{1,}))?)?(Z|(?:([-+])(\\d{2}):(\\d{2})))?)?)?)?$"),f=[0,31,59,90,120,151,181,212,243,273,304,334,365];for(var g in a)b[g]=a[g];return b.now=a.now,b.UTC=a.UTC,b.prototype=a.prototype,b.prototype.constructor=b,b.parse=function(b){var f=e.exec(b);if(f){var g,h=Number(f[1]),i=Number(f[2]||1)-1,j=Number(f[3]||1)-1,k=Number(f[4]||0),l=Number(f[5]||0),m=Number(f[6]||0),n=Math.floor(1e3*Number(f[7]||0)),o=Boolean(f[4]&&!f[8]),p="-"===f[9]?1:-1,q=Number(f[10]||0),r=Number(f[11]||0);return(l>0||m>0||n>0?24:25)>k&&60>l&&60>m&&1e3>n&&i>-1&&12>i&&24>q&&60>r&&j>-1&&j<c(h,i+1)-c(h,i)&&(g=60*(24*(c(h,i)+j)+k+q*p),g=1e3*(60*(g+l+r*p)+m)+n,o&&(g=d(g)),g>=-864e13&&864e13>=g)?g:0/0}return a.parse.apply(this,arguments)},b}(Date),Date.now||(Date.now=function(){return(new Date).getTime()}),Number.prototype.toFixed&&"0.000"===8e-5.toFixed(3)&&"0"!==.9.toFixed(0)&&"1.25"===1.255.toFixed(2)&&"1000000000000000128"===0xde0b6b3a7640080.toFixed(0)||!function(){function a(a,b){for(var c=-1;++c<g;)b+=a*h[c],h[c]=b%f,b=Math.floor(b/f)}function b(a){for(var b=g,c=0;--b>=0;)c+=h[b],h[b]=Math.floor(c/a),c=c%a*f}function c(){for(var a=g,b="";--a>=0;)if(""!==b||0===a||0!==h[a]){var c=String(h[a]);""===b?b=c:b+="0000000".slice(0,7-c.length)+c}return b}function d(a,b,c){return 0===b?c:1===b%2?d(a,b-1,c*a):d(a*a,b/2,c)}function e(a){for(var b=0;a>=4096;)b+=12,a/=4096;for(;a>=2;)b+=1,a/=2;return b}var f,g,h;f=1e7,g=6,h=[0,0,0,0,0,0],Number.prototype.toFixed=function(f){var g,h,i,j,k,l,m,n;if(g=Number(f),g=g!==g?0:Math.floor(g),0>g||g>20)throw new RangeError("Number.toFixed called with invalid number of decimals");if(h=Number(this),h!==h)return"NaN";if(-1e21>=h||h>=1e21)return String(h);if(i="",0>h&&(i="-",h=-h),j="0",h>1e-21)if(k=e(h*d(2,69,1))-69,l=0>k?h*d(2,-k,1):h/d(2,k,1),l*=4503599627370496,k=52-k,k>0){for(a(0,l),m=g;m>=7;)a(1e7,0),m-=7;for(a(d(10,m,1),0),m=k-1;m>=23;)b(1<<23),m-=23;b(1<<m),a(1,1),b(2),j=c()}else a(0,l),a(1<<-k,0),j=c()+"0.00000000000000000000".slice(2,2+g);return g>0?(n=j.length,j=g>=n?i+"0.0000000000000000000".slice(0,g-n+2)+j:i+j.slice(0,n-g)+"."+j.slice(n-g)):j=i+j,j}}();var B=String.prototype.split;if(2!=="ab".split(/(?:ab)*/).length||4!==".".split(/(.?)(.?)/).length||"t"==="tesst".split(/(s)*/)[1]||0==="".split(/.?/).length||".".split(/()()/).length>1?!function(){var a=void 0===/()??/.exec("")[1];String.prototype.split=function(b,c){var d=this;if(void 0===b&&0===c)return[];if("[object RegExp]"!==Object.prototype.toString.call(b))return B.apply(this,arguments);var e,f,g,h,i=[],j=(b.ignoreCase?"i":"")+(b.multiline?"m":"")+(b.extended?"x":"")+(b.sticky?"y":""),k=0,b=new RegExp(b.source,j+"g");for(d+="",a||(e=new RegExp("^"+b.source+"$(?!\\s)",j)),c=void 0===c?-1>>>0:c>>>0;(f=b.exec(d))&&(g=f.index+f[0].length,!(g>k&&(i.push(d.slice(k,f.index)),!a&&f.length>1&&f[0].replace(e,function(){for(var a=1;a<arguments.length-2;a++)void 0===arguments[a]&&(f[a]=void 0)}),f.length>1&&f.index<d.length&&Array.prototype.push.apply(i,f.slice(1)),h=f[0].length,k=g,i.length>=c)));)b.lastIndex===f.index&&b.lastIndex++;return k===d.length?(h||!b.test(""))&&i.push(""):i.push(d.slice(k)),i.length>c?i.slice(0,c):i}}():"0".split(void 0,0).length&&(String.prototype.split=function(a,b){return void 0===a&&0===b?[]:B.apply(this,arguments)}),"".substr&&"b"!=="0b".substr(-1)){var C=String.prototype.substr;String.prototype.substr=function(a,b){return C.call(this,0>a?(a=this.length+a)<0?0:a:a,b)}}var D=" \n\f\r \u2028\u2029";if(!String.prototype.trim||D.trim()){D="["+D+"]";var E=new RegExp("^"+D+D+"*"),F=new RegExp(D+D+"*$");String.prototype.trim=function(){if(void 0===this||null===this)throw new TypeError("can't convert "+this+" to object");return String(this).replace(E,"").replace(F,"")}}var G=function(a){if(null==a)throw new TypeError("can't convert "+a+" to object");return Object(a)}}),function(a){var b=["equipment","information","rice","money","species","series","fish","sheep","moose","deer","news"],c=[[new RegExp("(m)en$","gi")],[new RegExp("(pe)ople$","gi")],[new RegExp("(child)ren$","gi")],[new RegExp("([ti])a$","gi")],[new RegExp("((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$","gi")],[new RegExp("(hive)s$","gi")],[new RegExp("(tive)s$","gi")],[new RegExp("(curve)s$","gi")],[new RegExp("([lr])ves$","gi")],[new RegExp("([^fo])ves$","gi")],[new RegExp("([^aeiouy]|qu)ies$","gi")],[new RegExp("(s)eries$","gi")],[new RegExp("(m)ovies$","gi")],[new RegExp("(x|ch|ss|sh)es$","gi")],[new RegExp("([m|l])ice$","gi")],[new RegExp("(bus)es$","gi")],[new RegExp("(o)es$","gi")],[new RegExp("(shoe)s$","gi")],[new RegExp("(cris|ax|test)es$","gi")],[new RegExp("(octop|vir)i$","gi")],[new RegExp("(alias|status)es$","gi")],[new RegExp("^(ox)en","gi")],[new RegExp("(vert|ind)ices$","gi")],[new RegExp("(matr)ices$","gi")],[new RegExp("(quiz)zes$","gi")],[new RegExp("(m)an$","gi"),"$1en"],[new RegExp("(pe)rson$","gi"),"$1ople"],[new RegExp("(child)$","gi"),"$1ren"],[new RegExp("^(ox)$","gi"),"$1en"],[new RegExp("(ax|test)is$","gi"),"$1es"],[new RegExp("(octop|vir)us$","gi"),"$1i"],[new RegExp("(alias|status)$","gi"),"$1es"],[new RegExp("(bu)s$","gi"),"$1ses"],[new RegExp("(buffal|tomat|potat)o$","gi"),"$1oes"],[new RegExp("([ti])um$","gi"),"$1a"],[new RegExp("sis$","gi"),"ses"],[new RegExp("(?:([^f])fe|([lr])f)$","gi"),"$1$2ves"],[new RegExp("(hive)$","gi"),"$1s"],[new RegExp("([^aeiouy]|qu)y$","gi"),"$1ies"],[new RegExp("(x|ch|ss|sh)$","gi"),"$1es"],[new RegExp("(matr|vert|ind)ix|ex$","gi"),"$1ices"],[new RegExp("([m|l])ouse$","gi"),"$1ice"],[new RegExp("(quiz)$","gi"),"$1zes"],[new RegExp("s$","gi"),"s"],[new RegExp("$","gi"),"s"]],d=[[new RegExp("(m)an$","gi")],[new RegExp("(pe)rson$","gi")],[new RegExp("(child)$","gi")],[new RegExp("^(ox)$","gi")],[new RegExp("(ax|test)is$","gi")],[new RegExp("(octop|vir)us$","gi")],[new RegExp("(alias|status)$","gi")],[new RegExp("(bu)s$","gi")],[new RegExp("(buffal|tomat|potat)o$","gi")],[new RegExp("([ti])um$","gi")],[new RegExp("sis$","gi")],[new RegExp("(?:([^f])fe|([lr])f)$","gi")],[new RegExp("(hive)$","gi")],[new RegExp("([^aeiouy]|qu)y$","gi")],[new RegExp("(x|ch|ss|sh)$","gi")],[new RegExp("(matr|vert|ind)ix|ex$","gi")],[new RegExp("([m|l])ouse$","gi")],[new RegExp("(quiz)$","gi")],[new RegExp("(m)en$","gi"),"$1an"],[new RegExp("(pe)ople$","gi"),"$1rson"],[new RegExp("(child)ren$","gi"),"$1"],[new RegExp("([ti])a$","gi"),"$1um"],[new RegExp("((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$","gi"),"$1$2sis"],[new RegExp("(hive)s$","gi"),"$1"],[new RegExp("(tive)s$","gi"),"$1"],[new RegExp("(curve)s$","gi"),"$1"],[new RegExp("([lr])ves$","gi"),"$1f"],[new RegExp("([^fo])ves$","gi"),"$1fe"],[new RegExp("([^aeiouy]|qu)ies$","gi"),"$1y"],[new RegExp("(s)eries$","gi"),"$1eries"],[new RegExp("(m)ovies$","gi"),"$1ovie"],[new RegExp("(x|ch|ss|sh)es$","gi"),"$1"],[new RegExp("([m|l])ice$","gi"),"$1ouse"],[new RegExp("(bus)es$","gi"),"$1"],[new RegExp("(o)es$","gi"),"$1"],[new RegExp("(shoe)s$","gi"),"$1"],[new RegExp("(cris|ax|test)es$","gi"),"$1is"],[new RegExp("(octop|vir)i$","gi"),"$1us"],[new RegExp("(alias|status)es$","gi"),"$1"],[new RegExp("^(ox)en","gi"),"$1"],[new RegExp("(vert|ind)ices$","gi"),"$1ex"],[new RegExp("(matr)ices$","gi"),"$1ix"],[new RegExp("(quiz)zes$","gi"),"$1"],[new RegExp("ss$","gi"),"ss"],[new RegExp("s$","gi"),""]],e=["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"],f=new RegExp("(_ids|_id)$","g"),g=new RegExp("_","g"),h=new RegExp("[ _]","g"),i=new RegExp("([A-Z])","g"),j=new RegExp("^_"),k={_apply_rules:function(a,b,c,d){if(d)a=d;else{var e=k.indexOf(c,a.toLowerCase())>-1;if(!e)for(var f=0,g=b.length;g>f;f++)if(a.match(b[f][0])){void 0!==b[f][1]&&(a=a.replace(b[f][0],b[f][1]));break}}return a},indexOf:function(a,b,c,d){c||(c=-1);for(var e=-1,f=c,g=a.length;g>f;f++)if(a[f]===b||d&&d(a[f],b)){e=f;break}return e},pluralize:function(a,d){return k._apply_rules(a,c,b,d)},singularize:function(a,c){return k._apply_rules(a,d,b,c)},camelize:function(a,b){for(var c=a.toLowerCase().split("/"),d=0,e=c.length;e>d;d++){for(var f=c[d].split("_"),g=b&&d+1===e?1:0,h=g,i=f.length;i>h;h++)f[h]=f[h].charAt(0).toUpperCase()+f[h].substring(1);c[d]=f.join("")}return c.join("::")},underscore:function(a,b){if(b&&a===a.toUpperCase())return a;for(var c=a.split("::"),d=0,e=c.length;e>d;d++)c[d]=c[d].replace(i,"_$1"),c[d]=c[d].replace(j,"");return c.join("/").toLowerCase()},humanize:function(a,b){return a=a.toLowerCase(),a=a.replace(f,""),a=a.replace(g," "),b||(a=k.capitalize(a)),a},capitalize:function(a){return a=a.toLowerCase(),a.substring(0,1).toUpperCase()+a.substring(1)},dasherize:function(a){return a.replace(h,"-")},titleize:function(a){a=a.toLowerCase().replace(g," ");for(var b=a.split(" "),c=0,d=b.length;d>c;c++){for(var f=b[c].split("-"),h=0,i=f.length;i>h;h++)k.indexOf(e,f[h].toLowerCase())<0&&(f[h]=k.capitalize(f[h]));b[c]=f.join("-")}return a=b.join(" "),a=a.substring(0,1).toUpperCase()+a.substring(1)},demodulize:function(a){var b=a.split("::");return b[b.length-1]},tableize:function(a){return a=k.underscore(a),a=k.pluralize(a)},classify:function(a){return a=k.camelize(a),a=k.singularize(a)},foreign_key:function(a,b){return a=k.demodulize(a),a=k.underscore(a)+(b?"":"_")+"id"},ordinalize:function(a){for(var b=a.split(" "),c=0,d=b.length;d>c;c++){var e=parseInt(b[c],10);if(!isNaN(e)){var f=b[c].substring(b[c].length-2),g=b[c].substring(b[c].length-1),h="th";"11"!=f&&"12"!=f&&"13"!=f&&("1"===g?h="st":"2"===g?h="nd":"3"===g&&(h="rd")),b[c]+=h}}return b.join(" ")}};return"undefined"==typeof exports?a.inflection=k:(k.version="1.2.5",module.exports=k,void 0)}(this),function(){this.Joosy={Modules:{},Resources:{},Templaters:{},Helpers:{},Events:{},debug:function(a){return null!=a?this.__debug=a:!!this.__debug},templater:function(a){if(null!=a)return this.__templater=a;if(!this.__templater)throw new Error("No templater registered");return this.__templater},namespace:function(a,b){var c,d,e,f,g,h,i;for(null==b&&(b=!1),a=a.split("."),f=window,g=0,h=a.length;h>g;g++)e=a[g],e.length>0&&(f=null!=f[e]?f[e]:f[e]={});b&&(b=b.apply(f)),i=[];for(c in f)d=f[c],f.hasOwnProperty(c)&&Joosy.Module.hasAncestor(d,Joosy.Module)?i.push(d.__namespace__=a):i.push(void 0);return i},helpers:function(a,b){var c;return(c=Joosy.Helpers)[a]||(c[a]={}),b.apply(Joosy.Helpers[a])},uid:function(){return this.__uid||(this.__uid=0),"__joosy"+this.__uid++},uuid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b,c;return b=0|16*Math.random(),c="x"===a?b:8|3&b,c.toString(16)}).toUpperCase()},synchronize:function(){var a;return Joosy.Modules.Events?(a=Joosy.Modules.Events).synchronize.apply(a,arguments):console.error("Events module is required to use `Joosy.synchronize'!")},buildUrl:function(a,b){var c,d,e,f;e=[];for(d in b)f=b[d],e.push(""+d+"="+f);return c=a.match(/(\#.*)?$/)[0],a=a.replace(/\#.*$/,""),0!==e.length&&-1===a.indexOf("?")&&(a+="?"),e=e.join("&"),e.length>0&&"?"!==a[a.length-1]&&(e="&"+e),a+e+c}},null!=("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define("joosy",function(){return Joosy})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};Joosy.Module=function(){function a(){}return a.__namespace__=[],a.__className=function(a){return"function"!=typeof a&&(a=a.constructor),null!=a.name?a.name:a.toString().replace(/^function ([a-zA-Z]+)\([\s\S]+/,"$1")},a.hasAncestor=function(a,b){var c;if(null==a||null==b)return!1;for(a=a.prototype,b=b.prototype;a;){if(a===b)return!0;a=null!=(c=a.constructor)?c.__super__:void 0}return!1},a.aliasMethodChain=function(a,b,c){var d,e;return d=b.charAt(0).toUpperCase()+b.slice(1),e=""+a+"Without"+d,"function"!=typeof c&&(c=this.prototype[c]),this.prototype[e]=this.prototype[a],this.prototype[a]=c},a.aliasStaticMethodChain=function(a,b,c){var d,e;return d=b.charAt(0).toUpperCase()+b.slice(1),e=""+a+"Without"+d,this[e]=this[a],this[a]=c},a.merge=function(a,b,c,d){var e,f,g;null==c&&(c=!0),null==d&&(d=!1);for(e in b)f=b[e],b.hasOwnProperty(e)&&(c||!a.hasOwnProperty(e))&&(d&&f.constructor===Object?((null!=(g=a[e])?g.constructor:void 0)!==Object&&(a[e]={}),Joosy.Module.merge(a[e],f)):a[e]=f);return a},a.include=function(a){var b,c,d;if(!a)throw new Error("include(object) requires obj");for(b in a)c=a[b],"included"!==b&&"extended"!==b&&(this.prototype[b]=c);return null!=(d=a.included)&&d.apply(this),null},a.extend=function(a){var b;if(!a)throw new Error("extend(object) requires object");return this.merge(this,a),null!=(b=a.extended)&&b.apply(this),null},a}(),Joosy.Function=function(a){function c(a){var b,c,d;if(c=function(){return c.__call.apply(c,arguments)},c.__proto__)c.__proto__=this;else for(b in this)d=this[b],c[b]=d;return c.constructor=this.constructor,null!=a&&a.call(c),c}return b(c,a),c}(Joosy.Module),null!=("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define("joosy/module",function(){return Joosy.Module})}.call(this),function(){var a,b,c=[].slice;b=function(){function a(){this.actions=[]}return a.prototype["do"]=function(a){return this.actions.push(a)},a.prototype.after=function(a){this.after=a},a}(),a=function(){function a(a){this.parent=a,this.bindings=[]}return a.prototype.bind=function(){var a,b;return a=1<=arguments.length?c.call(arguments,0):[],this.bindings.push((b=this.parent).bind.apply(b,a))},a.prototype.unbind=function(){var a,b,c,d;for(d=this.bindings,b=0,c=d.length;c>b;b++)a=d[b],this.parent.unbind(a);return this.bindings=[]},a}(),Joosy.Modules.Events={eventsNamespace:function(b){var c;return c=new a(this),null!=b&&"function"==typeof b.call&&b.call(c),c},wait:function(a,b,c){return this.hasOwnProperty("__oneShotEvents")||(this.__oneShotEvents={}),2===arguments.length&&(c=b,b=a,a=Object.keys(this.__oneShotEvents).length.toString()),b=this.__splitEvents(b),b.length>0?this.__oneShotEvents[a]=[b,c]:c(),a},unwait:function(a){return this.hasOwnProperty("__oneShotEvents")?delete this.__oneShotEvents[a]:void 0},bind:function(a,b,c){return this.hasOwnProperty("__boundEvents")||(this.__boundEvents={}),2===arguments.length&&(c=b,b=a,a=Object.keys(this.__boundEvents).length.toString()),b=this.__splitEvents(b),b.length>0?this.__boundEvents[a]=[b,c]:c(),a},unbind:function(a){return this.hasOwnProperty("__boundEvents")?delete this.__boundEvents[a]:void 0},trigger:function(){var a,b,d,e,f,g,h,i,j,k,l,m,n,o,p,q=this;if(d=arguments[0],b=2<=arguments.length?c.call(arguments,1):[],Joosy.Modules.Log.debugAs(this,"Event "+d+" triggered"),"string"==typeof d?i=!1:(i=d.remember,d=d.name),this.hasOwnProperty("__oneShotEvents")){f=[],m=this.__oneShotEvents;for(g in m){for(n=m[g],e=n[0],a=n[1];-1!==(h=e.indexOf(d));)e.splice(h,1);0===e.length&&f.push(g)}for(j=function(c){return a=q.__oneShotEvents[c][1],delete q.__oneShotEvents[c],a.apply(null,b)},k=0,l=f.length;l>k;k++)g=f[k],j(g)}if(this.hasOwnProperty("__boundEvents")){o=this.__boundEvents;for(g in o)p=o[g],e=p[0],a=p[1],-1!==e.indexOf(d)&&a.apply(null,b)}return i?(this.hasOwnProperty("__triggeredEvents")||(this.__triggeredEvents={}),this.__triggeredEvents[d]=!0):void 0},synchronize:function(a){var c,d,e,f,g,h,i,j=this;if(d=new b,e=0,a(d),0===d.actions.length)return d.after.call(this);for(h=d.actions,i=[],f=0,g=h.length;g>f;f++)c=h[f],i.push(function(a){return a.call(j,function(){return++e>=d.actions.length?d.after.call(this):void 0})}(c));return i},__splitEvents:function(a){var b=this;return"string"==typeof a&&(a=0===a.length?[]:a.trim().split(/\s+/)),this.hasOwnProperty("__triggeredEvents")&&(a=a.filter(function(a){return!b.__triggeredEvents[a]})),a}},null!=("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define("joosy/modules/events",function(){return Joosy.Modules.Events})}.call(this),function(){var a=[].slice;Joosy.Modules.Log={log:function(){var b;return b=1<=arguments.length?a.call(arguments,0):[],"undefined"!=typeof console&&null!==console?null!=console.log.apply?(b.unshift("Joosy>"),console.log.apply(console,b)):console.log(b.first()):void 0},debug:function(){var b;return b=1<=arguments.length?a.call(arguments,0):[],Joosy.debug()?this.log.apply(this,b):void 0},debugAs:function(){var b,c,d;return c=arguments[0],d=arguments[1],b=3<=arguments.length?a.call(arguments,2):[],Joosy.debug()?(c=Joosy.Module.__className(c)||"unknown context",this.debug.apply(this,[""+c+"> "+d].concat(a.call(b)))):void 0}},null!=("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define("joosy/modules/log",function(){return Joosy.Modules.Log})}.call(this),function(){Joosy.Modules.DOM={eventSplitter:/^(\S+)\s*(.*)$/,included:function(){return this.mapElements=function(a){return this.prototype.hasOwnProperty("__elements")||(this.prototype.__elements=Joosy.Module.merge({},this.__super__.__elements)),Joosy.Module.merge(this.prototype.__elements,a)},this.mapEvents=function(a){return this.prototype.hasOwnProperty("__events")||(this.prototype.__events=Joosy.Module.merge({},this.__super__.__events)),Joosy.Module.merge(this.prototype.__events,a)}},$:function(a,b){return $(a,b||this.$container)},__extractSelector:function(a){var b=this;return a=a.replace(/(\$[A-z0-9\.\$]+)/g,function(a){var c,d,e,f,g,h;for(a=a.split("."),c=a.pop(),e=b,f=0,g=a.length;g>f;f++)d=a[f],e=null!=e?e[d]:void 0;return null!=e?null!=(h=e[c])?h.selector:void 0:void 0}),a.trim()},__assignElements:function(a,b){var c,d,e,f=this;if(a||(a=this),b||(b=this.__elements),b){e=[];for(c in b)d=b[c],e.push(function(b,c){return"string"!=typeof c?f.__assignElements(a["$"+b]={},c):(c=f.__extractSelector(c),a["$"+b]=f.__wrapElement(c),a["$"+b].selector=c)}(c,d));return e}},__wrapElement:function(a){var b=this;return function(c){return c?b.$(a,c):b.$(a)}},__delegateEvents:function(){var a,b,c,d,e,f=this;if(d=this,a=this.__events){e=[];for(b in a)c=a[b],e.push(function(a,b){var c,e,g,h,i,j,k,l,m;for(l=a.split(","),m=[],j=0,k=l.length;k>j;j++)if(g=l[j],g=g.replace(/^\s+/,""),"function"!=typeof b&&(b=f[b]),c=function(a){return b.call(d,$(this),a)},h=g.match(f.eventSplitter),e=h[1],i=f.__extractSelector(h[2]),""===i)f.$container.bind(e,c),m.push(Joosy.Modules.Log.debugAs(f,""+e+" binded on container"));else{if(void 0===i)throw new Error("Unknown element "+h[2]+" in "+Joosy.Module.__className(f.constructor)+" (maybe typo?)");f.$container.on(e,i,c),m.push(Joosy.Modules.Log.debugAs(f,""+e+" binded on "+i))}return m}(b,c));return e}},__clearContainer:function(){return this.$container.unbind().off(),this.$container=$()}},null!=("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define("joosy/modules/dom",function(){return Joosy.Modules.DOM})}.call(this),function(a){var b=function(){},c=0,d=a.document,e=("undefined"==typeof ENV?{}:ENV).DISABLE_RANGE_API,f=!e&&d&&"createRange"in d&&"undefined"!=typeof Range&&Range.prototype.createContextualFragment,g=d&&function(){var a=d.createElement("div");return a.innerHTML="<div></div>",a.firstChild.innerHTML="<script></script>",""===a.firstChild.innerHTML}(),h=d&&function(){var a=d.createElement("div");return a.innerHTML="Test: <script type='text/x-placeholder'></script>Value","Test:"===a.childNodes[0].nodeValue&&" Value"===a.childNodes[2].nodeValue}(),i=function(a){var d;d=this instanceof i?this:new b,d.innerHTML=a;var e="metamorph-"+c++;return d.start=e+"-start",d.end=e+"-end",d};b.prototype=i.prototype;var j,k,l,m,n,o,p,q,r;if(m=function(){return this.startTag()+this.innerHTML+this.endTag()},q=function(){return"<script id='"+this.start+"' type='text/x-placeholder'></script>"},r=function(){return"<script id='"+this.end+"' type='text/x-placeholder'></script>"},f)j=function(a,b){var c=d.createRange(),e=d.getElementById(a.start),f=d.getElementById(a.end);return b?(c.setStartBefore(e),c.setEndAfter(f)):(c.setStartAfter(e),c.setEndBefore(f)),c},k=function(a,b){var c=j(this,b);c.deleteContents();var d=c.createContextualFragment(a);c.insertNode(d)},l=function(){var a=j(this,!0);a.deleteContents()},n=function(a){var b=d.createRange();b.setStart(a),b.collapse(!1);var c=b.createContextualFragment(this.outerHTML());a.appendChild(c)},o=function(a){var b=d.createRange(),c=d.getElementById(this.end);b.setStartAfter(c),b.setEndAfter(c);var e=b.createContextualFragment(a);b.insertNode(e)},p=function(a){var b=d.createRange(),c=d.getElementById(this.start);b.setStartAfter(c),b.setEndAfter(c);var e=b.createContextualFragment(a);b.insertNode(e)};else{var s={select:[1,"<select multiple='multiple'>","</select>"],fieldset:[1,"<fieldset>","</fieldset>"],table:[1,"<table>","</table>"],tbody:[2,"<table><tbody>","</tbody></table>"],tr:[3,"<table><tbody><tr>","</tr></tbody></table>"],colgroup:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],map:[1,"<map>","</map>"],_default:[0,"",""]},t=function(a,b){if(a.getAttribute("id")===b)return a;var c,d,e,f=a.childNodes.length;for(c=0;f>c;c++)if(d=a.childNodes[c],e=1===d.nodeType&&t(d,b))return e},u=function(a,b){var c=[];if(h&&(b=b.replace(/(\s+)(<script id='([^']+)')/g,function(a,b,d,e){return c.push([e,b]),d})),a.innerHTML=b,c.length>0){var e,f=c.length;for(e=0;f>e;e++){var g=t(a,c[e][0]),i=d.createTextNode(c[e][1]);g.parentNode.insertBefore(i,g)}}},v=function(a,b){var c=s[a.tagName.toLowerCase()]||s._default,e=c[0],f=c[1],h=c[2];g&&(b="­"+b);var i=d.createElement("div");u(i,f+b+h);for(var j=0;e>=j;j++)i=i.firstChild;if(g){for(var k=i;1===k.nodeType&&!k.nodeName;)k=k.firstChild;3===k.nodeType&&""===k.nodeValue.charAt(0)&&(k.nodeValue=k.nodeValue.slice(1))}return i},w=function(a){for(;""===a.parentNode.tagName;)a=a.parentNode;return a},x=function(a,b){a.parentNode!==b.parentNode&&b.parentNode.insertBefore(a,b.parentNode.firstChild)};k=function(a,b){var c,e,f,g=w(d.getElementById(this.start)),h=d.getElementById(this.end),i=h.parentNode;for(x(g,h),c=g.nextSibling;c;){if(e=c.nextSibling,f=c===h){if(!b)break;h=c.nextSibling}if(c.parentNode.removeChild(c),f)break;c=e}for(c=v(g.parentNode,a);c;)e=c.nextSibling,i.insertBefore(c,h),c=e},l=function(){var a=w(d.getElementById(this.start)),b=d.getElementById(this.end);this.html(""),a.parentNode.removeChild(a),b.parentNode.removeChild(b)},n=function(a){for(var b,c=v(a,this.outerHTML());c;)b=c.nextSibling,a.appendChild(c),c=b},o=function(a){var b,c,e=d.getElementById(this.end),f=e.nextSibling,g=e.parentNode;for(c=v(g,a);c;)b=c.nextSibling,g.insertBefore(c,f),c=b},p=function(a){var b,c,e=d.getElementById(this.start),f=e.parentNode;c=v(f,a);for(var g=e.nextSibling;c;)b=c.nextSibling,f.insertBefore(c,g),c=b}}i.prototype.html=function(a){return this.checkRemoved(),void 0===a?this.innerHTML:(k.call(this,a),this.innerHTML=a,void 0)},i.prototype.replaceWith=function(a){this.checkRemoved(),k.call(this,a,!0)},i.prototype.remove=l,i.prototype.outerHTML=m,i.prototype.appendTo=n,i.prototype.after=o,i.prototype.prepend=p,i.prototype.startTag=q,i.prototype.endTag=r,i.prototype.isRemoved=function(){var a=d.getElementById(this.start),b=d.getElementById(this.end);return!a||!b},i.prototype.checkRemoved=function(){if(this.isRemoved())throw new Error("Cannot perform operations on a Metamorph that is not in the DOM.")},a.Metamorph=i}(this),function(){var a=[].slice;Joosy.Modules.Renderer={included:function(){return this.view=function(a,b){return null==b&&(b={}),this.prototype.__view=a,this.prototype.__renderDefault=function(c){return null==c&&(c={}),b.dynamic?this.renderDynamic(a,c):this.render(a,c)}},this.helper=function(){var b,c;return b=1<=arguments.length?a.call(arguments,0):[],this.prototype.hasOwnProperty("__helpers")||(this.prototype.__helpers=(null!=(c=this.__super__.__helpers)?c.slice():void 0)||[]),this.prototype.__helpers=this.prototype.__helpers.concat(b).filter(function(a,b,c){return c.indexOf(a)===b})}},render:function(a,b,c){return null==b&&(b={}),null==c&&(c=!1),this.__render(!1,a,b,c)},renderDynamic:function(a,b,c){return null==b&&(b={}),null==c&&(c=!1),this.__render(!0,a,b,c)},__assignHelpers:function(){var a,b,c,d,e,f,g=this;if(null!=this.__helpers){for(this.hasOwnProperty("__helpers")||(this.__helpers=this.__helpers.slice()),e=this.__helpers,f=[],b=c=0,d=e.length;d>c;b=++c)a=e[b],f.push(function(a,b){if(a.constructor!==Object){if(null==g[a])throw new Error("Cannot find method '"+a+"' to use as helper");return g.__helpers[b]={},g.__helpers[b][a]=function(){return g[a].apply(g,arguments)}}}(a,b));
|
2
|
+
return f}},__instantiateHelpers:function(){var a,b,c,d;if(!this.__helpersInstance&&(this.__assignHelpers(),this.__helpersInstance={},this.__helpersInstance.__renderer=this,Joosy.Module.merge(this.__helpersInstance,Joosy.Helpers.Application),null!=Joosy.Helpers.Routes&&Joosy.Module.merge(this.__helpersInstance,Joosy.Helpers.Routes),this.__helpers))for(d=this.__helpers,b=0,c=d.length;c>b;b++)a=d[b],Joosy.Module.merge(this.__helpersInstance,a);return this.__helpersInstance},__instantiateRenderers:function(a){var b=this;return{render:function(c,d){return null==d&&(d={}),b.render(c,d,a)},renderDynamic:function(c,d){return null==d&&(d={}),b.renderDynamic(c,d,a)},renderInline:function(c,d){var e;return null==c&&(c={}),e=function(a){return d.apply(a)},b.renderDynamic(e,c,a)}}},__render:function(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o=this;if(null==c&&(c={}),null==d&&(d=!1),l=this.__renderingStackChildFor(d),l.template=b,l.locals=c,"string"==typeof b)null!=this.__renderSection&&(b=Joosy.templater().resolveTemplate(this.__renderSection(),b,this)),b=Joosy.templater().buildView(b);else if("function"!=typeof b)throw new Error(""+Joosy.Module.__className(this)+"> template (maybe @view) does not look like a string or lambda");if(c.constructor!==Object)throw new Error(""+Joosy.Module.__className(this)+"> locals (maybe @data?) is not a hash");if(f=function(){var a;return a={},Joosy.Module.merge(a,l.locals),Joosy.Module.merge(a,o.__instantiateHelpers(),!1),Joosy.Module.merge(a,o.__instantiateRenderers(l)),a},k=function(){return b(f())},a){i=Metamorph(k()),n=function(){var a,b,c,d,e,f,g,h,j,m,n;if(i.isRemoved()){for(h=i.__bindings,n=[],d=0,f=h.length;f>d;d++)j=h[d],c=j[0],a=j[1],n.push(c.unbind(a));return n}for(m=l.children,e=0,g=m.length;g>e;e++)b=m[e],o.__removeMetamorphs(b);return l.children=[],i.html(k())},m=null,g=function(){return clearTimeout(m),m=setTimeout(n,0)};for(h in c)j=c[h],c.hasOwnProperty(h)&&null!=(null!=j?j.bind:void 0)&&null!=(null!=j?j.unbind:void 0)&&(e=[j,j.bind("changed",g)],l.metamorphBindings.push(e));return i.__bindings=l.metamorphBindings,i.outerHTML()}return k()},__renderingStackElement:function(a){return null==a&&(a=null),{metamorphBindings:[],locals:null,template:null,children:[],parent:a}},__renderingStackChildFor:function(a){var b;return this.__renderingStack||(this.__renderingStack=[]),a?(b=this.__renderingStackElement(a),a.children.push(b),b):(b=this.__renderingStackElement(),this.__renderingStack.push(b),b)},__removeMetamorphs:function(a){var b,c,d,e,f,g=this;if(null==a&&(a=!1),b=function(a){var b,c,d,e,f,h,i,j,k,l;if(null!=a?a.children:void 0)for(j=a.children,e=0,h=j.length;h>e;e++)c=j[e],g.__removeMetamorphs(c);if(null!=a?a.metamorphBindings:void 0){for(k=a.metamorphBindings,f=0,i=k.length;i>f;f++)l=k[f],d=l[0],b=l[1],d.unbind(b);return a.metamorphBindings=[]}},a)return b(a);if(null!=this.__renderingStack){for(e=this.__renderingStack,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(b(a));return f}}},null!=("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define("joosy/modules/renderer",function(){return Joosy.Modules.Renderer})}.call(this),function(){Joosy.Modules.TimeManager={setTimeout:function(a,b){var c;return this.__timeouts||(this.__timeouts=[]),c=window.setTimeout(function(){return b()},a),this.__timeouts.push(c),c},setInterval:function(a,b){var c;return this.__intervals||(this.__intervals=[]),c=window.setInterval(function(){return b()},a),this.__intervals.push(c),c},clearTimeout:function(a){return window.clearTimeout(a)},clearInterval:function(a){return window.clearInterval(a)},__clearTime:function(){var a,b,c,d,e,f,g,h;if(this.__intervals)for(f=this.__intervals,b=0,d=f.length;d>b;b++)a=f[b],window.clearInterval(a);if(this.__timeouts){for(g=this.__timeouts,h=[],c=0,e=g.length;e>c;c++)a=g[c],h.push(window.clearTimeout(a));return h}}},null!=("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define("joosy/modules/time_manager",function(){return Joosy.Modules.TimeManager})}.call(this),function(){var a=[].slice;Joosy.Modules.Filters={included:function(){return this.__registerFilterCollector=function(a){return this[a]=function(b){return this.prototype.hasOwnProperty("__"+a+"s")||(this.prototype["__"+a+"s"]=[].concat(this.__super__["__"+a+"s"]||[])),this.prototype["__"+a+"s"].push(b)},a.charAt(0).toUpperCase()+a.slice(1)},this.registerPlainFilters=function(){var b,c,d,e,f,g=this;for(c=1<=arguments.length?a.call(arguments,0):[],f=[],d=0,e=c.length;e>d;d++)b=c[d],f.push(function(b){var c;return c=g.__registerFilterCollector(b),g.prototype["__run"+c+"s"]=function(){var c,d,e,f,g,h;if(d=1<=arguments.length?a.call(arguments,0):[],this["__"+b+"s"]){for(g=this["__"+b+"s"],h=[],e=0,f=g.length;f>e;e++)c=g[e],"function"!=typeof c&&(c=this[c]),h.push(c.apply(this,d));return h}},g.prototype["__confirm"+c+"s"]=function(){var c,d=this;return c=1<=arguments.length?a.call(arguments,0):[],this["__"+b+"s"]?this["__"+b+"s"].reduce(function(a,b){return"function"!=typeof b&&(b=d[b]),a&&b.apply(d,c)!==!1},!0):!0},g.prototype["__apply"+c+"s"]=function(){var c,d,e,f,g,h;if(d=arguments[0],e=2<=arguments.length?a.call(arguments,1):[],!this["__"+b+"s"])return d;for(h=this["__"+b+"s"],f=0,g=h.length;g>f;f++)c=h[f],"function"!=typeof c&&(c=this[c]),d=c.apply(this,[d].concat(e));return d}}(b));return f},this.registerSequencedFilters=function(){var b,c,d,e,f,g=this;for(c=1<=arguments.length?a.call(arguments,0):[],f=[],d=0,e=c.length;e>d;d++)b=c[d],f.push(function(a){var b;return b=g.__registerFilterCollector(a),g.prototype["__run"+b+"s"]=function(b,c){var d,e;return this["__"+a+"s"]?(e=this["__"+a+"s"],d=this,1===e.length?e[0].apply(this,b.concat(c)):Joosy.synchronize(function(a){var f,g,h,i;for(g=function(c){return a["do"](function(a){return c.apply(d,b.concat(a))})},h=0,i=e.length;i>h;h++)f=e[h],g(f);return a.after(c)})):c()}}(b));return f}}},null!=("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define("joosy/modules/filters",function(){return Joosy.Modules.Filters})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};Joosy.Widget=function(a){function c(a,b){this.params=a,this.previous=b}return b(c,a),c.include(Joosy.Modules.Log),c.include(Joosy.Modules.Events),c.include(Joosy.Modules.DOM),c.include(Joosy.Modules.Renderer),c.include(Joosy.Modules.TimeManager),c.include(Joosy.Modules.Filters),c.mapWidgets=function(a){return this.prototype.hasOwnProperty("__widgets")||(this.prototype.__widgets=Joosy.Module.merge({},this.__super__.__widgets)),Joosy.Module.merge(this.prototype.__widgets,a)},c.independent=function(){return this.prototype.__independent=!0},c.registerPlainFilters("beforeLoad","afterLoad","afterUnload"),c.registerSequencedFilters("beforePaint","paint","erase","fetch"),c.prototype.registerWidget=function(a,b){return"string"==typeof a&&(a=this.__normalizeSelector(a)),b=this.__normalizeWidget(b),b.__bootstrapDefault(this,a),b},c.prototype.unregisterWidget=function(a){return a.__unload()},c.prototype.replaceWidget=function(a,b){return b=this.__normalizeWidget(b),b.previous=a,b.__bootstrapDefault(this,a.$container),b},c.prototype.navigate=function(){var a;return null!=(a=Joosy.Router)?a.navigate.apply(a,arguments):void 0},c.prototype.__renderSection=function(){return"widgets"},c.prototype.__nestingMap=function(){var a,b,c,d;a={},d=this.__widgets;for(b in d)c=d[b],c=this.__normalizeWidget(c),a[b]={instance:c,nested:c.__nestingMap()};return a},c.prototype.__bootstrapDefault=function(a,b){return this.__bootstrap(a,this.__nestingMap(),b)},c.prototype.__bootstrap=function(a,b,c,d){var e=this;return this.$container=c,null==d&&(d=!0),this.wait("section:fetched section:erased",function(){return e.__runPaints([],function(){return e.__paint(a,b,e.$container)})}),this.__erase(),d?this.__fetch(b):void 0},c.prototype.__fetch=function(a){var b=this;return this.data={},this.synchronize(function(c){var d,e,f;f=function(a,b){return b.instance.__fetch(b.nested),b.instance.__independent?void 0:c["do"](function(a){return b.instance.wait("section:fetched",a)})};for(e in a)d=a[e],f(e,d);return c["do"](function(a){return b.__runFetchs([],a)}),c.after(function(){return b.trigger({name:"section:fetched",remember:!0})})})},c.prototype.__erase=function(){var a=this;return null!=this.previous?this.previous.__runErases([],function(){return a.previous.__unload(),a.__runBeforePaints([],function(){return a.trigger({name:"section:erased",remember:!0})})}):this.__runBeforePaints([],function(){return a.trigger({name:"section:erased",remember:!0})})},c.prototype.__paint=function(a,b,c){var d,e,f,g=this;this.parent=a,this.$container=c,this.__nestedSections=[],this.$container.html("function"==typeof this.__renderDefault?this.__renderDefault(this.data||{}):void 0),this.__load(),f=[];for(e in b)d=b[e],f.push(function(a,b){var d;return c=g.__normalizeSelector(a),!b.instance.__independent||(null!=(d=b.instance.__triggeredEvents)?d["section:fetched"]:void 0)?b.instance.__paint(g,b.nested,c):b.instance.__bootstrap(g,b.nested,c,!1)}(e,d));return f},c.prototype.__load=function(){var a;return this.parent&&((a=this.parent).__nestedSections||(a.__nestedSections=[]),this.parent.__nestedSections.push(this)),this.__assignElements(),this.__delegateEvents(),this.__runAfterLoads()},c.prototype.__unload=function(a){var b,c,d,e;if(null==a&&(a=!0),this.__nestedSections){for(e=this.__nestedSections,c=0,d=e.length;d>c;c++)b=e[c],b.__unload(!1);delete this.__nestedSections}return this.__clearContainer(),this.__clearTime(),this.__removeMetamorphs(),this.__runAfterUnloads(),this.parent&&a&&this.parent.__nestedSections.splice(this.parent.__nestedSections.indexOf(this),1),delete this.previous,delete this.parent},c.prototype.__normalizeSelector=function(a){return"$container"===a?this.$container:$(this.__extractSelector(a),this.$container)},c.prototype.__normalizeWidget=function(a){return"function"!=typeof a||Joosy.Module.hasAncestor(a,Joosy.Widget)||(a=a.call(this)),Joosy.Module.hasAncestor(a,Joosy.Widget)&&(a=new a),a},c}(Joosy.Module),null!=("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define("joosy/widget",function(){return Joosy.Widget})}.call(this),function(){Joosy.helpers("Application",function(){var a,b;return b=document.createTextNode("test"),a=document.createElement("span"),a.appendChild(b),this.escapeOnce=function(c){return b.nodeValue=c,a.innerHTML},this.tag=function(a,b,c,d){var e,f,g,h;null==b&&(b={}),null==c&&(c=!1),null==d&&(d=!0),e=document.createElement(a),g=document.createElement("div");for(a in b)h=b[a],d&&(h=this.escapeOnce(h)),e.setAttribute(a,h);return g.appendChild(e),f=g.innerHTML,c&&(f=f.replace("/>",">")),f},this.contentTag=function(a,b,c,d){var e,f,g,h,i;null==b&&(b=null),null==c&&(c=null),null==d&&(d=!0),"string"==typeof b?(c||(c={}),e=b):"function"==typeof b?(c={},e=b()):("function"==typeof c?(d=!0,e=c()):(d=c,e=d()),c=b),g=document.createElement(a),h=document.createElement("div");for(a in c)i=c[a],d&&(i=this.escapeOnce(i)),g.setAttribute(a,i);try{g.innerHTML=e}catch(j){if(f=j,e)throw f}return h.appendChild(g),h.innerHTML},this.renderWrapped=function(a,b){return this.render(a,Joosy.Module.merge(this,{yield:b()}))}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};Joosy.Layout=function(a){function c(a,b){this.params=a,this.previous=b,this.uid=Joosy.uid()}return b(c,a),c.helper("page"),c.prototype.page=function(a,b){return null==b&&(b={}),b.id=this.uid,Joosy.Helpers.Application.tag(a,b)},c.prototype.content=function(){return $("#"+this.uid)},c.prototype.__renderSection=function(){return"layouts"},c.prototype.__nestingMap=function(a){var b;return b=c.__super__.__nestingMap.call(this),b["#"+this.uid]={instance:a,nested:a.__nestingMap()},b},c.prototype.__bootstrapDefault=function(a,b){return this.__bootstrap(null,this.__nestingMap(a),b)},c}(Joosy.Widget),null!=("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define("joosy/layout",function(){return Joosy.Layout})}.call(this),function(){Joosy.Modules.Page={}}.call(this),function(){Joosy.Modules.Page.Scrolling={included:function(){return this.scroll=function(a,b){return null==b&&(b={}),this.prototype.__scrollElement=a,this.prototype.__scrollSpeed=b.speed||500,this.prototype.__scrollMargin=b.margin||0},this.paint(function(a){return this.__scrollElement&&0!==this.__scrollSpeed&&this.__fixHeight(),a()}),this.afterLoad(function(){return this.__scrollElement?this.__performScrolling():void 0})},__performScrolling:function(){var a,b,c=this;return a=(null!=(b=$(this.__extractSelector(this.__scrollElement)).offset())?b.top:void 0)+this.__scrollMargin,Joosy.Modules.Log.debugAs(this,"Scrolling to "+this.__extractSelector(this.__scrollElement)),$("html, body").animate({scrollTop:a},this.__scrollSpeed,function(){return 0!==c.__scrollSpeed?c.__releaseHeight():void 0})},__fixHeight:function(){return $("html").css("min-height",$(document).height())},__releaseHeight:function(){return $("html").css("min-height","")}}}.call(this),function(){Joosy.Modules.Page.Title={title:function(a,b){return null==b&&(b=" / "),this.afterLoad(function(){return"function"==typeof a&&(a=a.apply(this)),a instanceof Array&&(a=a.join(b)),this.__previousTitle=document.title,document.title=a}),this.afterUnload(function(){return document.title=this.__previousTitle})}}}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};Joosy.Page=function(a){function c(a,b){var c;this.params=a,this.previous=b,this.layoutShouldChange=(null!=(c=this.previous)?c.__layoutClass:void 0)!==this.__layoutClass,this.halted=!this.__confirmBeforeLoads(),this.layout=function(){var b,c;switch(!1){case!(this.layoutShouldChange&&this.__layoutClass):return new this.__layoutClass(a,null!=(b=this.previous)?b.layout:void 0);case!!this.layoutShouldChange:return null!=(c=this.previous)?c.layout:void 0}}.call(this),this.layoutShouldChange&&!this.layout&&(this.previous=this.previous.layout)}return b(c,a),c.layout=function(a){return this.prototype.__layoutClass=a},c.include(Joosy.Modules.Page.Scrolling),c.extend(Joosy.Modules.Page.Title),c.prototype.__renderSection=function(){return"pages"},c.prototype.__bootstrapDefault=function(a){var b;return this.__bootstrap(this.layout,this.__nestingMap(),(null!=(b=this.layout)?b.content():void 0)||a)},c}(Joosy.Widget),null!=("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define("joosy/page",function(){return Joosy.Page})}.call(this),function(){Joosy.helpers("Routes",function(){return this.linkTo=function(a,b,c){var d,e;return null==a&&(a=""),null==b&&(b=""),null==c&&(c={}),"function"==typeof c&&(d=c,e=[a,b],b=e[0],c=e[1],a=d()),Joosy.Helpers.Application.contentTag("a",a,Joosy.Module.merge(c,{"data-joosy":!0,href:b}))}})}.call(this),function(){var a,b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};Joosy.Router=function(b){function d(){return a=d.__super__.constructor.apply(this,arguments)}var e;return c(d,b),d.extend(Joosy.Modules.Events),$(window).bind("popstate",function(a){return null!=window.history.loaded?d.trigger("popstate",a):window.history.loaded=!0}),$(document).on("click","a[data-joosy]",function(a){return a.preventDefault(),Joosy.Router.navigate(this.getAttribute("href"))}),e=function(){function a(a,b){this.__namespace=a,this.__alias=b}return a.run=function(b,c,d){var e;return null==c&&(c=""),null==d&&(d=""),e=new a(c,d),b.call(e)},a.prototype.match=function(a,b){var c;return null==b&&(b={}),null!=b.as&&(c=this.__alias?this.__alias+b.as.charAt(0).toUpperCase()+b.as.slice(1):b.as),a=this.__namespace+a,Joosy.Router.compileRoute(a,b.to,c)},a.prototype.root=function(a){return null==a&&(a={}),this.match("/",{to:a.to,as:a.as||"root"})},a.prototype.notFound=function(a){return null==a&&(a={}),this.match(404,{to:a.to})},a.prototype.namespace=function(b,c,d){var e;return null==c&&(c={}),2===arguments.length&&(d=c,c={}),a.run(d,this.__namespace+b,null!=(e=c.as)?e.toString():void 0)},a}(),d.map=function(a,b){var c,d,e;e=[];for(c in a)d=a[c],null!=b&&(c=b+"/"+c),"function"==typeof d||d.prototype?e.push(this.compileRoute(c,d)):e.push(this.map(d,c));return e},d.draw=function(a){return e.run(a)},d.setup=function(a,b,c){var d,e=this;return this.config=a,this.responder=b,null==c&&(c=!0),history.pushState||(this.config.prefix=this.config.hashSuffix,this.config.html5=!1),this.config.html5||(this.config.prefix=this.config.hashSuffix),(d=this.config).prefix||(d.prefix=""),this.config.html5?(this.config.prefix=("/"+this.config.prefix+"/").replace(/\/{2,}/g,"/"),this.listener=this.bind("popstate pushstate",function(){return e.respond(e.canonizeLocation())})):(this.config.prefix=this.config.prefix.replace(/^\#?\/?/,"").replace(/\/?$/,""),$(window).bind("hashchange.JoosyRouter",function(){return e.respond(e.canonizeLocation())})),c?this.respond(this.canonizeLocation()):void 0},d.reset=function(){return this.unbind(this.listener),$(window).unbind(".JoosyRouter"),this.restriction=!1,this.routes={}},d.restrict=function(a){this.restriction=a},d.navigate=function(a,b){var c;null==b&&(b={}),c=a,this.config.html5?(this.config.prefix&&"/"===c[0]&&!c.match(RegExp("^"+this.config.prefix.replace(/\/$/,"")+"(/|$)"))&&(c=c.replace(/^\//,this.config.prefix)),history.pushState({},"",c),this.trigger("pushstate")):(this.config.prefix&&!c.match(RegExp("^#?/?"+this.config.prefix+"(/|$)"))&&(c=c.replace(/^\#?\/?/,""+this.config.prefix+"/")),location.hash=c)},d.canonizeLocation=function(){return this.config.html5?location.pathname.replace(RegExp("^("+this.config.prefix+"?)?/?"),"/")+location.search:location.hash.replace(RegExp("^#?/?("+this.config.prefix+"(/|$))?"),"/")},d.compileRoute=function(a,b,c){var d,e,f;return"404"===a.toString()?(this.wildcardAction=b,void 0):("/"===a[0]&&(a=a.substr(1)),d=a.replace(/\/{2,}/g,"/"),f={},d=d.replace(/\/:([^\/]+)/g,"/([^/]+)"),d=d.replace(/^\/?/,"^/?"),d=d.replace(/\/?$/,"/?$"),e=(a.match(/\/:[^\/]+/g)||[]).map(function(a){return a.substr(2)}),this.routes||(this.routes={}),this.routes[d]={to:b,capture:e,as:c},null!=c?this.defineHelpers(a,c):void 0)},d.respond=function(a){var b,c,d,e,f,g;if(Joosy.Modules.Log.debug("Router> Answering '"+a+"'"),this.restriction&&null===a.match(this.restriction))return this.trigger("restricted",a),void 0;f=a.split("?"),a=f[0],c=f[1],c=(null!=c?"function"==typeof c.split?c.split("&"):void 0:void 0)||[],g=this.routes;for(d in g)if(e=g[d],this.routes.hasOwnProperty(d)&&(b=a.match(new RegExp(d))))return this.responder(e.to,this.__grabParams(c,e,b)),this.trigger("responded",a),void 0;return null!=this.wildcardAction?(this.responder(this.wildcardAction,a),this.trigger("responded")):this.trigger("missed")},d.defineHelpers=function(a,b){var c;return c=function(b){var c,d,e,f,g;if(e=a,c=a.match(/\/:[^\/]+/g))for(f=0,g=c.length;g>f;f++)d=c[f],e=e.replace(d.substr(1),b[d.substr(2)]);return Joosy.Router.config.html5?""+Joosy.Router.config.prefix+e:"#"+Joosy.Router.config.prefix+e},Joosy.helpers("Routes",function(){return this[""+b+"Path"]=c,this[""+b+"Url"]=function(a){return Joosy.Router.config.html5?""+location.origin+c(a):""+location.origin+location.pathname+c(a)}})},d.__grabParams=function(a,b,c){var d,e,f,g,h,i,j,k,l,m;if(null==b&&(b=null),null==c&&(c=[]),g={},c.shift(),d=null!=b?b.capture:void 0)for(i=0,k=d.length;k>i;i++)f=d[i],g[f]=decodeURIComponent(c.shift());for(j=0,l=a.length;l>j;j++)e=a[j],e.length>0&&(m=e.split("="),f=m[0],h=m[1],g[f]=h);return g},d}.call(this,Joosy.Module),null!=("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define("joosy/router",function(){return Joosy.Router})}.call(this),function(){Joosy.Templaters.JST=function(){function a(a){this.config=null!=a?a:{},null!=this.config.prefix&&this.config.prefix.length>0&&(this.prefix=this.config.prefix)}return a.prototype.buildView=function(a){var b,c,d,e,f;for(d=!1,b=this.prefix?[""+this.prefix+"/templates/"+a+"-"+("undefined"!=typeof I18n&&null!==I18n?I18n.locale:void 0),""+this.prefix+"/templates/"+a]:["templates/"+a+"-"+("undefined"!=typeof I18n&&null!==I18n?I18n.locale:void 0),"templates/"+a],e=0,f=b.length;f>e;e++)if(c=b[e],window.JST[c])return window.JST[c];throw new Error("Template '"+a+"' not found. Checked at: '"+b.join(", ")+"'")},a.prototype.resolveTemplate=function(a,b,c){var d,e,f;return"/"===b[0]?b.substr(1):(d=null!=(e=c.constructor)?null!=(f=e.__namespace__)?f.map(function(a){return inflection.underscore(a)}):void 0:void 0,d||(d=[]),d.unshift(a),""+d.join("/")+"/"+b)},a}(),null!=("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define("joosy/templaters/jst",function(){return Joosy.Templaters.JST})}.call(this),function(){Joosy.helpers("Application",function(){return this.widget=function(a,b,c){var d=this;return null==c&&(c=b,b={}),b.id=Joosy.uid(),this.__renderer.setTimeout(0,function(){return d.__renderer.registerWidget($("#"+b.id),c)}),this.tag(a,b)}})}.call(this),function(){}.call(this),function(){Joosy.Application=function(){function a(){}return a.Pages={},a.Layouts={},a.Controls={},a.initialized=!1,a.loading=!0,a.defaultConfig={test:!1,debug:!1,templater:{prefix:""},router:{html5:!1,base:"",prefix:""}},a.initialize=function(a,b){var c=this;if(this.selector=a,null==b&&(b={}),this.initialized)throw new Error("Attempted to initialize Application twice");return this.config={},Joosy.Module.merge(this.config,this.defaultConfig,!0,!0),null!=window.JoosyEnvironment&&Joosy.Module.merge(this.config,window.JoosyEnvironment,!0,!0),Joosy.Module.merge(this.config,b,!0,!0),this.config.test&&this.forceSandbox(),Joosy.templater(new Joosy.Templaters.JST(this.config.templater)),Joosy.debug(this.config.debug),Joosy.Router.setup(this.config.router,function(a,b){if(Joosy.Module.hasAncestor(a,Joosy.Page))return c.changePage(a,b);if("function"==typeof a)return a(b);throw new Error("Unknown kind of route action: "+a)}),this.initialized=!0},a.reset=function(){var a;return Joosy.Router.reset(),Joosy.templater(!1),Joosy.debug(!1),null!=(a=this.page)&&a.__unload(),delete this.page,this.loading=!0,this.initialized=!1},a.content=function(){return $(this.selector)},a.changePage=function(a,b){var c;return c=new a(b,this.page),c.halted?void 0:(c.layoutShouldChange&&c.layout?c.layout.__bootstrapDefault(c,this.content()):c.__bootstrapDefault(this.content()),this.page=c)},a.forceSandbox=function(){var a;return a=Joosy.uid(),this.selector="#"+a,$("body").append($("<div/>").attr("id",a).css({height:"0px",width:"0px",overflow:"hidden"}))},a}(),null!=("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define("joosy/application",function(){return Joosy.Application})}.call(this),function(){}.call(this);
|