| 1 |
jQuery(document).ready(function ($) { |
| 2 |
//Export page |
| 3 |
$('#bulk-action-selector-top option[value="exportsnp"]').css('color', '#999').prop('disabled', true); |
| 4 |
|
| 5 |
// |
| 6 |
$("a#winp-snippet-status-switch").on('click', function (e) { |
| 7 |
e.preventDefault(); |
| 8 |
var href = $(this); |
| 9 |
href.addClass('winp-snippet-switch-loader'); |
| 10 |
jQuery.post(ajaxurl, { |
| 11 |
action: 'change_snippet_status', |
| 12 |
snippet_id: href.data('snippet-id'), |
| 13 |
_ajax_nonce: winp_ajax_nonce, |
| 14 |
}).done(function (result) { |
| 15 |
href.removeClass('winp-snippet-switch-loader'); |
| 16 |
if (result.error_message) { |
| 17 |
if (result.alert) { |
| 18 |
alert(result.error_message); |
| 19 |
} |
| 20 |
console.error(result.error_message); |
| 21 |
|
| 22 |
href.removeClass('winp-snippet-switch-loader'); |
| 23 |
} else { |
| 24 |
console.log(result.message); |
| 25 |
href.toggleClass('winp-inactive'); |
| 26 |
} |
| 27 |
}); |
| 28 |
}); |
| 29 |
|
| 30 |
$("input.wbcr_inp_input_priority").on('change', function (e) { |
| 31 |
var previous = e.currentTarget.defaultValue; |
| 32 |
var input = $(this); |
| 33 |
input.attr('disabled', true); |
| 34 |
input.addClass('winp-loader'); |
| 35 |
jQuery.post(ajaxurl, { |
| 36 |
action: 'change_priority', |
| 37 |
snippet_id: input.data('snippet-id'), |
| 38 |
priority: input.val(), |
| 39 |
_ajax_nonce: winp_ajax_nonce, |
| 40 |
}).done(function (result) { |
| 41 |
//console.log(result); |
| 42 |
if (result.error_message) { |
| 43 |
console.error(result.error_message); |
| 44 |
input.val(previous); |
| 45 |
} else { |
| 46 |
console.log(result.message); |
| 47 |
} |
| 48 |
input.removeAttr('disabled'); |
| 49 |
input.removeClass('winp-loader'); |
| 50 |
}); |
| 51 |
}); |
| 52 |
|
| 53 |
$("input.wbcr_inp_input_priority").on('keydown', stop_enter); |
| 54 |
$("input.wbcr_inp_input_priority").on('keyup', stop_enter); |
| 55 |
$("input.wbcr_inp_input_priority").on('keypress', stop_enter); |
| 56 |
}); |
| 57 |
|
| 58 |
function stop_enter(e) { |
| 59 |
if (e.keyCode === 13) { |
| 60 |
e.preventDefault(); |
| 61 |
jQuery(this).blur(); |
| 62 |
} |
| 63 |
} |