json-object-editor 0.9.901 → 0.10.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/app.js +5 -4
- package/capp/capp.css +1 -0
- package/css/jif/Read Me.txt +5 -5
- package/css/jif/demo-files/demo.css +153 -153
- package/css/jif/demo-files/demo.js +30 -30
- package/css/jif/demo.html +285 -285
- package/css/jif/fonts/joeiconfont.svg +24 -24
- package/css/jif/ie7/ie7.css +45 -45
- package/css/jif/ie7/ie7.js +46 -46
- package/css/jif/selection.json +573 -573
- package/css/joe.css +6 -6
- package/css/jquery-ui-1.10.4.custom.min.css +5 -5
- package/css/jquery-ui.min.css +6 -6
- package/css/jquery.timepicker.css +72 -72
- package/es5-build/capp/capp.js +1083 -1083
- package/es5-build/js/JsonObjectEditor_es5.jquery.craydent.js +11047 -11047
- package/es5-build/web-components/account-info.js +136 -136
- package/es5-build/web-components/capp-components.js +160 -160
- package/es5-build/web-components/capp-panel.js +85 -85
- package/es5-build/web-components/capp-view.js +73 -73
- package/es5-build/web-components/joe-autocomplete.js +149 -149
- package/es5-build/web-components/joe-button.js +132 -132
- package/es5-build/web-components/joe-card.js +92 -92
- package/es5-build/web-components/joe-component.js +74 -74
- package/es5-build/web-components/joe-field.js +70 -70
- package/es5-build/web-components/joe-list-item.js +176 -176
- package/es5-build/web-components/joe-user-cube.js +100 -100
- package/es5-build/web-components/report-components.js +133 -133
- package/grunt/build +86 -86
- package/grunt/package-lock.json +6301 -2489
- package/grunt/package.json +47 -47
- package/grunt/src +86 -86
- package/js/JsonObjectEditor.jquery.craydent.js +3 -2
- package/js/joe-full.js +11 -10
- package/js/joe.js +12 -11
- package/js/joe_es5.js +11056 -11056
- package/js/jquery.timepicker.min.js +1 -1
- package/js/leaflet.js +8 -8
- package/js/libs/adapter-latest.js +4400 -4400
- package/js/libs/craydent-1.9.2.js +11741 -11741
- package/js/libs/craydent-upload-2.0.0.js +394 -394
- package/js/libs/hammer.min.208.js +6 -6
- package/js/libs/jquery-3.5.1.min.js +2 -2
- package/js/libs/moment.min.js +6 -6
- package/js/native-shim.js +46 -46
- package/js/plugins/c3/c3.min.js +5 -5
- package/js/plugins/c3/d3.v3.min.js +4 -4
- package/js/plugins/threejs/Detector.js +78 -78
- package/js/plugins/threejs/LICENSE +21 -21
- package/js/plugins/threejs/MTLLoader.js +417 -417
- package/js/plugins/threejs/OBJLoader.js +564 -564
- package/js/plugins/threejs/OrbitControls.js +1037 -1037
- package/js/plugins/threejs/README.md +9 -9
- package/js/plugins/threejs/assets/female-croupier-2013-03-26.mtl +3 -3
- package/js/plugins/threejs/index.html +178 -178
- package/js/plugins/threejs/three.js +41507 -41507
- package/package copy.json +62 -0
- package/package.json +12 -13
- package/server/schemas/initiative.js +85 -0
- package/server/webconfig.js +1 -1
- package/projectFilesBackup/.idea/workspace.xml +0 -424
package/es5-build/capp/capp.js
CHANGED
|
@@ -1,1084 +1,1084 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function CraydentApp(specs, render) {
|
|
4
|
-
if (typeof specs == "boolean") {
|
|
5
|
-
specs = {
|
|
6
|
-
autoInit: specs
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
var renderQueue = render ? $.type(render) == "array" ? render : [render] : [];
|
|
11
|
-
var self = this;
|
|
12
|
-
self.instances = {};
|
|
13
|
-
var dspecs = {
|
|
14
|
-
theme: 'light',
|
|
15
|
-
container: $('body')
|
|
16
|
-
};
|
|
17
|
-
var specs = $c.merge(dspecs, specs);
|
|
18
|
-
|
|
19
|
-
this.constructComponent = function (componentName) {
|
|
20
|
-
self[componentName] = {};
|
|
21
|
-
};
|
|
22
|
-
/*----------------------UTIL FUNCTIONS ----------------------*/
|
|
23
|
-
|
|
24
|
-
var utils;
|
|
25
|
-
this.utils = utils = {
|
|
26
|
-
addRenderFunction: function addRenderFunction(component) {
|
|
27
|
-
component.render = function (content, target, specs) {
|
|
28
|
-
var cssclass = specs.cssclass || '';
|
|
29
|
-
var CONTENT = (component.before_content || '') + content + (component.after_content || '');
|
|
30
|
-
var h = '<' + component.tag + ' class="' + cssclass + '">' + CONTENT + '</' + component.tag + '>';
|
|
31
|
-
|
|
32
|
-
if (target || component.target) {
|
|
33
|
-
$(target || component.target).append(h);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return h;
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
addRenderers: function addRenderers() {},
|
|
40
|
-
propAsFuncOrValue: function propAsFuncOrValue(prop, toPass) {
|
|
41
|
-
/*|{
|
|
42
|
-
featured:true,
|
|
43
|
-
tags:'helper',
|
|
44
|
-
description:'Parses the property passed as a function or value, can be passed an object to be a parameter of the function call.'
|
|
45
|
-
}|*/
|
|
46
|
-
try {
|
|
47
|
-
var toPass = toPass || null;
|
|
48
|
-
|
|
49
|
-
if (prop && typeof prop == 'function') {
|
|
50
|
-
return prop(toPass);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return prop;
|
|
54
|
-
} catch (e) {
|
|
55
|
-
logit('capp error parsing func val:[prop=' + prop + ']' + (e.stack || e));
|
|
56
|
-
return '';
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
initElements: function initElements(elementType, css, callback) {
|
|
60
|
-
var callback = callback || null;
|
|
61
|
-
$(elementType).each(function () {
|
|
62
|
-
if (!$(this).hasClass('init')) {
|
|
63
|
-
var data = $(this).data();
|
|
64
|
-
var id = data['capp'] || cuid();
|
|
65
|
-
var domid = $(this).attr('id');
|
|
66
|
-
var css = {};
|
|
67
|
-
$(this).css(css).addClass('init');
|
|
68
|
-
$(this).attr('data-capp', id);
|
|
69
|
-
var type = (self.instances[id] || {}).type || elementType.replace('capp-', '').toLowerCase();
|
|
70
|
-
self.instances[id] = $.extend(self.instances[id] || {}, {
|
|
71
|
-
dom: $(this),
|
|
72
|
-
data: data,
|
|
73
|
-
domid: domid,
|
|
74
|
-
type: type
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
if (callback) {
|
|
78
|
-
callback($(this), data);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
/*----------------------UTIL FUNCTIONS ----------------------*/
|
|
85
|
-
|
|
86
|
-
/*----------------------BEGIN WRAPPER ----------------------*/
|
|
87
|
-
|
|
88
|
-
this.Wrapper = {
|
|
89
|
-
tag: 'capp-wrapper',
|
|
90
|
-
target: 'body',
|
|
91
|
-
respond: function respond() {
|
|
92
|
-
var wrapperdom = $(self.Wrapper.tag)[0];
|
|
93
|
-
var sizeClass = '';
|
|
94
|
-
|
|
95
|
-
if (wrapperdom.className.indexOf('-size') == -1) {
|
|
96
|
-
wrapperdom.className += ' large-size ';
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if ($(self.Wrapper.tag).width() < 600) {
|
|
100
|
-
sizeClass = 'small-size';
|
|
101
|
-
} else {
|
|
102
|
-
sizeClass = 'large-size';
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
wrapperdom.className = wrapperdom.className.replace(/[a-z]*-size/, sizeClass);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
var Wrapper = this.Wrapper;
|
|
109
|
-
|
|
110
|
-
Wrapper.render = function (content, target) {
|
|
111
|
-
var h = '<' + self.Wrapper.tag + '>' + content + '</' + self.Wrapper.tag + '>';
|
|
112
|
-
|
|
113
|
-
if (target) {
|
|
114
|
-
$(target).append(h);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if ($c.isMobile()) {
|
|
118
|
-
var capwrap = document.getElementsByTagName('capp-wrapper')[0];
|
|
119
|
-
capwrap.style.minHeight = body.style.minHeight = window.innerHeight + 'px';
|
|
120
|
-
capwrap.style.minWidth = body.style.minWidth = window.innerWidth + 'px';
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return h;
|
|
124
|
-
};
|
|
125
|
-
/*----------------------END WRAPPER -------------------------*/
|
|
126
|
-
|
|
127
|
-
/*----------------------BEGIN HEADER ----------------------*/
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
this.Header = {
|
|
131
|
-
tag: 'capp-header',
|
|
132
|
-
target: 'capp-wrapper',
|
|
133
|
-
before_content: '<capp-header-bonus ></capp-header-bonus>'
|
|
134
|
-
};
|
|
135
|
-
var Header = this.Header;
|
|
136
|
-
utils.addRenderFunction(Header);
|
|
137
|
-
/* Header.render = function(content,target){
|
|
138
|
-
var h = '<'+self.Header.tag+' class="'+specs.theme+'-bg">'+content+'</'+self.Header.tag+'>';
|
|
139
|
-
|
|
140
|
-
};*/
|
|
141
|
-
|
|
142
|
-
/*----------------------END HEADER -------------------------*/
|
|
143
|
-
|
|
144
|
-
/*----------------------BEGIN BODY -------------------------*/
|
|
145
|
-
|
|
146
|
-
this.Body = {
|
|
147
|
-
tag: 'capp-body',
|
|
148
|
-
target: 'capp-wrapper'
|
|
149
|
-
};
|
|
150
|
-
var Body = this.Body;
|
|
151
|
-
utils.addRenderFunction(Body);
|
|
152
|
-
/*----------------------END BODY ----------------------*/
|
|
153
|
-
|
|
154
|
-
/*----------------------BEGIN VIEWS ----------------------*/
|
|
155
|
-
|
|
156
|
-
this.View = {
|
|
157
|
-
tag: 'capp-view'
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
this.View.toggle = function (ids, showhide) {
|
|
161
|
-
if (showhide != null) {
|
|
162
|
-
showhide = !showhide;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
var ids = ids || null;
|
|
166
|
-
|
|
167
|
-
if (typeof ids == "string") {
|
|
168
|
-
ids = ids.split(',');
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (ids && ids.length) {
|
|
172
|
-
ids.map(function (id) {
|
|
173
|
-
$(self.View.tag + '#' + id).toggleClass('hidden', showhide);
|
|
174
|
-
});
|
|
175
|
-
} else {
|
|
176
|
-
$(self.View.tag).toggleClass('hidden', showhide);
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
this.View.show = function (id) {
|
|
181
|
-
self.View.toggle(null, false);
|
|
182
|
-
self.View.toggle(id, true);
|
|
183
|
-
};
|
|
184
|
-
/*----------------------END VIEWS -------------------------*/
|
|
185
|
-
|
|
186
|
-
/*----------------------BEGIN BUTTONS ----------------------*/
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
this.Button = {};
|
|
190
|
-
|
|
191
|
-
this.Button.add = function (name, icon, action, container, specs) {
|
|
192
|
-
var obj = {};
|
|
193
|
-
|
|
194
|
-
if ($.type(name) == 'object') {
|
|
195
|
-
obj = name;
|
|
196
|
-
name = utils.propAsFuncOrValue(name.name);
|
|
197
|
-
action = utils.propAsFuncOrValue(obj.action);
|
|
198
|
-
icon = utils.propAsFuncOrValue(obj.icon);
|
|
199
|
-
container = utils.propAsFuncOrValue(obj.container);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
var schemaname;
|
|
203
|
-
var specs = specs || {};
|
|
204
|
-
|
|
205
|
-
if (specs.schema) {
|
|
206
|
-
schemaname = specs.schema.display || specs.schema.name || specs.schema;
|
|
207
|
-
specs.create = specs.schema.name || specs.schema;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
var id = specs.id ? 'id="' + specs.id + '"' : '';
|
|
211
|
-
var counter = specs.counter == 0 || specs.counter ? '<capp-counter>' + specs.counter + '</capp-counter>' : ''; // var newWindowLink = (specs.newWindowLink)?'<a class="capp-button-sublink capp-subthemed" onclick="__cancelPropagation();"href="'+(specs.newWindowLink||'')+'" target="_blank" title="new window">'+self.svgs.newwindow+'</a>':'';
|
|
212
|
-
|
|
213
|
-
var create = specs.create ? '<div class="capp-button-sublink capp-subthemed" onclick="_joe.createObject(\'' + specs.create + '\'); __cancelPropagation();" title="create">' + self.svgs.quickadd + '</div>' : '';
|
|
214
|
-
var btn_html = '<capp-button ' + id + ' onclick="' + action + '" class="' + (specs.cssclass || '') + '">' + (specs.newWindowLink && '<a onclick="__cancelClick();" href="' + specs.newWindowLink + '" >' || '') + (icon && '<capp-button-icon title="' + name + '">' + icon + '</capp-button-icon> ' + '<capp-button-label>' + name + counter + create +
|
|
215
|
-
/*newWindowLink+*/
|
|
216
|
-
'</capp-button-label> ' || name) + (specs.newWindowLink && '</a>' || '') + '</capp-button>';
|
|
217
|
-
$(container) && $(container).append(btn_html);
|
|
218
|
-
return btn_html;
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
this.Button.update = function (id, specs) {
|
|
222
|
-
var specs = specs || {};
|
|
223
|
-
|
|
224
|
-
var label = _joe.propAsFuncOrValue(specs.label);
|
|
225
|
-
|
|
226
|
-
var counter = _joe.propAsFuncOrValue(specs.counter);
|
|
227
|
-
|
|
228
|
-
if (label) {
|
|
229
|
-
$('#' + id + ' capp-button-label').html(label);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
if (counter) {
|
|
233
|
-
if ($('#' + id + ' capp-counter').length) {
|
|
234
|
-
$('#' + id + ' capp-counter').html(counter);
|
|
235
|
-
} else {
|
|
236
|
-
$('#' + id + ' capp-button-label').append('<capp-counter>' + counter + '</capp-counter>');
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
this.Button.addFromSchema = function (schema, specs) {
|
|
242
|
-
var specs = $.extend({
|
|
243
|
-
container: 'capp-panel'
|
|
244
|
-
}, specs);
|
|
245
|
-
var icon = schema.name;
|
|
246
|
-
|
|
247
|
-
if (schema.menuicon || schema.icon) {
|
|
248
|
-
icon = (schema.menuicon || schema.icon) + '<svg-label>' + (schema.display || schema.name) + '</svg-label>';
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
return self.Button.add(schema.display || schema.name, icon, '_joe.current.clear(); goJoe(\'' + schema.name + '\');', specs.container, {
|
|
252
|
-
schema: schema,
|
|
253
|
-
id: schema.name + 'SchemaBtn',
|
|
254
|
-
newWindowLink: '#/' + schema.name,
|
|
255
|
-
cssclass: schema.default_schema && 'default-schema' || ''
|
|
256
|
-
});
|
|
257
|
-
};
|
|
258
|
-
/*----------------------END BUTTONS ----------------------*/
|
|
259
|
-
|
|
260
|
-
/*----------------------BEGIN MENU ----------------------*/
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
this.Menu = {
|
|
264
|
-
tag: 'capp-menu'
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
this.Menu.add = function (label, items, container, specs) {
|
|
268
|
-
var obj = {};
|
|
269
|
-
var specs = specs || {};
|
|
270
|
-
var cssclass;
|
|
271
|
-
|
|
272
|
-
if ($.type(label) == 'object') {
|
|
273
|
-
obj = label;
|
|
274
|
-
items = label.items;
|
|
275
|
-
container = label.container;
|
|
276
|
-
specs = label.specs;
|
|
277
|
-
cssclass = label.cssclass;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
var temp = '<capp-menu-option class="${cssclass}" onclick="${action}">${name}</capp-menu-option>';
|
|
281
|
-
|
|
282
|
-
function renderBonus(side, content) {}
|
|
283
|
-
|
|
284
|
-
var menu_html = '<capp-menu class="' + (specs.cssclass || cssclass) + '">' + '<capp-menu-label class="' + (specs.labelcss || '') + '">' + label + '</capp-menu-label>' + '<capp-menu-panel>';
|
|
285
|
-
items.map(function (i) {
|
|
286
|
-
temp = _joe && _joe.propAsFuncOrValue(specs.template, i) || temp;
|
|
287
|
-
menu_html += fillTemplate(temp, i);
|
|
288
|
-
});
|
|
289
|
-
menu_html += '</capp-menu-panel>' + '</capp-menu>';
|
|
290
|
-
$(container) && $(container).append(menu_html);
|
|
291
|
-
$('capp-menu-label').not('.init').click(self.Menu.init).addClass('init');
|
|
292
|
-
return menu_html;
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
this.Menu.init = function () {
|
|
296
|
-
$(this).parent().toggleClass('expanded').siblings().removeClass('expanded');
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
this.Menu.addFromApps = function (apps, label, cssclass) {
|
|
300
|
-
var app_items = [],
|
|
301
|
-
link,
|
|
302
|
-
appname;
|
|
303
|
-
apps.map(function (a) {
|
|
304
|
-
var cssclass = location.pathname.indexOf(a) != -1 ? "selected" : '';
|
|
305
|
-
var link = a + location.search;
|
|
306
|
-
appname = a; //TODO allow appname to use app title or display
|
|
307
|
-
|
|
308
|
-
app_items.push({
|
|
309
|
-
name: appname + '<capp-menu-option-bonus title="open in new window" onclick="window.open(\'' + link + '\'); window.event.stopPropagation();">' + self.svgs.newwindow + '</capp-menu-option-bonus>',
|
|
310
|
-
action: 'window.location=\'/JOE/' + link + '\'',
|
|
311
|
-
cssclass: cssclass
|
|
312
|
-
});
|
|
313
|
-
});
|
|
314
|
-
app_items.push({
|
|
315
|
-
name: 'Docs',
|
|
316
|
-
action: 'window.open(\'/JsonObjectEditor/docs.html#/method/JOE\'); window.event.stopPropagation();'
|
|
317
|
-
});
|
|
318
|
-
return self.Menu.add(label || 'Apps', app_items, 'capp-header', {
|
|
319
|
-
labelcss: 'multi-line capp-app-title',
|
|
320
|
-
cssclass: 'dd capp-apps-menu'
|
|
321
|
-
});
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
this.Menu.addFromSites = function (apps) {
|
|
325
|
-
var app_items = [];
|
|
326
|
-
apps.map(function (a) {
|
|
327
|
-
app_items.push({
|
|
328
|
-
name: a,
|
|
329
|
-
action: 'window.location=\'//localhost:2098/' + a.url + '\''
|
|
330
|
-
});
|
|
331
|
-
});
|
|
332
|
-
return self.Menu.add('Sites', app_items, 'capp-header');
|
|
333
|
-
};
|
|
334
|
-
/*----------------------END MENU ----------------------*/
|
|
335
|
-
|
|
336
|
-
/*---------------------> CAPP-DASHBOARD <---------------------*/
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
var Dashboard = this.Dashboard = {
|
|
340
|
-
tag: 'capp-dashboard',
|
|
341
|
-
target: 'capp-body'
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
this.Dashboard.init = function () {
|
|
345
|
-
var config = {
|
|
346
|
-
containment: 'capp-dashboard',
|
|
347
|
-
grid: [self.Card.size + self.Card.offset, self.Card.size + self.Card.offset],
|
|
348
|
-
refreshPositions: true,
|
|
349
|
-
cursor: 'move',
|
|
350
|
-
handle: '.handle'
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
if (!$c.isMobile()) {
|
|
354
|
-
$('capp-dashboard').find('capp-card').draggable(config);
|
|
355
|
-
}
|
|
356
|
-
};
|
|
357
|
-
|
|
358
|
-
this.Dashboard.toggle = function () {
|
|
359
|
-
if ($('capp-dashboard').draggable('option', 'disabled')) {
|
|
360
|
-
$('capp-dashboard').draggable('enable');
|
|
361
|
-
} else {
|
|
362
|
-
$('capp-dashboard').draggable('disable');
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
this.Dashboard.respond = function () {
|
|
367
|
-
//for each dashboard,get width
|
|
368
|
-
var wcutoff = 500;
|
|
369
|
-
var width, height;
|
|
370
|
-
$('capp-dashboard').each(function () {
|
|
371
|
-
width = $(window).width(); //$(this).width();
|
|
372
|
-
|
|
373
|
-
if (width < wcutoff && !$(this).hasClass('mobile')) {
|
|
374
|
-
$(this).addClass('mobile').find('capp-card.ui-draggable').draggable('disable');
|
|
375
|
-
} else if (width >= wcutoff && $(this).hasClass('mobile')) {
|
|
376
|
-
$(this).removeClass('mobile').find('capp-card.ui-draggable').draggable('enable');
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
utils.addRenderFunction(Dashboard);
|
|
382
|
-
/*---------------------> CAPP-DASHBOARD <---------------------*/
|
|
383
|
-
|
|
384
|
-
/*---------------------> CAPP-CARD <---------------------*/
|
|
385
|
-
|
|
386
|
-
this.Card = {
|
|
387
|
-
size: 160,
|
|
388
|
-
tag: 'capp-card',
|
|
389
|
-
offset: 10
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
this.Card.add = function (title, content, css, specs) {
|
|
393
|
-
var bk = {
|
|
394
|
-
title: title,
|
|
395
|
-
content: content,
|
|
396
|
-
css: css,
|
|
397
|
-
specs: specs
|
|
398
|
-
};
|
|
399
|
-
var card = {};
|
|
400
|
-
var obj = {};
|
|
401
|
-
var specs = specs || {};
|
|
402
|
-
|
|
403
|
-
if ($.type(title) == 'object') {
|
|
404
|
-
obj = $.extend({}, title);
|
|
405
|
-
card.attributes = title.attributes;
|
|
406
|
-
card.title = title = utils.propAsFuncOrValue(title.title);
|
|
407
|
-
card.specs = specs = specs || utils.propAsFuncOrValue(obj.specs);
|
|
408
|
-
card.cappid = specs.capp || cuid();
|
|
409
|
-
card.onload = obj.onload;
|
|
410
|
-
content = content || utils.propAsFuncOrValue(obj.content, card);
|
|
411
|
-
css = css || utils.propAsFuncOrValue(obj.cssclass || obj.css);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
var defs = {
|
|
415
|
-
title: title || false,
|
|
416
|
-
content: content || 'Card Content',
|
|
417
|
-
css: css || ''
|
|
418
|
-
};
|
|
419
|
-
var cappid = card.cappid || specs.capp || cuid();
|
|
420
|
-
var container = specs.container || 'capp-dashboard';
|
|
421
|
-
var pos = '';
|
|
422
|
-
var left = obj.left || specs.left;
|
|
423
|
-
var top = obj.top || specs.top;
|
|
424
|
-
|
|
425
|
-
if (left) {
|
|
426
|
-
pos += ' data-left=' + left;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
if (top) {
|
|
430
|
-
pos += ' data-top=' + top;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
self.instances[cappid] = $.extend(defs, {
|
|
434
|
-
type: 'card',
|
|
435
|
-
capp: cappid,
|
|
436
|
-
bk: bk,
|
|
437
|
-
onload: card.onload
|
|
438
|
-
});
|
|
439
|
-
var atts = ' ';
|
|
440
|
-
|
|
441
|
-
if (card.attributes) {
|
|
442
|
-
Object.keys(card.attributes).map(function (att) {
|
|
443
|
-
atts += " card-".concat(att, "='").concat(card.attributes[att], "'");
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
var temp = '<capp-card data-capp="' + cappid + '" class="${css} ' + (!self.instances[cappid].title && 'no-title' || '') + '" ' + pos + ' ' + atts + '>' + '<capp-title class="handle">${title}</capp-title>' + '<capp-content>${content}</capp-content>' + '</capp-card>';
|
|
448
|
-
var code = fillTemplate(temp, defs);
|
|
449
|
-
|
|
450
|
-
if (!specs.returnOnly) {
|
|
451
|
-
$(container) && $(container).append(code);
|
|
452
|
-
self.Card.init();
|
|
453
|
-
|
|
454
|
-
if (container == "capp-dashboard") {
|
|
455
|
-
self.Dashboard.init();
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
return code;
|
|
460
|
-
};
|
|
461
|
-
|
|
462
|
-
this.Card.init = function () {
|
|
463
|
-
var offset = self.Card.size + self.Card.offset; //find l1 and t1 classnames
|
|
464
|
-
|
|
465
|
-
$('capp-card').each(function () {
|
|
466
|
-
if (!$(this).hasClass('init')) {
|
|
467
|
-
var data = $(this).data();
|
|
468
|
-
var id = data['capp'] || cuid();
|
|
469
|
-
var css = {};
|
|
470
|
-
|
|
471
|
-
if (data.left) {
|
|
472
|
-
css.left = offset * data.left;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
if (data.top) {
|
|
476
|
-
css.top = offset * data.top;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
$(this).css(css).addClass('init');
|
|
480
|
-
$(this).attr('data-capp', id);
|
|
481
|
-
self.instances[id] = $.extend(self.instances[id] || {}, {
|
|
482
|
-
dom: $(this)
|
|
483
|
-
});
|
|
484
|
-
|
|
485
|
-
if (self.instances[id].onload) {
|
|
486
|
-
self.instances[id].onload(self.instances[id]);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
});
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
this.Card.reload = function (id) {
|
|
493
|
-
//reload a particular card
|
|
494
|
-
var instance = capp.instances[id];
|
|
495
|
-
var specs = $.extend(instance.bk.specs || {}, {
|
|
496
|
-
capp: id,
|
|
497
|
-
returnOnly: true
|
|
498
|
-
});
|
|
499
|
-
var oldDom = instance.dom;
|
|
500
|
-
var html = self.Card.add(instance.bk.title, instance.bk.content, instance.bk.css, specs);
|
|
501
|
-
$('capp-card[data-capp=' + id + ']').replaceWith(html);
|
|
502
|
-
};
|
|
503
|
-
/*---------------------> CAPP-CARD <---------------------*/
|
|
504
|
-
|
|
505
|
-
/*---------------------> CAPP-CHART <---------------------*/
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
this.Chart = {
|
|
509
|
-
tag: 'capp-chart'
|
|
510
|
-
};
|
|
511
|
-
|
|
512
|
-
this.Chart.timeline = function (valueProp, dateProp, schemaname, cappid, specs) {
|
|
513
|
-
var specs = specs || {};
|
|
514
|
-
var dataset = _joe.Data[schemaname];
|
|
515
|
-
var schemaobj = _joe.schemas[schemaname];
|
|
516
|
-
|
|
517
|
-
if (dataset) {
|
|
518
|
-
if (specs.filter) {
|
|
519
|
-
dataset = dataset.where(specs.filter);
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
var dates = ['dates'];
|
|
523
|
-
var values = [specs.label || 'values'];
|
|
524
|
-
dataset.map(function (d) {
|
|
525
|
-
dates.push(_joe.propAsFuncOrValue(dateProp, d));
|
|
526
|
-
values.push(_joe.propAsFuncOrValue(valueProp, d));
|
|
527
|
-
});
|
|
528
|
-
var legendposition = _joe && _joe.sizeClass == "small-size" ? 'bottom' : 'right';
|
|
529
|
-
var chart = c3.generate({
|
|
530
|
-
bindto: 'capp-chart#chart_' + cappid + '',
|
|
531
|
-
legend: {
|
|
532
|
-
position: legendposition
|
|
533
|
-
},
|
|
534
|
-
data: {
|
|
535
|
-
x: 'dates',
|
|
536
|
-
columns: [dates, values]
|
|
537
|
-
}
|
|
538
|
-
/*onclick: function (d, i) {
|
|
539
|
-
var query = {schema:schemaname}
|
|
540
|
-
goJoe(_joe.getDataset(schemaname)||[],query);
|
|
541
|
-
}*/
|
|
542
|
-
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
};
|
|
546
|
-
|
|
547
|
-
this.Chart.byProperty = function (propertyname, schemaname, cappid, specs) {
|
|
548
|
-
var specs = specs || {};
|
|
549
|
-
var dataset = _joe.Data[schemaname];
|
|
550
|
-
var schemaobj = _joe.schemas[schemaname];
|
|
551
|
-
var propertymap = {};
|
|
552
|
-
var propcolors = specs.colors || {};
|
|
553
|
-
var subsets = specs.subsets;
|
|
554
|
-
|
|
555
|
-
if (dataset) {
|
|
556
|
-
propertymap = _joe.Utils.getPossibleValues('build_type', 'cg_model');
|
|
557
|
-
|
|
558
|
-
if (specs.filter) {
|
|
559
|
-
dataset = dataset.where(specs.filter);
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
var cols = [];
|
|
563
|
-
var names = {};
|
|
564
|
-
var colors = [];
|
|
565
|
-
var cnt;
|
|
566
|
-
|
|
567
|
-
for (var property in propertymap) {
|
|
568
|
-
cnt = propertymap[property];
|
|
569
|
-
cols.push([property, cnt]);
|
|
570
|
-
names[property] = property + ' ' + cnt;
|
|
571
|
-
colors.push(propcolors[property] || _joe.Utils.getRandomColor());
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
var legendposition = _joe && _joe.sizeClass == "small-size" ? 'bottom' : 'right';
|
|
575
|
-
var chart = c3.generate({
|
|
576
|
-
bindto: 'capp-chart#chart_' + cappid + '',
|
|
577
|
-
data: {
|
|
578
|
-
columns: cols,
|
|
579
|
-
type: 'donut',
|
|
580
|
-
names: names,
|
|
581
|
-
onclick: function onclick(d, i) {
|
|
582
|
-
console.log(arguments);
|
|
583
|
-
var query = {
|
|
584
|
-
schema: schemaname
|
|
585
|
-
};
|
|
586
|
-
|
|
587
|
-
if (subsets) {
|
|
588
|
-
query.subset = d.name;
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
goJoe(_joe.getDataset(schemaname) || [], query);
|
|
592
|
-
|
|
593
|
-
if (specs.filters) {
|
|
594
|
-
var dom = $('joe-filter-option[data-filter="' + d.id + '"]')[0];
|
|
595
|
-
|
|
596
|
-
_joe.toggleFilter(d.id, dom);
|
|
597
|
-
|
|
598
|
-
getJoe(0).toggleFiltersMenu();
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
},
|
|
602
|
-
donut: {
|
|
603
|
-
title: specs.chartTitle || propertyname
|
|
604
|
-
},
|
|
605
|
-
legend: {
|
|
606
|
-
position: legendposition
|
|
607
|
-
},
|
|
608
|
-
color: {
|
|
609
|
-
pattern: colors
|
|
610
|
-
}
|
|
611
|
-
});
|
|
612
|
-
}
|
|
613
|
-
};
|
|
614
|
-
|
|
615
|
-
this.Chart.byStatus = function (schemaname, cappid, specs) {
|
|
616
|
-
var specs = specs || {};
|
|
617
|
-
var dataset = _joe.Data[schemaname];
|
|
618
|
-
var schemaobj = _joe.schemas[schemaname];
|
|
619
|
-
|
|
620
|
-
if (dataset && _joe.Data.status) {
|
|
621
|
-
var statusmap = {
|
|
622
|
-
none: {
|
|
623
|
-
count: 0,
|
|
624
|
-
name: 'none',
|
|
625
|
-
color: 'grey'
|
|
626
|
-
}
|
|
627
|
-
};
|
|
628
|
-
|
|
629
|
-
var statuses = _joe.Data.status.sortBy('index').where({
|
|
630
|
-
datasets: {
|
|
631
|
-
$in: [schemaname]
|
|
632
|
-
}
|
|
633
|
-
});
|
|
634
|
-
|
|
635
|
-
statuses.map(function (status, i) {
|
|
636
|
-
statusmap[status._id] = {
|
|
637
|
-
count: 0,
|
|
638
|
-
name: status.name,
|
|
639
|
-
color: status.color
|
|
640
|
-
};
|
|
641
|
-
});
|
|
642
|
-
|
|
643
|
-
if (specs.filter) {
|
|
644
|
-
dataset = dataset.where(specs.filter);
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
dataset.map(function (obj) {
|
|
648
|
-
if (statusmap[obj.status]) {
|
|
649
|
-
statusmap[obj.status].count++;
|
|
650
|
-
} else {
|
|
651
|
-
statusmap['none'].count++;
|
|
652
|
-
}
|
|
653
|
-
});
|
|
654
|
-
var cols = [];
|
|
655
|
-
var colors = [];
|
|
656
|
-
statusmap.map(function (status) {
|
|
657
|
-
cols.push([status.name + ' ' + status.count, status.count]);
|
|
658
|
-
colors.push(status.color || '#ccc');
|
|
659
|
-
});
|
|
660
|
-
var legendposition = _joe && _joe.sizeClass == "small-size" ? 'bottom' : 'right';
|
|
661
|
-
|
|
662
|
-
if (specs.delay) {
|
|
663
|
-
setTimeout(function () {
|
|
664
|
-
return c3.generate({
|
|
665
|
-
bindto: specs.target || 'capp-chart#chart_' + cappid + '',
|
|
666
|
-
data: {
|
|
667
|
-
columns: cols,
|
|
668
|
-
type: 'donut',
|
|
669
|
-
onclick: specs.onclick || function (d, i) {
|
|
670
|
-
goJoe(_joe.getDataset(schemaname) || [], {
|
|
671
|
-
schema: schemaname,
|
|
672
|
-
subset: d.name
|
|
673
|
-
});
|
|
674
|
-
}
|
|
675
|
-
},
|
|
676
|
-
donut: {
|
|
677
|
-
title: dataset.length + " " + schemaobj.name.pluralize() + " in " + (statuses.length + 1) + " statuses"
|
|
678
|
-
},
|
|
679
|
-
legend: {
|
|
680
|
-
position: legendposition
|
|
681
|
-
},
|
|
682
|
-
color: {
|
|
683
|
-
pattern: colors
|
|
684
|
-
}
|
|
685
|
-
});
|
|
686
|
-
}, 100);
|
|
687
|
-
return true;
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
var chart = c3.generate({
|
|
691
|
-
bindto: specs.target || 'capp-chart#chart_' + cappid + '',
|
|
692
|
-
data: {
|
|
693
|
-
columns: cols,
|
|
694
|
-
type: 'donut',
|
|
695
|
-
onclick: specs.onclick || function (d, i) {
|
|
696
|
-
goJoe(_joe.getDataset(schemaname) || [], {
|
|
697
|
-
schema: schemaname,
|
|
698
|
-
subset: d.name
|
|
699
|
-
});
|
|
700
|
-
}
|
|
701
|
-
},
|
|
702
|
-
donut: {
|
|
703
|
-
title: dataset.length + " " + schemaobj.name.pluralize() + " in " + (statuses.length + 1) + " statuses"
|
|
704
|
-
},
|
|
705
|
-
legend: {
|
|
706
|
-
position: legendposition
|
|
707
|
-
},
|
|
708
|
-
color: {
|
|
709
|
-
pattern: colors
|
|
710
|
-
}
|
|
711
|
-
});
|
|
712
|
-
}
|
|
713
|
-
};
|
|
714
|
-
/*---------------------> CAPP-CHART <---------------------*/
|
|
715
|
-
|
|
716
|
-
/*---------------------> CAPP-PAGE <---------------------*/
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
this.Page = {
|
|
720
|
-
tag: 'capp-page'
|
|
721
|
-
};
|
|
722
|
-
|
|
723
|
-
this.Page.init = function () {
|
|
724
|
-
var offset = self.Card.size + self.Card.offset;
|
|
725
|
-
$('capp-page').each(function () {
|
|
726
|
-
if (!$(this).hasClass('init')) {
|
|
727
|
-
var data = $(this).data();
|
|
728
|
-
var css = {};
|
|
729
|
-
|
|
730
|
-
if (data.left) {
|
|
731
|
-
css.left = offset * data.left;
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
if (data.top) {
|
|
735
|
-
css.top = offset * data.top;
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
if (data.right) {
|
|
739
|
-
css.right = offset * data.right;
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
if (data.bottom) {
|
|
743
|
-
css.bottom = offset * data.bottom;
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
$(this).css(css).addClass('init');
|
|
747
|
-
}
|
|
748
|
-
});
|
|
749
|
-
};
|
|
750
|
-
/*---------------------> CAPP-PAGE <---------------------*/
|
|
751
|
-
|
|
752
|
-
/*---------------------> CAPP-TOGGLE <---------------------*/
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
this.Toggle = {
|
|
756
|
-
toggle: function toggle(id) {
|
|
757
|
-
$('*[data-toggle=' + id + ']').addClass('active').siblings().removeClass('active');
|
|
758
|
-
}
|
|
759
|
-
};
|
|
760
|
-
/*---------------------> CAPP-TOGGLE <---------------------*/
|
|
761
|
-
|
|
762
|
-
/*---------------------> CAPP-POPUP <---------------------*/
|
|
763
|
-
|
|
764
|
-
this.Popup = {
|
|
765
|
-
tag: 'capp-popup',
|
|
766
|
-
add: function add(title, content, specs) {
|
|
767
|
-
//pass cssclass id and capp
|
|
768
|
-
var bk = {
|
|
769
|
-
title: title,
|
|
770
|
-
content: content,
|
|
771
|
-
specs: specs
|
|
772
|
-
};
|
|
773
|
-
var specs = specs || {};
|
|
774
|
-
var cappid = specs.capp || cuid();
|
|
775
|
-
var closeBTN = specs.hasOwnProperty('close') && specs.close || true;
|
|
776
|
-
var active = specs.active || false;
|
|
777
|
-
var popobj = {
|
|
778
|
-
title: self.utils.propAsFuncOrValue(title),
|
|
779
|
-
content: self.utils.propAsFuncOrValue(content),
|
|
780
|
-
capp: cappid,
|
|
781
|
-
cssclass: self.utils.propAsFuncOrValue(specs.cssclass),
|
|
782
|
-
id: specs.cssid || specs.id || ''
|
|
783
|
-
};
|
|
784
|
-
var close_action = specs.close_action || '$(this).parent().toggleClass(\'active\');';
|
|
785
|
-
var template = '<capp-popup id="${id}" class="${cssclass} ' + (active && 'active' || '') + '" data-capp="${capp}">' + (closeBTN && '<capp-popup-close onclick="' + close_action + '"> X </capp-popup-close>' || '') + '<capp-title>${title}</capp-title>\
|
|
786
|
-
<capp-content>${content}</capp-content>\
|
|
787
|
-
</capp-popup>';
|
|
788
|
-
var popup_str = fillTemplate(template, popobj);
|
|
789
|
-
var container = specs.container || 'capp-wrapper';
|
|
790
|
-
$(container) && $(container).append(popup_str);
|
|
791
|
-
self.instances[cappid] = {
|
|
792
|
-
type: 'popup',
|
|
793
|
-
capp: cappid,
|
|
794
|
-
bk: bk
|
|
795
|
-
};
|
|
796
|
-
self.Popup.init();
|
|
797
|
-
return self.instances[cappid];
|
|
798
|
-
},
|
|
799
|
-
toggle: function toggle(cappid, title_active, content, callback) {
|
|
800
|
-
var popup;
|
|
801
|
-
var setActive;
|
|
802
|
-
var title_active = self.utils.propAsFuncOrValue(title_active);
|
|
803
|
-
var content = self.utils.propAsFuncOrValue(content);
|
|
804
|
-
|
|
805
|
-
if (!cappid) {
|
|
806
|
-
return;
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
if ($c.isCuid(cappid)) {
|
|
810
|
-
popup = $('capp-popup[data-capp=' + cappid + ']');
|
|
811
|
-
} else {
|
|
812
|
-
popup = $('capp-popup#' + cappid);
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
if (title_active) {
|
|
816
|
-
setActive = true;
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
if (title_active && title_active !== true) {
|
|
820
|
-
popup.find('capp-title').html(title_active);
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
if (content && content !== true) {
|
|
824
|
-
popup.find('capp-content').html(content);
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
popup.toggleClass('active', setActive);
|
|
828
|
-
return popup;
|
|
829
|
-
},
|
|
830
|
-
respond: function respond() {},
|
|
831
|
-
"delete": function _delete(cappid) {
|
|
832
|
-
if (!cappid) {
|
|
833
|
-
return;
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
if ($c.isCuid(cappid)) {
|
|
837
|
-
popup = $('capp-popup[data-capp=' + cappid + ']');
|
|
838
|
-
} else {
|
|
839
|
-
popup = $('capp-popup#' + cappid);
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
var capp = popup.data('capp');
|
|
843
|
-
delete self.instances[capp];
|
|
844
|
-
popup.remove();
|
|
845
|
-
}
|
|
846
|
-
};
|
|
847
|
-
|
|
848
|
-
this.Popup.init = function () {
|
|
849
|
-
self.utils.initElements('capp-popup');
|
|
850
|
-
};
|
|
851
|
-
/*---------------------> CAPP-POPUP <---------------------*/
|
|
852
|
-
|
|
853
|
-
/*---------------------> RESPONSIVE <---------------------*/
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
this.Responsive = {
|
|
857
|
-
init: function init() {
|
|
858
|
-
$(window).on('resize', self.Responsive.go);
|
|
859
|
-
self.Responsive.go();
|
|
860
|
-
},
|
|
861
|
-
go: function go() {
|
|
862
|
-
clearTimeout(self.Responsive.timer);
|
|
863
|
-
self.Responsive.timer = setTimeout(function () {
|
|
864
|
-
if (_joe && _joe.resizeOk()) {
|
|
865
|
-
var respBM = new Benchmarker();
|
|
866
|
-
self.Reload.all();
|
|
867
|
-
|
|
868
|
-
for (var object in self) {
|
|
869
|
-
if (self[object].respond && object != 'Responsive') {
|
|
870
|
-
self[object].respond();
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
logit('responded in ' + respBM.stop() + 's');
|
|
875
|
-
}
|
|
876
|
-
}, 500);
|
|
877
|
-
}
|
|
878
|
-
};
|
|
879
|
-
/*---------------------> RESPONSIVE <---------------------*/
|
|
880
|
-
|
|
881
|
-
/*---------------------> RELOAD <---------------------*/
|
|
882
|
-
|
|
883
|
-
this.Reload = {
|
|
884
|
-
instance: function instance(id) {
|
|
885
|
-
if (id) {
|
|
886
|
-
var instance = capp.instances[id];
|
|
887
|
-
var itype;
|
|
888
|
-
|
|
889
|
-
try {
|
|
890
|
-
itype = instance.type.capitalize();
|
|
891
|
-
|
|
892
|
-
if (capp[itype].reload) {
|
|
893
|
-
capp[itype].reload(id);
|
|
894
|
-
}
|
|
895
|
-
} catch (e) {
|
|
896
|
-
logit('could not reload: ' + itype + ' ' + id, e, instance);
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
},
|
|
900
|
-
all: function all() {
|
|
901
|
-
for (var i in capp.instances) {
|
|
902
|
-
self.Reload.instance(i);
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
self.Card.init();
|
|
906
|
-
self.Page.init();
|
|
907
|
-
self.Dashboard.init();
|
|
908
|
-
}
|
|
909
|
-
};
|
|
910
|
-
/*---------------------> RELOAD <---------------------*/
|
|
911
|
-
|
|
912
|
-
/*---------------------> HASH <---------------------*/
|
|
913
|
-
|
|
914
|
-
this.Hash = {
|
|
915
|
-
init: function init() {
|
|
916
|
-
window.addEventListener("hashchange", function (hashinfo) {
|
|
917
|
-
var hashchangehandler = specs.hashchangehandler || foo;
|
|
918
|
-
|
|
919
|
-
if (hashchangehandler) {
|
|
920
|
-
try {
|
|
921
|
-
hashchangehandler(hashinfo);
|
|
922
|
-
} catch (e) {
|
|
923
|
-
alert(e);
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
});
|
|
927
|
-
}
|
|
928
|
-
};
|
|
929
|
-
/*---------------------> HASH <---------------------*/
|
|
930
|
-
|
|
931
|
-
/*----------------------BEGIN INIT ----------------------*/
|
|
932
|
-
|
|
933
|
-
this.init = function (s) {
|
|
934
|
-
specs = $c.merge(specs, s || {});
|
|
935
|
-
self.renderComponents(renderQueue); //componetize('capp-header');
|
|
936
|
-
|
|
937
|
-
self.initSVGs();
|
|
938
|
-
self.initInteractions();
|
|
939
|
-
self.Responsive.init();
|
|
940
|
-
self.Hash.init();
|
|
941
|
-
};
|
|
942
|
-
|
|
943
|
-
this.renderComponents = function (components) {
|
|
944
|
-
if (!components) {
|
|
945
|
-
return false;
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
if (!components.isArray()) {
|
|
949
|
-
components = [components];
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
var comtype;
|
|
953
|
-
components.map(function (component) {
|
|
954
|
-
component = utils.propAsFuncOrValue(component); //(content,target,specs)
|
|
955
|
-
|
|
956
|
-
comtype = component.type.capitalize();
|
|
957
|
-
|
|
958
|
-
if (component && comtype) {
|
|
959
|
-
if (self[comtype]) {
|
|
960
|
-
if (self[comtype].render) {
|
|
961
|
-
self[comtype].render(utils.propAsFuncOrValue(component.content), component.target, component.specs);
|
|
962
|
-
} else if (self[comtype].add) {
|
|
963
|
-
component.config ? self[comtype].add(utils.propAsFuncOrValue(component.config)) : self[comtype].add(utils.propAsFuncOrValue(component.title), utils.propAsFuncOrValue(component.content), utils.propAsFuncOrValue(component.specs));
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
});
|
|
968
|
-
};
|
|
969
|
-
|
|
970
|
-
this.initSVGs = function () {
|
|
971
|
-
/*
|
|
972
|
-
* Replace all SVG images with inline SVG
|
|
973
|
-
*/
|
|
974
|
-
jQuery('img.svg').each(function () {
|
|
975
|
-
var $img = jQuery(this);
|
|
976
|
-
var imgID = $img.attr('id');
|
|
977
|
-
var imgClass = $img.attr('class');
|
|
978
|
-
var imgURL = $img.attr('src');
|
|
979
|
-
jQuery.get(imgURL, function (data) {
|
|
980
|
-
// Get the SVG tag, ignore the rest
|
|
981
|
-
var $svg = jQuery(data).find('svg'); // Add replaced image's ID to the new SVG
|
|
982
|
-
|
|
983
|
-
if (typeof imgID !== 'undefined') {
|
|
984
|
-
$svg = $svg.attr('id', imgID);
|
|
985
|
-
} // Add replaced image's classes to the new SVG
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
if (typeof imgClass !== 'undefined') {
|
|
989
|
-
$svg = $svg.attr('class', imgClass + ' replaced-svg');
|
|
990
|
-
} // Remove any invalid XML tags as per http://validator.w3.org
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
$svg = $svg.removeAttr('xmlns:a'); // Replace image with new SVG
|
|
994
|
-
|
|
995
|
-
$img.replaceWith($svg);
|
|
996
|
-
}, 'xml');
|
|
997
|
-
});
|
|
998
|
-
};
|
|
999
|
-
|
|
1000
|
-
this.special = {
|
|
1001
|
-
joeicon: function joeicon(open) {
|
|
1002
|
-
$('capp-menu.expanded').not('.default-schemas-menu').removeClass('expanded');
|
|
1003
|
-
$('#joePanelMenu').toggleClass('expanded', open);
|
|
1004
|
-
$('capp-dashboard').toggleClass('left-panel-open', $('#joePanelMenu').hasClass('expanded'));
|
|
1005
|
-
}
|
|
1006
|
-
};
|
|
1007
|
-
|
|
1008
|
-
this.initInteractions = function () {
|
|
1009
|
-
self.Card.init();
|
|
1010
|
-
self.Page.init();
|
|
1011
|
-
self.Dashboard.init();
|
|
1012
|
-
$('capp-header capp-menu-label').not('.init').click(self.Menu.init).addClass('init');
|
|
1013
|
-
/*$('capp-panel capp-menu-label').not('.init').on('dblclick',function(){
|
|
1014
|
-
$(this).parents('capp-panel').toggleClass('expanded');
|
|
1015
|
-
}).addClass('init');
|
|
1016
|
-
*/
|
|
1017
|
-
|
|
1018
|
-
$('capp-panel-toggle,.capp-panel-toggle').not('.init').click(function () {
|
|
1019
|
-
$(this).parents('capp-panel').toggleClass('expanded');
|
|
1020
|
-
}).addClass('init');
|
|
1021
|
-
$('capp-menu-toggle').click(function () {
|
|
1022
|
-
$('capp-wrapper').toggleClass('expanded');
|
|
1023
|
-
});
|
|
1024
|
-
$('capp-panel.hover-toggle').hover(function () {
|
|
1025
|
-
$(this).addClass('capp-targeted');
|
|
1026
|
-
window.__cpt = setTimeout(function () {
|
|
1027
|
-
$('.capp-targeted').addClass('expanded');
|
|
1028
|
-
}, 1000);
|
|
1029
|
-
}, function () {
|
|
1030
|
-
clearTimeout(window.__cpt);
|
|
1031
|
-
$('.capp-targeted').removeClass('expanded').removeClass('capp-targeted');
|
|
1032
|
-
}); //close panels on click
|
|
1033
|
-
|
|
1034
|
-
$('capp-view,capp-dashboard').on('click', function () {
|
|
1035
|
-
$('capp-panel.expanded,capp-menu.expanded').not('#joePanelMenu,.default-schemas-menu').removeClass('expanded');
|
|
1036
|
-
});
|
|
1037
|
-
};
|
|
1038
|
-
|
|
1039
|
-
if (specs.autoInit) {
|
|
1040
|
-
self.init();
|
|
1041
|
-
}
|
|
1042
|
-
/*----------------------END INIT ----------------------*/
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
this.svgs = {
|
|
1046
|
-
newwindow: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="-32 -32 96 96" ><path d="M32 0H8v8C5.1 8 0 8 0 8v24h24v-8h8V0zM20 28H4V16h4v8h12C20 25.8 20 28 20 28zM28 20H12V8h16V20z"></path></svg>',
|
|
1047
|
-
quickadd: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="-12 -12 64 64"><g data-name="Layer 2"><polygon class="cls-1" points="28 22.3 22.5 22.3 22.5 28 17.6 28 17.6 22.3 12 22.3 12 17.5 17.6 17.5 17.6 12 22.5 12 22.5 17.5 28 17.5 28 22.3"/></g></svg>',
|
|
1048
|
-
newwindow2: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 26 26"><path d="M4 4C2.9 4 2 4.9 2 6L2 17 4 15 4 8 23 8 23 20 9 20 7 22 23 22C24.1 22 25 21.1 25 20L25 6C25 4.9 24.1 4 23 4L4 4zM6 13L7.8 14.8 1 21.6 2.4 23 9.2 16.2 11 18 11 13 6 13z"/></svg>'
|
|
1049
|
-
};
|
|
1050
|
-
return this;
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
function componetize(name, createdCallback, specs) {
|
|
1054
|
-
var specs = specs || {};
|
|
1055
|
-
var componentPrototype = Object.create(HTMLElement.prototype);
|
|
1056
|
-
|
|
1057
|
-
componentPrototype.createdCallback = createdCallback || function () {//this.textContent = 'component: '+name;
|
|
1058
|
-
};
|
|
1059
|
-
|
|
1060
|
-
$c.merge(componentPrototype, specs); //componentPrototype.merge(specs);
|
|
1061
|
-
|
|
1062
|
-
document.registerElement(name, {
|
|
1063
|
-
prototype: componentPrototype
|
|
1064
|
-
});
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
function __cancelPropagation(e) {
|
|
1068
|
-
var eve = e || window.event;
|
|
1069
|
-
if (eve.stopPropagation) eve.stopPropagation(); //if (eve.preventDefault) eve.preventDefault();
|
|
1070
|
-
|
|
1071
|
-
__closeAllExpanded();
|
|
1072
|
-
|
|
1073
|
-
return true;
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
function __cancelClick() {
|
|
1077
|
-
__closeAllExpanded();
|
|
1078
|
-
|
|
1079
|
-
return false;
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
function __closeAllExpanded() {
|
|
1083
|
-
$('capp-menu.expanded,capp-panel.expanded').removeClass('expanded');
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function CraydentApp(specs, render) {
|
|
4
|
+
if (typeof specs == "boolean") {
|
|
5
|
+
specs = {
|
|
6
|
+
autoInit: specs
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
var renderQueue = render ? $.type(render) == "array" ? render : [render] : [];
|
|
11
|
+
var self = this;
|
|
12
|
+
self.instances = {};
|
|
13
|
+
var dspecs = {
|
|
14
|
+
theme: 'light',
|
|
15
|
+
container: $('body')
|
|
16
|
+
};
|
|
17
|
+
var specs = $c.merge(dspecs, specs);
|
|
18
|
+
|
|
19
|
+
this.constructComponent = function (componentName) {
|
|
20
|
+
self[componentName] = {};
|
|
21
|
+
};
|
|
22
|
+
/*----------------------UTIL FUNCTIONS ----------------------*/
|
|
23
|
+
|
|
24
|
+
var utils;
|
|
25
|
+
this.utils = utils = {
|
|
26
|
+
addRenderFunction: function addRenderFunction(component) {
|
|
27
|
+
component.render = function (content, target, specs) {
|
|
28
|
+
var cssclass = specs.cssclass || '';
|
|
29
|
+
var CONTENT = (component.before_content || '') + content + (component.after_content || '');
|
|
30
|
+
var h = '<' + component.tag + ' class="' + cssclass + '">' + CONTENT + '</' + component.tag + '>';
|
|
31
|
+
|
|
32
|
+
if (target || component.target) {
|
|
33
|
+
$(target || component.target).append(h);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return h;
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
addRenderers: function addRenderers() {},
|
|
40
|
+
propAsFuncOrValue: function propAsFuncOrValue(prop, toPass) {
|
|
41
|
+
/*|{
|
|
42
|
+
featured:true,
|
|
43
|
+
tags:'helper',
|
|
44
|
+
description:'Parses the property passed as a function or value, can be passed an object to be a parameter of the function call.'
|
|
45
|
+
}|*/
|
|
46
|
+
try {
|
|
47
|
+
var toPass = toPass || null;
|
|
48
|
+
|
|
49
|
+
if (prop && typeof prop == 'function') {
|
|
50
|
+
return prop(toPass);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return prop;
|
|
54
|
+
} catch (e) {
|
|
55
|
+
logit('capp error parsing func val:[prop=' + prop + ']' + (e.stack || e));
|
|
56
|
+
return '';
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
initElements: function initElements(elementType, css, callback) {
|
|
60
|
+
var callback = callback || null;
|
|
61
|
+
$(elementType).each(function () {
|
|
62
|
+
if (!$(this).hasClass('init')) {
|
|
63
|
+
var data = $(this).data();
|
|
64
|
+
var id = data['capp'] || cuid();
|
|
65
|
+
var domid = $(this).attr('id');
|
|
66
|
+
var css = {};
|
|
67
|
+
$(this).css(css).addClass('init');
|
|
68
|
+
$(this).attr('data-capp', id);
|
|
69
|
+
var type = (self.instances[id] || {}).type || elementType.replace('capp-', '').toLowerCase();
|
|
70
|
+
self.instances[id] = $.extend(self.instances[id] || {}, {
|
|
71
|
+
dom: $(this),
|
|
72
|
+
data: data,
|
|
73
|
+
domid: domid,
|
|
74
|
+
type: type
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
if (callback) {
|
|
78
|
+
callback($(this), data);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
/*----------------------UTIL FUNCTIONS ----------------------*/
|
|
85
|
+
|
|
86
|
+
/*----------------------BEGIN WRAPPER ----------------------*/
|
|
87
|
+
|
|
88
|
+
this.Wrapper = {
|
|
89
|
+
tag: 'capp-wrapper',
|
|
90
|
+
target: 'body',
|
|
91
|
+
respond: function respond() {
|
|
92
|
+
var wrapperdom = $(self.Wrapper.tag)[0];
|
|
93
|
+
var sizeClass = '';
|
|
94
|
+
|
|
95
|
+
if (wrapperdom.className.indexOf('-size') == -1) {
|
|
96
|
+
wrapperdom.className += ' large-size ';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if ($(self.Wrapper.tag).width() < 600) {
|
|
100
|
+
sizeClass = 'small-size';
|
|
101
|
+
} else {
|
|
102
|
+
sizeClass = 'large-size';
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
wrapperdom.className = wrapperdom.className.replace(/[a-z]*-size/, sizeClass);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
var Wrapper = this.Wrapper;
|
|
109
|
+
|
|
110
|
+
Wrapper.render = function (content, target) {
|
|
111
|
+
var h = '<' + self.Wrapper.tag + '>' + content + '</' + self.Wrapper.tag + '>';
|
|
112
|
+
|
|
113
|
+
if (target) {
|
|
114
|
+
$(target).append(h);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if ($c.isMobile()) {
|
|
118
|
+
var capwrap = document.getElementsByTagName('capp-wrapper')[0];
|
|
119
|
+
capwrap.style.minHeight = body.style.minHeight = window.innerHeight + 'px';
|
|
120
|
+
capwrap.style.minWidth = body.style.minWidth = window.innerWidth + 'px';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return h;
|
|
124
|
+
};
|
|
125
|
+
/*----------------------END WRAPPER -------------------------*/
|
|
126
|
+
|
|
127
|
+
/*----------------------BEGIN HEADER ----------------------*/
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
this.Header = {
|
|
131
|
+
tag: 'capp-header',
|
|
132
|
+
target: 'capp-wrapper',
|
|
133
|
+
before_content: '<capp-header-bonus ></capp-header-bonus>'
|
|
134
|
+
};
|
|
135
|
+
var Header = this.Header;
|
|
136
|
+
utils.addRenderFunction(Header);
|
|
137
|
+
/* Header.render = function(content,target){
|
|
138
|
+
var h = '<'+self.Header.tag+' class="'+specs.theme+'-bg">'+content+'</'+self.Header.tag+'>';
|
|
139
|
+
|
|
140
|
+
};*/
|
|
141
|
+
|
|
142
|
+
/*----------------------END HEADER -------------------------*/
|
|
143
|
+
|
|
144
|
+
/*----------------------BEGIN BODY -------------------------*/
|
|
145
|
+
|
|
146
|
+
this.Body = {
|
|
147
|
+
tag: 'capp-body',
|
|
148
|
+
target: 'capp-wrapper'
|
|
149
|
+
};
|
|
150
|
+
var Body = this.Body;
|
|
151
|
+
utils.addRenderFunction(Body);
|
|
152
|
+
/*----------------------END BODY ----------------------*/
|
|
153
|
+
|
|
154
|
+
/*----------------------BEGIN VIEWS ----------------------*/
|
|
155
|
+
|
|
156
|
+
this.View = {
|
|
157
|
+
tag: 'capp-view'
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
this.View.toggle = function (ids, showhide) {
|
|
161
|
+
if (showhide != null) {
|
|
162
|
+
showhide = !showhide;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
var ids = ids || null;
|
|
166
|
+
|
|
167
|
+
if (typeof ids == "string") {
|
|
168
|
+
ids = ids.split(',');
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (ids && ids.length) {
|
|
172
|
+
ids.map(function (id) {
|
|
173
|
+
$(self.View.tag + '#' + id).toggleClass('hidden', showhide);
|
|
174
|
+
});
|
|
175
|
+
} else {
|
|
176
|
+
$(self.View.tag).toggleClass('hidden', showhide);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
this.View.show = function (id) {
|
|
181
|
+
self.View.toggle(null, false);
|
|
182
|
+
self.View.toggle(id, true);
|
|
183
|
+
};
|
|
184
|
+
/*----------------------END VIEWS -------------------------*/
|
|
185
|
+
|
|
186
|
+
/*----------------------BEGIN BUTTONS ----------------------*/
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
this.Button = {};
|
|
190
|
+
|
|
191
|
+
this.Button.add = function (name, icon, action, container, specs) {
|
|
192
|
+
var obj = {};
|
|
193
|
+
|
|
194
|
+
if ($.type(name) == 'object') {
|
|
195
|
+
obj = name;
|
|
196
|
+
name = utils.propAsFuncOrValue(name.name);
|
|
197
|
+
action = utils.propAsFuncOrValue(obj.action);
|
|
198
|
+
icon = utils.propAsFuncOrValue(obj.icon);
|
|
199
|
+
container = utils.propAsFuncOrValue(obj.container);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
var schemaname;
|
|
203
|
+
var specs = specs || {};
|
|
204
|
+
|
|
205
|
+
if (specs.schema) {
|
|
206
|
+
schemaname = specs.schema.display || specs.schema.name || specs.schema;
|
|
207
|
+
specs.create = specs.schema.name || specs.schema;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
var id = specs.id ? 'id="' + specs.id + '"' : '';
|
|
211
|
+
var counter = specs.counter == 0 || specs.counter ? '<capp-counter>' + specs.counter + '</capp-counter>' : ''; // var newWindowLink = (specs.newWindowLink)?'<a class="capp-button-sublink capp-subthemed" onclick="__cancelPropagation();"href="'+(specs.newWindowLink||'')+'" target="_blank" title="new window">'+self.svgs.newwindow+'</a>':'';
|
|
212
|
+
|
|
213
|
+
var create = specs.create ? '<div class="capp-button-sublink capp-subthemed" onclick="_joe.createObject(\'' + specs.create + '\'); __cancelPropagation();" title="create">' + self.svgs.quickadd + '</div>' : '';
|
|
214
|
+
var btn_html = '<capp-button ' + id + ' onclick="' + action + '" class="' + (specs.cssclass || '') + '">' + (specs.newWindowLink && '<a onclick="__cancelClick();" href="' + specs.newWindowLink + '" >' || '') + (icon && '<capp-button-icon title="' + name + '">' + icon + '</capp-button-icon> ' + '<capp-button-label>' + name + counter + create +
|
|
215
|
+
/*newWindowLink+*/
|
|
216
|
+
'</capp-button-label> ' || name) + (specs.newWindowLink && '</a>' || '') + '</capp-button>';
|
|
217
|
+
$(container) && $(container).append(btn_html);
|
|
218
|
+
return btn_html;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
this.Button.update = function (id, specs) {
|
|
222
|
+
var specs = specs || {};
|
|
223
|
+
|
|
224
|
+
var label = _joe.propAsFuncOrValue(specs.label);
|
|
225
|
+
|
|
226
|
+
var counter = _joe.propAsFuncOrValue(specs.counter);
|
|
227
|
+
|
|
228
|
+
if (label) {
|
|
229
|
+
$('#' + id + ' capp-button-label').html(label);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (counter) {
|
|
233
|
+
if ($('#' + id + ' capp-counter').length) {
|
|
234
|
+
$('#' + id + ' capp-counter').html(counter);
|
|
235
|
+
} else {
|
|
236
|
+
$('#' + id + ' capp-button-label').append('<capp-counter>' + counter + '</capp-counter>');
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
this.Button.addFromSchema = function (schema, specs) {
|
|
242
|
+
var specs = $.extend({
|
|
243
|
+
container: 'capp-panel'
|
|
244
|
+
}, specs);
|
|
245
|
+
var icon = schema.name;
|
|
246
|
+
|
|
247
|
+
if (schema.menuicon || schema.icon) {
|
|
248
|
+
icon = (schema.menuicon || schema.icon) + '<svg-label>' + (schema.display || schema.name) + '</svg-label>';
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return self.Button.add(schema.display || schema.name, icon, '_joe.current.clear(); goJoe(\'' + schema.name + '\');', specs.container, {
|
|
252
|
+
schema: schema,
|
|
253
|
+
id: schema.name + 'SchemaBtn',
|
|
254
|
+
newWindowLink: '#/' + schema.name,
|
|
255
|
+
cssclass: schema.default_schema && 'default-schema' || ''
|
|
256
|
+
});
|
|
257
|
+
};
|
|
258
|
+
/*----------------------END BUTTONS ----------------------*/
|
|
259
|
+
|
|
260
|
+
/*----------------------BEGIN MENU ----------------------*/
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
this.Menu = {
|
|
264
|
+
tag: 'capp-menu'
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
this.Menu.add = function (label, items, container, specs) {
|
|
268
|
+
var obj = {};
|
|
269
|
+
var specs = specs || {};
|
|
270
|
+
var cssclass;
|
|
271
|
+
|
|
272
|
+
if ($.type(label) == 'object') {
|
|
273
|
+
obj = label;
|
|
274
|
+
items = label.items;
|
|
275
|
+
container = label.container;
|
|
276
|
+
specs = label.specs;
|
|
277
|
+
cssclass = label.cssclass;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
var temp = '<capp-menu-option class="${cssclass}" onclick="${action}">${name}</capp-menu-option>';
|
|
281
|
+
|
|
282
|
+
function renderBonus(side, content) {}
|
|
283
|
+
|
|
284
|
+
var menu_html = '<capp-menu class="' + (specs.cssclass || cssclass) + '">' + '<capp-menu-label class="' + (specs.labelcss || '') + '">' + label + '</capp-menu-label>' + '<capp-menu-panel>';
|
|
285
|
+
items.map(function (i) {
|
|
286
|
+
temp = _joe && _joe.propAsFuncOrValue(specs.template, i) || temp;
|
|
287
|
+
menu_html += fillTemplate(temp, i);
|
|
288
|
+
});
|
|
289
|
+
menu_html += '</capp-menu-panel>' + '</capp-menu>';
|
|
290
|
+
$(container) && $(container).append(menu_html);
|
|
291
|
+
$('capp-menu-label').not('.init').click(self.Menu.init).addClass('init');
|
|
292
|
+
return menu_html;
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
this.Menu.init = function () {
|
|
296
|
+
$(this).parent().toggleClass('expanded').siblings().removeClass('expanded');
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
this.Menu.addFromApps = function (apps, label, cssclass) {
|
|
300
|
+
var app_items = [],
|
|
301
|
+
link,
|
|
302
|
+
appname;
|
|
303
|
+
apps.map(function (a) {
|
|
304
|
+
var cssclass = location.pathname.indexOf(a) != -1 ? "selected" : '';
|
|
305
|
+
var link = a + location.search;
|
|
306
|
+
appname = a; //TODO allow appname to use app title or display
|
|
307
|
+
|
|
308
|
+
app_items.push({
|
|
309
|
+
name: appname + '<capp-menu-option-bonus title="open in new window" onclick="window.open(\'' + link + '\'); window.event.stopPropagation();">' + self.svgs.newwindow + '</capp-menu-option-bonus>',
|
|
310
|
+
action: 'window.location=\'/JOE/' + link + '\'',
|
|
311
|
+
cssclass: cssclass
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
app_items.push({
|
|
315
|
+
name: 'Docs',
|
|
316
|
+
action: 'window.open(\'/JsonObjectEditor/docs.html#/method/JOE\'); window.event.stopPropagation();'
|
|
317
|
+
});
|
|
318
|
+
return self.Menu.add(label || 'Apps', app_items, 'capp-header', {
|
|
319
|
+
labelcss: 'multi-line capp-app-title',
|
|
320
|
+
cssclass: 'dd capp-apps-menu'
|
|
321
|
+
});
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
this.Menu.addFromSites = function (apps) {
|
|
325
|
+
var app_items = [];
|
|
326
|
+
apps.map(function (a) {
|
|
327
|
+
app_items.push({
|
|
328
|
+
name: a,
|
|
329
|
+
action: 'window.location=\'//localhost:2098/' + a.url + '\''
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
return self.Menu.add('Sites', app_items, 'capp-header');
|
|
333
|
+
};
|
|
334
|
+
/*----------------------END MENU ----------------------*/
|
|
335
|
+
|
|
336
|
+
/*---------------------> CAPP-DASHBOARD <---------------------*/
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
var Dashboard = this.Dashboard = {
|
|
340
|
+
tag: 'capp-dashboard',
|
|
341
|
+
target: 'capp-body'
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
this.Dashboard.init = function () {
|
|
345
|
+
var config = {
|
|
346
|
+
containment: 'capp-dashboard',
|
|
347
|
+
grid: [self.Card.size + self.Card.offset, self.Card.size + self.Card.offset],
|
|
348
|
+
refreshPositions: true,
|
|
349
|
+
cursor: 'move',
|
|
350
|
+
handle: '.handle'
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
if (!$c.isMobile()) {
|
|
354
|
+
$('capp-dashboard').find('capp-card').draggable(config);
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
this.Dashboard.toggle = function () {
|
|
359
|
+
if ($('capp-dashboard').draggable('option', 'disabled')) {
|
|
360
|
+
$('capp-dashboard').draggable('enable');
|
|
361
|
+
} else {
|
|
362
|
+
$('capp-dashboard').draggable('disable');
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
this.Dashboard.respond = function () {
|
|
367
|
+
//for each dashboard,get width
|
|
368
|
+
var wcutoff = 500;
|
|
369
|
+
var width, height;
|
|
370
|
+
$('capp-dashboard').each(function () {
|
|
371
|
+
width = $(window).width(); //$(this).width();
|
|
372
|
+
|
|
373
|
+
if (width < wcutoff && !$(this).hasClass('mobile')) {
|
|
374
|
+
$(this).addClass('mobile').find('capp-card.ui-draggable').draggable('disable');
|
|
375
|
+
} else if (width >= wcutoff && $(this).hasClass('mobile')) {
|
|
376
|
+
$(this).removeClass('mobile').find('capp-card.ui-draggable').draggable('enable');
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
utils.addRenderFunction(Dashboard);
|
|
382
|
+
/*---------------------> CAPP-DASHBOARD <---------------------*/
|
|
383
|
+
|
|
384
|
+
/*---------------------> CAPP-CARD <---------------------*/
|
|
385
|
+
|
|
386
|
+
this.Card = {
|
|
387
|
+
size: 160,
|
|
388
|
+
tag: 'capp-card',
|
|
389
|
+
offset: 10
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
this.Card.add = function (title, content, css, specs) {
|
|
393
|
+
var bk = {
|
|
394
|
+
title: title,
|
|
395
|
+
content: content,
|
|
396
|
+
css: css,
|
|
397
|
+
specs: specs
|
|
398
|
+
};
|
|
399
|
+
var card = {};
|
|
400
|
+
var obj = {};
|
|
401
|
+
var specs = specs || {};
|
|
402
|
+
|
|
403
|
+
if ($.type(title) == 'object') {
|
|
404
|
+
obj = $.extend({}, title);
|
|
405
|
+
card.attributes = title.attributes;
|
|
406
|
+
card.title = title = utils.propAsFuncOrValue(title.title);
|
|
407
|
+
card.specs = specs = specs || utils.propAsFuncOrValue(obj.specs);
|
|
408
|
+
card.cappid = specs.capp || cuid();
|
|
409
|
+
card.onload = obj.onload;
|
|
410
|
+
content = content || utils.propAsFuncOrValue(obj.content, card);
|
|
411
|
+
css = css || utils.propAsFuncOrValue(obj.cssclass || obj.css);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
var defs = {
|
|
415
|
+
title: title || false,
|
|
416
|
+
content: content || 'Card Content',
|
|
417
|
+
css: css || ''
|
|
418
|
+
};
|
|
419
|
+
var cappid = card.cappid || specs.capp || cuid();
|
|
420
|
+
var container = specs.container || 'capp-dashboard';
|
|
421
|
+
var pos = '';
|
|
422
|
+
var left = obj.left || specs.left;
|
|
423
|
+
var top = obj.top || specs.top;
|
|
424
|
+
|
|
425
|
+
if (left) {
|
|
426
|
+
pos += ' data-left=' + left;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
if (top) {
|
|
430
|
+
pos += ' data-top=' + top;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
self.instances[cappid] = $.extend(defs, {
|
|
434
|
+
type: 'card',
|
|
435
|
+
capp: cappid,
|
|
436
|
+
bk: bk,
|
|
437
|
+
onload: card.onload
|
|
438
|
+
});
|
|
439
|
+
var atts = ' ';
|
|
440
|
+
|
|
441
|
+
if (card.attributes) {
|
|
442
|
+
Object.keys(card.attributes).map(function (att) {
|
|
443
|
+
atts += " card-".concat(att, "='").concat(card.attributes[att], "'");
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
var temp = '<capp-card data-capp="' + cappid + '" class="${css} ' + (!self.instances[cappid].title && 'no-title' || '') + '" ' + pos + ' ' + atts + '>' + '<capp-title class="handle">${title}</capp-title>' + '<capp-content>${content}</capp-content>' + '</capp-card>';
|
|
448
|
+
var code = fillTemplate(temp, defs);
|
|
449
|
+
|
|
450
|
+
if (!specs.returnOnly) {
|
|
451
|
+
$(container) && $(container).append(code);
|
|
452
|
+
self.Card.init();
|
|
453
|
+
|
|
454
|
+
if (container == "capp-dashboard") {
|
|
455
|
+
self.Dashboard.init();
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
return code;
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
this.Card.init = function () {
|
|
463
|
+
var offset = self.Card.size + self.Card.offset; //find l1 and t1 classnames
|
|
464
|
+
|
|
465
|
+
$('capp-card').each(function () {
|
|
466
|
+
if (!$(this).hasClass('init')) {
|
|
467
|
+
var data = $(this).data();
|
|
468
|
+
var id = data['capp'] || cuid();
|
|
469
|
+
var css = {};
|
|
470
|
+
|
|
471
|
+
if (data.left) {
|
|
472
|
+
css.left = offset * data.left;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
if (data.top) {
|
|
476
|
+
css.top = offset * data.top;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
$(this).css(css).addClass('init');
|
|
480
|
+
$(this).attr('data-capp', id);
|
|
481
|
+
self.instances[id] = $.extend(self.instances[id] || {}, {
|
|
482
|
+
dom: $(this)
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
if (self.instances[id].onload) {
|
|
486
|
+
self.instances[id].onload(self.instances[id]);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
this.Card.reload = function (id) {
|
|
493
|
+
//reload a particular card
|
|
494
|
+
var instance = capp.instances[id];
|
|
495
|
+
var specs = $.extend(instance.bk.specs || {}, {
|
|
496
|
+
capp: id,
|
|
497
|
+
returnOnly: true
|
|
498
|
+
});
|
|
499
|
+
var oldDom = instance.dom;
|
|
500
|
+
var html = self.Card.add(instance.bk.title, instance.bk.content, instance.bk.css, specs);
|
|
501
|
+
$('capp-card[data-capp=' + id + ']').replaceWith(html);
|
|
502
|
+
};
|
|
503
|
+
/*---------------------> CAPP-CARD <---------------------*/
|
|
504
|
+
|
|
505
|
+
/*---------------------> CAPP-CHART <---------------------*/
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
this.Chart = {
|
|
509
|
+
tag: 'capp-chart'
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
this.Chart.timeline = function (valueProp, dateProp, schemaname, cappid, specs) {
|
|
513
|
+
var specs = specs || {};
|
|
514
|
+
var dataset = _joe.Data[schemaname];
|
|
515
|
+
var schemaobj = _joe.schemas[schemaname];
|
|
516
|
+
|
|
517
|
+
if (dataset) {
|
|
518
|
+
if (specs.filter) {
|
|
519
|
+
dataset = dataset.where(specs.filter);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
var dates = ['dates'];
|
|
523
|
+
var values = [specs.label || 'values'];
|
|
524
|
+
dataset.map(function (d) {
|
|
525
|
+
dates.push(_joe.propAsFuncOrValue(dateProp, d));
|
|
526
|
+
values.push(_joe.propAsFuncOrValue(valueProp, d));
|
|
527
|
+
});
|
|
528
|
+
var legendposition = _joe && _joe.sizeClass == "small-size" ? 'bottom' : 'right';
|
|
529
|
+
var chart = c3.generate({
|
|
530
|
+
bindto: 'capp-chart#chart_' + cappid + '',
|
|
531
|
+
legend: {
|
|
532
|
+
position: legendposition
|
|
533
|
+
},
|
|
534
|
+
data: {
|
|
535
|
+
x: 'dates',
|
|
536
|
+
columns: [dates, values]
|
|
537
|
+
}
|
|
538
|
+
/*onclick: function (d, i) {
|
|
539
|
+
var query = {schema:schemaname}
|
|
540
|
+
goJoe(_joe.getDataset(schemaname)||[],query);
|
|
541
|
+
}*/
|
|
542
|
+
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
this.Chart.byProperty = function (propertyname, schemaname, cappid, specs) {
|
|
548
|
+
var specs = specs || {};
|
|
549
|
+
var dataset = _joe.Data[schemaname];
|
|
550
|
+
var schemaobj = _joe.schemas[schemaname];
|
|
551
|
+
var propertymap = {};
|
|
552
|
+
var propcolors = specs.colors || {};
|
|
553
|
+
var subsets = specs.subsets;
|
|
554
|
+
|
|
555
|
+
if (dataset) {
|
|
556
|
+
propertymap = _joe.Utils.getPossibleValues('build_type', 'cg_model');
|
|
557
|
+
|
|
558
|
+
if (specs.filter) {
|
|
559
|
+
dataset = dataset.where(specs.filter);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
var cols = [];
|
|
563
|
+
var names = {};
|
|
564
|
+
var colors = [];
|
|
565
|
+
var cnt;
|
|
566
|
+
|
|
567
|
+
for (var property in propertymap) {
|
|
568
|
+
cnt = propertymap[property];
|
|
569
|
+
cols.push([property, cnt]);
|
|
570
|
+
names[property] = property + ' ' + cnt;
|
|
571
|
+
colors.push(propcolors[property] || _joe.Utils.getRandomColor());
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
var legendposition = _joe && _joe.sizeClass == "small-size" ? 'bottom' : 'right';
|
|
575
|
+
var chart = c3.generate({
|
|
576
|
+
bindto: 'capp-chart#chart_' + cappid + '',
|
|
577
|
+
data: {
|
|
578
|
+
columns: cols,
|
|
579
|
+
type: 'donut',
|
|
580
|
+
names: names,
|
|
581
|
+
onclick: function onclick(d, i) {
|
|
582
|
+
console.log(arguments);
|
|
583
|
+
var query = {
|
|
584
|
+
schema: schemaname
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
if (subsets) {
|
|
588
|
+
query.subset = d.name;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
goJoe(_joe.getDataset(schemaname) || [], query);
|
|
592
|
+
|
|
593
|
+
if (specs.filters) {
|
|
594
|
+
var dom = $('joe-filter-option[data-filter="' + d.id + '"]')[0];
|
|
595
|
+
|
|
596
|
+
_joe.toggleFilter(d.id, dom);
|
|
597
|
+
|
|
598
|
+
getJoe(0).toggleFiltersMenu();
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
},
|
|
602
|
+
donut: {
|
|
603
|
+
title: specs.chartTitle || propertyname
|
|
604
|
+
},
|
|
605
|
+
legend: {
|
|
606
|
+
position: legendposition
|
|
607
|
+
},
|
|
608
|
+
color: {
|
|
609
|
+
pattern: colors
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
this.Chart.byStatus = function (schemaname, cappid, specs) {
|
|
616
|
+
var specs = specs || {};
|
|
617
|
+
var dataset = _joe.Data[schemaname];
|
|
618
|
+
var schemaobj = _joe.schemas[schemaname];
|
|
619
|
+
|
|
620
|
+
if (dataset && _joe.Data.status) {
|
|
621
|
+
var statusmap = {
|
|
622
|
+
none: {
|
|
623
|
+
count: 0,
|
|
624
|
+
name: 'none',
|
|
625
|
+
color: 'grey'
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
var statuses = _joe.Data.status.sortBy('index').where({
|
|
630
|
+
datasets: {
|
|
631
|
+
$in: [schemaname]
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
|
|
635
|
+
statuses.map(function (status, i) {
|
|
636
|
+
statusmap[status._id] = {
|
|
637
|
+
count: 0,
|
|
638
|
+
name: status.name,
|
|
639
|
+
color: status.color
|
|
640
|
+
};
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
if (specs.filter) {
|
|
644
|
+
dataset = dataset.where(specs.filter);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
dataset.map(function (obj) {
|
|
648
|
+
if (statusmap[obj.status]) {
|
|
649
|
+
statusmap[obj.status].count++;
|
|
650
|
+
} else {
|
|
651
|
+
statusmap['none'].count++;
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
var cols = [];
|
|
655
|
+
var colors = [];
|
|
656
|
+
statusmap.map(function (status) {
|
|
657
|
+
cols.push([status.name + ' ' + status.count, status.count]);
|
|
658
|
+
colors.push(status.color || '#ccc');
|
|
659
|
+
});
|
|
660
|
+
var legendposition = _joe && _joe.sizeClass == "small-size" ? 'bottom' : 'right';
|
|
661
|
+
|
|
662
|
+
if (specs.delay) {
|
|
663
|
+
setTimeout(function () {
|
|
664
|
+
return c3.generate({
|
|
665
|
+
bindto: specs.target || 'capp-chart#chart_' + cappid + '',
|
|
666
|
+
data: {
|
|
667
|
+
columns: cols,
|
|
668
|
+
type: 'donut',
|
|
669
|
+
onclick: specs.onclick || function (d, i) {
|
|
670
|
+
goJoe(_joe.getDataset(schemaname) || [], {
|
|
671
|
+
schema: schemaname,
|
|
672
|
+
subset: d.name
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
},
|
|
676
|
+
donut: {
|
|
677
|
+
title: dataset.length + " " + schemaobj.name.pluralize() + " in " + (statuses.length + 1) + " statuses"
|
|
678
|
+
},
|
|
679
|
+
legend: {
|
|
680
|
+
position: legendposition
|
|
681
|
+
},
|
|
682
|
+
color: {
|
|
683
|
+
pattern: colors
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
}, 100);
|
|
687
|
+
return true;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
var chart = c3.generate({
|
|
691
|
+
bindto: specs.target || 'capp-chart#chart_' + cappid + '',
|
|
692
|
+
data: {
|
|
693
|
+
columns: cols,
|
|
694
|
+
type: 'donut',
|
|
695
|
+
onclick: specs.onclick || function (d, i) {
|
|
696
|
+
goJoe(_joe.getDataset(schemaname) || [], {
|
|
697
|
+
schema: schemaname,
|
|
698
|
+
subset: d.name
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
},
|
|
702
|
+
donut: {
|
|
703
|
+
title: dataset.length + " " + schemaobj.name.pluralize() + " in " + (statuses.length + 1) + " statuses"
|
|
704
|
+
},
|
|
705
|
+
legend: {
|
|
706
|
+
position: legendposition
|
|
707
|
+
},
|
|
708
|
+
color: {
|
|
709
|
+
pattern: colors
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
/*---------------------> CAPP-CHART <---------------------*/
|
|
715
|
+
|
|
716
|
+
/*---------------------> CAPP-PAGE <---------------------*/
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
this.Page = {
|
|
720
|
+
tag: 'capp-page'
|
|
721
|
+
};
|
|
722
|
+
|
|
723
|
+
this.Page.init = function () {
|
|
724
|
+
var offset = self.Card.size + self.Card.offset;
|
|
725
|
+
$('capp-page').each(function () {
|
|
726
|
+
if (!$(this).hasClass('init')) {
|
|
727
|
+
var data = $(this).data();
|
|
728
|
+
var css = {};
|
|
729
|
+
|
|
730
|
+
if (data.left) {
|
|
731
|
+
css.left = offset * data.left;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
if (data.top) {
|
|
735
|
+
css.top = offset * data.top;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
if (data.right) {
|
|
739
|
+
css.right = offset * data.right;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
if (data.bottom) {
|
|
743
|
+
css.bottom = offset * data.bottom;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
$(this).css(css).addClass('init');
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
};
|
|
750
|
+
/*---------------------> CAPP-PAGE <---------------------*/
|
|
751
|
+
|
|
752
|
+
/*---------------------> CAPP-TOGGLE <---------------------*/
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
this.Toggle = {
|
|
756
|
+
toggle: function toggle(id) {
|
|
757
|
+
$('*[data-toggle=' + id + ']').addClass('active').siblings().removeClass('active');
|
|
758
|
+
}
|
|
759
|
+
};
|
|
760
|
+
/*---------------------> CAPP-TOGGLE <---------------------*/
|
|
761
|
+
|
|
762
|
+
/*---------------------> CAPP-POPUP <---------------------*/
|
|
763
|
+
|
|
764
|
+
this.Popup = {
|
|
765
|
+
tag: 'capp-popup',
|
|
766
|
+
add: function add(title, content, specs) {
|
|
767
|
+
//pass cssclass id and capp
|
|
768
|
+
var bk = {
|
|
769
|
+
title: title,
|
|
770
|
+
content: content,
|
|
771
|
+
specs: specs
|
|
772
|
+
};
|
|
773
|
+
var specs = specs || {};
|
|
774
|
+
var cappid = specs.capp || cuid();
|
|
775
|
+
var closeBTN = specs.hasOwnProperty('close') && specs.close || true;
|
|
776
|
+
var active = specs.active || false;
|
|
777
|
+
var popobj = {
|
|
778
|
+
title: self.utils.propAsFuncOrValue(title),
|
|
779
|
+
content: self.utils.propAsFuncOrValue(content),
|
|
780
|
+
capp: cappid,
|
|
781
|
+
cssclass: self.utils.propAsFuncOrValue(specs.cssclass),
|
|
782
|
+
id: specs.cssid || specs.id || ''
|
|
783
|
+
};
|
|
784
|
+
var close_action = specs.close_action || '$(this).parent().toggleClass(\'active\');';
|
|
785
|
+
var template = '<capp-popup id="${id}" class="${cssclass} ' + (active && 'active' || '') + '" data-capp="${capp}">' + (closeBTN && '<capp-popup-close onclick="' + close_action + '"> X </capp-popup-close>' || '') + '<capp-title>${title}</capp-title>\
|
|
786
|
+
<capp-content>${content}</capp-content>\
|
|
787
|
+
</capp-popup>';
|
|
788
|
+
var popup_str = fillTemplate(template, popobj);
|
|
789
|
+
var container = specs.container || 'capp-wrapper';
|
|
790
|
+
$(container) && $(container).append(popup_str);
|
|
791
|
+
self.instances[cappid] = {
|
|
792
|
+
type: 'popup',
|
|
793
|
+
capp: cappid,
|
|
794
|
+
bk: bk
|
|
795
|
+
};
|
|
796
|
+
self.Popup.init();
|
|
797
|
+
return self.instances[cappid];
|
|
798
|
+
},
|
|
799
|
+
toggle: function toggle(cappid, title_active, content, callback) {
|
|
800
|
+
var popup;
|
|
801
|
+
var setActive;
|
|
802
|
+
var title_active = self.utils.propAsFuncOrValue(title_active);
|
|
803
|
+
var content = self.utils.propAsFuncOrValue(content);
|
|
804
|
+
|
|
805
|
+
if (!cappid) {
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
if ($c.isCuid(cappid)) {
|
|
810
|
+
popup = $('capp-popup[data-capp=' + cappid + ']');
|
|
811
|
+
} else {
|
|
812
|
+
popup = $('capp-popup#' + cappid);
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
if (title_active) {
|
|
816
|
+
setActive = true;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
if (title_active && title_active !== true) {
|
|
820
|
+
popup.find('capp-title').html(title_active);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
if (content && content !== true) {
|
|
824
|
+
popup.find('capp-content').html(content);
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
popup.toggleClass('active', setActive);
|
|
828
|
+
return popup;
|
|
829
|
+
},
|
|
830
|
+
respond: function respond() {},
|
|
831
|
+
"delete": function _delete(cappid) {
|
|
832
|
+
if (!cappid) {
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
if ($c.isCuid(cappid)) {
|
|
837
|
+
popup = $('capp-popup[data-capp=' + cappid + ']');
|
|
838
|
+
} else {
|
|
839
|
+
popup = $('capp-popup#' + cappid);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
var capp = popup.data('capp');
|
|
843
|
+
delete self.instances[capp];
|
|
844
|
+
popup.remove();
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
|
|
848
|
+
this.Popup.init = function () {
|
|
849
|
+
self.utils.initElements('capp-popup');
|
|
850
|
+
};
|
|
851
|
+
/*---------------------> CAPP-POPUP <---------------------*/
|
|
852
|
+
|
|
853
|
+
/*---------------------> RESPONSIVE <---------------------*/
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
this.Responsive = {
|
|
857
|
+
init: function init() {
|
|
858
|
+
$(window).on('resize', self.Responsive.go);
|
|
859
|
+
self.Responsive.go();
|
|
860
|
+
},
|
|
861
|
+
go: function go() {
|
|
862
|
+
clearTimeout(self.Responsive.timer);
|
|
863
|
+
self.Responsive.timer = setTimeout(function () {
|
|
864
|
+
if (_joe && _joe.resizeOk()) {
|
|
865
|
+
var respBM = new Benchmarker();
|
|
866
|
+
self.Reload.all();
|
|
867
|
+
|
|
868
|
+
for (var object in self) {
|
|
869
|
+
if (self[object].respond && object != 'Responsive') {
|
|
870
|
+
self[object].respond();
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
logit('responded in ' + respBM.stop() + 's');
|
|
875
|
+
}
|
|
876
|
+
}, 500);
|
|
877
|
+
}
|
|
878
|
+
};
|
|
879
|
+
/*---------------------> RESPONSIVE <---------------------*/
|
|
880
|
+
|
|
881
|
+
/*---------------------> RELOAD <---------------------*/
|
|
882
|
+
|
|
883
|
+
this.Reload = {
|
|
884
|
+
instance: function instance(id) {
|
|
885
|
+
if (id) {
|
|
886
|
+
var instance = capp.instances[id];
|
|
887
|
+
var itype;
|
|
888
|
+
|
|
889
|
+
try {
|
|
890
|
+
itype = instance.type.capitalize();
|
|
891
|
+
|
|
892
|
+
if (capp[itype].reload) {
|
|
893
|
+
capp[itype].reload(id);
|
|
894
|
+
}
|
|
895
|
+
} catch (e) {
|
|
896
|
+
logit('could not reload: ' + itype + ' ' + id, e, instance);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
},
|
|
900
|
+
all: function all() {
|
|
901
|
+
for (var i in capp.instances) {
|
|
902
|
+
self.Reload.instance(i);
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
self.Card.init();
|
|
906
|
+
self.Page.init();
|
|
907
|
+
self.Dashboard.init();
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
/*---------------------> RELOAD <---------------------*/
|
|
911
|
+
|
|
912
|
+
/*---------------------> HASH <---------------------*/
|
|
913
|
+
|
|
914
|
+
this.Hash = {
|
|
915
|
+
init: function init() {
|
|
916
|
+
window.addEventListener("hashchange", function (hashinfo) {
|
|
917
|
+
var hashchangehandler = specs.hashchangehandler || foo;
|
|
918
|
+
|
|
919
|
+
if (hashchangehandler) {
|
|
920
|
+
try {
|
|
921
|
+
hashchangehandler(hashinfo);
|
|
922
|
+
} catch (e) {
|
|
923
|
+
alert(e);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
};
|
|
929
|
+
/*---------------------> HASH <---------------------*/
|
|
930
|
+
|
|
931
|
+
/*----------------------BEGIN INIT ----------------------*/
|
|
932
|
+
|
|
933
|
+
this.init = function (s) {
|
|
934
|
+
specs = $c.merge(specs, s || {});
|
|
935
|
+
self.renderComponents(renderQueue); //componetize('capp-header');
|
|
936
|
+
|
|
937
|
+
self.initSVGs();
|
|
938
|
+
self.initInteractions();
|
|
939
|
+
self.Responsive.init();
|
|
940
|
+
self.Hash.init();
|
|
941
|
+
};
|
|
942
|
+
|
|
943
|
+
this.renderComponents = function (components) {
|
|
944
|
+
if (!components) {
|
|
945
|
+
return false;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
if (!components.isArray()) {
|
|
949
|
+
components = [components];
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
var comtype;
|
|
953
|
+
components.map(function (component) {
|
|
954
|
+
component = utils.propAsFuncOrValue(component); //(content,target,specs)
|
|
955
|
+
|
|
956
|
+
comtype = component.type.capitalize();
|
|
957
|
+
|
|
958
|
+
if (component && comtype) {
|
|
959
|
+
if (self[comtype]) {
|
|
960
|
+
if (self[comtype].render) {
|
|
961
|
+
self[comtype].render(utils.propAsFuncOrValue(component.content), component.target, component.specs);
|
|
962
|
+
} else if (self[comtype].add) {
|
|
963
|
+
component.config ? self[comtype].add(utils.propAsFuncOrValue(component.config)) : self[comtype].add(utils.propAsFuncOrValue(component.title), utils.propAsFuncOrValue(component.content), utils.propAsFuncOrValue(component.specs));
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
});
|
|
968
|
+
};
|
|
969
|
+
|
|
970
|
+
this.initSVGs = function () {
|
|
971
|
+
/*
|
|
972
|
+
* Replace all SVG images with inline SVG
|
|
973
|
+
*/
|
|
974
|
+
jQuery('img.svg').each(function () {
|
|
975
|
+
var $img = jQuery(this);
|
|
976
|
+
var imgID = $img.attr('id');
|
|
977
|
+
var imgClass = $img.attr('class');
|
|
978
|
+
var imgURL = $img.attr('src');
|
|
979
|
+
jQuery.get(imgURL, function (data) {
|
|
980
|
+
// Get the SVG tag, ignore the rest
|
|
981
|
+
var $svg = jQuery(data).find('svg'); // Add replaced image's ID to the new SVG
|
|
982
|
+
|
|
983
|
+
if (typeof imgID !== 'undefined') {
|
|
984
|
+
$svg = $svg.attr('id', imgID);
|
|
985
|
+
} // Add replaced image's classes to the new SVG
|
|
986
|
+
|
|
987
|
+
|
|
988
|
+
if (typeof imgClass !== 'undefined') {
|
|
989
|
+
$svg = $svg.attr('class', imgClass + ' replaced-svg');
|
|
990
|
+
} // Remove any invalid XML tags as per http://validator.w3.org
|
|
991
|
+
|
|
992
|
+
|
|
993
|
+
$svg = $svg.removeAttr('xmlns:a'); // Replace image with new SVG
|
|
994
|
+
|
|
995
|
+
$img.replaceWith($svg);
|
|
996
|
+
}, 'xml');
|
|
997
|
+
});
|
|
998
|
+
};
|
|
999
|
+
|
|
1000
|
+
this.special = {
|
|
1001
|
+
joeicon: function joeicon(open) {
|
|
1002
|
+
$('capp-menu.expanded').not('.default-schemas-menu').removeClass('expanded');
|
|
1003
|
+
$('#joePanelMenu').toggleClass('expanded', open);
|
|
1004
|
+
$('capp-dashboard').toggleClass('left-panel-open', $('#joePanelMenu').hasClass('expanded'));
|
|
1005
|
+
}
|
|
1006
|
+
};
|
|
1007
|
+
|
|
1008
|
+
this.initInteractions = function () {
|
|
1009
|
+
self.Card.init();
|
|
1010
|
+
self.Page.init();
|
|
1011
|
+
self.Dashboard.init();
|
|
1012
|
+
$('capp-header capp-menu-label').not('.init').click(self.Menu.init).addClass('init');
|
|
1013
|
+
/*$('capp-panel capp-menu-label').not('.init').on('dblclick',function(){
|
|
1014
|
+
$(this).parents('capp-panel').toggleClass('expanded');
|
|
1015
|
+
}).addClass('init');
|
|
1016
|
+
*/
|
|
1017
|
+
|
|
1018
|
+
$('capp-panel-toggle,.capp-panel-toggle').not('.init').click(function () {
|
|
1019
|
+
$(this).parents('capp-panel').toggleClass('expanded');
|
|
1020
|
+
}).addClass('init');
|
|
1021
|
+
$('capp-menu-toggle').click(function () {
|
|
1022
|
+
$('capp-wrapper').toggleClass('expanded');
|
|
1023
|
+
});
|
|
1024
|
+
$('capp-panel.hover-toggle').hover(function () {
|
|
1025
|
+
$(this).addClass('capp-targeted');
|
|
1026
|
+
window.__cpt = setTimeout(function () {
|
|
1027
|
+
$('.capp-targeted').addClass('expanded');
|
|
1028
|
+
}, 1000);
|
|
1029
|
+
}, function () {
|
|
1030
|
+
clearTimeout(window.__cpt);
|
|
1031
|
+
$('.capp-targeted').removeClass('expanded').removeClass('capp-targeted');
|
|
1032
|
+
}); //close panels on click
|
|
1033
|
+
|
|
1034
|
+
$('capp-view,capp-dashboard').on('click', function () {
|
|
1035
|
+
$('capp-panel.expanded,capp-menu.expanded').not('#joePanelMenu,.default-schemas-menu').removeClass('expanded');
|
|
1036
|
+
});
|
|
1037
|
+
};
|
|
1038
|
+
|
|
1039
|
+
if (specs.autoInit) {
|
|
1040
|
+
self.init();
|
|
1041
|
+
}
|
|
1042
|
+
/*----------------------END INIT ----------------------*/
|
|
1043
|
+
|
|
1044
|
+
|
|
1045
|
+
this.svgs = {
|
|
1046
|
+
newwindow: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="-32 -32 96 96" ><path d="M32 0H8v8C5.1 8 0 8 0 8v24h24v-8h8V0zM20 28H4V16h4v8h12C20 25.8 20 28 20 28zM28 20H12V8h16V20z"></path></svg>',
|
|
1047
|
+
quickadd: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="-12 -12 64 64"><g data-name="Layer 2"><polygon class="cls-1" points="28 22.3 22.5 22.3 22.5 28 17.6 28 17.6 22.3 12 22.3 12 17.5 17.6 17.5 17.6 12 22.5 12 22.5 17.5 28 17.5 28 22.3"/></g></svg>',
|
|
1048
|
+
newwindow2: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 26 26"><path d="M4 4C2.9 4 2 4.9 2 6L2 17 4 15 4 8 23 8 23 20 9 20 7 22 23 22C24.1 22 25 21.1 25 20L25 6C25 4.9 24.1 4 23 4L4 4zM6 13L7.8 14.8 1 21.6 2.4 23 9.2 16.2 11 18 11 13 6 13z"/></svg>'
|
|
1049
|
+
};
|
|
1050
|
+
return this;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
function componetize(name, createdCallback, specs) {
|
|
1054
|
+
var specs = specs || {};
|
|
1055
|
+
var componentPrototype = Object.create(HTMLElement.prototype);
|
|
1056
|
+
|
|
1057
|
+
componentPrototype.createdCallback = createdCallback || function () {//this.textContent = 'component: '+name;
|
|
1058
|
+
};
|
|
1059
|
+
|
|
1060
|
+
$c.merge(componentPrototype, specs); //componentPrototype.merge(specs);
|
|
1061
|
+
|
|
1062
|
+
document.registerElement(name, {
|
|
1063
|
+
prototype: componentPrototype
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
function __cancelPropagation(e) {
|
|
1068
|
+
var eve = e || window.event;
|
|
1069
|
+
if (eve.stopPropagation) eve.stopPropagation(); //if (eve.preventDefault) eve.preventDefault();
|
|
1070
|
+
|
|
1071
|
+
__closeAllExpanded();
|
|
1072
|
+
|
|
1073
|
+
return true;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
function __cancelClick() {
|
|
1077
|
+
__closeAllExpanded();
|
|
1078
|
+
|
|
1079
|
+
return false;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
function __closeAllExpanded() {
|
|
1083
|
+
$('capp-menu.expanded,capp-panel.expanded').removeClass('expanded');
|
|
1084
1084
|
}
|