traffic-counter/assets/scripts/main.min.js

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).bind("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(),e(this).parent().hasClass("active"))e(this).parent().removeClass("active"),e(this).next().stop().slideUp(400);else{var r=e(this);t.find(".active").children(".js__content").stop().slideUp(400),t.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",r,{timeout:0,scrollInertia:200})})}})}),!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,r){return r||(r=o),t.each(function(){var t=e(this).data(r);if(t){var a={};a[o]=t,e(this).css(a)}}),!1},dropDown:function(t,o){var r=e("."+t);return r.each(function(){var t=e(this);t.on("click",".js__drop_down_button",function(a){return a.preventDefault(),(e(window).width()<1025||0==o)&&(t.hasClass("active")?t.removeClass("active"):(r.removeClass("active"),t.addClass("active"))),!1})}),e("html").on("click",function(o){var r=e(o.target);r.hasClass(t)||r.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,confirmButtonColor:"#DD6B55",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(r){var a=e(this).data("target");if(r.preventDefault(),t.find(".js__tab_content").removeClass("js__active"),t.find(".js__tab_control").removeClass("js__active"),e(this).addClass("js__active"),a)e(a).addClass("js__active");else{var n;n=o?e(this).parents(o).first().index():e(this).index(),t.find(".js__tab_content").eq(n).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"),r=e(this).find(".js__todo_button");r.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,r){if(o.children("li").children(".sub-menu").length){var a=0;return o.children("li").children(".sub-menu").each(function(){var o=t.func.childReturnWidth(e(this),r+e(this).outerWidth());o>a&&(a=o)}),a}return r},getResponsiveSettings:function(t){var o=t.data("responsive"),r=[];if(o){for(;o.indexOf("'")>-1;)o=o.replace("'",'"');var a=JSON.parse(o);e.each(a,function(e,t){r[r.length]={breakpoint:e,settings:{slidesToShow:t,slidesToScroll:t}}})}return r},getChart:function(){e(".js__chart").each(function(){var t,o,r,a=e(this),n=a.data("chart"),i=[],l=a.attr("id"),s=a.data("type"),c=e(this).hasClass("black-chart")?"#1b1c1c":"#ffffff";if(n){var d,h,u=n.split("|");for(d=0;d<u.length;d++)for(u[d]=u[d].trim(),i[d]=u[d].split("/"),h=0;h<i[d].length;h++)if(i[d][h].indexOf("'")>-1){for(;i[d][h].indexOf("'")>-1;)i[d][h]=i[d][h].replace("'","");i[d][h]=i[d][h].trim()}else i[d][h].indexOf(".")>-1?i[d][h]=parseFloat(i[d][h]):i[d][h]=parseInt(i[d][h],10);if(o=google.visualization.arrayToDataTable(i),e(this).hasClass("black-chart"))switch(s){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"}}},r=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},r=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"}}},r=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"}}},r=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"}}},r=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"}}},r=new google.visualization.AreaChart(document.getElementById(l))}else switch(s){case"circle":t={chartArea:{left:0,top:0,width:"100%",height:"75%"},legend:{position:"bottom"},colors:["#304ffe","#f60e0e","#ffa000"],fontName:"Poppins",backgroundColor:c},r=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},r=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},r=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},r=new google.visualization.LineChart(document.getElementById(l));break;case"line":t={chartArea:{left:30,top:10,width:"90%",height:"80%"},fontName:"Poppins",backgroundColor:c},r=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},r=new google.visualization.AreaChart(document.getElementById(l))}r.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,r=e(window).height()-o;t.attr("style",""),t.height()>r&&t.css({height:r})})}},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"),r=t.find(".js__slider_amount"),a=parseInt(t.data("min"),10),n=parseInt(t.data("max"),10),i=parseInt(t.data("value-1"),10),l=parseInt(t.data("value-2"),10),s=t.data("range");l>0?(o.slider({range:!0,min:a,max:n,values:[i,l],slide:function(e,t){r.val("$"+t.values[0]+" - $"+t.values[1])}}),r.val("$"+o.slider("values",0)+" - $"+o.slider("values",1))):(o.slider({range:s,min:a,max:n,value:i,slide:function(e,t){r.val("$"+t.value)}}),r.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);