/* Author : Dreamguys Template Name: Preadmin - Bootstrap Template Version : 1.1 */ (function($) { "use strict"; var Sidemenu = function() { this.$menuItem = $("#sidebar-menu a"); }; Sidemenu.prototype.init = function() { var $this = this; $this.$menuItem.on('click', function(e) { if ($(this).parent().hasClass("submenu")) { e.preventDefault(); } if (!$(this).hasClass("subdrop")) { $("ul", $(this).parents("ul:first")).slideUp(350); $("a", $(this).parents("ul:first")).removeClass("subdrop"); $(this).next("ul").slideDown(350); $(this).addClass("subdrop"); } else if ($(this).hasClass("subdrop")) { $(this).removeClass("subdrop"); $(this).next("ul").slideUp(350); } }); $("#sidebar-menu ul li.submenu a.active").parents("li:last").children("a:first").addClass("active").trigger("click"); }, $.Sidemenu = new Sidemenu; $(document).ready(function($) { // Sidebar Initiate $.Sidemenu.init(); // Sidebar overlay var $sidebarOverlay = $(".sidebar-overlay"); $("#mobile_btn, .task-chat").on("click", function(e) { var $target = $($(this).attr("href")); if ($target.length) { $target.toggleClass("opened"); $sidebarOverlay.toggleClass("opened"); $("html").toggleClass("menu-opened"); $sidebarOverlay.attr("data-reff", $(this).attr("href")); } e.preventDefault(); }); $sidebarOverlay.on("click", function(e) { var $target = $($(this).attr("data-reff")); if ($target.length) { $target.removeClass("opened"); $("html").removeClass("menu-opened"); $(this).removeClass("opened"); $(".main-wrapper").removeClass("slide-nav"); } e.preventDefault(); }); // Select 2 if ($('.select').length > 0) { $('.select').select2({ minimumResultsForSearch: -1, width: '100%' }); } // Modal if ($('.modal').length > 0) { var modalUniqueClass = ".modal"; $('.modal').on('show.bs.modal', function(e) { var $element = $(this); var $uniques = $(modalUniqueClass + ':visible').not($(this)); if ($uniques.length) { $uniques.modal('hide'); $uniques.one('hidden.bs.modal', function(e) { $element.modal('show'); $("body").addClass("modal-open"); }); return false; } }); } // Floating Label if ($('.floating').length > 0) { $('.floating').on('focus blur', function(e) { $(this).parents('.form-focus').toggleClass('focused', (e.type === 'focus' || this.value.length > 0)); }).trigger('blur'); } // Right Sidebar Scroll if ($('.msg-list-scroll').length > 0) { $('.msg-list-scroll').slimscroll({ height: '100%', color: '#878787', disableFadeOut: true, borderRadius: 0, size: '4px', alwaysVisible: false, touchScrollStep: 100 }); var h = $(window).height() - 94; $('.msg-list-scroll').height(h); $('.msg-sidebar .slimScrollDiv').height(h); $(window).resize(function() { var h = $(window).height() - 94; $('.msg-list-scroll').height(h); $('.msg-sidebar .slimScrollDiv').height(h); }); } // Left Sidebar Scroll if ($('.slimscroll').length > 0) { $('.slimscroll').slimScroll({ height: 'auto', width: '100%', position: 'right', size: "7px", color: '#ccc', wheelStep: 10, touchScrollStep: 100 }); var hei = $(window).height() - 161; $('.slimscroll').height(hei); $('.sidebar .slimScrollDiv').height(hei); $(window).resize(function() { var hei = $(window).height() - 161; $('.slimscroll').height(hei); $('.sidebar .slimScrollDiv').height(hei); }); } // Page wrapper height if ($('.page-wrapper').length > 0) { var height = $(window).height(); $(".page-wrapper").css("min-height", height); } $(window).resize(function() { if ($('.page-wrapper').length > 0) { var height = $(window).height(); $(".page-wrapper").css("min-height", height); } }); // Datetimepicker if ($('.datetimepicker').length > 0) { $('.datetimepicker').datetimepicker({ format: 'DD/MM/YYYY' }); } // Datatable if ($('.datatable').length > 0) { $('.datatable').DataTable({ "bFilter": false, }); } // Bootstrap Tooltip if ($('[data-toggle="tooltip"]').length > 0) { $('[data-toggle="tooltip"]').tooltip(); } // Bootstrap Popover if ($('[data-toggle="popover"]').length > 0) { $('[data-toggle="popover"]').popover(); } // Toggle Button if ($('.btn-toggle').length > 0) { $('.btn-toggle').click(function() { $(this).find('.btn').toggleClass('active'); if ($(this).find('.btn-success').size() > 0) { $(this).find('.btn').toggleClass('btn-success'); } }); } // Mobile Menu if ($('.main-wrapper').length > 0) { var $wrapper = $(".main-wrapper"); $('#mobile_btn').click(function() { $wrapper.toggleClass('slide-nav'); $('#chat_sidebar').removeClass('opened'); $(".dropdown.open > .dropdown-toggle").dropdown("toggle"); return false; }); $('#open_msg_box').click(function() { $wrapper.toggleClass('open-msg-box'); $('.themes').removeClass('active'); $('.dropdown').removeClass('open'); $('.main-wrapper').removeClass('open-msg-box-two'); return false; }); $('.open_msg_box_class').click(function() { $wrapper.toggleClass('open-msg-box'); $('.themes').removeClass('active'); $('.dropdown').removeClass('open'); $('.main-wrapper').removeClass('open-msg-box-two'); return false; }); $('.open_msg_box_class_two').click(function() { $wrapper.toggleClass('open-msg-box-two'); $('.themes').removeClass('active'); $('.dropdown').removeClass('open'); $('.main-wrapper').removeClass('open-msg-box'); return false; }); } // Product thumb images if ($('.proimage-thumb li a').length > 0) { var full_image = $(this).attr("href"); $(".proimage-thumb li a").click(function() { full_image = $(this).attr("href"); $(".pro-image img").attr("src", full_image); return false; }); } // Lightgallery if ($('#pro_popup').length > 0) { $('#pro_popup').lightGallery({ thumbnail: true, selector: 'a' }); } if ($('#lightgallery').length > 0) { $('#lightgallery').lightGallery({ thumbnail: true, selector: 'a' }); } // Summernote if ($('.summernote').length > 0) { $('.summernote').summernote({ height: 200, minHeight: null, maxHeight: null, focus: false }); } // File Upload if($('.custom-file-container').length > 0) { //First upload var firstUpload = new FileUploadWithPreview('myFirstImage') //Second upload var secondUpload = new FileUploadWithPreview('mySecondImage') } // Clipboard if($('.clipboard').length > 0) { var clipboard = new Clipboard('.btn'); } // Counter if($('.counter').length > 0) { $('.counter').counterUp({ delay: 20, time: 2000 }); } if($('#timer-countdown').length > 0) { $( '#timer-countdown' ).countdown( { from: 180, // 3 minutes (3*60) to: 0, // stop at zero movingUnit: 1000, // 1000 for 1 second increment/decrements timerEnd: undefined, outputPattern: '$day Day $hour : $minute : $second', autostart: true }); } if($('#timer-countup').length > 0) { $( '#timer-countup' ).countdown( { from: 0, to: 180 }); } if($('#timer-countinbetween').length > 0) { $( '#timer-countinbetween' ).countdown( { from: 30, to: 20 }); } if($('#timer-countercallback').length > 0) { $( '#timer-countercallback' ).countdown( { from: 10, to: 0, timerEnd: function() { this.css( { 'text-decoration':'line-through' } ).animate( { 'opacity':.5 }, 500 ); } }); } if($('#timer-outputpattern').length > 0) { $( '#timer-outputpattern' ).countdown( { outputPattern: '$day Days $hour Hour $minute Min $second Sec..', from: 60 * 60 * 24 * 3 }); } // Will Delete if ($('.themes-icon').length > 0) { $(".themes-icon").click(function() { $('.themes').toggleClass("active"); if ($('.main-wrapper').hasClass('open-msg-box')) { $('.main-wrapper').removeClass('open-msg-box'); }else if($('.main-wrapper').hasClass('open-msg-box-two')){ $('.main-wrapper').removeClass('open-msg-box-two'); } }); } // Check all email if ($('.checkbox-all').length > 0) { $('.checkbox-all').click(function() { $('.checkmail').click(); }); } if ($('.checkmail').length > 0) { $('.checkmail').each(function() { $(this).click(function() { if ($(this).closest('tr').hasClass("checked")) { $(this).closest('tr').removeClass('checked'); } else { $(this).closest('tr').addClass('checked'); } }); }); } $('a.cargePage').click( function(){ $(this).children('i').removeAttr('class'); $(this).children('i').css({"width":"18px","height":"18px","font-size":"12px"}); $(this).children('i').addClass('spinner-border text-danger'); }) // Mail important if ($('.mail-important').length > 0) { $(".mail-important").click(function() { $(this).find('i.fa').toggleClass("fa-star"); $(this).find('i.fa').toggleClass("fa-star-o"); }); } if ($('.dropdown-toggle').length > 0) { $('.dropdown-toggle').click(function() { if ($('.main-wrapper').hasClass('open-msg-box')) { $('.main-wrapper').removeClass('open-msg-box'); }else if($('.main-wrapper').hasClass('open-msg-box-two')){ $('.main-wrapper').removeClass('open-msg-box-two'); } }); } /* Custom Modal */ if ($('.custom-modal').length > 0) { $(".custom-modal .modal-content").prepend(''); } // Custom Backdrop for modal popup $('a[data-toggle="modal"]').on('click', function() { setTimeout(function() { if ($(".modal.custom-modal").hasClass('show')) { $(".modal-backdrop").addClass('custom-backdrop'); } }, 500); }); // Task function var notificationTimeout; //Shows updated notification popup var updateNotification = function(task, notificationText, newClass) { var notificationPopup = $('.notification-popup '); notificationPopup.find('.task').text(task); notificationPopup.find('.notification-text').text(notificationText); notificationPopup.removeClass('hide success'); // If a custom class is provided for the popup, add It if (newClass) notificationPopup.addClass(newClass); // If there is already a timeout running for hiding current popup, clear it. if (notificationTimeout) clearTimeout(notificationTimeout); // Init timeout for hiding popup after 3 seconds notificationTimeout = setTimeout(function() { notificationPopup.addClass('hide'); }, 3000); }; // Adds a new Task to the todo list var addTask = function() { // Get the new task entered by user var newTask = $('#new-task').val(); // If new task is blank show error message if (newTask === '') { $('#new-task').addClass('error'); $('.new-task-wrapper .error-message').removeClass('hidden'); } else { var todoListScrollHeight = $('.task-list-body').prop('scrollHeight'); // Make a new task template var newTemplate = $(taskTemplate).clone(); // update the task label in the new template newTemplate.find('.task-label').text(newTask); // Add new class to the template newTemplate.addClass('new'); // Remove complete class in the new Template in case it is present newTemplate.removeClass('completed'); //Append the new template to todo list $('#task-list').append(newTemplate); // Clear the text in textarea $('#new-task').val(''); // As a new task is added, hide the mark all tasks as incomplete button & show the mark all finished button $('#mark-all-finished').removeClass('move-up'); $('#mark-all-incomplete').addClass('move-down'); // Show notification updateNotification(newTask, 'added to list'); // Smoothly scroll the todo list to the end $('.task-list-body').animate({ scrollTop: todoListScrollHeight }, 1000); } }; // Closes the panel for entering new tasks & shows the button for opening the panel var closeNewTaskPanel = function() { $('.add-task-btn').toggleClass('visible'); $('.new-task-wrapper').toggleClass('visible'); if ($('#new-task').hasClass('error')) { $('#new-task').removeClass('error'); $('.new-task-wrapper .error-message').addClass('hidden'); } }; // Initalizes HTML template for a given task //var taskTemplate = $($('#task-template').html()); var taskTemplate = '