(function ($) { 'use strict'; /** * All of the code for your admin-facing JavaScript source * should reside in this file. * * Note: It has been assumed you will write jQuery code here, so the * $ function reference has been prepared for usage within the scope * of this function. * * This enables you to define handlers, for when the DOM is ready: * * $(function() { * * }); * * When the window is loaded: * * $( window ).load(function() { * * }); * * ...and/or other possibilities. * * Ideally, it is not considered best practise to attach more than a * single DOM-ready or window-load handler for a particular page. * Although scripts in the WordPress core, Plugins and Themes may be * practising this, we should strive to set a better example in our own work. */ // Instantiates the variable that holds the media library frame. var metaImageFrame; // Runs when the media button is clicked. $('#adfoxly-image_button').click(function (e) { // Get the btn var btn = e.target; // Check if it's the upload button if (!btn || !$(btn).attr('data-media-uploader-target')) return; // Get the field target var field = $(btn).data('media-uploader-target'); // Prevents the default action from occuring. e.preventDefault(); // Sets up the media library frame metaImageFrame = wp.media.frames.metaImageFrame = wp.media({ title: "Choose or Upload Media", button: {text: 'Use this file'}, }); // Runs when an image is selected. metaImageFrame.on('select', function () { // Grabs the attachment selection and creates a JSON representation of the model. var media_attachment = metaImageFrame.state().get('selection').first().toJSON(); // Sends the attachment URL to our custom image input field. $(field).val(media_attachment.url); $('#adfoxly-ad-preview').attr('src', media_attachment.url); $('#adfoxly-ad-preview-summary').attr('src', media_attachment.url); $('#adfoxly-ad-name').attr('value', media_attachment.title); $('#adfoxly-ad-name-summary').attr('value', media_attachment.title); }); // Opens the media library frame. metaImageFrame.open(); }); })(jQuery); $(document).ready(function() { var primaryColor = getComputedStyle(document.body).getPropertyValue('--primary'); var secondaryColor = getComputedStyle(document.body).getPropertyValue('--secondary'); var successColor = getComputedStyle(document.body).getPropertyValue('--success'); var warningColor = getComputedStyle(document.body).getPropertyValue('--warning'); var dangerColor = getComputedStyle(document.body).getPropertyValue('--danger'); var infoColor = getComputedStyle(document.body).getPropertyValue('--info'); var darkColor = getComputedStyle(document.body).getPropertyValue('--dark'); var lightColor = getComputedStyle(document.body).getPropertyValue('--light'); var lineChartStyleOption_2 = { scales: { yAxes: [{ display: false }], xAxes: [{ display: false }] }, legend: { display: false }, elements: { point: { radius: 0 }, line: { tension: 0 } }, stepsize: 100 }; if ($('#statistics-graph-1').length) { var lineChartCanvas = $("#statistics-graph-1").get(0).getContext("2d"); var gradientStrokeFill_1 = lineChartCanvas.createLinearGradient(1, 2, 1, 400); gradientStrokeFill_1.addColorStop(0, '#fff'); gradientStrokeFill_1.addColorStop(1, infoColor); var lineChart = new Chart(lineChartCanvas, { type: 'line', data: { labels: ["Day 1", "Day 2", "Day 3", "Day 4", "Day 5", "Day 6", "Day 7"], datasets: [{ label: 'Profit', data: [3, 9, 7, 5, 7, 2, 8], borderColor: infoColor, backgroundColor: gradientStrokeFill_1, borderWidth: 2, fill: true }] }, options: lineChartStyleOption_2 }); } if ($('#statistics-graph-2').length) { var lineChartCanvas = $("#statistics-graph-2").get(0).getContext("2d"); var gradientStrokeFill_1 = lineChartCanvas.createLinearGradient(1, 2, 1, 400); gradientStrokeFill_1.addColorStop(0, '#fff'); gradientStrokeFill_1.addColorStop(1, primaryColor); var lineChart = new Chart(lineChartCanvas, { type: 'line', data: { labels: ["Day 1", "Day 2", "Day 3", "Day 4", "Day 5", "Day 6", "Day 7"], datasets: [{ label: 'Profit', data: [7, 9, 2, 2, 8, 7, 9], borderColor: primaryColor, backgroundColor: gradientStrokeFill_1, borderWidth: 2, fill: true }] }, options: lineChartStyleOption_2 }); } if ($('#statistics-graph-3').length) { var lineChartCanvas = $("#statistics-graph-3").get(0).getContext("2d"); var gradientStrokeFill_1 = lineChartCanvas.createLinearGradient(1, 2, 1, 400); gradientStrokeFill_1.addColorStop(0, '#fff'); gradientStrokeFill_1.addColorStop(1, warningColor); var lineChart = new Chart(lineChartCanvas, { type: 'line', data: { labels: ["Day 1", "Day 2", "Day 3", "Day 4", "Day 5", "Day 6", "Day 7"], datasets: [{ label: 'Profit', data: [5, 4, 7, 2, 9, 2, 8], borderColor: warningColor, backgroundColor: gradientStrokeFill_1, borderWidth: 2, fill: true }] }, options: lineChartStyleOption_2 }); } if ($('#statistics-graph-4').length) { var lineChartCanvas = $("#statistics-graph-4").get(0).getContext("2d"); var gradientStrokeFill_1 = lineChartCanvas.createLinearGradient(1, 2, 1, 400); gradientStrokeFill_1.addColorStop(0, '#fff'); gradientStrokeFill_1.addColorStop(1, dangerColor); var lineChart = new Chart(lineChartCanvas, { type: 'line', data: { labels: ["Day 1", "Day 2", "Day 3", "Day 4", "Day 5", "Day 6", "Day 7"], datasets: [{ label: 'Profit', data: [5, 2, 5, 2, 4, 4, 1], borderColor: dangerColor, backgroundColor: gradientStrokeFill_1, borderWidth: 2, fill: true }] }, options: lineChartStyleOption_2 }); } }); $(document).ready(function ($) { $('.open-popover').popover({ html: true, trigger: 'hover', content: function () { return ''; } }); var $notice = $("html").find(".notice"); var $upgradeNotice = $("html").find(".update-nag"); function createEditor(name) { // find the textarea var textarea = document.querySelector("form textarea[name=" + name + "]"); var editor1 = document.querySelector("textarea[name=" + name + "]"); // create ace editor var editor = ace.edit(); // editor.container.style.height = "100px" editor.setTheme("ace/theme/monokai"); editor.getSession().setMode("ace/mode/html"); editor.session.setValue(textarea.value); // replace textarea with ace textarea.parentNode.insertBefore(editor.container, textarea); textarea.style.display = "none"; // find the parent form and add submit event listener var form = textarea; while (form && form.localName != "form") form = form.parentNode; editor.getSession().on('change', function() { // alert('ha!'); textarea.value = editor.getValue(); // update() }); form.addEventListener("submit", function () { // update value of textarea to match value in ace textarea.value = editor.getValue(); }, true) } if ($("#adfoxly-facebook-pixel-code").length) { // createEditor("adfoxly-facebook-pixel-code"); } if ($("#test123").length) { // createEditor("test123"); } // if(window.CodeMirror) { $("#adfoxly-facebook-pixel-code").each(function() { var editor = CodeMirror.fromTextArea(this, { lineNumbers: true, theme: "duotone-dark", mode: 'javascript', height: 200 }); editor.setSize("100%", 200); }); // } if ($('#adfoxlyadsense').length) { // createEditor("adfoxlyadsense"); // createEditor("adfoxlyadsense"); // $(function () { // var editor = ace.edit("adfoxlyadsense"); // editor.setTheme("ace/theme/monokai"); // editor.getSession().setMode("ace/mode/html"); // document.getElementById('adfoxlyadsense'); // }); } if ($("input[name='adfoxly-format']")) { var $bannerAdFormat = $("input[name='adfoxly-format']:checked").val(); if ($bannerAdFormat === '1') { $('.ad-format-group-image').css('display', 'flex'); $('.ad-format-group-google-adsense').hide(); } else if ($bannerAdFormat === '2') { $('.ad-format-group-google-adsense').css('display', 'flex'); $('.ad-format-group-image').hide(); } } // adCampaign // admin.php?page=adfoxly-new#step-6 if ($("input[name='adfoxly-campaign-exists']")) { var $bannerAdCampaign = $("input[name='adfoxly-campaign-exists']:checked").val(); if ($bannerAdCampaign === 'no-campaign') { $('.ad-format-group-adfoxly-campaign-new-campaign-wrapper').hide(); $('.ad-format-group-adfoxly-campaign-choose-campaign-wrapper').hide(); } else if ($bannerAdCampaign === 'exists') { $('.ad-format-group-adfoxly-campaign-new-campaign-wrapper').hide(); $('.ad-format-group-adfoxly-campaign-choose-campaign-wrapper').css('display', 'flex'); } else if ($bannerAdCampaign === 'no-exists') { $('.ad-format-group-adfoxly-campaign-new-campaign-wrapper').css('display', 'flex'); $('.ad-format-group-adfoxly-campaign-choose-campaign-wrapper').hide(); if ($('#home2').length) { var $adFoxlyTabInnerWidth = $("#home2").innerWidth() - 30; $('.select2').css('width', $adFoxlyTabInnerWidth); } } } $(".custom-control").bind("click", function () { var $bannerAdCampaign = $("input[name='adfoxly-campaign-exists']:checked").val(); if ($bannerAdCampaign === 'no-campaign') { $('.ad-format-group-adfoxly-campaign-new-campaign-wrapper').hide(); $('.ad-format-group-adfoxly-campaign-choose-campaign-wrapper').hide(); } else if ($bannerAdCampaign === 'exists') { $('.ad-format-group-adfoxly-campaign-new-campaign-wrapper').hide(); $('.ad-format-group-adfoxly-campaign-choose-campaign-wrapper').css('display', 'flex'); } else if ($bannerAdCampaign === 'no-exists') { $('.ad-format-group-adfoxly-campaign-new-campaign-wrapper').css('display', 'flex'); $('.ad-format-group-adfoxly-campaign-choose-campaign-wrapper').hide(); if ($('#home2').length) { var $adFoxlyTabInnerWidth = $("#home2").innerWidth() - 30; $('.select2').css('width', $adFoxlyTabInnerWidth); } } }); if ($("input[name='adfoxly-adzone-is-rotate']") && $("input[name='adfoxly-adzone-how-rotate']") && $("input[name='adfoxly-adzone-rotate-time']")) { var $isRotate = $("input[name='adfoxly-adzone-is-rotate']:checked").val(); var $howRotate = $("input[name='adfoxly-adzone-how-rotate']:checked").val(); if ($isRotate === 'yes') { $("#adfoxly-adzone-how-rotate-wrapper").css('display', "flex"); if ($howRotate === 'time') { $("#adfoxly-adzone-rotate-time-wrapper").css('display', "flex"); } else { $("#adfoxly-adzone-rotate-time-wrapper").hide(); } } else { $("#adfoxly-adzone-how-rotate-wrapper").hide(); $("#adfoxly-adzone-rotate-time-wrapper").hide(); } $(".custom-control").bind("click", function () { var $isRotate = $("input[name='adfoxly-adzone-is-rotate']:checked").val(); var $howRotate = $("input[name='adfoxly-adzone-how-rotate']:checked").val(); if ($isRotate === 'yes') { $("#adfoxly-adzone-how-rotate-wrapper").css('display', "flex"); if ($howRotate === 'time') { $("#adfoxly-adzone-rotate-time-wrapper").css('display', "flex"); } else { $("#adfoxly-adzone-rotate-time-wrapper").hide(); } } else { $("#adfoxly-adzone-how-rotate-wrapper").hide(); $("#adfoxly-adzone-rotate-time-wrapper").hide(); } }); } if ($("input[name='adfoxly-statistics-status']") && $("input[name='adfoxly-statistics-type']") && $("input[name='adfoxly-statistics-gaid']")) { var $statisticsStatus = $("input[name='adfoxly-statistics-status']:checked").val(); var $statisticsType = $("input[name='adfoxly-statistics-type']:checked").val(); var $statisticsGaID = $("input[name='adfoxly-statistics-gaid-select']:checked").val(); if ($statisticsStatus === 'enabled') { $("#adfoxly-statistics-type-wrapper").css('display', "flex"); if ($statisticsType === 'google-analytics') { $("#adfoxly-statistics-gaid-wrapper").css('display', "flex"); if ($statisticsGaID === 'other') { $("#adfoxly-statistics-custom-gaid-wrapper").css('display', "flex"); } else { $("#adfoxly-statistics-custom-gaid-wrapper").hide(); } } else { $("#adfoxly-statistics-gaid-wrapper").hide(); $("#adfoxly-statistics-custom-gaid-wrapper").hide(); } } else { $("#adfoxly-statistics-type-wrapper").hide(); $("#adfoxly-statistics-gaid-wrapper").hide(); $("#adfoxly-statistics-custom-gaid-wrapper").hide(); } $(".custom-control").bind("click", function () { var $statisticsStatus = $("input[name='adfoxly-statistics-status']:checked").val(); var $statisticsType = $("input[name='adfoxly-statistics-type']:checked").val(); var $statisticsGaID = $("input[name='adfoxly-statistics-gaid-select']:checked").val(); var $bannerAdFormat = $("input[name='adfoxly-format']:checked").val(); if ($statisticsStatus === 'enabled') { $("#adfoxly-statistics-type-wrapper").css('display', "flex"); if ($statisticsType === 'google-analytics') { $("#adfoxly-statistics-gaid-wrapper").css('display', "flex"); if ($statisticsGaID === 'other') { $("#adfoxly-statistics-custom-gaid-wrapper").css('display', "flex"); } else { $("#adfoxly-statistics-custom-gaid-wrapper").hide(); } } else { $("#adfoxly-statistics-gaid-wrapper").hide(); $("#adfoxly-statistics-custom-gaid-wrapper").hide(); } } else { $("#adfoxly-statistics-type-wrapper").hide(); $("#adfoxly-statistics-gaid-wrapper").hide(); $("#adfoxly-statistics-custom-gaid-wrapper").hide(); } }); if ($("input[name='adfoxly-format']")) { $('#step-1-form .file-item').bind("click", function () { var $bannerAdFormat = $("input[name='adfoxly-format']:checked").val(); if ($bannerAdFormat === '1') { $('.ad-format-group-image').css('display', 'flex'); $('.ad-format-group-google-adsense').hide(); } else if ($bannerAdFormat === '2') { $('.ad-format-group-google-adsense').css('display', 'flex'); $('.ad-format-group-image').hide(); } }); } } $('#adfoxly-ad-preview-summary').attr('src', $('#adfoxly-ad-preview').attr('src')); // admin.php?page=adfoxly-campaigns if($(".adfoxly-timepicker").length) { $('.adfoxly-timepicker').timepicki(); } // admin.php?page=adfoxly-campaigns function adfoxlyCheckSpecificHours(that) { var $adfoxlyClickedDayName = $(that).attr('data-adfoxly-day'); if ($(".adfoxly-campaign-specific-hours-" + $adfoxlyClickedDayName).is(':checked')) { $(".adfoxly-campaign-specific-hour-start-" + $adfoxlyClickedDayName).removeAttr('disabled'); $(".adfoxly-campaign-specific-hour-end-" + $adfoxlyClickedDayName).removeAttr('disabled'); } else { $(".adfoxly-campaign-specific-hour-start-" + $adfoxlyClickedDayName).prop("disabled", true); $(".adfoxly-campaign-specific-hour-end-" + $adfoxlyClickedDayName).prop("disabled", true); } } $('.adfoxly-campaign-days').click(function() { adfoxlyCheckSpecificHours(this); }); }); $(function () { }); function showAdblockWarning() { $('.adfoxly-notices-wrapper').html('
\n' + '
\n' + '
\n' + '
Oh snap!
\n' + ' Please turn off AdBlock (or/and other blocking plugins). Some features could not works well.' + '
\n' + '
'); } window.onload = function () { if (window.adblock !== true) { showAdblockWarning(); } $('#smartwizard').smartWizard({ selected: 0, // Initial selected step, 0 = first step keyNavigation: false, // Enable/Disable keyboard navigation(left and right keys are used if enabled) autoAdjustHeight: true, // Automatically adjust content height cycleSteps: false, // Allows to cycle the navigation of steps backButtonSupport: true, // Enable the back button support useURLhash: true, // Enable selection of the step based on url hash toolbarSettings: { toolbarPosition: 'bottom', // none, top, bottom, both toolbarButtonPosition: 'left', // left, right showNextButton: false, // show/hide a Next button showPreviousButton: false, // show/hide a Previous button // toolbarExtraButtons: [ // $('').text('Finish') // .addClass('btn btn-info') // .on('click', function(){ // alert('Finsih button click'); // }), // $('').text('Cancel') // .addClass('btn btn-danger') // .on('click', function(){ // alert('Cancel button click'); // }) // ] }, anchorSettings: { anchorClickable: true, // Enable/Disable anchor navigation enableAllAnchors: false // Activates all anchors clickable all times // markDoneStep: true, // add done css // enableAnchorOnDoneStep: true // Enable/Disable the done steps navigation } }); $("#prev-btn").on("click", function () { $('#smartwizard').smartWizard("prev"); $("html, body").animate({ scrollTop: 0 }, "slow"); return true; }); $("#next-btn").on("click", function () { var $activeTab = $(".step-anchor").find('.active').find('a').attr('href'); if ($activeTab == '#step-6') { $("#new-ad-wizard-form").submit(); } else { $($activeTab + '-form').parsley().whenValidate().done(function () { $('#smartwizard').smartWizard("next"); $("html, body").animate({ scrollTop: 0 }, "fast"); return true; }); } }); $("#save-btn").on("click", function () { $("#new-ad-wizard-form").submit(); }); function wizard_summary() { $("#adfoxly-campaigns-start-date-summary-wrapper").hide(); $("#adfoxly-campaigns-end-date-summary-wrapper").hide(); $("#adfoxly-ad-name-summary").html($("#adfoxly-ad-name").val()); $("#adfoxly-target-url-summary").html($("#adfoxly-target-url").val()); var $listOfPlaces = $('.form-check-flat .custom-control-input:checkbox:checked'); var placesNames = ''; $listOfPlaces.each(function( index ) { if (placesNames === '') { placesNames = $($listOfPlaces[index]).parent().find('label').html(); } else { placesNames = placesNames + ", " + $( $listOfPlaces[index]).parent().find('label').html(); } }); $("#adfoxly-places-summary").html(placesNames); var $listOfCampaigns = $('.ad-format-group-adfoxly-campaign-choose-campaign-wrapper .custom-control-input:checkbox:checked'); if ($('#adfoxly-campaign-exists_no-exists').is(":checked")) { $("#adfoxly-campaigns-summary").html($("#adfoxly-campaign-name").val()); } else { var campaignsNames = ''; $listOfCampaigns.each(function( index ) { if (campaignsNames === '') { campaignsNames = $($listOfCampaigns[index]).parent().parent().find('label').html() } else { campaignsNames = campaignsNames + ", " + $($listOfCampaigns[index]).parent().parent().find('label').html() } }); $("#adfoxly-campaigns-summary").html(campaignsNames); } if ( $("#adfoxly-ad-campaign-start").val() !== '' && $('#adfoxly-campaign-exists_no-exists').is(":checked")) { $("#adfoxly-campaigns-start-date-summary").html( $("#adfoxly-ad-campaign-start").val() ); $("#adfoxly-campaigns-start-date-summary-wrapper").show(); } if ( $("#adfoxly-ad-campaign-end").val() !== '' && $('#adfoxly-campaign-exists_no-exists').is(":checked")) { $("#adfoxly-campaigns-end-date-summary").html( $("#adfoxly-ad-campaign-end").val() ); $("#adfoxly-campaigns-end-date-summary-wrapper").show(); } } $("#next-btn").on("click", function () { var $activeTab = $(".step-anchor").find('.active').find('a').attr('href'); if ($activeTab == '#step-6') { wizard_summary(); } }); $(".nav-link").on("click", function () { var $activeTab = $(".step-anchor").find('.active').find('a').attr('href'); if ($activeTab == '#step-6') { wizard_summary(); } }); $("#smartwizard").show(); $(".loaded-content").show(); $(".loader").hide(); $(".loading-content").hide(); var notices = document.querySelectorAll(".notice"); var upgradeNotices = document.querySelectorAll(".update-nag"); var freemiusNotices = document.querySelectorAll(".fs-notice"); [].forEach.call(notices, function (notice) { notice.setAttribute("style", 'display: block'); // Get a reference to the element, before we want to insert the element var sp2 = document.querySelector(".adfoxly-notices-wrapper"); // Get a reference to the parent element var parentDiv = sp2.parentNode; // Insert the new element into the DOM before sp2 sp2.appendChild(notice); }); [].forEach.call(upgradeNotices, function (notice) { // notice.setAttribute("style", 'display: none'); // Get a reference to the element, before we want to insert the element var sp2 = document.querySelector(".adfoxly-notices-wrapper"); // Get a reference to the parent element var parentDiv = sp2.parentNode; // Insert the new element into the DOM before sp2 sp2.appendChild(notice); }); [].forEach.call(freemiusNotices, function (notice) { // notice.setAttribute("style", 'display: none'); // Get a reference to the element, before we want to insert the element var sp2 = document.querySelector(".adfoxly-notices-wrapper"); // Get a reference to the parent element var parentDiv = sp2.parentNode; // Insert the new element into the DOM before sp2 sp2.appendChild(notice); }); if ($('#dashboard-area-chart').length) { function roundNearest(num, acc) { if (acc < 0) { num *= acc; num = Math.round(num); num /= acc; return num; } else { num /= acc; num = Math.round(num); num *= acc; return num; } } var $data = $('#dashboard-area-chart').attr('data-views'); var $labels = $('#dashboard-area-chart').attr('data-labels'); var $dataClicks = $('#dashboard-area-chart').attr('data-clicks'); // var $labels = $('#dashboard-area-chart').attr('data-labels'); var $max = $('#dashboard-area-chart').attr('data-max'); // var $data = '1,30,7'; // var $array = $data.substring(0, str.length - 1); var $array = JSON.parse("[" + $data + "]"); var $arrayClicks = JSON.parse("[" + $dataClicks + "]"); var $labelsArray = $labels.split(","); if ($max < 10) { var newmax = roundNearest(JSON.parse($max), 1); newmax = newmax; } else if ($max < 100) { var newmax = roundNearest(JSON.parse($max), 10); newmax = newmax + 10; } else if ($max < 1000) { var newmax = roundNearest(JSON.parse($max), 10); newmax = newmax + 10; } else if ($max < 10000) { var newmax = roundNearest(JSON.parse($max), 100); newmax = newmax + 100; } else { var newmax = roundNearest(JSON.parse($max), 1000); newmax = newmax + 1000; } // var newmax = roundNearest(newmax, 200); var steps = newmax / 10; steps = roundNearest(steps, 100); var lineChartCanvas = $("#dashboard-area-chart").get(0).getContext("2d"); var data = { labels: $labelsArray, datasets: [{ label: 'Clicks', data: $arrayClicks, backgroundColor: 'rgba(63,82,227,.8)', borderWidth: 0, borderColor: 'transparent', pointBorderWidth: 0, pointRadius: 3.5, pointBackgroundColor: 'transparent', pointHoverBackgroundColor: 'rgba(63,82,227,.8)', }, { label: 'Views', data: $array, backgroundColor: 'rgba(254,86,83,.7)', borderWidth: 0, borderColor: 'transparent', pointBorderWidth: 0 , pointRadius: 3.5, pointBackgroundColor: 'transparent', pointHoverBackgroundColor: 'rgba(254,86,83,.8)', } ] }; var options = { responsive: true, maintainAspectRatio: true, scales: { yAxes: [{ gridLines: { color: '#f2f2f2' }, ticks: { beginAtZero: true, min: 0, max: newmax, stepSize: steps, } }], xAxes: [{ gridLines: { color: '#f2f2f2' }, ticks: { beginAtZero: true } }] }, legend: { display: true }, elements: { point: { radius: 2 } }, layout: { padding: { left: 0, right: 0, top: 0, bottom: 0 } }, stepsize: 1 }; var lineChart = new Chart(lineChartCanvas, { type: 'line', data: data, options: options }); } if ($('#trafficSourceDoughnutChart').length) { var $dataClicks = $('#trafficSourceDoughnutChart').attr('data-clicks'); var $arrayClicks = JSON.parse("[" + $dataClicks + "]"); var $dataBannerNames = $('#trafficSourceDoughnutChart').attr('data-banners'); var $arrayBannerNames = JSON.parse("[" + $dataBannerNames + "]"); var ctx = document.getElementById("trafficSourceDoughnutChart").getContext('2d'); var myChart = new Chart(ctx, { type: 'pie', data: { datasets: [{ data: $arrayClicks, backgroundColor: [ '#191d21', '#63ed7a', '#ffa426', '#fc544b', '#6777ef', ], label: 'Dataset 1' }], labels: $arrayBannerNames }, options: { responsive: true, legend: { position: 'bottom' } } }); } if ($('#trafficSourceDoughnutChart2').length) { var $dataClicks = $('#trafficSourceDoughnutChart2').attr('data-clicks'); var $arrayClicks = JSON.parse("[" + $dataClicks + "]"); var $dataBannerNames = $('#trafficSourceDoughnutChart2').attr('data-banners'); var $arrayBannerNames = JSON.parse("[" + $dataBannerNames + "]"); var ctx = document.getElementById("trafficSourceDoughnutChart2").getContext('2d'); var myChart = new Chart(ctx, { type: 'pie', data: { datasets: [{ data: $arrayClicks, backgroundColor: [ '#191d21', '#63ed7a', '#ffa426', '#fc544b', '#6777ef', ], label: 'Dataset 1' }], labels: $arrayBannerNames }, options: { responsive: true, legend: { position: 'bottom' } } }); } if ( $('#home2').length ) { var $adFoxlyTabInnerWidth = $("#home2").innerWidth() - 30; $('.select2').css('width', $adFoxlyTabInnerWidth); } if ( $(".inputtags").length ) { $(".inputtags").tagsinput('items'); } $('form input').keydown(function (e) { if (e.keyCode == 13) { var inputs = $(this).parents("form").eq(0).find(":input"); if (inputs[inputs.index(this) + 1] != null) { inputs[inputs.index(this) + 1].focus(); } e.preventDefault(); return false; } }); // Timepicker // if($(".timepicker").length) { // } }; $( window ).resize(function() { if ($('#home2').length) { var $adFoxlyTabInnerWidth = $("#home2").innerWidth() - 30; $('.select2').css('width', $adFoxlyTabInnerWidth); } });