0
|
1 /*
|
|
2 * Name: Oscar
|
|
3 * Written by: Unifato - (http://unifato.com)
|
|
4 * Version: 1.0.0
|
|
5 */
|
|
6
|
|
7 (function($) {
|
|
8 'use strict';
|
|
9
|
|
10 var initBodyClass = "";
|
|
11 if($("body").hasClass("sidebar-collapse")) {
|
|
12 initBodyClass = "sidebar-collapse";
|
|
13 } else if ($("body").hasClass("sidebar-expand")) {
|
|
14 initBodyClass = "sidebar-expand";
|
|
15 }
|
|
16
|
|
17 var Unifato = {
|
|
18 init: function() {
|
|
19 this.collapseNavbar();
|
|
20 $(window).scroll(this.collapseNavbar);
|
|
21 this.contentHeight();
|
|
22
|
|
23 this.header();
|
|
24 this.sidebar();
|
|
25 this.content();
|
|
26 this.enableScrollbar();
|
|
27 this.inputFocus();
|
|
28 this.enableTooltip();
|
|
29 this.enableMailbox();
|
|
30 this.enableRadioCheckbox();
|
|
31 this.enableValidation();
|
|
32 this.enablePace();
|
|
33 this.enablePlugins();
|
|
34 },
|
|
35
|
|
36 enablePace: function() {
|
|
37 Pace.on('done', function() {
|
|
38 $(document).trigger('PACE_DONE');
|
|
39 });
|
|
40 },
|
|
41
|
|
42 enablePlugins: function() {
|
|
43 this.enableSweetAlert();
|
|
44 this.enableTodo();
|
|
45 this.enableTwitterWidget();
|
|
46 this.enableFacebookWidget();
|
|
47 this.enableVectorMaps();
|
|
48 this.enableGoogleMaps();
|
|
49 this.enableFullCalendar();
|
|
50 this.enableClndr();
|
|
51 this.enableDataTables();
|
|
52 this.enableFootable();
|
|
53 this.enableTableEditable();
|
|
54 this.enableCountUp();
|
|
55 this.enableRangeSlider();
|
|
56 this.enableSortable();
|
|
57 this.enableNestedSortable();
|
|
58 this.enableTimelineLoadMoreBtn();
|
|
59 this.enableCarousel();
|
|
60 this.enableMedia();
|
|
61 this.enableInputMask();
|
|
62 this.enableDropify();
|
|
63 this.enableDropzone();
|
|
64 this.enableClockPicker();
|
|
65 this.enableColorPicker();
|
|
66 this.enableDateRangePicker();
|
|
67 this.enablePredefinedDateRangePicker();
|
|
68 this.enableDatePicker();
|
|
69 this.enableSelect2();
|
|
70 this.enableSwitchery();
|
|
71 this.enableTouchspin();
|
|
72 this.enableMultiSelect();
|
|
73 this.enableTinyMCE();
|
|
74 this.enableBootstrapWysiwyg();
|
|
75 this.enableCircleProgress();
|
|
76 this.enableSparkline();
|
|
77 },
|
|
78
|
|
79 collapseNavbar: function() {
|
|
80 if( $(window).scrollTop() > 30 ) {
|
|
81 $("#wrapper").addClass("fix-top");
|
|
82 }
|
|
83 else {
|
|
84 $("#wrapper").removeClass("fix-top");
|
|
85 }
|
|
86 },
|
|
87
|
|
88 header: function() {
|
|
89
|
|
90 },
|
|
91
|
|
92 contentHeight: function() {
|
|
93 var width = window.innerWidth > 0 ? window.innerWidth:screen.width;
|
|
94 var l;
|
|
95
|
|
96 if ( width > 720 && $("body").hasClass("collapse-collapse") ) {
|
|
97 l = $(".site-sidebar").outerHeight() - 1;
|
|
98 $(".main-wrapper").css("min-height", l + "px");
|
|
99 }
|
|
100 if ( width > 720 && $("body").hasClass('sidebar-horizontal') ) {
|
|
101 l = (window.innerHeight > 0 ? window.innerHeight : this.screen.height) - 1 - $(".navbar").outerHeight() - $('.site-sidebar').outerHeight();
|
|
102 $(".main-wrapper").css("min-height", l + "px");
|
|
103 }
|
|
104 else if (width > 720) {
|
|
105 l = (window.innerHeight > 0 ? window.innerHeight : this.screen.height) - 1 - $(".navbar").outerHeight();
|
|
106 $(".main-wrapper").css("min-height", l + "px");
|
|
107 }
|
|
108 },
|
|
109
|
|
110 content: function() {
|
|
111 $(".card-expandable .card-header").on("click",function(e) {
|
|
112 $(this).parents(".card").toggleClass("card-expanded");
|
|
113 });
|
|
114
|
|
115 this.enableMagnificPopup();
|
|
116
|
|
117 var scrollToBottom = document.getElementsByClassName('scroll-to-bottom');
|
|
118 for( var i = 0; i < scrollToBottom.length; i++ ) {
|
|
119 scrollToBottom[i].scrollTop = scrollToBottom[i].scrollHeight;
|
|
120 }
|
|
121
|
|
122 $('.blog-post-share-links .toggle-link').click(function() {
|
|
123 $(this).closest('ul').toggleClass('active');
|
|
124 });
|
|
125 },
|
|
126
|
|
127 initScrollbar: function($el) {
|
|
128 $el.perfectScrollbar($el[0].dataset);
|
|
129 },
|
|
130
|
|
131 sidebar: function() {
|
|
132 var self = this;
|
|
133 if( document.body.classList.contains('sidebar-expand') )
|
|
134 $('.side-menu').metisMenu({ preventDefault: true });
|
|
135 $('.side-menu').on('show.metisMenu',function() {
|
|
136 $('.site-sidebar.scrollbar-enabled').perfectScrollbar('destroy');
|
|
137 self.initScrollbar( $('.site-sidebar.scrollbar-enabled') );
|
|
138 });
|
|
139 this.sidebarToggle();
|
|
140 this.rightSidebarToggle();
|
|
141 this.sidebarUserToggle();
|
|
142 this.chatSidebar();
|
|
143 },
|
|
144
|
|
145 setMenu: function(){
|
|
146 var self = this;
|
|
147 var width = window.innerWidth > 0 ? window.innerWidth:screen.width;
|
|
148 var $body = $("body");
|
|
149 $('.site-sidebar.scrollbar-enabled').perfectScrollbar('destroy').removeClass('ps');
|
|
150
|
|
151 if (width < 961) {
|
|
152 $('.side-menu').metisMenu({ preventDefault: true });
|
|
153 }
|
|
154 else if (width > 960 && width < 1170 && initBodyClass == "sidebar-expand") {
|
|
155 $(".site-sidebar").show();
|
|
156 $body.removeClass("sidebar-expand");
|
|
157 $body.addClass("sidebar-collapse");
|
|
158 }
|
|
159 else if (width >= 1170 && initBodyClass == "sidebar-expand") {
|
|
160 $(".site-sidebar").show();
|
|
161 $body.removeClass("sidebar-collapse");
|
|
162 $body.addClass("sidebar-expand");
|
|
163 Unifato.initScrollbar( $('.site-sidebar.scrollbar-enabled') );
|
|
164 }
|
|
165 else if ($body.hasClass("sidebar-expand")) {
|
|
166 $(".site-sidebar").show();
|
|
167 Unifato.initScrollbar( $('.site-sidebar.scrollbar-enabled') );
|
|
168 }
|
|
169 else if ( document.body.classList.contains('sidebar-horizontal') ) {
|
|
170 $(".site-sidebar").show();
|
|
171 $('.side-menu').metisMenu('dispose');
|
|
172 }
|
|
173 else {
|
|
174 $(".site-sidebar").show();
|
|
175 }
|
|
176 },
|
|
177
|
|
178 sidebarToggle: function() {
|
|
179 var self = this;
|
|
180 $(".sidebar-toggle a").on("click",function(){
|
|
181 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
|
|
182 var $body = $("body");
|
|
183 $('.site-sidebar.scrollbar-enabled').perfectScrollbar('destroy').removeClass('ps');
|
|
184
|
|
185 if (width < 961) {
|
|
186 $(".site-sidebar").toggle();
|
|
187 }
|
|
188 else if ($body.hasClass("sidebar-expand")) {
|
|
189 $body.removeClass("sidebar-expand");
|
|
190 $body.addClass("sidebar-collapse");
|
|
191 $(".side-user > a").removeClass("active");
|
|
192 $(".side-user > a").siblings(".side-menu").hide();
|
|
193 $('.side-menu .sub-menu').css('height', 'auto');
|
|
194 $('.side-menu').metisMenu('dispose');
|
|
195 }
|
|
196 else if ($body.hasClass("sidebar-collapse")) {
|
|
197 $body.removeClass("sidebar-collapse");
|
|
198 $body.addClass("sidebar-expand");
|
|
199 self.initScrollbar( $('.site-sidebar.scrollbar-enabled') );
|
|
200 $('.side-menu').metisMenu({ preventDefault: true });
|
|
201 }
|
|
202
|
|
203 Unifato.contentHeight();
|
|
204 if( width > 961 ) {
|
|
205 $(document).trigger("SIDEBAR_CHANGED_WIDTH");
|
|
206 }
|
|
207 });
|
|
208
|
|
209 },
|
|
210
|
|
211 rightSidebarToggle : function() {
|
|
212 $(".right-sidebar-toggle").on("click",function(e) {
|
|
213 $('.dropdown-toggle[aria-expanded="true"]').dropdown('toggle');
|
|
214 $('body').toggleClass('right-sidebar-expand');
|
|
215 return false;
|
|
216 });
|
|
217
|
|
218 document.addEventListener('click', function(event) {
|
|
219 var $rightSidebar = document.getElementsByClassName('right-sidebar')[0],
|
|
220 $chatPanel = document.getElementsByClassName('chat-panel')[0];
|
|
221 var isInsideContainer = $rightSidebar.contains( event.target ) || $chatPanel.contains(event.target);
|
|
222 if( !isInsideContainer ) {
|
|
223 document.body.classList.remove('right-sidebar-expand');
|
|
224 $chatPanel.hidden = 'hidden';
|
|
225 }
|
|
226 });
|
|
227 },
|
|
228
|
|
229 sidebarUserToggle: function() {
|
|
230 $(".side-user > a").on("click",function(){
|
|
231 if ($('body').hasClass("sidebar-collapse") === false) {
|
|
232 $(this).toggleClass("active");
|
|
233 $(this).siblings(".side-menu").toggle();
|
|
234 }
|
|
235 });
|
|
236 },
|
|
237
|
|
238 chatSidebar: function() {
|
|
239 var el = $('[data-plugin="chat-sidebar"]');
|
|
240 if( !el.length ) return;
|
|
241 var chatList = el.find('.chat-list');
|
|
242 this.chatPanel();
|
|
243 chatList.each(function(index) {
|
|
244 var $this = $(this);
|
|
245 $(this).find('.list-group a').on('click', function() {
|
|
246 $this.find('.list-group a.active').removeClass('active');
|
|
247 $(this).addClass('active');
|
|
248 var el = $('.chat-panel');
|
|
249 if(!el.length) return;
|
|
250 el.removeAttr('hidden');
|
|
251
|
|
252 // For Scroll to Bottom
|
|
253 var messages = el.find('.messages');
|
|
254 messages[0].scrollTop = messages[0].scrollHeight;
|
|
255 if( messages[0].classList.contains('scrollbar-enabled') ) {
|
|
256 messages.perfectScrollbar('update');
|
|
257 }
|
|
258
|
|
259 el.find('.user-name').html( $(this).data('chat-user'));
|
|
260 });
|
|
261 });
|
|
262 },
|
|
263
|
|
264 chatPanel: function() {
|
|
265 var el = $('.chat-panel');
|
|
266 if(!el.length) return;
|
|
267
|
|
268 // Close Button
|
|
269 el.find('.close').on('click', function(){
|
|
270 el.attr('hidden', true);
|
|
271 el.find('.panel-body').removeClass('hide');
|
|
272 });
|
|
273
|
|
274 // Minimize Button
|
|
275 el.find('.minimize').on('click', function(){
|
|
276 el.find('.card-block').attr('hidden', !el.find('.card-block').attr('hidden') );
|
|
277 if( el.find('.card-block').attr('hidden') === 'hidden' )
|
|
278 $(this).find('.material-icons').html('expand_less');
|
|
279 else
|
|
280 $(this).find('.material-icons').html('expand_more');
|
|
281 });
|
|
282
|
|
283 },
|
|
284
|
|
285 enableMagnificPopup: function() {
|
|
286 var el = $('[data-toggle="lightbox"], [data-toggle="lightbox-gallery"]');
|
|
287 if(!el.length) return;
|
|
288 el.each(function() {
|
|
289 var $this = $(this),
|
|
290 src = $this.data('src'),
|
|
291 type = $this.data('type'),
|
|
292 defaults = {},
|
|
293 options = $this.data('plugin-options') !== undefined ? $this.data('plugin-options') : {},
|
|
294 lightboxClass = $this.data('lightbox-class') !== undefined ? $this.data('lightbox-class') : "";
|
|
295
|
|
296 if( $this.data('toggle') === "lightbox" ) {
|
|
297 defaults = {
|
|
298 type: type,
|
|
299 callbacks: {
|
|
300 beforeOpen: function() {
|
|
301 this.st.image.markup = this.st.image.markup.replace('mfp-figure', 'mfp-figure animated ' + this.st.el.attr('data-effect') );
|
|
302 }
|
|
303 }
|
|
304 };
|
|
305 options = $.extend( {}, defaults, options);
|
|
306 $this.magnificPopup(options);
|
|
307 }
|
|
308
|
|
309 else if( $this.data('toggle') === "lightbox-gallery" ) {
|
|
310 defaults = {
|
|
311 type: type,
|
|
312 delegate: 'a',
|
|
313 gallery: {
|
|
314 enabled: true,
|
|
315 },
|
|
316 callback: {
|
|
317 beforeOpen: function() {
|
|
318 this.st.image.markup = this.st.image.markup.replace('mfp-figure', 'mfp-figure animated ' + this.st.el.attr('data-effect') );
|
|
319 }
|
|
320 }
|
|
321 };
|
|
322 options = $.extend( {}, defaults, options);
|
|
323 $this.magnificPopup(options);
|
|
324 }
|
|
325 });
|
|
326 },
|
|
327
|
|
328 enableScrollbar: function() {
|
|
329 var el = $('.scrollbar-enabled, .dropdown-list-group ');
|
|
330 if(!el.length) return;
|
|
331 el.each(function(index){
|
|
332
|
|
333 var $this = $(this);
|
|
334 var options = {
|
|
335 wheelSpeed: 0.5
|
|
336 };
|
|
337 if( this.classList.contains('suppress-x') ) options.suppressScrollX = true;
|
|
338 if( this.classList.contains('suppress-y') ) options.suppressScrollY = true;
|
|
339 $this.perfectScrollbar(options);
|
|
340
|
|
341 if($this.parent().parent().hasClass('dropdown-card')) {
|
|
342 $(document).on('shown.bs.dropdown',$this.parent().parent(), function(){
|
|
343 $this.perfectScrollbar('update');
|
|
344 });
|
|
345 }
|
|
346
|
|
347 $(document).on('show.metisMenu, hide.metisMenu', function() {
|
|
348 $this.perfectScrollbar('update');
|
|
349 });
|
|
350
|
|
351 if ( this.classList.contains('scroll-to-bottom') ) {
|
|
352 this.scrollTop = this.scrollHeight;
|
|
353 $this.perfectScrollbar('update');
|
|
354 }
|
|
355
|
|
356 });
|
|
357 },
|
|
358
|
|
359 inputFocus: function() {
|
|
360 var el = $('input:not([type=checkbox]):not([type=radio]), textarea');
|
|
361 if( !el.length ) return;
|
|
362
|
|
363 el.each(function() {
|
|
364 var $this = $(this),
|
|
365 self = this;
|
|
366
|
|
367 var hasValueFunction = function() {
|
|
368 if( self.value.length > 0 ) {
|
|
369 self.parentNode.classList.add('input-has-value');
|
|
370 $(self).closest('.form-group').addClass('input-has-value');
|
|
371 }
|
|
372 else {
|
|
373 self.parentNode.classList.remove('input-has-value');
|
|
374 $(self).closest('.form-group').removeClass('input-has-value');
|
|
375 }
|
|
376 };
|
|
377
|
|
378 hasValueFunction(this);
|
|
379 $this.on('input', hasValueFunction);
|
|
380
|
|
381 $this.focusin(function() {
|
|
382 this.parentNode.classList.add('input-focused');
|
|
383 $this.closest('.form-group').addClass('input-focused');
|
|
384 });
|
|
385 $this.focusout(function() {
|
|
386 this.parentNode.classList.remove('input-focused');
|
|
387 $this.closest('.form-group').removeClass('input-focused');
|
|
388 });
|
|
389
|
|
390 $this.find('.remove-focus').on('click',function() {
|
|
391 $this.emit('focusout');
|
|
392 });
|
|
393 });
|
|
394 },
|
|
395
|
|
396 enableTooltip: function() {
|
|
397 $('[data-toggle="tooltip"]').tooltip();
|
|
398 },
|
|
399
|
|
400 enableMailbox: function() {
|
|
401 this.enableMailboxInbox();
|
|
402 },
|
|
403
|
|
404 enableMailboxInbox: function() {
|
|
405 var el = $('.mail-inbox');
|
|
406 if( !el.length ) return;
|
|
407 var MailBox = {
|
|
408 init: function() {
|
|
409 this.selectAll();
|
|
410 },
|
|
411 selectAll: function() {
|
|
412 var selectAll = el.find('.mail-inbox-select-all input');
|
|
413 selectAll.on('change', function() {
|
|
414 var allCheckboxes = el.find('.mail-list .mail-select-checkbox input[type="checkbox"]');
|
|
415 for( var i = 0; i < allCheckboxes.length; i++ ) {
|
|
416 allCheckboxes[i].checked = selectAll[0].checked;
|
|
417 }
|
|
418 });
|
|
419 }
|
|
420 };
|
|
421 MailBox.init();
|
|
422 },
|
|
423
|
|
424 enableRadioCheckbox: function() {
|
|
425 var input = document.getElementsByTagName('input');
|
|
426 for( var i = 0; i < input.length; i++ ) {
|
|
427 if( input[i].type === 'checkbox' ) {
|
|
428 if( input[i].checked === true ) {
|
|
429 input[i].parentNode.classList.add('checkbox-checked');
|
|
430 }
|
|
431 input[i].addEventListener('change', function() {
|
|
432 if( this.checked === true ) {
|
|
433 this.parentNode.classList.add('checkbox-checked');
|
|
434 } else {
|
|
435 this.parentNode.classList.remove('checkbox-checked');
|
|
436 }
|
|
437 });
|
|
438 }
|
|
439 }
|
|
440 },
|
|
441
|
|
442 enableValidation: function() {
|
|
443 if( typeof $.validate === 'function' ) {
|
|
444 $.validate({
|
|
445 modules: 'security, date',
|
|
446 errorMessageClass: 'invalid-feedback',
|
|
447 errorElementClass: 'is-invalid',
|
|
448 });
|
|
449 }
|
|
450
|
|
451 this.enableFieldLengthIndicator();
|
|
452 },
|
|
453
|
|
454 enableFieldLengthIndicator: function() {
|
|
455 var el = $('.field-length-indicator');
|
|
456 if( !el.length ) return;
|
|
457 el.each(function() {
|
|
458 var $this = $(this),
|
|
459 target = $this.data('length-target');
|
|
460
|
|
461 $(target).restrictLength( $this.find('.indicator') );
|
|
462 });
|
|
463 },
|
|
464
|
|
465 enableSweetAlert: function() {
|
|
466 if( typeof swal === 'function' ) {
|
|
467 swal.setDefaults({
|
|
468 buttonsStyling: false, // disables plugn styles for buttons
|
|
469 cancelButtonClass: 'btn btn-default',
|
|
470 confirmButtonClass: 'btn btn-info'
|
|
471 });
|
|
472 }
|
|
473
|
|
474 var el = $('.modal-alert');
|
|
475 if( !el.length ) return;
|
|
476 el.each(function() {
|
|
477 var $this = $(this);
|
|
478 var options = {};
|
|
479
|
|
480 if ( $this.data('title') !== undefined ) options.title = $this.data('title');
|
|
481 if ( $this.data('text') !== undefined ) options.text = $this.data('text');
|
|
482
|
|
483 if ( $this.data('type') !== undefined ) {
|
|
484 options.type = $this.data('type');
|
|
485
|
|
486 switch( $this.data('type') ) {
|
|
487 case 'success': options.confirmButtonClass = 'btn btn-success'; break;
|
|
488 case 'warning': options.confirmButtonClass = 'btn btn-warning'; break;
|
|
489 case 'error': options.confirmButtonClass = 'btn btn-danger'; break;
|
|
490 default: options.confirmButtonClass = 'btn btn-info';
|
|
491 }
|
|
492 } else {
|
|
493 options.confirmButtonClass = 'btn btn-info';
|
|
494 }
|
|
495
|
|
496 if ( $this.data('button-text') !== undefined ) options.confirmButtonText = $this.data('button-text');
|
|
497
|
|
498 $this.click(function() {
|
|
499 swal(options);
|
|
500 });
|
|
501 });
|
|
502 },
|
|
503
|
|
504 enableTodo: function() {
|
|
505 var el = document.getElementsByClassName('todo-widget');
|
|
506 if( !el.length ) return;
|
|
507 for( var i = 0; i < el.length; i++ ) {
|
|
508 var todo1 = new Todo( el[i] );
|
|
509 }
|
|
510 },
|
|
511
|
|
512 enableTwitterWidget: function() {
|
|
513 var el = document.getElementsByClassName('twitter-widget');
|
|
514 if ( !el.length ) return;
|
|
515 for( var i = 0; i < el.length; i++) {
|
|
516 var options = JSON.parse( JSON.stringify( el[i].dataset )).pluginOptions;
|
|
517 if ( options === undefined ) options = {};
|
|
518 var twitter = new TwitterWidget( el[i], options );
|
|
519 }
|
|
520 },
|
|
521
|
|
522 enableFacebookWidget: function() {
|
|
523 var el = document.getElementsByClassName('facebook-widget');
|
|
524 if ( !el.length ) return;
|
|
525 for( var i = 0; i < el.length; i++) {
|
|
526 var options = JSON.parse( JSON.stringify( el[i].dataset )).pluginOptions;
|
|
527 if ( options === undefined ) options = {};
|
|
528 var facebook = new FacebookWidget( el[i], options );
|
|
529 }
|
|
530 },
|
|
531
|
|
532 enableVectorMaps: function() {
|
|
533 var el = $('[data-toggle="vector-map"]');
|
|
534 if ( !el.length ) return;
|
|
535 var defaults = {
|
|
536 map: 'world_en',
|
|
537 backgroundColor: null,
|
|
538 borderColor: "#ffffff",
|
|
539 color: '#999999',
|
|
540 hoverOpacity: 0.8,
|
|
541 selectedColor: '#777777',
|
|
542 enableZoom: true,
|
|
543 showTooltip: true,
|
|
544 normalizeFunction: 'polynomial',
|
|
545 onLabelShow: function(event, label, code) {
|
|
546 var mapValues = $(this)[0].mapValues,
|
|
547 $this = $(this),
|
|
548 place = label[0].innerHTML;
|
|
549 if( mapValues !== undefined) {
|
|
550 var value = $(this)[0].mapValues[code];
|
|
551 if(value!==undefined ) {
|
|
552 value = $(this)[0].mapValues[code];
|
|
553 if($this.data('plugin-options').label !== undefined) {
|
|
554 label[0].innerHTML = $this.data('plugin-options').label.replace('%p', place).replace('%v', value);
|
|
555 }
|
|
556 else
|
|
557 label[0].innerHTML = label[0].innerHTML + ": " + value;
|
|
558 }
|
|
559 else if(value===undefined) {
|
|
560 if($this.data('plugin-options').label !== undefined) {
|
|
561 label[0].innerHTML = $this.data('plugin-options').labelNaN.replace('%p', place);
|
|
562 }
|
|
563 else
|
|
564 label[0].innerHTML = 'NaN';
|
|
565 }
|
|
566 }
|
|
567 else if( $this.data('plugin-options').label !== undefined ) {
|
|
568 label[0].innerHTML = $this.data('plugin-options').label.replace('%p',place);
|
|
569 }
|
|
570 },
|
|
571 };
|
|
572 el.each(function(index) {
|
|
573 var $this = $(this),
|
|
574 mapOptions = $this.data('plugin-options'),
|
|
575 instance = null,
|
|
576 options = $.extend({}, defaults, mapOptions);
|
|
577
|
|
578 if ( this.unifato === undefined )
|
|
579 this.unifato = {};
|
|
580 instance = this.unifato;
|
|
581 if(typeof(options.valuesSrcFile) !== 'undefined') {
|
|
582 $.ajax({
|
|
583 url: options.valuesSrcFile,
|
|
584 dataType: "json",
|
|
585 success: function(result) {
|
|
586 options.values = result;
|
|
587 $this[0].mapValues = result;
|
|
588 instance.vmap = $this.vectorMap(options);
|
|
589 },
|
|
590 });
|
|
591 }
|
|
592 else {
|
|
593 instance.vmap = $this.vectorMap(options);
|
|
594 }
|
|
595 });
|
|
596 },
|
|
597
|
|
598 enableGoogleMaps: function() {
|
|
599 var el = $('[data-toggle="google-map"]');
|
|
600 if( !el.length ) return;
|
|
601 var maps = 0;
|
|
602 el.each(function(index) {
|
|
603 var $this = $(this),
|
|
604 instance = null,
|
|
605 options = $(this).data('plugin-options');
|
|
606
|
|
607 maps++;
|
|
608 $this.attr('id', 'gmaps-' + maps );
|
|
609 var defaults = {
|
|
610 el: "#gmaps-" + maps
|
|
611 };
|
|
612
|
|
613 if ( this.unifato === undefined )
|
|
614 this.unifato = {};
|
|
615 instance = this.unifato;
|
|
616
|
|
617 // Map Markers
|
|
618 if( $this.has('.map-marker').length !== 0 )
|
|
619 {
|
|
620 options.markers = [];
|
|
621 var markers = $this.find('.map-marker');
|
|
622 markers.each(function(index){
|
|
623 var markerOptions = $(this).data('plugin-options');
|
|
624 if( $(this).has('.content').length !== 0 ) {
|
|
625 markerOptions.infoWindow = {};
|
|
626 markerOptions.infoWindow.content = $(this).find('.content').html();
|
|
627 }
|
|
628 options.markers.push(markerOptions);
|
|
629 });
|
|
630 }
|
|
631
|
|
632 // Map Overlays
|
|
633 if( $this.has('.map-overlays').length !== 0 )
|
|
634 {
|
|
635 options.overlays = [];
|
|
636 var overlays = $this.find('.map-overlays');
|
|
637 overlays.each(function(index){
|
|
638 var overlayOptions = $(this).data('plugin-options');
|
|
639 overlayOptions.content = $(this).html();
|
|
640 overlayOptions.content = overlayOptions.content.trim();
|
|
641 options.overlays.push(overlayOptions);
|
|
642 });
|
|
643 }
|
|
644
|
|
645 // Map Path
|
|
646 if( $this.has('.map-path').length !== 0 )
|
|
647 {
|
|
648 options.path = [];
|
|
649 var paths = $this.find('.map-path');
|
|
650 paths.each(function(index){
|
|
651 var pathOptions = $(this).data('plugin-options');
|
|
652 options.path.push(pathOptions);
|
|
653 });
|
|
654 }
|
|
655
|
|
656 // Map Route
|
|
657 if( $this.has('.map-route').length !== 0 )
|
|
658 {
|
|
659 options.routes = [];
|
|
660 var routes = $this.find('.map-route');
|
|
661 routes.each(function(index){
|
|
662 var routeOptions = $(this).data('plugin-options');
|
|
663 options.routes.push(routeOptions);
|
|
664 });
|
|
665 }
|
|
666
|
|
667 // Map Polygon
|
|
668 if( $this.has('.map-polygon').length !== 0 )
|
|
669 {
|
|
670 options.polygon = [];
|
|
671 var polygons = $this.find('.map-polygon');
|
|
672 polygons.each(function(index){
|
|
673 var polygonOptions = $(this).data('plugin-options');
|
|
674 options.polygon.push(polygonOptions);
|
|
675 });
|
|
676 }
|
|
677
|
|
678 // Map Style
|
|
679 if( $this.has('.map-style').length !== 0 )
|
|
680 {
|
|
681 var styles = JSON.parse( $this.find('.map-style').html() );
|
|
682 options.styles = styles;
|
|
683 //map.addStyle({
|
|
684 //styledMapName:"Styled Map",
|
|
685 //styles: styles,
|
|
686 //mapTypeId: "map_style"
|
|
687 //});
|
|
688 //map.setStyle("map_style");
|
|
689 }
|
|
690
|
|
691 // Initialize Maps
|
|
692 options = $.extend({}, defaults, options);
|
|
693 var map = new GMaps(options);
|
|
694 instance.gmap = map;
|
|
695 var i = 0;
|
|
696
|
|
697 if( options.styles !== undefined ) {
|
|
698 map.addStyle({
|
|
699 styledMapName:"Styled Map",
|
|
700 styles: options.styles,
|
|
701 mapTypeId: "map_style"
|
|
702 });
|
|
703 map.setStyle("map_style");
|
|
704 }
|
|
705
|
|
706 // Adding Markers to Map
|
|
707 if(options.markers !== undefined)
|
|
708 {
|
|
709 for(i=0; i<options.markers.length; i++ )
|
|
710 map.addMarker(options.markers[i]);
|
|
711 }
|
|
712
|
|
713 // Adding Overlays to Map
|
|
714 if(options.overlays !== undefined)
|
|
715 {
|
|
716 for(i=0; i < options.overlays.length; i++ )
|
|
717 map.drawOverlay(options.overlays[i]);
|
|
718 }
|
|
719
|
|
720 // Adding Path to Map
|
|
721 if(options.path !== undefined)
|
|
722 {
|
|
723 for(i=0; i < options.path.length; i++ )
|
|
724 map.drawPolyline(options.path[i]);
|
|
725 }
|
|
726
|
|
727 // Adding Routes to Map
|
|
728 if(options.routes !== undefined)
|
|
729 {
|
|
730 for(i=0; i < options.routes.length; i++ )
|
|
731 map.drawRoute(options.routes[i]);
|
|
732 }
|
|
733
|
|
734 // Adding Path to Map
|
|
735 if(options.polygon !== undefined)
|
|
736 {
|
|
737 for(i=0; i < options.polygon.length; i++ )
|
|
738 map.drawPolygon(options.polygon[i]);
|
|
739 }
|
|
740 });
|
|
741 },
|
|
742
|
|
743 enableFullCalendar: function() {
|
|
744 var el = $('[data-toggle="fullcalendar"]');
|
|
745 if( !el.length ) return;
|
|
746 this.enableFullCalendarEvents();
|
|
747 window.ThemeFullCalendar = {};
|
|
748 var showContentInModal = function(calEvent, instance) {
|
|
749 window.ThemeFullCalendar.EventEditMode = calEvent;
|
|
750 var eventModal = $('#eventEditModal');
|
|
751 eventModal.find('input[name="event-name"]').val(calEvent.title);
|
|
752 var classNames = calEvent.className;
|
|
753 for(var i=0; i<classNames.length; i++) {
|
|
754 if(classNames[i].startsWith('bg-')) {
|
|
755 var bg = classNames[i].substr(3);
|
|
756 eventModal.find('select[name="event-bg"]').val(bg);
|
|
757 var s = eventModal.find('select[name="event-bg"]').val();
|
|
758 break;
|
|
759 }
|
|
760 }
|
|
761 };
|
|
762 var defaults = {
|
|
763 header: {
|
|
764 left: "prev,next,today",
|
|
765 center: "title",
|
|
766 right: "month,agendaWeek,agendaDay"
|
|
767 },
|
|
768 editable: true,
|
|
769 droppable: true,
|
|
770 eventLimit: true,
|
|
771 navLinks: true,
|
|
772 drop: function() {
|
|
773 if ($('#drop-remove').is(':checked')) {
|
|
774 $(this).remove();
|
|
775 }
|
|
776 },
|
|
777 eventClick: function(calEvent,jsEvent, view) {
|
|
778 $("#eventEditModal").modal('show');
|
|
779 showContentInModal(calEvent);
|
|
780 },
|
|
781 dayClick: function(date,jsEvent, view) {
|
|
782 $("#eventAddModal").modal('show');
|
|
783 window.ThemeFullCalendar.EventAddMode = date;
|
|
784 }
|
|
785 };
|
|
786 el.each(function(index){
|
|
787 var $this = $(this),
|
|
788 calendarOptions = $this.data('plugin-options'),
|
|
789 instance = null,
|
|
790 options = {};
|
|
791
|
|
792 if( this.unifato === undefined )
|
|
793 this.unifato = {};
|
|
794 instance = this.unifato;
|
|
795
|
|
796 if(calendarOptions.eventsSrc!==undefined) {
|
|
797 $.ajax({
|
|
798 url: calendarOptions.eventsSrc,
|
|
799 dataType: "json",
|
|
800 success: function(result) {
|
|
801 options = $.extend({}, defaults, calendarOptions);
|
|
802 options.events = result.events;
|
|
803 var fullcalendar = $this.fullCalendar(options);
|
|
804 instance.fullcalendar = fullcalendar[0];
|
|
805 },
|
|
806 });
|
|
807 }
|
|
808 else {
|
|
809 options = $.extend({}, defaults, calendarOptions);
|
|
810 var fullcalendar = $this.fullCalendar(options);
|
|
811 instance.fullcalendar = fullcalendar[0];
|
|
812 }
|
|
813
|
|
814 var eventModal =
|
|
815 '<div class="modal fade" id="eventEditModal" tabindex="-1" role="dialog">' +
|
|
816 '<div class="modal-dialog" role="document">'+
|
|
817 '<div class="modal-content">'+
|
|
818 '<div class="modal-header">'+
|
|
819 '<h4 class="modal-title">Edit Event</h4>'+
|
|
820 '</div>'+
|
|
821 '<div class="modal-body">'+
|
|
822 '<label for="eventName">Event Name</label>'+
|
|
823 '<input class="form-control mr-b-10" name="event-name" type="text" />'+
|
|
824 '<label for="eventType">Event Type</label>'+
|
|
825 '<select name="event-bg" class="form-control">'+
|
|
826 '<option value="danger">Danger</option>'+
|
|
827 '<option value="success">Success</option>'+
|
|
828 '<option value="info">Info</option>'+
|
|
829 '<option value="warning">Warning</option>'+
|
|
830 '<option value="color-scheme">Color Scheme</option>'+
|
|
831 '<option value="primary">Primary</option>'+
|
|
832 '<option value="pink">Pink</option>'+
|
|
833 '<option value="violet">Violet</option>'+
|
|
834 '<option value="purple">Purple</option>'+
|
|
835 '<option value="teal">Teal</option>'+
|
|
836 '<option value="slate">Slate</option>'+
|
|
837 '<option value="grey">Grey</option>'+
|
|
838 '<option value="persian-blue">Persian Blue</option>'+
|
|
839 '<option value="cerize-red">Cerize Red</option>'+
|
|
840 '<option value="mustard">Mustard</option>'+
|
|
841 '<option value="gray-light">Gray Light</option>'+
|
|
842 '</select>'+
|
|
843 '</div>'+
|
|
844 '<div class="modal-footer">'+
|
|
845 '<button class="btn mr-auto delete-btn btn-danger">Delete</button>'+
|
|
846 '<button class="btn save-btn btn-success">Save</button>'+
|
|
847 '<button class="btn btn-default" data-dismiss="modal">Cancel</button>'+
|
|
848 '</div>'+
|
|
849 '</div>'+
|
|
850 '</div>'+
|
|
851 '</div>'
|
|
852 ;
|
|
853
|
|
854 if( !$('#eventEditModal').length ) {
|
|
855 $('body').append(eventModal);
|
|
856 var $eventEditModal = $('#eventEditModal');
|
|
857 $eventEditModal.find('.delete-btn').click(function(){
|
|
858 var eventId = window.ThemeFullCalendar.EventEditMode._id;
|
|
859 $this.fullCalendar('removeEvents',[eventId]);
|
|
860 $eventEditModal.modal('hide');
|
|
861 });
|
|
862 $eventEditModal.find('.save-btn').click(function(){
|
|
863 var eventE = window.ThemeFullCalendar.EventEditMode;
|
|
864 eventE.title = $eventEditModal.find('[name="event-name"]').val();
|
|
865 eventE.className = 'bg-' + $eventEditModal.find('select[name="event-bg"]').val();
|
|
866 $this.fullCalendar('updateEvent',eventE);
|
|
867 $eventEditModal.modal('hide');
|
|
868 window.ThemeFullCalendar.EventEditMode = null;
|
|
869 });
|
|
870 }
|
|
871
|
|
872 var eventAddModal =
|
|
873 '<div class="modal fade" id="eventAddModal" tabindex="-1" role="dialog">'+
|
|
874 '<div class="modal-dialog" role="document">'+
|
|
875 '<div class="modal-content">'+
|
|
876 '<div class="modal-header">'+
|
|
877 '<h4 class="modal-title">Add Event</h4>'+
|
|
878 '</div>'+
|
|
879 '<div class="modal-body">'+
|
|
880 '<label for="eventName">Event Name</label>'+
|
|
881 '<input class="form-control mr-b-10" name="event-name" type="text" />'+
|
|
882 '<label for="eventType">Event Type</label>'+
|
|
883 '<select name="event-bg" class="form-control">'+
|
|
884 '<option value="danger">Danger</option>'+
|
|
885 '<option value="success">Success</option>'+
|
|
886 '<option value="info">Info</option>'+
|
|
887 '<option value="warning">Warning</option>'+
|
|
888 '<option value="color-scheme">Color Scheme</option>'+
|
|
889 '<option value="primary">Primary</option>'+
|
|
890 '<option value="pink">Pink</option>'+
|
|
891 '<option value="violet">Violet</option>'+
|
|
892 '<option value="purple">Purple</option>'+
|
|
893 '<option value="teal">Teal</option>'+
|
|
894 '<option value="slate">Slate</option>'+
|
|
895 '<option value="grey">Grey</option>'+
|
|
896 '<option value="persian-blue">Persian Blue</option>'+
|
|
897 '<option value="cerize-red">Cerize Red</option>'+
|
|
898 '<option value="mustard">Mustard</option>'+
|
|
899 '<option value="gray-light">Gray Light</option>'+
|
|
900 '</select>'+
|
|
901 '</div>'+
|
|
902 '<div class="modal-footer">'+
|
|
903 '<button class="btn save-btn btn-success">Save</button>'+
|
|
904 '<button class="btn btn-default" data-dismiss="modal">Cancel</button>'+
|
|
905 '</div>'+
|
|
906 '</div>'+
|
|
907 '</div>'+
|
|
908 '</div>'
|
|
909 ;
|
|
910
|
|
911 if( !$('#eventAddModal').length ) {
|
|
912 $('body').append(eventAddModal);
|
|
913 var $eventAddModal = $('#eventAddModal');
|
|
914 $eventAddModal.find('.save-btn').click(function(){
|
|
915 var event = {};
|
|
916 event.title = $eventAddModal.find('input[name="event-name"]').val();
|
|
917 event.className = 'bg-' + $eventAddModal.find('select[name="event-bg"]').val();
|
|
918
|
|
919 if( window.ThemeFullCalendar.EventAddMode !== undefined && window.ThemeFullCalendar.EventAddMode !== null) {
|
|
920 event.start = window.ThemeFullCalendar.EventAddMode._d;
|
|
921 $this.fullCalendar('addEventSource',[event]);
|
|
922 $eventAddModal.modal('hide');
|
|
923 window.ThemeFullCalendar.EventAddMode = null;
|
|
924 }
|
|
925 else if( window.ThemeFullCalendar.EventAddListMode !== undefined && window.ThemeFullCalendar.EventAddListMode !== null) {
|
|
926 var $target = window.ThemeFullCalendar.EventAddListMode.target;
|
|
927 var element = '<div class="fc-event ' + event.className + '"><i class="feather feather-check color-white ' + event.className + '"></i>' + '<span class="fc-event-text">' + event.title + '</span></div>';
|
|
928 $target.find('.fc-events').append(element);
|
|
929 $eventAddModal.modal('hide');
|
|
930 window.ThemeFullCalendar.EventAddListMode = null;
|
|
931 Unifato.enableFullCalendarEvents();
|
|
932 }
|
|
933 });
|
|
934 }
|
|
935 });
|
|
936 },
|
|
937
|
|
938 enableFullCalendarEvents: function() {
|
|
939 var el = $('[data-toggle="fullcalendar-events"]');
|
|
940 if( !el.length ) return;
|
|
941 el.each(function(index){
|
|
942 var $this = $(this);
|
|
943 var target = $(this).data('target');
|
|
944 var events = $this.find('.fc-event');
|
|
945
|
|
946 events.each(function(){
|
|
947 $(this).data('event', {
|
|
948 title: $.trim($(this).find('.fc-event-text').text()),
|
|
949 stick: true,
|
|
950 className: $(this).attr('class')
|
|
951 });
|
|
952 $(this).draggable({
|
|
953 zIndex: 999,
|
|
954 revert: true,
|
|
955 revertDuration: 0
|
|
956 });
|
|
957 });
|
|
958
|
|
959 $this.find('.fc-add-event').click(function(){
|
|
960 $('#eventAddModal').modal('show');
|
|
961 window.ThemeFullCalendar.EventAddListMode = { target: $this };
|
|
962 });
|
|
963 });
|
|
964 },
|
|
965
|
|
966 enableClndr: function() {
|
|
967 var el = $('[data-toggle="clndr"]');
|
|
968 if( !el.length ) return;
|
|
969 el.each(function(){
|
|
970 var $this = $(this);
|
|
971 var $template = $this.find('script.template').html();
|
|
972 var events = {};
|
|
973 events.events = [];
|
|
974 var instance = null;
|
|
975 if( this.unifato === undefined )
|
|
976 this.unifato = {};
|
|
977 instance = this.unifato;
|
|
978
|
|
979 if($this.find('.events').length) events = JSON.parse($this.find('.events').html().trim());
|
|
980 instance.clndr = $this.clndr({
|
|
981 template: $template,
|
|
982 userTouchEvents: true,
|
|
983 events: events.events,
|
|
984 extras: {
|
|
985 selectedDay: {},
|
|
986 },
|
|
987 clickEvents: {
|
|
988 click: function(target) {
|
|
989 this.options.extras.selectedDay = target;
|
|
990 this.render();
|
|
991 },
|
|
992 },
|
|
993 ready: function() {
|
|
994 $this.find('.today').trigger('click');
|
|
995 }
|
|
996 });
|
|
997 });
|
|
998 },
|
|
999
|
|
1000 enableDataTables: function() {
|
|
1001 var el = $('[data-toggle="datatables"]');
|
|
1002 if ( !el.length ) return;
|
|
1003 var defaults = {
|
|
1004 responsive: true,
|
|
1005 };
|
|
1006 el.each(function(index) {
|
|
1007 var $this = $(this),
|
|
1008 options = $(this).data('plugin-options');
|
|
1009 if (options === null )
|
|
1010 options = {};
|
|
1011
|
|
1012 if( this.unifato === undefined )
|
|
1013 this.unifato = {};
|
|
1014
|
|
1015 options = $.extend({},defaults,options);
|
|
1016 this.unifato.datatable = $this.DataTable(options);
|
|
1017 });
|
|
1018 },
|
|
1019
|
|
1020 enableFootable: function(){
|
|
1021 var el = $('[data-toggle="footable"]');
|
|
1022 if( !el.length ) return;
|
|
1023 el.each(function(){
|
|
1024 var $this = $(this),
|
|
1025 instance = null;
|
|
1026
|
|
1027 if ( this.unifato === undefined )
|
|
1028 this.unifato = {};
|
|
1029
|
|
1030 instance = this.unifato;
|
|
1031
|
|
1032 if( $this.data('row-src')!== undefined && $this.data('column-src') === undefined ) {
|
|
1033 instance.footable = $this.footable({
|
|
1034 "rows": $.get('assets/js/row.json'),
|
|
1035 });
|
|
1036 }
|
|
1037 else if( $this.data('row-src') !== undefined && $this.data('column-src') !== undefined ) {
|
|
1038 instance.footable = $this.footable({
|
|
1039 "rows": $.get('assets/js/row.json'),
|
|
1040 "columns": $.get('assets/js/column.json'),
|
|
1041 });
|
|
1042 }
|
|
1043 else {
|
|
1044 instance.footable = $this.footable();
|
|
1045 }
|
|
1046 });
|
|
1047 },
|
|
1048
|
|
1049 enableTableEditable: function() {
|
|
1050 var el = $('.table-editable, .table-editable-inline');
|
|
1051 if(!el.length) return;
|
|
1052 el.each(function(){
|
|
1053 var $this = $(this);
|
|
1054 var columns = $this.find('th[data-editable]');
|
|
1055 var columnsList = [];
|
|
1056 var identifier = [ $this.find('th[data-identifier]').index(), $this.find('th[data-identifier]').html() ];
|
|
1057 var instance = null;
|
|
1058 if( this.unifato === undefined )
|
|
1059 this.unifato = {};
|
|
1060 this.unifato.tabledit = this;
|
|
1061 columns.each(function(){
|
|
1062 columnsList.push([ $(this).index(), $(this).html() ]);
|
|
1063 });
|
|
1064 if( $this.hasClass('table-editable-inline') ) {
|
|
1065 $this.Tabledit({
|
|
1066 editButton: false,
|
|
1067 removeButton: false,
|
|
1068 columns: {
|
|
1069 editable: columnsList,
|
|
1070 identifier: identifier,
|
|
1071 }
|
|
1072 });
|
|
1073 }
|
|
1074 else {
|
|
1075 $this.Tabledit({
|
|
1076 columns: {
|
|
1077 editable: columnsList,
|
|
1078 identifier: identifier,
|
|
1079 }
|
|
1080 });
|
|
1081 }
|
|
1082 });
|
|
1083 },
|
|
1084
|
|
1085 enableCountUp: function() {
|
|
1086 var el = document.body.getElementsByClassName('counter');
|
|
1087
|
|
1088 var defaults = {
|
|
1089 useEasing: true,
|
|
1090 useGrouping: true,
|
|
1091 };
|
|
1092
|
|
1093 if( !el.length ) return;
|
|
1094
|
|
1095 function decimalPlaces(num) {
|
|
1096 var match = (''+num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
|
|
1097 if (!match) { return 0; }
|
|
1098 return Math.max(
|
|
1099 0,
|
|
1100 // Number of digits right of decimal point.
|
|
1101 (match[1] ? match[1].length : 0)
|
|
1102 // Adjust for scientific notation.
|
|
1103 - (match[2] ? +match[2] : 0));
|
|
1104 }
|
|
1105
|
|
1106 var counterInstanceArr = [];
|
|
1107
|
|
1108 for(var i = 0; i < el.length; i++ ) {
|
|
1109 var counterEl = el[i];
|
|
1110 counterEl.id = 'counter-' + i;
|
|
1111
|
|
1112 var options = counterEl.dataset;
|
|
1113 options = $.extend({}, defaults, options);
|
|
1114
|
|
1115 var startVal = counterEl.dataset.startval !== undefined ? counterEl.dataset.startval : 0;
|
|
1116 var endVal = parseFloat(counterEl.innerHTML);
|
|
1117
|
|
1118 var decimals = Math.max( decimalPlaces(startVal), decimalPlaces(endVal) );
|
|
1119
|
|
1120 var counter = new CountUp( counterEl.id, startVal, endVal, decimals, 3, options);
|
|
1121
|
|
1122 if (!counter.error) counterInstanceArr.push( counter );
|
|
1123 else console.error(counter.error);
|
|
1124 }
|
|
1125
|
|
1126 $(document).on('PACE_DONE', function() {
|
|
1127 for( var j = 0; j < counterInstanceArr.length; j++ ) {
|
|
1128 counterInstanceArr[j].start();
|
|
1129 }
|
|
1130 });
|
|
1131
|
|
1132 for( var i = 0; i < counterInstanceArr.length; i++ ) {
|
|
1133 counterInstanceArr[i].start();
|
|
1134 }
|
|
1135 },
|
|
1136
|
|
1137 enableRangeSlider: function() {
|
|
1138 var el = $('input[data-toggle="rangeslider"]');
|
|
1139 if(!el.length) return;
|
|
1140 el.each(function() {
|
|
1141 var $this = $(this);
|
|
1142 if( this.unifato === undefined )
|
|
1143 this.unifato = {};
|
|
1144
|
|
1145 $this.ionRangeSlider();
|
|
1146 this.unifato.ionRangeSlider = $this.data('ionRangeSlider');
|
|
1147 });
|
|
1148 },
|
|
1149
|
|
1150 enableSortable: function() {
|
|
1151 var el = $('.sortable');
|
|
1152 if( !el.length ) return;
|
|
1153 el.each(function() {
|
|
1154 var $this = $(this);
|
|
1155 if( this.unifato === undefined )
|
|
1156 this.unifato = {};
|
|
1157 $this.sortable();
|
|
1158 this.unifato.sortable = $this.data('ui-sortable');
|
|
1159 });
|
|
1160 },
|
|
1161
|
|
1162 enableNestedSortable: function() {
|
|
1163 var el = $('.dd');
|
|
1164 if( !el.length ) return;
|
|
1165 var defaults = {
|
|
1166 };
|
|
1167 el.each( function() {
|
|
1168 var $this = $(this),
|
|
1169 options = $this.data('plugin-options');
|
|
1170 options = $.extend({}, defaults, options);
|
|
1171
|
|
1172 if( this.unifato === undefined )
|
|
1173 this.unifato = {};
|
|
1174
|
|
1175 $this.nestable(options);
|
|
1176 this.unifato.nestable = $this.data('nestable');
|
|
1177 });
|
|
1178 },
|
|
1179
|
|
1180 enableTimelineLoadMoreBtn: function() {
|
|
1181 var el = $('.timeline .load-more-btn');
|
|
1182 if( !el.length ) return;
|
|
1183 el.each(function(){
|
|
1184 var $this = $(this),
|
|
1185 url = $this.data('url');
|
|
1186 $this.on('click', function() {
|
|
1187 $this.addClass('loading');
|
|
1188 $this.addClass('disabled');
|
|
1189 $.ajax({
|
|
1190 url: url,
|
|
1191 }).done(function(data) {
|
|
1192 // just to show loading effect
|
|
1193 setTimeout(function() {
|
|
1194 $this.before(data);
|
|
1195 $this.removeClass('loading');
|
|
1196 $this.removeClass('disabled');
|
|
1197 }, 1000);
|
|
1198 }).fail(function() {
|
|
1199 alert("Couldn't load Timeline Content");
|
|
1200 $this.removeClass('loading');
|
|
1201 });
|
|
1202 });
|
|
1203 });
|
|
1204 },
|
|
1205
|
|
1206 enableCarousel: function() {
|
|
1207 var el = document.getElementsByClassName('carousel');
|
|
1208 if( !el.length ) return;
|
|
1209 var defaults = {
|
|
1210 responsive: [
|
|
1211 {
|
|
1212 breakpoint: 720,
|
|
1213 settings: {
|
|
1214 slidesToShow: 1,
|
|
1215 slidesToScroll: 1
|
|
1216 }
|
|
1217 }, {
|
|
1218 breakpoint: 480,
|
|
1219 settings: {
|
|
1220 slidesToShow: 1,
|
|
1221 slidesToScroll: 1
|
|
1222 }
|
|
1223 }
|
|
1224 ]
|
|
1225 };
|
|
1226 for( var i = 0; i < el.length; i++ ) {
|
|
1227 var $this = $(el[i]),
|
|
1228 options = $this.data('plugin-options');
|
|
1229 options = $.extend({}, defaults, options);
|
|
1230 var sl = $this.slick(options);
|
|
1231
|
|
1232 window.addEventListener('resize', function() {
|
|
1233 sl.slick('resize');
|
|
1234 });
|
|
1235
|
|
1236 $(document).on('SIDEBAR_CHANGED_WIDTH', function() {
|
|
1237 sl.slick('resize');
|
|
1238 sl.slick('slickNext');
|
|
1239 });
|
|
1240 };
|
|
1241 },
|
|
1242
|
|
1243 enableMedia: function() {
|
|
1244 var el = $('video, audio');
|
|
1245 if(!el.length) return;
|
|
1246 el.each(function() {
|
|
1247 var $this = $(this);
|
|
1248 if( this.unifato === undefined )
|
|
1249 this.unifato = {};
|
|
1250 $this.mediaelementplayer({
|
|
1251 pluginPath: 'https://cdnjs.com/libraries/mediaelement/',
|
|
1252 shimScriptAccess: 'always'
|
|
1253 });
|
|
1254 if( this.tagName === 'VIDEO' ) {
|
|
1255 $this.on('playing', function() {
|
|
1256 $this.closest('.mejs__container').addClass('mejs__video--playing');
|
|
1257 });
|
|
1258 $this.on('ended', function() {
|
|
1259 $this.closest('.mejs__container').removeClass('mejs__video--playing');
|
|
1260 });
|
|
1261 }
|
|
1262 this.unifato.mediaelementplayer = $this.data('mediaelementplayer');
|
|
1263 });
|
|
1264 },
|
|
1265
|
|
1266 enableInputMask: function() {
|
|
1267 var el = $('[data-masked-input]');
|
|
1268 if(!el.length) return;
|
|
1269 $.mask.definitions.h = "[A-Fa-f0-9]";
|
|
1270 $.mask.definitions['~']='[+-]';
|
|
1271 el.each(function() {
|
|
1272 var $this = $(this),
|
|
1273 mask = $this.data('masked-input');
|
|
1274 $this.mask(mask);
|
|
1275 });
|
|
1276 },
|
|
1277
|
|
1278 enableDropify: function() {
|
|
1279 var el = $('[data-toggle="dropify"]');
|
|
1280 if(!el.length) return;
|
|
1281 el.each(function() {
|
|
1282 var $this = $(this);
|
|
1283 if( this.unifato === undefined )
|
|
1284 this.unifato = {};
|
|
1285 $this.dropify();
|
|
1286 this.unifato.dropify = $this.data('dropify');
|
|
1287 });
|
|
1288 },
|
|
1289
|
|
1290 enableDropzone: function() {
|
|
1291 var el = $('[data-toggle="dropzone"]');
|
|
1292 if(!el.length) return;
|
|
1293 Dropzone.prototype.defaultOptions.addRemoveLinks = true;
|
|
1294 var defaults = {};
|
|
1295 el.each( function() {
|
|
1296 var $this = $(this),
|
|
1297 options = $this.data('plugin-options');
|
|
1298
|
|
1299 if( this.unifato === undefined )
|
|
1300 this.unifato = {};
|
|
1301
|
|
1302 if( options === undefined ) options = {};
|
|
1303 options = $.extend({}, defaults, options);
|
|
1304 $this.dropzone(options);
|
|
1305 this.unifato.dropzone = this.dropzone;
|
|
1306 $this.addClass('dropzone');
|
|
1307 });
|
|
1308 },
|
|
1309
|
|
1310 enableClockPicker: function() {
|
|
1311 var el = $('.clockpicker');
|
|
1312 if(!el.length) return;
|
|
1313 var defaults = {
|
|
1314 donetext: 'Done',
|
|
1315 };
|
|
1316 el.each(function() {
|
|
1317 var $this = $(this),
|
|
1318 options = $this.data('plugin-options');
|
|
1319
|
|
1320 if( this.unifato === undefined )
|
|
1321 this.unifato = {};
|
|
1322
|
|
1323 if( options === undefined ) options = {};
|
|
1324 options = $.extend({}, defaults, options);
|
|
1325 $this.clockpicker(options);
|
|
1326 this.unifato.clockpicker = $this.data('clockpicker');
|
|
1327 });
|
|
1328 },
|
|
1329
|
|
1330 enableColorPicker: function() {
|
|
1331 var el = $('.colorpicker');
|
|
1332 if(!el.length) return;
|
|
1333 var defaults = {
|
|
1334 preferredFormat: "rgb",
|
|
1335 showInput: true,
|
|
1336 change: function(color) {
|
|
1337 var $this = $(this);
|
|
1338 $this.parent().find('input').val( color );
|
|
1339 $this.find('i').css( 'background', color );
|
|
1340 },
|
|
1341 };
|
|
1342 el.each(function() {
|
|
1343 var $this = $(this),
|
|
1344 options = $this.data('plugin-options'),
|
|
1345 value = $this.find('input').val();
|
|
1346 if( options === undefined ) options = {};
|
|
1347 options = $.extend({}, defaults, options);
|
|
1348 options.color = value;
|
|
1349 $this.find('.input-group-addon').spectrum(options).find('i').css('background', value);
|
|
1350 $this.find('input').click( function(e) {
|
|
1351 $this.find('.input-group-addon').spectrum('toggle');
|
|
1352 return false;
|
|
1353 });
|
|
1354 });
|
|
1355 },
|
|
1356
|
|
1357 enableDateRangePicker: function() {
|
|
1358 var el = $('.daterange');
|
|
1359 if( !el.length ) return;
|
|
1360 var defaults = {
|
|
1361 locale: {
|
|
1362 format: 'MMMM D',
|
|
1363 },
|
|
1364 };
|
|
1365 el.each(function(){
|
|
1366 var $this = $(this),
|
|
1367 options = $this.data('plugin-options');
|
|
1368
|
|
1369 if( this.unifato === undefined )
|
|
1370 this.unifato = {};
|
|
1371
|
|
1372 if( options === undefined ) options = {};
|
|
1373 options = $.extend({}, defaults, options);
|
|
1374 $this.daterangepicker(options);
|
|
1375 this.unifato.daterangepicker = $this.data('daterangepicker');
|
|
1376 });
|
|
1377 },
|
|
1378
|
|
1379 enablePredefinedDateRangePicker: function() {
|
|
1380 var $el = $('.predefinedRanges');
|
|
1381 if ( !$el.length ) return;
|
|
1382 var defaults = {
|
|
1383 locale: {
|
|
1384 format: 'MMMM-D',
|
|
1385 },
|
|
1386 startDate: moment().subtract(29, 'days'),
|
|
1387 endDate: moment(),
|
|
1388 opens: "left",
|
|
1389 ranges: {
|
|
1390 'Today': [moment(), moment()],
|
|
1391 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
|
1392 'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
|
1393 'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
|
1394 'This Month': [moment().startOf('month'), moment().endOf('month')],
|
|
1395 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
|
1396 }
|
|
1397 };
|
|
1398 $el.each( function() {
|
|
1399 var start = moment().subtract(29, 'days');
|
|
1400 var end = moment();
|
|
1401 var $this = $(this);
|
|
1402 var options = $this.data('plugin-options');
|
|
1403 options = $.extend({}, defaults, options);
|
|
1404 function cb(start, end) {
|
|
1405 $this.find('span').html(start.format(options.locale.format) + ' - ' + end.format(options.locale.format));
|
|
1406 }
|
|
1407
|
|
1408 if( this.unifato === undefined )
|
|
1409 this.unifato = {};
|
|
1410
|
|
1411 $this.daterangepicker(options, cb);
|
|
1412 this.unifato.daterangepicker = $this.data('daterangepicker');
|
|
1413 cb(start, end);
|
|
1414 });
|
|
1415 },
|
|
1416
|
|
1417 enableDatePicker: function() {
|
|
1418 var el = $('.datepicker');
|
|
1419 if( !el.length ) return;
|
|
1420 var defaults = {
|
|
1421 };
|
|
1422 el.each(function(){
|
|
1423 var $this = $(this),
|
|
1424 options = $this.data('plugin-options');
|
|
1425
|
|
1426 if( this.unifato === undefined )
|
|
1427 this.unifato = {};
|
|
1428
|
|
1429 if( options === undefined ) options = {};
|
|
1430 options = $.extend({}, defaults, options);
|
|
1431 $this.datepicker(options);
|
|
1432 this.unifato.datepicker = $this.data('datepicker');
|
|
1433 });
|
|
1434 },
|
|
1435
|
|
1436 enableSelect2: function() {
|
|
1437 var el = $('[data-toggle="select2"]');
|
|
1438 if(!el.length) return;
|
|
1439 el.each( function() {
|
|
1440 var $this = $(this),
|
|
1441 options = $this.data('plugin-options');
|
|
1442
|
|
1443 if( this.unifato === undefined )
|
|
1444 this.unifato = {};
|
|
1445
|
|
1446 $this.select2(options);
|
|
1447 this.unifato.select2 = $this.data('select2');
|
|
1448 });
|
|
1449 },
|
|
1450
|
|
1451 enableSwitchery: function() {
|
|
1452 var elems = document.getElementsByClassName('js-switch');
|
|
1453 if( !elems.length ) return;
|
|
1454 var defaults = {
|
|
1455 secondaryColor: '#ddd',
|
|
1456 };
|
|
1457 for(var i=0; i < elems.length; i++ ) {
|
|
1458 var dataset = JSON.parse(JSON.stringify(elems[i].dataset));
|
|
1459 dataset = $.extend({}, defaults, dataset);
|
|
1460 var jsSwitch = new Switchery(elems[i], dataset);
|
|
1461 if( elems[i].unifato === undefined )
|
|
1462 elems[i].unifato = {};
|
|
1463
|
|
1464 elems[i].unifato.switchery = jsSwitch;
|
|
1465 }
|
|
1466
|
|
1467 },
|
|
1468
|
|
1469 enableTouchspin: function() {
|
|
1470 var el = $('[data-toggle="touchspin"]');
|
|
1471 if(!el.length) return;
|
|
1472 var defaults = {
|
|
1473 verticalupclass: '',
|
|
1474 verticaldownclass: ''
|
|
1475 };
|
|
1476 el.each(function() {
|
|
1477 var $this = $(this),
|
|
1478 options = $this.data('plugin-options');
|
|
1479
|
|
1480 if(options===undefined) options = {};
|
|
1481 options = $.extend({}, defaults, options);
|
|
1482 $this.TouchSpin(options);
|
|
1483 });
|
|
1484 },
|
|
1485
|
|
1486 enableMultiSelect: function() {
|
|
1487 var el = $('[data-toggle="multiselect"]');
|
|
1488 if(!el.length) return;
|
|
1489 this.enableMultiSelectBtns();
|
|
1490 el.each(function() {
|
|
1491 var $this = $(this);
|
|
1492 if( this.unifato === undefined )
|
|
1493 this.unifato = {};
|
|
1494 this.unifato.multiselect = $this.multiSelect();
|
|
1495 });
|
|
1496 },
|
|
1497
|
|
1498 enableMultiSelectBtns: function() {
|
|
1499 var el = $('[data-multiselect-target]');
|
|
1500 if(!el.length) return;
|
|
1501 el.each(function() {
|
|
1502 var $this = $(this),
|
|
1503 $targetData = $this.data('multiselect-target'),
|
|
1504 $method = $this.data('multiselect-method'),
|
|
1505 $event = $this.data('event');
|
|
1506
|
|
1507 var $target = $( $targetData );
|
|
1508 $this.on( $event, function(e) {
|
|
1509 e.preventDefault();
|
|
1510
|
|
1511 switch ( $method ) {
|
|
1512 case "addOption":
|
|
1513 $target.multiSelect( 'addOption', { value: 'test', text: 'test', index: 0, nested: 'optgroup_label' });
|
|
1514 break;
|
|
1515 default:
|
|
1516 $target.multiSelect( $method );
|
|
1517 }
|
|
1518 });
|
|
1519 });
|
|
1520 },
|
|
1521
|
|
1522 enableTinyMCE: function() {
|
|
1523 this.enableTinyMCEInline();
|
|
1524 var el = $('[data-toggle="tinymce"]');
|
|
1525 if(!el.length) return;
|
|
1526 var defaults = {
|
|
1527 skin: "lightgray",
|
|
1528 };
|
|
1529 el.each(function() {
|
|
1530 var $this = $(this),
|
|
1531 options = $this.data('plugin-options');
|
|
1532
|
|
1533
|
|
1534 if( options === undefined ) options = {};
|
|
1535 options = $.extend({}, defaults, options);
|
|
1536
|
|
1537 $this.tinymce(options);
|
|
1538 });
|
|
1539 },
|
|
1540
|
|
1541 enableTinyMCEInline: function() {
|
|
1542 var el = $('[data-toggle="tinymce-inline"]');
|
|
1543 if( !el.length ) return;
|
|
1544 var defaults = {
|
|
1545 skin: "lightgray",
|
|
1546 inline: true,
|
|
1547 theme: "inlite",
|
|
1548 plugins: [
|
|
1549 'advlist autolink lists link image charmap print preview anchor',
|
|
1550 'searchreplace visualblocks code fullscreen',
|
|
1551 'insertdatetime media table contextmenu paste'
|
|
1552 ],
|
|
1553 };
|
|
1554 el.each(function() {
|
|
1555 var $this = $(this),
|
|
1556 $html = $this.html(),
|
|
1557 options = $this.data('plugin-options');
|
|
1558
|
|
1559 if( options === undefined ) options = {};
|
|
1560 options = $.extend({}, defaults, options);
|
|
1561 $this.tinymce(options);
|
|
1562 });
|
|
1563 },
|
|
1564
|
|
1565 enableBootstrapWysiwyg: function() {
|
|
1566 this.enableTinyMCEInline();
|
|
1567 var el = $('[data-toggle="wysiwyg"]');
|
|
1568 if(!el.length) return;
|
|
1569 var defaults = {
|
|
1570 };
|
|
1571 el.each(function() {
|
|
1572 var $this = $(this),
|
|
1573 options = $this.data('plugin-options');
|
|
1574
|
|
1575 if( this.unifato === undefined )
|
|
1576 this.unifato = {};
|
|
1577
|
|
1578 if( options === undefined ) options = {};
|
|
1579 options = $.extend({}, defaults, options);
|
|
1580 $this.wysihtml5(options);
|
|
1581 this.unifato.wysihtml5 = $this.data('wysihtml5');
|
|
1582 });
|
|
1583 $('[data-wysihtml5-dialog]').on('hidden.bs.modal', function(){
|
|
1584 $('.modal-backdrop').remove();
|
|
1585 });
|
|
1586 },
|
|
1587
|
|
1588 enableCircleProgress: function() {
|
|
1589 var el = $('[data-toggle="circle-progress"]');
|
|
1590 if( !el.length ) return;
|
|
1591 el.each(function() {
|
|
1592 $(this).circleProgress();
|
|
1593 });
|
|
1594 },
|
|
1595
|
|
1596 enableSparkline: function() {
|
|
1597 var el = $('[data-toggle="sparklines"]');
|
|
1598 if( !el.length ) return;
|
|
1599 el.each(function() {
|
|
1600 $(this).sparkline('html', { enableTagOptions: true });
|
|
1601 });
|
|
1602 },
|
|
1603 };
|
|
1604
|
|
1605 document.addEventListener('DOMContentLoaded', function() {
|
|
1606 Pace.options = {
|
|
1607 ajax: {
|
|
1608 ignoreURLs: [
|
|
1609 'assets/vendors/theme-widgets/getTwitterFeed',
|
|
1610 'assets/vendors/theme-widgets/getFacebookFeed'
|
|
1611 ],
|
|
1612 }
|
|
1613 }
|
|
1614 Unifato.init();
|
|
1615 Unifato.setMenu();
|
|
1616 });
|
|
1617
|
|
1618 window.addEventListener('resize', Unifato.setMenu);
|
|
1619 window.addEventListener('resize', Unifato.contentHeight);
|
|
1620 })(jQuery);
|