Advertisement
Guest User

Untitled

a guest
Apr 6th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var config = window.config = {};
  2.  
  3. // Config reference element
  4. var $ref = $("#ref");
  5.  
  6. // Configure responsive bootstrap toolkit
  7. config.ResponsiveBootstrapToolkitVisibilityDivs = {
  8.     'xs': $('<div class="device-xs                hidden-sm-up"></div>'),
  9.     'sm': $('<div class="device-sm hidden-xs-down hidden-md-up"></div>'),
  10.     'md': $('<div class="device-md hidden-sm-down hidden-lg-up"></div>'),
  11.     'lg': $('<div class="device-lg hidden-md-down hidden-xl-up"></div>'),
  12.     'xl': $('<div class="device-xl hidden-lg-down             "></div>'),
  13. };
  14.  
  15. ResponsiveBootstrapToolkit.use('Custom', config.ResponsiveBootstrapToolkitVisibilityDivs);
  16.  
  17. //validation configuration
  18. config.validations = {
  19.     debug: true,
  20.     errorClass:'has-error',
  21.     validClass:'success',
  22.     errorElement:"span",
  23.  
  24.     // add error class
  25.     highlight: function(element, errorClass, validClass) {
  26.         $(element).parents("div.form-group")
  27.         .addClass(errorClass)
  28.         .removeClass(validClass);
  29.     },
  30.  
  31.     // add error class
  32.     unhighlight: function(element, errorClass, validClass) {
  33.         $(element).parents(".has-error")
  34.         .removeClass(errorClass)
  35.         .addClass(validClass);
  36.     },
  37.  
  38.     // submit handler
  39.     submitHandler: function(form) {
  40.         form.submit();
  41.     }
  42. }
  43.  
  44. //delay time configuration
  45. config.delayTime = 50;
  46.  
  47. // chart configurations
  48. config.chart = {};
  49.  
  50. config.chart.colorPrimary = tinycolor($ref.find(".chart .color-primary").css("color"));
  51. config.chart.colorSecondary = tinycolor($ref.find(".chart .color-secondary").css("color"));
  52. $(function() {
  53.     animate({
  54.         name: 'flipInY',
  55.         selector: '.error-card > .error-title-block'
  56.     });
  57.  
  58.  
  59.     setTimeout(function(){
  60.         var $el = $('.error-card > .error-container');
  61.  
  62.         animate({
  63.             name: 'fadeInUp',
  64.             selector: $el
  65.         });
  66.  
  67.         $el.addClass('visible');
  68.     }, 1000);
  69. })
  70. //LoginForm validation
  71. $(function() {
  72.     if (!$('#login-form').length) {
  73.         return false;
  74.     }
  75.  
  76.     var loginValidationSettings = {
  77.         rules: {
  78.             username: {
  79.                 required: true,
  80.                 email: true
  81.             },
  82.             password: "required",
  83.             agree: "required"
  84.         },
  85.         messages: {
  86.             username: {
  87.                 required: "Please enter username",
  88.                 email: "Please enter a valid email address"
  89.             },
  90.             password:  "Please enter password",
  91.             agree: "Please accept our policy"
  92.         },
  93.         invalidHandler: function() {
  94.             animate({
  95.                 name: 'shake',
  96.                 selector: '.auth-container > .card'
  97.             });
  98.         }
  99.     }
  100.  
  101.     $.extend(loginValidationSettings, config.validations);
  102.  
  103.     $('#login-form').validate(loginValidationSettings);
  104. })
  105. //ResetForm validation
  106. $(function() {
  107.     if (!$('#reset-form').length) {
  108.         return false;
  109.     }
  110.  
  111.     var resetValidationSettings = {
  112.         rules: {
  113.             email1: {
  114.                 required: true,
  115.                 email: true
  116.             }
  117.         },
  118.         messages: {
  119.             email1: {
  120.                 required: "Please enter email address",
  121.                 email: "Please enter a valid email address"
  122.             }
  123.         },
  124.         invalidHandler: function() {
  125.             animate({
  126.                 name: 'shake',
  127.                 selector: '.auth-container > .card'
  128.             });
  129.         }
  130.     }
  131.  
  132.     $.extend(resetValidationSettings, config.validations);
  133.  
  134.     $('#reset-form').validate(resetValidationSettings);
  135. })
  136. //SignupForm validation
  137. $(function() {
  138.     if (!$('#signup-form').length) {
  139.         return false;
  140.     }
  141.  
  142.     var signupValidationSettings = {
  143.         rules: {
  144.             firstname: {
  145.                 required: true,
  146.             },
  147.             lastname: {
  148.                 required: true,
  149.             },
  150.             email: {
  151.                 required: true,
  152.                 email: true
  153.             },
  154.             password: {
  155.                 required: true,
  156.                 minlength: 8
  157.             },
  158.             retype_password: {
  159.                 required: true,
  160.                 minlength: 8,
  161.                 equalTo: "#password"
  162.             },
  163.             agree: {
  164.                 required: true,
  165.             }
  166.         },
  167.         groups: {
  168.             name: "firstname lastname",
  169.             pass: "password retype_password",
  170.         },
  171.         errorPlacement: function(error, element) {
  172.             if (
  173.                 element.attr("name") == "firstname" ||
  174.                 element.attr("name") == "lastname"
  175.             ) {
  176.                 error.insertAfter($("#lastname").closest('.row'));
  177.                 element.parents("div.form-group")
  178.                 .addClass('has-error');
  179.             }
  180.             else if (
  181.                 element.attr("name") == "password" ||
  182.                 element.attr("name") == "retype_password"
  183.             ) {
  184.                 error.insertAfter($("#retype_password").closest('.row'));
  185.                 element.parents("div.form-group")
  186.                 .addClass('has-error');
  187.             }
  188.             else if (element.attr("name") == "agree") {
  189.                 error.insertAfter("#agree-text");
  190.             }
  191.             else {
  192.                 error.insertAfter(element);
  193.             }
  194.         },
  195.         messages: {
  196.             firstname: "Please enter firstname and lastname",
  197.             lastname: "Please enter firstname and lastname",
  198.             email: {
  199.                 required: "Please enter email",
  200.                 email: "Please enter a valid email address"
  201.             },
  202.             password: {
  203.                 required: "Please enter password fields.",
  204.                 minlength: "Passwords should be at least 8 characters."
  205.             },
  206.             retype_password: {
  207.                 required: "Please enter password fields.",
  208.                 minlength: "Passwords should be at least 8 characters."
  209.             },
  210.             agree: "Please accept our policy"
  211.         },
  212.         invalidHandler: function() {
  213.             animate({
  214.                 name: 'shake',
  215.                 selector: '.auth-container > .card'
  216.             });
  217.         }
  218.     }
  219.  
  220.     $.extend(signupValidationSettings, config.validations);
  221.  
  222.     $('#signup-form').validate(signupValidationSettings);
  223. });
  224. /***********************************************
  225. *        Animation Settings
  226. ***********************************************/
  227. function animate(options) {
  228.     var animationName = "animated " + options.name;
  229.     var animationEnd = "webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend";
  230.     $(options.selector)
  231.     .addClass(animationName)
  232.     .one(animationEnd,
  233.         function(){
  234.             $(this).removeClass(animationName);
  235.         }
  236.     );
  237. }
  238.  
  239. $(function() {
  240.     var $itemActions = $(".item-actions-dropdown");
  241.  
  242.     $(document).on('click',function(e) {
  243.         if (!$(e.target).closest('.item-actions-dropdown').length) {
  244.             $itemActions.removeClass('active');
  245.         }
  246.     });
  247.    
  248.     $('.item-actions-toggle-btn').on('click',function(e){
  249.         e.preventDefault();
  250.  
  251.         var $thisActionList = $(this).closest('.item-actions-dropdown');
  252.  
  253.         $itemActions.not($thisActionList).removeClass('active');
  254.  
  255.         $thisActionList.toggleClass('active'); 
  256.     });
  257. });
  258.  
  259. /***********************************************
  260. *        NProgress Settings
  261. ***********************************************/
  262. var npSettings = {
  263.     easing: 'ease',
  264.     speed: 500
  265. }
  266.  
  267. NProgress.configure(npSettings);
  268. $(function() {
  269.     setSameHeights();
  270.  
  271.     var resizeTimer;
  272.  
  273.     $(window).resize(function() {
  274.         clearTimeout(resizeTimer);
  275.         resizeTimer = setTimeout(setSameHeights, 150);
  276.     });
  277. });
  278.  
  279.  
  280. function setSameHeights($container) {
  281.  
  282.     $container = $container || $('.sameheight-container');
  283.  
  284.     var viewport = ResponsiveBootstrapToolkit.current();
  285.  
  286.     $container.each(function() {
  287.  
  288.         var $items = $(this).find(".sameheight-item");
  289.  
  290.         // Get max height of items in container
  291.         var maxHeight = 0;
  292.  
  293.         $items.each(function() {
  294.             $(this).css({height: 'auto'});
  295.             maxHeight = Math.max(maxHeight, $(this).innerHeight());
  296.         });
  297.  
  298.  
  299.         // Set heights of items
  300.         $items.each(function() {
  301.             // Ignored viewports for item
  302.             var excludedStr = $(this).data('exclude') || '';
  303.             var excluded = excludedStr.split(',');
  304.  
  305.             // Set height of element if it's not excluded on
  306.             if (excluded.indexOf(viewport) === -1) {
  307.                 $(this).innerHeight(maxHeight);
  308.             }
  309.         });
  310.     });
  311. }
  312.  
  313. //Flot Bar Chart
  314. $(function() {
  315.  
  316.     if (!$('#flot-bar-chart').length) {
  317.         return false;
  318.     }
  319.  
  320.     function drawFlotCharts() {
  321.  
  322.         var barOptions = {
  323.             series: {
  324.                 bars: {
  325.                     show: true,
  326.                     barWidth: 0.6,
  327.                     fill: true,
  328.                     fillColor: {
  329.                         colors: [{
  330.                             opacity: 0.8
  331.                         }, {
  332.                             opacity: 0.8
  333.                         }]
  334.                     }
  335.                 }
  336.             },
  337.             xaxis: {
  338.                 tickDecimals: 0
  339.             },
  340.             colors: [config.chart.colorPrimary],
  341.             grid: {
  342.                 color: "#999999",
  343.                 hoverable: true,
  344.                 clickable: true,
  345.                 tickColor: "#D4D4D4",
  346.                 borderWidth:0
  347.             },
  348.             legend: {
  349.                 show: false
  350.             },
  351.             tooltip: true,
  352.             tooltipOpts: {
  353.                 content: "x: %x, y: %y"
  354.             }
  355.         };
  356.         var barData = {
  357.             label: "bar",
  358.             data: [
  359.                 [1, 34],
  360.                 [2, 25],
  361.                 [3, 19],
  362.                 [4, 34],
  363.                 [5, 32],
  364.                 [6, 44]
  365.             ]
  366.         };
  367.         $.plot($("#flot-bar-chart"), [barData], barOptions);
  368.  
  369.  
  370.         // Flot line chart
  371.         var lineOptions = {
  372.             series: {
  373.                 lines: {
  374.                     show: true,
  375.                     lineWidth: 2,
  376.                     fill: true,
  377.                     fillColor: {
  378.                         colors: [{
  379.                             opacity: 0.0
  380.                         }, {
  381.                             opacity: 0.0
  382.                         }]
  383.                     }
  384.                 }
  385.             },
  386.             xaxis: {
  387.                 tickDecimals: 0
  388.             },
  389.             colors: [config.chart.colorPrimary],
  390.             grid: {
  391.                 color: "#999999",
  392.                 hoverable: true,
  393.                 clickable: true,
  394.                 tickColor: "#D4D4D4",
  395.                 borderWidth:0
  396.             },
  397.             legend: {
  398.                 show: false
  399.             },
  400.             tooltip: true,
  401.             tooltipOpts: {
  402.                 content: "x: %x, y: %y"
  403.             }
  404.         };
  405.         var barData = {
  406.             label: "bar",
  407.             data: [
  408.                 [1, 34],
  409.                 [2, 25],
  410.                 [3, 19],
  411.                 [4, 34],
  412.                 [5, 32],
  413.                 [6, 44]
  414.             ]
  415.         };
  416.         $.plot($("#flot-line-chart"), [barData], lineOptions);
  417.  
  418.         //Flot Pie Chart
  419.         var data = [{
  420.             label: "Sales 1",
  421.             data: 21,
  422.             color: tinycolor(config.chart.colorPrimary.toString()).lighten(20),
  423.         }, {
  424.             label: "Sales 2",
  425.             data: 15,
  426.             color: tinycolor(config.chart.colorPrimary.toString()).lighten(10),
  427.         }, {
  428.             label: "Sales 3",
  429.             data: 7,
  430.             color: tinycolor(config.chart.colorPrimary.toString()),
  431.         }, {
  432.             label: "Sales 4",
  433.             data: 52,
  434.             color: tinycolor(config.chart.colorPrimary.toString()).darken(10),
  435.         }];
  436.  
  437.         var plotObj = $.plot($("#flot-pie-chart"), data, {
  438.             series: {
  439.                 pie: {
  440.                     show: true
  441.                 }
  442.             },
  443.             grid: {
  444.                 hoverable: true
  445.             },
  446.             tooltip: true,
  447.             tooltipOpts: {
  448.                 content: "%p.0%, %s", // show percentages, rounding to 2 decimal places
  449.                 shifts: {
  450.                     x: 20,
  451.                     y: 0
  452.                 },
  453.                 defaultTheme: false
  454.             }
  455.         });
  456.  
  457.  
  458.         //live chart example
  459.         var container = $("#flot-line-chart-moving");
  460.         container.empty();
  461.         // Determine how many data points to keep based on the placeholder's initial size;
  462.         // this gives us a nice high-res plot while avoiding more than one point per pixel.
  463.  
  464.         var maximum = container.outerWidth() / 10 || 100;
  465.  
  466.         //
  467.  
  468.         var data = [];
  469.  
  470.         function getRandomData() {
  471.  
  472.             if (data.length) {
  473.                 data = data.slice(1);
  474.             }
  475.  
  476.             while (data.length < maximum) {
  477.                 var previous = data.length ? data[data.length - 1] : 50;
  478.                 var y = previous + Math.random() * 10 - 5;
  479.                 data.push(y < 0 ? 0 : y > 100 ? 100 : y);
  480.             }
  481.  
  482.             // zip the generated y values with the x values
  483.  
  484.             var res = [];
  485.             for (var i = 0; i < data.length; ++i) {
  486.                 res.push([i, data[i]])
  487.             }
  488.  
  489.             return res;
  490.         }
  491.  
  492.         series = [{
  493.             data: getRandomData(),
  494.             lines: {
  495.                 fill: true
  496.             }
  497.         }];
  498.  
  499.  
  500.         var plot = $.plot(container, series, {
  501.             grid: {
  502.  
  503.                 color: "#999999",
  504.                 tickColor: "#D4D4D4",
  505.                 borderWidth:0,
  506.                 minBorderMargin: 20,
  507.                 labelMargin: 10,
  508.                 backgroundColor: {
  509.                     colors: ["#ffffff", "#ffffff"]
  510.                 },
  511.                 margin: {
  512.                     top: 8,
  513.                     bottom: 20,
  514.                     left: 20
  515.                 },
  516.                 markings: function(axes) {
  517.                     var markings = [];
  518.                     var xaxis = axes.xaxis;
  519.                     for (var x = Math.floor(xaxis.min); x < xaxis.max; x += xaxis.tickSize * 2) {
  520.                         markings.push({
  521.                             xaxis: {
  522.                                 from: x,
  523.                                 to: x + xaxis.tickSize
  524.                             },
  525.                             color: "#fff"
  526.                         });
  527.                     }
  528.                     return markings;
  529.                 }
  530.             },
  531.             colors: [config.chart.colorPrimary.toString()],
  532.             xaxis: {
  533.                 tickFormatter: function() {
  534.                     return "";
  535.                 }
  536.             },
  537.             yaxis: {
  538.                 min: 0,
  539.                 max: 110
  540.             },
  541.             legend: {
  542.                 show: true
  543.             }
  544.         });
  545.  
  546.         // Update the random dataset at 25FPS for a smoothly-animating chart
  547.  
  548.         setInterval(function updateRandom() {
  549.             series[0].data = getRandomData();
  550.             plot.setData(series);
  551.             plot.draw();
  552.         }, 40);
  553.  
  554.  
  555.         //Flot Multiple Axes Line Chart
  556. "€";
  557.         }
  558.  
  559.         function doPlot(position) {
  560.             $.plot($("#flot-line-chart-multi"), [{
  561.                 data: oilprices,
  562.                 label: "Oil price ($)"
  563.             }, {
  564.                 data: exchangerates,
  565.                 label: "USD/EUR exchange rate",
  566.                 yaxis: 2
  567.             }], {
  568.                 xaxes: [{
  569.                     mode: 'time'
  570.                 }],
  571.                 yaxes: [{
  572.                     min: 0
  573.                 }, {
  574.                     // align if we are to the right
  575.                     alignTicksWithAxis: position == "right" ? 1 : null,
  576.                     position: position,
  577.                     tickFormatter: euroFormatter
  578.                 }],
  579.                 legend: {
  580.                     position: 'sw'
  581.                 },
  582.                 colors: [config.chart.colorPrimary.toString()],
  583.                 grid: {
  584.                     color: "#999999",
  585.                     hoverable: true,
  586.                     clickable: true,
  587.                     tickColor: "#D4D4D4",
  588.                     borderWidth:0,
  589.                     hoverable: true //IMPORTANT! this is needed for tooltip to work,
  590.  
  591.                 },
  592.                 tooltip: {
  593.                     show: true,
  594.                     content: "%s for %x was %y",
  595.                     xDateFormat: "%y-%m-%d",
  596.                     onHover: function(flotItem, $tooltipEl) {
  597.                         // console.log(flotItem, $tooltipEl);
  598.                     }
  599.                 }
  600.  
  601.             });
  602.         }
  603.  
  604.         doPlot("right");
  605.  
  606.         $("button").click(function() {
  607.             doPlot($(this).text());
  608.         });
  609.  
  610.     }
  611.  
  612.     drawFlotCharts();
  613.  
  614.     $(document).on("themechange", function(){
  615.         drawFlotCharts();
  616.     });
  617.  
  618. });
  619.  
  620. $(function() {
  621.    
  622.     if (!$('#morris-one-line-chart').length) {
  623.         return false;
  624.     }
  625.  
  626.     function drawMorrisCharts() {
  627.  
  628.         $('#morris-one-line-chart').empty();
  629.        
  630.         Morris.Line({
  631.             element: 'morris-one-line-chart',
  632.                 data: [
  633.                     { year: '2008', value: 5 },
  634.                     { year: '2009', value: 10 },
  635.                     { year: '2010', value: 8 },
  636.                     { year: '2011', value: 22 },
  637.                     { year: '2012', value: 8 },
  638.                     { year: '2014', value: 10 },
  639.                     { year: '2015', value: 5 }
  640.                 ],
  641.             xkey: 'year',
  642.             ykeys: ['value'],
  643.             resize: true,
  644.             lineWidth:4,
  645.             labels: ['Value'],
  646.             lineColors: [config.chart.colorPrimary.toString()],
  647.             pointSize:5,
  648.         });
  649.  
  650.         $('#morris-area-chart').empty();
  651.  
  652.         Morris.Area({
  653.             element: 'morris-area-chart',
  654.             data: [{ period: '2010 Q1', iphone: 2666, ipad: null, itouch: 2647 },
  655.                 { period: '2010 Q2', iphone: 2778, ipad: 2294, itouch: 2441 },
  656.                 { period: '2010 Q3', iphone: 4912, ipad: 1969, itouch: 2501 },
  657.                 { period: '2010 Q4', iphone: 3767, ipad: 3597, itouch: 5689 },
  658.                 { period: '2011 Q1', iphone: 6810, ipad: 1914, itouch: 2293 },
  659.                 { period: '2011 Q2', iphone: 5670, ipad: 4293, itouch: 1881 },
  660.                 { period: '2011 Q3', iphone: 4820, ipad: 3795, itouch: 1588 },
  661.                 { period: '2011 Q4', iphone: 15073, ipad: 5967, itouch: 5175 },
  662.                 { period: '2012 Q1', iphone: 10687, ipad: 4460, itouch: 2028 },
  663.                 { period: '2012 Q2', iphone: 8432, ipad: 5713, itouch: 1791 } ],
  664.             xkey: 'period',
  665.             ykeys: ['iphone', 'ipad', 'itouch'],
  666.             labels: ['iPhone', 'iPad', 'iPod Touch'],
  667.             pointSize: 2,
  668.             hideHover: 'auto',
  669.             resize: true,
  670.             lineColors: [
  671.                 tinycolor(config.chart.colorPrimary.toString()).lighten(10).toString(),
  672.                 tinycolor(config.chart.colorPrimary.toString()).darken(10).toString(),
  673.                 config.chart.colorPrimary.toString()
  674.             ],
  675.             lineWidth:2,
  676.             pointSize:1,
  677.         });
  678.  
  679.         $('#morris-donut-chart').empty();
  680.  
  681.         Morris.Donut({
  682.             element: 'morris-donut-chart',
  683.             data: [{ label: "Download Sales", value: 12 },
  684.                 { label: "In-Store Sales", value: 30 },
  685.                 { label: "Mail-Order Sales", value: 20 } ],
  686.             resize: true,
  687.             colors: [
  688.                 tinycolor(config.chart.colorPrimary.toString()).lighten(10).toString(),
  689.                 tinycolor(config.chart.colorPrimary.toString()).darken(10).toString(),
  690.                 config.chart.colorPrimary.toString()
  691.             ],
  692.         });
  693.  
  694.         $('#morris-bar-chart').empty();
  695.  
  696.         Morris.Bar({
  697.             element: 'morris-bar-chart',
  698.             data: [{ y: '2006', a: 60, b: 50 },
  699.                 { y: '2007', a: 75, b: 65 },
  700.                 { y: '2008', a: 50, b: 40 },
  701.                 { y: '2009', a: 75, b: 65 },
  702.                 { y: '2010', a: 50, b: 40 },
  703.                 { y: '2011', a: 75, b: 65 },
  704.                 { y: '2012', a: 100, b: 90 } ],
  705.             xkey: 'y',
  706.             ykeys: ['a', 'b'],
  707.             labels: ['Series A', 'Series B'],
  708.             hideHover: 'auto',
  709.             resize: true,
  710.             barColors: [
  711.                 config.chart.colorPrimary.toString(),
  712.                 tinycolor(config.chart.colorPrimary.toString()).darken(10).toString()
  713.             ],
  714.         });
  715.  
  716.         $('#morris-line-chart').empty();
  717.  
  718.         Morris.Line({
  719.             element: 'morris-line-chart',
  720.             data: [{ y: '2006', a: 100, b: 90 },
  721.                 { y: '2007', a: 75, b: 65 },
  722.                 { y: '2008', a: 50, b: 40 },
  723.                 { y: '2009', a: 75, b: 65 },
  724.                 { y: '2010', a: 50, b: 40 },
  725.                 { y: '2011', a: 75, b: 65 },
  726.                 { y: '2012', a: 100, b: 90 } ],
  727.             xkey: 'y',
  728.             ykeys: ['a', 'b'],
  729.             labels: ['Series A', 'Series B'],
  730.             hideHover: 'auto',
  731.             resize: true,
  732.             lineColors: [
  733.                 config.chart.colorPrimary.toString(),
  734.                 tinycolor(config.chart.colorPrimary.toString()).darken(10).toString()
  735.             ],
  736.         });
  737.     }
  738.  
  739.     drawMorrisCharts();
  740.  
  741.     $(document).on("themechange", function(){
  742.         drawMorrisCharts();
  743.     });
  744. });
  745. $(function() {
  746.  
  747.     if (!$('#dashboard-visits-chart').length) {
  748.         return false;
  749.     }
  750.  
  751.     // drawing visits chart
  752.     drawVisitsChart();
  753.  
  754.     var el = null;
  755.     var item = 'visits';
  756.  
  757.     $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  758.  
  759.        el = e.target;
  760.        item = $(el).attr('href').replace('#', '');
  761.        switchHistoryCharts(item);
  762.  
  763.     });
  764.  
  765.     $(document).on("themechange", function(){
  766.         switchHistoryCharts(item);
  767.     });
  768.  
  769.     function switchHistoryCharts(item){
  770.         var chartSelector = "#dashboard-" + item + "-chart";
  771.  
  772.         if ($(chartSelector).has('svg').length) {
  773.             $(chartSelector).empty();
  774.         }
  775.  
  776.         switch(item){
  777.             case 'visits':
  778.                 drawVisitsChart();
  779.                 break;
  780.              case 'downloads':
  781.                 drawDownloadsChart();
  782.                 break;
  783.         }
  784.     }
  785.  
  786.     function drawVisitsChart(){
  787.         var dataVisits = [
  788.             { x: '2015-09-01', y: 70},
  789.             { x: '2015-09-02', y: 75 },
  790.             { x: '2015-09-03', y: 50},
  791.             { x: '2015-09-04', y: 75 },
  792.             { x: '2015-09-05', y: 50 },
  793.             { x: '2015-09-06', y: 75 },
  794.             { x: '2015-09-07', y: 86 }
  795.         ];
  796.  
  797.  
  798.         Morris.Line({
  799.             element: 'dashboard-visits-chart',
  800.             data: dataVisits,
  801.             xkey: 'x',
  802.             ykeys: ['y'],
  803.             ymin: 'auto 40',
  804.             labels: ['Visits'],
  805.             xLabels: "day",
  806.             hideHover: 'auto',
  807.             yLabelFormat: function (y) {
  808.                 // Only integers
  809.                 if (y === parseInt(y, 10)) {
  810.                     return y;
  811.                 }
  812.                 else {
  813.                     return '';
  814.                 }
  815.             },
  816.             resize: true,
  817.             lineColors: [
  818.                 config.chart.colorSecondary.toString(),
  819.             ],
  820.             pointFillColors: [
  821.                  config.chart.colorPrimary.toString(),
  822.             ]
  823.         });
  824.     }
  825.  
  826.     function drawDownloadsChart(){
  827.  
  828.         var dataDownloads = [
  829.             {
  830.                 year: '2006',
  831.                 downloads: 1300
  832.             },
  833.             {
  834.                 year: '2007',
  835.                 downloads: 1526
  836.             },
  837.             {
  838.                 year: '2008',
  839.                 downloads: 2000
  840.             },
  841.             {
  842.                 year: '2009',
  843.                 downloads: 1800
  844.             },
  845.             {
  846.                 year: '2010',
  847.                 downloads: 1650
  848.             },
  849.             {
  850.                 year: '2011',
  851.                 downloads: 620
  852.             },
  853.             {
  854.                 year: '2012',
  855.                 downloads: 1000
  856.             },
  857.             {
  858.                 year: '2013',
  859.                 downloads: 1896
  860.             },
  861.             {
  862.                 year: '2014',
  863.                 downloads: 850
  864.             },
  865.             {
  866.                 year: '2015',
  867.                 downloads: 1500
  868.             }
  869.         ];
  870.  
  871.  
  872.         Morris.Bar({
  873.             element: 'dashboard-downloads-chart',
  874.             data: dataDownloads,
  875.             xkey: 'year',
  876.             ykeys: ['downloads'],
  877.             labels: ['Downloads'],
  878.             hideHover: 'auto',
  879.             resize: true,
  880.             barColors: [
  881.                 config.chart.colorPrimary.toString(),
  882.                 tinycolor(config.chart.colorPrimary.toString()).darken(10).toString()
  883.             ],
  884.         });
  885.     }
  886. });
  887.  
  888.  
  889.  
  890.  
  891. $(function() {
  892.    
  893.  
  894.     function drawDashboardItemsListSparklines(){
  895.         $(".dashboard-page .items .sparkline").each(function() {
  896.             var type = $(this).data('type');
  897.  
  898.             // There is predefined data
  899.             if ($(this).data('data')) {
  900.                 var data = $(this).data('data').split(',').map(function(item) {
  901.                     if (item.indexOf(":") > 0) {
  902.                         return item.split(":");
  903.                     }
  904.                     else {
  905.                         return item;
  906.                     }
  907.                 });
  908.             }
  909.             // Generate random data
  910.             else {
  911.                 var data = [];
  912.                 for (var i = 0; i < 17; i++) {
  913.                     data.push(Math.round(100 * Math.random()));
  914.                 }
  915.             }
  916.  
  917.  
  918.             $(this).sparkline(data, {
  919.                 barColor: config.chart.colorPrimary.toString(),
  920.                 height: $(this).height(),
  921.                 type: type
  922.             });
  923.         });
  924.     }
  925.  
  926.     drawDashboardItemsListSparklines();
  927.  
  928.     $(document).on("themechange", function(){
  929.         drawDashboardItemsListSparklines();
  930.     });
  931. });
  932. $(function() {
  933.  
  934.     var $dashboardSalesBreakdownChart = $('#dashboard-sales-breakdown-chart');
  935.  
  936.     if (!$dashboardSalesBreakdownChart.length) {
  937.         return false;
  938.     }
  939.  
  940.     function drawSalesChart(){
  941.  
  942.     $dashboardSalesBreakdownChart.empty();
  943.  
  944.         Morris.Donut({
  945.             element: 'dashboard-sales-breakdown-chart',
  946.             data: [{ label: "Download Sales", value: 12 },
  947.                 { label: "In-Store Sales", value: 30 },
  948.                 { label: "Mail-Order Sales", value: 20 } ],
  949.             resize: true,
  950.             colors: [
  951.                 tinycolor(config.chart.colorPrimary.toString()).lighten(10).toString(),
  952.                 tinycolor(config.chart.colorPrimary.toString()).darken(8).toString(),
  953.                 config.chart.colorPrimary.toString()
  954.             ],
  955.         });
  956.  
  957.         var $sameheightContainer = $dashboardSalesBreakdownChart.closest(".sameheight-container");
  958.  
  959.         setSameHeights($sameheightContainer);
  960.     }
  961.  
  962.     drawSalesChart();
  963.  
  964.     $(document).on("themechange", function(){
  965.        drawSalesChart();
  966.     });
  967.    
  968. })
  969. $(function() {
  970.  
  971.     var $dashboardSalesMap = $('#dashboard-sales-map');
  972.  
  973.     if (!$dashboardSalesMap.length) {
  974.         return false;
  975.     }
  976.  
  977.     function drawSalesMap() {
  978.  
  979.         $dashboardSalesMap.empty();
  980.  
  981.         var color = config.chart.colorPrimary.toHexString();
  982.         var darkColor = tinycolor(config.chart.colorPrimary.toString()).darken(40).toHexString();
  983.         var selectedColor = tinycolor(config.chart.colorPrimary.toString()).darken(10).toHexString();
  984.  
  985.         var sales_data = {
  986.             us: 2000,
  987.             ru: 2000,
  988.             gb: 10000,
  989.             fr: 10000,
  990.             de: 10000,
  991.             cn: 10000,
  992.             in: 10000,
  993.             sa: 10000,
  994.             ca: 10000,
  995.             br: 5000,
  996.             au: 5000
  997.         };
  998.  
  999.         $dashboardSalesMap.vectorMap({
  1000.             map: 'world_en',
  1001.             backgroundColor: 'transparent',
  1002.             color: '#E5E3E5',
  1003.             hoverOpacity: 0.7,
  1004.             selectedColor: selectedColor,
  1005.             enableZoom: true,
  1006.             showTooltip: true,
  1007.             values: sales_data,
  1008.             scaleColors: [ color, darkColor],
  1009.             normalizeFunction: 'linear'
  1010.         });
  1011.     }
  1012.  
  1013.     drawSalesMap();
  1014.  
  1015.     $(document).on("themechange", function(){
  1016.        drawSalesMap();
  1017.     });
  1018. });
  1019. $(function() {
  1020.  
  1021.     $('.actions-list > li').on('click', '.check', function(e){
  1022.         e.preventDefault();
  1023.  
  1024.         $(this).parents('.tasks-item')
  1025.         .find('.checkbox')
  1026.         .prop("checked",  true);
  1027.  
  1028.         removeActionList();
  1029.     });
  1030.  
  1031. });
  1032. //LoginForm validation
  1033. $(function() {
  1034.     if (!$('.form-control').length) {
  1035.         return false;
  1036.     }
  1037.  
  1038.     $('.form-control').focus(function() {
  1039.         $(this).siblings('.input-group-addon').addClass('focus');
  1040.     });
  1041.  
  1042.     $('.form-control').blur(function() {
  1043.         $(this).siblings('.input-group-addon').removeClass('focus');
  1044.     });
  1045. });
  1046. $(function(){
  1047.  
  1048.     // set sortable options
  1049.     var sortable = new Sortable($('.images-container').get(0), {
  1050.         animation: 150,
  1051.         handle: ".control-btn.move",
  1052.         draggable: ".image-container",
  1053.         onMove: function (evt) {
  1054.             var $relatedElem = $(evt.related);
  1055.  
  1056.             if ($relatedElem.hasClass('add-image')) {
  1057.                 return false;
  1058.             }
  1059.         }
  1060.     });
  1061.  
  1062.  
  1063.     $controlsButtons = $('.controls');
  1064.  
  1065.     $controlsButtonsStar = $controlsButtons.find('.star');
  1066.     $controlsButtonsRemove = $controlsButtons.find('.remove');
  1067.  
  1068.     $controlsButtonsStar.on('click',function(e){
  1069.         e.preventDefault();
  1070.  
  1071.         $controlsButtonsStar.removeClass('active');
  1072.         $controlsButtonsStar.parents('.image-container').removeClass('main');
  1073.  
  1074.         $(this).addClass('active');
  1075.  
  1076.         $(this).parents('.image-container').addClass('main');
  1077.     })
  1078.  
  1079. })
  1080.  
  1081. $(function() {
  1082.  
  1083.     if (!$('#select-all-items').length) {
  1084.         return false;
  1085.     }
  1086.  
  1087.  
  1088.     $('#select-all-items').on('change', function() {
  1089.         var $this = $(this).children(':checkbox').get(0);    
  1090.  
  1091.         $(this).parents('li')
  1092.             .siblings()
  1093.             .find(':checkbox')
  1094.             .prop('checked', $this.checked)
  1095.             .val($this.checked)
  1096.             .change();
  1097.     });
  1098.  
  1099.  
  1100.     function drawItemsListSparklines(){
  1101.         $(".items-list-page .sparkline").each(function() {
  1102.             var type = $(this).data('type');
  1103.  
  1104.             // Generate random data
  1105.             var data = [];
  1106.             for (var i = 0; i < 17; i++) {
  1107.                 data.push(Math.round(100 * Math.random()));
  1108.             }
  1109.  
  1110.             $(this).sparkline(data, {
  1111.                 barColor: config.chart.colorPrimary.toString(),
  1112.                 height: $(this).height(),
  1113.                 type: type
  1114.             });
  1115.         });
  1116.     }
  1117.  
  1118.     drawItemsListSparklines();
  1119.  
  1120.     $(document).on("themechange", function(){
  1121.         drawItemsListSparklines();
  1122.     });
  1123.  
  1124. });
  1125. $(function() {
  1126.  
  1127.     $(".wyswyg").each(function() {
  1128.  
  1129.         var $editor = $(this).find(".editor");
  1130.         var $toolbar = $(this).find(".toolbar");
  1131.  
  1132.         var editor = new Quill($editor.get(0), {
  1133.             theme: 'snow',
  1134.             // modules: {
  1135.             //  toolbar: toolbarOptions
  1136.             // }
  1137.             modules: {
  1138.                 toolbar: $toolbar.get(0)
  1139.             }
  1140.         });
  1141.  
  1142.         // var $toolbar = $(this).find(".toolbar");
  1143.         // var $editor = $(this).find(".editor");
  1144.  
  1145.  
  1146.         // var editor = new Quill($editor.get(0), {
  1147.         //  theme: 'snow'
  1148.         // });
  1149.  
  1150.         // editor.addModule('toolbar', {
  1151.         //  container: $toolbar.get(0)     // Selector for toolbar container
  1152.         // });
  1153.  
  1154.  
  1155.  
  1156.     });
  1157.  
  1158. });
  1159.  
  1160. $(function () {
  1161.  
  1162.     $('#sidebar-menu, #customize-menu').metisMenu({
  1163.         activeClass: 'open'
  1164.     });
  1165.  
  1166.  
  1167.     $('#sidebar-collapse-btn').on('click', function(event){
  1168.         event.preventDefault();
  1169.        
  1170.         $("#app").toggleClass("sidebar-open");
  1171.     });
  1172.  
  1173.     $("#sidebar-overlay").on('click', function() {
  1174.         $("#app").removeClass("sidebar-open");
  1175.     });
  1176.  
  1177.     if ($.browser.mobile) {
  1178.         var $appContainer = $('#app ');
  1179.         var $mobileHandle = $('#sidebar-mobile-menu-handle ');
  1180.  
  1181.         $mobileHandle.swipe({
  1182.             swipeLeft: function() {
  1183.                 if($appContainer.hasClass("sidebar-open")) {
  1184.                     $appContainer.removeClass("sidebar-open"); 
  1185.                 }
  1186.             },
  1187.             swipeRight: function() {
  1188.                 if(!$appContainer.hasClass("sidebar-open")) {
  1189.                     $appContainer.addClass("sidebar-open");
  1190.                 }
  1191.             },
  1192.             // excludedElements: "button, input, select, textarea, .noSwipe, table",
  1193.             triggerOnTouchEnd: false
  1194.         });
  1195.     }
  1196.    
  1197. });
  1198. // Animating dropdowns is temporary disabled
  1199. // Please feel free to send a pull request :)
  1200.  
  1201. // $(function() {
  1202. //  $('.nav-profile > li > a').on('click', function() {
  1203. //      var $el = $(this).next();
  1204.  
  1205.  
  1206. //      animate({
  1207. //          name: 'flipInX',
  1208. //          selector: $el
  1209. //      });
  1210. //  });
  1211. // })
  1212.  
  1213. var modalMedia = {
  1214.     $el: $("#modal-media"),
  1215.     result: {},
  1216.     options: {},
  1217.     open: function(options) {
  1218.         options = options || {};
  1219.         this.options = options;
  1220.  
  1221.  
  1222.         this.$el.modal('show');
  1223.     },
  1224.     close: function() {
  1225.         if ($.isFunction(this.options.beforeClose)) {
  1226.             this.options.beforeClose(this.result);
  1227.         }
  1228.  
  1229.         this.$el.modal('hide');
  1230.  
  1231.         if ($.isFunction(this.options.afterClose)) {
  1232.             this.options.beforeClose(this.result);
  1233.         }
  1234.     }
  1235. };
  1236. $(function () {
  1237.  
  1238.     // Local storage settings
  1239.     var themeSettings = getThemeSettings();
  1240.  
  1241.     // Elements
  1242.  
  1243.     var $app = $('#app');
  1244.     var $styleLink = $('#theme-style');
  1245.     var $customizeMenu = $('#customize-menu');
  1246.  
  1247.     // Color switcher
  1248.     var $customizeMenuColorBtns = $customizeMenu.find('.color-item');
  1249.  
  1250.     // Position switchers
  1251.     var $customizeMenuRadioBtns = $customizeMenu.find('.radio');
  1252.  
  1253.  
  1254.     // /////////////////////////////////////////////////
  1255.  
  1256.     // Initial state
  1257.  
  1258.     // On setting event, set corresponding options
  1259.  
  1260.     // Update customize view based on options
  1261.  
  1262.     // Update theme based on options
  1263.  
  1264.     /************************************************
  1265.     *               Initial State
  1266.     *************************************************/
  1267.  
  1268.     setThemeSettings();
  1269.  
  1270.     /************************************************
  1271.     *                   Events
  1272.     *************************************************/
  1273.  
  1274.     // set theme type
  1275.     $customizeMenuColorBtns.on('click', function() {
  1276.         themeSettings.themeName = $(this).data('theme');
  1277.  
  1278.         setThemeSettings();
  1279.     });
  1280.  
  1281.  
  1282.     $customizeMenuRadioBtns.on('click', function() {
  1283.  
  1284.         var optionName = $(this).prop('name');
  1285.         var value = $(this).val();
  1286.  
  1287.         themeSettings[optionName] = value;
  1288.  
  1289.         setThemeSettings();
  1290.     });
  1291.  
  1292.     function setThemeSettings() {
  1293.         setThemeState()
  1294.         .delay(config.delayTime)
  1295.         .queue(function (next) {
  1296.  
  1297.             setThemeColor();
  1298.             setThemeControlsState();
  1299.             saveThemeSettings();
  1300.  
  1301.             $(document).trigger("themechange");
  1302.            
  1303.             next();
  1304.         });
  1305.     }
  1306.  
  1307.     /************************************************
  1308.     *           Update theme based on options
  1309.     *************************************************/
  1310.  
  1311.     function setThemeState() {
  1312.         // set theme type
  1313.         if (themeSettings.themeName) {
  1314.             $styleLink.attr('href', 'css/app-' + themeSettings.themeName + '.css');
  1315.         }
  1316.         else {
  1317.             $styleLink.attr('href', 'css/app.css');
  1318.         }
  1319.  
  1320.         // App classes
  1321.         $app.removeClass('header-fixed footer-fixed sidebar-fixed');
  1322.  
  1323.         // set header
  1324.         $app.addClass(themeSettings.headerPosition);
  1325.  
  1326.         // set footer
  1327.         $app.addClass(themeSettings.footerPosition);
  1328.  
  1329.         // set footer
  1330.         $app.addClass(themeSettings.sidebarPosition);
  1331.  
  1332.         return $app;
  1333.     }
  1334.  
  1335.     /************************************************
  1336.     *           Update theme controls based on options
  1337.     *************************************************/
  1338.  
  1339.     function setThemeControlsState() {
  1340.         // set color switcher
  1341.         $customizeMenuColorBtns.each(function() {
  1342.             if($(this).data('theme') === themeSettings.themeName) {
  1343.                 $(this).addClass('active');
  1344.             }
  1345.             else {
  1346.                 $(this).removeClass('active');
  1347.             }
  1348.         });
  1349.  
  1350.         // set radio buttons
  1351.         $customizeMenuRadioBtns.each(function() {
  1352.             var name = $(this).prop('name');
  1353.             var value = $(this).val();
  1354.  
  1355.             if (themeSettings[name] === value) {
  1356.                 $(this).prop("checked", true );
  1357.             }
  1358.             else {
  1359.                 $(this).prop("checked", false );
  1360.             }
  1361.         });
  1362.     }
  1363.  
  1364.     /************************************************
  1365.     *           Update theme color
  1366.     *************************************************/
  1367.     function setThemeColor(){
  1368.         config.chart.colorPrimary = tinycolor($ref.find(".chart .color-primary").css("color"));
  1369.         config.chart.colorSecondary = tinycolor($ref.find(".chart .color-secondary").css("color"));
  1370.     }
  1371.  
  1372.     /************************************************
  1373.     *               Storage Functions
  1374.     *************************************************/
  1375.  
  1376.     function getThemeSettings() {
  1377.         var settings = (localStorage.getItem('themeSettings')) ? JSON.parse(localStorage.getItem('themeSettings')) : {};
  1378.  
  1379.         settings.headerPosition = settings.headerPosition || '';
  1380.         settings.sidebarPosition = settings.sidebarPosition || '';
  1381.         settings.footerPosition = settings.footerPosition || '';
  1382.  
  1383.         return settings;
  1384.     }
  1385.  
  1386.     function saveThemeSettings() {
  1387.         localStorage.setItem('themeSettings', JSON.stringify(themeSettings));
  1388.     }
  1389.  
  1390. });
  1391. $(function() {
  1392.  
  1393.     $("body").addClass("loaded");
  1394.  
  1395. });
  1396.  
  1397.  
  1398. /***********************************************
  1399. *        NProgress Settings
  1400. ***********************************************/
  1401.  
  1402. // start load bar
  1403. NProgress.start();
  1404.  
  1405. // end loading bar
  1406. NProgress.done();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement