1 line
12 KiB
JavaScript
1 line
12 KiB
JavaScript
!function(e){"use strict";var t={};NProgress.start(),e(document).ready(function(){return t.module.init(),t.plugin.init(),e('[data-toggle="tooltip"]').length&&e('[data-toggle="tooltip"]').tooltip(),!1}),e(window).on("load",function(){return t.plugin.isotope.init(),t.func.resizeNotice(),NProgress.done(),!1}),e(window).on("resize",function(){return t.func.resizeNotice(),t.func.getChart(),!1}),e(".js__full_screen").on("click",function(){e(document).fullScreen(!0)}),t.module={init:function(){return t.module.accordion(),t.module.card(),t.module.css(e(".js__width"),"width"),t.module.dropDown("js__drop_down",!1),t.module.logout(),t.module.menu(),t.module.tab(".js__tab","li"),t.module.toggle(),t.module.todo(),!1},accordion:function(){return e(".js__accordion").each(function(){var t=e(this);t.find(".js__control").on("click",function(o){if(o.preventDefault?o.preventDefault():o.returnValue=!1,e(this).parent().hasClass("active"))e(this).parent().removeClass("active"),e(this).next().stop().slideUp(400);else{var n=e(this),i=n.parent().parent();i.find(".active").children(".js__content").stop().slideUp(400),i.find(".active").removeClass("active"),e(this).parent().addClass("active"),e(this).next(".js__content").slideDown(400,function(){t.parents(".main-menu").length&&e(".main-menu .content").mCustomScrollbar("scrollTo",n,{timeout:0,scrollInertia:0})})}})}),!1},card:function(){return e(".js__card").each(function(){var t=e(this);t.on("click",".js__card_minus",function(){t.toggleClass("card-closed"),t.find(".js__card_content").stop().slideToggle(400)}),t.on("click",".js__card_remove",function(){t.slideUp(400)})}),!1},css:function(t,o,n){return n||(n=o),t.each(function(){var t=e(this).data(n);if(t){var i={};i[o]=t,e(this).css(i)}}),!1},dropDown:function(t,o){var n=e("."+t);return n.each(function(){var t=e(this);t.on("click",".js__drop_down_button",function(i){return i.preventDefault(),(e(window).width()<1025||o===!1)&&(t.hasClass("active")?t.removeClass("active"):(n.removeClass("active"),t.addClass("active"))),!1})}),e("html").on("click",function(o){var n=e(o.target);n.hasClass(t)||n.parents("."+t).length||e("."+t+".active").removeClass("active")}),!1},logout:function(){e(".js__logout").on("click",function(e){return e.preventDefault(),swal({title:"Logout?",text:"Are you sure you want to logout?",type:"warning",showCancelButton:!0,confirmButtonText:"Yes, I'm out!",cancelButtonText:"No, stay plx!",closeOnConfirm:!1,closeOnCancel:!0,confirmButtonColor:"#f60e0e"},function(e){e&&swal({title:"Logout success",text:"See you later!",type:"success",confirmButtonColor:"#304ffe"})}),!1})},menu:function(){return e(".js__menu_mobile").on("click",function(){e("html").toggleClass("menu-active"),e(window).trigger("resize")}),e(".js__menu_close").on("click",function(){e("html").removeClass("menu-active")}),e("body").on("click",function(t){if(e("html.menu-active").length&&e(window).width()<800){var o=e(t.target);o.hasClass("main-menu")||o.hasClass("js__menu_mobile")||o.parents(".main-menu").length||o.parents(".js__menu_mobile").length||e("html").removeClass("menu-active")}}),!1},tab:function(t,o){return e(".js__tab").each(function(){var t=e(this);t.on("click",".js__tab_control",function(n){var i=e(this).data("target");if(n.preventDefault(),t.find(".js__tab_content").removeClass("js__active"),t.find(".js__tab_control").removeClass("js__active"),e(this).addClass("js__active"),i)e(i).addClass("js__active");else{var a;a=o?e(this).parents(o).first().index():e(this).index(),t.find(".js__tab_content").eq(a).addClass("js__active")}return!1})}),!1},todo:function(){return e(".js__todo_widget").each(function(){var t=(e(this),e(this).find(".js__todo_list")),o=e(this).find(".js__todo_value"),n=e(this).find(".js__todo_button");n.on("click",function(){if(""!=o.val()){var e=Math.floor(1e8*Math.random()+1);t.append('<div class="todo-item"><div class="checkbox"><input type="checkbox" id="todo-'+e+'"><label for="todo-'+e+'">'+o.val()+"</label></div></div>"),o.val("")}else alert("You must enter task name.");return!1})}),!1},toggle:function(){return e(".js__toggle_open").on("click",function(t){return t.preventDefault(),e(e(this).data("target")).hasClass("active")||e(".js__toggle").removeClass("active"),e(e(this).data("target")).toggleClass("active"),!1}),e(".js__toggle_close").on("click",function(t){return t.preventDefault(),e(this).parents(".js__toggle").removeClass("active"),!1}),e("body").on("click",function(t){if(e(".js__toggle").hasClass("active")){var o=e(t.target);o.hasClass("js__toggle_open")||o.hasClass("js__toggle")||o.parents(".js__toggle_open").length||o.parents(".js__toggle").length||e(".js__toggle").removeClass("active")}}),!1}},t.func={childReturnWidth:function(o,n){if(o.children("li").children(".sub-menu").length){var i=0;return o.children("li").children(".sub-menu").each(function(){var o=t.func.childReturnWidth(e(this),n+e(this).outerWidth());o>i&&(i=o)}),i}return n},getResponsiveSettings:function(t){var o=t.data("responsive"),n=[];if(o){for(;o.indexOf("'")>-1;)o=o.replace("'",'"');var i=JSON.parse(o);e.each(i,function(e,t){n[n.length]={breakpoint:e,settings:{slidesToShow:t,slidesToScroll:t}}})}return n},getChart:function(){e(".js__chart").each(function(){var t,o,n,i=e(this),a=i.data("chart"),s=[],l=i.attr("id"),r=i.data("type"),c=e(this).hasClass("black-chart")?"#1b1c1c":"#ffffff";if(a){var u,d,h=a.split("|");for(u=0;u<h.length;u++)for(h[u]=h[u].trim(),s[u]=h[u].split("/"),d=0;d<s[u].length;d++)if(s[u][d].indexOf("'")>-1){for(;s[u][d].indexOf("'")>-1;)s[u][d]=s[u][d].replace("'","");s[u][d]=s[u][d].trim()}else s[u][d].indexOf(".")>-1?s[u][d]=parseFloat(s[u][d]):s[u][d]=parseInt(s[u][d],10);if(o=google.visualization.arrayToDataTable(s),e(this).hasClass("black-chart"))switch(r){case"circle":t={chartArea:{left:0,top:0,width:"100%",height:"75%"},colors:["#304ffe","#f60e0e","#ffa000"],fontName:"Poppins",backgroundColor:c,legend:{position:"bottom",textStyle:{color:"#484848"}},vAxis:{baselineColor:"#484848",gridlines:{color:"#484848"},textStyle:{color:"#484848"}},hAxis:{textStyle:{color:"#484848"}}},n=new google.visualization.PieChart(document.getElementById(l));break;case"donut":t={pieHole:.3,chartArea:{left:0,top:0,width:"100%",height:"75%"},legend:{position:"bottom",textStyle:{color:"#484848"}},colors:["#304ffe","#f60e0e","#ffa000"],fontName:"Poppins",backgroundColor:c},n=new google.visualization.PieChart(document.getElementById(l));break;case"column":t={chartArea:{left:30,top:10,width:"100%",height:"80%"},colors:["#304ffe"],fontName:"Poppins",backgroundColor:c,vAxis:{baselineColor:"#484848",gridlines:{color:"#484848"},textStyle:{color:"#484848"}},hAxis:{textStyle:{color:"#484848"}}},n=new google.visualization.ColumnChart(document.getElementById(l));break;case"curve":t={chartArea:{left:30,top:10,width:"90%",height:"80%"},curveType:"function",colors:["#304ffe","#f60e0e","#ffa000"],fontName:"Poppins",backgroundColor:c,vAxis:{baselineColor:"#484848",gridlines:{color:"#484848"},textStyle:{color:"#484848"}},hAxis:{textStyle:{color:"#484848"}}},n=new google.visualization.LineChart(document.getElementById(l));break;case"line":t={chartArea:{left:30,top:10,width:"90%",height:"80%"},fontName:"Poppins",backgroundColor:c,vAxis:{baselineColor:"#484848",gridlines:{color:"#484848"},textStyle:{color:"#484848"}},hAxis:{textStyle:{color:"#484848"}}},n=new google.visualization.LineChart(document.getElementById(l));break;case"area":t={chartArea:{left:50,top:20,width:"100%",height:"70%"},legend:{position:"bottom"},fontName:"Poppins",backgroundColor:c,vAxis:{baselineColor:"#484848",gridlines:{color:"#484848"},textStyle:{color:"#484848"}},hAxis:{textStyle:{color:"#484848"}}},n=new google.visualization.AreaChart(document.getElementById(l))}else switch(r){case"circle":t={chartArea:{left:0,top:0,width:"100%",height:"75%"},legend:{position:"bottom"},colors:["#304ffe","#f60e0e","#ffa000"],fontName:"Poppins",backgroundColor:c},n=new google.visualization.PieChart(document.getElementById(l));break;case"donut":t={pieHole:.3,chartArea:{left:0,top:0,width:"100%",height:"75%"},legend:{position:"bottom"},colors:["#304ffe","#f60e0e","#ffa000"],fontName:"Poppins",backgroundColor:c},n=new google.visualization.PieChart(document.getElementById(l));break;case"column":t={chartArea:{left:30,top:10,width:"100%",height:"80%"},colors:["#304ffe"],fontName:"Poppins",backgroundColor:c},n=new google.visualization.ColumnChart(document.getElementById(l));break;case"curve":t={chartArea:{left:30,top:10,width:"90%",height:"80%"},curveType:"function",colors:["#304ffe","#f60e0e","#ffa000"],fontName:"Poppins",backgroundColor:c},n=new google.visualization.LineChart(document.getElementById(l));break;case"line":t={chartArea:{left:30,top:10,width:"90%",height:"80%"},fontName:"Poppins",backgroundColor:c},n=new google.visualization.LineChart(document.getElementById(l));break;case"area":t={chartArea:{left:50,top:20,width:"100%",height:"70%"},legend:{position:"bottom"},fontName:"Poppins",backgroundColor:c},n=new google.visualization.AreaChart(document.getElementById(l))}n.draw(o,t)}})},resizeNotice:function(){e(".notice-popup").each(function(){var t=e(this),o=parseInt(t.data("space"),10)>0?parseInt(t.data("space"),10):75,n=e(window).height()-o;t.attr("style",""),t.height()>n&&t.css({height:n})})}},t.plugin={init:function(){return t.plugin.chart(),t.plugin.mCustomScrollbar(),t.plugin.select2(),t.plugin.ui.accordion(),t.plugin.ui.slider(),t.plugin.ui.sortable(),t.plugin.ui.tabs(),t.plugin.waves(),t.plugin.isotope.filter(),!1},chart:function(){return e(".js__chart").length&&(google.charts.load("current",{packages:["corechart"]}),google.charts.setOnLoadCallback(t.func.getChart)),!1},isotope:{init:function(){return setTimeout(function(){e(".js__filter_isotope").each(function(){var t=e(this);t.find(".js__isotope_items").isotope({itemSelector:".js__isotope_item",layoutMode:"cellsByRow"})})},100),!1},filter:function(){return e(".js__filter_isotope").each(function(){var t=e(this);t.on("click",".js__filter_control",function(o){return o.preventDefault(),e(this).hasClass(".js__active")||(t.find(".js__filter_control").removeClass("js__active"),e(this).addClass("js__active"),t.find(".js__isotope_items").isotope({filter:e(this).data("filter")})),!1})}),!1}},mCustomScrollbar:function(){return e(".main-menu").length&&e(".main-menu .content").mCustomScrollbar(),e(".notice-popup").length&&e(".notice-popup .content").mCustomScrollbar(),!1},select2:function(){return e(".js__select2").each(function(){var t=e(this).data("min-results"),o=e(this).data("container-class");t?("Infinity"===t?e(this).select2({minimumResultsForSearch:1/0}):e(this).select2({minimumResultsForSearch:parseInt(t,10)}),o&&e(this).on("select2:open",function(){return e(".select2-container--open").addClass(o),!1})):e(this).select2()}),!1},ui:{accordion:function(){return e(".js__ui_accordion").length&&e(".js__ui_accordion").accordion({heightStyle:"content",collapsible:!0}),!1},slider:function(){return e(".js__ui_slider").each(function(){var t=e(this),o=t.find(".js__slider_range"),n=t.find(".js__slider_amount"),i=parseInt(t.data("min"),10),a=parseInt(t.data("max"),10),s=parseInt(t.data("value-1"),10),l=parseInt(t.data("value-2"),10),r=t.data("range");l>0?(o.slider({range:!0,min:i,max:a,values:[s,l],slide:function(e,t){n.val("$"+t.values[0]+" - $"+t.values[1])}}),n.val("$"+o.slider("values",0)+" - $"+o.slider("values",1))):(o.slider({range:r,min:i,max:a,value:s,slide:function(e,t){n.val("$"+t.value)}}),n.val("$"+o.slider("value")))}),!1},sortable:function(){return e(".js__sortable").length&&e(".js__sortable").sortable({revert:!0,start:function(e,t){t.placeholder.height(t.item.height()-20),t.placeholder.css("visibility","visible")}}),!1},tabs:function(){return e(".js__ui_tab").length&&e(".js__ui_tab").tabs(),!1}},waves:function(){return e(".js__control").length&&(Waves.attach(".js__control"),Waves.init()),!1}}}(jQuery); |