var toggle_share = false; function mdocs_admin(plugin_url) { //INITIALIZE IRIS COLOR PICKER //jQuery('.mdocs-color-picker').wpColorPicker(); var cat_index = parseInt(jQuery('input[name$="[order]"]').last().prop('value'))+1; if (isNaN(cat_index)) cat_index = 1; jQuery('#mdocs-add-cat').click(function(event) { mdocs_set_onleave(); event.preventDefault(); jQuery('.mdocs-nofiles').parent().remove(); jQuery('#the-list').append('\ \ \ \ \ \ \ \ \ \ \ \ \ \ '); cat_index++; jQuery('input[id="mdocs-cat-remove-new"]').click(function() { jQuery(this).parent().parent().remove(); }); }); jQuery('input[id="mdocs-cat-remove"]').click(function() { var confirm = window.confirm(mdocs_js.category_delete); var cat = jQuery(this).prop('name'); if (confirm) { jQuery('[name="mdocs-cats['+cat+'][remove]"]').prop('value',1); jQuery('#mdocs-cats').submit(); } }); jQuery('#mdocs-file-status').change(function() { if (jQuery(this).val() == 'hidden') jQuery('#mdocs-post-status').prop('disabled','true'); else if (jQuery(this).val() == 'public') jQuery('#mdocs-post-status').removeAttr('disabled'); }); } function mdocs_set_onleave() { window.onbeforeunload = function() { return mdocs_js.leave_page;}; } function mdocs_reset_onleave() { window.onbeforeunload = null; } function mdocs_download_zip(zip_file) { window.location.href = '?mdocs-export-file='+zip_file; } function mdocs_download_version(version_file) { window.location.href = '?mdocs-version='+version_file; } function mdocs_delete_version(version_file, index, category, nonce) { var confirm = window.confirm(mdocs_js.version_delete); if (confirm) { window.location.href = 'admin.php?page=memphis-documents.php&cat='+category+'&action=delete-version&version-file='+version_file+'&mdocs-index='+index+'&mdocs-nonce='+nonce; } } function mdocs_download_file(mdocs_file) { window.location.href = '?mdocs-file='+mdocs_file; } function mdocs_share(mdocs_link,the_id) { if (toggle_share == false) { jQuery('#'+the_id+' .mdocs-share-link').remove(); jQuery('#'+the_id).append('"); toggle_share = true; } else { jQuery('#'+the_id+' .mdocs-share-link').remove(); toggle_share = false; } }