(function( $ ) {
'use strict';
/**
* All of the code for your admin-specific JavaScript source
* should reside in this file.
*
* Note that this assume you're going to use jQuery, so it prepares
* the $ function reference to be used within the scope of this
* function.
*
* From here, you're able to define handlers for when the DOM is
* ready:
*
* $(function() {
*
* });
*
* Or when the window is loaded:
*
* $( window ).load(function() {
*
* });
*
* ...and so on.
*
* Remember that ideally, we should not attach any more than a single DOM-ready or window-load handler
* for any particular page. Though other scripts in WordPress core, other plugins, and other themes may
* be doing this, we should try to minimize doing that in our own work.
*/
$(document).ready(function(){
$('.datepicker').datepicker({
minDate: +1,
});
$("#app_form_fields").sortable({
placeholder: "ui-state-highlight",
update: function( event, ui ) {
$('#aol_keys_order_wrapper').empty(); //
$( '#app_form_fields tr' ).each(function(){
var field = $(this).data( "id" );
$('#aol_keys_order_wrapper').append('');
});
}
});
/*Ad editor Scripts*/
/*Application Field Type change for new Field only*/
$('#adapp_field_type').change(function(){
var fieldType=$(this).val();
if(fieldType == 'checkbox' || fieldType == 'dropdown' || fieldType == 'radio'){
$('#adapp_field_options').show();
}
else{
$('#adapp_field_options').hide();
$('#adapp_field_options').val('');
}
});
/*Add Application Field (Group Fields)*/
$('#addField').click(function(){
var fieldNameRaw=$('#adapp_name').val(); // Get Raw value.
var fieldNameRaw = fieldNameRaw.trim(); // Remove White Spaces from both ends.
var fieldName = fieldNameRaw.replace(" ", "_"); //Replace white space with _.
var fieldType = $('#adapp_field_type').val();
var fieldOptions = $('#adapp_field_options').val();
var style;
var fieldTypeHtml = $('#adapp_field_type').html();
if(fieldName != ''){
$('#adapp_name').css('border','1px solid #ddd');
if(fieldType=='text' || fieldType=='email' || fieldType=='date' || fieldType == 'text_area'|| fieldType == 'file'){
style = "display:none";
}
else {
style = "";
$('#adapp_field_options').val('');
$('#adapp_field_options').hide();
}
$('#app_form_fields').append('
Required
Delete
');
$('#aol_keys_order_wrapper').append('');
$('.'+fieldName+' .'+fieldType).attr('selected','selected');
$('#adapp_name').val('');
$('#adapp_field_type').val('text');
}
else{
$('#adapp_name').css('border','1px solid #F00');
}
});
/* Application Field Type change for existing fields. */
$('#app_form_fields').on('change', 'tr td .adapp_field_type',function(){
var fieldType=$(this).val();
if(fieldType == 'checkbox' || fieldType == 'dropdown' || fieldType == 'radio'){
$(this).next().show();
}
else{
$(this).next().hide();
}
});
/*Add Job Feature*/
$('#addFeature').click(function(){
var fieldNameRaw=$('#adfeature_name').val(); // Get Raw value.
var fieldNameRaw = fieldNameRaw.trim(); // Remove White Spaces from both ends.
var fieldName = fieldNameRaw.replace(" ", "_"); //Replace white space with _.
var fieldVal = $('#adfeature_value').val();
var fieldVal = fieldVal.trim();
if(fieldName != '' && fieldVal!=''){
$('#ad_features').append('