diff --git a/build/js/custom.js b/build/js/custom.js index 466e495f..e69de29b 100644 --- a/build/js/custom.js +++ b/build/js/custom.js @@ -1,309 +0,0 @@ -/** - * Resize function without multiple trigger - * - * Usage: - * $(window).smartresize(function(){ - * // code here - * }); - */ -(function($,sr){ - // debouncing function from John Hann - // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/ - var debounce = function (func, threshold, execAsap) { - var timeout; - - return function debounced () { - var obj = this, args = arguments; - function delayed () { - if (!execAsap) - func.apply(obj, args); - timeout = null; - } - - if (timeout) - clearTimeout(timeout); - else if (execAsap) - func.apply(obj, args); - - timeout = setTimeout(delayed, threshold || 100); - }; - }; - - // smartresize - jQuery.fn[sr] = function(fn){ return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); }; - -})(jQuery,'smartresize'); -/** - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -var CURRENT_URL = window.location.href, - $BODY = $('body'), - $MENU_TOGGLE = $('#menu_toggle'), - $SIDEBAR_MENU = $('#sidebar-menu'), - $SIDEBAR_FOOTER = $('.sidebar-footer'), - $LEFT_COL = $('.left_col'), - $RIGHT_COL = $('.right_col'), - $NAV_MENU = $('.nav_menu'), - $FOOTER = $('footer'); - -// Sidebar -$(document).ready(function() { - // TODO: This is some kind of easy fix, maybe we can improve this - var setContentHeight = function () { - // reset height - $RIGHT_COL.css('min-height', $(window).height()); - - var bodyHeight = $BODY.outerHeight(), - footerHeight = $BODY.hasClass('footer_fixed') ? -10 : $FOOTER.height(), - leftColHeight = $LEFT_COL.eq(1).height() + $SIDEBAR_FOOTER.height(), - contentHeight = bodyHeight < leftColHeight ? leftColHeight : bodyHeight; - - // normalize content - contentHeight -= $NAV_MENU.height() + footerHeight; - - $RIGHT_COL.css('min-height', contentHeight); - }; - - $SIDEBAR_MENU.find('a').on('click', function(ev) { - var $li = $(this).parent(); - if ($li.is('.active')) { - $li.removeClass('active active-sm'); - $('ul:first', $li).slideUp(function() { - setContentHeight(); - }); - } - else - { - // prevent closing menu if we are on child menu - if (!$li.parent().is('.child_menu')) { - $SIDEBAR_MENU.find('li').removeClass('active active-sm'); - $SIDEBAR_MENU.find('li ul').slideUp(); - }else - { - if ( $BODY.is( ".nav-sm" ) ) - { - if (!$li.parent().is('.child_menu')) { - $SIDEBAR_MENU.find('li').removeClass('active active-sm'); - $SIDEBAR_MENU.find('li ul').slideUp(); - } - } - } - $li.addClass('active'); - - $('ul:first', $li).slideDown(function() { - - }); - } - }); - - - // toggle small or large menu - $MENU_TOGGLE.on('click', function() { - if ($BODY.hasClass('nav-md')) { - $SIDEBAR_MENU.find('li.active ul').hide(); - $SIDEBAR_MENU.find('li.active').addClass('active-sm').removeClass('active'); - } else { - $SIDEBAR_MENU.find('li.active-sm ul').show(); - $SIDEBAR_MENU.find('li.active-sm').addClass('active').removeClass('active-sm'); - } - - $BODY.toggleClass('nav-md nav-sm'); - - setContentHeight(); - - $('.dataTable').each ( function () { $(this).dataTable().fnDraw(); }); - }); - - // check active menu - - var $cur_menu = $SIDEBAR_MENU.find('a').filter(function () { // find nav element with exact match - return this.href == CURRENT_URL; - }); - - if ($cur_menu.length == 0) { // if no exact match, try to find best match - var $cur_menu = $SIDEBAR_MENU.find('a').filter(function () { - return CURRENT_URL.startsWith(this.href) && this.href != ''; - }); - - if ($cur_menu.length > 1) { // get ONLY one with longest href as best match - var l = 0; - for (var i = 0; i < $cur_menu.length; i++) { - if ($cur_menu.eq(l).attr('href').length < $cur_menu.eq(i).attr('href').length) l = i; - } - $cur_menu = $cur_menu.eq(l); - } - } - - // original code below, but executed for $cur_menu - $cur_menu.parent('li').addClass('current-page').parents('ul').slideDown(function() { - setContentHeight(); - }).parent().addClass('active'); - - // recompute content when resizing - $(window).smartresize(function(){ - setContentHeight(); - }); - - setContentHeight(); - - // fixed sidebar - if ($.fn.mCustomScrollbar) { - $('.menu_fixed').mCustomScrollbar({ - autoHideScrollbar: true, - theme: 'minimal', - mouseWheel:{ preventDefault: true } - }); - } -}); -// /Sidebar - -// Panel toolbox -$(document).ready(function() { - $('.collapse-link').on('click', function() { - var $BOX_PANEL = $(this).closest('.x_panel'), - $ICON = $(this).find('i'), - $BOX_CONTENT = $BOX_PANEL.find('.x_content').eq(0); - - // fix for some div with hardcoded fix class - if ($BOX_PANEL.attr('style')) { - $BOX_CONTENT.slideToggle(200, function(){ - $BOX_PANEL.removeAttr('style'); - }); - } else { - $BOX_CONTENT.slideToggle(200); - $BOX_PANEL.css('height', 'auto'); - } - - $ICON.toggleClass('fa-chevron-up fa-chevron-down'); - }); - - $('.close-link').click(function () { - var $BOX_PANEL = $(this).closest('.x_panel'); - - $BOX_PANEL.remove(); - }); -}); -// /Panel toolbox - -// Tooltip -$(document).ready(function() { - $('[data-toggle="tooltip"]').tooltip({ - container: 'body' - }); -}); -// /Tooltip - -// Progressbar -$(document).ready(function() { - if ($(".progress .progress-bar")[0]) { - $('.progress .progress-bar').progressbar(); - } -}); -// /Progressbar - -// Switchery -$(document).ready(function() { - if ($(".js-switch")[0]) { - var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch')); - elems.forEach(function (html) { - var switchery = new Switchery(html, { - color: '#26B99A' - }); - }); - } -}); -// /Switchery - -// iCheck -$(document).ready(function() { - if ($("input.flat")[0]) { - $(document).ready(function () { - $('input.flat').iCheck({ - checkboxClass: 'icheckbox_flat-green', - radioClass: 'iradio_flat-green' - }); - }); - } -}); -// /iCheck - -// Table -$('table input').on('ifChecked', function () { - checkState = ''; - $(this).parent().parent().parent().addClass('selected'); - countChecked(); -}); -$('table input').on('ifUnchecked', function () { - checkState = ''; - $(this).parent().parent().parent().removeClass('selected'); - countChecked(); -}); - -var checkState = ''; - -$('.bulk_action input').on('ifChecked', function () { - checkState = ''; - $(this).parent().parent().parent().addClass('selected'); - countChecked(); -}); -$('.bulk_action input').on('ifUnchecked', function () { - checkState = ''; - $(this).parent().parent().parent().removeClass('selected'); - countChecked(); -}); -$('.bulk_action input#check-all').on('ifChecked', function () { - checkState = 'all'; - countChecked(); -}); -$('.bulk_action input#check-all').on('ifUnchecked', function () { - checkState = 'none'; - countChecked(); -}); - -function countChecked() { - if (checkState === 'all') { - $(".bulk_action input[name='table_records']").iCheck('check'); - } - if (checkState === 'none') { - $(".bulk_action input[name='table_records']").iCheck('uncheck'); - } - - var checkCount = $(".bulk_action input[name='table_records']:checked").length; - - if (checkCount) { - $('.column-title').hide(); - $('.bulk-actions').show(); - $('.action-cnt').html(checkCount + ' Records Selected'); - } else { - $('.column-title').show(); - $('.bulk-actions').hide(); - } -} - -// Accordion -$(document).ready(function() { - $(".expand").on("click", function () { - $(this).next().slideToggle(200); - $expand = $(this).find(">:first-child"); - - if ($expand.text() == "+") { - $expand.text("-"); - } else { - $expand.text("+"); - } - }); -}); - -// NProgress -if (typeof NProgress != 'undefined') { - $(document).ready(function () { - NProgress.start(); - }); - - $(window).on('load', function() { - NProgress.done(); - }); -} diff --git a/build/js/custom.min.js b/build/js/custom.min.js index 5706ad1c..0cf6546c 100644 --- a/build/js/custom.min.js +++ b/build/js/custom.min.js @@ -1 +1,3 @@ -function countChecked(){"all"===checkState&&$(".bulk_action input[name='table_records']").iCheck("check"),"none"===checkState&&$(".bulk_action input[name='table_records']").iCheck("uncheck");var e=$(".bulk_action input[name='table_records']:checked").length;e?($(".column-title").hide(),$(".bulk-actions").show(),$(".action-cnt").html(e+" Records Selected")):($(".column-title").show(),$(".bulk-actions").hide())}!function(e,t){var n=function(e,t,n){var i;return function(){function c(){n||e.apply(a,o),i=null}var a=this,o=arguments;i?clearTimeout(i):n&&e.apply(a,o),i=setTimeout(c,t||100)}};jQuery.fn[t]=function(e){return e?this.bind("resize",n(e)):this.trigger(t)}}(jQuery,"smartresize");var CURRENT_URL=window.location.href,$BODY=$("body"),$MENU_TOGGLE=$("#menu_toggle"),$SIDEBAR_MENU=$("#sidebar-menu"),$SIDEBAR_FOOTER=$(".sidebar-footer"),$LEFT_COL=$(".left_col"),$RIGHT_COL=$(".right_col"),$NAV_MENU=$(".nav_menu"),$FOOTER=$("footer");$(document).ready(function(){var e=function(){$RIGHT_COL.css("min-height",$(window).height());var e=$BODY.outerHeight(),t=$BODY.hasClass("footer_fixed")?-10:$FOOTER.height(),n=$LEFT_COL.eq(1).height()+$SIDEBAR_FOOTER.height(),i=e1){for(var n=0,i=0;i:first-child"),"+"==$expand.text()?$expand.text("-"):$expand.text("+")})}),"undefined"!=typeof NProgress&&($(document).ready(function(){NProgress.start()}),$(window).on("load",function(){NProgress.done()})); \ No newline at end of file +function init_sidebar(){var e=function(){$RIGHT_COL.css("min-height",$(window).height());var e=$BODY.outerHeight(),a=$BODY.hasClass("footer_fixed")?-10:$FOOTER.height(),t=$LEFT_COL.eq(1).height()+$SIDEBAR_FOOTER.height(),n=e File upload error '+t+" ").prependTo("#alerts")}"undefined"!=typeof $.fn.wysiwyg&&(console.log("init_wysiwyg"),$(".editor-wrapper").each(function(){var a=$(this).attr("id");$(this).wysiwyg({toolbarSelector:'[data-target="#'+a+'"]',fileUploadError:e})}),window.prettyPrint,prettyPrint())}function init_cropper(){if("undefined"!=typeof $.fn.cropper){console.log("init_cropper");var e=$("#image"),a=$("#download"),t=$("#dataX"),n=$("#dataY"),o=$("#dataHeight"),i=$("#dataWidth"),r=$("#dataRotate"),l=$("#dataScaleX"),s=$("#dataScaleY"),c={aspectRatio:16/9,preview:".img-preview",crop:function(e){t.val(Math.round(e.x)),n.val(Math.round(e.y)),o.val(Math.round(e.height)),i.val(Math.round(e.width)),r.val(e.rotate),l.val(e.scaleX),s.val(e.scaleY)}};$('[data-toggle="tooltip"]').tooltip(),e.on({"build.cropper":function(e){console.log(e.type)},"built.cropper":function(e){console.log(e.type)},"cropstart.cropper":function(e){console.log(e.type,e.action)},"cropmove.cropper":function(e){console.log(e.type,e.action)},"cropend.cropper":function(e){console.log(e.type,e.action)},"crop.cropper":function(e){console.log(e.type,e.x,e.y,e.width,e.height,e.rotate,e.scaleX,e.scaleY)},"zoom.cropper":function(e){console.log(e.type,e.ratio)}}).cropper(c),$.isFunction(document.createElement("canvas").getContext)||$('button[data-method="getCroppedCanvas"]').prop("disabled",!0),"undefined"==typeof document.createElement("cropper").style.transition&&($('button[data-method="rotate"]').prop("disabled",!0),$('button[data-method="scale"]').prop("disabled",!0)),"undefined"==typeof a[0].download&&a.addClass("disabled"),$(".docs-toggles").on("change","input",function(){var a,t,n=$(this),o=n.attr("name"),i=n.prop("type");e.data("cropper")&&("checkbox"===i?(c[o]=n.prop("checked"),a=e.cropper("getCropBoxData"),t=e.cropper("getCanvasData"),c.built=function(){e.cropper("setCropBoxData",a),e.cropper("setCanvasData",t)}):"radio"===i&&(c[o]=n.val()),e.cropper("destroy").cropper(c))}),$(".docs-buttons").on("click","[data-method]",function(){var e,t,n=$(this),o=n.data();if(!n.prop("disabled")&&!n.hasClass("disabled")&&i.data("cropper")&&o.method){if(o=$.extend({},o),"undefined"!=typeof o.target&&(e=$(o.target),"undefined"==typeof o.option))try{o.option=JSON.parse(e.val())}catch(i){console.log(i.message)}switch(t=i.cropper(o.method,o.option,o.secondOption),o.method){case"scaleX":case"scaleY":$(this).data("option",-o.option);break;case"getCroppedCanvas":t&&($("#getCroppedCanvasModal").modal().find(".modal-body").html(t),a.hasClass("disabled")||a.attr("href",t.toDataURL()))}if($.isPlainObject(t)&&e)try{e.val(JSON.stringify(t))}catch(i){console.log(i.message)}}}),$(document.body).on("keydown",function(a){if(e.data("cropper")&&!(this.scrollTop>300))switch(a.which){case 37:a.preventDefault(),e.cropper("move",-1,0);break;case 38:a.preventDefault(),e.cropper("move",0,-1);break;case 39:a.preventDefault(),e.cropper("move",1,0);break;case 40:a.preventDefault(),e.cropper("move",0,1)}});var d,u=$("#inputImage"),m=window.URL||window.webkitURL;m?u.change(function(){var a,t=this.files;e.data("cropper")&&t&&t.length&&(a=t[0],/^image\/\w+$/.test(a.type)?(d=m.createObjectURL(a),e.one("built.cropper",function(){m.revokeObjectURL(d)}).cropper("reset").cropper("replace",d),u.val("")):window.alert("Please choose an image file."))}):u.prop("disabled",!0).parent().addClass("disabled")}}function init_knob(){if("undefined"!=typeof $.fn.knob){console.log("init_knob"),$(".knob").knob({change:function(e){},release:function(e){console.log("release : "+e)},cancel:function(){console.log("cancel : ",this)},draw:function(){if("tron"==this.$.data("skin")){this.cursorExt=.3;var e,a=this.arc(this.cv),t=1;return this.g.lineWidth=this.lineWidth,this.o.displayPrevious&&(e=this.arc(this.v),this.g.beginPath(),this.g.strokeStyle=this.pColor,this.g.arc(this.xy,this.xy,this.radius-this.lineWidth,e.s,e.e,e.d),this.g.stroke()),this.g.beginPath(),this.g.strokeStyle=t?this.o.fgColor:this.fgColor,this.g.arc(this.xy,this.xy,this.radius-this.lineWidth,a.s,a.e,a.d),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+2*this.lineWidth/3,0,2*Math.PI,!1),this.g.stroke(),!1}}});var e,a=0,t=0,n=0,o=$("div.idir"),i=$("div.ival"),r=function(){n++,o.show().html("+").fadeOut(),i.html(n)},l=function(){n--,o.show().html("-").fadeOut(),i.html(n)};$("input.infinite").knob({min:0,max:20,stopper:!1,change:function(){e>this.cv?a?(l(),a=0):(a=1,t=0):e