| 1 |
(function( $ ) { |
| 2 |
'use strict'; |
| 3 |
|
| 4 |
/** |
| 5 |
* All of the code for your admin-facing JavaScript source |
| 6 |
* should reside in this file. |
| 7 |
* |
| 8 |
* Note: It has been assumed you will write jQuery code here, so the |
| 9 |
* $ function reference has been prepared for usage within the scope |
| 10 |
* of this function. |
| 11 |
* |
| 12 |
* This enables you to define handlers, for when the DOM is ready: |
| 13 |
* |
| 14 |
* $(function() { |
| 15 |
* |
| 16 |
* }); |
| 17 |
* |
| 18 |
* When the window is loaded: |
| 19 |
* |
| 20 |
* $( window ).load(function() { |
| 21 |
* |
| 22 |
* }); |
| 23 |
* |
| 24 |
* ...and/or other possibilities. |
| 25 |
* |
| 26 |
* Ideally, it is not considered best practise to attach more than a |
| 27 |
* single DOM-ready or window-load handler for a particular page. |
| 28 |
* Although scripts in the WordPress core, Plugins and Themes may be |
| 29 |
* practising this, we should strive to set a better example in our own work. |
| 30 |
*/ |
| 31 |
|
| 32 |
jQuery(document).ready(function($) { |
| 33 |
$('.event-ajax-indicator').on('click submit', function () { |
| 34 |
if ($(this).find('.wdk-ajax-indicator').length) { |
| 35 |
$(this).find('.wdk-ajax-indicator').removeClass('hidden') |
| 36 |
.removeClass('wdk-hidden'); |
| 37 |
$(this).find('.hidden-onloading').addClass('wdk-hidden'); |
| 38 |
} |
| 39 |
else { |
| 40 |
$(this).parent().find('.wdk-ajax-indicator').removeClass('hidden'); |
| 41 |
} |
| 42 |
}) |
| 43 |
|
| 44 |
/* date time fields init */ |
| 45 |
if ($('.wdk-fielddate').length && typeof $.datepicker != 'undefined') { |
| 46 |
$('.wdk-fielddate').each(function () { |
| 47 |
let dateFormat = 'yy-mm-dd'; |
| 48 |
if ($(this).attr('date-format')) |
| 49 |
dateFormat = $(this).attr('date-format'); |
| 50 |
$(this).datepicker({ dateFormat: dateFormat }); |
| 51 |
}) |
| 52 |
}; |
| 53 |
|
| 54 |
if ($('.wdk-fielddate_from').length && $('.wdk-fielddate_to').length && typeof $.datepicker != 'undefined') { |
| 55 |
var dateFormat, from, to; |
| 56 |
const getDate = ( element ) => { |
| 57 |
var date; |
| 58 |
try { |
| 59 |
date = $.datepicker.parseDate( dateFormat, element.value ); |
| 60 |
} catch( error ) { |
| 61 |
date = null; |
| 62 |
} |
| 63 |
return date; |
| 64 |
} |
| 65 |
|
| 66 |
dateFormat = 'yy-mm-dd'; |
| 67 |
if ($('.wdk-fielddate_from').attr('date-format')) |
| 68 |
dateFormat = $('.wdk-fielddate_from').attr('date-format'); |
| 69 |
|
| 70 |
from = $('.wdk-fielddate_from') |
| 71 |
.datepicker({ |
| 72 |
dateFormat: dateFormat, |
| 73 |
onSelect: function( selectedDate ) { |
| 74 |
to.datepicker("option", "minDate", selectedDate ); |
| 75 |
setTimeout(function(){ |
| 76 |
to.datepicker('show'); |
| 77 |
}, 16); |
| 78 |
} |
| 79 |
}) |
| 80 |
|
| 81 |
to =$('.wdk-fielddate_to').datepicker({ |
| 82 |
dateFormat: dateFormat |
| 83 |
}) |
| 84 |
.on( "change", function() { |
| 85 |
from.datepicker( "option", "maxDate", getDate( this ) ); |
| 86 |
}); |
| 87 |
} |
| 88 |
|
| 89 |
jQuery(document).ready( function($) { |
| 90 |
$( "ul#adminmenu a[href*='wordpress.org/support/plugin/wpdirectorykit']" ).attr( 'target', '_blank' ); |
| 91 |
$( "ul#adminmenu a[href*='wpdirectorykit.com/contact.html']" ).attr( 'target', '_blank' ); |
| 92 |
$( "ul#adminmenu a[href*='wpdirectorykit.com/documentation']" ).attr( 'target', '_blank' ); |
| 93 |
}); |
| 94 |
}) |
| 95 |
|
| 96 |
})( jQuery ); |
| 97 |
|