123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122 |
- /**
- Core script to handle the entire theme and core functions
- **/
- var selectSrchInit = function () {
- // IE mode
- var isRTL = false;
- var isIE8 = false;
- var isIE9 = false;
- var isIE10 = false;
- var sidebarWidth = 225;
- var sidebarCollapsedWidth = 35;
- var responsiveHandlers = [];
- // theme layout color set
- var layoutColorCodes = {
- 'blue': '#4b8df8',
- 'red': '#e02222',
- 'green': '#35aa47',
- 'purple': '#852b99',
- 'grey': '#555555',
- 'light-grey': '#fafafa',
- 'yellow': '#ffb848'
- };
- // To get the correct viewport width based on http://andylangton.co.uk/articles/javascript/get-viewport-size-javascript/
- var _getViewPort = function () {
- var e = window, a = 'inner';
- if (!('innerWidth' in window)) {
- a = 'client';
- e = document.documentElement || document.body;
- }
- return {
- width: e[a + 'Width'],
- height: e[a + 'Height']
- }
- }
- // initializes main settings
- var handleInit = function () {
- if ($('body').css('direction') === 'rtl') {
- isRTL = true;
- }
- isIE8 = !! navigator.userAgent.match(/MSIE 8.0/);
- isIE9 = !! navigator.userAgent.match(/MSIE 9.0/);
- isIE10 = !! navigator.userAgent.match(/MSIE 10.0/);
- if (isIE10) {
- jQuery('html').addClass('ie10'); // detect IE10 version
- }
-
- if (isIE10 || isIE9 || isIE8) {
- jQuery('html').addClass('ie'); // detect IE10 version
- }
- /*
- Virtual keyboards:
- Also, note that if you're using inputs in your modal – iOS has a rendering bug which doesn't
- update the position of fixed elements when the virtual keyboard is triggered
- */
- var deviceAgent = navigator.userAgent.toLowerCase();
- if (deviceAgent.match(/(iphone|ipod|ipad)/)) {
- $(document).on('focus', 'input, textarea', function () {
- $('.header').hide();
- $('.footer').hide();
- });
- $(document).on('blur', 'input, textarea', function () {
- $('.header').show();
- $('.footer').show();
- });
- }
- }
- var handleSidebarState = function () {
- // remove sidebar toggler if window width smaller than 992(for tablet and phone mode)
- var viewport = _getViewPort();
- if (viewport.width < 992) {
- $('body').removeClass("page-sidebar-closed");
- }
- }
- // runs callback functions set by App.addResponsiveHandler().
- var runResponsiveHandlers = function () {
- // reinitialize other subscribed elements
- for (var i in responsiveHandlers) {
- var each = responsiveHandlers[i];
- each.call();
- }
- }
- // reinitialize the laypot on window resize
- var handleResponsive = function () {
- handleSidebarState();
- handleSidebarAndContentHeight();
- handleFixedSidebar();
- runResponsiveHandlers();
- }
- // initialize the layout on page load
- var handleResponsiveOnInit = function () {
- handleSidebarState();
- handleSidebarAndContentHeight();
- }
- // handle the layout reinitialization on window resize
- var handleResponsiveOnResize = function () {
- var resize;
- if (isIE8) {
- var currheight;
- $(window).resize(function () {
- if (currheight == document.documentElement.clientHeight) {
- return; //quite event since only body resized not window.
- }
- if (resize) {
- clearTimeout(resize);
- }
- resize = setTimeout(function () {
- handleResponsive();
- }, 50); // wait 50ms until window resize finishes.
- currheight = document.documentElement.clientHeight; // store last body client height
- });
- } else {
- $(window).resize(function () {
- if (resize) {
- clearTimeout(resize);
- }
- resize = setTimeout(function () {
- handleResponsive();
- }, 50); // wait 50ms until window resize finishes.
- });
- }
- }
- //* BEGIN:CORE HANDLERS *//
- // this function handles responsive layout on screen size resize or mobile device rotate.
- // Set proper height for sidebar and content. The content and sidebar height must be synced always.
- var handleSidebarAndContentHeight = function () {
- var content = $('.page-content');
- var sidebar = $('.page-sidebar');
- var body = $('body');
- var height;
- if (body.hasClass("page-footer-fixed") === true && body.hasClass("page-sidebar-fixed") === false) {
- var available_height = $(window).height() - $('.footer').outerHeight();
- if (content.height() < available_height) {
- content.attr('style', 'min-height:' + available_height + 'px !important');
- }
- } else {
- if (body.hasClass('page-sidebar-fixed')) {
- height = _calculateFixedSidebarViewportHeight();
- } else {
- height = sidebar.height() + 20;
- }
- if (height >= content.height()) {
- content.attr('style', 'min-height:' + height + 'px !important');
- }
- }
- }
- // Handle sidebar menu
- var handleSidebarMenu = function () {
- jQuery('.page-sidebar').on('click', 'li > a', function (e) {
- if ($(this).next().hasClass('sub-menu') == false) {
- if ($('.btn-navbar').hasClass('collapsed') == false) {
- $('.btn-navbar').click();
- }
- return;
- }
- if ($(this).next().hasClass('sub-menu.always-open')) {
- return;
- }
- var parent = $(this).parent().parent();
- var the = $(this);
- parent.children('li.open').children('a').children('.arrow').removeClass('open');
- parent.children('li.open').children('.sub-menu').slideUp(200);
- parent.children('li.open').removeClass('open');
- var sub = jQuery(this).next();
- var slideOffeset = -200;
- var slideSpeed = 200;
- if (sub.is(":visible")) {
- jQuery('.arrow', jQuery(this)).removeClass("open");
- jQuery(this).parent().removeClass("open");
- sub.slideUp(slideSpeed, function () {
- if ($('body').hasClass('page-sidebar-fixed') == false && $('body').hasClass('page-sidebar-closed') == false) {
- selectSrchInit.scrollTo(the, slideOffeset);
- }
- handleSidebarAndContentHeight();
- });
- } else {
- jQuery('.arrow', jQuery(this)).addClass("open");
- jQuery(this).parent().addClass("open");
- sub.slideDown(slideSpeed, function () {
- if ($('body').hasClass('page-sidebar-fixed') == false && $('body').hasClass('page-sidebar-closed') == false) {
- selectSrchInit.scrollTo(the, slideOffeset);
- }
- handleSidebarAndContentHeight();
- });
- }
- e.preventDefault();
- });
- // handle ajax links
- jQuery('.page-sidebar').on('click', ' li > a.ajaxify', function (e) {
- e.preventDefault();
- selectSrchInit.scrollTop();
- var url = $(this).attr("href");
- var menuContainer = jQuery('.page-sidebar ul');
- var pageContent = $('.page-content');
- var pageContentBody = $('.page-content .page-content-body');
- menuContainer.children('li.active').removeClass('active');
- menuContainer.children('arrow.open').removeClass('open');
- $(this).parents('li').each(function () {
- $(this).addClass('active');
- $(this).children('a > span.arrow').addClass('open');
- });
- $(this).parents('li').addClass('active');
- selectSrchInit.blockUI(pageContent, false);
- $.ajax({
- type: "GET",
- cache: false,
- url: url,
- dataType: "html",
- success: function (res) {
- selectSrchInit.unblockUI(pageContent);
- pageContentBody.html(res);
- selectSrchInit.fixContentHeight(); // fix content height
- selectSrchInit.initAjax(); // initialize core stuff
- },
- error: function (xhr, ajaxOptions, thrownError) {
- pageContentBody.html('<h4>Could not load the requested content.</h4>');
- selectSrchInit.unblockUI(pageContent);
- },
- async: false
- });
- });
- }
- // Helper function to calculate sidebar height for fixed sidebar layout.
- var _calculateFixedSidebarViewportHeight = function () {
- var sidebarHeight = $(window).height() - $('.header').height() + 1;
- if ($('body').hasClass("page-footer-fixed")) {
- sidebarHeight = sidebarHeight - $('.footer').outerHeight();
- }
- return sidebarHeight;
- }
- // Handles fixed sidebar
- var handleFixedSidebar = function () {
- var menu = $('.page-sidebar-menu');
- if (menu.parent('.slimScrollDiv').size() === 1) { // destroy existing instance before updating the height
- menu.slimScroll({
- destroy: true
- });
- menu.removeAttr('style');
- $('.page-sidebar').removeAttr('style');
- }
- if ($('.page-sidebar-fixed').size() === 0) {
- handleSidebarAndContentHeight();
- return;
- }
- var viewport = _getViewPort();
- if (viewport.width >= 992) {
- var sidebarHeight = _calculateFixedSidebarViewportHeight();
- menu.slimScroll({
- size: '7px',
- color: '#a1b2bd',
- opacity: .3,
- position: isRTL ? 'left' : 'right',
- height: sidebarHeight,
- allowPageScroll: false,
- disableFadeOut: false
- });
- handleSidebarAndContentHeight();
- }
- }
- // Handles the sidebar menu hover effect for fixed sidebar.
- var handleFixedSidebarHoverable = function () {
- if ($('body').hasClass('page-sidebar-fixed') === false) {
- return;
- }
- $('.page-sidebar').off('mouseenter').on('mouseenter', function () {
- var body = $('body');
- if ((body.hasClass('page-sidebar-closed') === false || body.hasClass('page-sidebar-fixed') === false) || $(this).hasClass('page-sidebar-hovering')) {
- return;
- }
- body.removeClass('page-sidebar-closed').addClass('page-sidebar-hover-on');
- if (body.hasClass("page-sidebar-reversed")) {
- $(this).width(sidebarWidth);
- } else {
- $(this).addClass('page-sidebar-hovering');
- $(this).animate({
- width: sidebarWidth
- }, 400, '', function () {
- $(this).removeClass('page-sidebar-hovering');
- });
- }
- });
- $('.page-sidebar').off('mouseleave').on('mouseleave', function () {
- var body = $('body');
- if ((body.hasClass('page-sidebar-hover-on') === false || body.hasClass('page-sidebar-fixed') === false) || $(this).hasClass('page-sidebar-hovering')) {
- return;
- }
- if (body.hasClass("page-sidebar-reversed")) {
- $('body').addClass('page-sidebar-closed').removeClass('page-sidebar-hover-on');
- $(this).width(sidebarCollapsedWidth);
- } else {
- $(this).addClass('page-sidebar-hovering');
- $(this).animate({
- width: sidebarCollapsedWidth
- }, 400, '', function () {
- $('body').addClass('page-sidebar-closed').removeClass('page-sidebar-hover-on');
- $(this).removeClass('page-sidebar-hovering');
- });
- }
- });
- }
- // Handles sidebar toggler to close/hide the sidebar.
- var handleSidebarToggler = function () {
- var viewport = _getViewPort();
- if ($.cookie('sidebar_closed') === '1' && viewport.width >= 992) {
- $('body').addClass('page-sidebar-closed');
- }
- // handle sidebar show/hide
- $('.page-sidebar, .header').on('click', '.sidebar-toggler', function (e) {
- var body = $('body');
- var sidebar = $('.page-sidebar');
- if ((body.hasClass("page-sidebar-hover-on") && body.hasClass('page-sidebar-fixed')) || sidebar.hasClass('page-sidebar-hovering')) {
- body.removeClass('page-sidebar-hover-on');
- sidebar.css('width', '').hide().show();
- handleSidebarAndContentHeight(); //fix content & sidebar height
- $.cookie('sidebar_closed', '0');
- e.stopPropagation();
- runResponsiveHandlers();
- return;
- }
- $(".sidebar-search", sidebar).removeClass("open");
- if (body.hasClass("page-sidebar-closed")) {
- body.removeClass("page-sidebar-closed");
- if (body.hasClass('page-sidebar-fixed')) {
- sidebar.css('width', '');
- }
- $.cookie('sidebar_closed', '0');
- } else {
- body.addClass("page-sidebar-closed");
- $.cookie('sidebar_closed', '1');
- }
- handleSidebarAndContentHeight(); //fix content & sidebar height
- runResponsiveHandlers();
- });
- // handle the search bar close
- $('.page-sidebar').on('click', '.sidebar-search .remove', function (e) {
- e.preventDefault();
- $('.sidebar-search').removeClass("open");
- });
- // handle the search query submit on enter press
- $('.page-sidebar .sidebar-search').on('keypress', 'input.form-control', function (e) {
- if (e.which == 13) {
- $('.sidebar-search').submit();
- return false; //<---- Add this line
- }
- });
- // handle the search submit(for sidebar search and responsive mode of the header search)
- $('.sidebar-search .submit').on('click', function (e) {
- e.preventDefault();
- if ($('body').hasClass("page-sidebar-closed")) {
- if ($('.sidebar-search').hasClass('open') == false) {
- if ($('.page-sidebar-fixed').size() === 1) {
- $('.page-sidebar .sidebar-toggler').click(); //trigger sidebar toggle button
- }
- $('.sidebar-search').addClass("open");
- } else {
- $('.sidebar-search').submit();
- }
- } else {
- $('.sidebar-search').submit();
- }
- });
- // header search box:
- // handle the search query submit on enter press
- $('.header .search-form').on('keypress', 'input.form-control', function (e) {
- if (e.which == 13) {
- $('.sidebar-search').submit();
- return false; //<---- Add this line
- }
- });
- //handle header search button click
- $('.header .search-form .submit').on('click', function (e) {
- e.preventDefault();
- $('.header .search-form').submit();
- });
- }
- // Handles the horizontal menu
- var handleHorizontalMenu = function () {
- //handle hor menu search form toggler click
- $('.header').on('click', '.hor-menu .hor-menu-search-form-toggler', function (e) {
- if ($(this).hasClass('off')) {
- $(this).removeClass('off');
- $('.header .hor-menu .search-form').hide();
- } else {
- $(this).addClass('off');
- $('.header .hor-menu .search-form').show();
- }
- e.preventDefault();
- });
- //handle tab click
- $('.header').on('click', '.hor-menu a[data-toggle="tab"]', function (e) {
- e.preventDefault();
- var nav = $(".hor-menu .nav");
- var active_link = nav.find('li.current');
- $('li.active', active_link).removeClass("active");
- $('.selected', active_link).remove();
- var new_link = $(this).parents('li').last();
- new_link.addClass("current");
- new_link.find("a:first").append('<span class="selected"></span>');
- });
- //handle hor menu search button click
- $('.header').on('click', '.hor-menu .search-form .btn', function (e) {
- $('.form-search').submit();
- e.preventDefault();
- });
- //handle hor menu search form on enter press
- $('.header').on('keypress', '.hor-menu .search-form input', function (e) {
- if (e.which == 13) {
- $('.form-search').submit();
- return false;
- }
- });
- }
- // Handles the go to top button at the footer
- var handleGoTop = function () {
- /* set variables locally for increased performance */
- jQuery('.footer').on('click', '.go-top', function (e) {
- selectSrchInit.scrollTo();
- e.preventDefault();
- });
- }
- // Handles portlet tools & actions
- var handlePortletTools = function () {
- jQuery('body').on('click', '.portlet > .portlet-title > .tools > a.remove', function (e) {
- e.preventDefault();
- jQuery(this).closest(".portlet").remove();
- });
- jQuery('body').on('click', '.portlet > .portlet-title > .tools > a.reload', function (e) {
- e.preventDefault();
- var el = jQuery(this).closest(".portlet").children(".portlet-body");
- selectSrchInit.blockUI(el);
- window.setTimeout(function () {
- selectSrchInit.unblockUI(el);
- }, 1000);
- });
- jQuery('body').on('click', '.portlet > .portlet-title > .tools > .collapse, .portlet .portlet-title > .tools > .expand', function (e) {
- e.preventDefault();
- var el = jQuery(this).closest(".portlet").children(".portlet-body");
- if (jQuery(this).hasClass("collapse")) {
- jQuery(this).removeClass("collapse").addClass("expand");
- el.slideUp(200);
- } else {
- jQuery(this).removeClass("expand").addClass("collapse");
- el.slideDown(200);
- }
- });
- }
- // Handles custom checkboxes & radios using jQuery Uniform plugin
- var handleUniform = function () {
- if (!jQuery().uniform) {
- return;
- }
- var test = $("input[type=checkbox]:not(.toggle), input[type=radio]:not(.toggle, .star)");
- if (test.size() > 0) {
- test.each(function () {
- if ($(this).parents(".checker").size() == 0) {
- $(this).show();
- $(this).uniform();
- }
- });
- }
- }
- // Handles Bootstrap Accordions.
- var handleAccordions = function () {
- var lastClicked;
- //add scrollable class name if you need scrollable panes
- jQuery('body').on('click', '.accordion.scrollable .accordion-toggle', function () {
- lastClicked = jQuery(this);
- }); //move to faq section
- jQuery('body').on('show.bs.collapse', '.accordion.scrollable', function () {
- jQuery('html,body').animate({
- scrollTop: lastClicked.offset().top - 150
- }, 'slow');
- });
- }
- // Handles Bootstrap Tabs.
- var handleTabs = function () {
- // fix content height on tab click
- $('body').on('shown.bs.tab', '.nav.nav-tabs', function () {
- handleSidebarAndContentHeight();
- });
- //activate tab if tab id provided in the URL
- if (location.hash) {
- var tabid = location.hash.substr(1);
- $('a[href="#' + tabid + '"]').parents('.tab-pane:hidden').each(function(){
- var tabid = $(this).attr("id");
- $('a[href="#' + tabid + '"]').click();
- });
- $('a[href="#' + tabid + '"]').click();
- }
- }
- // Handles Bootstrap Modals.
- var handleModals = function () {
- // fix stackable modal issue: when 2 or more modals opened, closing one of modal will remove .modal-open class.
- $('body').on('hide.bs.modal', function () {
- if ($('.modal:visible').size() > 1 && $('html').hasClass('modal-open') == false) {
- $('html').addClass('modal-open');
- } else if ($('.modal:visible').size() <= 1) {
- $('html').removeClass('modal-open');
- }
- });
-
- $('body').on('show.bs.modal', '.modal', function () {
- if ($(this).hasClass("modal-scroll")) {
- $('body').addClass("modal-open-noscroll");
- }
- });
- $('body').on('hide.bs.modal', '.modal', function () {
- $('body').removeClass("modal-open-noscroll");
- });
- }
- // Handles Bootstrap Tooltips.
- var handleTooltips = function () {
- //jQuery('.tooltips').tooltip();
- }
- // Handles Bootstrap Dropdowns
- var handleDropdowns = function () {
- /*
- For touch supported devices disable the
- hoverable dropdowns - data-hover="dropdown"
- */
- if (selectSrchInit.isTouchDevice()) {
- $('[data-hover="dropdown"]').each(function(){
- $(this).parent().off("hover");
- $(this).off("hover");
- });
- }
- /*
- Hold dropdown on click
- */
- $('body').on('click', '.dropdown-menu.hold-on-click', function (e) {
- e.stopPropagation();
- });
- }
- // Handle Hower Dropdowns
- var handleDropdownHover = function () {
- $('[data-hover="dropdown"]').dropdownHover();
- }
- var handleAlerts = function () {
- $('body').on('click', '[data-close="alert"]', function(e){
- $(this).parent('.alert').hide();
- e.preventDefault();
- });
- }
- // Handles Bootstrap Popovers
- // last popep popover
- var lastPopedPopover;
- var handlePopovers = function () {
- //jQuery('.popovers').popover();
- // close last poped popover
- $(document).on('click.bs.popover.data-api', function (e) {
- if (lastPopedPopover) {
- lastPopedPopover.popover('hide');
- }
- });
- }
- // Handles scrollable contents using jQuery SlimScroll plugin.
- var handleScrollers = function () {
- $('.scroller').each(function () {
- var height;
- if ($(this).attr("data-height")) {
- height = $(this).attr("data-height");
- } else {
- height = $(this).css('height');
- }
- $(this).slimScroll({
- size: '7px',
- color: ($(this).attr("data-handle-color") ? $(this).attr("data-handle-color") : '#a1b2bd'),
- railColor: ($(this).attr("data-rail-color") ? $(this).attr("data-rail-color") : '#333'),
- position: isRTL ? 'left' : 'right',
- height: height,
- alwaysVisible: ($(this).attr("data-always-visible") == "1" ? true : false),
- railVisible: ($(this).attr("data-rail-visible") == "1" ? true : false),
- disableFadeOut: true
- });
- });
- }
- // Handles Image Preview using jQuery Fancybox plugin
- var handleFancybox = function () {
- if (!jQuery.fancybox) {
- return;
- }
- if (jQuery(".fancybox-button").size() > 0) {
- jQuery(".fancybox-button").fancybox({
- groupAttr: 'data-rel',
- prevEffect: 'none',
- nextEffect: 'none',
- closeBtn: true,
- helpers: {
- title: {
- type: 'inside'
- }
- }
- });
- }
- }
- // Fix input placeholder issue for IE8 and IE9
- var handleFixInputPlaceholderForIE = function () {
- //fix html5 placeholder attribute for ie7 & ie8
- if (isIE8 || isIE9) { // ie8 & ie9
- // this is html5 placeholder fix for inputs, inputs with placeholder-no-fix class will be skipped(e.g: we need this for password fields)
- jQuery('input[placeholder]:not(.placeholder-no-fix), textarea[placeholder]:not(.placeholder-no-fix)').each(function () {
- var input = jQuery(this);
- if (input.val() == '' && input.attr("placeholder") != '') {
- input.addClass("placeholder").val(input.attr('placeholder'));
- }
- input.focus(function () {
- if (input.val() == input.attr('placeholder')) {
- input.val('');
- }
- });
- input.blur(function () {
- if (input.val() == '' || input.val() == input.attr('placeholder')) {
- input.val(input.attr('placeholder'));
- }
- });
- });
- }
- }
- // Handle full screen mode toggle
- var handleFullScreenMode = function() {
- // mozfullscreenerror event handler
-
- // toggle full screen
- function toggleFullScreen() {
- if (!document.fullscreenElement && // alternative standard method
- !document.mozFullScreenElement && !document.webkitFullscreenElement) { // current working methods
- if (document.documentElement.requestFullscreen) {
- document.documentElement.requestFullscreen();
- } else if (document.documentElement.mozRequestFullScreen) {
- document.documentElement.mozRequestFullScreen();
- } else if (document.documentElement.webkitRequestFullscreen) {
- document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
- }
- } else {
- if (document.cancelFullScreen) {
- document.cancelFullScreen();
- } else if (document.mozCancelFullScreen) {
- document.mozCancelFullScreen();
- } else if (document.webkitCancelFullScreen) {
- document.webkitCancelFullScreen();
- }
- }
- }
- $('#trigger_fullscreen').click(function() {
- toggleFullScreen();
- });
- }
- // Handle Select2 Dropdowns
- var handleSelect2 = function() {
- if (jQuery().selectSrchFun) {
- $('.sp-select-srch').selectSrchFun({
- placeholder: "Select",
- allowClear: true
- });
- }
- }
- // Handle Theme Settings
- var handleTheme = function () {
- var panel = $('.theme-panel');
- if ($('body').hasClass('page-boxed') == false) {
- $('.layout-option', panel).val("fluid");
- }
- $('.sidebar-option', panel).val("default");
- $('.header-option', panel).val("fixed");
- $('.footer-option', panel).val("default");
- if ( $('.sidebar-pos-option').attr("disabled") === false) {
- $('.sidebar-pos-option', panel).val(selectSrchInit.isRTL() ? 'right' : 'left');
- }
-
- //handle theme layout
- var resetLayout = function () {
- $("body").
- removeClass("page-boxed").
- removeClass("page-footer-fixed").
- removeClass("page-sidebar-fixed").
- removeClass("page-header-fixed").
- removeClass("page-sidebar-reversed");
- $('.header > .header-inner').removeClass("container");
- if ($('.page-container').parent(".container").size() === 1) {
- $('.page-container').insertAfter('body > .clearfix');
- }
- if ($('.footer > .container').size() === 1) {
- $('.footer').html($('.footer > .container').html());
- } else if ($('.footer').parent(".container").size() === 1) {
- $('.footer').insertAfter('.page-container');
- }
- $('body > .container').remove();
- }
- var lastSelectedLayout = '';
- var setLayout = function () {
- var layoutOption = $('.layout-option', panel).val();
- var sidebarOption = $('.sidebar-option', panel).val();
- var headerOption = $('.header-option', panel).val();
- var footerOption = $('.footer-option', panel).val();
- var sidebarPosOption = $('.sidebar-pos-option', panel).val();
- if (sidebarOption == "fixed" && headerOption == "default") {
- alert('Default Header with Fixed Sidebar option is not supported. Proceed with Fixed Header with Fixed Sidebar.');
- $('.header-option', panel).val("fixed");
- $('.sidebar-option', panel).val("fixed");
- sidebarOption = 'fixed';
- headerOption = 'fixed';
- }
- resetLayout(); // reset layout to default state
- if (layoutOption === "boxed") {
- $("body").addClass("page-boxed");
- // set header
- $('.header > .header-inner').addClass("container");
- var cont = $('body > .clearfix').after('<div class="container"></div>');
- // set content
- $('.page-container').appendTo('body > .container');
- // set footer
- if (footerOption === 'fixed') {
- $('.footer').html('<div class="container">' + $('.footer').html() + '</div>');
- } else {
- $('.footer').appendTo('body > .container');
- }
- }
- if (lastSelectedLayout != layoutOption) {
- //layout changed, run responsive handler:
- runResponsiveHandlers();
- }
- lastSelectedLayout = layoutOption;
- //header
- if (headerOption === 'fixed') {
- $("body").addClass("page-header-fixed");
- $(".header").removeClass("navbar-static-top").addClass("navbar-fixed-top");
- } else {
- $("body").removeClass("page-header-fixed");
- $(".header").removeClass("navbar-fixed-top").addClass("navbar-static-top");
- }
- //sidebar
- if (sidebarOption === 'fixed') {
- $("body").addClass("page-sidebar-fixed");
- } else {
- $("body").removeClass("page-sidebar-fixed");
- }
- //footer
- if (footerOption === 'fixed') {
- $("body").addClass("page-footer-fixed");
- } else {
- $("body").removeClass("page-footer-fixed");
- }
- //sidebar position
- if (selectSrchInit.isRTL()) {
- if (sidebarPosOption === 'left') {
- $("body").addClass("page-sidebar-reversed");
- $('#frontend-link').tooltip('destroy').tooltip({placement: 'right'});
- } else {
- $("body").removeClass("page-sidebar-reversed");
- $('#frontend-link').tooltip('destroy').tooltip({placement: 'left'});
- }
- } else {
- if (sidebarPosOption === 'right') {
- $("body").addClass("page-sidebar-reversed");
- $('#frontend-link').tooltip('destroy').tooltip({placement: 'left'});
- } else {
- $("body").removeClass("page-sidebar-reversed");
- $('#frontend-link').tooltip('destroy').tooltip({placement: 'right'});
- }
- }
- handleSidebarAndContentHeight(); // fix content height
- handleFixedSidebar(); // reinitialize fixed sidebar
- handleFixedSidebarHoverable(); // reinitialize fixed sidebar hover effect
- }
- // handle theme colors
- var setColor = function (color) {
- var color_ = (selectSrchInit.isRTL() ? color + '-rtl' : color);
- $('#style_color').attr("href", "assets/css/themes/" + color_ + ".css");
- $.cookie('style_color', color);
- }
- $('.toggler', panel).click(function () {
- $('.toggler').hide();
- $('.toggler-close').show();
- $('.theme-panel > .theme-options').show();
- });
- $('.toggler-close', panel).click(function () {
- $('.toggler').show();
- $('.toggler-close').hide();
- $('.theme-panel > .theme-options').hide();
- });
- $('.theme-colors > ul > li', panel).click(function () {
- var color = $(this).attr("data-style");
- setColor(color);
- $('ul > li', panel).removeClass("current");
- $(this).addClass("current");
- });
- $('.layout-option, .header-option, .sidebar-option, .footer-option, .sidebar-pos-option', panel).change(setLayout);
- if ($.cookie('style_color')) {
- setColor($.cookie('style_color'));
- }
- }
- //* END:CORE HANDLERS *//
- return {
- //main function to initiate the theme
- init: function () {
- //IMPORTANT!!!: Do not modify the core handlers call order.
- //core handlers
- handleInit(); // initialize core variables
- handleResponsiveOnResize(); // set and handle responsive
- handleUniform(); // hanfle custom radio & checkboxes
- handleScrollers(); // handles slim scrolling contents
- handleResponsiveOnInit(); // handler responsive elements on page load
- //layout handlers
- handleFixedSidebar(); // handles fixed sidebar menu
- handleFixedSidebarHoverable(); // handles fixed sidebar on hover effect
- handleSidebarMenu(); // handles main menu
- handleHorizontalMenu(); // handles horizontal menu
- handleSidebarToggler(); // handles sidebar hide/show
- handleFixInputPlaceholderForIE(); // fixes/enables html5 placeholder attribute for IE9, IE8
- handleGoTop(); //handles scroll to top functionality in the footer
- handleTheme(); // handles style customer tool
- //ui component handlers
- handleFancybox() // handle fancy box
- handleSelect2(); // handle custom Select2 dropdowns
- handlePortletTools(); // handles portlet action bar functionality(refresh, configure, toggle, remove)
- handleAlerts(); //handle closabled alerts
- handleDropdowns(); // handle dropdowns
- handleTabs(); // handle tabs
- handleTooltips(); // handle bootstrap tooltips
- handlePopovers(); // handles bootstrap popovers
- handleAccordions(); //handles accordions
- handleModals(); // handle modals
- handleFullScreenMode(); // handles full screen
- },
- //main function to initiate core javascript after ajax complete
- initAjax: function () {
- handleSelect2(); // handle custom Select2 dropdowns
- handleDropdowns(); // handle dropdowns
- handleTooltips(); // handle bootstrap tooltips
- handlePopovers(); // handles bootstrap popovers
- handleAccordions(); //handles accordions
- handleUniform(); // hanfle custom radio & checkboxes
- handleDropdownHover() // handles dropdown hover
- },
- //public function to fix the sidebar and content height accordingly
- fixContentHeight: function () {
- handleSidebarAndContentHeight();
- },
- //public function to remember last opened popover that needs to be closed on click
- setLastPopedPopover: function (el) {
- lastPopedPopover = el;
- },
- //public function to add callback a function which will be called on window resize
- addResponsiveHandler: function (func) {
- responsiveHandlers.push(func);
- },
- // useful function to make equal height for contacts stand side by side
- setEqualHeight: function (els) {
- var tallestEl = 0;
- els = jQuery(els);
- els.each(function () {
- var currentHeight = $(this).height();
- if (currentHeight > tallestEl) {
- tallestColumn = currentHeight;
- }
- });
- els.height(tallestEl);
- },
- // wrapper function to scroll(focus) to an element
- scrollTo: function (el, offeset) {
- pos = (el && el.size() > 0) ? el.offset().top : 0;
- jQuery('html,body').animate({
- scrollTop: pos + (offeset ? offeset : 0)
- }, 'slow');
- },
- // function to scroll to the top
- scrollTop: function () {
- selectSrchInit.scrollTo();
- },
- // wrapper function to block element(indicate loading)
- blockUI: function (el, centerY) {
- var el = jQuery(el);
- if (el.height() <= 400) {
- centerY = true;
- }
- el.block({
- message: '<img src="./assets/img/ajax-loading.gif" align="">',
- centerY: centerY != undefined ? centerY : true,
- css: {
- top: '10%',
- border: 'none',
- padding: '2px',
- backgroundColor: 'none'
- },
- overlayCSS: {
- backgroundColor: '#000',
- opacity: 0.05,
- cursor: 'wait'
- }
- });
- },
- // wrapper function to un-block element(finish loading)
- unblockUI: function (el, clean) {
- jQuery(el).unblock({
- onUnblock: function () {
- jQuery(el).css('position', '');
- jQuery(el).css('zoom', '');
- }
- });
- },
- // initializes uniform elements
- initUniform: function (els) {
- if (els) {
- jQuery(els).each(function () {
- if ($(this).parents(".checker").size() == 0) {
- $(this).show();
- $(this).uniform();
- }
- });
- } else {
- handleUniform();
- }
- },
- //wrapper function to update/sync jquery uniform checkbox & radios
- updateUniform: function (els) {
- $.uniform.update(els); // update the uniform checkbox & radios UI after the actual input control state changed
- },
- //public function to initialize the fancybox plugin
- initFancybox: function () {
- handleFancybox();
- },
- //public helper function to get actual input value(used in IE9 and IE8 due to placeholder attribute not supported)
- getActualVal: function (el) {
- var el = jQuery(el);
- if (el.val() === el.attr("placeholder")) {
- return "";
- }
- return el.val();
- },
- //public function to get a paremeter by name from URL
- getURLParameter: function (paramName) {
- var searchString = window.location.search.substring(1),
- i, val, params = searchString.split("&");
- for (i = 0; i < params.length; i++) {
- val = params[i].split("=");
- if (val[0] == paramName) {
- return unescape(val[1]);
- }
- }
- return null;
- },
- // check for device touch support
- isTouchDevice: function () {
- try {
- document.createEvent("TouchEvent");
- return true;
- } catch (e) {
- return false;
- }
- },
- // check IE8 mode
- isIE8: function () {
- return isIE8;
- },
- // check IE9 mode
- isIE9: function () {
- return isIE9;
- },
- //check RTL mode
- isRTL: function () {
- return isRTL;
- },
- // get layout color code by color name
- getLayoutColorCode: function (name) {
- if (layoutColorCodes[name]) {
- return layoutColorCodes[name];
- } else {
- return '';
- }
- }
- };
- }();
|