(function ($) { $(function () { $('#artsopolis-calendar-info').on('change', '#data-source', function() { if ($(this).val() == 'xml') { $('#xml-block').show(); $('#token-block').hide(); } else { $('#xml-block').hide(); $('#token-block').show(); } }); $('#artsopolis-calendar-list-categories').on('click', 'input', function() { $('input[name^="artsopolis_calendar_options"][name$="[has_changed]"]').val(1); }); $( '#artsopolis-calendar-settings-form input[type="submit"]' ).click( function() { var error = false; var _arr_urls = $('.artsopolist-calendar-input-url'); var urlregex = new RegExp( "^(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$"); $.each( _arr_urls, function(i, v) { if ( $( v ).val() && ! urlregex.test( $( v ).val() ) ) { $( '#apollo-notice' ).show(); $( v ).addClass( 'apollo-input-error' ); $( '[data-id=\"'+$( v ).attr( 'name' ) +'-url\"]' ).show(); error = true; } else { $( '[data-id="'+$( v ).attr( 'name' ) +'-url"]' ).hide(); $( v ).removeClass( 'apollo-input-error' ); } }); if ( error ) { $( '.updated.settings-error' ).hide(); $( '.error.settings-error' ).show(); $('html,body').animate({ scrollTop: $('.artsopolis-calendar-tabs-menu').offset().top }, 1000); return false; } }); $(".artsopolist-calendar-input-url[type=text]").bind( 'keyup change', check_url ); $( '.artsopolist-calendar-input-url' ).focus(function() { if ( ! $(this).val() ) { $(this).val('http://'); } }); $( '#wrapper-category' ).on( 'click', '.sub-row label', function() { var checkbox = $( this ).prev(); if ( ! checkbox.attr('checked' ) ) { checkbox.attr( 'checked', 'checked' ); } else { checkbox.removeAttr( 'checked' ); } } ); $( '#ac-filter-by-feed' ).change( function() { window.location.href = $(this).data().href + $(this).val(); }); // handle active plugin menu if ( ( $( '#ac-feature-event-page' ) && $( '#ac-feature-event-page' ).length ) || $( '#ac-feed-frm' ) && $( '#ac-feed-frm' ).length ) { $( '#menu-plugins' ).addClass('wp-has-current-submenu wp-has-submenu'); $( '#menu-plugins > a' ).addClass( 'wp-has-current-submenu' ); $( 'a[href="plugins.php?page=admin-artsopolis-calendar"]' ).parent().addClass( 'current' ); } // Loads the color pickers $('.nav-bg-color').wpColorPicker(); // Handle the fancy box for the logo $("a#ac-teaser-widget-logo-link").fancybox({}); $("a#ac-plugin-logo-link").fancybox({}); // Upload logo artsopolis_calendar_upload(); // Add sorting for featured events use jQuery Datatable add_sorting_data_table(); $('#artsopolis-calendar-settings-form').submit(check_artsopolis_calendar_form); $('#ac-show-list-territory').click(show_territories); $('input[name^="artsopolis_calendar_options"][name$="[feed_url]"]').keyup(function (e) { // Not ctrl v, ctrl a, f5, tab, ctrl c if (e.keyCode != 17 && e.keyCode != 65 && e.keyCode != 67 && e.keyCode != 9 && e.keyCode != 116) { clearTimeout($.data(this, 'timer')); if (e.keyCode == 13) { artsopolis_calendar_check_feed_url(); } else $(this).data('timer', setTimeout(artsopolis_calendar_check_feed_url, 500)); } }); $('input[name^="artsopolis_calendar_options]"][name$="[feed_url"]').focus(artsopolis_calendar_check_feed_url_empty); $('.artsopolis-calendar-settings-category .hide-show-subcategory').bind('click', hide_show_subcategory); $('input[name^="artsopolis_calendar_options"][name$="[category_xml_feed_url]"]').keyup(function (e) { // Not ctrl v, ctrl a, f5, tab, ctrl c if (e.keyCode != 17 && e.keyCode != 65 && e.keyCode != 67 && e.keyCode != 9 && e.keyCode != 116) { clearTimeout($.data(this, 'timer')); if (e.keyCode == 13) { artsopolis_calendar_check_category_xml_feed(); } else $(this).data('timer', setTimeout(artsopolis_calendar_check_category_xml_feed, 500)); } }); $('#arts-delete-plugin-logo').bind('click', artsopolis_calendar_delete_image_by_url); $('#arts-delete-teaser-logo').bind('click', artsopolis_calendar_delete_image_by_url); }); function check_artsopolis_calendar_form() { var messages = '', main_focus = $('input[name^="artsopolis_calendar_options"][name$="[feed_url]"]'); if ($('input[name^="artsopolis_calendar_options"][name$="[feed_valid]"]').val() == "0") { messages += '\n + The XML feed is invalid'; messages = "Warning:\n" + messages + "\n\n Do you want to continue ?"; } else { return true; } if(messages && confirm(messages)) { return true; } if(main_focus){ main_focus.focus(); } return false; } function show_territories() { var url = artsopolis_calendar_obj.admin_url + '/?action=ac_get_territories' tb_show("Territories List", url); return false; } function artsopolis_calendar_check_feed_url(callback) { var feed_url = $('input[name^="artsopolis_calendar_options"][name$="[feed_url]"]').val(); if (feed_url.length < 3 || ! feed_url.length) { $('#checking-xml-feed').hide(); $('.xml-feed .artsopolis-calendar-error').show(); $('.xml-feed .artsopolis-calendar-success').hide(); $('input[name^="artsopolis_calendar_options"][name$="[feed_valid]"]').val(0); artsopolis_calendar_hide_loading(); return false; } $('.xml-feed .artsopolis-calendar-success').hide(); $('.xml-feed .artsopolis-calendar-error').hide(); $('#checking-xml-feed').show(); artsopolis_calendar_show_loading(); $('#artsopolis-calendar-settings-form #submit').prop('disabled', true); $.ajax({ url: artsopolis_calendar_obj.admin_url, type: 'post', data: { 'action': 'ac_check_valid_feed_url', 'feed_url': encodeURI(feed_url) }, beforeSend: function() { $('#checking-xml-feed').attr('is-checking', 1); }, success: function(res) { var parent = $('.artsopolis-calendar-status-container'), success = true; $('#checking-xml-feed').attr('is-checking', 0); if (parseInt(res)) { $('.xml-feed .artsopolis-calendar-error').hide(); $('.xml-feed .artsopolis-calendar-success').show(); $('input[name^="artsopolis_calendar_options"][name$="[feed_valid]"]').val(1); } else { $('.xml-feed .artsopolis-calendar-error').show(); $('.xml-feed .artsopolis-calendar-success').hide(); $('input[name^="artsopolis_calendar_options"][name$="[feed_valid]"]').val(0); success = false; } if ($('input[name=feed_hidden]').val() != feed_url) { $('input[name^="artsopolis_calendar_options"][name$="[has_changed]"]').val(1); } else { $('input[name^="artsopolis_calendar_options"][name$="[has_changed]"]').val(0); } if (typeof(callback) === 'function') { callback({ success: success }); } parent.show(); artsopolis_calendar_hide_loading(); if (! parseInt($('#checking-category-xml').attr('is-checking'))) { $('#artsopolis-calendar-settings-form #submit').prop('disabled', false); } $('#checking-xml-feed').hide(); }, error: function(errorThrown) { console.log(errorThrown); } }); } function artsopolis_calendar_check_category_xml_feed(callback) { var url = $('input[name^="artsopolis_calendar_options"][name$="[category_xml_feed_url]"]').val(); if (! url.length) { $('.xml-category .artsopolis-calendar-error').show(); $('#wrapper-category').html(''); $('.xml-category .artsopolis-calendar-success').hide(); $('input[name^="artsopolis_calendar_options"][name$="[category_valid]"]').val(0); return false; } $.ajax({ url: artsopolis_calendar_obj.admin_url, type: 'post', data: { 'action': 'ac_check_valid_category_xml_url', 'category_xml_feed_url': encodeURI(url), 'fid' : $( '#ac-feed-id' ).val(), }, beforeSend: function() { $('#checking-category-xml').attr('is-checking', 1); $('.xml-category .artsopolis-calendar-success').hide(); $('.xml-category .artsopolis-calendar-error').hide(); $('#checking-category-xml').show(); artsopolis_calendar_show_loading(); $('#artsopolis-calendar-settings-form #submit').prop('disabled', true); }, success: function(res) { var parent = $('.artsopolis-calendar-status-container'); $('#checking-category-xml').attr('is-checking', 0); $('#wrapper-category').html(res); if (res) { $('.xml-category .artsopolis-calendar-error').hide(); $('.xml-category .artsopolis-calendar-success').show(); $('input[name^="artsopolis_calendar_options"][name$="[category_valid]"]').val(1); } else { $('.xml-category .artsopolis-calendar-error').show(); $('.xml-category .artsopolis-calendar-success').hide(); $('input[name^="artsopolis_calendar_options"][name$="[category_valid]"]').val(0); } parent.show(); artsopolis_calendar_hide_loading(); if (! parseInt($('#checking-xml-feed').attr('is-checking'))) { $('#artsopolis-calendar-settings-form #submit').prop('disabled', false); } $('#checking-category-xml').hide(); }, error: function(errorThrown) { console.log(errorThrown); } }); } function artsopolis_calendar_show_loading() { if(document.getElementById("TB_overlay") === null) { jQuery("body").append("
"); jQuery("#TB_overlay").addClass("TB_overlayBG");//use background and opacity } console.log(imgLoader.src); jQuery("body").append("