var App = function () { var isIE8 = false; // IE8 mode var isIE9 = false; var currentPage = ''; // current page // useful function to make equal height for contacts stand side by side var setEqualHeight = function (columns) { var tallestColumn = 0; columns = jQuery(columns); columns.each(function () { var currentHeight = $(this).height(); if (currentHeight > tallestColumn) { tallestColumn = currentHeight; } }); columns.height(tallestColumn); } // this function handles responsive layout on screen size resize or mobile device rotate. var handleResponsive = function () { if (jQuery.browser.msie && jQuery.browser.version.substr(0, 1) == 8) { isIE8 = true; // checkes for IE8 browser version $('.visible-ie8').show(); // } if (jQuery.browser.msie && jQuery.browser.version.substr(0, 1) == 9) { isIE9 = true; } var isIE10 = !! navigator.userAgent.match(/MSIE 10/); if (isIE10) { jQuery('html').addClass('ie10'); // set ie10 class on html element. } // loops all page elements with "responsive" class and applied classes for tablet mode // For metornic 1280px or less set as tablet mode to display the content properly var handleTabletElements = function () { if ($(window).width() <= 1280) { $(".responsive").each(function () { var forTablet = $(this).attr('data-tablet'); var forDesktop = $(this).attr('data-desktop'); if (forTablet) { $(this).removeClass(forDesktop); $(this).addClass(forTablet); } }); handleTooltip(); } } // 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 var handleDesktopElements = function () { if ($(window).width() > 1280) { $(".responsive").each(function () { var forTablet = $(this).attr('data-tablet'); var forDesktop = $(this).attr('data-desktop'); if (forTablet) { $(this).removeClass(forTablet); $(this).addClass(forDesktop); } }); handleTooltip(); } } // handle all elements which require to re-initialize on screen width change(on resize or on rotate mobile device) var handleElements = function () { if ($(window).width() < 900) { // remove sidebar toggler $.cookie('sidebar-closed', null); $('.page-container').removeClass("sidebar-closed"); } handleTabletElements(); handleDesktopElements(); } // handles responsive breakpoints. $(window).setBreakpoints({ breakpoints: [320, 480, 768, 900, 1024, 1280] }); $(window).bind('exitBreakpoint320', function () { handleElements(); }); $(window).bind('enterBreakpoint320', function () { handleElements(); }); $(window).bind('exitBreakpoint480', function () { handleElements(); }); $(window).bind('enterBreakpoint480', function () { handleElements(); }); $(window).bind('exitBreakpoint768', function () { handleElements(); }); $(window).bind('enterBreakpoint768', function () { handleElements(); }); $(window).bind('exitBreakpoint900', function () { handleElements(); }); $(window).bind('enterBreakpoint900', function () { handleElements(); }); $(window).bind('exitBreakpoint1024', function () { handleElements(); }); $(window).bind('enterBreakpoint1024', function () { handleElements(); }); $(window).bind('exitBreakpoint1280', function () { handleElements(); }); $(window).bind('enterBreakpoint1280', function () { handleElements(); }); } var handleMainMenu = function () { jQuery('.page-sidebar .has-sub > a').click(function () { var handleContentHeight = function () { var content = $('.page-content'); var sidebar = $('.page-sidebar'); if (!content.attr("data-height")) { content.attr("data-height", content.height()); } if (sidebar.height() > content.height()) { content.css("min-height", sidebar.height() + 20); } else { content.css("min-height", content.attr("data-height")); } } var last = jQuery('.has-sub.open', $('.page-sidebar')); if (last.size() == 0) { //last = jQuery('.has-sub.active', $('.page-sidebar')); } last.removeClass("open"); jQuery('.arrow', last).removeClass("open"); jQuery('.sub', last).slideUp(200); var sub = jQuery(this).next(); if (sub.is(":visible")) { jQuery('.arrow', jQuery(this)).removeClass("open"); jQuery(this).parent().removeClass("open"); sub.slideUp(200, function () { handleContentHeight(); }); } else { jQuery('.arrow', jQuery(this)).addClass("open"); jQuery(this).parent().addClass("open"); sub.slideDown(200, function () { handleContentHeight(); }); } }); } var handleSidebarToggler = function () { var container = $(".page-container"); if ($.cookie('sidebar-closed') == 1) { container.addClass("sidebar-closed"); } // handle sidebar show/hide $('.page-sidebar .sidebar-toggler').click(function () { $(".sidebar-search").removeClass("open"); var container = $(".page-container"); if (container.hasClass("sidebar-closed") === true) { container.removeClass("sidebar-closed"); $.cookie('sidebar-closed', null); } else { container.addClass("sidebar-closed"); $.cookie('sidebar-closed', 1); } if (App.isPage("charts")) { setTimeout(function () { handleChartGraphs(); }, 100); } }); // handle the search bar close $('.sidebar-search .remove').click(function () { $('.sidebar-search').removeClass("open"); }); // handle the search query submit on enter press $('.sidebar-search input').keypress(function (e) { if (e.which == 13) { window.location.href = "extra_search.html"; return false; //<---- Add this line } }); // handle the search submit $('.sidebar-search .submit').click(function () { if ($('.page-container').hasClass("sidebar-closed")) { if ($('.sidebar-search').hasClass('open') == false) { $('.sidebar-search').addClass("open"); } else { window.location.href = "extra_search.html"; } } else { window.location.href = "extra_search.html"; } }); } var handlePortletTools = function () { jQuery('.portlet .tools a.remove').click(function () { 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('.portlet .tools a.reload').click(function () { var el = jQuery(this).parents(".portlet"); App.blockUI(el); window.setTimeout(function () { App.unblockUI(el); }, 1000); }); jQuery('.portlet .tools .collapse, .portlet .tools .expand').click(function () { var el = jQuery(this).parents(".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); } }); /* sample code to handle portlet config popup on close $('#portlet-config').on('hide', function (e) { //alert(1); //if (!data) return e.preventDefault() // stops modal from being shown }); */ } var handlePortletSortable = function () { if (!jQuery().sortable) { return; } $("#sortable_portlets").sortable({ connectWith: ".portlet", items: ".portlet", opacity: 0.8, coneHelperSize: true, placeholder: 'sortable-box-placeholder round-all', forcePlaceholderSize: true, tolerance: "pointer" }); $(".column").disableSelection(); } 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 handleLoginForm = function () { $('.login-form').validate({ errorElement: 'label', //default input error message container errorClass: 'help-inline', // default input error message class focusInvalid: false, // do not focus the last invalid input rules: { username: { required: true }, password: { required: true }, remember: { required: false } }, messages: { username: { required: "Username is required." }, password: { required: "Password is required." } }, invalidHandler: function (event, validator) { //display error alert on form submit $('.alert-error', $('.login-form')).show(); }, highlight: function (element) { // hightlight error inputs $(element) .closest('.control-group').addClass('error'); // set error class to the control group }, success: function (label) { label.closest('.control-group').removeClass('error'); label.remove(); }, errorPlacement: function (error, element) { error.addClass('help-small no-left-padding').insertAfter(element.closest('.input-icon')); }, submitHandler: function (form) { window.location.href = "index.html"; } }); $('.login-form input').keypress(function (e) { if (e.which == 13) { if ($('.login-form').validate().form()) { window.location.href = "index.html"; } return false; } }); $('.forget-form').validate({ errorElement: 'label', //default input error message container errorClass: 'help-inline', // default input error message class focusInvalid: false, // do not focus the last invalid input ignore: "", rules: { email: { required: true, email: true } }, messages: { email: { required: "Email is required." } }, invalidHandler: function (event, validator) { //display error alert on form submit }, highlight: function (element) { // hightlight error inputs $(element) .closest('.control-group').addClass('error'); // set error class to the control group }, success: function (label) { label.closest('.control-group').removeClass('error'); label.remove(); }, errorPlacement: function (error, element) { error.addClass('help-small no-left-padding').insertAfter(element.closest('.input-icon')); }, submitHandler: function (form) { window.location.href = "index.html"; } }); $('.forget-form input').keypress(function (e) { if (e.which == 13) { if ($('.forget-form').validate().form()) { window.location.href = "index.html"; } return false; } }); jQuery('#forget-password').click(function () { jQuery('.login-form').hide(); jQuery('.forget-form').show(); }); jQuery('#back-btn').click(function () { jQuery('.login-form').show(); jQuery('.forget-form').hide(); }); $('.register-form').validate({ errorElement: 'label', //default input error message container errorClass: 'help-inline', // default input error message class focusInvalid: false, // do not focus the last invalid input ignore: "", rules: { username: { required: true }, password: { required: true }, rpassword: { equalTo: "#register_password" }, email: { required: true, email: true }, tnc: { required: true } }, messages: { // custom messages for radio buttons and checkboxes tnc: { required: "Please accept TNC first." } }, invalidHandler: function (event, validator) { //display error alert on form submit }, highlight: function (element) { // hightlight error inputs $(element) .closest('.control-group').addClass('error'); // set error class to the control group }, success: function (label) { label.closest('.control-group').removeClass('error'); label.remove(); }, errorPlacement: function (error, element) { if (element.attr("name") == "tnc") { // insert checkbox errors after the container error.addClass('help-small no-left-padding').insertAfter($('#register_tnc_error')); } else { error.addClass('help-small no-left-padding').insertAfter(element.closest('.input-icon')); } }, submitHandler: function (form) { window.location.href = "index.html"; } }); jQuery('#register-btn').click(function () { jQuery('.login-form').hide(); jQuery('.register-form').show(); }); jQuery('#register-back-btn').click(function () { jQuery('.login-form').show(); jQuery('.register-form').hide(); }); } var handleFixInputPlaceholderForIE = function () { //fix html5 placeholder attribute for ie7 & ie8 if (jQuery.browser.msie && jQuery.browser.version.substr(0, 1) <= 9) { // 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); jQuery(input).addClass("placeholder").val(input.attr('placeholder')); jQuery(input).focus(function () { if (input.val() == input.attr('placeholder')) { input.val(''); } }); jQuery(input).blur(function () { if (input.val() == '' || input.val() == input.attr('placeholder')) { input.val(input.attr('placeholder')); } }); }); } } var handlePulsate = function () { if (!jQuery().pulsate) { return; } if (isIE8 == true) { return; // pulsate plugin does not support IE8 and below } if (jQuery().pulsate) { jQuery('#pulsate-regular').pulsate({ color: "#bf1c56" }); jQuery('#pulsate-once').click(function () { $(this).pulsate({ color: "#399bc3", repeat: false }); }); jQuery('#pulsate-hover').pulsate({ color: "#5ebf5e", repeat: false, onHover: true }); jQuery('#pulsate-crazy').click(function () { $(this).pulsate({ color: "#fdbe41", reach: 50, repeat: 10, speed: 100, glow: true }); }); } } var handleIntro = function () { if ($.cookie('intro_show')) { return; } $.cookie('intro_show', 1); setTimeout(function () { var unique_id = $.gritter.add({ // (string | mandatory) the heading of the notification title: 'Meet Metronic!', // (string | mandatory) the text inside the notification text: 'Metronic is a brand new Responsive Admin Dashboard Template you have always been looking for!', // (string | optional) the image to display on the left image: './assets/img/avatar1.jpg', // (bool | optional) if you want it to fade out on its own or just sit there sticky: true, // (int | optional) the time you want it to be alive for before fading out time: '', // (string | optional) the class name you want to apply to that specific message class_name: 'my-sticky-class' }); // You can have it return a unique id, this can be used to manually remove it later using setTimeout(function () { $.gritter.remove(unique_id, { fade: true, speed: 'slow' }); }, 12000); }, 2000); setTimeout(function () { var unique_id = $.gritter.add({ // (string | mandatory) the heading of the notification title: 'Buy Metronic!', // (string | mandatory) the text inside the notification text: 'Metronic comes with a huge collection of reusable and easy customizable UI components and plugins. Buy Metronic today!', // (string | optional) the image to display on the left image: './assets/img/avatar1.jpg', // (bool | optional) if you want it to fade out on its own or just sit there sticky: true, // (int | optional) the time you want it to be alive for before fading out time: '', // (string | optional) the class name you want to apply to that specific message class_name: 'my-sticky-class' }); // You can have it return a unique id, this can be used to manually remove it later using setTimeout(function () { $.gritter.remove(unique_id, { fade: true, speed: 'slow' }); }, 13000); }, 8000); setTimeout(function () { $('#styler').pulsate({ color: "#bb3319", repeat: 10 }); $.extend($.gritter.options, { position: 'top-left' }); var unique_id = $.gritter.add({ position: 'top-left', // (string | mandatory) the heading of the notification title: 'Customize Metronic!', // (string | mandatory) the text inside the notification text: 'Metronic allows you to easily customize the theme colors and layout settings.', // (string | optional) the image to display on the left image1: './assets/img/avatar1.png', // (bool | optional) if you want it to fade out on its own or just sit there sticky: true, // (int | optional) the time you want it to be alive for before fading out time: '', // (string | optional) the class name you want to apply to that specific message class_name: 'my-sticky-class' }); $.extend($.gritter.options, { position: 'top-right' }); // You can have it return a unique id, this can be used to manually remove it later using setTimeout(function () { $.gritter.remove(unique_id, { fade: true, speed: 'slow' }); }, 15000); }, 23000); setTimeout(function () { $.extend($.gritter.options, { position: 'top-left' }); var unique_id = $.gritter.add({ // (string | mandatory) the heading of the notification title: 'Notification', // (string | mandatory) the text inside the notification text: 'You have 3 new notifications.', // (string | optional) the image to display on the left image1: './assets/img/image1.jpg', // (bool | optional) if you want it to fade out on its own or just sit there sticky: true, // (int | optional) the time you want it to be alive for before fading out time: '', // (string | optional) the class name you want to apply to that specific message class_name: 'my-sticky-class' }); setTimeout(function () { $.gritter.remove(unique_id, { fade: true, speed: 'slow' }); }, 4000); $.extend($.gritter.options, { position: 'top-right' }); var number = $('#header_notification_bar .badge').text(); number = parseInt(number); number = number + 3; $('#header_notification_bar .badge').text(number); $('#header_notification_bar').pulsate({ color: "#66bce6", repeat: 5 }); }, 40000); setTimeout(function () { $.extend($.gritter.options, { position: 'top-left' }); var unique_id = $.gritter.add({ // (string | mandatory) the heading of the notification title: 'Inbox', // (string | mandatory) the text inside the notification text: 'You have 2 new messages in your inbox.', // (string | optional) the image to display on the left image1: './assets/img/avatar1.jpg', // (bool | optional) if you want it to fade out on its own or just sit there sticky: true, // (int | optional) the time you want it to be alive for before fading out time: '', // (string | optional) the class name you want to apply to that specific message class_name: 'my-sticky-class' }); $.extend($.gritter.options, { position: 'top-right' }); setTimeout(function () { $.gritter.remove(unique_id, { fade: true, speed: 'slow' }); }, 4000); var number = $('#header_inbox_bar .badge').text(); number = parseInt(number); number = number + 2; $('#header_inbox_bar .badge').text(number); $('#header_inbox_bar').pulsate({ color: "#dd5131", repeat: 5 }); }, 60000); } var handleGritterNotifications = function () { if (!jQuery.gritter) { return; } $('#gritter-sticky').click(function () { var unique_id = $.gritter.add({ // (string | mandatory) the heading of the notification title: 'This is a sticky notice!', // (string | mandatory) the text inside the notification text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus eget tincidunt velit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.', // (string | optional) the image to display on the left image: './assets/img/avatar1.jpg', // (bool | optional) if you want it to fade out on its own or just sit there sticky: true, // (int | optional) the time you want it to be alive for before fading out time: '', // (string | optional) the class name you want to apply to that specific message class_name: 'my-sticky-class' }); return false; }); $('#gritter-regular').click(function () { $.gritter.add({ // (string | mandatory) the heading of the notification title: 'This is a regular notice!', // (string | mandatory) the text inside the notification text: 'This will fade out after a certain amount of time. Vivamus eget tincidunt velit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.', // (string | optional) the image to display on the left image: './assets/img/avatar1.jpg', // (bool | optional) if you want it to fade out on its own or just sit there sticky: false, // (int | optional) the time you want it to be alive for before fading out time: '' }); return false; }); $('#gritter-max').click(function () { $.gritter.add({ // (string | mandatory) the heading of the notification title: 'This is a notice with a max of 3 on screen at one time!', // (string | mandatory) the text inside the notification text: 'This will fade out after a certain amount of time. Vivamus eget tincidunt velit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.', // (string | optional) the image to display on the left image: './assets/img/avatar1.jpg', // (bool | optional) if you want it to fade out on its own or just sit there sticky: false, // (function) before the gritter notice is opened before_open: function () { if ($('.gritter-item-wrapper').length == 3) { // Returning false prevents a new gritter from opening return false; } } }); return false; }); $('#gritter-without-image').click(function () { $.gritter.add({ // (string | mandatory) the heading of the notification title: 'This is a notice without an image!', // (string | mandatory) the text inside the notification text: 'This will fade out after a certain amount of time. Vivamus eget tincidunt velit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.' }); return false; }); $('#gritter-light').click(function () { $.gritter.add({ // (string | mandatory) the heading of the notification title: 'This is a light notification', // (string | mandatory) the text inside the notification text: 'Just add a "gritter-light" class_name to your $.gritter.add or globally to $.gritter.options.class_name', class_name: 'gritter-light' }); return false; }); $("#gritter-remove-all").click(function () { $.gritter.removeAll(); return false; }); } var handleTooltip = 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 handlePopover = function () { jQuery('.popovers').popover(); } var handleChoosenSelect = function () { if (!jQuery().chosen) { return; } $(".chosen").chosen(); $(".chosen-with-diselect").chosen({ allow_single_deselect: true }) } var initChosenSelect = function (els) { $(els).chosen({ allow_single_deselect: true }) } var handleUniform = function () { if (!jQuery().uniform) { return; } var test = $("input[type=checkbox]:not(.toggle), input[type=radio]:not(.toggle, .star)"); if (test) { test.uniform(); } } var initUniform = function (els) { jQuery(els).each(function () { if ($(this).parents(".checker").size() == 0) { $(this).show(); $(this).uniform(); } }); } var handleWysihtml5 = function () { if (!jQuery().wysihtml5) { return; } if ($('.wysihtml5').size() > 0) { $('.wysihtml5').wysihtml5(); } } var handleToggleButtons = function () { if (!jQuery().toggleButtons) { return; } $('.basic-toggle-button').toggleButtons(); $('.text-toggle-button').toggleButtons({ width: 200, label: { enabled: "Lorem Ipsum", disabled: "Dolor Sit" } }); $('.danger-toggle-button').toggleButtons({ style: { // Accepted values ["primary", "danger", "info", "success", "warning"] or nothing enabled: "danger", disabled: "info" } }); $('.info-toggle-button').toggleButtons({ style: { enabled: "info", disabled: "" } }); $('.success-toggle-button').toggleButtons({ style: { enabled: "success", disabled: "info" } }); $('.warning-toggle-button').toggleButtons({ style: { enabled: "warning", disabled: "info" } }); $('.height-toggle-button').toggleButtons({ height: 100, font: { 'line-height': '100px', 'font-size': '20px', 'font-style': 'italic' } }); } var handleTables = function () { if (!jQuery().dataTable) { return; } // begin first table $('#sample_1').dataTable({ "aLengthMenu": [ [10, 25, 50, -1], [5, 15, 20, "All"] ], // set the initial value "iDisplayLength": 5, "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>", "sPaginationType": "bootstrap", "oLanguage": { "sLengthMenu": "_MENU_ records per page", "oPaginate": { "sPrevious": "Prev", "sNext": "Next" } }, "aoColumnDefs": [{ 'bSortable': false, 'aTargets': [0] }] }); jQuery('#sample_1 .group-checkable').change(function () { var set = jQuery(this).attr("data-set"); var checked = jQuery(this).is(":checked"); jQuery(set).each(function () { if (checked) { $(this).attr("checked", true); } else { $(this).attr("checked", false); } }); jQuery.uniform.update(set); }); jQuery('#sample_1_wrapper .dataTables_filter input').addClass("m-wrap medium"); // modify table search input jQuery('#sample_1_wrapper .dataTables_length select').addClass("m-wrap xsmall"); // modify table per page dropdown // begin second table $('#sample_2').dataTable({ "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>", "sPaginationType": "bootstrap", "oLanguage": { "sLengthMenu": "_MENU_ per page", "oPaginate": { "sPrevious": "Prev", "sNext": "Next" } }, "aoColumnDefs": [{ 'bSortable': false, 'aTargets': [0] }] }); jQuery('#sample_2 .group-checkable').change(function () { var set = jQuery(this).attr("data-set"); var checked = jQuery(this).is(":checked"); jQuery(set).each(function () { if (checked) { $(this).attr("checked", true); } else { $(this).attr("checked", false); } }); jQuery.uniform.update(set); }); jQuery('#sample_2_wrapper .dataTables_filter input').addClass("m-wrap small"); // modify table search input jQuery('#sample_2_wrapper .dataTables_length select').addClass("m-wrap xsmall"); // modify table per page dropdown // begin: third table $('#sample_3').dataTable({ "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>", "sPaginationType": "bootstrap", "oLanguage": { "sLengthMenu": "_MENU_ per page", "oPaginate": { "sPrevious": "Prev", "sNext": "Next" } }, "aoColumnDefs": [{ 'bSortable': false, 'aTargets': [0] }] }); jQuery('#sample_3 .group-checkable').change(function () { var set = jQuery(this).attr("data-set"); var checked = jQuery(this).is(":checked"); jQuery(set).each(function () { if (checked) { $(this).attr("checked", true); } else { $(this).attr("checked", false); } }); jQuery.uniform.update(set); }); jQuery('#sample_3_wrapper .dataTables_filter input').addClass("m-wrap small"); // modify table search input jQuery('#sample_3_wrapper .dataTables_length select').addClass("m-wrap xsmall"); // modify table per page dropdown } var handleEditableTables = function () { function restoreRow(oTable, nRow) { var aData = oTable.fnGetData(nRow); var jqTds = $('>td', nRow); for (var i = 0, iLen = jqTds.length; i < iLen; i++) { oTable.fnUpdate(aData[i], nRow, i, false); } oTable.fnDraw(); } function editRow(oTable, nRow) { var aData = oTable.fnGetData(nRow); var jqTds = $('>td', nRow); jqTds[0].innerHTML = ''; jqTds[1].innerHTML = ''; jqTds[2].innerHTML = ''; jqTds[3].innerHTML = ''; jqTds[4].innerHTML = 'Save'; jqTds[5].innerHTML = 'Cancel'; } function saveRow(oTable, nRow) { var jqInputs = $('input', nRow); oTable.fnUpdate(jqInputs[0].value, nRow, 0, false); oTable.fnUpdate(jqInputs[1].value, nRow, 1, false); oTable.fnUpdate(jqInputs[2].value, nRow, 2, false); oTable.fnUpdate(jqInputs[3].value, nRow, 3, false); oTable.fnUpdate('Edit', nRow, 4, false); oTable.fnUpdate('Delete', nRow, 5, false); oTable.fnDraw(); } function cancelEditRow(oTable, nRow) { var jqInputs = $('input', nRow); oTable.fnUpdate(jqInputs[0].value, nRow, 0, false); oTable.fnUpdate(jqInputs[1].value, nRow, 1, false); oTable.fnUpdate(jqInputs[2].value, nRow, 2, false); oTable.fnUpdate(jqInputs[3].value, nRow, 3, false); oTable.fnUpdate('Edit', nRow, 4, false); oTable.fnDraw(); } var oTable = $('#sample_editable_1').dataTable(); jQuery('#sample_editable_1_wrapper .dataTables_filter input').addClass("m-wrap medium"); // modify table search input jQuery('#sample_editable_1_wrapper .dataTables_length select').addClass("m-wrap xsmall"); // modify table per page dropdown var nEditing = null; $('#sample_editable_1_new').click(function (e) { e.preventDefault(); var aiNew = oTable.fnAddData(['', '', '', '', 'Edit', 'Cancel']); var nRow = oTable.fnGetNodes(aiNew[0]); editRow(oTable, nRow); nEditing = nRow; }); $('#sample_editable_1 a.delete').live('click', function (e) { e.preventDefault(); if (confirm("Are you sure to delete this row ?") == false) { return; } var nRow = $(this).parents('tr')[0]; oTable.fnDeleteRow(nRow); alert("Deleted! Do not forget to do some ajax to sync with backend :)"); }); $('#sample_editable_1 a.cancel').live('click', function (e) { e.preventDefault(); if ($(this).attr("data-mode") == "new") { var nRow = $(this).parents('tr')[0]; oTable.fnDeleteRow(nRow); } else { restoreRow(oTable, nEditing); nEditing = null; } }); $('#sample_editable_1 a.edit').live('click', function (e) { e.preventDefault(); /* Get the row as a parent of the link that was clicked on */ var nRow = $(this).parents('tr')[0]; if (nEditing !== null && nEditing != nRow) { /* Currently editing - but not this row - restore the old before continuing to edit mode */ restoreRow(oTable, nEditing); editRow(oTable, nRow); nEditing = nRow; } else if (nEditing == nRow && this.innerHTML == "Save") { /* Editing this row and want to save it */ saveRow(oTable, nEditing); nEditing = null; alert("Updated! Do not forget to do some ajax to sync with backend :)"); } else { /* No edit in progress - let's start one */ editRow(oTable, nRow); nEditing = nRow; } }); } var handleTagsInput = function () { if (!jQuery().tagsInput) { return; } $('#tags_1').tagsInput({ width: 'auto', 'onAddTag': function () { alert(1); }, }); $('#tags_2').tagsInput({ width: 240 }); } var handleDateTimePickers = function () { if (jQuery().datepicker) { $('.date-picker').datepicker(); } if (jQuery().timepicker) { $('.timepicker-default').timepicker(); $('.timepicker-24').timepicker({ minuteStep: 1, showSeconds: true, showMeridian: false }); } if (!jQuery().daterangepicker) { return; } $('.date-range').daterangepicker(); $('#form-date-range').daterangepicker({ ranges: { 'Today': ['today', 'today'], 'Yesterday': ['yesterday', 'yesterday'], 'Last 7 Days': [Date.today().add({ days: -6 }), 'today'], 'Last 30 Days': [Date.today().add({ days: -29 }), 'today'], 'This Month': [Date.today().moveToFirstDayOfMonth(), Date.today().moveToLastDayOfMonth()], 'Last Month': [Date.today().moveToFirstDayOfMonth().add({ months: -1 }), Date.today().moveToFirstDayOfMonth().add({ days: -1 })] }, opens: 'right', format: 'MM/dd/yyyy', separator: ' to ', startDate: Date.today().add({ days: -29 }), endDate: Date.today(), minDate: '01/01/2012', maxDate: '12/31/2014', locale: { applyLabel: 'Submit', fromLabel: 'From', toLabel: 'To', customRangeLabel: 'Custom Range', daysOfWeek: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], firstDay: 1 }, showWeekNumbers: true, buttonClasses: ['btn-danger'] }, function (start, end) { $('#form-date-range span').html(start.toString('MMMM d, yyyy') + ' - ' + end.toString('MMMM d, yyyy')); }); $('#form-date-range span').html(Date.today().add({ days: -29 }).toString('MMMM d, yyyy') + ' - ' + Date.today().toString('MMMM d, yyyy')); if (!jQuery().datepicker || !jQuery().timepicker) { return; } } var handleAccordions = function () { $(".accordion").collapse().height('auto'); var lastClicked; //add scrollable class name if you need scrollable panes jQuery('.accordion.scrollable .accordion-toggle').click(function () { lastClicked = jQuery(this); }); //move to faq section jQuery('.accordion.scrollable').on('shown', function () { jQuery('html,body').animate({ scrollTop: lastClicked.offset().top - 150 }, 'slow'); }); } var handleScrollers = function () { var setPageScroller = function () { $('.main').slimScroll({ size: '12px', color: '#a1b2bd', height: $(window).height(), allowPageScroll: true, alwaysVisible: true, railVisible: true }); } /* //if (isIE8 == false) { $(window).resize(function(){ setPageScroller(); }); setPageScroller(); //} else { $('.main').removeClass("main"); //} */ $('.scroller').each(function () { $(this).slimScroll({ //start: $('.blah:eq(1)'), size: '7px', color: '#a1b2bd', 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 handleSliders = function () { // basic $(".slider-basic").slider(); // basic sliders // snap inc $("#slider-snap-inc").slider({ value: 100, min: 0, max: 1000, step: 100, slide: function (event, ui) { $("#slider-snap-inc-amount").text("$" + ui.value); } }); $("#slider-snap-inc-amount").text("$" + $("#slider-snap-inc").slider("value")); // range slider $("#slider-range").slider({ range: true, min: 0, max: 500, values: [75, 300], slide: function (event, ui) { $("#slider-range-amount").text("$" + ui.values[0] + " - $" + ui.values[1]); } }); $("#slider-range-amount").text("$" + $("#slider-range").slider("values", 0) + " - $" + $("#slider-range").slider("values", 1)); //range max $("#slider-range-max").slider({ range: "max", min: 1, max: 10, value: 2, slide: function (event, ui) { $("#slider-range-max-amount").text(ui.value); } }); $("#slider-range-max-amount").text($("#slider-range-max").slider("value")); // range min $("#slider-range-min").slider({ range: "min", value: 37, min: 1, max: 700, slide: function (event, ui) { $("#slider-range-min-amount").text("$" + ui.value); } }); $("#slider-range-min-amount").text("$" + $("#slider-range-min").slider("value")); // // setup graphic EQ $("#slider-eq > span").each(function () { // read initial values from markup and remove that var value = parseInt($(this).text(), 10); $(this).empty().slider({ value: value, range: "min", animate: true, orientation: "vertical" }); }); // vertical slider $("#slider-vertical").slider({ orientation: "vertical", range: "min", min: 0, max: 100, value: 60, slide: function (event, ui) { $("#slider-vertical-amount").text(ui.value); } }); $("#slider-vertical-amount").text($("#slider-vertical").slider("value")); // vertical range sliders $("#slider-range-vertical").slider({ orientation: "vertical", range: true, values: [17, 67], slide: function (event, ui) { $("#slider-range-vertical-amount").text("$" + ui.values[0] + " - $" + ui.values[1]); } }); $("#slider-range-vertical-amount").text("$" + $("#slider-range-vertical").slider("values", 0) + " - $" + $("#slider-range-vertical").slider("values", 1)); } var handlKnobElements = function () { //knob does not support ie8 so skip it if (!jQuery().knob || isIE8) { return; } $(".knob").knob({ 'dynamicDraw': true, 'thickness': 0.2, 'tickColorizeValues': true, 'skin': 'tron' }); if ($(".knobify").size() > 0) { $(".knobify").knob({ readOnly: true, skin: "tron", 'width': 100, 'height': 100, 'dynamicDraw': true, 'thickness': 0.2, 'tickColorizeValues': true, 'skin': 'tron', draw: function () { // "tron" case if (this.$.data('skin') == 'tron') { var a = this.angle(this.cv) // Angle , sa = this.startAngle // Previous start angle , sat = this.startAngle // Start angle , ea // Previous end angle , eat = sat + a // End angle , r = 1; this.g.lineWidth = this.lineWidth; this.o.cursor && (sat = eat - 0.3) && (eat = eat + 0.3); if (this.o.displayPrevious) { ea = this.startAngle + this.angle(this.v); this.o.cursor && (sa = ea - 0.3) && (ea = ea + 0.3); this.g.beginPath(); this.g.strokeStyle = this.pColor; this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, sa, ea, false); this.g.stroke(); } this.g.beginPath(); this.g.strokeStyle = r ? this.o.fgColor : this.fgColor; this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, sat, eat, false); this.g.stroke(); this.g.lineWidth = 2; this.g.beginPath(); this.g.strokeStyle = this.o.fgColor; this.g.arc(this.xy, this.xy, this.radius - this.lineWidth + 1 + this.lineWidth * 2 / 3, 0, 2 * Math.PI, false); this.g.stroke(); return false; } } }); } } var handleGoTop = function () { /* set variables locally for increased performance */ jQuery('.footer .go-top').click(function () { App.scrollTo(); }); } var handleChat = function () { var cont = $('#chats'); var list = $('.chats', cont); var form = $('.chat-form', cont); var input = $('input', form); var btn = $('.btn', form); var handleClick = function () { var text = input.val(); if (text.length == 0) { return; } var time = new Date(); var time_str = time.toString('MMM dd, yyyy HH:MM'); var tpl = ''; tpl += '