1
|
/*
|
2
|
* Altair Admin
|
3
|
* author: tzd
|
4
|
*
|
5
|
* 1. Init functions
|
6
|
* 2. Helpers / Variables
|
7
|
* 3. Common functions & variables
|
8
|
*
|
9
|
* */
|
10
|
|
11
|
// 1. Init common functions on document ready
|
12
|
|
13
|
$(function() {
|
14
|
"use strict";
|
15
|
|
16
|
// page onload functions
|
17
|
altair_page_onload.init();
|
18
|
|
19
|
// main header
|
20
|
altair_main_header.init();
|
21
|
|
22
|
// main sidebar
|
23
|
altair_main_sidebar.init();
|
24
|
// secondary sidebar
|
25
|
altair_secondary_sidebar.init();
|
26
|
|
27
|
// top bar
|
28
|
altair_top_bar.init();
|
29
|
|
30
|
// page heading
|
31
|
altair_page._heading();
|
32
|
// page aside
|
33
|
altair_page._aside();
|
34
|
// page aside
|
35
|
altair_page._overflow();
|
36
|
|
37
|
// material design
|
38
|
altair_md.init();
|
39
|
|
40
|
// forms
|
41
|
altair_forms.init();
|
42
|
|
43
|
// truncate text helper
|
44
|
altair_helpers.truncate_text($('.truncate-text'));
|
45
|
|
46
|
// full screen
|
47
|
altair_helpers.full_screen();
|
48
|
|
49
|
// table check
|
50
|
altair_helpers.table_check();
|
51
|
|
52
|
// table tree
|
53
|
altair_helpers.table_tree();
|
54
|
|
55
|
// print page
|
56
|
altair_helpers.print_page();
|
57
|
|
58
|
// scroll to top
|
59
|
altair_helpers.scroll_to_top();
|
60
|
|
61
|
// uikit custom
|
62
|
altair_uikit.accordion_user_selected();
|
63
|
|
64
|
});
|
65
|
|
66
|
|
67
|
// 2. Helpers
|
68
|
|
69
|
/* Detect hi-res devices */
|
70
|
function isHighDensity() {
|
71
|
return ((window.matchMedia && (window.matchMedia('only screen and (min-resolution: 124dpi), only screen and (min-resolution: 1.3dppx), only screen and (min-resolution: 48.8dpcm)').matches || window.matchMedia('only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (min--moz-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3)').matches)) || (window.devicePixelRatio && window.devicePixelRatio > 1.3));
|
72
|
}
|
73
|
|
74
|
/* Calculate Scrollbar Width (http://chris-spittles.co.uk/jquery-calculate-scrollbar-width/) */
|
75
|
function scrollbarWidth(){var a=jQuery('<div style="width: 100%; height:200px;">test</div>'),b=jQuery('<div style="width:200px;height:150px; position: absolute; top: 0; left: 0; visibility: hidden; overflow:hidden;"></div>').append(a),c=a[0],a=b[0];jQuery("body").append(a);c=c.offsetWidth;b.css("overflow","scroll");a=a.clientWidth;b.remove();return c-a};
|
76
|
|
77
|
/* random id generator */
|
78
|
function randID_generator() {
|
79
|
var randLetter = String.fromCharCode(65 + Math.floor(Math.random() * 26));
|
80
|
return randLetter + Date.now();
|
81
|
}
|
82
|
|
83
|
/* detect IE */
|
84
|
function detectIE(){var a=window.navigator.userAgent,b=a.indexOf("MSIE ");if(0<b)return parseInt(a.substring(b+5,a.indexOf(".",b)),10);if(0<a.indexOf("Trident/"))return b=a.indexOf("rv:"),parseInt(a.substring(b+3,a.indexOf(".",b)),10);b=a.indexOf("Edge/");return 0<b?parseInt(a.substring(b+5,a.indexOf(".",b)),10):!1};
|
85
|
|
86
|
/* reverse array */
|
87
|
jQuery.fn.reverse = [].reverse;
|
88
|
|
89
|
/* serialize form */
|
90
|
$.fn.serializeObject = function() {
|
91
|
var o = {};
|
92
|
var a = this.serializeArray();
|
93
|
$.each(a, function() {
|
94
|
if (o[this.name] !== undefined) {
|
95
|
if (!o[this.name].push) {
|
96
|
o[this.name] = [o[this.name]];
|
97
|
}
|
98
|
o[this.name].push(this.value || '');
|
99
|
} else {
|
100
|
o[this.name] = this.value || '';
|
101
|
}
|
102
|
});
|
103
|
return o;
|
104
|
};
|
105
|
|
106
|
/* hex 2 rgba conversion */
|
107
|
function hex2rgba(hex,opacity){
|
108
|
hex = hex.replace('#','');
|
109
|
r = parseInt(hex.substring(0,2), 16);
|
110
|
g = parseInt(hex.substring(2,4), 16);
|
111
|
b = parseInt(hex.substring(4,6), 16);
|
112
|
|
113
|
result = 'rgba('+r+','+g+','+b+','+opacity/100+')';
|
114
|
return result;
|
115
|
}
|
116
|
|
117
|
/* Modernizr test for localStorage */
|
118
|
function lsTest(){
|
119
|
var test = 'test';
|
120
|
try {
|
121
|
localStorage.setItem(test, test);
|
122
|
localStorage.removeItem(test);
|
123
|
return true;
|
124
|
} catch(e) {
|
125
|
return false;
|
126
|
}
|
127
|
}
|
128
|
|
129
|
// selectize plugin
|
130
|
if(typeof $.fn.selectize != 'undefined') {
|
131
|
|
132
|
// inline dropdown
|
133
|
Selectize.define('dropdown_after', function(options) {
|
134
|
this.positionDropdown = (function () {
|
135
|
var $control = this.$control,
|
136
|
position = $control.position(),
|
137
|
position_left = position.left,
|
138
|
position_top = position.top + $control.outerHeight(true) + 32;
|
139
|
|
140
|
this.$dropdown.css({
|
141
|
width : $control.outerWidth(),
|
142
|
top : position_top,
|
143
|
left : position_left
|
144
|
});
|
145
|
|
146
|
});
|
147
|
});
|
148
|
|
149
|
// tooltip
|
150
|
Selectize.define('tooltip', function(options) {
|
151
|
var self = this;
|
152
|
this.setup = (function() {
|
153
|
var original = self.setup;
|
154
|
return function() {
|
155
|
original.apply(this, arguments);
|
156
|
var $wrapper = this.$wrapper,
|
157
|
$input = this.$input;
|
158
|
if($input.attr('title')) {
|
159
|
$wrapper
|
160
|
.attr('title', $input.attr('title'))
|
161
|
.attr('data-uk-tooltip', $input.attr('data-uk-tooltip'));
|
162
|
}
|
163
|
};
|
164
|
})();
|
165
|
});
|
166
|
|
167
|
Selectize.define('drag_drop', function(options) {
|
168
|
if (!$.fn.sortable) throw new Error('The "drag_drop" plugin requires jQuery UI "sortable".');
|
169
|
if (this.settings.mode !== 'multi') return;
|
170
|
var self = this;
|
171
|
|
172
|
self.lock = (function() {
|
173
|
var original = self.lock;
|
174
|
return function() {
|
175
|
var sortable = self.$control.data('sortable');
|
176
|
if (sortable) sortable.disable();
|
177
|
return original.apply(self, arguments);
|
178
|
};
|
179
|
})();
|
180
|
|
181
|
self.unlock = (function() {
|
182
|
var original = self.unlock;
|
183
|
return function() {
|
184
|
var sortable = self.$control.data('sortable');
|
185
|
if (sortable) sortable.enable();
|
186
|
return original.apply(self, arguments);
|
187
|
};
|
188
|
})();
|
189
|
|
190
|
self.setup = (function() {
|
191
|
var original = self.setup;
|
192
|
return function() {
|
193
|
original.apply(this, arguments);
|
194
|
|
195
|
var $control = self.$control.sortable({
|
196
|
items: '[data-value]',
|
197
|
forcePlaceholderSize: true,
|
198
|
disabled: self.isLocked,
|
199
|
start: function(e, ui) {
|
200
|
ui.placeholder.css('width', ui.helper.css('width'));
|
201
|
$control.css({overflow: 'visible'});
|
202
|
},
|
203
|
stop: function() {
|
204
|
$control.css({overflow: 'hidden'});
|
205
|
var active = self.$activeItems ? self.$activeItems.slice() : null;
|
206
|
var values = [];
|
207
|
$control.children('[data-value]').each(function() {
|
208
|
values.push($(this).attr('data-value'));
|
209
|
});
|
210
|
self.setValue(values);
|
211
|
self.setActiveItem(active);
|
212
|
},
|
213
|
helper: function(event, ui){
|
214
|
var $clone = $(ui).clone();
|
215
|
$clone .css('position','absolute');
|
216
|
return $clone.get(0);
|
217
|
}
|
218
|
});
|
219
|
};
|
220
|
})();
|
221
|
|
222
|
});
|
223
|
|
224
|
Selectize.define('remove_button', function(options) {
|
225
|
options = $.extend({
|
226
|
label : '×',
|
227
|
title : 'Remove',
|
228
|
className : 'remove',
|
229
|
append : true
|
230
|
}, options);
|
231
|
|
232
|
var escape_html = function(str) {
|
233
|
return (str + '')
|
234
|
.replace(/&/g, '&')
|
235
|
.replace(/</g, '<')
|
236
|
.replace(/>/g, '>')
|
237
|
.replace(/"/g, '"');
|
238
|
};
|
239
|
|
240
|
var singleClose = function(thisRef, options) {
|
241
|
|
242
|
options.className = options.className || 'remove-single';
|
243
|
|
244
|
var self = thisRef;
|
245
|
var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';
|
246
|
|
247
|
/**
|
248
|
* Appends an element as a child (with raw HTML).
|
249
|
*
|
250
|
* @param {string} html_container
|
251
|
* @param {string} html_element
|
252
|
* @return {string}
|
253
|
*/
|
254
|
var append = function(html_container, html_element) {
|
255
|
var pos = html_container.search(/(<\/[^>]+>\s*)$/);
|
256
|
return html_container.substring(0, pos) + html_element + html_container.substring(pos);
|
257
|
};
|
258
|
|
259
|
thisRef.setup = (function() {
|
260
|
var original = self.setup;
|
261
|
return function() {
|
262
|
// override the item rendering method to add the button to each
|
263
|
if (options.append) {
|
264
|
var id = $(self.$input.context).attr('id');
|
265
|
var selectizer = $('#'+id);
|
266
|
|
267
|
var render_item = self.settings.render.item;
|
268
|
self.settings.render.item = function(data) {
|
269
|
return append(render_item.apply(thisRef, arguments), html);
|
270
|
};
|
271
|
}
|
272
|
|
273
|
original.apply(thisRef, arguments);
|
274
|
|
275
|
// add event listener
|
276
|
thisRef.$control.on('click', '.' + options.className, function(e) {
|
277
|
e.preventDefault();
|
278
|
if (self.isLocked) return;
|
279
|
|
280
|
self.clear();
|
281
|
});
|
282
|
|
283
|
};
|
284
|
})();
|
285
|
};
|
286
|
|
287
|
var multiClose = function(thisRef, options) {
|
288
|
|
289
|
var self = thisRef;
|
290
|
var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';
|
291
|
|
292
|
/**
|
293
|
* Appends an element as a child (with raw HTML).
|
294
|
*
|
295
|
* @param {string} html_container
|
296
|
* @param {string} html_element
|
297
|
* @return {string}
|
298
|
*/
|
299
|
var append = function(html_container, html_element) {
|
300
|
var pos = html_container.search(/(<\/[^>]+>\s*)$/);
|
301
|
return html_container.substring(0, pos) + html_element + html_container.substring(pos);
|
302
|
};
|
303
|
|
304
|
thisRef.setup = (function() {
|
305
|
var original = self.setup;
|
306
|
return function() {
|
307
|
// override the item rendering method to add the button to each
|
308
|
if (options.append) {
|
309
|
var render_item = self.settings.render.item;
|
310
|
self.settings.render.item = function(data) {
|
311
|
return append(render_item.apply(thisRef, arguments), html);
|
312
|
};
|
313
|
}
|
314
|
|
315
|
original.apply(thisRef, arguments);
|
316
|
|
317
|
// add event listener
|
318
|
thisRef.$control.on('click', '.' + options.className, function(e) {
|
319
|
e.preventDefault();
|
320
|
if (self.isLocked) return;
|
321
|
|
322
|
var $item = $(e.currentTarget).parent();
|
323
|
self.setActiveItem($item);
|
324
|
if (self.deleteSelection()) {
|
325
|
self.setCaret(self.items.length);
|
326
|
}
|
327
|
});
|
328
|
|
329
|
};
|
330
|
})();
|
331
|
};
|
332
|
|
333
|
if (this.settings.mode === 'single') {
|
334
|
singleClose(this, options);
|
335
|
return;
|
336
|
} else {
|
337
|
multiClose(this, options);
|
338
|
}
|
339
|
});
|
340
|
}
|
341
|
|
342
|
|
343
|
// 3. Common functions & variables
|
344
|
|
345
|
// 3.1 material design easing
|
346
|
// 3.2 page onload init functions
|
347
|
// 3.3 page content
|
348
|
// 3.4 forms
|
349
|
// 3.5 main sidebar / main menu (left)
|
350
|
// 3.6 secondary sidebar (right)
|
351
|
// 3.7 top bar
|
352
|
// 3.8 main header
|
353
|
// 3.9 material design
|
354
|
// 3.10 common helpers
|
355
|
// 3.11 uikit custom
|
356
|
|
357
|
|
358
|
// 3.1 material design easing
|
359
|
easing_swiftOut = [ 0.35,0,0.25,1 ];
|
360
|
bez_easing_swiftOut = $.bez(easing_swiftOut);
|
361
|
|
362
|
var $body = $('body'),
|
363
|
$html = $('html'),
|
364
|
$document = $(document),
|
365
|
$window = $(window),
|
366
|
$page_content = $('#page_content'),
|
367
|
$page_content_inner = $('#page_content_inner'),
|
368
|
$sidebar_main = $('#sidebar_main'),
|
369
|
$sidebar_main_toggle = $('#sidebar_main_toggle'),
|
370
|
$sidebar_secondary = $('#sidebar_secondary'),
|
371
|
$sidebar_secondary_toggle = $('#sidebar_secondary_toggle'),
|
372
|
$topBar = $('#top_bar'),
|
373
|
$pageHeading = $('#page_heading'),
|
374
|
$pageAside = $('#page_aside'),
|
375
|
$pageOverflow = $('#page_overflow'),
|
376
|
$header_main = $('#header_main'),
|
377
|
header__main_height = 48;
|
378
|
|
379
|
|
380
|
// 3.2 page init functions
|
381
|
altair_page_onload = {
|
382
|
init: function() {
|
383
|
$window.on('load',function(){
|
384
|
// fire functions on window load
|
385
|
altair_helpers.hierarchical_show();
|
386
|
altair_helpers.hierarchical_slide();
|
387
|
// add animations when all partials are loaded
|
388
|
$body.removeClass('disable_transitions');
|
389
|
});
|
390
|
}
|
391
|
};
|
392
|
|
393
|
// 3.3 page content
|
394
|
altair_page_content = {
|
395
|
hide_content_sidebar: function() {
|
396
|
if(!$body.hasClass('header_double_height')) {
|
397
|
//$page_content.css('max-height',$html.height() - 40);
|
398
|
$html.css({
|
399
|
'paddingRight': scrollbarWidth(),
|
400
|
'overflow': 'hidden'
|
401
|
});
|
402
|
}
|
403
|
},
|
404
|
show_content_sidebar: function() {
|
405
|
if(!$body.hasClass('header_double_height')) {
|
406
|
//$page_content.css('max-height','');
|
407
|
$html.css({
|
408
|
'paddingRight': '',
|
409
|
'overflow': ''
|
410
|
});
|
411
|
}
|
412
|
}
|
413
|
};
|
414
|
|
415
|
// 3.4 forms
|
416
|
altair_forms = {
|
417
|
init: function() {
|
418
|
altair_forms.textarea_autosize();
|
419
|
altair_forms.select_elements();
|
420
|
altair_forms.select_elements_2();
|
421
|
altair_forms.switches();
|
422
|
altair_forms.dynamic_fields();
|
423
|
},
|
424
|
textarea_autosize: function() {
|
425
|
$textarea = $('textarea.md-input').not('.no_autosize');
|
426
|
if($textarea.hasClass('autosized')) {
|
427
|
autosize.destroy($textarea);
|
428
|
}
|
429
|
autosize($textarea);
|
430
|
$textarea.addClass('autosized');
|
431
|
},
|
432
|
select_elements: function(parent) {
|
433
|
|
434
|
var $selectize = parent ? $(parent).find("[data-md-selectize-delayed]") : $("[data-md-selectize],.data-md-selectize");
|
435
|
|
436
|
$selectize.each(function(){
|
437
|
var $this = $(this);
|
438
|
if(!$this.hasClass('selectized')) {
|
439
|
var thisPosBottom = $this.attr('data-md-selectize-bottom'),
|
440
|
sel_plugins = ['tooltip'];
|
441
|
|
442
|
$this
|
443
|
.after('<div class="selectize_fix"></div>')
|
444
|
.selectize({
|
445
|
plugins: sel_plugins,
|
446
|
hideSelected: true,
|
447
|
dropdownParent: 'body',
|
448
|
onDropdownOpen: function($dropdown) {
|
449
|
$dropdown
|
450
|
.hide()
|
451
|
.velocity('slideDown', {
|
452
|
begin: function() {
|
453
|
if (typeof thisPosBottom !== 'undefined') {
|
454
|
$dropdown.css({'margin-top':'0'})
|
455
|
}
|
456
|
},
|
457
|
duration: 200,
|
458
|
easing: easing_swiftOut
|
459
|
})
|
460
|
},
|
461
|
onDropdownClose: function($dropdown) {
|
462
|
$dropdown
|
463
|
.show()
|
464
|
.velocity('slideUp', {
|
465
|
complete: function() {
|
466
|
if (typeof thisPosBottom !== 'undefined') {
|
467
|
$dropdown.css({'margin-top': ''})
|
468
|
}
|
469
|
},
|
470
|
duration: 200,
|
471
|
easing: easing_swiftOut
|
472
|
});
|
473
|
},
|
474
|
onChange: function(value) {
|
475
|
if( !!$this.attr('data-parsley-id')) {
|
476
|
$this.parsley().validate();
|
477
|
}
|
478
|
},
|
479
|
onInitialize: function() {
|
480
|
if($this[0].selectize.isRequired) {
|
481
|
$this.prop('required', true);
|
482
|
}
|
483
|
}
|
484
|
});
|
485
|
}
|
486
|
});
|
487
|
|
488
|
// dropdowns
|
489
|
var $selectize_inline = parent ? $(parent).find("[data-md-selectize-inline-delayed]") : $("[data-md-selectize-inline]");
|
490
|
|
491
|
$selectize_inline.each(function(){
|
492
|
var $this = $(this);
|
493
|
if(!$this.hasClass('selectized')) {
|
494
|
var thisPosBottom = $this.attr('data-md-selectize-bottom');
|
495
|
$this
|
496
|
.after('<div class="selectize_fix"></div>')
|
497
|
.closest('div').addClass('uk-position-relative')
|
498
|
.end()
|
499
|
.selectize({
|
500
|
plugins: [
|
501
|
'dropdown_after'
|
502
|
],
|
503
|
dropdownParent: $this.closest('div'),
|
504
|
hideSelected: true,
|
505
|
onDropdownOpen: function($dropdown) {
|
506
|
$dropdown
|
507
|
.hide()
|
508
|
.velocity('slideDown', {
|
509
|
begin: function() {
|
510
|
if (typeof thisPosBottom !== 'undefined') {
|
511
|
$dropdown.css({'margin-top':'0'})
|
512
|
}
|
513
|
},
|
514
|
duration: 200,
|
515
|
easing: easing_swiftOut
|
516
|
})
|
517
|
},
|
518
|
onDropdownClose: function($dropdown) {
|
519
|
$dropdown
|
520
|
.show()
|
521
|
.velocity('slideUp', {
|
522
|
complete: function() {
|
523
|
if (typeof thisPosBottom !== 'undefined') {
|
524
|
$dropdown.css({'margin-top': ''})
|
525
|
}
|
526
|
},
|
527
|
duration: 200,
|
528
|
easing: easing_swiftOut
|
529
|
});
|
530
|
},
|
531
|
onChange: function(value) {
|
532
|
if( !!$this.attr('data-parsley-id')) {
|
533
|
$this.parsley().validate();
|
534
|
}
|
535
|
}
|
536
|
});
|
537
|
}
|
538
|
})
|
539
|
|
540
|
},
|
541
|
select_elements_2: function(parent) {
|
542
|
var $select2 = parent ? $(parent).find("[data-md-select2-delayed]") : $("[data-md-select2],.md-select2");
|
543
|
|
544
|
$select2.each(function() {
|
545
|
var $this = $(this);
|
546
|
if (!$this.hasClass('select2-hidden-accessible')) {
|
547
|
$this.select2({
|
548
|
closeOnSelect: false
|
549
|
})
|
550
|
}
|
551
|
|
552
|
$this.on('select2:open', function (e) {
|
553
|
var $dropdown = $('.select2-dropdown');
|
554
|
$dropdown.hide();
|
555
|
setTimeout(function() {
|
556
|
$dropdown.velocity('slideDown', {
|
557
|
duration: 150,
|
558
|
easing: easing_swiftOut
|
559
|
})
|
560
|
},50)
|
561
|
});
|
562
|
|
563
|
})
|
564
|
},
|
565
|
// switchery plugin
|
566
|
switches: function(parent) {
|
567
|
var $elem = parent ? $(parent).find('[data-switchery]') : $('[data-switchery]');
|
568
|
if($elem.length) {
|
569
|
$elem.each(function() {
|
570
|
if(!$(this).siblings('.switchery').length) {
|
571
|
var $this = this,
|
572
|
this_size = $($this).attr('data-switchery-size'),
|
573
|
this_color = $($this).attr('data-switchery-color'),
|
574
|
this_secondary_color = $($this).attr('data-switchery-secondary-color');
|
575
|
|
576
|
var switchery = new Switchery($this, {
|
577
|
color: (typeof this_color !== 'undefined') ? hex2rgba(this_color,50) : hex2rgba('#009688',50),
|
578
|
jackColor: (typeof this_color !== 'undefined') ? hex2rgba(this_color,100) : hex2rgba('#009688',100),
|
579
|
secondaryColor: (typeof this_secondary_color !== 'undefined') ? hex2rgba(this_secondary_color,50) : 'rgba(0, 0, 0,0.26)',
|
580
|
jackSecondaryColor: (typeof this_secondary_color !== 'undefined') ? hex2rgba(this_secondary_color,50) : '#fafafa',
|
581
|
className: 'switchery' + ( (typeof this_size !== 'undefined') ? ' switchery-'+ this_size : '' )
|
582
|
});
|
583
|
|
584
|
$(this).data('ObjSwitchery', switchery);
|
585
|
|
586
|
}
|
587
|
})
|
588
|
}
|
589
|
},
|
590
|
parsley_validation_config: function() {
|
591
|
window.ParsleyConfig = {
|
592
|
excluded: 'input[type=button], input[type=submit], input[type=reset], input[type=hidden], input.exclude_validation',
|
593
|
trigger: 'change',
|
594
|
errorsWrapper: '<div class="parsley-errors-list"></div>',
|
595
|
errorTemplate: '<span></span>',
|
596
|
errorClass: 'md-input-danger',
|
597
|
successClass: 'md-input-success',
|
598
|
errorsContainer: function (ParsleyField) {
|
599
|
var element = ParsleyField.$element;
|
600
|
return element.closest('.parsley-row');
|
601
|
},
|
602
|
classHandler: function (ParsleyField) {
|
603
|
var element = ParsleyField.$element;
|
604
|
if( element.is(':checkbox') || element.is(':radio') || element.parent().is('label') || $(element).is('[data-md-selectize]') ) {
|
605
|
return element.closest('.parsley-row');
|
606
|
}
|
607
|
}
|
608
|
};
|
609
|
},
|
610
|
parsley_extra_validators: function() {
|
611
|
window.ParsleyConfig = window.ParsleyConfig || {};
|
612
|
window.ParsleyConfig.validators = window.ParsleyConfig.validators || {};
|
613
|
|
614
|
window.ParsleyConfig.validators.date = {
|
615
|
fn: function (value) {
|
616
|
|
617
|
var matches = /^(\d{2})[.\/](\d{2})[.\/](\d{4})$/.exec(value);
|
618
|
if (matches == null) return false;
|
619
|
|
620
|
var parts = value.split(/[.\/-]+/),
|
621
|
day = parseInt(parts[1], 10),
|
622
|
month = parseInt(parts[0], 10),
|
623
|
year = parseInt(parts[2], 10);
|
624
|
|
625
|
if (year == 0 || month == 0 || month > 12) {
|
626
|
return false;
|
627
|
}
|
628
|
var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
629
|
if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) {
|
630
|
monthLength[1] = 29;
|
631
|
}
|
632
|
return day > 0 && day <= monthLength[month - 1];
|
633
|
},
|
634
|
priority: 256
|
635
|
};
|
636
|
},
|
637
|
dynamic_fields: function(parent,resize,fields_on_load) {
|
638
|
function add_fields(wrapper,template,index) {
|
639
|
|
640
|
var source = $("#"+template).html(),
|
641
|
tmpl = Handlebars.compile(source),
|
642
|
theCompiledHtml = tmpl({
|
643
|
index: index ? index : 0,
|
644
|
counter: index ? '__' + index : '__' + 0
|
645
|
});
|
646
|
|
647
|
wrapper.append(theCompiledHtml);
|
648
|
|
649
|
// initialize inputs
|
650
|
altair_md.inputs(wrapper);
|
651
|
// initialize checkboxes
|
652
|
altair_md.checkbox_radio(wrapper.find('[data-md-icheck]'));
|
653
|
// initialize switches
|
654
|
altair_forms.switches(wrapper);
|
655
|
// initialize selectize
|
656
|
altair_forms.select_elements(wrapper);
|
657
|
|
658
|
}
|
659
|
var $dynamic_fields = parent ? $(parent).find('[data-dynamic-fields]') : $('[data-dynamic-fields]');
|
660
|
$dynamic_fields.each(function () {
|
661
|
var $this = $(this).attr('dynamic-fields-counter',0),
|
662
|
this_template = $this.data('dynamicFields');
|
663
|
|
664
|
if(!fields_on_load) {
|
665
|
add_fields($this,this_template);
|
666
|
}
|
667
|
|
668
|
$this
|
669
|
// add section
|
670
|
.on('click','.btnSectionClone',function (e) {
|
671
|
e.preventDefault();
|
672
|
$this.find('.btnSectionClone').replaceWith('<a href="#" class="btnSectionRemove"><i class="material-icons md-24"></i></a>');
|
673
|
|
674
|
var index = parseInt($this.attr('dynamic-fields-counter')) + 1;
|
675
|
$this.attr('dynamic-fields-counter',index);
|
676
|
|
677
|
add_fields($this,this_template,index);
|
678
|
|
679
|
if(resize) {
|
680
|
$window.resize();
|
681
|
}
|
682
|
})
|
683
|
// remove section
|
684
|
.on('click', '.btnSectionRemove', function(e) {
|
685
|
e.preventDefault();
|
686
|
var $this = $(this);
|
687
|
$this.closest('.form_section').next('.form_hr').remove().end().remove();
|
688
|
if(resize) {
|
689
|
$window.resize();
|
690
|
}
|
691
|
});
|
692
|
|
693
|
});
|
694
|
}
|
695
|
};
|
696
|
|
697
|
// 3.5 main sidebar (left)
|
698
|
altair_main_sidebar = {
|
699
|
init: function() {
|
700
|
if($sidebar_main.length) {
|
701
|
// check if browser support localstorage
|
702
|
if(lsTest()) {
|
703
|
// check if mini sidebar is enabled
|
704
|
if(localStorage.getItem("altair_sidebar_mini") !== null) {
|
705
|
$body.addClass('sidebar_mini');
|
706
|
}
|
707
|
if(localStorage.getItem("altair_sidebar_slim") !== null) {
|
708
|
$body.addClass('sidebar_slim');
|
709
|
}
|
710
|
}
|
711
|
|
712
|
if ($body.hasClass('sidebar_mini')) {
|
713
|
|
714
|
// small sidebar
|
715
|
altair_main_sidebar.mini_sidebar();
|
716
|
|
717
|
setTimeout(function() {
|
718
|
$window.resize();
|
719
|
}, 280);
|
720
|
|
721
|
} else if($body.hasClass('sidebar_slim')) {
|
722
|
|
723
|
// slim sidebar
|
724
|
altair_main_sidebar.slim_sidebar();
|
725
|
|
726
|
// custom scroller
|
727
|
altair_helpers.custom_scrollbar($sidebar_main);
|
728
|
|
729
|
// menu
|
730
|
altair_main_sidebar.sidebar_menu();
|
731
|
|
732
|
setTimeout(function() {
|
733
|
$window.resize();
|
734
|
}, 280);
|
735
|
|
736
|
} else {
|
737
|
|
738
|
$sidebar_main_toggle.on('click', function(e) {
|
739
|
e.preventDefault();
|
740
|
( $body.hasClass('sidebar_main_active') || ($body.hasClass('sidebar_main_open') && $window.width() >= 1220) ) ? altair_main_sidebar.hide_sidebar() : altair_main_sidebar.show_sidebar();
|
741
|
});
|
742
|
// hide sidebar (outside click/esc key pressed)
|
743
|
$document.on('click keyup', function(e) {
|
744
|
if( $body.hasClass('sidebar_main_active') && $window.width() < 1220 ) {
|
745
|
if (
|
746
|
( !$(e.target).closest($sidebar_main).length && !$(e.target).closest($sidebar_main_toggle).length )
|
747
|
|| ( e.keyCode == 27 )
|
748
|
) {
|
749
|
altair_main_sidebar.hide_sidebar();
|
750
|
}
|
751
|
}
|
752
|
});
|
753
|
|
754
|
// custom scroller
|
755
|
altair_helpers.custom_scrollbar($sidebar_main);
|
756
|
|
757
|
if( $body.hasClass('sidebar_main_active') && $window.width() < 1220 ) {
|
758
|
altair_page_content.hide_content_sidebar();
|
759
|
} else {
|
760
|
altair_page_content.show_content_sidebar();
|
761
|
}
|
762
|
if( $body.hasClass('sidebar_main_open') && $window.width() < 1220 ) {
|
763
|
$body.removeClass('sidebar_main_open')
|
764
|
}
|
765
|
|
766
|
// menu
|
767
|
altair_main_sidebar.sidebar_menu();
|
768
|
// swipe to open (touch devices)
|
769
|
altair_main_sidebar.swipe_open();
|
770
|
|
771
|
}
|
772
|
|
773
|
// language switcher
|
774
|
altair_main_sidebar.lang_switcher();
|
775
|
}
|
776
|
},
|
777
|
hide_sidebar: function() {
|
778
|
|
779
|
$body.addClass('sidebar_main_hiding').removeClass('sidebar_main_active sidebar_main_open');
|
780
|
if( $window.width() < 1220 ) {
|
781
|
altair_page_content.show_content_sidebar();
|
782
|
}
|
783
|
setTimeout(function() {
|
784
|
$body.removeClass('sidebar_main_hiding');
|
785
|
$window.resize();
|
786
|
},290);
|
787
|
|
788
|
},
|
789
|
show_sidebar: function() {
|
790
|
|
791
|
$body.addClass('sidebar_main_active');
|
792
|
if( $window.width() < 1220 && !$body.find('#page_overflow').length ) {
|
793
|
altair_page_content.hide_content_sidebar();
|
794
|
}
|
795
|
setTimeout(function() {
|
796
|
$window.resize();
|
797
|
},290);
|
798
|
|
799
|
},
|
800
|
sidebar_menu: function() {
|
801
|
// check for submenu
|
802
|
$sidebar_main.find('.menu_section > ul').find('li').each(function() {
|
803
|
var hasChildren = $(this).children('ul').length;
|
804
|
if(hasChildren) {
|
805
|
$(this).addClass('submenu_trigger')
|
806
|
}
|
807
|
});
|
808
|
// toggle sections
|
809
|
$('.submenu_trigger > a').on('click',function(e) {
|
810
|
e.preventDefault();
|
811
|
var $this = $(this);
|
812
|
var slideToogle = $this.next('ul').is(':visible') ? 'slideUp' : 'slideDown';
|
813
|
// accordion mode
|
814
|
var accordion_mode = $sidebar_main.hasClass('accordion_mode');
|
815
|
$this.next('ul')
|
816
|
.velocity(slideToogle, {
|
817
|
duration: 400,
|
818
|
easing: easing_swiftOut,
|
819
|
begin: function() {
|
820
|
if(slideToogle == 'slideUp') {
|
821
|
$(this).closest('.submenu_trigger').removeClass('act_section')
|
822
|
} else {
|
823
|
if(accordion_mode) {
|
824
|
$this.closest('li').siblings('.submenu_trigger').each(function() {
|
825
|
$(this).children('ul').velocity('slideUp', {
|
826
|
duration: 400,
|
827
|
easing: easing_swiftOut,
|
828
|
begin: function() {
|
829
|
$(this).closest('.submenu_trigger').removeClass('act_section')
|
830
|
}
|
831
|
})
|
832
|
})
|
833
|
}
|
834
|
$(this).closest('.submenu_trigger').addClass('act_section')
|
835
|
}
|
836
|
},
|
837
|
complete: function() {
|
838
|
if(slideToogle !== 'slideUp') {
|
839
|
var scrollContainer = $sidebar_main.find(".scroll-content").length ? $sidebar_main.find(".scroll-content") : $sidebar_main.find(".scrollbar-inner");
|
840
|
$this.closest('.act_section').velocity("scroll", {
|
841
|
duration: 400,
|
842
|
easing: easing_swiftOut,
|
843
|
container: scrollContainer
|
844
|
});
|
845
|
}
|
846
|
}
|
847
|
});
|
848
|
});
|
849
|
|
850
|
// open section/add classes if children has class .act_item
|
851
|
$sidebar_main.find('.act_item')
|
852
|
.each(function() {
|
853
|
var $this = $(this);
|
854
|
// top parent
|
855
|
$this.parents('.submenu_trigger').last().addClass('current_section');
|
856
|
// all parents
|
857
|
$this.parents('.submenu_trigger').addClass('act_section').children('ul').show();
|
858
|
// active item
|
859
|
$this.children('ul').show();
|
860
|
});
|
861
|
},
|
862
|
lang_switcher: function() {
|
863
|
var $lang_switcher = $('#lang_switcher');
|
864
|
|
865
|
if($lang_switcher.length) {
|
866
|
$lang_switcher.selectize({
|
867
|
options: [
|
868
|
{id: 1, title: 'English', value: 'gb'},
|
869
|
{id: 2, title: 'French', value: 'fr'},
|
870
|
{id: 3, title: 'Chinese', value: 'cn'},
|
871
|
{id: 4, title: 'Dutch', value: 'nl'},
|
872
|
{id: 5, title: 'Italian', value: 'it'},
|
873
|
{id: 6, title: 'Spanish', value: 'es'},
|
874
|
{id: 7, title: 'German', value: 'de'},
|
875
|
{id: 8, title: 'Polish', value: 'pl'}
|
876
|
],
|
877
|
render: {
|
878
|
option: function(data, escape) {
|
879
|
return '<div class="option">' +
|
880
|
'<i class="item-icon flag-' + escape(data.value).toUpperCase() + '"></i>' +
|
881
|
'<span>' + escape(data.title) + '</span>' +
|
882
|
'</div>';
|
883
|
},
|
884
|
item: function(data, escape) {
|
885
|
return '<div class="item"><i class="item-icon flag-' + escape(data.value).toUpperCase() + '"></i></div>';
|
886
|
}
|
887
|
},
|
888
|
valueField: 'value',
|
889
|
labelField: 'title',
|
890
|
searchField: 'title',
|
891
|
create: false,
|
892
|
hideSelected: true,
|
893
|
onDropdownOpen: function($dropdown) {
|
894
|
$dropdown
|
895
|
.hide()
|
896
|
.velocity('slideDown', {
|
897
|
begin: function() {
|
898
|
$dropdown.css({'margin-top':'-33px'})
|
899
|
},
|
900
|
duration: 200,
|
901
|
easing: easing_swiftOut
|
902
|
})
|
903
|
},
|
904
|
onDropdownClose: function($dropdown) {
|
905
|
$dropdown
|
906
|
.show()
|
907
|
.velocity('slideUp', {
|
908
|
complete: function() {
|
909
|
$dropdown.css({'margin-top':''})
|
910
|
},
|
911
|
duration: 200,
|
912
|
easing: easing_swiftOut
|
913
|
})
|
914
|
}
|
915
|
});
|
916
|
|
917
|
$lang_switcher.next().children('.selectize-input').find('input').attr('readonly',true);
|
918
|
|
919
|
}
|
920
|
|
921
|
},
|
922
|
swipe_open: function() {
|
923
|
if( $body.hasClass('sidebar_main_swipe') && Modernizr.touch) {
|
924
|
$body.append('<div id="sidebar_swipe_area" style="position: fixed;left: 0;top:0;z-index:1000;width:16px;height:100%"></div>');
|
925
|
|
926
|
var sidebar_swipe_area = document.getElementById("sidebar_swipe_area");
|
927
|
|
928
|
mc = new Hammer.Manager(sidebar_swipe_area);
|
929
|
mc.add(new Hammer.Swipe({
|
930
|
threshold: 0,
|
931
|
pointers: 2,
|
932
|
velocity: 0
|
933
|
}));
|
934
|
|
935
|
mc.on("swiperight", function() {
|
936
|
if (!$body.hasClass('sidebar_main_active')) {
|
937
|
altair_main_sidebar.show_sidebar();
|
938
|
}
|
939
|
});
|
940
|
|
941
|
}
|
942
|
},
|
943
|
mini_sidebar: function() {
|
944
|
|
945
|
$sidebar_main_toggle.hide();
|
946
|
|
947
|
$sidebar_main.find('.menu_section > ul').children('li').each(function() {
|
948
|
var hasChildren = $(this).children('ul').length;
|
949
|
if(hasChildren) {
|
950
|
$(this).addClass('sidebar_submenu');
|
951
|
if($(this).find('.act_item').length) {
|
952
|
$(this).addClass('current_section');
|
953
|
}
|
954
|
} else {
|
955
|
$(this).attr({
|
956
|
'data-uk-tooltip': "{pos:'right'}"
|
957
|
});
|
958
|
}
|
959
|
});
|
960
|
|
961
|
$body
|
962
|
.addClass('sidebar_mini')
|
963
|
.removeClass('sidebar_main_active sidebar_main_open sidebar_main_swipe');
|
964
|
|
965
|
},
|
966
|
slim_sidebar: function() {
|
967
|
$sidebar_main_toggle.hide();
|
968
|
|
969
|
$body
|
970
|
.addClass('sidebar_slim sidebar_slim_inactive')
|
971
|
.removeClass('sidebar_main_active sidebar_main_open sidebar_main_swipe');
|
972
|
|
973
|
$sidebar_main
|
974
|
.mouseenter(function() {
|
975
|
$body.removeClass('sidebar_slim_inactive');
|
976
|
$body.addClass('sidebar_slim_active');
|
977
|
})
|
978
|
.mouseleave(function() {
|
979
|
$body.addClass('sidebar_slim_inactive');
|
980
|
$body.removeClass('sidebar_slim_active');
|
981
|
})
|
982
|
|
983
|
}
|
984
|
};
|
985
|
|
986
|
// secondary sidebar (right)
|
987
|
altair_secondary_sidebar = {
|
988
|
init: function() {
|
989
|
if($sidebar_secondary.length) {
|
990
|
$sidebar_secondary_toggle.removeClass('sidebar_secondary_check');
|
991
|
|
992
|
$sidebar_secondary_toggle.on('click', function (e) {
|
993
|
e.preventDefault();
|
994
|
$body.hasClass('sidebar_secondary_active') ? altair_secondary_sidebar.hide_sidebar() : altair_secondary_sidebar.show_sidebar();
|
995
|
});
|
996
|
|
997
|
// hide sidebar (outside/esc click)
|
998
|
$document.on('click keydown', function(e) {
|
999
|
if($body.hasClass('sidebar_secondary_persisten')) {
|
1000
|
return;
|
1001
|
}
|
1002
|
if( $body.hasClass('sidebar_secondary_active') && ( ( !$(e.target).closest($sidebar_secondary).length && !$(e.target).closest($sidebar_secondary_toggle).length ) || (e.which == 27) )) {
|
1003
|
altair_secondary_sidebar.hide_sidebar();
|
1004
|
}
|
1005
|
});
|
1006
|
|
1007
|
// hide page sidebar on page load
|
1008
|
if ( $body.hasClass('sidebar_secondary_active') ) {
|
1009
|
altair_secondary_sidebar.hide_sidebar();
|
1010
|
}
|
1011
|
|
1012
|
// custom scroller
|
1013
|
altair_helpers.custom_scrollbar($sidebar_secondary);
|
1014
|
|
1015
|
// chat section
|
1016
|
altair_secondary_sidebar.chat_sidebar();
|
1017
|
|
1018
|
}
|
1019
|
},
|
1020
|
hide_sidebar: function() {
|
1021
|
$body.removeClass('sidebar_secondary_active');
|
1022
|
},
|
1023
|
show_sidebar: function() {
|
1024
|
$body.addClass('sidebar_secondary_active');
|
1025
|
},
|
1026
|
chat_sidebar: function() {
|
1027
|
if($sidebar_secondary.find('.md-list.chat_users').length) {
|
1028
|
|
1029
|
$('.md-list.chat_users').children('li').on('click',function() {
|
1030
|
$('.md-list.chat_users').velocity("transition.slideRightBigOut", {
|
1031
|
duration: 280,
|
1032
|
easing: easing_swiftOut,
|
1033
|
complete: function() {
|
1034
|
$sidebar_secondary
|
1035
|
.find('.chat_box_wrapper')
|
1036
|
.addClass('chat_box_active')
|
1037
|
.velocity("transition.slideRightBigIn", {
|
1038
|
duration: 280,
|
1039
|
easing: easing_swiftOut,
|
1040
|
begin: function() {
|
1041
|
$sidebar_secondary.addClass('chat_sidebar')
|
1042
|
}
|
1043
|
})
|
1044
|
}
|
1045
|
});
|
1046
|
});
|
1047
|
|
1048
|
$sidebar_secondary
|
1049
|
.find('.chat_sidebar_close')
|
1050
|
.on('click',function() {
|
1051
|
$sidebar_secondary
|
1052
|
.find('.chat_box_wrapper')
|
1053
|
.removeClass('chat_box_active')
|
1054
|
.velocity("transition.slideRightBigOut", {
|
1055
|
duration: 280,
|
1056
|
easing: easing_swiftOut,
|
1057
|
complete: function () {
|
1058
|
$sidebar_secondary.removeClass('chat_sidebar')
|
1059
|
$('.md-list.chat_users').velocity("transition.slideRightBigIn", {
|
1060
|
duration: 280,
|
1061
|
easing: easing_swiftOut
|
1062
|
})
|
1063
|
}
|
1064
|
})
|
1065
|
});
|
1066
|
|
1067
|
if($sidebar_secondary.find('.uk-tab').length) {
|
1068
|
$sidebar_secondary.find('.uk-tab').on('change.uk.tab',function(event, active_item, previous_item) {
|
1069
|
if($(active_item).hasClass('chat_sidebar_tab') && $sidebar_secondary.find('.chat_box_wrapper').hasClass('chat_box_active')) {
|
1070
|
$sidebar_secondary.addClass('chat_sidebar')
|
1071
|
} else {
|
1072
|
$sidebar_secondary.removeClass('chat_sidebar')
|
1073
|
}
|
1074
|
})
|
1075
|
}
|
1076
|
}
|
1077
|
}
|
1078
|
};
|
1079
|
|
1080
|
// top bar
|
1081
|
altair_top_bar = {
|
1082
|
init: function () {
|
1083
|
if($topBar.length) {
|
1084
|
if($topBar.hasClass('top_bar_static')) {
|
1085
|
$body.addClass('top_bar_static_active');
|
1086
|
} else {
|
1087
|
$body.addClass('top_bar_active');
|
1088
|
}
|
1089
|
}
|
1090
|
}
|
1091
|
};
|
1092
|
|
1093
|
altair_page = {
|
1094
|
// page heading
|
1095
|
_heading: function () {
|
1096
|
if($pageHeading.length) {
|
1097
|
$body.addClass('page_heading_active');
|
1098
|
}
|
1099
|
},
|
1100
|
// page aside
|
1101
|
_aside: function () {
|
1102
|
if($pageAside.length) {
|
1103
|
function calculateHeight() {
|
1104
|
var viewportHeight = $window.height(),
|
1105
|
asideTop = $pageAside.offset().top;
|
1106
|
$pageAside.height(viewportHeight - asideTop);
|
1107
|
}
|
1108
|
calculateHeight();
|
1109
|
$window.on('debouncedresize',function() {
|
1110
|
calculateHeight();
|
1111
|
});
|
1112
|
|
1113
|
// toggle aside
|
1114
|
$('.page_aside_toggle').on('click', function (e) {
|
1115
|
e.preventDefault();
|
1116
|
$body.toggleClass('page_aside_collapsed');
|
1117
|
})
|
1118
|
|
1119
|
}
|
1120
|
},
|
1121
|
_overflow: function () {
|
1122
|
if($pageOverflow.length) {
|
1123
|
function calculateHeight() {
|
1124
|
var viewportHeight = $window.height(),
|
1125
|
overflowTop = $pageOverflow.offset().top,
|
1126
|
height = viewportHeight - overflowTop;
|
1127
|
|
1128
|
if($pageOverflow.children('.uk-overflow-container').length) {
|
1129
|
$pageOverflow.children('.uk-overflow-container').height(height);
|
1130
|
} else {
|
1131
|
$pageOverflow.height(height);
|
1132
|
}
|
1133
|
|
1134
|
}
|
1135
|
calculateHeight();
|
1136
|
$window.on('debouncedresize',function() {
|
1137
|
calculateHeight();
|
1138
|
});
|
1139
|
}
|
1140
|
}
|
1141
|
};
|
1142
|
|
1143
|
// main header
|
1144
|
altair_main_header = {
|
1145
|
init: function() {
|
1146
|
altair_main_header.search_activate();
|
1147
|
altair_main_header.search_autocomplete();
|
1148
|
},
|
1149
|
search_activate: function() {
|
1150
|
|
1151
|
$('#main_search_btn').on('click',function(e) {
|
1152
|
e.preventDefault();
|
1153
|
altair_main_header.search_show();
|
1154
|
});
|
1155
|
|
1156
|
// hide main search
|
1157
|
$(document).on('click keydown', function(e) {
|
1158
|
if( !$body.hasClass('main_search_persistent') && $body.hasClass('main_search_active') ) {
|
1159
|
if (
|
1160
|
( !$(e.target).closest('.header_main_search_form').length && !$(e.target).closest('#main_search_btn').length )
|
1161
|
|| ( e.which == 27 )
|
1162
|
) {
|
1163
|
altair_main_header.search_hide();
|
1164
|
}
|
1165
|
}
|
1166
|
});
|
1167
|
|
1168
|
$('.header_main_search_close').on('click', function() {
|
1169
|
altair_main_header.search_hide();
|
1170
|
});
|
1171
|
|
1172
|
if($body.hasClass('main_search_persistent')) {
|
1173
|
altair_main_header.search_show();
|
1174
|
}
|
1175
|
},
|
1176
|
search_show: function() {
|
1177
|
$header_main
|
1178
|
.children('.header_main_content')
|
1179
|
.velocity("transition.slideUpBigOut", {
|
1180
|
duration: 280,
|
1181
|
easing: easing_swiftOut,
|
1182
|
begin: function() {
|
1183
|
$body.addClass('main_search_active');
|
1184
|
},
|
1185
|
complete: function() {
|
1186
|
$header_main
|
1187
|
.children('.header_main_search_form')
|
1188
|
.velocity("transition.slideDownBigIn", {
|
1189
|
duration: 280,
|
1190
|
easing: easing_swiftOut,
|
1191
|
complete: function() {
|
1192
|
$('.header_main_search_input').focus();
|
1193
|
}
|
1194
|
})
|
1195
|
}
|
1196
|
});
|
1197
|
},
|
1198
|
search_hide: function() {
|
1199
|
$header_main
|
1200
|
.children('.header_main_search_form')
|
1201
|
.velocity("transition.slideUpBigOut", {
|
1202
|
duration: 280,
|
1203
|
easing: easing_swiftOut,
|
1204
|
begin: function() {
|
1205
|
$header_main.velocity("reverse");
|
1206
|
$body.removeClass('main_search_active');
|
1207
|
},
|
1208
|
complete: function() {
|
1209
|
$header_main
|
1210
|
.children('.header_main_content')
|
1211
|
.velocity("transition.slideDownBigIn", {
|
1212
|
duration: 280,
|
1213
|
easing: easing_swiftOut,
|
1214
|
complete: function() {
|
1215
|
$('.header_main_search_input').blur().val('');
|
1216
|
}
|
1217
|
})
|
1218
|
}
|
1219
|
});
|
1220
|
},
|
1221
|
search_autocomplete: function() {
|
1222
|
// 'on item selected' event
|
1223
|
$('.header_main_search_form').children('[data-uk-autocomplete]').on('selectitem.uk.autocomplete', function(event, data, acobject) {
|
1224
|
console.log(event);
|
1225
|
console.log(data);
|
1226
|
console.log(acobject);
|
1227
|
});
|
1228
|
}
|
1229
|
};
|
1230
|
|
1231
|
// material design
|
1232
|
altair_md = {
|
1233
|
init: function() {
|
1234
|
altair_md.inputs();
|
1235
|
altair_md.checkbox_radio();
|
1236
|
altair_md.card_fullscreen();
|
1237
|
altair_md.card_expand();
|
1238
|
altair_md.card_overlay();
|
1239
|
altair_md.card_single();
|
1240
|
altair_md.card_panel();
|
1241
|
altair_md.card_progress();
|
1242
|
altair_md.list_outside();
|
1243
|
// FAB transitions
|
1244
|
altair_md.fab_speed_dial();
|
1245
|
altair_md.fab_toolbar();
|
1246
|
altair_md.fab_sheet();
|
1247
|
altair_md.wave_effect();
|
1248
|
},
|
1249
|
// card toggle fullscreen
|
1250
|
card_fullscreen: function() {
|
1251
|
$('.md-card-fullscreen-activate').on('click',function() {
|
1252
|
var $thisCard = $(this).closest('.md-card');
|
1253
|
|
1254
|
if(!$thisCard.hasClass('md-card-fullscreen')) {
|
1255
|
// get card atributes
|
1256
|
var mdCard_h = $thisCard.height(),
|
1257
|
mdCardToolbarFixed = $(this).hasClass('toolbar_fixed'),
|
1258
|
mdCard_w = $thisCard.width(),
|
1259
|
body_scroll_top = $body.scrollTop(),
|
1260
|
mdCard_offset = $thisCard.offset();
|
1261
|
|
1262
|
// create placeholder for card
|
1263
|
$thisCard.after('<div class="md-card-placeholder" style="width:'+ mdCard_w+'px;height:'+ mdCard_h+'px;"/>');
|
1264
|
// add overflow hidden to #page_content (fix for ios)
|
1265
|
//$body.addClass('md-card-fullscreen-active');
|
1266
|
// add width/height to card (preserve original size)
|
1267
|
$thisCard
|
1268
|
.addClass('md-card-fullscreen')
|
1269
|
.css({
|
1270
|
'width': mdCard_w,
|
1271
|
'height': mdCard_h,
|
1272
|
'left': mdCard_offset.left,
|
1273
|
'top': mdCard_offset.top - body_scroll_top
|
1274
|
})
|
1275
|
// animate card to top/left position
|
1276
|
.velocity(
|
1277
|
{
|
1278
|
left: 0,
|
1279
|
top: 0
|
1280
|
},
|
1281
|
{
|
1282
|
duration: 400,
|
1283
|
easing: easing_swiftOut,
|
1284
|
begin: function(elements) {
|
1285
|
// add back button
|
1286
|
var $toolbar = $thisCard.find('.md-card-toolbar');
|
1287
|
if($toolbar.length) {
|
1288
|
$toolbar.prepend('<span class="md-icon md-card-fullscreen-deactivate material-icons uk-float-left"></span>');
|
1289
|
} else {
|
1290
|
$thisCard.append('<span class="md-icon md-card-fullscreen-deactivate material-icons uk-position-top-right" style="margin:10px 10px 0 0"></span>')
|
1291
|
}
|
1292
|
altair_page_content.hide_content_sidebar();
|
1293
|
}
|
1294
|
}
|
1295
|
// resize card to full width/height
|
1296
|
).velocity(
|
1297
|
{
|
1298
|
height: '100%',
|
1299
|
width: '100%'
|
1300
|
},
|
1301
|
{
|
1302
|
duration: 400,
|
1303
|
easing: easing_swiftOut,
|
1304
|
complete: function(elements) {
|
1305
|
// show fullscreen content
|
1306
|
$thisCard.find('.md-card-fullscreen-content').velocity("transition.slideUpBigIn", {
|
1307
|
duration: 400,
|
1308
|
easing: easing_swiftOut,
|
1309
|
complete: function(elements) {
|
1310
|
// activate onResize callback for some js plugins
|
1311
|
$(window).resize();
|
1312
|
}
|
1313
|
});
|
1314
|
if(mdCardToolbarFixed) {
|
1315
|
$thisCard.addClass('mdToolbar_fixed')
|
1316
|
}
|
1317
|
}
|
1318
|
}
|
1319
|
);
|
1320
|
}
|
1321
|
});
|
1322
|
|
1323
|
$page_content.on('click', '.md-card-fullscreen-deactivate', function() {
|
1324
|
// get card placeholder width/height and offset
|
1325
|
var $thisPlaceholderCard = $('.md-card-placeholder'),
|
1326
|
mdPlaceholderCard_h = $thisPlaceholderCard.height(),
|
1327
|
mdPlaceholderCard_w = $thisPlaceholderCard.width(),
|
1328
|
body_scroll_top = $body.scrollTop(),
|
1329
|
mdPlaceholderCard_offset_top = $thisPlaceholderCard.offset().top - body_scroll_top,
|
1330
|
mdPlaceholderCard_offset_left = $thisPlaceholderCard.offset().left,
|
1331
|
$thisCard = $('.md-card-fullscreen'),
|
1332
|
mdCardToolbarFixed = $thisCard.hasClass('mdToolbar_fixed');
|
1333
|
|
1334
|
$thisCard
|
1335
|
// resize card to original size
|
1336
|
.velocity(
|
1337
|
{
|
1338
|
height: mdPlaceholderCard_h,
|
1339
|
width: mdPlaceholderCard_w
|
1340
|
},
|
1341
|
{
|
1342
|
duration: 400,
|
1343
|
easing: easing_swiftOut,
|
1344
|
begin: function(elements) {
|
1345
|
// hide fullscreen content
|
1346
|
$thisCard.find('.md-card-fullscreen-content').velocity("transition.slideDownOut",{ duration: 275, easing: easing_swiftOut });
|
1347
|
if(mdCardToolbarFixed) {
|
1348
|
$thisCard.removeClass('mdToolbar_fixed')
|
1349
|
}
|
1350
|
},
|
1351
|
complete: function(elements) {
|
1352
|
// activate onResize callback for js plugins
|
1353
|
$window.resize();
|
1354
|
// remove back button
|
1355
|
$thisCard.find('.md-card-fullscreen-deactivate').remove();
|
1356
|
altair_page_content.show_content_sidebar();
|
1357
|
}
|
1358
|
}
|
1359
|
)
|
1360
|
// move card to original position
|
1361
|
.velocity(
|
1362
|
{
|
1363
|
left: mdPlaceholderCard_offset_left,
|
1364
|
top: mdPlaceholderCard_offset_top
|
1365
|
},
|
1366
|
{
|
1367
|
duration: 400,
|
1368
|
easing: easing_swiftOut,
|
1369
|
complete: function(elements) {
|
1370
|
// remove some styles added by velocity.js
|
1371
|
$thisCard.removeClass('md-card-fullscreen').css({
|
1372
|
width: '',
|
1373
|
height: '',
|
1374
|
left: '',
|
1375
|
top: ''
|
1376
|
});
|
1377
|
// remove card placeholder
|
1378
|
$thisPlaceholderCard.remove();
|
1379
|
// remove overflow:hidden from #page_content (ios fix)
|
1380
|
$body.removeClass('md-card-fullscreen-active');
|
1381
|
}
|
1382
|
}
|
1383
|
);
|
1384
|
});
|
1385
|
},
|
1386
|
card_expand: function() {
|
1387
|
// expand elements
|
1388
|
$(".md-expand").velocity("transition.expandIn", { stagger: 175, drag: true });
|
1389
|
$(".md-expand-group").children().velocity("transition.expandIn", { stagger: 175, drag: true });
|
1390
|
},
|
1391
|
card_overlay: function() {
|
1392
|
var $md_card = $('.md-card');
|
1393
|
|
1394
|
// replace toggler icon (x) when overlay is active
|
1395
|
$md_card.each(function() {
|
1396
|
var $this = $(this);
|
1397
|
if($this.hasClass('md-card-overlay-active')) {
|
1398
|
$this.find('.md-card-overlay-toggler').html('')
|
1399
|
}
|
1400
|
});
|
1401
|
|
1402
|
// toggle card overlay
|
1403
|
$md_card.on('click','.md-card-overlay-toggler', function(e) {
|
1404
|
e.preventDefault();
|
1405
|
if(!$(this).closest('.md-card').hasClass('md-card-overlay-active')) {
|
1406
|
$(this)
|
1407
|
.html('')
|
1408
|
.closest('.md-card').addClass('md-card-overlay-active');
|
1409
|
|
1410
|
} else {
|
1411
|
$(this)
|
1412
|
.html('')
|
1413
|
.closest('.md-card').removeClass('md-card-overlay-active');
|
1414
|
}
|
1415
|
})
|
1416
|
},
|
1417
|
card_single: function() {
|
1418
|
var $md_card_single = $('.md-card-single');
|
1419
|
if($md_card_single && $body.hasClass('header_double_height')) {
|
1420
|
function md_card_content_height() {
|
1421
|
var content_height = $window.height() - ((header__main_height * 2) + 12);
|
1422
|
$md_card_single.find('.md-card-content:first').innerHeight(content_height);
|
1423
|
}
|
1424
|
md_card_content_height();
|
1425
|
$window.on('debouncedresize',function() {
|
1426
|
md_card_content_height();
|
1427
|
});
|
1428
|
}
|
1429
|
},
|
1430
|
card_panel: function() {
|
1431
|
|
1432
|
$('.md-card-close').on('click',function(e) {
|
1433
|
e.preventDefault();
|
1434
|
var $this = $(this),
|
1435
|
thisCard = $this.closest('.md-card'),
|
1436
|
removeCard = function() {
|
1437
|
$(thisCard).remove();
|
1438
|
};
|
1439
|
altair_md.card_show_hide(thisCard,undefined,removeCard)
|
1440
|
});
|
1441
|
|
1442
|
$('.md-card-toggle').on('click',function(e) {
|
1443
|
e.preventDefault();
|
1444
|
var $this = $(this),
|
1445
|
thisCard = $this.closest('.md-card');
|
1446
|
|
1447
|
$(thisCard).toggleClass('md-card-collapsed').children('.md-card-content').slideToggle('280', bez_easing_swiftOut);
|
1448
|
|
1449
|
$this.velocity({
|
1450
|
scale: 0,
|
1451
|
opacity: 0.2
|
1452
|
}, {
|
1453
|
duration: 280,
|
1454
|
easing: easing_swiftOut,
|
1455
|
complete: function() {
|
1456
|
$(thisCard).hasClass('md-card-collapsed') ? $this.html('') : $this.html('');
|
1457
|
$this.velocity('reverse');
|
1458
|
$window.resize();
|
1459
|
}
|
1460
|
});
|
1461
|
|
1462
|
});
|
1463
|
|
1464
|
$('.md-card-collapsed').each(function() {
|
1465
|
var $card = $(this),
|
1466
|
$this_toggle = $card.find('.md-card-toggle');
|
1467
|
|
1468
|
$this_toggle.html('');
|
1469
|
$card.children('.md-card-content').hide();
|
1470
|
})
|
1471
|
|
1472
|
},
|
1473
|
card_show_hide: function(card,begin_callback,complete_callback,callback_element) {
|
1474
|
$(card)
|
1475
|
.velocity({
|
1476
|
scale: 0,
|
1477
|
opacity: 0.2
|
1478
|
}, {
|
1479
|
duration: 400,
|
1480
|
easing: easing_swiftOut,
|
1481
|
// on begin callback
|
1482
|
begin: function () {
|
1483
|
if (typeof begin_callback !== 'undefined') {
|
1484
|
begin_callback(callback_element);
|
1485
|
}
|
1486
|
},
|
1487
|
// on complete callback
|
1488
|
complete: function () {
|
1489
|
if (typeof complete_callback !== 'undefined') {
|
1490
|
complete_callback(callback_element);
|
1491
|
}
|
1492
|
}
|
1493
|
})
|
1494
|
.velocity('reverse');
|
1495
|
},
|
1496
|
card_progress: function(card,percent,steps) {
|
1497
|
var $toolbar_progress = card ? $(card).children('.md-card-toolbar') : $('[data-toolbar-progress]');
|
1498
|
$toolbar_progress.each(function() {
|
1499
|
var $this = $(this),
|
1500
|
bg_percent = percent ? parseInt(percent) : parseInt($this.attr('data-toolbar-progress')),
|
1501
|
progress_steps = $this.attr('data-toolbar-progress-steps');
|
1502
|
|
1503
|
if(steps || progress_steps) {
|
1504
|
if(bg_percent > 66) {
|
1505
|
var bg_color = '#dcedc8';
|
1506
|
} else if(bg_percent > 33) {
|
1507
|
var bg_color = '#ffecb3';
|
1508
|
} else {
|
1509
|
var bg_color = '#ffcdd2';
|
1510
|
}
|
1511
|
} else {
|
1512
|
var bg_color_default = $this.attr('data-toolbar-bg-default');
|
1513
|
if(!bg_color_default) {
|
1514
|
var bg_color = $this.css('backgroundColor');
|
1515
|
$this.attr('data-toolbar-bg-default',bg_color)
|
1516
|
} else {
|
1517
|
var bg_color = bg_color_default;
|
1518
|
}
|
1519
|
}
|
1520
|
|
1521
|
if(percent) {
|
1522
|
$this.attr('data-toolbar-progress',percent);
|
1523
|
}
|
1524
|
|
1525
|
var bg_theme = '#fff';
|
1526
|
|
1527
|
$this
|
1528
|
.css({ 'background': '-moz-linear-gradient(left, '+bg_color+' '+bg_percent+'%, '+ bg_theme+' '+(bg_percent)+'%)'})
|
1529
|
.css({ 'background': 'linear-gradient(to right, '+bg_color+' '+bg_percent+'%, '+bg_theme+' '+(bg_percent)+'%)'})
|
1530
|
.css({ 'background': '-webkit-linear-gradient(left, '+bg_color+' '+bg_percent+'%, '+bg_theme+' '+(bg_percent)+'%)'});
|
1531
|
|
1532
|
})
|
1533
|
},
|
1534
|
list_outside: function() {
|
1535
|
var $md_list_outside_wrapper = $('.md-list-outside-wrapper'),
|
1536
|
$md_list_outside_inner = $md_list_outside_wrapper.children('.md-list-outside-inner');
|
1537
|
|
1538
|
if($md_list_outside_wrapper && $body.hasClass('header_double_height')) {
|
1539
|
function md_list_outside_height() {
|
1540
|
// check header height
|
1541
|
var content_height = $window.height() - ((header__main_height * 2) + 10);
|
1542
|
$md_list_outside_wrapper.height(content_height);
|
1543
|
if($md_list_outside_inner.length){
|
1544
|
$md_list_outside_inner.height(content_height)
|
1545
|
}
|
1546
|
}
|
1547
|
md_list_outside_height();
|
1548
|
$window.on('debouncedresize',function() {
|
1549
|
md_list_outside_height();
|
1550
|
});
|
1551
|
if($md_list_outside_inner.length){
|
1552
|
altair_helpers.custom_scrollbar($md_list_outside_inner);
|
1553
|
} else {
|
1554
|
altair_helpers.custom_scrollbar($md_list_outside_wrapper);
|
1555
|
}
|
1556
|
}
|
1557
|
},
|
1558
|
inputs: function(parent) {
|
1559
|
var $mdInput = (typeof parent === 'undefined') ? $('.md-input') : $(parent).find('.md-input');
|
1560
|
$mdInput.each(function() {
|
1561
|
if(!$(this).closest('.md-input-wrapper').length) {
|
1562
|
var $this = $(this),
|
1563
|
extraClass = '';
|
1564
|
|
1565
|
if($this.is('[class*="uk-form-width-"]')) {
|
1566
|
var elClasses = $this.attr('class').split (' ');
|
1567
|
for(var i = 0; i < elClasses.length; i++){
|
1568
|
var classPart = elClasses[i].substr(0,14);
|
1569
|
if(classPart == "uk-form-width-"){
|
1570
|
var extraClass = elClasses[i];
|
1571
|
}
|
1572
|
}
|
1573
|
}
|
1574
|
|
1575
|
if( $this.prev('label').length ) {
|
1576
|
$this.prev('label').andSelf().wrapAll('<div class="md-input-wrapper"/>');
|
1577
|
} else if($this.siblings('[data-uk-form-password]').length) {
|
1578
|
$this.siblings('[data-uk-form-password]').andSelf().wrapAll('<div class="md-input-wrapper"/>');
|
1579
|
} else {
|
1580
|
$this.wrap('<div class="md-input-wrapper"/>');
|
1581
|
}
|
1582
|
$this.closest('.md-input-wrapper').append('<span class="md-input-bar '+extraClass+'"/>');
|
1583
|
|
1584
|
altair_md.update_input($this);
|
1585
|
}
|
1586
|
$body
|
1587
|
.on('focus', '.md-input', function() {
|
1588
|
$(this).closest('.md-input-wrapper').addClass('md-input-focus')
|
1589
|
})
|
1590
|
.on('blur', '.md-input', function() {
|
1591
|
$(this).closest('.md-input-wrapper').removeClass('md-input-focus');
|
1592
|
if(!$(this).hasClass('label-fixed')) {
|
1593
|
if($(this).val() != '') {
|
1594
|
$(this).closest('.md-input-wrapper').addClass('md-input-filled')
|
1595
|
} else {
|
1596
|
$(this).closest('.md-input-wrapper').removeClass('md-input-filled')
|
1597
|
}
|
1598
|
}
|
1599
|
})
|
1600
|
.on('change input', '.md-input', function(e) {
|
1601
|
altair_md.update_input($(this));
|
1602
|
});
|
1603
|
|
1604
|
// wait for browser autofill
|
1605
|
setTimeout(function () {
|
1606
|
altair_md.update_input('.md-input');
|
1607
|
}, 500);
|
1608
|
|
1609
|
})
|
1610
|
},
|
1611
|
checkbox_radio: function(checkbox) {
|
1612
|
var mdCheckbox = (typeof checkbox === 'undefined') ? $("[data-md-icheck],.data-md-icheck") : $(checkbox);
|
1613
|
mdCheckbox.each(function() {
|
1614
|
if( !$(this).next('.iCheck-helper').length ) {
|
1615
|
$(this)
|
1616
|
.iCheck({
|
1617
|
checkboxClass: 'icheckbox_md',
|
1618
|
radioClass: 'iradio_md',
|
1619
|
increaseArea: '20%'
|
1620
|
})
|
1621
|
// validate inputs on change (parsley)
|
1622
|
.on('ifChanged', function(event){
|
1623
|
if ( !!$(this).data('parsley-multiple') ) {
|
1624
|
$(this).parsley().validate();
|
1625
|
}
|
1626
|
});
|
1627
|
}
|
1628
|
});
|
1629
|
},
|
1630
|
update_input: function(object) {
|
1631
|
$(object).each(function () {
|
1632
|
var el = $(this);
|
1633
|
// clear wrapper classes
|
1634
|
el.closest('.uk-input-group').removeClass('uk-input-group-danger uk-input-group-success');
|
1635
|
el.closest('.md-input-wrapper').removeClass('md-input-wrapper-danger md-input-wrapper-success md-input-wrapper-disabled');
|
1636
|
|
1637
|
if(el.hasClass('md-input-danger')) {
|
1638
|
if(el.closest('.uk-input-group').length) {
|
1639
|
el.closest('.uk-input-group').addClass('uk-input-group-danger')
|
1640
|
}
|
1641
|
el.closest('.md-input-wrapper').addClass('md-input-wrapper-danger')
|
1642
|
}
|
1643
|
if(el.hasClass('md-input-success')) {
|
1644
|
if(el.closest('.uk-input-group').length) {
|
1645
|
el.closest('.uk-input-group').addClass('uk-input-group-success')
|
1646
|
}
|
1647
|
el.closest('.md-input-wrapper').addClass('md-input-wrapper-success')
|
1648
|
}
|
1649
|
if(el.prop('disabled')) {
|
1650
|
el.closest('.md-input-wrapper').addClass('md-input-wrapper-disabled')
|
1651
|
}
|
1652
|
if(el.val() !== '') {
|
1653
|
el.closest('.md-input-wrapper').addClass('md-input-filled')
|
1654
|
} else {
|
1655
|
el.closest('.md-input-wrapper').removeClass('md-input-filled')
|
1656
|
}
|
1657
|
if(el.hasClass('label-fixed')) {
|
1658
|
el.closest('.md-input-wrapper').addClass('md-input-filled')
|
1659
|
}
|
1660
|
})
|
1661
|
},
|
1662
|
fab_speed_dial: function() {
|
1663
|
function activateFAB(obj) {
|
1664
|
obj.closest('.md-fab-wrapper').addClass('md-fab-active');
|
1665
|
obj.velocity({
|
1666
|
scale: 0
|
1667
|
}, {
|
1668
|
duration: 140,
|
1669
|
easing: easing_swiftOut,
|
1670
|
complete: function() {
|
1671
|
obj
|
1672
|
.velocity({ scale: 1 },{
|
1673
|
duration: 140,
|
1674
|
easing: easing_swiftOut
|
1675
|
})
|
1676
|
.children().toggle()
|
1677
|
}
|
1678
|
})
|
1679
|
}
|
1680
|
function deactivateFAB(obj) {
|
1681
|
obj.closest('.md-fab-wrapper').removeClass('md-fab-active');
|
1682
|
obj.velocity({
|
1683
|
scale: 0
|
1684
|
}, {
|
1685
|
duration: 140,
|
1686
|
easing: easing_swiftOut,
|
1687
|
complete: function() {
|
1688
|
obj
|
1689
|
.velocity({ scale: 1 },{
|
1690
|
duration: 140,
|
1691
|
easing: easing_swiftOut
|
1692
|
})
|
1693
|
.children().toggle()
|
1694
|
}
|
1695
|
})
|
1696
|
}
|
1697
|
var $fab = $('.md-fab-speed-dial,.md-fab-speed-dial-horizontal');
|
1698
|
$fab.each(function () {
|
1699
|
var $this = $(this),
|
1700
|
$thisBtn = $this.children('.md-fab').append('<i class="material-icons md-fab-action-close" style="display:none"></i>');
|
1701
|
|
1702
|
if($this.is('[data-fab-hover]')) {
|
1703
|
var deactiveateFabTimeout;
|
1704
|
$this
|
1705
|
.on('mouseenter',function() {
|
1706
|
$this.addClass('md-fab-over');
|
1707
|
clearTimeout(deactiveateFabTimeout);
|
1708
|
setTimeout(function() {
|
1709
|
activateFAB($thisBtn);
|
1710
|
},100);
|
1711
|
})
|
1712
|
.on('mouseleave',function() {
|
1713
|
deactivateFAB($thisBtn);
|
1714
|
deactiveateFabTimeout = setTimeout(function() {
|
1715
|
$this.removeClass('md-fab-over');
|
1716
|
},500);
|
1717
|
})
|
1718
|
} else {
|
1719
|
$thisBtn
|
1720
|
.on('click',function() {
|
1721
|
var $this = $(this);
|
1722
|
if(!$this.closest('.md-fab-wrapper').hasClass('md-fab-active')) {
|
1723
|
activateFAB($this);
|
1724
|
} else {
|
1725
|
deactivateFAB($this);
|
1726
|
}
|
1727
|
})
|
1728
|
.closest('.md-fab-wrapper').find('.md-fab-small')
|
1729
|
.on('click',function() {
|
1730
|
deactivateFAB($thisBtn);
|
1731
|
});
|
1732
|
}
|
1733
|
})
|
1734
|
},
|
1735
|
fab_toolbar: function() {
|
1736
|
var $fab_toolbar = $('.md-fab-toolbar');
|
1737
|
|
1738
|
if($fab_toolbar) {
|
1739
|
$fab_toolbar
|
1740
|
.children('i')
|
1741
|
.on('click', function(e) {
|
1742
|
e.preventDefault();
|
1743
|
|
1744
|
var toolbarItems = $fab_toolbar.children('.md-fab-toolbar-actions').children().length;
|
1745
|
|
1746
|
$fab_toolbar.addClass('md-fab-animated');
|
1747
|
|
1748
|
var FAB_padding = !$fab_toolbar.hasClass('md-fab-small') ? 16 : 24,
|
1749
|
FAB_size = !$fab_toolbar.hasClass('md-fab-small') ? 64 : 44;
|
1750
|
|
1751
|
setTimeout(function() {
|
1752
|
$fab_toolbar
|
1753
|
.width((toolbarItems*FAB_size + FAB_padding))
|
1754
|
},140);
|
1755
|
|
1756
|
setTimeout(function() {
|
1757
|
$fab_toolbar.addClass('md-fab-active');
|
1758
|
},420);
|
1759
|
|
1760
|
});
|
1761
|
|
1762
|
$document.on('click scroll', function(e) {
|
1763
|
if( $fab_toolbar.hasClass('md-fab-active') ) {
|
1764
|
if (!$(e.target).closest($fab_toolbar).length) {
|
1765
|
|
1766
|
$fab_toolbar
|
1767
|
.css('width','')
|
1768
|
.removeClass('md-fab-active');
|
1769
|
|
1770
|
setTimeout(function() {
|
1771
|
$fab_toolbar.removeClass('md-fab-animated');
|
1772
|
},140);
|
1773
|
|
1774
|
}
|
1775
|
}
|
1776
|
});
|
1777
|
}
|
1778
|
},
|
1779
|
fab_sheet: function() {
|
1780
|
var $fab_sheet = $('.md-fab-sheet');
|
1781
|
|
1782
|
if($fab_sheet) {
|
1783
|
$fab_sheet
|
1784
|
.children('i')
|
1785
|
.on('click', function(e) {
|
1786
|
e.preventDefault();
|
1787
|
|
1788
|
var sheetItems = $fab_sheet.children('.md-fab-sheet-actions').children('a').length;
|
1789
|
|
1790
|
$fab_sheet.addClass('md-fab-animated');
|
1791
|
|
1792
|
setTimeout(function() {
|
1793
|
$fab_sheet
|
1794
|
.width('240px')
|
1795
|
.height(sheetItems*40 + 8);
|
1796
|
},140);
|
1797
|
|
1798
|
setTimeout(function() {
|
1799
|
$fab_sheet.addClass('md-fab-active');
|
1800
|
},280);
|
1801
|
|
1802
|
});
|
1803
|
|
1804
|
$document.on('click scroll', function(e) {
|
1805
|
if( $fab_sheet.hasClass('md-fab-active') ) {
|
1806
|
if (!$(e.target).closest($fab_sheet).length) {
|
1807
|
|
1808
|
$fab_sheet
|
1809
|
.css({
|
1810
|
'height':'',
|
1811
|
'width':''
|
1812
|
})
|
1813
|
.removeClass('md-fab-active');
|
1814
|
|
1815
|
setTimeout(function() {
|
1816
|
$fab_sheet.removeClass('md-fab-animated');
|
1817
|
},140);
|
1818
|
|
1819
|
}
|
1820
|
}
|
1821
|
});
|
1822
|
}
|
1823
|
},
|
1824
|
wave_effect: function() {
|
1825
|
if(!$html.hasClass('lte-ie9')) {
|
1826
|
Waves.attach('.md-btn-wave,.md-fab-wave', ['waves-button']);
|
1827
|
Waves.attach('.md-btn-wave-light,.md-fab-wave-light', ['waves-button', 'waves-light']);
|
1828
|
Waves.attach('.wave-box', ['waves-float']);
|
1829
|
Waves.init({
|
1830
|
delay: 300
|
1831
|
});
|
1832
|
}
|
1833
|
}
|
1834
|
};
|
1835
|
|
1836
|
// common helpers
|
1837
|
altair_helpers = {
|
1838
|
truncate_text: function($object) {
|
1839
|
if($object.length) {
|
1840
|
$object.each(function() {
|
1841
|
$(this).dotdotdot({
|
1842
|
watch: "window"
|
1843
|
});
|
1844
|
})
|
1845
|
}
|
1846
|
},
|
1847
|
custom_scrollbar: function($object) {
|
1848
|
|
1849
|
if(!$object.children('.scrollbar-inner').length) {
|
1850
|
$object.wrapInner("<div class='scrollbar-inner'></div>");
|
1851
|
}
|
1852
|
if(Modernizr.touch) {
|
1853
|
$object.children('.scrollbar-inner').addClass('touchscroll');
|
1854
|
} else {
|
1855
|
$object.children('.scrollbar-inner').scrollbar({
|
1856
|
//disableBodyScroll: true,
|
1857
|
scrollx: false,
|
1858
|
duration: 100,
|
1859
|
ignoreMobile: true,
|
1860
|
ignoreOverlay: true
|
1861
|
});
|
1862
|
}
|
1863
|
},
|
1864
|
hierarchical_show: function(element) {
|
1865
|
var $hierarchical_show = $('.hierarchical_show');
|
1866
|
|
1867
|
if($hierarchical_show.length) {
|
1868
|
|
1869
|
$hierarchical_show.each(function() {
|
1870
|
|
1871
|
var timeout = $(this).attr('data-show-delay') ? parseInt($(this).attr('data-show-delay')) : 0,
|
1872
|
$this = $(this),
|
1873
|
thisChildrenLength = $this.children().length,
|
1874
|
baseDelay = 100;
|
1875
|
|
1876
|
$this.children().each(function(index) {
|
1877
|
$(this).css({
|
1878
|
'-webkit-animation-delay': (index * baseDelay) + "ms",
|
1879
|
'animation-delay': (index * baseDelay) + "ms"
|
1880
|
});
|
1881
|
});
|
1882
|
|
1883
|
setTimeout(function () {
|
1884
|
$this.waypoint({
|
1885
|
handler: function() {
|
1886
|
$this.addClass('hierarchical_show_inView');
|
1887
|
setTimeout(function() {
|
1888
|
$this
|
1889
|
.removeClass('hierarchical_show hierarchical_show_inView fast_animation')
|
1890
|
.children()
|
1891
|
.css({
|
1892
|
'-webkit-animation-delay': '',
|
1893
|
'animation-delay': ''
|
1894
|
});
|
1895
|
}, (thisChildrenLength*baseDelay)+1200 );
|
1896
|
this.destroy();
|
1897
|
},
|
1898
|
context: 'window',
|
1899
|
offset: '90%'
|
1900
|
});
|
1901
|
}, timeout);
|
1902
|
|
1903
|
})
|
1904
|
}
|
1905
|
if(element) {
|
1906
|
var $this = $(element).addClass('hierarchical_show hierarchical_show_inView'),
|
1907
|
thisChildrenLength = $this.children().length,
|
1908
|
baseDelay = 100;
|
1909
|
|
1910
|
$this.children().each(function(index) {
|
1911
|
$(this).css({
|
1912
|
'-webkit-animation-delay': (index * baseDelay) + "ms",
|
1913
|
'animation-delay': (index * baseDelay) + "ms"
|
1914
|
});
|
1915
|
});
|
1916
|
|
1917
|
$this.addClass('');
|
1918
|
setTimeout(function() {
|
1919
|
$this
|
1920
|
.removeClass('hierarchical_show hierarchical_show_inView fast_animation')
|
1921
|
.children()
|
1922
|
.css({
|
1923
|
'-webkit-animation-delay': '',
|
1924
|
'animation-delay': ''
|
1925
|
});
|
1926
|
}, (thisChildrenLength*baseDelay)+1200 );
|
1927
|
|
1928
|
}
|
1929
|
},
|
1930
|
hierarchical_slide: function(element) {
|
1931
|
|
1932
|
var $hierarchical_slide = $('.hierarchical_slide');
|
1933
|
if($hierarchical_slide.length) {
|
1934
|
|
1935
|
$hierarchical_slide.each(function() {
|
1936
|
var $this = $(this),
|
1937
|
$thisChildren = $this.attr('data-slide-children') ? $this.children($this.attr('data-slide-children')) : $this.children(),
|
1938
|
thisChildrenLength = $thisChildren.length,
|
1939
|
thisContext = $this.attr('data-slide-context') ? $this.closest($this.attr('data-slide-context'))[0] : 'window',
|
1940
|
baseDelay = 100;
|
1941
|
|
1942
|
if(thisChildrenLength >= 1) {
|
1943
|
|
1944
|
$thisChildren.each(function(index) {
|
1945
|
$(this).css({
|
1946
|
'-webkit-animation-delay': (index * baseDelay) + "ms",
|
1947
|
'animation-delay': (index * baseDelay) + "ms"
|
1948
|
})
|
1949
|
});
|
1950
|
|
1951
|
$this.waypoint({
|
1952
|
handler: function() {
|
1953
|
$this.addClass('hierarchical_slide_inView');
|
1954
|
setTimeout(function() {
|
1955
|
$this.removeClass('hierarchical_slide hierarchical_slide_inView');
|
1956
|
$thisChildren.css({
|
1957
|
'-webkit-animation-delay': '',
|
1958
|
'animation-delay': ''
|
1959
|
});
|
1960
|
}, (thisChildrenLength*baseDelay)+1200 );
|
1961
|
this.destroy();
|
1962
|
},
|
1963
|
context: thisContext,
|
1964
|
offset: '90%'
|
1965
|
});
|
1966
|
|
1967
|
}
|
1968
|
})
|
1969
|
|
1970
|
}
|
1971
|
|
1972
|
if(element) {
|
1973
|
|
1974
|
var $this = $(element).addClass('hierarchical_slide hierarchical_slide_inView'),
|
1975
|
$thisChildren = $this.attr('data-slide-children') ? $this.children($this.attr('data-slide-children')) : $this.children(),
|
1976
|
thisChildrenLength = $thisChildren.length,
|
1977
|
thisContext = $this.attr('data-slide-context') ? $this.closest($this.attr('data-slide-context'))[0] : 'window',
|
1978
|
baseDelay = 100;
|
1979
|
|
1980
|
console.log($thisChildren);
|
1981
|
|
1982
|
if(thisChildrenLength >= 1) {
|
1983
|
|
1984
|
$thisChildren.each(function(index) {
|
1985
|
$(this).css({
|
1986
|
'-webkit-animation-delay': (index * baseDelay) + "ms",
|
1987
|
'animation-delay': (index * baseDelay) + "ms"
|
1988
|
})
|
1989
|
});
|
1990
|
|
1991
|
setTimeout(function() {
|
1992
|
$this.removeClass('hierarchical_slide hierarchical_slide_inView');
|
1993
|
$thisChildren.css({
|
1994
|
'-webkit-animation-delay': '',
|
1995
|
'animation-delay': ''
|
1996
|
});
|
1997
|
}, (thisChildrenLength*baseDelay)+1200 );
|
1998
|
|
1999
|
}
|
2000
|
|
2001
|
}
|
2002
|
},
|
2003
|
content_preloader_show: function(style,variant,container,width,height) {
|
2004
|
|
2005
|
if(!$body.find('.content-preloader').length) {
|
2006
|
var image_density = isHighDensity() ? '@2x' : '',
|
2007
|
width = width ? width : 48,
|
2008
|
height = height ? height : 48;
|
2009
|
|
2010
|
var preloader_content = (style == 'regular')
|
2011
|
? '<img src="assets/img/spinners/spinner' + image_density + '.gif" alt="" width="32" height="32">'
|
2012
|
: '<div class="md-preloader"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="'+height+'" width="'+width+'" viewbox="0 0 75 75"><circle cx="37.5" cy="37.5" r="33.5" stroke-width="8"/></svg></div>';
|
2013
|
|
2014
|
var thisContainer = (typeof container !== 'undefined') ? $(container) : $body;
|
2015
|
var _variant = variant ? 'content-preloader-' + variant : '';
|
2016
|
|
2017
|
thisContainer.append('<div class="content-preloader '+_variant+'" style="height:'+height+'px;width:'+width+'px;margin-left:-'+width/2+'px">' + preloader_content + '</div>');
|
2018
|
setTimeout(function() {
|
2019
|
$('.content-preloader').addClass('preloader-active');
|
2020
|
}, 0);
|
2021
|
}
|
2022
|
},
|
2023
|
content_preloader_hide: function() {
|
2024
|
if($body.find('.content-preloader').length) {
|
2025
|
// hide preloader
|
2026
|
$('.content-preloader').removeClass('preloader-active');
|
2027
|
// remove preloader
|
2028
|
preloader_timeout = window.setTimeout(function() {
|
2029
|
$('.content-preloader').remove();
|
2030
|
}, 500);
|
2031
|
}
|
2032
|
},
|
2033
|
color_picker: function(object,pallete,callback) {
|
2034
|
if(object) {
|
2035
|
var cp_id = randID_generator(),
|
2036
|
cp_pallete = pallete ? pallete : ['#e53935','#d81b60','#8e24aa','#5e35b1','#3949ab','#1e88e5','#039be5','#0097a7','#00897b','#43a047','#689f38','#ef6c00','#f4511e','#6d4c41','#757575','#546e7a'],
|
2037
|
cp_pallete_length = cp_pallete.length,
|
2038
|
cp_wrapper = $('<div class="cp_altair" id="'+cp_id+'"/>');
|
2039
|
|
2040
|
for(var $i=0;$i<cp_pallete_length;$i++) {
|
2041
|
var span = (cp_pallete[$i].substring(0, 6) == "md-bg-" ) ?
|
2042
|
'<span data-color=' + cp_pallete[$i] + ' class="' + cp_pallete[$i] + '"></span>'
|
2043
|
:
|
2044
|
'<span data-color=' + cp_pallete[$i] + ' style="background:' + cp_pallete[$i] + '"></span>';
|
2045
|
cp_wrapper.append(span);
|
2046
|
}
|
2047
|
|
2048
|
cp_wrapper.append('<input type="hidden">');
|
2049
|
|
2050
|
$body.on('click', '#'+cp_id+' span',function() {
|
2051
|
$(this)
|
2052
|
.addClass('active_color')
|
2053
|
.siblings().removeClass('active_color')
|
2054
|
.end()
|
2055
|
.closest('.cp_altair').find('input').val($(this).attr('data-color'));
|
2056
|
if(typeof callback == 'function') {
|
2057
|
callback.call(this);
|
2058
|
}
|
2059
|
});
|
2060
|
|
2061
|
return object.append(cp_wrapper);
|
2062
|
|
2063
|
}
|
2064
|
},
|
2065
|
retina_images: function() {
|
2066
|
if (typeof $.fn.dense !== "undefined") {
|
2067
|
$('img')
|
2068
|
// set resolution cap at "2"
|
2069
|
.attr('data-dense-cap',2)
|
2070
|
.dense({
|
2071
|
glue: "@",
|
2072
|
ping: false
|
2073
|
});
|
2074
|
}
|
2075
|
},
|
2076
|
full_screen: function() {
|
2077
|
var $el = $('#full_screen_toggle');
|
2078
|
if($el.length) {
|
2079
|
$el.on('click',function(e) {
|
2080
|
e.preventDefault();
|
2081
|
if(screenfull.enabled) {
|
2082
|
screenfull.request();
|
2083
|
$el.children('.material-icons').text("fullscreen_exit");
|
2084
|
if(screenfull.isFullscreen) {
|
2085
|
screenfull.exit();
|
2086
|
$el.children('.material-icons').text("fullscreen");
|
2087
|
}
|
2088
|
}
|
2089
|
$window.resize();
|
2090
|
});
|
2091
|
}
|
2092
|
},
|
2093
|
table_check: function() {
|
2094
|
$table_check = $('.table_check');
|
2095
|
$table_check.each(function() {
|
2096
|
var $this = $(this),
|
2097
|
$checkAll = $this.find('.check_all'),
|
2098
|
$checkRow = $this.find('.check_row');
|
2099
|
|
2100
|
$checkAll
|
2101
|
.on('ifChecked',function() {
|
2102
|
$checkRow.iCheck('check');
|
2103
|
})
|
2104
|
.on('ifUnchecked',function() {
|
2105
|
$checkRow.iCheck('uncheck');
|
2106
|
});
|
2107
|
|
2108
|
$checkRow
|
2109
|
.on('ifChecked',function(event) {
|
2110
|
$(event.currentTarget).closest('tr').addClass('row_checked');
|
2111
|
})
|
2112
|
.on('ifUnchecked',function(event) {
|
2113
|
$(event.currentTarget).closest('tr').removeClass('row_checked');
|
2114
|
})
|
2115
|
|
2116
|
|
2117
|
});
|
2118
|
},
|
2119
|
table_tree: function() {
|
2120
|
$table_tree = $('.table_tree');
|
2121
|
$table_tree.each(function() {
|
2122
|
var $this = $(this),
|
2123
|
$checkChildrens = $this.find('.check_childrens'),
|
2124
|
$checkRow = $this.find('.check_row'),
|
2125
|
$toggleChildrens = $this.find('.js-toggle-children-row');
|
2126
|
|
2127
|
$this.find('.show_child_row').nextUntil('.table-parent-row').hide();
|
2128
|
|
2129
|
//$(this).parent('tr').nextAll('.table-child-row').show();
|
2130
|
|
2131
|
$checkChildrens
|
2132
|
.on('ifChecked',function() {
|
2133
|
$(this).closest('tr').addClass('row_checked').nextUntil('.table-parent-row').find('.check_row').iCheck('check');
|
2134
|
})
|
2135
|
.on('ifUnchecked',function() {
|
2136
|
$(this).closest('tr').removeClass('row_checked').nextUntil('.table-parent-row').find('.check_row').iCheck('uncheck');
|
2137
|
});
|
2138
|
|
2139
|
$checkRow
|
2140
|
.on('ifChecked',function(event) {
|
2141
|
$(event.currentTarget).closest('tr').addClass('row_checked');
|
2142
|
})
|
2143
|
.on('ifUnchecked',function(event) {
|
2144
|
$(event.currentTarget).closest('tr').removeClass('row_checked');
|
2145
|
});
|
2146
|
|
2147
|
$toggleChildrens.on('click', function(e) {
|
2148
|
e.preventDefault();
|
2149
|
$(this).closest('tr').toggleClass('show_child_row').nextUntil('.table-parent-row').toggle();
|
2150
|
});
|
2151
|
|
2152
|
});
|
2153
|
},
|
2154
|
ie_fix: function() {
|
2155
|
if(detectIE()) {
|
2156
|
$('svg,canvas,video').each(function() {
|
2157
|
$(this).css('height', 0);
|
2158
|
});
|
2159
|
setTimeout(function() {
|
2160
|
$('svg,canvas,video').each(function() {
|
2161
|
var $this = $(this),
|
2162
|
height = $(this).attr('height'),
|
2163
|
width = $(this).attr('width');
|
2164
|
|
2165
|
if(height) {
|
2166
|
$this.css('height', height);
|
2167
|
}
|
2168
|
if(width) {
|
2169
|
$this.css('width', width);
|
2170
|
}
|
2171
|
var peity = $this.prev('.peity_data');
|
2172
|
if(peity.length) {
|
2173
|
peity.peity().change()
|
2174
|
}
|
2175
|
});
|
2176
|
}, 1000)
|
2177
|
}
|
2178
|
},
|
2179
|
print_page: function() {
|
2180
|
$body.on('click','#page_print',function(e) {
|
2181
|
e.preventDefault();
|
2182
|
UIkit.modal.confirm('Do you want to print this page?', function () {
|
2183
|
// hide sidebar
|
2184
|
altair_main_sidebar.hide_sidebar();
|
2185
|
// wait for dialog to fully hide
|
2186
|
setTimeout(function () {
|
2187
|
window.print();
|
2188
|
}, 300)
|
2189
|
}, {
|
2190
|
labels: {
|
2191
|
'Ok': 'print'
|
2192
|
}
|
2193
|
});
|
2194
|
})
|
2195
|
},
|
2196
|
scroll_to_top: function() {
|
2197
|
var $scrollTop = $('#scrollTop');
|
2198
|
if ($scrollTop) {
|
2199
|
$(window).on('scroll', function () {
|
2200
|
( $(window).scrollTop() > 120 ) ? $scrollTop.fadeIn() : $scrollTop.fadeOut();
|
2201
|
});
|
2202
|
}
|
2203
|
}
|
2204
|
};
|
2205
|
|
2206
|
// uikit custom
|
2207
|
altair_uikit = {
|
2208
|
reinitialize_grid_margin: function() {
|
2209
|
$("[data-uk-grid-margin]").each(function() {
|
2210
|
var element = $(this);
|
2211
|
if (!element.data("gridMargin")) {
|
2212
|
$.UIkit.gridMargin(element, $.UIkit.Utils.options(element.attr("data-uk-grid-margin")));
|
2213
|
}
|
2214
|
});
|
2215
|
$window.resize();
|
2216
|
},
|
2217
|
accordion_user_selected: function() {
|
2218
|
// open user defined accordion section on page load
|
2219
|
$('[data-accordion-section-open]').each(function() {
|
2220
|
var $elem = $(this);
|
2221
|
setTimeout(function() {
|
2222
|
var data = $elem.data();
|
2223
|
sectOpen = data.accordionSectionOpen.toString().split(",");
|
2224
|
|
2225
|
// close all accordion sections
|
2226
|
$elem.children('.uk-accordion-title.uk-active').each(function() {
|
2227
|
$(this).trigger('click');
|
2228
|
});
|
2229
|
if(!data.accordion.options.collapse && (sectOpen.length > 1)) {
|
2230
|
// open multiple sections
|
2231
|
for(var $i = 0;$i <= sectOpen.length;$i++) {
|
2232
|
$elem.children('.uk-accordion-title').eq(sectOpen[$i] - 1).trigger('click')
|
2233
|
}
|
2234
|
} else {
|
2235
|
$elem.children('.uk-accordion-title').eq(sectOpen[0] - 1).trigger('click')
|
2236
|
}
|
2237
|
},220);
|
2238
|
})
|
2239
|
}
|
2240
|
};
|