123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890 |
- /**
- Core script to handle the entire layout and base functions
- **/
- var App = 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'
- };
- 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/);
-
- if (isIE10) {
- jQuery('html').addClass('ie10'); // detect IE10 version
- }
- }
- var handleDesktopTabletContents = function () {
- // loops all page elements with "responsive" class and applies classes for tablet mode
- // For metornic 1280px or less set as tablet mode to display the content properly
- if ($(window).width() <= 1280 || $('body').hasClass('page-boxed')) {
- $(".responsive").each(function () {
- var forTablet = $(this).attr('data-tablet');
- var forDesktop = $(this).attr('data-desktop');
- if (forTablet) {
- $(this).removeClass(forDesktop);
- $(this).addClass(forTablet);
- }
- });
- }
- // loops all page elements with "responsive" class and applied classes for desktop mode
- // For metornic higher 1280px set as desktop mode to display the content properly
- if ($(window).width() > 1280 && $('body').hasClass('page-boxed') === false) {
- $(".responsive").each(function () {
- var forTablet = $(this).attr('data-tablet');
- var forDesktop = $(this).attr('data-desktop');
- if (forTablet) {
- $(this).removeClass(forTablet);
- $(this).addClass(forDesktop);
- }
- });
- }
- }
- var handleSidebarState = function () {
- // remove sidebar toggler if window width smaller than 900(for table and phone mode)
- if ($(window).width() < 980) {
- $('body').removeClass("page-sidebar-closed");
- }
- }
- var runResponsiveHandlers = function () {
- // reinitialize other subscribed elements
- for (var i in responsiveHandlers) {
- var each = responsiveHandlers[i];
- each.call();
- }
- }
- var handleResponsive = function () {
- handleTooltips();
- handleSidebarState();
- handleDesktopTabletContents();
- handleSidebarAndContentHeight();
- handleChoosenSelect();
- handleFixedSidebar();
- runResponsiveHandlers();
- }
- var handleResponsiveOnInit = function () {
- handleSidebarState();
- handleDesktopTabletContents();
- handleSidebarAndContentHeight();
- }
- 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() {
- console.log('resize');
- handleResponsive();
- }, 50); // wait 50ms until window resize finishes.
- });
- }
- }
- //* BEGIN:CORE HANDLERS *//
- // this function handles responsive layout on screen size resize or mobile device rotate.
-
- 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').height();
- 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');
- }
- }
- }
- 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;
- }
- var parent = $(this).parent().parent();
- 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();
- if (sub.is(":visible")) {
- jQuery('.arrow', jQuery(this)).removeClass("open");
- jQuery(this).parent().removeClass("open");
- sub.slideUp(200, function () {
- handleSidebarAndContentHeight();
- });
- } else {
- jQuery('.arrow', jQuery(this)).addClass("open");
- jQuery(this).parent().addClass("open");
- sub.slideDown(200, function () {
- handleSidebarAndContentHeight();
- });
- }
- e.preventDefault();
- });
- // handle ajax links
- jQuery('.page-sidebar').on('click', ' li > a.ajaxify', function (e) {
- e.preventDefault();
- App.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');
- App.blockUI(pageContent, false);
- $.post(url, {}, function (res) {
- App.unblockUI(pageContent);
- pageContentBody.html(res);
- App.fixContentHeight(); // fix content height
- App.initUniform(); // initialize uniform elements
- });
- });
- }
- var _calculateFixedSidebarViewportHeight = function () {
- var sidebarHeight = $(window).height() - $('.header').height() + 1;
- if ($('body').hasClass("page-footer-fixed")) {
- sidebarHeight = sidebarHeight - $('.footer').height();
- }
- return sidebarHeight;
- }
- 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;
- }
- if ($(window).width() >= 980) {
- var sidebarHeight = _calculateFixedSidebarViewportHeight();
- menu.slimScroll({
- size: '7px',
- color: '#a1b2bd',
- opacity: .3,
- position: isRTL ? 'left' : ($('.page-sidebar-on-right').size() === 1 ? 'left' : 'right'),
- height: sidebarHeight,
- allowPageScroll: false,
- disableFadeOut: false
- });
- handleSidebarAndContentHeight();
- }
- }
- 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');
- $(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;
- }
- $(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');
- });
- });
- }
- var handleSidebarToggler = function () {
- // handle sidebar show/hide
- $('.page-sidebar').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();
- 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', '');
- }
- } else {
- body.addClass("page-sidebar-closed");
- }
- 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').on('keypress', '.sidebar-search input', function (e) {
- if (e.which == 13) {
- window.location.href = "extra_search.html";
- return false; //<---- Add this line
- }
- });
- // handle the search submit
- $('.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 {
- window.location.href = "extra_search.html";
- }
- } else {
- window.location.href = "extra_search.html";
- }
- });
- }
- 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('hide')) {
- $(this).removeClass('hide');
- $('.header .hor-menu .search-form').hide();
- } else {
- $(this).addClass('hide');
- $('.header .hor-menu .search-form').show();
- }
- e.preventDefault();
- });
- //handle hor menu search button click
- $('.header').on('click', '.hor-menu .search-form .btn', function (e) {
- window.location.href = "extra_search.html";
- e.preventDefault();
- });
- //handle hor menu search form on enter press
- $('.header').on('keypress', '.hor-menu .search-form input', function (e) {
- if (e.which == 13) {
- window.location.href = "extra_search.html";
- return false;
- }
- });
- }
- var handleGoTop = function () {
- /* set variables locally for increased performance */
- jQuery('.footer').on('click', '.go-top', function (e) {
- App.scrollTo();
- e.preventDefault();
- });
- }
- var handlePortletTools = function () {
- jQuery('body').on('click', '.portlet .tools a.remove', function (e) {
- e.preventDefault();
- var removable = jQuery(this).parents(".portlet");
- if (removable.next().hasClass('portlet') || removable.prev().hasClass('portlet')) {
- jQuery(this).parents(".portlet").remove();
- } else {
- jQuery(this).parents(".portlet").parent().remove();
- }
- });
- jQuery('body').on('click', '.portlet .tools a.reload', function (e) {
- e.preventDefault();
- var el = jQuery(this).parents(".portlet");
- App.blockUI(el);
- window.setTimeout(function () {
- App.unblockUI(el);
- }, 1000);
- });
- jQuery('body').on('click', '.portlet .tools .collapse, .portlet .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);
- }
- });
- }
- 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();
- }
- });
- }
- }
- var handleAccordions = function () {
- $(".accordion").collapse().height('auto');
- 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('shown', '.accordion.scrollable', function () {
- jQuery('html,body').animate({
- scrollTop: lastClicked.offset().top - 150
- }, 'slow');
- });
- }
- var handleTabs = function () {
- // function to fix left/right tab contents
- var fixTabHeight = function(tab) {
- $(tab).each(function() {
- var content = $($($(this).attr("href")));
- var tab = $(this).parent().parent();
- if (tab.height() > content.height()) {
- content.css('min-height', tab.height());
- }
- });
- }
- // fix tab content on tab shown
- $('body').on('shown', '.nav.nav-tabs.tabs-left a[data-toggle="tab"], .nav.nav-tabs.tabs-right a[data-toggle="tab"]', function(){
- fixTabHeight($(this));
- });
- $('body').on('shown', '.nav.nav-tabs', function(){
- handleSidebarAndContentHeight();
- });
- //fix tab contents for left/right tabs
- fixTabHeight('.nav.nav-tabs.tabs-left > li.active > a[data-toggle="tab"], .nav.nav-tabs.tabs-right > li.active > a[data-toggle="tab"]');
- //activate tab if tab id provided in the URL
- if(location.hash) {
- var tabid = location.hash.substr(1);
- $('a[href="#'+tabid+'"]').click();
- }
- }
- var handleScrollers = function () {
- $('.scroller').each(function () {
- $(this).slimScroll({
- size: '7px',
- color: '#a1b2bd',
- position: isRTL ? 'left' : 'right',
- height: $(this).attr("data-height"),
- alwaysVisible: ($(this).attr("data-always-visible") == "1" ? true : false),
- railVisible: ($(this).attr("data-rail-visible") == "1" ? true : false),
- disableFadeOut: true
- });
- });
- }
- var handleTooltips = function () {
- if (App.isTouchDevice()) { // if touch device, some tooltips can be skipped in order to not conflict with click events
- jQuery('.tooltips:not(.no-tooltip-on-touch-device)').tooltip();
- } else {
- jQuery('.tooltips').tooltip();
- }
- }
- var handleDropdowns = function () {
- $('body').on('click', '.dropdown-menu.hold-on-click', function(e){
- e.stopPropagation();
- })
- }
- var handlePopovers = function () {
- jQuery('.popovers').popover();
- }
- var handleChoosenSelect = function () {
- if (!jQuery().chosen) {
- return;
- }
- $(".chosen").each(function () {
- $(this).chosen({
- allow_single_deselect: $(this).attr("data-with-diselect") === "1" ? true : false
- });
- });
- }
- 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'
- }
- }
- });
- }
- }
- var handleTheme = function () {
- var panel = $('.color-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");
- //handle theme layout
- var resetLayout = function () {
- $("body").
- removeClass("page-boxed").
- removeClass("page-footer-fixed").
- removeClass("page-sidebar-fixed").
- removeClass("page-header-fixed");
- $('.header > .navbar-inner > .container').removeClass("container").addClass("container-fluid");
- if ($('.page-container').parent(".container").size() === 1) {
- $('.page-container').insertAfter('.header');
- }
- 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();
- if (sidebarOption == "fixed" && headerOption == "default") {
- alert('Default Header with Fixed Sidebar option is not supported. Proceed with Default Header with Default Sidebar.');
- $('.sidebar-option', panel).val("default");
- sidebarOption = 'default';
- }
- resetLayout(); // reset layout to default state
- if (layoutOption === "boxed") {
- $("body").addClass("page-boxed");
- // set header
- $('.header > .navbar-inner > .container-fluid').removeClass("container-fluid").addClass("container");
- var cont = $('.header').after('<div class="container"></div>');
- // set content
- $('.page-container').appendTo('body > .container');
- // set footer
- if (footerOption === 'fixed' || sidebarOption === 'default') {
- $('.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");
- }
- handleSidebarAndContentHeight(); // fix content height
- handleFixedSidebar(); // reinitialize fixed sidebar
- handleFixedSidebarHoverable(); // reinitialize fixed sidebar hover effect
- }
- // handle theme colors
- var setColor = function (color) {
- $('#style_color').attr("href", "assets/css/themes/" + color + ".css");
- $.cookie('style_color', color);
- }
- $('.icon-color', panel).click(function () {
- $('.color-mode').show();
- $('.icon-color-close').show();
- });
- $('.icon-color-close', panel).click(function () {
- $('.color-mode').hide();
- $('.icon-color-close').hide();
- });
- $('li', panel).click(function () {
- var color = $(this).attr("data-style");
- setColor(color);
- $('.inline li', panel).removeClass("current");
- $(this).addClass("current");
- });
- $('.layout-option, .header-option, .sidebar-option, .footer-option', panel).change(setLayout);
- }
- var handleFixInputPlaceholderForIE = function () {
- //fix html5 placeholder attribute for ie7 & ie8
- if (isIE8 || isIE9) { // ie7&ie8
- // 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'));
- }
- });
- });
- }
- }
- //* END:CORE HANDLERS *//
- return {
- //main function to initiate template pages
- init: function () {
- //IMPORTANT!!!: Do not modify the core handlers call order.
- //core handlers
- handleInit();
- handleResponsiveOnResize(); // set and handle responsive
- handleUniform();
- 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
- handlePortletTools(); // handles portlet action bar functionality(refresh, configure, toggle, remove)
- handleDropdowns(); // handle dropdowns
- handleTabs(); // handle tabs
- handleTooltips(); // handle bootstrap tooltips
- handlePopovers(); // handles bootstrap popovers
- handleAccordions(); //handles accordions
- handleChoosenSelect(); // handles bootstrap chosen dropdowns
- App.addResponsiveHandler(handleChoosenSelect); // reinitiate chosen dropdown on main content resize. disable this line if you don't really use chosen dropdowns.
- },
- fixContentHeight: function () {
- handleSidebarAndContentHeight();
- },
- 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 to an element
- scrollTo: function (el, offeset) {
- pos = el ? el.offset().top : 0;
- jQuery('html,body').animate({
- scrollTop: pos + (offeset ? offeset : 0)
- }, 'slow');
- },
- scrollTop: function () {
- App.scrollTo();
- },
- // wrapper function to block element(indicate loading)
- blockUI: function (el, centerY) {
- var el = jQuery(el);
- 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) {
- jQuery(el).unblock({
- onUnblock: function () {
- jQuery(el).removeAttr("style");
- }
- });
- },
- // initializes uniform elements
- initUniform: function (els) {
- if (els) {
- jQuery(els).each(function () {
- if ($(this).parents(".checker").size() == 0) {
- $(this).show();
- $(this).uniform();
- }
- });
- } else {
- handleUniform();
- }
- },
- // initializes choosen dropdowns
- initChosenSelect: function (els) {
- $(els).chosen({
- allow_single_deselect: true
- });
- },
- initFancybox: function () {
- handleFancybox();
- },
- getActualVal: function (el) {
- var el = jQuery(el);
- if (el.val() === el.attr("placeholder")) {
- return "";
- }
- return el.val();
- },
- 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;
- }
- },
- isIE8: function () {
- return isIE8;
- },
- isRTL: function () {
- return isRTL;
- },
- getLayoutColorCode: function (name) {
- if (layoutColorCodes[name]) {
- return layoutColorCodes[name];
- } else {
- return '';
- }
- }
- };
- }();
|