/* 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 // 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); }; // Coming Soon function getTimeRemaining(endtime) { var t = Date.parse(endtime) - Date.parse(new Date()); var seconds = Math.floor((t / 1000) % 60); var minutes = Math.floor((t / 1000 / 60) % 60); var hours = Math.floor((t / (1000 * 60 * 60)) % 24); var days = Math.floor(t / (1000 * 60 * 60 * 24)); return { 'total': t, 'days': days, 'hours': hours, 'minutes': minutes, 'seconds': seconds }; } function initializeClock(id, endtime) { var clock = document.getElementById(id); var daysSpan = clock.querySelector('.days'); var hoursSpan = clock.querySelector('.hours'); var minutesSpan = clock.querySelector('.minutes'); var secondsSpan = clock.querySelector('.seconds'); function updateClock() { var t = getTimeRemaining(endtime); daysSpan.innerHTML = t.days; hoursSpan.innerHTML = ('0' + t.hours).slice(-2); minutesSpan.innerHTML = ('0' + t.minutes).slice(-2); secondsSpan.innerHTML = ('0' + t.seconds).slice(-2); if (t.total <= 0) { clearInterval(timeinterval); } } updateClock(); var timeinterval = setInterval(updateClock, 1000); } var deadline = new Date(Date.parse(new Date()) + 256 * 24 * 60 * 60 * 1000); if ($("#countdown").length > 0) initializeClock('countdown', deadline); }); // Inspect keyCode // $( window ).on( "load", function() { // document.onkeydown = function(e) { // if(e.keyCode == 123) { // return false; // } // if(e.ctrlKey && e.shiftKey && e.keyCode == 'I'.charCodeAt(0)){ // return false; // } // if(e.ctrlKey && e.shiftKey && e.keyCode == 'J'.charCodeAt(0)){ // return false; // } // if(e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)){ // return false; // } // if(e.ctrlKey && e.shiftKey && e.keyCode == 'C'.charCodeAt(0)){ // return false; // } // }; // }); // document.oncontextmenu = function() {return false;}; // $(document).mousedown(function(e){ // if( e.button == 2 ) { // return false; // } // return true; // }); })(jQuery);