Add upstream
This commit is contained in:
@@ -0,0 +1,269 @@
|
||||
/* global ajaxurl, uploader */
|
||||
|
||||
var jQuery,
|
||||
mla_add_new_bulk_edit_vars,
|
||||
mla = {
|
||||
// Properties (for mla-set-parent-scripts, too)
|
||||
// mla.settings.uploadTitle
|
||||
// mla.settings.toggleClose
|
||||
// mla.settings.toggleOpen
|
||||
// mla.settings.areaOnTop
|
||||
// mla.settings.comma for flat taxonomy suggest
|
||||
// mla.settings.ajaxFailError for setParent
|
||||
// mla.settings.ajaxDoneError for setParent
|
||||
// mla.settings.useDashicons for setParent
|
||||
// mla.settings.useSpinnerClass for setParent
|
||||
settings: {},
|
||||
|
||||
// Utility functions
|
||||
utility: {
|
||||
getId : function( o ) {
|
||||
var id = jQuery( o ).closest( 'tr' ).attr( 'id' ),
|
||||
parts = id.split( '-' );
|
||||
return parts[ parts.length - 1 ];
|
||||
},
|
||||
|
||||
attachSearch : function( rowId ) {
|
||||
jQuery( rowId + ' .categorydiv' ).each( function(){
|
||||
var this_id = jQuery(this).attr('id'), taxonomyParts, taxonomy;
|
||||
|
||||
taxonomyParts = this_id.split('-');
|
||||
taxonomyParts.shift(); // taxonomy-
|
||||
taxonomy = taxonomyParts.join('-');
|
||||
|
||||
jQuery.extend( jQuery.expr[":"], {
|
||||
"matchTerms": function( elem, i, match, array ) {
|
||||
return ( elem.textContent || elem.innerText || "" ).toLowerCase().indexOf( ( match[3] || "" ).toLowerCase() ) >= 0;
|
||||
}
|
||||
});
|
||||
|
||||
jQuery( rowId + ' #' + taxonomy + '-searcher' ).addClass( 'wp-hidden-children' );
|
||||
jQuery( rowId + ' #' + taxonomy + 'checklist li' ).show();
|
||||
|
||||
jQuery( rowId + ' #search-' + taxonomy ).off();
|
||||
|
||||
jQuery( rowId + ' #search-' + taxonomy ).keydown( function( event ){
|
||||
|
||||
if( 13 === event.keyCode ) {
|
||||
event.preventDefault();
|
||||
jQuery( rowId + ' #search-' + taxonomy ).val( '' );
|
||||
jQuery( rowId + ' #' + taxonomy + '-searcher' ).addClass( 'wp-hidden-children' );
|
||||
|
||||
jQuery( rowId + ' #' + taxonomy + 'checklist li' ).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
jQuery( rowId + ' #search-' + taxonomy ).keypress( function( event ){
|
||||
|
||||
if( 13 === event.keyCode ) {
|
||||
event.preventDefault();
|
||||
jQuery( rowId + ' #search-' + taxonomy ).val( '' );
|
||||
jQuery( rowId + ' #' + taxonomy + '-searcher' ).addClass( 'wp-hidden-children' );
|
||||
|
||||
jQuery( rowId + ' #' + taxonomy + 'checklist li' ).show();
|
||||
return;
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
jQuery( rowId + ' #search-' + taxonomy ).keyup( function( event ){
|
||||
var searchValue, termList, matchingTerms;
|
||||
|
||||
if( 13 === event.keyCode ) {
|
||||
event.preventDefault();
|
||||
jQuery( rowId + ' #' + taxonomy + '-search-toggle' ).focus();
|
||||
return;
|
||||
}
|
||||
|
||||
searchValue = jQuery( rowId + ' #search-' + taxonomy ).val();
|
||||
termList = jQuery( rowId + ' #' + taxonomy + 'checklist li' );
|
||||
|
||||
if ( 0 < searchValue.length ) {
|
||||
termList.hide();
|
||||
} else {
|
||||
termList.show();
|
||||
}
|
||||
|
||||
matchingTerms = jQuery( rowId + ' #' + taxonomy + "checklist label:matchTerms('" + searchValue + "')");
|
||||
matchingTerms.closest( 'li' ).find( 'li' ).andSelf().show();
|
||||
matchingTerms.parents( rowId + ' #' + taxonomy + 'checklist li' ).show();
|
||||
} );
|
||||
|
||||
jQuery( rowId + ' #' + taxonomy + '-search-toggle' ).off();
|
||||
|
||||
jQuery( rowId + ' #' + taxonomy + '-search-toggle' ).click( function() {
|
||||
jQuery( rowId + ' #' + taxonomy + '-adder ').addClass( 'wp-hidden-children' );
|
||||
jQuery( rowId + ' #' + taxonomy + '-searcher' ).toggleClass( 'wp-hidden-children' );
|
||||
jQuery( rowId + ' #' + taxonomy + 'checklist li' ).show();
|
||||
|
||||
if ( false === jQuery( rowId + ' #' + taxonomy + '-searcher' ).hasClass( 'wp-hidden-children' ) ) {
|
||||
jQuery( rowId + ' #search-' + taxonomy ).val( '' ).removeClass( 'form-input-tip' );
|
||||
jQuery( rowId + ' #search-' + taxonomy ).focus();
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}); // .categorydiv.each,
|
||||
}
|
||||
},
|
||||
|
||||
// Components
|
||||
addNewBulkEdit: null,
|
||||
setParent: null
|
||||
};
|
||||
|
||||
( function( $ ) {
|
||||
// Localized settings and strings
|
||||
mla.settings = typeof mla_add_new_bulk_edit_vars === 'undefined' ? {} : mla_add_new_bulk_edit_vars;
|
||||
mla_add_new_bulk_edit_vars = void 0; // delete won't work on Globals
|
||||
|
||||
if ( typeof mla.settings.areaOnTop === 'undefined' ) {
|
||||
mla.settings.areaOnTop = false;
|
||||
};
|
||||
|
||||
mla.addNewBulkEdit = {
|
||||
init: function() {
|
||||
var blankContent, toggleButton, resetButton,
|
||||
bypass = $( '.upload-flash-bypass' ), title = $( '#wpbody .wrap' ).children ( 'h1, h2' ),
|
||||
uploadContent, uploadDiv = $( '#mla-add-new-bulk-edit-div' ).hide(); // Start with area closed up
|
||||
|
||||
if ( typeof mla.addTerm !== 'undefined' ) {
|
||||
mla.addTerm.init( '#mla-add-new-bulk-edit-div' );
|
||||
}
|
||||
mla.utility.attachSearch( '#mla-add-new-bulk-edit-div' );
|
||||
|
||||
$( '#bulk-edit-set-parent', uploadDiv ).on( 'click', function(){
|
||||
return mla.addNewBulkEdit.parentOpen();
|
||||
});
|
||||
|
||||
// Move the blank content out of the form so it won't pollute the serialize() results
|
||||
blankContent = $('#mla-blank-add-new-bulk-edit-div').detach();
|
||||
$( '#file-form' ).after( blankContent );
|
||||
|
||||
// Move the Open/Close Bulk Edit area toggleButton to save space on the page
|
||||
toggleButton = $( '#bulk-edit-toggle', uploadDiv ).detach();
|
||||
resetButton = $( '#bulk-edit-reset', uploadDiv ).detach();
|
||||
|
||||
if ( mla.settings.areaOnTop ) {
|
||||
toggleButton.appendTo( title );
|
||||
resetButton.appendTo( title );
|
||||
uploadContent = uploadDiv.detach();
|
||||
$( '#media-upload-notice' ).before( uploadContent );
|
||||
} else {
|
||||
toggleButton.appendTo( bypass );
|
||||
resetButton.appendTo( bypass );
|
||||
};
|
||||
|
||||
// Hook the "browser uploader" link to close the Bulk Edit area when it is in use
|
||||
toggleButton.siblings( 'a' ).on( 'click', function(){
|
||||
toggleButton.attr( 'title', mla.settings.toggleOpen );
|
||||
toggleButton.attr( 'value', mla.settings.toggleOpen );
|
||||
resetButton.hide();
|
||||
uploadDiv.hide();
|
||||
});
|
||||
|
||||
toggleButton.on( 'click', function(){
|
||||
return mla.addNewBulkEdit.formToggle();
|
||||
});
|
||||
|
||||
resetButton.on( 'click', function(){
|
||||
return mla.addNewBulkEdit.doReset();
|
||||
});
|
||||
|
||||
if ( mla.settings.areaOpen ) {
|
||||
mla.addNewBulkEdit.formToggle();
|
||||
};
|
||||
|
||||
//auto-complete/suggested matches for flat taxonomies
|
||||
$( 'textarea.mla_tags', uploadDiv ).each(function(){
|
||||
var taxname = $(this).attr('name').replace(']', '').replace('tax_input[', '');
|
||||
|
||||
$(this).suggest( ajaxurl + '?action=ajax-tag-search&tax=' + taxname, { delay: 500, minchars: 2, multiple: true, multipleSep: mla.settings.comma + ' ' } );
|
||||
});
|
||||
|
||||
uploader.bind( 'BeforeUpload', function( up, file ) {
|
||||
var formString = $( '#file-form' ).serialize();
|
||||
|
||||
up.settings.multipart_params.mlaAddNewBulkEditFormString = formString;
|
||||
});
|
||||
},
|
||||
|
||||
doReset : function(){
|
||||
var bulkDiv = $('#mla-add-new-bulk-edit-div'),
|
||||
blankDiv = $('#mla-blank-add-new-bulk-edit-div'),
|
||||
blankCategories = $('.inline-edit-categories', blankDiv ).html(),
|
||||
blankTags = $('.inline-edit-tags', blankDiv ).html(),
|
||||
blankFields = $('.inline-edit-fields', blankDiv ).html();
|
||||
|
||||
$('.inline-edit-categories', bulkDiv ).html( blankCategories ),
|
||||
$('.inline-edit-tags', bulkDiv ).html( blankTags ),
|
||||
$('.inline-edit-fields', bulkDiv ).html( blankFields );
|
||||
|
||||
if ( typeof mla.addTerm !== 'undefined' ) {
|
||||
mla.addTerm.init( '#mla-add-new-bulk-edit-div' );
|
||||
}
|
||||
mla.utility.attachSearch( '#mla-add-new-bulk-edit-div' );
|
||||
|
||||
$('#bulk-edit-set-parent', bulkDiv).on( 'click', function(){
|
||||
return mla.addNewBulkEdit.parentOpen();
|
||||
});
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
formToggle : function() {
|
||||
var toggleButton = $( '#bulk-edit-toggle' ), resetButton = $( '#bulk-edit-reset' ),
|
||||
area = $( '#mla-add-new-bulk-edit-div' );
|
||||
|
||||
// Expand/collapse the Bulk Edit area
|
||||
if ( 'none' === area.css( 'display' ) ) {
|
||||
toggleButton.attr( 'title', mla.settings.toggleClose );
|
||||
toggleButton.attr( 'value', mla.settings.toggleClose );
|
||||
resetButton.show();
|
||||
} else {
|
||||
toggleButton.attr( 'title', mla.settings.toggleOpen );
|
||||
toggleButton.attr( 'value', mla.settings.toggleOpen );
|
||||
resetButton.hide();
|
||||
}
|
||||
|
||||
area.slideToggle( 'slow' );
|
||||
},
|
||||
|
||||
parentOpen : function() {
|
||||
var parentId, postId, postTitle;
|
||||
|
||||
postId = -1;
|
||||
postTitle = mla.settings.uploadTitle;
|
||||
parentId = $( '#mla-add-new-bulk-edit-div :input[name="post_parent"]' ).val() || -1;
|
||||
mla.setParent.open( parentId, postId, postTitle );
|
||||
/*
|
||||
* Grab the "Update" button
|
||||
*/
|
||||
$( '#mla-set-parent-submit' ).on( 'click', function( event ){
|
||||
event.preventDefault();
|
||||
mla.addNewBulkEdit.parentSave();
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
parentSave : function() {
|
||||
var foundRow = $( '#mla-set-parent-response-div input:checked' ).closest( 'tr' ), parentId, newParent;
|
||||
|
||||
if ( foundRow.length ) {
|
||||
parentId = $( ':radio', foundRow ).val() || '';
|
||||
newParent = $('#mla-add-new-bulk-edit-div :input[name="post_parent"]').clone( true ).val( parentId );
|
||||
$('#mla-add-new-bulk-edit-div :input[name="post_parent"]').replaceWith( newParent );
|
||||
}
|
||||
|
||||
mla.setParent.close();
|
||||
$('#mla-set-parent-submit' ).off( 'click' );
|
||||
},
|
||||
|
||||
}; // mla.addNewBulkEdit
|
||||
|
||||
$( document ).ready( function() {
|
||||
mla.addNewBulkEdit.init();
|
||||
});
|
||||
})( jQuery );
|
||||
1
wp-content/plugins/media-library-assistant/js/mla-add-new-bulk-edit-scripts.min.js
vendored
Normal file
1
wp-content/plugins/media-library-assistant/js/mla-add-new-bulk-edit-scripts.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,744 @@
|
||||
/* global ajaxurl, mla */
|
||||
|
||||
var jQuery;
|
||||
|
||||
/*
|
||||
* This script requires the global "mla" object to be defined and include the following:
|
||||
*
|
||||
* properties:
|
||||
* mla.settings.useDashicons
|
||||
*
|
||||
* components:
|
||||
* mla.addTerm
|
||||
* mla.mlaList
|
||||
*/
|
||||
|
||||
( function( $ ) {
|
||||
/**
|
||||
* addTerm opens an area beneath a "checklist-style" taxonomy in the
|
||||
* Media/Assistant Bulk Edit area and Media/Add New Bulk Edit area.
|
||||
* It allows the user to add a term to the associated taxonomy.
|
||||
*/
|
||||
mla.addTerm = {
|
||||
/**
|
||||
* Attach new term functions to each taxonomy in the appropriate context
|
||||
*
|
||||
* @param {string} contextId a CSS "id=" selector, i.e. starting with "#"
|
||||
*/
|
||||
init: function( contextId ) {
|
||||
/*
|
||||
* contextId must be unique on the page, e.g., a <div> around the Bulk Edit or Quick Edit area.
|
||||
* Each taxonomy's '.categorydiv' must appear just once within the context.
|
||||
*/
|
||||
var context = $( contextId );
|
||||
|
||||
$( '.categorydiv', context ).each( function(){
|
||||
var this_id = $(this).attr('id'), catAddBefore, catAddAfter, taxonomyParts, taxonomy;
|
||||
|
||||
taxonomyParts = this_id.split('-');
|
||||
taxonomyParts.shift(); // taxonomy-
|
||||
taxonomy = taxonomyParts.join('-');
|
||||
|
||||
// Add category button controls.
|
||||
$( '#new' + taxonomy, context ).one( 'focus', function() {
|
||||
$( this ).val( '' ).removeClass( 'form-input-tip' );
|
||||
});
|
||||
|
||||
// On [enter] submit the taxonomy.
|
||||
$( '#new' + taxonomy, context ).keypress( function(event){
|
||||
if( 13 === event.keyCode ) {
|
||||
event.preventDefault();
|
||||
$( '#' + taxonomy + '-add-submit', context ).click();
|
||||
}
|
||||
});
|
||||
|
||||
// After submitting a new taxonomy, re-focus the input field.
|
||||
$( '#' + taxonomy + '-add-submit', context ).click( function() {
|
||||
$( '#new' + taxonomy, context ).focus();
|
||||
});
|
||||
|
||||
/**
|
||||
* Before adding a new taxonomy, disable submit button.
|
||||
*
|
||||
* @param {Object} s Taxonomy object which will be added.
|
||||
*
|
||||
* @returns {Object}
|
||||
*/
|
||||
catAddBefore = function( s ) {
|
||||
if ( !$( '#new' + taxonomy, context ).val() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
s.data += '&' + $( ':checked', '#' + taxonomy +'-checklist', context ).serialize();
|
||||
$( '#' + taxonomy + '-add-submit', context ).prop( 'disabled', true );
|
||||
return s;
|
||||
};
|
||||
|
||||
/**
|
||||
* Re-enable submit button after a taxonomy has been added.
|
||||
*
|
||||
* Re-enable submit button.
|
||||
* If the taxonomy has a parent place the taxonomy underneath the parent.
|
||||
*
|
||||
* @param {Object} r Response.
|
||||
* @param {Object} s Taxonomy data.
|
||||
*
|
||||
* @returns void
|
||||
*/
|
||||
catAddAfter = function( r, s ) {
|
||||
var sup;
|
||||
|
||||
$( '#' + taxonomy + '-add-submit', context ).prop( 'disabled', false );
|
||||
|
||||
// Update the "Parent Term" dropdown control(s)
|
||||
if ( 'undefined' != s.parsed.responses[0] && (sup = s.parsed.responses[0].supplemental.newcat_parent) ) {
|
||||
$( '.edit-fields-div' ).each( function(){
|
||||
var drop = $( '#new' + taxonomy + '_parent', $(this) );
|
||||
|
||||
drop.before(sup);
|
||||
drop.remove();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
mla.mlaList.settings.context = context;
|
||||
$( '#' + taxonomy + 'checklist', context ).mlaList({
|
||||
alt: '',
|
||||
context: context,
|
||||
// response: taxonomy + '-ajax-response',
|
||||
response: 'add-term-ajax-response',
|
||||
addBefore: catAddBefore,
|
||||
addAfter: catAddAfter
|
||||
});
|
||||
|
||||
$( '#' + taxonomy + '-add-toggle', context ).off();
|
||||
|
||||
// Add new taxonomy button toggles input form visibility.
|
||||
$( '#' + taxonomy + '-add-toggle', context ).click( function( e ) {
|
||||
e.preventDefault();
|
||||
$( '#' + taxonomy + '-adder', context ).toggleClass( 'wp-hidden-children' );
|
||||
$( '#new' + taxonomy, context ).focus();
|
||||
// Hide the "? Search" text box when displaying the "+ Add New ..." text box
|
||||
$( '#' + taxonomy + '-searcher', context ).addClass( 'wp-hidden-children' );
|
||||
return false;
|
||||
});
|
||||
}); // .categorydiv.each,
|
||||
}
|
||||
}; // mla.addTerm
|
||||
|
||||
/**
|
||||
* mlaList adapts the WordPress wpList object found in wp-includes/js/wp-lists.js
|
||||
* It handles the case where more than one instance of a taxonomy "metabox" occurs
|
||||
* on a page, e.g., the Bulk and Quick edit areas on the Media/Assistant admin page.
|
||||
*/
|
||||
mla.mlaList = {
|
||||
|
||||
/**
|
||||
* @member {object}
|
||||
*/
|
||||
settings: {
|
||||
|
||||
/**
|
||||
* URL for Ajax requests.
|
||||
*
|
||||
* @member {string}
|
||||
*/
|
||||
url: ajaxurl,
|
||||
|
||||
/**
|
||||
* The HTTP method to use for Ajax requests.
|
||||
*
|
||||
* @member {string}
|
||||
*/
|
||||
type: 'POST',
|
||||
|
||||
/**
|
||||
* jQuery context of the taxonomy's HTML elements.
|
||||
*
|
||||
* @member {object}
|
||||
*/
|
||||
context: null,
|
||||
|
||||
/**
|
||||
* ID of the element the parsed Ajax response will be stored in.
|
||||
*
|
||||
* @member {string}
|
||||
*/
|
||||
response: 'ajax-response',
|
||||
|
||||
/**
|
||||
* The type of list.
|
||||
*
|
||||
* @member {string}
|
||||
*/
|
||||
what: '',
|
||||
|
||||
/**
|
||||
* CSS class name for alternate styling.
|
||||
*
|
||||
* @member {string}
|
||||
*/
|
||||
alt: 'alternate',
|
||||
|
||||
/**
|
||||
* Offset to start alternate styling from.
|
||||
*
|
||||
* @member {number}
|
||||
*/
|
||||
altOffset: 0,
|
||||
|
||||
/**
|
||||
* Color used in animation when adding an element.
|
||||
*
|
||||
* Can be 'none' to disable the animation.
|
||||
*
|
||||
* @member {string}
|
||||
*/
|
||||
addColor: '#ffff33',
|
||||
|
||||
/**
|
||||
* Callback that's run before a request is made.
|
||||
*
|
||||
* @callback mlaList~confirm
|
||||
* @param {object} this
|
||||
* @param {HTMLElement} list The list DOM element.
|
||||
* @param {object} settings Settings for the current list.
|
||||
* @param {string} action The type of action to perform: 'add', 'delete', or 'dim'.
|
||||
* @param {string} backgroundColor Background color of the list's DOM element.
|
||||
* @returns {boolean} Whether to proceed with the action or not.
|
||||
*/
|
||||
confirm: null,
|
||||
|
||||
/**
|
||||
* Callback that's run before an item gets added to the list.
|
||||
*
|
||||
* Allows to cancel the request.
|
||||
*
|
||||
* @callback mlaList~addBefore
|
||||
* @param {object} settings Settings for the Ajax request.
|
||||
* @returns {object|boolean} Settings for the Ajax request or false to abort.
|
||||
*/
|
||||
addBefore: null,
|
||||
|
||||
/**
|
||||
* Callback that's run after an item got added to the list.
|
||||
*
|
||||
* @callback mlaList~addAfter
|
||||
* @param {XML} returnedResponse Raw response returned from the server.
|
||||
* @param {object} settings Settings for the Ajax request.
|
||||
* @param {jqXHR} settings.xml jQuery XMLHttpRequest object.
|
||||
* @param {string} settings.status Status of the request: 'success', 'notmodified', 'nocontent', 'error',
|
||||
* 'timeout', 'abort', or 'parsererror'.
|
||||
* @param {object} settings.parsed Parsed response object.
|
||||
*/
|
||||
addAfter: null
|
||||
},
|
||||
|
||||
/**
|
||||
* Finds a nonce.
|
||||
*
|
||||
* 1. Nonce in settings.
|
||||
* 2. `_ajax_nonce` value in element's href attribute.
|
||||
* 3. `_ajax_nonce` input field that is a descendant of element.
|
||||
* 4. `_wpnonce` value in element's href attribute.
|
||||
* 5. `_wpnonce` input field that is a descendant of element.
|
||||
* 6. 0 if none can be found.
|
||||
*
|
||||
* @param {jQuery} element Element that triggered the request.
|
||||
* @param {object} settings Settings for the Ajax request.
|
||||
* @returns {string|number} Nonce
|
||||
*/
|
||||
nonce: function( element, settings ) {
|
||||
var url = wpAjax.unserialize( element.attr( 'href' ) ),
|
||||
$element = $( '#' + settings.element, mla.mlaList.settings.context );
|
||||
|
||||
return settings.nonce || url._ajax_nonce || $element.find( 'input[name="_ajax_nonce"]' ).val() || url._wpnonce || $element.find( 'input[name="_wpnonce"]' ).val() || 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* Extract list item data from a DOM element.
|
||||
*
|
||||
* Example 1: data-wp-lists="delete:the-comment-list:comment-{comment_ID}:66cc66:unspam=1"
|
||||
* Example 2: data-wp-lists="dim:the-comment-list:comment-{comment_ID}:unapproved:e7e7d3:e7e7d3:new=approved"
|
||||
*
|
||||
* Returns an unassociated array with the following data:
|
||||
* data[0] - Data identifier: 'list', 'add', 'delete', or 'dim'.
|
||||
* data[1] - ID of the corresponding list. If data[0] is 'list', the type of list ('comment', 'category', etc).
|
||||
* data[2] - ID of the parent element of all inputs necessary for the request.
|
||||
* data[3] - Hex color to be used in this request. If data[0] is 'dim', dim class.
|
||||
* data[4] - Additional arguments in query syntax that are added to the request. Example: 'post_id=1234'.
|
||||
* If data[0] is 'dim', dim add color.
|
||||
* data[5] - Only available if data[0] is 'dim', dim delete color.
|
||||
* data[6] - Only available if data[0] is 'dim', additional arguments in query syntax that are added to the request.
|
||||
*
|
||||
* Result for Example 1:
|
||||
* data[0] - delete
|
||||
* data[1] - the-comment-list
|
||||
* data[2] - comment-{comment_ID}
|
||||
* data[3] - 66cc66
|
||||
* data[4] - unspam=1
|
||||
*
|
||||
* @param {HTMLElement} element The DOM element.
|
||||
* @param {string} type The type of data to look for: 'list', 'add', 'delete', or 'dim'.
|
||||
* @returns {Array} Extracted list item data.
|
||||
*/
|
||||
parseData: function( element, type ) {
|
||||
var data = [], mlaListsData;
|
||||
|
||||
try {
|
||||
mlaListsData = $( element ).data( 'wp-lists' ) || '';
|
||||
mlaListsData = mlaListsData.match( new RegExp( type + ':[\\S]+' ) );
|
||||
|
||||
if ( mlaListsData ) {
|
||||
data = mlaListsData[0].split( ':' );
|
||||
}
|
||||
} catch ( error ) {}
|
||||
|
||||
return data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Calls a confirm callback to verify the action that is about to be performed.
|
||||
*
|
||||
* @param {HTMLElement} list The DOM element.
|
||||
* @param {object} settings Settings for this list.
|
||||
* @param {string} action The type of action to perform: 'add', 'delete', or 'dim'.
|
||||
* @returns {object|boolean} Settings if confirmed, false if not.
|
||||
*/
|
||||
pre: function( list, settings, action ) {
|
||||
var $element, backgroundColor, confirmed;
|
||||
|
||||
settings = $.extend( {}, this.mlaList.settings, {
|
||||
element: null,
|
||||
nonce: 0,
|
||||
target: list.get( 0 )
|
||||
}, settings || {} );
|
||||
|
||||
if ( $.isFunction( settings.confirm ) ) {
|
||||
$element = $( '#' + settings.element, mla.mlaList.settings.context );
|
||||
|
||||
if ( 'add' !== action ) {
|
||||
backgroundColor = $element.css( 'backgroundColor' );
|
||||
$element.css( 'backgroundColor', '#ff9966' );
|
||||
}
|
||||
|
||||
confirmed = settings.confirm.call( this, list, settings, action, backgroundColor );
|
||||
|
||||
if ( 'add' !== action ) {
|
||||
$element.css( 'backgroundColor', backgroundColor );
|
||||
}
|
||||
|
||||
if ( ! confirmed ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return settings;
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds an item to the list via AJAX.
|
||||
*
|
||||
* @param {HTMLElement} element The DOM element.
|
||||
* @param {object} settings Settings for this list.
|
||||
* @returns {boolean} Whether the item was added.
|
||||
*/
|
||||
ajaxAdd: function( element, settings ) {
|
||||
var list = this,
|
||||
$element = $( element, mla.mlaList.settings.context ),
|
||||
data = mla.mlaList.parseData( $element, 'add' ),
|
||||
formValues, formData, parsedResponse, returnedResponse;
|
||||
|
||||
settings = settings || {};
|
||||
settings = mla.mlaList.pre.call( list, $element, settings, 'add' );
|
||||
|
||||
settings.element = data[2] || $element.prop( 'id' ) || settings.element || null;
|
||||
settings.addColor = data[3] ? '#' + data[3] : settings.addColor;
|
||||
|
||||
if ( ! settings ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! $element.is( '[id="' + settings.element + '-submit"]', mla.mlaList.settings.context ) ) {
|
||||
return ! mla.mlaList.add.call( list, $element, settings );
|
||||
}
|
||||
|
||||
if ( ! settings.element ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
settings.action = 'add-' + settings.what;
|
||||
settings.nonce = mla.mlaList.nonce( $element, settings );
|
||||
|
||||
if ( ! wpAjax.validateForm( mla.mlaList.settings.context.selector + ' #' + settings.element ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
settings.data = $.param( $.extend( {
|
||||
_ajax_nonce: settings.nonce,
|
||||
action: settings.action
|
||||
}, wpAjax.unserialize( data[4] || '' ) ) );
|
||||
|
||||
formValues = $( '#' + settings.element + ' :input', mla.mlaList.settings.context ).not( '[name="_ajax_nonce"], [name="_wpnonce"], [name="action"]' );
|
||||
formData = $.isFunction( formValues.fieldSerialize ) ? formValues.fieldSerialize() : formValues.serialize();
|
||||
|
||||
if ( formData ) {
|
||||
settings.data += '&' + formData;
|
||||
}
|
||||
|
||||
if ( $.isFunction( settings.addBefore ) ) {
|
||||
settings = settings.addBefore( settings );
|
||||
|
||||
if ( ! settings ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! settings.data.match( /_ajax_nonce=[a-f0-9]+/ ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
settings.success = function( response ) {
|
||||
var contextId = mla.mlaList.settings.context.selector.substring(1);
|
||||
|
||||
parsedResponse = wpAjax.parseAjaxResponse( response, contextId + ' #' + settings.response, settings.element );
|
||||
returnedResponse = response;
|
||||
|
||||
if ( ! parsedResponse || parsedResponse.errors ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( true === parsedResponse ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Add the new term, checked/selected, to the list
|
||||
$.each( parsedResponse.responses, function() {
|
||||
mla.mlaList.add.call( list, this.data, $.extend( {}, settings, { // this.firstChild.nodevalue
|
||||
position: this.position || 0,
|
||||
id: this.id || 0,
|
||||
oldId: this.oldId || null
|
||||
} ) );
|
||||
} );
|
||||
|
||||
list.mlaList.recolor();
|
||||
$( list ).trigger( 'mlaListAddEnd', [ settings, list.mlaList ] );
|
||||
mla.mlaList.clear.call( list, '#' + settings.element );
|
||||
};
|
||||
|
||||
// The addAfter function uses the supplemental data to update the "Parent Term" dropdown ontrol
|
||||
settings.complete = function( jqXHR, status ) {
|
||||
if ( $.isFunction( settings.addAfter ) ) {
|
||||
settings.addAfter( returnedResponse, $.extend( {
|
||||
xml: jqXHR,
|
||||
status: status,
|
||||
parsed: parsedResponse
|
||||
}, settings ) );
|
||||
}
|
||||
};
|
||||
|
||||
$.ajax( settings );
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the background color of the passed element.
|
||||
*
|
||||
* @param {jQuery|string} element Element to check.
|
||||
* @returns {string} Background color value in HEX. Default: '#ffffff'.
|
||||
*/
|
||||
getColor: function( element ) {
|
||||
return $( element ).css( 'backgroundColor' ) || '#ffffff';
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a new item to all other taxonomy checklists on the page.
|
||||
*
|
||||
* @param {HTMLElement} element A DOM element containing new item data.
|
||||
* @param {object} $list jQuery object for the current list.
|
||||
* @param {object} settings Settings for this list.
|
||||
*/
|
||||
addToOtherLists: function( element, $list, settings ) {
|
||||
$( '.edit-fields-div' ).each( function() {
|
||||
var $thisDiv = $( this ),
|
||||
thisId = $thisDiv.attr( 'id' ),
|
||||
targetId = settings.context.selector.substring(1),
|
||||
$checklist, $element, old, position, reference;
|
||||
|
||||
if ( targetId !== thisId ) {
|
||||
$checklist = $( '.' + $list.attr('id'), $thisDiv );
|
||||
$element = $( element );
|
||||
old = false;
|
||||
|
||||
$( 'input', $element ).removeAttr( 'checked' )
|
||||
|
||||
if ( settings.oldId ) {
|
||||
old = $( '#' + settings.what + '-' + settings.oldId, $checklist );
|
||||
}
|
||||
|
||||
if ( settings.id && ( settings.id !== settings.oldId || ! old || ! old.length ) ) {
|
||||
$( '#' + settings.what + '-' + settings.id, $checklist ).remove();
|
||||
}
|
||||
|
||||
if ( old && old.length ) {
|
||||
old.before( $element );
|
||||
old.remove();
|
||||
|
||||
} else if ( isNaN( settings.position ) ) {
|
||||
position = 'after';
|
||||
|
||||
if ( '-' === settings.position.substr( 0, 1 ) ) {
|
||||
settings.position = settings.position.substr( 1 );
|
||||
position = 'before';
|
||||
}
|
||||
|
||||
reference = $checklist.find( '#' + settings.position );
|
||||
|
||||
if ( 1 === reference.length ) {
|
||||
reference[position]( $element );
|
||||
} else {
|
||||
$checklist.append( $element );
|
||||
}
|
||||
|
||||
} else if ( 'comment' !== settings.what || 0 === $( '#' + settings.element, $checklist ).length ) {
|
||||
if ( settings.position < 0 ) {
|
||||
$checklist.prepend( $element );
|
||||
} else {
|
||||
$checklist.append( $element );
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a new item to the enclosing list.
|
||||
*
|
||||
* @param {HTMLElement} element A DOM element containing item data.
|
||||
* @param {object} settings Settings for this list.
|
||||
* @returns {boolean} Whether the item was added.
|
||||
*/
|
||||
add: function( element, settings ) {
|
||||
var $list = $( this ),
|
||||
$element = $( element ),
|
||||
old = false,
|
||||
position, reference;
|
||||
|
||||
if ( 'string' === typeof settings ) {
|
||||
settings = { what: settings };
|
||||
}
|
||||
|
||||
settings = $.extend( { position: 0, id: 0, oldId: null }, this.mlaList.settings, settings );
|
||||
|
||||
if ( ! $element.length || ! settings.what ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mla.mlaList.addToOtherLists( element, $list, settings );
|
||||
|
||||
if ( settings.oldId ) {
|
||||
old = $( '#' + settings.what + '-' + settings.oldId, settings.context );
|
||||
}
|
||||
|
||||
if ( settings.id && ( settings.id !== settings.oldId || ! old || ! old.length ) ) {
|
||||
$( '#' + settings.what + '-' + settings.id, settings.context ).remove();
|
||||
}
|
||||
|
||||
if ( old && old.length ) {
|
||||
old.before( $element );
|
||||
old.remove();
|
||||
|
||||
} else if ( isNaN( settings.position ) ) {
|
||||
position = 'after';
|
||||
|
||||
if ( '-' === settings.position.substr( 0, 1 ) ) {
|
||||
settings.position = settings.position.substr( 1 );
|
||||
position = 'before';
|
||||
}
|
||||
|
||||
reference = $list.find( '#' + settings.position );
|
||||
|
||||
if ( 1 === reference.length ) {
|
||||
reference[position]( $element );
|
||||
} else {
|
||||
$list.append( $element );
|
||||
}
|
||||
|
||||
} else if ( 'comment' !== settings.what || 0 === $( '#' + settings.element, mla.mlaList.settings.context ).length ) {
|
||||
if ( settings.position < 0 ) {
|
||||
$list.prepend( $element );
|
||||
} else {
|
||||
$list.append( $element );
|
||||
}
|
||||
}
|
||||
|
||||
if ( settings.alt ) {
|
||||
$element.toggleClass( settings.alt, ( $list.children( ':visible' ).index( $element[0] ) + settings.altOffset ) % 2 );
|
||||
}
|
||||
|
||||
if ( 'none' !== settings.addColor ) {
|
||||
$element.css( 'backgroundColor', settings.addColor ).animate( { backgroundColor: mla.mlaList.getColor( $element ) }, {
|
||||
complete: function() {
|
||||
$( this ).css( 'backgroundColor', '' );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
// Add event handlers.
|
||||
$list.each( function( index, list ) {
|
||||
list.mlaList.process( $element );
|
||||
} );
|
||||
|
||||
return $element;
|
||||
},
|
||||
|
||||
/**
|
||||
* Clears all input fields within the element passed.
|
||||
*
|
||||
* @param {string} elementId ID of the element to check, including leading #.
|
||||
*/
|
||||
clear: function( elementId ) {
|
||||
var list = this,
|
||||
$element = $( elementId ),
|
||||
type, tagName;
|
||||
|
||||
// Bail if we're within the list.
|
||||
if ( list.mlaList && $element.parents( '#' + list.id ).length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check each input field.
|
||||
$element.find( ':input' ).each( function( index, input ) {
|
||||
|
||||
// Bail if the form was marked to not to be cleared.
|
||||
if ( $( input ).parents( '.form-no-clear' ).length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
type = input.type.toLowerCase();
|
||||
tagName = input.tagName.toLowerCase();
|
||||
|
||||
if ( 'text' === type || 'password' === type || 'textarea' === tagName ) {
|
||||
input.value = '';
|
||||
|
||||
} else if ( 'checkbox' === type || 'radio' === type ) {
|
||||
input.checked = false;
|
||||
|
||||
} else if ( 'select' === tagName ) {
|
||||
input.selectedIndex = null;
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Registers event handlers to add, delete, and dim items.
|
||||
*
|
||||
* @param {string} elementId
|
||||
*/
|
||||
process: function( elementId ) {
|
||||
var list = this,
|
||||
$element = $( elementId || document );
|
||||
|
||||
$element.on( 'submit', 'form[data-wp-lists^="add:' + list.id + ':"]', function() {
|
||||
return list.mlaList.add( this );
|
||||
} );
|
||||
|
||||
$element.on( 'click', 'a[data-wp-lists^="add:' + list.id + ':"], input[data-wp-lists^="add:' + list.id + ':"]', function() {
|
||||
return list.mlaList.add( this );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates list item background colors.
|
||||
*/
|
||||
recolor: function() {
|
||||
var list = this,
|
||||
evenOdd = [':even', ':odd'],
|
||||
items;
|
||||
|
||||
// Bail if there is no alternate class name specified.
|
||||
if ( ! list.mlaList.settings.alt ) {
|
||||
return;
|
||||
}
|
||||
|
||||
items = $( '.list-item:visible', list );
|
||||
|
||||
if ( ! items.length ) {
|
||||
items = $( list ).children( ':visible' );
|
||||
}
|
||||
|
||||
if ( list.mlaList.settings.altOffset % 2 ) {
|
||||
evenOdd.reverse();
|
||||
}
|
||||
|
||||
items.filter( evenOdd[0] ).addClass( list.mlaList.settings.alt ).end();
|
||||
items.filter( evenOdd[1] ).removeClass( list.mlaList.settings.alt );
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets up `process()` and `recolor()` functions.
|
||||
*/
|
||||
init: function() {
|
||||
var $list = this;
|
||||
|
||||
$list.mlaList.process = function( element ) {
|
||||
$list.each( function() {
|
||||
this.mlaList.process( element );
|
||||
} );
|
||||
};
|
||||
|
||||
$list.mlaList.recolor = function() {
|
||||
$list.each( function() {
|
||||
this.mlaList.recolor();
|
||||
} );
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
var functions = {
|
||||
add: 'ajaxAdd',
|
||||
process: 'process',
|
||||
recolor: 'recolor'
|
||||
};
|
||||
|
||||
/**
|
||||
* Initializes mlaList object.
|
||||
*
|
||||
* @param {Object} settings
|
||||
* @param {string} settings.url URL for ajax calls. Default: ajaxurl.
|
||||
* @param {string} settings.type The HTTP method to use for Ajax requests. Default: 'POST'.
|
||||
* @param {string} settings.response ID of the element the parsed ajax response will be stored in.
|
||||
* Default: 'ajax-response'.
|
||||
*
|
||||
* @param {string} settings.what Default: ''.
|
||||
* @param {string} settings.alt CSS class name for alternate styling. Default: 'alternate'.
|
||||
* @param {number} settings.altOffset Offset to start alternate styling from. Default: 0.
|
||||
* @param {string} settings.addColor Hex code or 'none' to disable animation. Default: '#ffff33'.
|
||||
*
|
||||
* @param {mlaList~confirm} settings.confirm Callback that's run before a request is made. Default: null.
|
||||
* @param {mlaList~addBefore} settings.addBefore Callback that's run before an item gets added to the list.
|
||||
* Default: null.
|
||||
* @param {mlaList~addAfter} settings.addAfter Callback that's run after an item got added to the list.
|
||||
* Default: null.
|
||||
* @returns {$.fn} mlaList API function.
|
||||
*/
|
||||
$.fn.mlaList = function( settings ) {
|
||||
this.each( function( index, list ) {
|
||||
list.mlaList = {
|
||||
settings: $.extend( {}, mla.mlaList.settings, { what: mla.mlaList.parseData( list, 'list' )[1] || '' }, settings )
|
||||
};
|
||||
|
||||
$.each( functions, function( func, callback ) {
|
||||
list.mlaList[func] = function( element, setting ) {
|
||||
return mla.mlaList[callback].call( list, element, setting );
|
||||
};
|
||||
} );
|
||||
} );
|
||||
|
||||
mla.mlaList.init.call( this );
|
||||
this.mlaList.process( settings.context );
|
||||
|
||||
return this;
|
||||
};
|
||||
})( jQuery );
|
||||
1
wp-content/plugins/media-library-assistant/js/mla-add-term-scripts.min.js
vendored
Normal file
1
wp-content/plugins/media-library-assistant/js/mla-add-term-scripts.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,29 @@
|
||||
// defines Global ajaxurl if needed
|
||||
|
||||
//if ( ( typeof ajaxurl === 'undefined' ) && ( typeof wp.media.view.l10n.mla_strings.ajaxurl === 'string' ) ) {
|
||||
// var ajaxurl = wp.media.view.l10n.mla_strings.ajaxurl;
|
||||
//}
|
||||
|
||||
if ( typeof ajaxurl === 'undefined' ) {
|
||||
// Default location at worst
|
||||
var ajaxurl = '/wp-admin/admin-ajax.php';
|
||||
|
||||
// See if we can do better
|
||||
try {
|
||||
if ( typeof window._wpMediaViewsL10n === 'object' ) {
|
||||
if ( typeof window._wpMediaViewsL10n.mla_strings === 'object' ) {
|
||||
if ( typeof window._wpMediaViewsL10n.mla_strings.ajaxurl === 'string' ) {
|
||||
var ajaxurl = window._wpMediaViewsL10n.mla_strings.ajaxurl;
|
||||
} else {
|
||||
console.log( 'mla-define-ajaxurl-scripts.js window._wpMediaViewsL10n.mla_strings.ajaxurl failed' );
|
||||
}
|
||||
} else {
|
||||
console.log( 'mla-define-ajaxurl-scripts.js window._wpMediaViewsL10n.mla_strings failed' );
|
||||
}
|
||||
} else {
|
||||
console.log( 'mla-define-ajaxurl-scripts.js window._wpMediaViewsL10n failed' );
|
||||
}
|
||||
} catch ( error ) {
|
||||
console.log( 'mla-define-ajaxurl-scripts.js error thrown' );
|
||||
};
|
||||
}
|
||||
1
wp-content/plugins/media-library-assistant/js/mla-define-ajaxurl-scripts.min.js
vendored
Normal file
1
wp-content/plugins/media-library-assistant/js/mla-define-ajaxurl-scripts.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
if(typeof ajaxurl==="undefined"){var ajaxurl="/wp-admin/admin-ajax.php";try{if(typeof window._wpMediaViewsL10n==="object"){if(typeof window._wpMediaViewsL10n.mla_strings==="object"){if(typeof window._wpMediaViewsL10n.mla_strings.ajaxurl==="string"){var ajaxurl=window._wpMediaViewsL10n.mla_strings.ajaxurl}else{console.log("mla-define-ajaxurl-scripts.js window._wpMediaViewsL10n.mla_strings.ajaxurl failed")}}else{console.log("mla-define-ajaxurl-scripts.js window._wpMediaViewsL10n.mla_strings failed")}}else{console.log("mla-define-ajaxurl-scripts.js window._wpMediaViewsL10n failed")}}catch(error){console.log("mla-define-ajaxurl-scripts.js error thrown")}};
|
||||
@@ -0,0 +1,251 @@
|
||||
var jQuery,
|
||||
mla_edit_media_vars,
|
||||
mla = {
|
||||
// Properties
|
||||
// mla.settings.uploadLabel
|
||||
// mla.settings.modifyLabel
|
||||
settings: {},
|
||||
|
||||
// Utility functions
|
||||
utility: {
|
||||
},
|
||||
|
||||
// Components
|
||||
setParent: null,
|
||||
mlaEditAttachment: null
|
||||
};
|
||||
|
||||
( function( $ ) {
|
||||
// Localized settings and strings
|
||||
mla.settings = typeof mla_edit_media_vars === 'undefined' ? {} : mla_edit_media_vars;
|
||||
mla_edit_media_vars = void 0; // delete won't work on Globals
|
||||
|
||||
// The mlaEditAttachment functions are adapted from wp-admin/js/post.js
|
||||
mla.mlaEditAttachment = {
|
||||
$uploaddiv : null,
|
||||
uploadtimestamp : '',
|
||||
$modifydiv : null,
|
||||
modifytimestamp : '',
|
||||
|
||||
init : function(){
|
||||
$( '#mla_set_parent' ).on( 'click', function(){
|
||||
return mla.mlaEditAttachment.setParentOpen();
|
||||
});
|
||||
|
||||
$('.categorydiv').each( function(){
|
||||
var this_id = $(this).attr('id'), taxonomyParts, taxonomy;
|
||||
|
||||
taxonomyParts = this_id.split('-');
|
||||
taxonomyParts.shift(); // taxonomy-
|
||||
taxonomy = taxonomyParts.join('-');
|
||||
|
||||
$.extend( $.expr[":"], {
|
||||
"matchTerms": function( elem, i, match, array ) {
|
||||
return ( elem.textContent || elem.innerText || "" ).toLowerCase().indexOf( ( match[3] || "" ).toLowerCase() ) >= 0;
|
||||
}
|
||||
});
|
||||
|
||||
$( '#search-' + taxonomy ).keypress( function( event ){
|
||||
|
||||
if( 13 === event.keyCode ) {
|
||||
event.preventDefault();
|
||||
$( '#search-' + taxonomy ).val( '' );
|
||||
$( '#' + taxonomy + '-searcher' ).addClass( 'wp-hidden-children' );
|
||||
|
||||
$( '#' + taxonomy + 'checklist li' ).show();
|
||||
$( '#' + taxonomy + 'checklist-pop li' ).show();
|
||||
return;
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
$( '#search-' + taxonomy ).keyup( function( event ){
|
||||
var searchValue, termList, termListPopular, matchingTerms, matchingTermsPopular;
|
||||
|
||||
if( 13 === event.keyCode ) {
|
||||
event.preventDefault();
|
||||
$( '#' + taxonomy + '-search-toggle' ).focus();
|
||||
return;
|
||||
}
|
||||
|
||||
searchValue = $( '#search-' + taxonomy ).val();
|
||||
termList = $( '#' + taxonomy + 'checklist li' );
|
||||
termListPopular = $( '#' + taxonomy + 'checklist-pop li' );
|
||||
|
||||
if ( 0 < searchValue.length ) {
|
||||
termList.hide();
|
||||
termListPopular.hide();
|
||||
} else {
|
||||
termList.show();
|
||||
termListPopular.show();
|
||||
}
|
||||
|
||||
matchingTerms = $( '#' + taxonomy + "checklist label:matchTerms('" + searchValue + "')");
|
||||
matchingTerms.closest( 'li' ).find( 'li' ).andSelf().show();
|
||||
matchingTerms.parents( '#' + taxonomy + 'checklist li' ).show();
|
||||
|
||||
matchingTermsPopular = $( '#' + taxonomy + "checklist-pop label:matchTerms('" + searchValue + "')");
|
||||
matchingTermsPopular.closest( 'li' ).find( 'li' ).andSelf().show();
|
||||
matchingTermsPopular.parents( '#' + taxonomy + 'checklist li' ).show();
|
||||
} );
|
||||
|
||||
$( '#' + taxonomy + '-search-toggle' ).click( function() {
|
||||
$( '#' + taxonomy + '-adder ').addClass( 'wp-hidden-children' );
|
||||
$( '#' + taxonomy + '-searcher' ).toggleClass( 'wp-hidden-children' );
|
||||
$( 'a[href="#' + taxonomy + '-all"]', '#' + taxonomy + '-tabs' ).click();
|
||||
$( '#' + taxonomy + 'checklist li' ).show();
|
||||
$( '#' + taxonomy + 'checklist-pop li' ).show();
|
||||
|
||||
if ( false === $( '#' + taxonomy + '-searcher' ).hasClass( 'wp-hidden-children' ) ) {
|
||||
$( '#search-' + taxonomy ).val( '' ).removeClass( 'form-input-tip' );
|
||||
$( '#search-' + taxonomy ).focus();
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// Supplement the click logic in wp-admin/js/post.js
|
||||
$( '#' + taxonomy + '-add-toggle' ).click( function() {
|
||||
$( '#' + taxonomy + '-searcher' ).addClass( 'wp-hidden-children' );
|
||||
return false;
|
||||
});
|
||||
}); // .categorydiv.each,
|
||||
|
||||
// Save Post box (#submitdiv), for Uploaded on and Last modified dates
|
||||
if ( $('#submitdiv').length ) {
|
||||
mla.mlaEditAttachment.uploadtimestamp = $('#upload-timestamp').html();
|
||||
mla.mlaEditAttachment.$uploaddiv = $('#timestampdiv');
|
||||
//mla.mlaEditAttachment.modifytimestamp = $('#modify-timestamp').html();
|
||||
//mla.mlaEditAttachment.$modifydiv = $('#modifytimestampdiv');
|
||||
|
||||
// Edit Uploaded on click.
|
||||
mla.mlaEditAttachment.$uploaddiv.siblings('a.edit-timestamp').click( function( event ) {
|
||||
if ( mla.mlaEditAttachment.$uploaddiv.is( ':hidden' ) ) {
|
||||
mla.mlaEditAttachment.$uploaddiv.slideDown( 'fast', function() {
|
||||
$( 'input, select', mla.mlaEditAttachment.$uploaddiv.find( '.timestamp-wrap' ) ).first().focus();
|
||||
} );
|
||||
$(this).hide();
|
||||
}
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
// Cancel editing the Uploaded on time and hide the settings.
|
||||
mla.mlaEditAttachment.$uploaddiv.find('.cancel-timestamp').click( function( event ) {
|
||||
mla.mlaEditAttachment.$uploaddiv.slideUp('fast').siblings('a.edit-timestamp').show().focus();
|
||||
$( '#mm', mla.mlaEditAttachment.$uploaddiv ).val($( '#hidden_mm', mla.mlaEditAttachment.$uploaddiv ).val());
|
||||
$( '#jj', mla.mlaEditAttachment.$uploaddiv ).val($( '#hidden_jj', mla.mlaEditAttachment.$uploaddiv ).val());
|
||||
$( '#aa', mla.mlaEditAttachment.$uploaddiv ).val($( '#hidden_aa', mla.mlaEditAttachment.$uploaddiv ).val());
|
||||
$( '#hh', mla.mlaEditAttachment.$uploaddiv ).val($( '#hidden_hh', mla.mlaEditAttachment.$uploaddiv ).val());
|
||||
$( '#mn', mla.mlaEditAttachment.$uploaddiv ).val($( '#hidden_mn', mla.mlaEditAttachment.$uploaddiv ).val());
|
||||
mla.mlaEditAttachment.updateText( mla.mlaEditAttachment.$uploaddiv, mla.mlaEditAttachment.uploadtimestamp, '#upload-timestamp' );
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
// Save the changed Uploaded on timestamp.
|
||||
mla.mlaEditAttachment.$uploaddiv.find('.save-timestamp').click( function( event ) { // crazyhorse - multiple ok cancels
|
||||
if ( mla.mlaEditAttachment.updateText( mla.mlaEditAttachment.$uploaddiv, mla.mlaEditAttachment.uploadtimestamp, '#upload-timestamp' ) ) {
|
||||
mla.mlaEditAttachment.$uploaddiv.slideUp('fast');
|
||||
mla.mlaEditAttachment.$uploaddiv.siblings('a.edit-timestamp').show().focus();
|
||||
}
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
// Cancel submit when an invalid Uploaded on timestamp has been selected.
|
||||
$('#post').on( 'submit', function( event ) {
|
||||
if ( ! mla.mlaEditAttachment.updateText( mla.mlaEditAttachment.$uploaddiv, mla.mlaEditAttachment.uploadtimestamp, '#upload-timestamp' ) ) {
|
||||
event.preventDefault();
|
||||
mla.mlaEditAttachment.$uploaddiv.show();
|
||||
|
||||
if ( wp.autosave ) {
|
||||
wp.autosave.enableButtons();
|
||||
}
|
||||
|
||||
$( '#publishing-action .spinner' ).removeClass( 'is-active' );
|
||||
}
|
||||
});
|
||||
} // $('#submitdiv').length
|
||||
}, // function init
|
||||
|
||||
setParentOpen : function() {
|
||||
var parentId, postId, postTitle;
|
||||
|
||||
parentId = $( '#mla_post_parent' ).val() || '';
|
||||
postId = $( '#post_ID' ).val() || '';
|
||||
postTitle = $( '#title' ).val() || '';
|
||||
mla.setParent.open( parentId, postId, postTitle );
|
||||
|
||||
// Grab the "Update" button
|
||||
$( '#mla-set-parent-submit' ).on( 'click', function( event ){
|
||||
event.preventDefault();
|
||||
mla.mlaEditAttachment.setParentSave();
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
setParentSave : function() {
|
||||
var foundRow = $( '#mla-set-parent-response-div input:checked' ).closest( 'tr' ),
|
||||
parentId, parentTitle, newParent, newTitle;
|
||||
|
||||
if ( foundRow.length ) {
|
||||
parentId = $( ':radio', foundRow ).val() || '';
|
||||
parentTitle = $( 'label', foundRow ).html() || '';
|
||||
newParent = $( '#mla_post_parent' ).clone( true ).val( parentId );
|
||||
newTitle = $( '#mla_parent_info' ).clone( true ).val( parentTitle );
|
||||
$( '#mla_post_parent' ).replaceWith( newParent );
|
||||
$( '#mla_parent_info' ).replaceWith( newTitle );
|
||||
mla.setParent.close();
|
||||
}
|
||||
|
||||
$( '#mla-set-parent-submit' ).off( 'click' );
|
||||
},
|
||||
|
||||
/*
|
||||
* Make sure all Uploaded on or Last Modified labels represent the current settings.
|
||||
*
|
||||
* @returns {boolean} False when an invalid timestamp has been selected, otherwise True.
|
||||
*/
|
||||
updateText : function( $div, stamp, stampdiv ) {
|
||||
|
||||
if ( ! $div.length )
|
||||
return true;
|
||||
|
||||
var attemptedDate, originalDate, currentDate,
|
||||
aa = $( '#aa', $div ).val(), mm = $( '#mm', $div ).val(), jj = $( '#jj', $div ).val(),
|
||||
hh = $( '#hh', $div ).val(), mn = $( '#mn', $div ).val();
|
||||
|
||||
attemptedDate = new Date( aa, mm - 1, jj, hh, mn );
|
||||
originalDate = new Date( $( '#hidden_aa', $div ).val(), $( '#hidden_mm', $div ).val() -1, $( '#hidden_jj', $div ).val(), $( '#hidden_hh', $div ).val(), $( '#hidden_mn', $div ).val() );
|
||||
currentDate = new Date( $( '#cur_aa', $div ).val(), $( '#cur_mm', $div ).val() -1, $( '#cur_jj', $div ).val(), $( '#cur_hh', $div ).val(), $( '#cur_mn', $div ).val() );
|
||||
|
||||
// Catch unexpected date problems.
|
||||
if ( attemptedDate.getFullYear() != aa || (1 + attemptedDate.getMonth()) != mm || attemptedDate.getDate() != jj || attemptedDate.getMinutes() != mn ) {
|
||||
$div.find('.timestamp-wrap').addClass('form-invalid');
|
||||
return false;
|
||||
} else {
|
||||
$div.find('.timestamp-wrap').removeClass('form-invalid');
|
||||
}
|
||||
|
||||
// If the date is the same, set it to trigger update events.
|
||||
if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) {
|
||||
// Re-set to the current value.
|
||||
$( stampdiv ).html( stamp );
|
||||
} else {
|
||||
label = '#upload-timestamp' == stampdiv ? mla.settings.uploadLabel : mla.settings.modifyLabel;
|
||||
$( stampdiv ).html(
|
||||
label + '<b>' +
|
||||
postL10n.dateFormat
|
||||
.replace( '%1$s', $( 'option[value="' + mm + '"]', '#mm' ).attr( 'data-text' ) )
|
||||
.replace( '%2$s', parseInt( jj, 10 ) )
|
||||
.replace( '%3$s', aa )
|
||||
.replace( '%4$s', ( '00' + hh ).slice( -2 ) )
|
||||
.replace( '%5$s', ( '00' + mn ).slice( -2 ) ) +
|
||||
'</b> '
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}; // mla.mlaEditAttachment
|
||||
|
||||
$( document ).ready( function(){ mla.mlaEditAttachment.init(); } );
|
||||
})( jQuery );
|
||||
1
wp-content/plugins/media-library-assistant/js/mla-edit-media-scripts.min.js
vendored
Normal file
1
wp-content/plugins/media-library-assistant/js/mla-edit-media-scripts.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,879 @@
|
||||
/* global ajaxurl */
|
||||
|
||||
var jQuery,
|
||||
mla_inline_edit_vars,
|
||||
mla = {
|
||||
// Properties (for mla-set-parent-scripts, too)
|
||||
// mla.settings.noTitle
|
||||
// mla.settings.ntdelTitle
|
||||
// mla.settings.quickTagsInit
|
||||
// mla.settings.bulkChunkSize
|
||||
// mla.settings.ajax_action
|
||||
// mla.settings.ajax_nonce
|
||||
// mla.settings.bulkWaiting
|
||||
// mla.settings.bulkComplete
|
||||
// mla.settings.bulkSuccess
|
||||
// mla.settings.bulkFailure
|
||||
// mla.settings.error
|
||||
// mla.settings.bulkCanceled
|
||||
// mla.settings.fields
|
||||
// mla.settings.bulkTitle
|
||||
// mla.settings.comma for flat taxonomy suggest
|
||||
// mla.settings.ajaxFailError for setParent
|
||||
// mla.settings.ajaxDoneError for setParent
|
||||
// mla.settings.useDashicons for setParent
|
||||
// mla.settings.useSpinnerClass for setParent
|
||||
settings: {},
|
||||
bulkEdit: {
|
||||
inProcess: false,
|
||||
doCancel: false
|
||||
},
|
||||
|
||||
// Utility functions
|
||||
utility: {
|
||||
getId : function( o ) {
|
||||
var id = jQuery( o ).closest( 'tr' ).attr( 'id' ),
|
||||
parts = id.split( '-' );
|
||||
return parts[ parts.length - 1 ];
|
||||
},
|
||||
|
||||
attachSearch : function( rowId ) {
|
||||
jQuery( rowId + ' .categorydiv').each( function(){
|
||||
var this_id = jQuery(this).attr('id'), taxonomyParts, taxonomy;
|
||||
|
||||
taxonomyParts = this_id.split('-');
|
||||
taxonomyParts.shift(); // taxonomy-
|
||||
taxonomy = taxonomyParts.join('-');
|
||||
|
||||
jQuery.extend( jQuery.expr[":"], {
|
||||
"matchTerms": function( elem, i, match, array ) {
|
||||
return ( elem.textContent || elem.innerText || "" ).toLowerCase().indexOf( ( match[3] || "" ).toLowerCase() ) >= 0;
|
||||
}
|
||||
});
|
||||
|
||||
jQuery( rowId + ' #' + taxonomy + '-searcher' ).addClass( 'wp-hidden-children' );
|
||||
jQuery( rowId + ' #' + taxonomy + 'checklist li' ).show();
|
||||
|
||||
jQuery( rowId + ' #search-' + taxonomy ).off();
|
||||
|
||||
jQuery( rowId + ' #search-' + taxonomy ).keydown( function( event ){
|
||||
|
||||
if( 13 === event.keyCode ) {
|
||||
event.preventDefault();
|
||||
jQuery( rowId + ' #search-' + taxonomy ).val( '' );
|
||||
jQuery( rowId + ' #' + taxonomy + '-searcher' ).addClass( 'wp-hidden-children' );
|
||||
|
||||
jQuery( rowId + ' #' + taxonomy + 'checklist li' ).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
jQuery( rowId + ' #search-' + taxonomy ).keypress( function( event ){
|
||||
|
||||
if( 13 === event.keyCode ) {
|
||||
event.preventDefault();
|
||||
jQuery( rowId + ' #search-' + taxonomy ).val( '' );
|
||||
jQuery( rowId + ' #' + taxonomy + '-searcher' ).addClass( 'wp-hidden-children' );
|
||||
|
||||
jQuery( rowId + ' #' + taxonomy + 'checklist li' ).show();
|
||||
return;
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
jQuery( rowId + ' #search-' + taxonomy ).keyup( function( event ){
|
||||
var searchValue, termList, matchingTerms;
|
||||
|
||||
if( 13 === event.keyCode ) {
|
||||
event.preventDefault();
|
||||
jQuery( rowId + ' #' + taxonomy + '-search-toggle' ).focus();
|
||||
return;
|
||||
}
|
||||
|
||||
searchValue = jQuery( rowId + ' #search-' + taxonomy ).val();
|
||||
termList = jQuery( rowId + ' #' + taxonomy + 'checklist li' );
|
||||
|
||||
if ( 0 < searchValue.length ) {
|
||||
termList.hide();
|
||||
} else {
|
||||
termList.show();
|
||||
}
|
||||
|
||||
matchingTerms = jQuery( rowId + ' #' + taxonomy + "checklist label:matchTerms('" + searchValue + "')");
|
||||
matchingTerms.closest( 'li' ).find( 'li' ).andSelf().show();
|
||||
matchingTerms.parents( rowId + ' #' + taxonomy + 'checklist li' ).show();
|
||||
} );
|
||||
|
||||
jQuery( rowId + ' #' + taxonomy + '-search-toggle' ).off();
|
||||
|
||||
jQuery( rowId + ' #' + taxonomy + '-search-toggle' ).click( function() {
|
||||
jQuery( rowId + ' #' + taxonomy + '-adder ').addClass( 'wp-hidden-children' );
|
||||
jQuery( rowId + ' #' + taxonomy + '-searcher' ).toggleClass( 'wp-hidden-children' );
|
||||
jQuery( rowId + ' #' + taxonomy + 'checklist li' ).show();
|
||||
|
||||
if ( false === jQuery( rowId + ' #' + taxonomy + '-searcher' ).hasClass( 'wp-hidden-children' ) ) {
|
||||
jQuery( rowId + ' #search-' + taxonomy ).val( '' ).removeClass( 'form-input-tip' );
|
||||
jQuery( rowId + ' #search-' + taxonomy ).focus();
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}); // .categorydiv.each,
|
||||
}
|
||||
},
|
||||
|
||||
// Components
|
||||
setParent: null,
|
||||
inlineEditAttachment: null
|
||||
};
|
||||
|
||||
( function( $ ) {
|
||||
// Localized settings and strings
|
||||
mla.settings = typeof mla_inline_edit_vars === 'undefined' ? {} : mla_inline_edit_vars;
|
||||
mla_inline_edit_vars = void 0; // delete won't work on Globals
|
||||
|
||||
// The inlineEditAttachment functions are adapted from wp-admin/js/inline-edit-post.js
|
||||
mla.inlineEditAttachment = {
|
||||
init : function(){
|
||||
var t = this, qeRow = $( '#inline-edit' ), bulkRow = $( '#bulk-edit' ), progressRow = $( '#bulk-progress' );
|
||||
|
||||
if ( mla.settings.deleteAcpBulkEdit ) {
|
||||
setTimeout( function() {
|
||||
var elements = document.querySelectorAll( 'body.ac-mla-media-assistant .acp-be-editrow, body.ac-mla-media-assistant .acp-be-noticerow' );
|
||||
|
||||
for ( i = 0; i < elements.length; ++i ) {
|
||||
elements[ i ].remove();
|
||||
}
|
||||
}, 1000 );
|
||||
}
|
||||
|
||||
t.type = 'attachment';
|
||||
t.what = '#attachment-';
|
||||
|
||||
// prepare the edit rows
|
||||
qeRow.keyup(function(e){
|
||||
if (e.which == 27)
|
||||
return mla.inlineEditAttachment.revert();
|
||||
});
|
||||
bulkRow.keyup(function(e){
|
||||
if (e.which == 27)
|
||||
return mla.inlineEditAttachment.revert();
|
||||
});
|
||||
progressRow.keyup(function(e){
|
||||
if (e.which == 27)
|
||||
return mla.inlineEditAttachment.revert();
|
||||
});
|
||||
|
||||
$('#inline-edit-post-set-parent', qeRow).on( 'click', function(){
|
||||
return mla.inlineEditAttachment.inlineParentOpen(this);
|
||||
});
|
||||
$('a.cancel', qeRow).click(function(){
|
||||
return mla.inlineEditAttachment.revert();
|
||||
});
|
||||
$('a.save', qeRow).click(function(){
|
||||
return mla.inlineEditAttachment.quickSave(this);
|
||||
});
|
||||
$('td', qeRow).keydown(function(e){
|
||||
if ( e.which == 13 )
|
||||
return mla.inlineEditAttachment.quickSave(this);
|
||||
});
|
||||
|
||||
if ( typeof mla.addTerm !== 'undefined' ) {
|
||||
mla.addTerm.init( '#bulk-edit-fields-div' );
|
||||
}
|
||||
mla.utility.attachSearch( '#bulk-edit-fields-div' );
|
||||
|
||||
$('#bulk-edit-set-parent', bulkRow).on( 'click', function(){
|
||||
return mla.inlineEditAttachment.bulkParentOpen();
|
||||
});
|
||||
$('a.cancel', bulkRow).click(function(){
|
||||
return mla.inlineEditAttachment.revert();
|
||||
});
|
||||
$('a.reset', bulkRow).click(function(){
|
||||
return mla.inlineEditAttachment.doReset();
|
||||
});
|
||||
$('input[type="submit"]', bulkRow).click(function(e){
|
||||
e.preventDefault();
|
||||
return mla.inlineEditAttachment.bulkSave(e);
|
||||
});
|
||||
|
||||
$('a.cancel', progressRow).click(function(){
|
||||
if ( mla.bulkEdit.inProcess ) {
|
||||
mla.bulkEdit.doCancel = true;
|
||||
return false;
|
||||
} else {
|
||||
return mla.inlineEditAttachment.revert();
|
||||
}
|
||||
});
|
||||
|
||||
// Clicking "Refresh" submits the form, refreshing the page
|
||||
$('#bulk_refresh', progressRow).click(function(){
|
||||
$( '#bulk-progress a' ).prop( 'disabled', true );
|
||||
$( '#bulk-progress' ).css( 'opacity', '0.5' );
|
||||
});
|
||||
|
||||
// add event to the Quick Edit links
|
||||
$( '#the-list' ).on( 'click', 'a.editinline', function(){
|
||||
mla.inlineEditAttachment.quickEdit(this);
|
||||
return false;
|
||||
});
|
||||
|
||||
$('select[name="_status"] option[value="future"]', bulkRow).remove();
|
||||
|
||||
$('#doaction, #doaction2').click(function(e){
|
||||
var n = $(this).attr('id').substr(2);
|
||||
|
||||
if ( $('select[name="'+n+'"]').val() == 'edit' ) {
|
||||
e.preventDefault();
|
||||
t.bulkEdit();
|
||||
} else if ( $('form#posts-filter tr.inline-editor').length > 0 ) {
|
||||
t.revert();
|
||||
}
|
||||
});
|
||||
|
||||
// Filter button (dates, categories) in top nav bar
|
||||
$('#post-query-submit').mousedown(function(){
|
||||
t.revert();
|
||||
$('select[name^="action"]').val('-1');
|
||||
});
|
||||
},
|
||||
|
||||
bulkEdit : function(){
|
||||
var te = '', c = true;
|
||||
this.revert();
|
||||
|
||||
$('#bulk-edit td').attr('colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length);
|
||||
/*
|
||||
* Insert the editor at the top of the table with an empty row above
|
||||
* in WP 4.2+ to maintain zebra striping.
|
||||
*/
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
$('table.wp-list-table tbody').prepend( $('#bulk-edit') ).prepend('<tr class="hidden"></tr>');
|
||||
} else {
|
||||
$('table.wp-list-table tbody').prepend( $('#bulk-edit') );
|
||||
}
|
||||
|
||||
$('#bulk-edit').addClass('inline-editor').show();
|
||||
|
||||
$('tbody th.check-column input[type="checkbox"]').each(function(){
|
||||
if ( $(this).prop('checked') ) {
|
||||
c = false;
|
||||
var id = $(this).val(), theTitle;
|
||||
theTitle = $('#inline_'+id+' .post_title').text() || mla.settings.noTitle;
|
||||
te += '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+mla.settings.ntdelTitle+'">X</a>'+theTitle+'</div>';
|
||||
}
|
||||
});
|
||||
|
||||
if ( c )
|
||||
return this.revert();
|
||||
|
||||
$('#bulk-titles').html(te);
|
||||
$('#bulk-titles a').click(function(){
|
||||
var id = $(this).attr('id').substr(1);
|
||||
|
||||
$('table.wp-list-table input[value="' + id + '"]').prop('checked', false);
|
||||
$('#ttle'+id).remove();
|
||||
});
|
||||
|
||||
//flat taxonomies
|
||||
$('textarea.mla_tags').each(function(){
|
||||
var taxname = $(this).attr('name').replace(']', '').replace('tax_input[', '');
|
||||
|
||||
$(this).suggest( ajaxurl + '?action=ajax-tag-search&tax=' + taxname, { delay: 500, minchars: 2, multiple: true, multipleSep: mla.settings.comma + ' ' } );
|
||||
});
|
||||
|
||||
$('html, body').animate( { scrollTop: 0 }, 'fast' );
|
||||
|
||||
if ( ( typeof quicktags !== 'undefined' ) && ( typeof mla.settings.quickTagsInit !== 'undefined' ) ) {
|
||||
for ( id in mla.settings.quickTagsInit ) {
|
||||
quicktags( mla.settings.quickTagsInit[id] );
|
||||
|
||||
if ( mla.settings.quickTagsInit[id]['active'] ) {
|
||||
window.wpActiveEditor = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
bulkSave : function(e) {
|
||||
var ids;
|
||||
|
||||
mla.bulkEdit = {
|
||||
inProcess: false,
|
||||
doCancel: false,
|
||||
chunkSize: 0,
|
||||
targetName: '',
|
||||
fields: '',
|
||||
ids: [],
|
||||
idsCount: 0,
|
||||
offset: 0,
|
||||
waiting: 0,
|
||||
running: 0,
|
||||
complete: 0,
|
||||
unchanged:0,
|
||||
success: 0,
|
||||
failure: 0
|
||||
};
|
||||
|
||||
//mla.bulkEdit.ids = []; // clone doesn't do this.
|
||||
mla.bulkEdit.chunkSize = +mla.settings.bulkChunkSize;
|
||||
mla.bulkEdit.targetName = e.target.name;
|
||||
mla.bulkEdit.fields = $('#bulk-edit :input').serialize();
|
||||
ids = $('tbody th.check-column input[type="checkbox"]').serializeArray();
|
||||
$.each( ids, function( index, id ) {
|
||||
mla.bulkEdit.ids[ index ] = +id.value;
|
||||
});
|
||||
mla.bulkEdit.idsCount = mla.bulkEdit.waiting = mla.bulkEdit.ids.length;
|
||||
//console.log( JSON.stringify( mla.bulkEdit ) );
|
||||
|
||||
mla.inlineEditAttachment.bulkProgressOpen();
|
||||
mla.inlineEditAttachment.bulkPost();
|
||||
return false;
|
||||
},
|
||||
|
||||
bulkProgressOpen : function(){
|
||||
var te = '', c = true;
|
||||
this.revert();
|
||||
|
||||
$('#bulk-progress td').attr('colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length);
|
||||
$('table.wp-list-table tbody').prepend( $('#bulk-progress') );
|
||||
$('#bulk-progress').addClass('inline-editor').show();
|
||||
$('#cb-select-all-1' ).removeAttr( 'checked' );
|
||||
$('#cb-select-all-2' ).removeAttr( 'checked' );
|
||||
|
||||
$('tbody th.check-column input[type="checkbox"]').each(function(){
|
||||
if ( $(this).prop('checked') ) {
|
||||
c = false;
|
||||
var id = $(this).val(), theTitle;
|
||||
theTitle = $('#inline_'+id+' .post_title').text() || mla.settings.noTitle;
|
||||
te += '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+mla.settings.ntdelTitle+'">X</a>'+theTitle+'</div>';
|
||||
}
|
||||
});
|
||||
|
||||
if ( c )
|
||||
return this.revert();
|
||||
|
||||
$('#bulk-progress-running').html('');
|
||||
$('#bulk-progress-complete').html('');
|
||||
$('#bulk-progress-waiting').html(te);
|
||||
$('#bulk-progress-waiting a').click(function(){
|
||||
var id = $(this).attr('id').substr(1);
|
||||
|
||||
$('table.wp-list-table input[value="' + id + '"]').prop('checked', false);
|
||||
$('#ttle'+id).remove();
|
||||
});
|
||||
|
||||
// Disable "Refresh" until the bulk updates are complete
|
||||
$( '#bulk-progress .inline-edit-save .error' ).html( '' );;
|
||||
$( '#bulk_refresh' ).prop( 'disabled', true ).css( 'opacity', '0.5' );
|
||||
$('html, body').animate( { scrollTop: 0 }, 'fast' );
|
||||
},
|
||||
|
||||
bulkPost : function() {
|
||||
var params, chunk, cIndex, item, statusMessage,
|
||||
spinner = $('table.wp-list-table .inline-edit-save .spinner'),
|
||||
results = $( '#bulk-progress .inline-edit-save .error' ),
|
||||
waiting = $( '#bulk-progress-waiting' ),
|
||||
running = $( '#bulk-progress-running' );
|
||||
|
||||
// Find the items to process
|
||||
chunk = mla.bulkEdit.ids.slice( mla.bulkEdit.offset, mla.bulkEdit.offset + mla.bulkEdit.chunkSize );
|
||||
|
||||
// Move them from waiting to running
|
||||
for ( cIndex = 0; cIndex < chunk.length; cIndex++ ) {
|
||||
item = $( '#ttle' + chunk[ cIndex ], waiting ).remove()
|
||||
$( 'a', item ).hide();
|
||||
running.append( item );
|
||||
}
|
||||
mla.bulkEdit.waiting -= chunk.length;
|
||||
mla.bulkEdit.running = chunk.length;
|
||||
|
||||
params = {
|
||||
action: mla.settings.ajax_action,
|
||||
mla_admin_nonce: mla.settings.ajax_nonce,
|
||||
bulk_action: mla.bulkEdit.targetName,
|
||||
cb_offset: mla.bulkEdit.offset,
|
||||
cb_count: mla.bulkEdit.idsCount,
|
||||
cb_attachment: chunk
|
||||
};
|
||||
|
||||
mla.bulkEdit.offset += mla.bulkEdit.chunkSize;
|
||||
|
||||
params = $.param( params ) + '&' + mla.bulkEdit.fields;
|
||||
//console.log( params );
|
||||
|
||||
// make ajax request
|
||||
mla.bulkEdit.inProcess = true;
|
||||
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
spinner.addClass("is-active");
|
||||
} else {
|
||||
spinner.show();
|
||||
}
|
||||
|
||||
statusMessage = mla.settings.bulkWaiting + ': ' + mla.bulkEdit.waiting
|
||||
+ ', ' + mla.settings.bulkComplete + ': ' + mla.bulkEdit.complete
|
||||
+ ', ' + mla.settings.bulkUnchanged + ': ' + mla.bulkEdit.unchanged
|
||||
+ ', ' + mla.settings.bulkSuccess + ': ' + mla.bulkEdit.success
|
||||
+ ', ' + mla.settings.bulkFailure + ': ' + mla.bulkEdit.failure;
|
||||
results.html( statusMessage ).show();
|
||||
|
||||
$.ajax( ajaxurl, {
|
||||
type: 'POST',
|
||||
data: params,
|
||||
dataType: 'json'
|
||||
}).always( function() {
|
||||
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
spinner.removeClass("is-active");
|
||||
} else {
|
||||
spinner.hide();
|
||||
}
|
||||
|
||||
}).done( function( response, status ) {
|
||||
var responseData = 'no response.data', responseMessage, items;
|
||||
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
spinner.removeClass("is-active");
|
||||
} else {
|
||||
spinner.hide();
|
||||
}
|
||||
|
||||
if ( response ) {
|
||||
if ( ! response.success ) {
|
||||
if ( response.responseData ) {
|
||||
responseData = response.data;
|
||||
}
|
||||
|
||||
results.html( JSON.stringify( response ) ).show();
|
||||
mla.bulkEdit.offset = mla.bulkEdit.idsCount; // Stop
|
||||
} else {
|
||||
// Move the items from Running to Complete
|
||||
items = $( '#bulk-progress-running div' ).remove();
|
||||
$.each( items, function() {
|
||||
var result, title = $( this ).html(),
|
||||
id = $( this ).attr('id').substr( 4 );
|
||||
|
||||
if ( 'string' === typeof( response.data.item_results[ id ]['result'] ) ) {
|
||||
result = response.data.item_results[ id ]['result'];
|
||||
$( this ).html( title + ' (' + id + ') - ' + result );
|
||||
}
|
||||
|
||||
$( '#attachment-' + id ).remove();
|
||||
});
|
||||
|
||||
$( '#bulk-progress-complete' ).append( items );
|
||||
mla.bulkEdit.complete += mla.bulkEdit.running;
|
||||
mla.bulkEdit.running = 0;
|
||||
mla.bulkEdit.unchanged += response.data.unchanged;
|
||||
mla.bulkEdit.success += response.data.success;
|
||||
mla.bulkEdit.failure += response.data.failure;
|
||||
|
||||
responseMessage = mla.settings.bulkWaiting + ': ' + mla.bulkEdit.waiting
|
||||
+ ', ' + mla.settings.bulkComplete + ': ' + mla.bulkEdit.complete
|
||||
+ ', ' + mla.settings.bulkUnchanged + ': ' + mla.bulkEdit.unchanged
|
||||
+ ', ' + mla.settings.bulkSuccess + ': ' + mla.bulkEdit.success
|
||||
+ ', ' + mla.settings.bulkFailure + ': ' + mla.bulkEdit.failure;
|
||||
results.html( responseMessage ).show();
|
||||
}
|
||||
} else {
|
||||
results.html( mla.settings.error ).show();
|
||||
mla.bulkEdit.offset = mla.bulkEdit.idsCount; // Stop
|
||||
}
|
||||
|
||||
if ( mla.bulkEdit.doCancel ) {
|
||||
results.html( mla.settings.bulkCanceled + '. ' + responseMessage ).show();
|
||||
} else {
|
||||
if ( mla.bulkEdit.offset < mla.bulkEdit.idsCount ) {
|
||||
mla.inlineEditAttachment.bulkPost();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$( '#bulk_refresh' ).prop( 'disabled', false ).css( 'opacity', '1.0' );
|
||||
mla.bulkEdit.inProcess = false;
|
||||
}).fail( function( jqXHR, status ) {
|
||||
if ( 200 == jqXHR.status ) {
|
||||
results.text( '(' + status + ') ' + jqXHR.responseText );
|
||||
} else {
|
||||
results.text( mla.settings.ajaxFailError + ' (' + status + '), jqXHR( ' + jqXHR.status + ', ' + jqXHR.statusText + ', ' + jqXHR.responseText + ')' );
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
quickEdit : function(id) {
|
||||
var t = this, fields, editRow, rowData, checkedOnTop = [], icon, fIndex;
|
||||
t.revert();
|
||||
|
||||
if ( typeof(id) == 'object' )
|
||||
id = mla.utility.getId(id);
|
||||
|
||||
fields = mla.settings.fields;
|
||||
|
||||
/*
|
||||
* add the new edit row with an extra blank row underneath
|
||||
* in WP 4.2+ to maintain zebra striping
|
||||
*/
|
||||
editRow = $('#inline-edit').clone(true);
|
||||
$('td', editRow).attr('colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length);
|
||||
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
$(t.what+id).hide().after(editRow).after('<tr class="hidden"></tr>');
|
||||
} else {
|
||||
if ( $(t.what+id).hasClass('alternate') ) {
|
||||
$(editRow).addClass('alternate');
|
||||
}
|
||||
|
||||
$(t.what+id).hide().after(editRow);
|
||||
}
|
||||
|
||||
// populate the data
|
||||
rowData = $('#inline_'+id);
|
||||
|
||||
icon = $('.item_thumbnail', rowData).html();
|
||||
if ( icon.length ) {
|
||||
$( '#item_thumbnail', editRow ).html( icon );
|
||||
}
|
||||
|
||||
if ( !$(':input[name="post_author"] option[value="' + $('.post_author', rowData).text() + '"]', editRow).val() ) {
|
||||
// author no longer has edit caps, so we need to add them to the list of authors
|
||||
$(':input[name="post_author"]', editRow).prepend('<option value="' + $('.post_author', rowData).text() + '">' + $('#' + t.type + '-' + id + ' .author').text() + '</option>');
|
||||
}
|
||||
|
||||
if ( $(':input[name="post_author"] option', editRow).length == 1 ) {
|
||||
$('label.inline-edit-author', editRow).hide();
|
||||
}
|
||||
|
||||
for ( fIndex = 0; fIndex < fields.length; fIndex++ ) {
|
||||
$(':input[name="' + fields[fIndex] + '"]', editRow).val( $('.'+fields[fIndex], rowData).text() );
|
||||
}
|
||||
|
||||
if ( $('.image_alt', rowData).length === 0) {
|
||||
$('label.inline-edit-image-alt', editRow).hide();
|
||||
}
|
||||
|
||||
// checklist taxonomies having "checked terms on top"
|
||||
$('.checked_on_top', rowData).each(function(){
|
||||
checkedOnTop[checkedOnTop.length] = $(this).attr('id').replace('_'+id, '');
|
||||
});
|
||||
|
||||
// hierarchical taxonomies
|
||||
$('.mla_category', rowData).each(function(){
|
||||
var term_ids = $(this).text(), taxname = $(this).attr('id').replace('_'+id, ''), checkedLabels, checkedTerms;
|
||||
|
||||
if ( term_ids ) {
|
||||
$('ul.'+taxname+'checklist :checkbox', editRow).val(term_ids.split(','));
|
||||
|
||||
if ( -1 !== checkedOnTop.indexOf( taxname ) ) {
|
||||
checkedLabels = $('ul.'+taxname+'checklist li :checked', editRow ).parents( 'label' ).remove().toArray().reverse();
|
||||
checkedTerms = $( '<li></li>' ).html( checkedLabels );
|
||||
$('ul.'+taxname+'checklist', editRow ).prepend( checkedTerms );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//flat taxonomies
|
||||
$('.mla_tags', rowData).each(function(){
|
||||
var terms = $(this).text(),
|
||||
taxname = $(this).attr('id').replace('_' + id, ''),
|
||||
textarea = $('textarea.tax_input_' + taxname, editRow),
|
||||
comma = mla.settings.comma, langArgument;
|
||||
|
||||
if ( terms ) {
|
||||
if ( ',' !== comma )
|
||||
terms = terms.replace(/,/g, comma);
|
||||
textarea.val(terms);
|
||||
}
|
||||
|
||||
langArgument = $('.lang', rowData).text();
|
||||
if ( 0 < langArgument.length ) {
|
||||
langArgument = '&lang=' + langArgument;
|
||||
} else {
|
||||
langArgument = '';
|
||||
}
|
||||
|
||||
textarea.suggest( ajaxurl + '?action=ajax-tag-search&tax=' + taxname + '&preview_id=' + id + langArgument, { delay: 500, minchars: 2, multiple: true, multipleSep: mla.settings.comma + ' ' } );
|
||||
});
|
||||
|
||||
rowData = $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show().position().top;
|
||||
$('.ptitle', editRow).focus();
|
||||
$( 'html, body' ).animate( { scrollTop: rowData }, 'fast' );
|
||||
|
||||
// Make the edit-fields-div id unique again
|
||||
$( '#inline-edit-fields-div', editRow ).attr( 'id', 'inline-edit-fields-div-active' );
|
||||
if ( typeof mla.addTerm !== 'undefined' ) {
|
||||
mla.addTerm.init( '#inline-edit-fields-div-active' );
|
||||
}
|
||||
mla.utility.attachSearch( '#inline-edit-fields-div-active' );
|
||||
return false;
|
||||
},
|
||||
|
||||
quickSave : function( id ) {
|
||||
var params, fields, page = $('.post_status_page').val() || '';
|
||||
|
||||
if ( typeof(id) == 'object' ) {
|
||||
id = mla.utility.getId(id);
|
||||
}
|
||||
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
$('table.wp-list-table .inline-edit-save .spinner').addClass("is-active");
|
||||
} else {
|
||||
$('table.wp-list-table .inline-edit-save .spinner').show();
|
||||
}
|
||||
|
||||
params = {
|
||||
action: mla.settings.ajax_action,
|
||||
mla_admin_nonce: mla.settings.ajax_nonce,
|
||||
post_type: 'attachment',
|
||||
post_ID: id,
|
||||
edit_date: 'true',
|
||||
post_status: page
|
||||
};
|
||||
|
||||
fields = $('#edit-' + id + ' :input').serialize();
|
||||
params = fields + '&' + $.param(params);
|
||||
|
||||
// make ajax request
|
||||
$.post( ajaxurl, params,
|
||||
function( response ) {
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
$('table.wp-list-table .inline-edit-save .spinner').removeClass("is-active");
|
||||
} else {
|
||||
$('table.wp-list-table .inline-edit-save .spinner').hide();
|
||||
}
|
||||
|
||||
if ( response ) {
|
||||
if ( -1 != response.indexOf( '<tr' ) ) {
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
$( mla.inlineEditAttachment.what + id ).siblings('tr.hidden').addBack().remove();
|
||||
} else {
|
||||
$( mla.inlineEditAttachment.what + id ).remove();
|
||||
}
|
||||
|
||||
$( '#edit-' + id ).before( response ).remove();
|
||||
$( mla.inlineEditAttachment.what + id ).hide().fadeIn();
|
||||
} else {
|
||||
response = response.replace( /<.[^<>]*?>/g, '' );
|
||||
$( '#edit-' + id + ' .inline-edit-save .error' ).html( response ).show();
|
||||
}
|
||||
} else {
|
||||
$( '#edit-' + id + ' .inline-edit-save .error' ).html( mla.settings.error ).show();
|
||||
}
|
||||
}, 'html');
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
inlineParentOpen : function( id ) {
|
||||
var parentId, postId, postTitle;
|
||||
|
||||
if ( typeof( id ) == 'object' ) {
|
||||
postId = mla.utility.getId( id );
|
||||
parentId = $( '#edit-' + postId + ' :input[name="post_parent"]' ).val() || '';
|
||||
postTitle = $( '#edit-' + postId + ' :input[name="post_title"]' ).val() || '';
|
||||
mla.setParent.open( parentId, postId, postTitle );
|
||||
/*
|
||||
* Grab the "Update" button
|
||||
*/
|
||||
$( '#mla-set-parent-submit' ).on( 'click', function( event ){
|
||||
event.preventDefault();
|
||||
mla.inlineEditAttachment.inlineParentSave( postId );
|
||||
return false;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
inlineParentSave : function( postId ) {
|
||||
var foundRow = $( '#mla-set-parent-response-div input:checked' ).closest( 'tr' ), parentId, parentTitle,
|
||||
editRow = $( '#edit-' + postId ), newParent, newTitle;
|
||||
|
||||
if ( foundRow.length ) {
|
||||
parentId = $( ':radio', foundRow ).val() || '';
|
||||
parentTitle = $( 'label', foundRow ).html() || '';
|
||||
newParent = $(':input[name="post_parent"]', editRow).clone( true ).val( parentId );
|
||||
newTitle = $(':input[name="post_parent_title"]', editRow).clone( true ).val( parentTitle );
|
||||
$(':input[name="post_parent"]', editRow).replaceWith( newParent );
|
||||
$(':input[name="post_parent_title"]', editRow).replaceWith( newTitle );
|
||||
}
|
||||
|
||||
mla.setParent.close();
|
||||
$('#mla-set-parent-submit' ).off( 'click' );
|
||||
},
|
||||
|
||||
bulkParentOpen : function() {
|
||||
var parentId, postId, postTitle;
|
||||
|
||||
postId = -1;
|
||||
postTitle = mla.settings.bulkTitle;
|
||||
parentId = $( '#bulk-edit :input[name="post_parent"]' ).val() || -1;
|
||||
mla.setParent.open( parentId, postId, postTitle );
|
||||
/*
|
||||
* Grab the "Update" button
|
||||
*/
|
||||
$( '#mla-set-parent-submit' ).on( 'click', function( event ){
|
||||
event.preventDefault();
|
||||
mla.inlineEditAttachment.bulkParentSave();
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
bulkParentSave : function() {
|
||||
var foundRow = $( '#mla-set-parent-response-div input:checked' ).closest( 'tr' ), parentId, newParent;
|
||||
|
||||
if ( foundRow.length ) {
|
||||
parentId = $( ':radio', foundRow ).val() || '';
|
||||
newParent = $('#bulk-edit :input[name="post_parent"]').clone( true ).val( parentId );
|
||||
$('#bulk-edit :input[name="post_parent"]').replaceWith( newParent );
|
||||
}
|
||||
|
||||
mla.setParent.close();
|
||||
$('#mla-set-parent-submit' ).off( 'click' );
|
||||
},
|
||||
|
||||
tableParentOpen : function( parentId, postId, postTitle ) {
|
||||
mla.setParent.open( parentId, postId, postTitle );
|
||||
/*
|
||||
* Grab the "Update" button
|
||||
*/
|
||||
$( '#mla-set-parent-submit' ).on( 'click', function( event ){
|
||||
event.preventDefault();
|
||||
mla.inlineEditAttachment.tableParentSave( postId );
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
tableParentSave : function( postId ) {
|
||||
var foundRow = $( '#mla-set-parent-response-div input:checked' ).closest( 'tr' ),
|
||||
parentId = $( ':radio', foundRow ).val() || '-1',
|
||||
params, tableCell = $( '#attachment-' + postId + " td.attached_to" ).clone( true );
|
||||
|
||||
if ( foundRow.length && ( parentId >= 0 ) ) {
|
||||
tableCell = $( '#attachment-' + postId + " td.attached_to" ).clone( true );
|
||||
tableCell.html( '<span class="spinner"></span>' );
|
||||
$( '#attachment-' + postId + " td.attached_to" ).replaceWith( tableCell );
|
||||
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
$( '#attachment-' + postId + " td.attached_to .spinner" ).addClass("is-active");
|
||||
} else {
|
||||
$( '#attachment-' + postId + " td.attached_to .spinner" ).show();
|
||||
}
|
||||
|
||||
params = $.param( {
|
||||
action: mla.settings.ajax_action + '-set-parent',
|
||||
mla_admin_nonce: mla.settings.ajax_nonce,
|
||||
post_ID: postId,
|
||||
post_parent: parentId,
|
||||
} );
|
||||
|
||||
$.post( ajaxurl, params,
|
||||
function( response ) {
|
||||
if ( response ) {
|
||||
if ( -1 == response.indexOf( 'tableParentOpen(' ) ) {
|
||||
response = response.replace( /<.[^<>]*?>/g, '' );
|
||||
}
|
||||
} else {
|
||||
response = mla.settings.ajaxFailError;
|
||||
}
|
||||
|
||||
$( '#attachment-' + postId ).before( response ).remove();
|
||||
$( '#attachment-' + postId ).hide().fadeIn();
|
||||
}, 'html');
|
||||
} else {
|
||||
tableCell.html( mla.settings.error );
|
||||
$( '#attachment-' + postId + " td.attached_to" ).replaceWith( tableCell );
|
||||
}
|
||||
|
||||
$('#mla-set-parent-submit' ).off( 'click' );
|
||||
mla.setParent.close();
|
||||
},
|
||||
|
||||
doReset : function(){
|
||||
var id = $('table.wp-list-table tr.inline-editor').attr('id'),
|
||||
bulkRow = $('table.wp-list-table #bulk-edit'),
|
||||
blankRow = $('#inlineedit #blank-bulk-edit'),
|
||||
blankCategories = $('.inline-edit-categories', blankRow ).html(),
|
||||
blankTags = $('.inline-edit-tags', blankRow ).html(),
|
||||
blankFields = $('.inline-edit-fields', blankRow ).html();
|
||||
|
||||
if ( id ) {
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
$('table.wp-list-table .inline-edit-save .spinner').removeClass("is-active");
|
||||
} else {
|
||||
$('table.wp-list-table .inline-edit-save .spinner').hide();
|
||||
}
|
||||
|
||||
if ( 'bulk-edit' == id ) {
|
||||
$('.inline-edit-categories', bulkRow ).html( blankCategories ),
|
||||
$('.inline-edit-tags', bulkRow ).html( blankTags ),
|
||||
$('.inline-edit-fields', bulkRow ).html( blankFields );
|
||||
|
||||
if ( ( typeof quicktags !== 'undefined' ) && ( typeof mla.settings.quickTagsInit !== 'undefined' ) ) {
|
||||
for ( id in mla.settings.quickTagsInit ) {
|
||||
quicktags( mla.settings.quickTagsInit[id] );
|
||||
|
||||
if ( mla.settings.quickTagsInit[id]['active'] ) {
|
||||
window.wpActiveEditor = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( typeof mla.addTerm !== 'undefined' ) {
|
||||
mla.addTerm.init( '#bulk-edit-fields-div' );
|
||||
}
|
||||
mla.utility.attachSearch( '#bulk-edit-fields-div' );
|
||||
|
||||
$('#bulk-edit-set-parent', bulkRow).on( 'click', function(){
|
||||
return mla.inlineEditAttachment.bulkParentOpen();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
revert : function(){
|
||||
var id = $('table.wp-list-table tr.inline-editor').attr('id');
|
||||
|
||||
if ( id ) {
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
$('table.wp-list-table .inline-edit-save .spinner').removeClass("is-active");
|
||||
} else {
|
||||
$('table.wp-list-table .inline-edit-save .spinner').hide();
|
||||
}
|
||||
|
||||
if ( 'bulk-edit' == id ) {
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
$('table.wp-list-table #bulk-edit').removeClass('inline-editor').hide().siblings('tr.hidden').remove();
|
||||
} else {
|
||||
$('table.wp-list-table #bulk-edit').removeClass('inline-editor').hide();
|
||||
}
|
||||
|
||||
$('#bulk-titles').html('');
|
||||
$('#inlineedit').append( $('#bulk-edit') );
|
||||
} else {
|
||||
if ( 'bulk-progress' == id ) {
|
||||
$('table.wp-list-table #bulk-progress').removeClass('inline-editor').hide();
|
||||
$('#bulk-progress-waiting').html('');
|
||||
$('#inlineedit').append( $('#bulk-progress') );
|
||||
} else {
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
$('#'+id).siblings('tr.hidden').addBack().remove();
|
||||
} else {
|
||||
$('#'+id).remove();
|
||||
}
|
||||
|
||||
id = id.substr( id.lastIndexOf('-') + 1 );
|
||||
$(this.what+id).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}; // mla.inlineEditAttachment
|
||||
|
||||
$( document ).ready( function() {
|
||||
mla.inlineEditAttachment.init();
|
||||
});
|
||||
})( jQuery );
|
||||
1
wp-content/plugins/media-library-assistant/js/mla-inline-edit-scripts.min.js
vendored
Normal file
1
wp-content/plugins/media-library-assistant/js/mla-inline-edit-scripts.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,248 @@
|
||||
// These functions are adapted from wp-admin/js/inline-edit-post.js
|
||||
|
||||
var ajaxurl, jQuery, mlaInlineEditSettings, mla, mla_inline_edit_settings_vars;
|
||||
|
||||
(function($) {
|
||||
mlaInlineEditSettings = {
|
||||
|
||||
init : function(){
|
||||
var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit');
|
||||
|
||||
t.type = mla_inline_edit_settings_vars.tab;
|
||||
t.what = '#' + mla_inline_edit_settings_vars.tab + '-';
|
||||
|
||||
// prepare the edit rows
|
||||
qeRow.keyup(function(e){
|
||||
if (e.which == 27)
|
||||
return mlaInlineEditSettings.revert();
|
||||
});
|
||||
bulkRow.keyup(function(e){
|
||||
if (e.which == 27)
|
||||
return mlaInlineEditSettings.revert();
|
||||
});
|
||||
|
||||
$('a.cancel', qeRow).click(function(){
|
||||
return mlaInlineEditSettings.revert();
|
||||
});
|
||||
$('a.save', qeRow).click(function(){
|
||||
return mlaInlineEditSettings.save(this);
|
||||
});
|
||||
$('td', qeRow).keydown(function(e){
|
||||
if ( e.which == 13 )
|
||||
return mlaInlineEditSettings.save(this);
|
||||
});
|
||||
|
||||
$('a.cancel', bulkRow).click(function(){
|
||||
return mlaInlineEditSettings.revert();
|
||||
});
|
||||
|
||||
// add events
|
||||
$('a.editinline').live('click', function(){
|
||||
mlaInlineEditSettings.edit(this);
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#doaction, #doaction2').click(function(e){
|
||||
var n = $(this).attr('id').substr(2);
|
||||
|
||||
if ( $('select[name="'+n+'"]').val() == 'edit' ) {
|
||||
e.preventDefault();
|
||||
t.setBulk();
|
||||
} else if ( $('form#posts-filter tr.inline-editor').length > 0 ) {
|
||||
t.revert();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
toggle : function(el){
|
||||
var t = this;
|
||||
|
||||
if ( 'none' == $( t.what + t.getId( el ) ).css('display') ) {
|
||||
t.revert();
|
||||
} else {
|
||||
t.edit( el );
|
||||
}
|
||||
},
|
||||
|
||||
setBulk : function(){
|
||||
var te = '', c = true;
|
||||
this.revert();
|
||||
|
||||
$('#bulk-edit td').attr('colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length);
|
||||
$('table.widefat tbody').prepend( $('#bulk-edit') );
|
||||
$('#bulk-edit').addClass('inline-editor').show();
|
||||
|
||||
$('tbody th.check-column input[type="checkbox"]').each(function(){
|
||||
if ( $(this).prop('checked') ) {
|
||||
c = false;
|
||||
var id = $(this).val(), theTitle;
|
||||
theTitle = $('#inline_'+id+' .slug').text() || mla_inline_edit_settings_vars.notitle;
|
||||
te += '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+mla_inline_edit_settings_vars.ntdeltitle+'">X</a>'+theTitle+'</div>';
|
||||
}
|
||||
});
|
||||
|
||||
if ( c )
|
||||
return this.revert();
|
||||
|
||||
$('#bulk-titles').html(te);
|
||||
$('#bulk-titles a').click(function(){
|
||||
var id = $(this).attr('id').substr(1);
|
||||
|
||||
$('table.widefat input[value="' + id + '"]').prop('checked', false);
|
||||
$('#ttle'+id).remove();
|
||||
});
|
||||
|
||||
$('html, body').animate( { scrollTop: 0 }, 'fast' );
|
||||
},
|
||||
|
||||
edit : function(id) {
|
||||
var t = this, fields, checkboxes, editRow, rowData, fIndex, fText;
|
||||
t.revert();
|
||||
|
||||
if ( typeof(id) == 'object' )
|
||||
id = t.getId(id);
|
||||
|
||||
fields = mla_inline_edit_settings_vars.fields;
|
||||
checkboxes = mla_inline_edit_settings_vars.checkboxes;
|
||||
|
||||
// add the new blank row
|
||||
editRow = $('#inline-edit').clone(true);
|
||||
$('td', editRow).attr('colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length);
|
||||
|
||||
if ( $(t.what+id).hasClass('alternate') )
|
||||
$(editRow).addClass('alternate');
|
||||
|
||||
$(t.what+id).hide().after(editRow);
|
||||
|
||||
// populate the data
|
||||
rowData = $('#inline_'+id);
|
||||
|
||||
for ( fIndex = 0; fIndex < fields.length; fIndex++ ) {
|
||||
fText = $( '.' + fields[fIndex], rowData ).text();
|
||||
|
||||
switch ( fields[fIndex] ) {
|
||||
case 'type':
|
||||
// IPTC/EXIF rules differ by type
|
||||
if ( 'taxonomy' == fText ) {
|
||||
$('.inline-taxonomy-group', editRow).show();
|
||||
} else {
|
||||
$('.inline-taxonomy-group', editRow).hide();
|
||||
}
|
||||
|
||||
if ( 'custom' == fText ) {
|
||||
$('.inline-custom-group', editRow).show();
|
||||
} else {
|
||||
$('.inline-custom-group', editRow).hide();
|
||||
}
|
||||
|
||||
break;
|
||||
case 'parent_options':
|
||||
fText = $( '.' + fields[fIndex], rowData ).html();
|
||||
$(':input[name="parent"]', editRow).html( fText );
|
||||
break;
|
||||
default:
|
||||
$(':input[name="' + fields[fIndex] + '"]', editRow).val( fText );
|
||||
break;
|
||||
} // switch fields[fIndex]
|
||||
}
|
||||
|
||||
for ( fIndex = 0; fIndex < checkboxes.length; fIndex++ ) {
|
||||
if ( '1' == $('.'+checkboxes[fIndex], rowData).text() )
|
||||
$(':input[name="' + checkboxes[fIndex] + '"]', editRow).attr( 'checked', 'checked' );
|
||||
else
|
||||
$(':input[name="' + checkboxes[fIndex] + '"]', editRow).removeAttr('checked');
|
||||
}
|
||||
|
||||
$(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show();
|
||||
$('.ptitle', editRow).focus(); // $('.ptitle', editRow).eq(0).focus();
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
save : function(id) {
|
||||
var params, fields;
|
||||
|
||||
if ( typeof(id) == 'object' )
|
||||
id = this.getId(id);
|
||||
|
||||
if ( mla_inline_edit_settings_vars.useSpinnerClass ) {
|
||||
$('table.widefat .spinner').addClass("is-active");
|
||||
} else {
|
||||
$('table.widefat .spinner').show();
|
||||
}
|
||||
|
||||
params = {
|
||||
action: mla_inline_edit_settings_vars.ajax_action,
|
||||
mla_admin_nonce: mla_inline_edit_settings_vars.ajax_nonce,
|
||||
post_ID: id
|
||||
};
|
||||
|
||||
fields = $('#edit-'+id+' :input').serialize();
|
||||
params = fields + '&' + $.param(params);
|
||||
|
||||
// make ajax request
|
||||
$.post( ajaxurl, params,
|
||||
function(r) {
|
||||
if ( mla_inline_edit_settings_vars.useSpinnerClass ) {
|
||||
$('table.widefat .spinner').removeClass("is-active");
|
||||
} else {
|
||||
$('table.widefat .spinner').hide();
|
||||
}
|
||||
|
||||
if (r) {
|
||||
if ( -1 != r.indexOf('<tr') ) {
|
||||
$(mlaInlineEditSettings.what+id).remove();
|
||||
$('#edit-'+id).before(r).remove();
|
||||
$(mlaInlineEditSettings.what+id).hide().fadeIn();
|
||||
|
||||
// add event handler to the Execute rollover link
|
||||
$(mlaInlineEditSettings.what+id + ' a.execute' ).click(function( e ){
|
||||
e.preventDefault();
|
||||
return mla.inlineMapAttachment.bulkMap( e.target.id, 0 );
|
||||
});
|
||||
} else {
|
||||
r = r.replace( /<.[^<>]*?>/g, '' );
|
||||
$('#edit-'+id+' .inline-edit-save .error').html(r).show();
|
||||
}
|
||||
} else {
|
||||
$('#edit-'+id+' .inline-edit-save .error').html(mla_inline_edit_settings_vars.error).show();
|
||||
}
|
||||
}, 'html');
|
||||
return false;
|
||||
},
|
||||
|
||||
revert : function(){
|
||||
var id = $('table.widefat tr.inline-editor').attr('id');
|
||||
|
||||
if ( id ) {
|
||||
$('table.widefat .inline-edit-save .waiting').hide();
|
||||
|
||||
if ( 'bulk-edit' == id ) {
|
||||
$('table.widefat #bulk-edit').removeClass('inline-editor').hide();
|
||||
$('#bulk-titles').html('');
|
||||
$('#inlineedit').append( $('#bulk-edit') );
|
||||
} else {
|
||||
if ( mla_inline_edit_settings_vars.useSpinnerClass ) {
|
||||
$('table.widefat .spinner').removeClass("is-active");
|
||||
} else {
|
||||
$('table.widefat .spinner').hide();
|
||||
}
|
||||
|
||||
$('#'+id).remove();
|
||||
id = id.substr( id.lastIndexOf('-') + 1 );
|
||||
$(this.what+id).show();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
getId : function(o) {
|
||||
var id = $(o).closest('tr').attr('id'),
|
||||
parts = id.split('-');
|
||||
return parts[parts.length - 1];
|
||||
}
|
||||
};
|
||||
|
||||
$(document).ready(function(){mlaInlineEditSettings.init();});
|
||||
})(jQuery);
|
||||
1
wp-content/plugins/media-library-assistant/js/mla-inline-edit-settings-scripts.min.js
vendored
Normal file
1
wp-content/plugins/media-library-assistant/js/mla-inline-edit-settings-scripts.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var ajaxurl,jQuery,mlaInlineEditSettings,mla,mla_inline_edit_settings_vars;(function(a){mlaInlineEditSettings={init:function(){var c=this,d=a("#inline-edit"),b=a("#bulk-edit");c.type=mla_inline_edit_settings_vars.tab;c.what="#"+mla_inline_edit_settings_vars.tab+"-";d.keyup(function(f){if(f.which==27){return mlaInlineEditSettings.revert()}});b.keyup(function(f){if(f.which==27){return mlaInlineEditSettings.revert()}});a("a.cancel",d).click(function(){return mlaInlineEditSettings.revert()});a("a.save",d).click(function(){return mlaInlineEditSettings.save(this)});a("td",d).keydown(function(f){if(f.which==13){return mlaInlineEditSettings.save(this)}});a("a.cancel",b).click(function(){return mlaInlineEditSettings.revert()});a("a.editinline").live("click",function(){mlaInlineEditSettings.edit(this);return false});a("#doaction, #doaction2").click(function(f){var g=a(this).attr("id").substr(2);if(a('select[name="'+g+'"]').val()=="edit"){f.preventDefault();c.setBulk()}else{if(a("form#posts-filter tr.inline-editor").length>0){c.revert()}}})},toggle:function(c){var b=this;if("none"==a(b.what+b.getId(c)).css("display")){b.revert()}else{b.edit(c)}},setBulk:function(){var b="",d=true;this.revert();a("#bulk-edit td").attr("colspan",a("th:visible, td:visible",".widefat:first thead").length);a("table.widefat tbody").prepend(a("#bulk-edit"));a("#bulk-edit").addClass("inline-editor").show();a('tbody th.check-column input[type="checkbox"]').each(function(){if(a(this).prop("checked")){d=false;var e=a(this).val(),c;c=a("#inline_"+e+" .slug").text()||mla_inline_edit_settings_vars.notitle;b+='<div id="ttle'+e+'"><a id="_'+e+'" class="ntdelbutton" title="'+mla_inline_edit_settings_vars.ntdeltitle+'">X</a>'+c+"</div>"}});if(d){return this.revert()}a("#bulk-titles").html(b);a("#bulk-titles a").click(function(){var c=a(this).attr("id").substr(1);a('table.widefat input[value="'+c+'"]').prop("checked",false);a("#ttle"+c).remove()});a("html, body").animate({scrollTop:0},"fast")},edit:function(i){var e=this,b,g,d,f,h,c;e.revert();if(typeof(i)=="object"){i=e.getId(i)}b=mla_inline_edit_settings_vars.fields;g=mla_inline_edit_settings_vars.checkboxes;d=a("#inline-edit").clone(true);a("td",d).attr("colspan",a("th:visible, td:visible",".widefat:first thead").length);if(a(e.what+i).hasClass("alternate")){a(d).addClass("alternate")}a(e.what+i).hide().after(d);f=a("#inline_"+i);for(h=0;h<b.length;h++){c=a("."+b[h],f).text();switch(b[h]){case"type":if("taxonomy"==c){a(".inline-taxonomy-group",d).show()}else{a(".inline-taxonomy-group",d).hide()}if("custom"==c){a(".inline-custom-group",d).show()}else{a(".inline-custom-group",d).hide()}break;case"parent_options":c=a("."+b[h],f).html();a(':input[name="parent"]',d).html(c);break;default:a(':input[name="'+b[h]+'"]',d).val(c);break}}for(h=0;h<g.length;h++){if("1"==a("."+g[h],f).text()){a(':input[name="'+g[h]+'"]',d).attr("checked","checked")}else{a(':input[name="'+g[h]+'"]',d).removeAttr("checked")}}a(d).attr("id","edit-"+i).addClass("inline-editor").show();a(".ptitle",d).focus();return false},save:function(d){var c,b;if(typeof(d)=="object"){d=this.getId(d)}if(mla_inline_edit_settings_vars.useSpinnerClass){a("table.widefat .spinner").addClass("is-active")}else{a("table.widefat .spinner").show()}c={action:mla_inline_edit_settings_vars.ajax_action,mla_admin_nonce:mla_inline_edit_settings_vars.ajax_nonce,post_ID:d};b=a("#edit-"+d+" :input").serialize();c=b+"&"+a.param(c);a.post(ajaxurl,c,function(e){if(mla_inline_edit_settings_vars.useSpinnerClass){a("table.widefat .spinner").removeClass("is-active")}else{a("table.widefat .spinner").hide()}if(e){if(-1!=e.indexOf("<tr")){a(mlaInlineEditSettings.what+d).remove();a("#edit-"+d).before(e).remove();a(mlaInlineEditSettings.what+d).hide().fadeIn();a(mlaInlineEditSettings.what+d+" a.execute").click(function(f){f.preventDefault();return mla.inlineMapAttachment.bulkMap(f.target.id,0)})}else{e=e.replace(/<.[^<>]*?>/g,"");a("#edit-"+d+" .inline-edit-save .error").html(e).show()}}else{a("#edit-"+d+" .inline-edit-save .error").html(mla_inline_edit_settings_vars.error).show()}},"html");return false},revert:function(){var b=a("table.widefat tr.inline-editor").attr("id");if(b){a("table.widefat .inline-edit-save .waiting").hide();if("bulk-edit"==b){a("table.widefat #bulk-edit").removeClass("inline-editor").hide();a("#bulk-titles").html("");a("#inlineedit").append(a("#bulk-edit"))}else{if(mla_inline_edit_settings_vars.useSpinnerClass){a("table.widefat .spinner").removeClass("is-active")}else{a("table.widefat .spinner").hide()}a("#"+b).remove();b=b.substr(b.lastIndexOf("-")+1);a(this.what+b).show()}}return false},getId:function(c){var d=a(c).closest("tr").attr("id"),b=d.split("-");return b[b.length-1]}};a(document).ready(function(){mlaInlineEditSettings.init()})})(jQuery);
|
||||
@@ -0,0 +1,377 @@
|
||||
/* global ajaxurl */
|
||||
|
||||
var jQuery,
|
||||
mla_inline_mapping_vars,
|
||||
mla = {
|
||||
// Properties
|
||||
settings: {},
|
||||
bulkMap: {
|
||||
ids: [],
|
||||
inProcess: false,
|
||||
doCancel: false
|
||||
},
|
||||
|
||||
// Utility functions
|
||||
utility: {
|
||||
},
|
||||
|
||||
// Components
|
||||
inlineMapAttachment: null
|
||||
};
|
||||
|
||||
( function( $ ) {
|
||||
/**
|
||||
* Localized settings and strings
|
||||
*/
|
||||
mla.settings = typeof mla_inline_mapping_vars === 'undefined' ? {} : mla_inline_mapping_vars;
|
||||
mla_inline_mapping_vars = void 0; // delete won't work on Globals
|
||||
|
||||
mla.inlineMapAttachment = {
|
||||
init : function(){
|
||||
var progressDiv = $( '#mla-progress-div' );
|
||||
|
||||
$('#mla-progress-pause', progressDiv).off( 'click' );
|
||||
$('#mla-progress-pause', progressDiv).click( function(){
|
||||
if ( mla.bulkMap.inProcess ) {
|
||||
mla.bulkMap.doCancel = true;
|
||||
return false;
|
||||
} else {
|
||||
return mla.inlineMapAttachment.revert();
|
||||
}
|
||||
});
|
||||
|
||||
$('#mla-progress-cancel', progressDiv).off( 'click' );
|
||||
$('#mla-progress-cancel', progressDiv).click( function(){
|
||||
return mla.inlineMapAttachment.revert();
|
||||
});
|
||||
|
||||
$('#mla-progress-resume', progressDiv).off( 'click' );
|
||||
$('#mla-progress-resume', progressDiv).click( function(){
|
||||
var totalItems = +mla.settings.totalItems, newOffset = + $( '#mla-progress-offset' ).val();
|
||||
|
||||
if ( totalItems < newOffset ) {
|
||||
newOffset = totalItems;
|
||||
} else {
|
||||
if ( 0 > newOffset ) {
|
||||
newOffset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( mla.bulkMap.inProcess ) {
|
||||
mla.bulkMap.doCancel = true;
|
||||
return false;
|
||||
} else {
|
||||
return mla.inlineMapAttachment.bulkMap( mla.bulkMap.targetName, newOffset );
|
||||
}
|
||||
});
|
||||
|
||||
// Clicking "Refresh" submits the form, refreshing the page
|
||||
$( '#mla-progress-refresh', progressDiv ).off( 'click' );
|
||||
$( '#mla-progress-refresh', progressDiv ).click( function(){
|
||||
$( '#mla-progress-refresh' ).prop( 'disabled', true ).css( 'opacity', '0.5' );
|
||||
});
|
||||
|
||||
$('#mla-progress-close', progressDiv).off( 'click' );
|
||||
$('#mla-progress-close', progressDiv).click( function( e ){
|
||||
if ( mla.bulkMap.inProcess ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mla.inlineMapAttachment.revert();
|
||||
});
|
||||
|
||||
// add event handler to the Execute All Rules
|
||||
$( 'input[type="submit"].mla-mapping' ).click(function( e ){
|
||||
e.preventDefault();
|
||||
return mla.inlineMapAttachment.bulkMap( e.target.name, 0 );
|
||||
});
|
||||
|
||||
// add event handler to the Bulk Actions Apply (top)
|
||||
$( 'input[type="submit"]#doaction' ).click(function( e ){
|
||||
var action = $( '#bulk-action-selector-top' ).val(), ids;
|
||||
//console.log( 'Bulk Actions Apply (top) ', e.target.id, ' ', action );
|
||||
if ( 'execute' !== action ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ids = $('tbody th.check-column input[type="checkbox"]').serializeArray();
|
||||
if ( 0 === ids.length ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$.each( ids, function( index, id ) {
|
||||
mla.bulkMap.ids[ index ] = +id.value;
|
||||
});
|
||||
//console.log( JSON.stringify( mla.bulkMap ) );
|
||||
|
||||
e.preventDefault();
|
||||
return mla.inlineMapAttachment.bulkMap( 'mapping-options-bulk-execute', 0 );
|
||||
});
|
||||
|
||||
// add event handler to the Bulk Actions Apply (bottom)
|
||||
$( 'input[type="submit"]#doaction2' ).click(function( e ){
|
||||
var action = $( '#bulk-action-selector-bottom' ).val(), ids;
|
||||
if ( 'execute' !== action ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ids = $('tbody th.check-column input[type="checkbox"]').serializeArray();
|
||||
if ( 0 === ids.length ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$.each( ids, function( index, id ) {
|
||||
mla.bulkMap.ids[ index ] = +id.value;
|
||||
});
|
||||
|
||||
e.preventDefault();
|
||||
return mla.inlineMapAttachment.bulkMap( 'mapping-options-bulk-execute', 0 );
|
||||
});
|
||||
|
||||
// add event handler to the Execute rollover links
|
||||
$( 'a.execute' ).click(function( e ){
|
||||
e.preventDefault();
|
||||
return mla.inlineMapAttachment.bulkMap( e.target.id, 0 );
|
||||
});
|
||||
},
|
||||
|
||||
bulkMap : function( action, initialOffset ) {
|
||||
var oldComplete = 0, oldUnchanged = 0, oldSuccess = 0, oldSkip = 0, oldRedone = 0, bulk_ids = [];
|
||||
|
||||
initialOffset = +initialOffset;
|
||||
|
||||
if ( 0 < initialOffset ) {
|
||||
oldComplete = typeof mla.bulkMap.complete === 'undefined' ? 0 : mla.bulkMap.complete;
|
||||
oldUnchanged = typeof mla.bulkMap.unchanged === 'undefined' ? 0 : mla.bulkMap.unchanged;
|
||||
oldSuccess = typeof mla.bulkMap.success === 'undefined' ? 0 : mla.bulkMap.success;
|
||||
oldSkip = typeof mla.bulkMap.skip === 'undefined' ? 0 : mla.bulkMap.skip;
|
||||
oldRedone = typeof mla.bulkMap.redone === 'undefined' ? 0 : mla.bulkMap.redone;
|
||||
}
|
||||
|
||||
// See if we're skipping or re-processing any items
|
||||
if ( oldComplete < initialOffset ) {
|
||||
oldSkip += initialOffset - oldComplete;
|
||||
} else {
|
||||
if ( oldComplete > initialOffset ) {
|
||||
oldRedone += oldComplete - initialOffset;
|
||||
}
|
||||
}
|
||||
|
||||
bulk_ids = typeof mla.bulkMap.ids === 'undefined' ? [] : mla.bulkMap.ids;
|
||||
mla.bulkMap = {
|
||||
ids: bulk_ids,
|
||||
inProcess: false,
|
||||
doCancel: false,
|
||||
chunkSize: +mla.settings.bulkChunkSize,
|
||||
targetName: action,
|
||||
fields: $( mla.settings.fieldsId + ' :input').serialize(),
|
||||
offset: initialOffset,
|
||||
waiting: mla.settings.totalItems - initialOffset,
|
||||
running: 0,
|
||||
complete: initialOffset,
|
||||
unchanged: oldUnchanged,
|
||||
success: oldSuccess,
|
||||
skip: oldSkip,
|
||||
redone: oldRedone,
|
||||
refresh: false
|
||||
};
|
||||
|
||||
mla.inlineMapAttachment.progressOpen();
|
||||
mla.inlineMapAttachment.bulkPost();
|
||||
return false;
|
||||
},
|
||||
|
||||
progressOpen : function(){
|
||||
this.revert();
|
||||
|
||||
$( '#mla-progress-meter' ).css( 'width', '0%' );
|
||||
$( '#mla-progress-meter' ).html('0%');
|
||||
$( '#mla-progress-message' ).html('');
|
||||
$( '#mla-progress-error' ).html('');
|
||||
$( '#mla-progress-div' ).show();
|
||||
|
||||
// Disable "Close" until the bulk mapping is complete
|
||||
$( '#mla-progress-pause' ).prop( 'disabled', false ).css( 'opacity', '1.0' ).show();
|
||||
$( '#mla-progress-cancel' ).hide();
|
||||
$( '#mla-progress-resume' ).hide();
|
||||
$( '#mla-progress-offset' ).hide();
|
||||
$( '#mla-progress-refresh' ).hide();
|
||||
$( '#mla-progress-close' ).prop( 'disabled', true ).css( 'opacity', '0.5' ).show();
|
||||
$( 'html, body' ).animate( { scrollTop: 0 }, 'fast' );
|
||||
},
|
||||
|
||||
bulkPost : function() {
|
||||
var params, chunk, statusMessage = '',
|
||||
spinner = $('#mla-progress-div p.inline-edit-save .spinner'),
|
||||
message = $( '#mla-progress-message' ),
|
||||
error = $( '#mla-progress-error' );
|
||||
|
||||
// Find the number of items to process
|
||||
if ( mla.bulkMap.waiting < mla.bulkMap.chunkSize ) {
|
||||
chunk = mla.bulkMap.waiting;
|
||||
} else {
|
||||
chunk = mla.bulkMap.chunkSize;
|
||||
}
|
||||
|
||||
mla.bulkMap.waiting -= chunk;
|
||||
mla.bulkMap.running = chunk;
|
||||
|
||||
params = {
|
||||
page: mla.settings.page,
|
||||
mla_tab: mla.settings.mla_tab,
|
||||
screen: mla.settings.screen,
|
||||
action: mla.settings.ajax_action,
|
||||
mla_admin_nonce: mla.settings.ajax_nonce,
|
||||
bulk_action: mla.bulkMap.targetName,
|
||||
ids: mla.bulkMap.ids,
|
||||
offset: mla.bulkMap.complete,
|
||||
length: chunk
|
||||
};
|
||||
|
||||
params = $.param( params ) + '&' + mla.bulkMap.fields;
|
||||
|
||||
// make ajax request
|
||||
mla.bulkMap.inProcess = true;
|
||||
|
||||
percentComplete = Math.floor( ( 100 * mla.bulkMap.complete ) / mla.settings.totalItems ) + '%';
|
||||
$( '#mla-progress-meter' ).css( 'width', percentComplete );
|
||||
$( '#mla-progress-meter' ).html( percentComplete );
|
||||
|
||||
if ( 0 < mla.bulkMap.skip ) {
|
||||
statusMessage += ', ' + mla.settings.bulkSkip + ': ' + mla.bulkMap.skip;
|
||||
}
|
||||
|
||||
if ( 0 < mla.bulkMap.redone ) {
|
||||
statusMessage += ', ' + mla.settings.bulkRedone + ': ' + mla.bulkMap.redone;
|
||||
}
|
||||
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
spinner.addClass("is-active");
|
||||
} else {
|
||||
spinner.show();
|
||||
}
|
||||
|
||||
statusMessage = mla.settings.bulkWaiting + ': ' + mla.bulkMap.waiting
|
||||
+ ', ' + mla.settings.bulkRunning + ': ' + mla.bulkMap.running
|
||||
+ ', ' + mla.settings.bulkComplete + ': ' + mla.bulkMap.complete
|
||||
+ statusMessage // skip and redone
|
||||
+ ', ' + mla.settings.bulkUnchanged + ': ' + mla.bulkMap.unchanged
|
||||
+ ', ' + mla.settings.bulkSuccess + ': ' + mla.bulkMap.success;
|
||||
message.html( statusMessage ).show();
|
||||
|
||||
$.ajax( ajaxurl, {
|
||||
type: 'POST',
|
||||
data: params,
|
||||
dataType: 'json'
|
||||
}).always( function() {
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
spinner.removeClass("is-active");
|
||||
} else {
|
||||
spinner.hide();
|
||||
}
|
||||
}).done( function( response, status ) {
|
||||
var responseData = 'no response.data', responseMessage = '';
|
||||
|
||||
if ( response ) {
|
||||
if ( ! response.success ) {
|
||||
if ( response.responseData ) {
|
||||
responseData = response.data;
|
||||
}
|
||||
|
||||
error.html( JSON.stringify( response ) );
|
||||
mla.bulkMap.waiting = 0; // Stop
|
||||
} else {
|
||||
if ( 0 == response.data.processed ) {
|
||||
// Something went wrong; we're done
|
||||
responseMessage = response.data.message;
|
||||
mla.bulkMap.waiting = 0; // Stop
|
||||
} else {
|
||||
// Move the items from Running to Complete
|
||||
mla.bulkMap.complete += response.data.processed;
|
||||
mla.bulkMap.running = 0;
|
||||
mla.bulkMap.unchanged += response.data.unchanged;
|
||||
mla.bulkMap.success += response.data.success;
|
||||
|
||||
if ( 'undefined' !== typeof response.data.refresh ) {
|
||||
mla.bulkMap.refresh = response.data.refresh;
|
||||
}
|
||||
|
||||
percentComplete = Math.floor( ( 100 * mla.bulkMap.complete ) / mla.settings.totalItems ) + '%';
|
||||
$( '#mla-progress-meter' ).css( 'width', percentComplete );
|
||||
$( '#mla-progress-meter' ).html( percentComplete );
|
||||
|
||||
if ( 0 < mla.bulkMap.skip ) {
|
||||
responseMessage += ', ' + mla.settings.bulkSkip + ': ' + mla.bulkMap.skip;
|
||||
}
|
||||
|
||||
if ( 0 < mla.bulkMap.redone ) {
|
||||
responseMessage += ', ' + mla.settings.bulkRedone + ': ' + mla.bulkMap.redone;
|
||||
}
|
||||
|
||||
responseMessage = mla.settings.bulkWaiting + ': ' + mla.bulkMap.waiting
|
||||
+ ', ' + mla.settings.bulkComplete + ': ' + mla.bulkMap.complete
|
||||
+ responseMessage // skip and redone
|
||||
+ ', ' + mla.settings.bulkUnchanged + ': ' + mla.bulkMap.unchanged
|
||||
+ ', ' + mla.settings.bulkSuccess + ': ' + mla.bulkMap.success;
|
||||
}
|
||||
message.html( responseMessage ).show();
|
||||
}
|
||||
} else {
|
||||
error.html( mla.settings.error );
|
||||
mla.bulkMap.waiting = 0; // Stop
|
||||
}
|
||||
|
||||
if ( mla.bulkMap.doCancel ) {
|
||||
message.html( mla.settings.bulkPaused + '. ' + responseMessage ).show();
|
||||
$( '#mla-progress-pause' ).hide();
|
||||
$( '#mla-progress-cancel' ).show();
|
||||
$( '#mla-progress-resume' ).show();
|
||||
$( '#mla-progress-offset' ).val( mla.bulkMap.complete ).show();
|
||||
} else {
|
||||
if ( mla.bulkMap.waiting ) {
|
||||
mla.inlineMapAttachment.bulkPost();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( mla.bulkMap.refresh ) {
|
||||
$( '#mla-progress-close' ).hide();
|
||||
$( '#mla-progress-refresh' ).prop( 'disabled', false ).css( 'opacity', '1.0' ).show();
|
||||
} else {
|
||||
$( '#mla-progress-close' ).prop( 'disabled', false ).css( 'opacity', '1.0' );
|
||||
}
|
||||
|
||||
$( '#mla-progress-pause' ).prop( 'disabled', true ).css( 'opacity', '0.5' );
|
||||
mla.bulkMap.inProcess = false;
|
||||
}).fail( function( jqXHR, status ) {
|
||||
if ( 200 == jqXHR.status ) {
|
||||
error.html( '(' + status + ') ' + jqXHR.responseText );
|
||||
} else {
|
||||
error.html( mla.settings.ajaxFailError + ' (' + status + '), jqXHR( ' + jqXHR.status + ', ' + jqXHR.statusText + ', ' + jqXHR.responseText + ')' );
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
revert : function(){
|
||||
var progressDiv = $( '#mla-progress-div' );
|
||||
|
||||
if ( progressDiv ) {
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
$('p.inline-edit-save .spinner', progressDiv ).removeClass("is-active");
|
||||
} else {
|
||||
$('p.inline-edit-save .spinner', progressDiv ).hide();
|
||||
}
|
||||
|
||||
// Reset Div content to initial values
|
||||
|
||||
$( progressDiv ).hide();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}; // mla.inlineMapAttachment
|
||||
|
||||
$( document ).ready( function() {
|
||||
mla.inlineMapAttachment.init();
|
||||
});
|
||||
})( jQuery );
|
||||
1
wp-content/plugins/media-library-assistant/js/mla-inline-mapping-scripts.min.js
vendored
Normal file
1
wp-content/plugins/media-library-assistant/js/mla-inline-mapping-scripts.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
1
wp-content/plugins/media-library-assistant/js/mla-media-modal-scripts.min.js
vendored
Normal file
1
wp-content/plugins/media-library-assistant/js/mla-media-modal-scripts.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,390 @@
|
||||
/* global ajaxurl */
|
||||
|
||||
var jQuery,
|
||||
mla_polylang_support_vars,
|
||||
mlaPolylang = {
|
||||
// Properties
|
||||
// mlaPolylang.settings.noTitle
|
||||
// mlaPolylang.settings.ntdelTitle
|
||||
// mlaPolylang.settings.fields
|
||||
// mlaPolylang.settings.comma
|
||||
// mlaPolylang.settings.ajax_action
|
||||
// mlaPolylang.settings.ajax_nonce
|
||||
// mlaPolylang.settings.error
|
||||
settings: {},
|
||||
|
||||
// Utility functions
|
||||
utility: {
|
||||
getId : function( o ) {
|
||||
var id = jQuery( o ).closest( 'tr' ).attr( 'id' ),
|
||||
parts = id.split( '-' );
|
||||
return parts[ parts.length - 1 ];
|
||||
}
|
||||
},
|
||||
|
||||
// Components
|
||||
inlineTranslate: null
|
||||
};
|
||||
|
||||
( function( $ ) {
|
||||
/**
|
||||
* Localized settings and strings
|
||||
*/
|
||||
mlaPolylang.settings = typeof mla_polylang_support_vars === 'undefined' ? {} : mla_polylang_support_vars;
|
||||
mla_polylang_support_vars = void 0; // delete won't work on Globals
|
||||
|
||||
mlaPolylang.inlineTranslate = {
|
||||
init : function(){
|
||||
var t = this, qtRow = $( '#pll-quick-translate' ), btRow = $( '#pll-bulk-translate' );
|
||||
|
||||
t.type = 'attachment';
|
||||
t.what = '#attachment-';
|
||||
|
||||
// prepare the quick-translate row
|
||||
qtRow.keyup( function( e ){
|
||||
if ( e.which == 27 )
|
||||
return mlaPolylang.inlineTranslate.revert();
|
||||
});
|
||||
|
||||
$( 'a.cancel', qtRow ).click( function(){
|
||||
return mlaPolylang.inlineTranslate.revert();
|
||||
});
|
||||
|
||||
$( 'a.save', qtRow ).click( function(){
|
||||
return mlaPolylang.inlineTranslate.save( this );
|
||||
});
|
||||
|
||||
$( 'td', qtRow ).keydown( function(e){
|
||||
if ( e.which == 13 )
|
||||
return mlaPolylang.inlineTranslate.save( this );
|
||||
});
|
||||
|
||||
// add event to the Quick Translate links
|
||||
$( '#the-list' ).on( 'click', 'a.inlineTranslate', function(){
|
||||
mlaPolylang.inlineTranslate.edit( this );
|
||||
return false;
|
||||
});
|
||||
|
||||
/*
|
||||
* Add event to the Quick Edit links. This click function runs before
|
||||
* the Quick Edit row is created; the focusin() event delays action until
|
||||
* everything is ready.
|
||||
*/
|
||||
$( '#the-list' ).on( 'click', 'a.editinline', function(){
|
||||
$( '.quick-edit-row' ).one( 'focusin', function() {
|
||||
mlaPolylang.inlineTranslate.openQuickEdit( this );
|
||||
return false;
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// prepare the bulk-translate row
|
||||
btRow.keyup( function( e ){
|
||||
if ( e.which == 27 )
|
||||
return mlaPolylang.inlineTranslate.revert();
|
||||
});
|
||||
|
||||
$( 'a.cancel', btRow ).click( function(){
|
||||
return mlaPolylang.inlineTranslate.revert();
|
||||
});
|
||||
|
||||
$( '#doaction, #doaction2' ).click( function( e ){
|
||||
var n = $( this ).attr( 'id' ).substr( 2 );
|
||||
|
||||
if ( $( 'select[name="'+n+'"]' ).val() == 'pll-translate' ) {
|
||||
e.preventDefault();
|
||||
t.openBulkTranslate();
|
||||
} else if ( $( 'form#posts-filter tr.inline-translator' ).length > 0 ) {
|
||||
t.revert();
|
||||
}
|
||||
});
|
||||
|
||||
// Filter button (dates, categories) in top nav bar
|
||||
$( '#post-query-submit' ).mousedown( function(){
|
||||
t.revert();
|
||||
$( 'select[name^="action"]' ).val( '-1' );
|
||||
});
|
||||
},
|
||||
|
||||
toggle : function( el ){
|
||||
var t = this;
|
||||
|
||||
if ( 'none' == $( t.what + mlaPolylang.utility.getId( el ) ).css( 'display' ) ) {
|
||||
t.revert();
|
||||
} else {
|
||||
t.edit( el );
|
||||
}
|
||||
},
|
||||
|
||||
openBulkTranslate : function(){
|
||||
var te = '', c = true;
|
||||
this.revert();
|
||||
|
||||
// Open up the Bulk Translate area
|
||||
$( '#pll-bulk-translate td' ).attr( 'colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length );
|
||||
$( 'table.widefat tbody' ).prepend( $( '#pll-bulk-translate' ) );
|
||||
$( '#pll-bulk-translate' ).addClass( 'inline-translator' ).show();
|
||||
|
||||
// Make sure at least one item has been selected
|
||||
$( 'tbody th.check-column input[type="checkbox"]' ).each( function(){
|
||||
if ( $( this ).prop( 'checked' ) ) {
|
||||
c = false;
|
||||
var id = $( this ).val(), theTitle;
|
||||
theTitle = $( '#inline_'+id+' .post_title' ).text() || mlaPolylang.settings.noTitle;
|
||||
te += '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+mlaPolylang.settings.ntdelTitle+'">X</a>'+theTitle+'</div>';
|
||||
}
|
||||
});
|
||||
|
||||
if ( c ) {
|
||||
return this.revert();
|
||||
}
|
||||
|
||||
// Populate the list of selected items
|
||||
$( '#pll-bulk-titles' ).html( te );
|
||||
$( '#pll-bulk-titles a' ).click(function(){
|
||||
var id = $( this ).attr( 'id' ).substr( 1 );
|
||||
|
||||
$( 'table.widefat input[value="' + id + '"]' ).prop( 'checked', false );
|
||||
$( '#ttle'+id ).remove();
|
||||
});
|
||||
|
||||
// Capture Language links
|
||||
$( '#pll-bulk-translate .pll-media-action-table tr' ).each( function ( idx ){
|
||||
//$( '.pll-media-action-column a', this ).off( 'click' );
|
||||
$( '.pll-media-action-column a', this ).click( function( e ){
|
||||
var bulkLanguage = $( this ).attr( 'pll_bulk_language' );
|
||||
|
||||
$( ':input[name="pll_bulk_language"]', '#pll-bulk-translate' ).val( bulkLanguage );
|
||||
$( '#pll-bulk-translate .pll-media-action-table a' ).prop( 'disabled', true );
|
||||
$( '#pll-bulk-translate' ).css( 'opacity', '0.5' );
|
||||
$( this ).hide();
|
||||
return $( '#pll-bulk-translate-submit', '#pll-bulk-translate' ).click();
|
||||
});
|
||||
});
|
||||
|
||||
$( 'html, body' ).animate( { scrollTop: 0 }, 'fast' );
|
||||
},
|
||||
|
||||
openQuickEdit : function( id ) {
|
||||
var translateRow, translations, currentLanguage;
|
||||
|
||||
if ( typeof( id ) == 'object' )
|
||||
id = mlaPolylang.utility.getId( id );
|
||||
|
||||
// find the Quick Edit row
|
||||
translateRow = $( '#edit-' + id );
|
||||
|
||||
// set up the quick translate entries
|
||||
currentLanguage = $( ':input[name="old_lang"]', translateRow ).val();
|
||||
translations = JSON.parse( $( ':input[name="inline_translations"]', translateRow ).val() );
|
||||
|
||||
$( '.pll-media-action-table tr', translateRow ).each( function ( idx ){
|
||||
var parts = $( this ).attr( 'class' ).split( '-' ), slug = parts[ parts.length - 1 ];
|
||||
|
||||
if ( slug === currentLanguage ) {
|
||||
$( '.pll-media-action-column input', this ).val( translations[ slug ] );
|
||||
$( this ).hide();
|
||||
} else if ( 'undefined' != typeof translations[ slug ] ) {
|
||||
$( '.pll-media-action-column input', this ).val( translations[ slug ] );
|
||||
$( '.pll-media-action-column a', this ).addClass( 'pll_icon_edit' );
|
||||
$( '.pll-media-action-column a', this ).attr( 'title', mlaPolylang.settings.edit );
|
||||
$( '.pll-media-action-column a', this ).attr( 'pll_quick_language', slug );
|
||||
$( '.pll-media-action-column a', this ).attr( 'pll_quick_id', translations[ slug ] );
|
||||
} else {
|
||||
$( '.pll-media-action-column input', this ).val( 0 );
|
||||
$( '.pll-media-action-column a', this ).addClass( 'pll_icon_add' );
|
||||
$( '.pll-media-action-column a', this ).attr( 'title', mlaPolylang.settings.addNew );
|
||||
$( '.pll-media-action-column a', this ).attr( 'pll_quick_language', slug );
|
||||
$( '.pll-media-action-column a', this ).attr( 'pll_quick_id', 0 );
|
||||
}
|
||||
|
||||
$( '.pll-media-action-column a', this ).off( 'click' );
|
||||
$( '.pll-media-action-column a', this ).click( function( e ){
|
||||
var quickLanguage = $( this ).attr( 'pll_quick_language' ), quickId = $( this ).attr( 'pll_quick_id' );
|
||||
|
||||
$( ':input[name="pll_quick_language"]', translateRow ).val( quickLanguage );
|
||||
$( ':input[name="pll_quick_id"]', translateRow ).val( quickId );
|
||||
e.preventDefault();
|
||||
return mlaPolylang.inlineTranslate.save( translateRow );
|
||||
});
|
||||
});
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
edit : function( id ) {
|
||||
var t = this, fields, translateRow, rowData, fIndex, translations, currentLanguage;
|
||||
t.revert();
|
||||
|
||||
if ( typeof( id ) == 'object' )
|
||||
id = mlaPolylang.utility.getId( id );
|
||||
|
||||
fields = mlaPolylang.settings.fields;
|
||||
|
||||
// add the new Quick Translate row before its corresponding item
|
||||
translateRow = $( '#pll-quick-translate' ).clone( true );
|
||||
$( 'td', translateRow ).attr( 'colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length );
|
||||
|
||||
if ( $( t.what+id ).hasClass( 'alternate' ) )
|
||||
$( translateRow ).addClass( 'alternate' );
|
||||
|
||||
$( t.what+id ).before( translateRow );
|
||||
|
||||
// populate the data
|
||||
rowData = $( '#inline_'+id );
|
||||
|
||||
for ( fIndex = 0; fIndex < fields.length; fIndex++ ) {
|
||||
$( ':input[name="' + fields[fIndex] + '"]', translateRow ).val( $( '.'+fields[fIndex], rowData ).text() );
|
||||
}
|
||||
|
||||
// set up the quick translate entries
|
||||
currentLanguage = $( ':input[name="old_lang"]', translateRow ).val();
|
||||
translations = JSON.parse( $( ':input[name="inline_translations"]', translateRow ).val() );
|
||||
|
||||
$( '.pll-media-action-table tr', translateRow ).each( function ( idx ){
|
||||
var parts = $( this ).attr( 'class' ).split( '-' ), slug = parts[ parts.length - 1 ];
|
||||
|
||||
if ( slug === currentLanguage ) {
|
||||
$( '.pll-media-action-column input', this ).val( translations[ slug ] );
|
||||
$( this ).hide();
|
||||
} else if ( 'undefined' != typeof translations[ slug ] ) {
|
||||
$( '.pll-media-action-column input', this ).val( translations[ slug ] );
|
||||
$( '.pll-media-action-column a', this ).addClass( 'pll_icon_edit' );
|
||||
$( '.pll-media-action-column a', this ).attr( 'title', mlaPolylang.settings.edit );
|
||||
$( '.pll-media-action-column a', this ).attr( 'pll_quick_language', slug );
|
||||
$( '.pll-media-action-column a', this ).attr( 'pll_quick_id', translations[ slug ] );
|
||||
} else {
|
||||
$( '.pll-media-action-column input', this ).val( 0 );
|
||||
$( '.pll-media-action-column a', this ).addClass( 'pll_icon_add' );
|
||||
$( '.pll-media-action-column a', this ).attr( 'title', mlaPolylang.settings.addNew );
|
||||
$( '.pll-media-action-column a', this ).attr( 'pll_quick_language', slug );
|
||||
$( '.pll-media-action-column a', this ).attr( 'pll_quick_id', 0 );
|
||||
}
|
||||
|
||||
$( '.pll-media-action-column a', this ).off( 'click' );
|
||||
$( '.pll-media-action-column a', this ).click( function( e ){
|
||||
var quickLanguage = $( this ).attr( 'pll_quick_language' ), quickId = $( this ).attr( 'pll_quick_id' );
|
||||
|
||||
$( ':input[name="pll_quick_language"]', translateRow ).val( quickLanguage );
|
||||
$( ':input[name="pll_quick_id"]', translateRow ).val( quickId );
|
||||
return mlaPolylang.inlineTranslate.save( translateRow );
|
||||
});
|
||||
});
|
||||
|
||||
rowData = $( translateRow ).attr( 'id', 'edit-'+id ).addClass( 'inline-translator' ).show().position().top;
|
||||
$( 'html, body' ).animate( { scrollTop: rowData }, 'fast' );
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
save : function( id ) {
|
||||
var params, fields, page = $( '.post_status_page' ).val() || '';
|
||||
|
||||
if ( typeof( id ) == 'object' )
|
||||
id = mlaPolylang.utility.getId( id );
|
||||
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
$( 'table.widefat .pll-quick-translate-save .spinner' ).addClass("is-active");
|
||||
} else {
|
||||
$( 'table.widefat .pll-quick-translate-save .spinner' ).show();
|
||||
}
|
||||
|
||||
params = {
|
||||
action: mlaPolylang.settings.ajax_action,
|
||||
mla_admin_nonce: mlaPolylang.settings.ajax_nonce,
|
||||
post_type: 'attachment',
|
||||
post_ID: id,
|
||||
edit_date: 'true',
|
||||
post_status: page
|
||||
};
|
||||
|
||||
fields = $( '#edit-' + id + ' :input' ).serialize();
|
||||
params = fields + '&' + $.param( params );
|
||||
|
||||
// make ajax request
|
||||
$.post( ajaxurl, params,
|
||||
function( response ) {
|
||||
var newId, oldRow, rowId, rows, rIndex;
|
||||
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
$( 'table.widefat .pll-quick-translate-save .spinner' ).removeClass("is-active");
|
||||
} else {
|
||||
$( 'table.widefat .pll-quick-translate-save .spinner' ).hide();
|
||||
}
|
||||
|
||||
if ( response ) {
|
||||
if ( -1 != response.indexOf( '<tr id="attachment' ) ) {
|
||||
// Find all the rows in the response
|
||||
rows = $( response ).closest( 'tr' );
|
||||
|
||||
// Remove the selected item
|
||||
newId = mlaPolylang.utility.getId( rows[ 0 ] );
|
||||
oldRow = $( mlaPolylang.inlineTranslate.what + newId )
|
||||
if ( 'undefined' != typeof oldRow ) {
|
||||
oldRow.remove();
|
||||
}
|
||||
|
||||
// Replace the Quick Translate area with the selected item
|
||||
$( '#edit-' + id ).before( rows[ 0 ] ).remove();
|
||||
$( mlaPolylang.inlineTranslate.what + newId ).hide().fadeIn();
|
||||
|
||||
// Update any other translations in the table
|
||||
if ( 1 < rows.length ) {
|
||||
for ( rIndex = 1; rIndex < rows.length; rIndex++ ) {
|
||||
rowId = mlaPolylang.utility.getId( rows[ rIndex ] );
|
||||
oldRow = $( mlaPolylang.inlineTranslate.what + rowId )
|
||||
|
||||
if ( 'undefined' != typeof oldRow ) {
|
||||
oldRow.before( rows[ rIndex ] ).remove();
|
||||
oldRow = $( mlaPolylang.inlineTranslate.what + rowId )
|
||||
oldRow.hide().fadeIn();
|
||||
}
|
||||
}
|
||||
} // other translations
|
||||
|
||||
// Quick Edit a new selected item
|
||||
if ( newId != id ) {
|
||||
$( 'a.editinline', mlaPolylang.inlineTranslate.what + newId ).click();
|
||||
}
|
||||
} else {
|
||||
response = response.replace( /<.[^<>]*?>/g, '' );
|
||||
$( '#edit-' + id + ' .pll-quick-translate-save .error' ).html( response ).show();
|
||||
}
|
||||
} else {
|
||||
$( '#edit-' + id + ' .pll-quick-translate-save .error' ).html( mlaPolylang.settings.error ).show();
|
||||
}
|
||||
}, 'html' );
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
revert : function(){
|
||||
var id = $( 'table.widefat tr.inline-translator ').attr( 'id' );
|
||||
|
||||
if ( id ) {
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
$( 'table.widefat .pll-quick-translate-save .spinner' ).removeClass("is-active");
|
||||
} else {
|
||||
$( 'table.widefat .pll-quick-translate-save .spinner' ).hide();
|
||||
}
|
||||
|
||||
if ( 'pll-bulk-translate' == id ) {
|
||||
$( 'table.widefat #pll-bulk-translate ').removeClass( 'inline-translator' ).hide();
|
||||
$( '#pll-bulk-titles' ).html( '' );
|
||||
$( '#pll-inline-translate' ).append( $('#pll-bulk-translate') );
|
||||
} else {
|
||||
$( '#'+id ).remove();
|
||||
id = id.substr( id.lastIndexOf( '-' ) + 1 );
|
||||
$( this.what+id ).show();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}; // mlaPolylang.inlineTranslate
|
||||
|
||||
$( document ).ready( function() {
|
||||
mlaPolylang.inlineTranslate.init();
|
||||
});
|
||||
})( jQuery );
|
||||
1
wp-content/plugins/media-library-assistant/js/mla-polylang-support-scripts.min.js
vendored
Normal file
1
wp-content/plugins/media-library-assistant/js/mla-polylang-support-scripts.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,209 @@
|
||||
/* global ajaxurl, mla */
|
||||
|
||||
var jQuery;
|
||||
|
||||
/*
|
||||
* This script requires the global "mla" object to be defined and include the following:
|
||||
*
|
||||
* properties:
|
||||
* mla.settings.useDashicons
|
||||
* mla.settings.useSpinnerClass
|
||||
* mla.settings.ajaxDoneError
|
||||
* mla.settings.ajaxFailError
|
||||
*
|
||||
* components:
|
||||
* mla.setParent
|
||||
*/
|
||||
|
||||
( function( $ ) {
|
||||
/**
|
||||
* setParent displays a popup modal window with a post/page list
|
||||
* from which a new parent can be selected.
|
||||
* setParent.open is called from an "onclick" attribute in the submenu table links
|
||||
*/
|
||||
mla.setParent = {
|
||||
init: function() {
|
||||
// Send setParent selected parent
|
||||
$( '#mla-set-parent-submit' ).click( function( event ) {
|
||||
if ( ! $( '#mla-set-parent-response-div input[type="radio"]:checked' ).length )
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
// Send setParent parent keywords for filtering
|
||||
$( '#mla-set-parent-search' ).click( function () {
|
||||
$( '#mla-set-parent-paged' ).val( 1 );
|
||||
mla.setParent.send();
|
||||
});
|
||||
|
||||
$( '#mla-set-parent-search-div :input' ).keypress( function() {
|
||||
if ( 13 == event.which ) {
|
||||
mla.setParent.send();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Send post type(s) for filtering
|
||||
$( '#mla-set-parent-post-type' ).change( function () {
|
||||
$( '#mla-set-parent-paged' ).val( 1 );
|
||||
mla.setParent.send();
|
||||
});
|
||||
|
||||
// Pagination controls
|
||||
$( '#mla-set-parent-previous' ).click( function () {
|
||||
var paged = + $( '#mla-set-parent-paged' ).val();
|
||||
|
||||
if ( paged > 1 ) {
|
||||
$( '#mla-set-parent-paged' ).val( paged - 1 );
|
||||
} else {
|
||||
$( '#mla-set-parent-paged' ).val( 1 );
|
||||
}
|
||||
|
||||
mla.setParent.send();
|
||||
});
|
||||
|
||||
$( '#mla-set-parent-next' ).click( function () {
|
||||
var count = + $( '#mla-set-parent-count' ).val(),
|
||||
paged = + $( '#mla-set-parent-paged' ).val(),
|
||||
found = + $( '#mla-set-parent-found' ).val();
|
||||
|
||||
if ( found < count ) {
|
||||
$( '#mla-set-parent-paged' ).val( 1 );
|
||||
} else {
|
||||
$( '#mla-set-parent-paged' ).val( paged + 1 );
|
||||
}
|
||||
|
||||
mla.setParent.send();
|
||||
});
|
||||
|
||||
// Close the setParent pop-up
|
||||
$( '#mla-set-parent-close-div' ).click( mla.setParent.close );
|
||||
|
||||
$( '#mla-set-parent-cancel' ).click( function ( event ) {
|
||||
event.preventDefault();
|
||||
return mla.setParent.close();
|
||||
});
|
||||
|
||||
// Enable whole row to be clicked
|
||||
$( '#mla-set-parent-inside-div' ).on( 'click', 'tr', function() {
|
||||
$( this ).find( '.found-radio input' ).prop( 'checked', true );
|
||||
});
|
||||
},
|
||||
|
||||
open: function( affectedParent, affectedChild, affectedTitles ) {
|
||||
var overlay = $( '#mla-set-parent-overlay' );
|
||||
|
||||
if ( overlay.length === 0 ) {
|
||||
$( 'body' ).append( '<div id="mla-set-parent-overlay"></div>' );
|
||||
mla.setParent.overlay();
|
||||
}
|
||||
|
||||
overlay.show();
|
||||
|
||||
if ( affectedParent && affectedChild ) {
|
||||
$( '#mla-set-parent-parent' ).val( affectedParent );
|
||||
$( '#mla-set-parent-children' ).val( affectedChild );
|
||||
}
|
||||
|
||||
if ( affectedTitles ) {
|
||||
$( '#mla-set-parent-titles' ).html( affectedTitles );
|
||||
}
|
||||
|
||||
if ( mla.settings.useDashicons ) {
|
||||
$( '#mla-set-parent-close-div' ).addClass("mla-set-parent-close-div-dashicons");
|
||||
} else {
|
||||
$( '#mla-set-parent-close-div' ).html( 'x' );
|
||||
}
|
||||
|
||||
$( '#mla-set-parent-div' ).show();
|
||||
|
||||
$( '#mla-set-parent-input ' ).focus().keyup( function( event ){
|
||||
if ( event.which == 27 ) {
|
||||
mla.setParent.close();
|
||||
} // close on Escape
|
||||
});
|
||||
|
||||
// Pull some results up by default
|
||||
mla.setParent.send();
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
close: function() {
|
||||
$( '#mla-set-parent-input' ).val('');
|
||||
$( '#mla-set-parent-post-type' ).val('all');
|
||||
$( '#mla-set-parent-response-div' ).html('');
|
||||
$( '#mla-set-parent-div' ).hide();
|
||||
$( '#mla-set-parent-overlay' ).hide();
|
||||
},
|
||||
|
||||
overlay: function() {
|
||||
$( '#mla-set-parent-overlay' ).on( 'click', function () {
|
||||
mla.setParent.close();
|
||||
});
|
||||
},
|
||||
|
||||
send: function() {
|
||||
var post = {
|
||||
mla_set_parent_search_text: $( '#mla-set-parent-input' ).val(),
|
||||
mla_set_parent_post_type: $( '#mla-set-parent-post-type' ).val(),
|
||||
mla_set_parent_count: $( '#mla-set-parent-count' ).val(),
|
||||
mla_set_parent_paged: $( '#mla-set-parent-paged' ).val(),
|
||||
action: 'mla_find_posts',
|
||||
mla_admin_nonce: $('#mla-set-parent-ajax-nonce').val()
|
||||
},
|
||||
spinner = $( '#mla-set-parent-search-div .spinner' );
|
||||
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
spinner.addClass("is-active");
|
||||
} else {
|
||||
spinner.show();
|
||||
}
|
||||
|
||||
$.ajax( ajaxurl, {
|
||||
type: 'POST',
|
||||
data: post,
|
||||
dataType: 'json'
|
||||
}).always( function() {
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
spinner.removeClass("is-active");
|
||||
} else {
|
||||
spinner.hide();
|
||||
}
|
||||
}).done( function( response ) {
|
||||
var responseData = 'no response.data', id = 0;
|
||||
|
||||
if ( ! response.success ) {
|
||||
if ( response.responseData ) {
|
||||
responseData = response.data;
|
||||
}
|
||||
|
||||
$( '#mla-set-parent-response-div' ).text( mla.settings.ajaxDoneError + ' (' + responseData + ')' );
|
||||
} else {
|
||||
/*
|
||||
* Add the (Unattached) row, then the post/page list
|
||||
*/
|
||||
$( '#mla-set-parent-response-div' ).html( response.data );
|
||||
$( '#mla-set-parent-response-div table tbody tr:eq(0)' ).before( $( '#found-0-row' ).clone() );
|
||||
|
||||
/*
|
||||
* See if we can "check" the current parent
|
||||
*/
|
||||
id = $( '#mla-set-parent-parent' ).val();
|
||||
$( '#mla-set-parent-response-div #found-' + id ).each(function(){
|
||||
$( this ).prop( 'checked', true );
|
||||
});
|
||||
}
|
||||
}).fail( function( jqXHR, status ) {
|
||||
if ( 200 == jqXHR.status ) {
|
||||
$( '#mla-set-parent-response-div' ).text( '(' + status + ') ' + jqXHR.responseText );
|
||||
} else {
|
||||
$( '#mla-set-parent-response-div' ).text( mla.settings.ajaxFailError + ' (' + status + '), jqXHR( ' + jqXHR.status + ', ' + jqXHR.statusText + ', ' + jqXHR.responseText + ')' );
|
||||
}
|
||||
});
|
||||
}
|
||||
}; // mla.setParent
|
||||
|
||||
$( document ).ready( function() {
|
||||
mla.setParent.init();
|
||||
});
|
||||
})( jQuery );
|
||||
1
wp-content/plugins/media-library-assistant/js/mla-set-parent-scripts.min.js
vendored
Normal file
1
wp-content/plugins/media-library-assistant/js/mla-set-parent-scripts.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var jQuery;(function(a){mla.setParent={init:function(){a("#mla-set-parent-submit").click(function(b){if(!a('#mla-set-parent-response-div input[type="radio"]:checked').length){b.preventDefault()}});a("#mla-set-parent-search").click(function(){a("#mla-set-parent-paged").val(1);mla.setParent.send()});a("#mla-set-parent-search-div :input").keypress(function(){if(13==event.which){mla.setParent.send();return false}});a("#mla-set-parent-post-type").change(function(){a("#mla-set-parent-paged").val(1);mla.setParent.send()});a("#mla-set-parent-previous").click(function(){var b=+a("#mla-set-parent-paged").val();if(b>1){a("#mla-set-parent-paged").val(b-1)}else{a("#mla-set-parent-paged").val(1)}mla.setParent.send()});a("#mla-set-parent-next").click(function(){var c=+a("#mla-set-parent-count").val(),b=+a("#mla-set-parent-paged").val(),d=+a("#mla-set-parent-found").val();if(d<c){a("#mla-set-parent-paged").val(1)}else{a("#mla-set-parent-paged").val(b+1)}mla.setParent.send()});a("#mla-set-parent-close-div").click(mla.setParent.close);a("#mla-set-parent-cancel").click(function(b){b.preventDefault();return mla.setParent.close()});a("#mla-set-parent-inside-div").on("click","tr",function(){a(this).find(".found-radio input").prop("checked",true)})},open:function(e,d,b){var c=a("#mla-set-parent-overlay");if(c.length===0){a("body").append('<div id="mla-set-parent-overlay"></div>');mla.setParent.overlay()}c.show();if(e&&d){a("#mla-set-parent-parent").val(e);a("#mla-set-parent-children").val(d)}if(b){a("#mla-set-parent-titles").html(b)}if(mla.settings.useDashicons){a("#mla-set-parent-close-div").addClass("mla-set-parent-close-div-dashicons")}else{a("#mla-set-parent-close-div").html("x")}a("#mla-set-parent-div").show();a("#mla-set-parent-input ").focus().keyup(function(f){if(f.which==27){mla.setParent.close()}});mla.setParent.send();return false},close:function(){a("#mla-set-parent-input").val("");a("#mla-set-parent-post-type").val("all");a("#mla-set-parent-response-div").html("");a("#mla-set-parent-div").hide();a("#mla-set-parent-overlay").hide()},overlay:function(){a("#mla-set-parent-overlay").on("click",function(){mla.setParent.close()})},send:function(){var b={mla_set_parent_search_text:a("#mla-set-parent-input").val(),mla_set_parent_post_type:a("#mla-set-parent-post-type").val(),mla_set_parent_count:a("#mla-set-parent-count").val(),mla_set_parent_paged:a("#mla-set-parent-paged").val(),action:"mla_find_posts",mla_admin_nonce:a("#mla-set-parent-ajax-nonce").val()},c=a("#mla-set-parent-search-div .spinner");if(mla.settings.useSpinnerClass){c.addClass("is-active")}else{c.show()}a.ajax(ajaxurl,{type:"POST",data:b,dataType:"json"}).always(function(){if(mla.settings.useSpinnerClass){c.removeClass("is-active")}else{c.hide()}}).done(function(d){var e="no response.data",f=0;if(!d.success){if(d.responseData){e=d.data}a("#mla-set-parent-response-div").text(mla.settings.ajaxDoneError+" ("+e+")")}else{a("#mla-set-parent-response-div").html(d.data);a("#mla-set-parent-response-div table tbody tr:eq(0)").before(a("#found-0-row").clone());f=a("#mla-set-parent-parent").val();a("#mla-set-parent-response-div #found-"+f).each(function(){a(this).prop("checked",true)})}}).fail(function(e,d){if(200==e.status){a("#mla-set-parent-response-div").text("("+d+") "+e.responseText)}else{a("#mla-set-parent-response-div").text(mla.settings.ajaxFailError+" ("+d+"), jqXHR( "+e.status+", "+e.statusText+", "+e.responseText+")")}})}};a(document).ready(function(){mla.setParent.init()})})(jQuery);
|
||||
@@ -0,0 +1,83 @@
|
||||
var jQuery,
|
||||
mla_shortcodes_tab_vars,
|
||||
mlaShortcodes = {
|
||||
// Properties
|
||||
// mlaShortcodes.settings.definitions
|
||||
// mlaShortcodes.settings.sectionText
|
||||
settings: {},
|
||||
|
||||
// Utility functions
|
||||
utility: {
|
||||
getId : function( o ) {
|
||||
var id = jQuery( o ).closest( 'tr' ).attr( 'id' ),
|
||||
parts = id.split( '-' );
|
||||
return parts[ parts.length - 1 ];
|
||||
}
|
||||
},
|
||||
|
||||
// Components
|
||||
addTemplate: null
|
||||
};
|
||||
|
||||
( function( $ ) {
|
||||
// Localized settings and strings
|
||||
mlaShortcodes.settings = typeof mla_shortcodes_tab_vars === 'undefined' ? {} : mla_shortcodes_tab_vars;
|
||||
mla_shortcodes_tab_vars = void 0; // delete won't work on Globals
|
||||
mlaShortcodes.settings.sectionText = [];
|
||||
|
||||
mlaShortcodes.addTemplate = {
|
||||
init : function(){
|
||||
var t = this, templateForm = $( '#mla-edit-template' );
|
||||
|
||||
$( '#mla-template-type, #mla-template-shortcode', templateForm ).change( function( e ){
|
||||
var type = $( '#mla-template-type', templateForm ).val(),
|
||||
shortcode = $( '#mla-template-shortcode', templateForm ).val();
|
||||
|
||||
e.preventDefault();
|
||||
t.fillSections( type, shortcode, templateForm );
|
||||
});
|
||||
},
|
||||
|
||||
fillSections : function( type, shortcode, templateForm ){
|
||||
var oldType = $( '#mla-template-item-type', templateForm ).val(),
|
||||
oldShortcode = $( '#mla-template-item-shortcode', templateForm ).val(),
|
||||
oldClass = '.mla_section.mla_' + oldType + '.mla_' + oldShortcode;
|
||||
newClass = '.mla_section.mla_' + type + '.mla_' + shortcode;
|
||||
|
||||
$( '#mla-template-item-type', templateForm ).val( type ),
|
||||
$( '#mla-template-item-shortcode', templateForm ).val( shortcode ),
|
||||
|
||||
// Remove old sections, saving their values for reuse
|
||||
$( oldClass, templateForm ).each( function( index ) {
|
||||
var id = $('textarea', this).attr('id'), value = $('textarea', this).val(),
|
||||
prefix = 'mla-template-' + oldType + '-' + oldShortcode + '-',
|
||||
slug = id.substring( prefix.length );
|
||||
|
||||
mlaShortcodes.settings.sectionText[ slug ] = value;
|
||||
}); // oldClass.each
|
||||
|
||||
$( '.mla_section', templateForm ).hide();
|
||||
|
||||
if ( type == 'any' || shortcode == 'any' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Fill section rows, with any saved values
|
||||
$( newClass, templateForm ).each( function( index ) {
|
||||
var id = $('textarea', this).attr('id'),
|
||||
prefix = 'mla-template-' + type + '-' + shortcode + '-',
|
||||
slug = id.substring( prefix.length );
|
||||
|
||||
if ( typeof mlaShortcodes.settings.sectionText[ slug ] !== 'undefined' ) {
|
||||
$('textarea', this).val( mlaShortcodes.settings.sectionText[ slug ] );
|
||||
}
|
||||
}); // newClass.each
|
||||
|
||||
$( newClass, templateForm ).show();
|
||||
},
|
||||
}; // mlaShortcodes.addTemplate
|
||||
|
||||
$( document ).ready( function() {
|
||||
mlaShortcodes.addTemplate.init();
|
||||
});
|
||||
})( jQuery );
|
||||
1
wp-content/plugins/media-library-assistant/js/mla-settings-shortcodes-tab-scripts.min.js
vendored
Normal file
1
wp-content/plugins/media-library-assistant/js/mla-settings-shortcodes-tab-scripts.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var jQuery,mla_shortcodes_tab_vars,mlaShortcodes={settings:{},utility:{getId:function(b){var c=jQuery(b).closest("tr").attr("id"),a=c.split("-");return a[a.length-1]}},addTemplate:null};(function(a){mlaShortcodes.settings=typeof mla_shortcodes_tab_vars==="undefined"?{}:mla_shortcodes_tab_vars;mla_shortcodes_tab_vars=void 0;mlaShortcodes.settings.sectionText=[];mlaShortcodes.addTemplate={init:function(){var c=this,b=a("#mla-edit-template");a("#mla-template-type, #mla-template-shortcode",b).change(function(g){var d=a("#mla-template-type",b).val(),f=a("#mla-template-shortcode",b).val();g.preventDefault();c.fillSections(d,f,b)})},fillSections:function(e,f,d){var g=a("#mla-template-item-type",d).val(),b=a("#mla-template-item-shortcode",d).val(),c=".mla_section.mla_"+g+".mla_"+b;newClass=".mla_section.mla_"+e+".mla_"+f;a("#mla-template-item-type",d).val(e),a("#mla-template-item-shortcode",d).val(f),a(c,d).each(function(i){var l=a("textarea",this).attr("id"),k=a("textarea",this).val(),j="mla-template-"+g+"-"+b+"-",h=l.substring(j.length);mlaShortcodes.settings.sectionText[h]=k});a(".mla_section",d).hide();if(e=="any"||f=="any"){return}a(newClass,d).each(function(i){var k=a("textarea",this).attr("id"),j="mla-template-"+e+"-"+f+"-",h=k.substring(j.length);if(typeof mlaShortcodes.settings.sectionText[h]!=="undefined"){a("textarea",this).val(mlaShortcodes.settings.sectionText[h])}});a(newClass,d).show()}};a(document).ready(function(){mlaShortcodes.addTemplate.init()})})(jQuery);
|
||||
@@ -0,0 +1,169 @@
|
||||
/* global ajaxurl */
|
||||
|
||||
/*
|
||||
* This script requires the global "mla" object to be defined and include the following:
|
||||
*
|
||||
* properties:
|
||||
* mla.settings.useSpinnerClass
|
||||
*/
|
||||
|
||||
var jQuery, wpAjax, ajaxurl,
|
||||
mla_terms_search_vars,
|
||||
mlaTaxonomy = {
|
||||
// Properties
|
||||
settings: {},
|
||||
|
||||
// Utility functions
|
||||
utility: {
|
||||
},
|
||||
|
||||
// Components
|
||||
termsSearch: null
|
||||
};
|
||||
|
||||
( function( $ ) {
|
||||
/**
|
||||
* Localized settings and strings
|
||||
*/
|
||||
mlaTaxonomy.settings = typeof mla_terms_search_vars === 'undefined' ? {} : mla_terms_search_vars;
|
||||
mla_terms_search_vars = void 0; // delete won't work on Globals
|
||||
|
||||
/**
|
||||
* termsSearch displays a popup modal window with text box, options and taxonomy list.
|
||||
* termsSearch.open is called from an "onclick" attribute in the Media/Assistant submenu table.
|
||||
*/
|
||||
mlaTaxonomy.termsSearch = {
|
||||
init: function() {
|
||||
// Suppress form "submit" action for the "Terms Search" button
|
||||
$( '#mla-terms-search-open' ).click( function( event ) {
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
$( '#mla-terms-search-submit' ).click( function() {
|
||||
mlaTaxonomy.termsSearch.close();
|
||||
});
|
||||
|
||||
// Close the termsSearch pop-up
|
||||
$( '#mla-terms-search-close-div' ).click( mlaTaxonomy.termsSearch.close );
|
||||
|
||||
},
|
||||
|
||||
open: function() {
|
||||
var overlay = $( '#mla-terms-search-overlay' );
|
||||
|
||||
if ( overlay.length === 0 ) {
|
||||
$( 'body' ).append( '<div id="mla-terms-search-overlay"></div>' );
|
||||
mlaTaxonomy.termsSearch.overlay();
|
||||
}
|
||||
|
||||
overlay.show();
|
||||
|
||||
if ( mlaTaxonomy.settings.useDashicons ) {
|
||||
$( '#mla-terms-search-close-div' ).addClass("mla-terms-search-close-div-dashicons");
|
||||
} else {
|
||||
$( '#mla-terms-search-close-div' ).html( 'x' );
|
||||
}
|
||||
/* if ( ! mlaTaxonomy.settings.useDashicons ) {
|
||||
$( '#mla-terms-search-close-div' ).html( 'x' );
|
||||
} */
|
||||
|
||||
$( '#mla-terms-search-div' ).show();
|
||||
|
||||
$( '#mla-terms-search-input ' ).focus().keyup( function( event ){
|
||||
if ( event.which == 27 ) {
|
||||
mlaTaxonomy.termsSearch.close();
|
||||
} // close on Escape
|
||||
});
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
close: function() {
|
||||
$( '#mla-terms-search-response-div' ).html('');
|
||||
$( '#mla-terms-search-div' ).hide();
|
||||
$( '#mla-terms-search-overlay' ).hide();
|
||||
},
|
||||
|
||||
overlay: function() {
|
||||
$( '#mla-terms-search-overlay' ).on( 'click', function () {
|
||||
mlaTaxonomy.termsSearch.close();
|
||||
});
|
||||
},
|
||||
|
||||
send: function() {
|
||||
var post = {
|
||||
ps: $( '#mla-terms-search-input' ).val(),
|
||||
action: 'find_posts',
|
||||
_ajax_nonce: $('#mla-terms-search-ajax-nonce').val()
|
||||
},
|
||||
spinner = $( '#mla-terms-search-search-div .spinner' ),
|
||||
ajaxResponse = null;
|
||||
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
spinner.addClass("is-active");
|
||||
} else {
|
||||
spinner.show();
|
||||
}
|
||||
|
||||
$.ajax( ajaxurl, {
|
||||
type: 'POST',
|
||||
data: post,
|
||||
dataType: mlaTaxonomy.settings.termsSearchDataType
|
||||
}).always( function() {
|
||||
if ( mla.settings.useSpinnerClass ) {
|
||||
spinner.removeClass("is-active");
|
||||
} else {
|
||||
spinner.hide();
|
||||
}
|
||||
}).done( function( response ) {
|
||||
var responseData = 'no response.data', id = 0;
|
||||
|
||||
if ( 'xml' === mlaTaxonomy.settings.termsSearchDataType ) {
|
||||
if ( 'string' === typeof( response ) ) {
|
||||
response = { 'success': false, data: response };
|
||||
} else {
|
||||
ajaxResponse = wpAjax.parseAjaxResponse( response );
|
||||
|
||||
if ( ajaxResponse.errors ) {
|
||||
response = { 'success': false, data: wpAjax.broken };
|
||||
} else {
|
||||
response = { 'success': true, data: ajaxResponse.responses[0].data };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! response.success ) {
|
||||
if ( response.responseData ) {
|
||||
responseData = response.data;
|
||||
}
|
||||
|
||||
$( '#mla-terms-search-response-div' ).text( mlaTaxonomy.settings.ajaxDoneError + ' (' + responseData + ')' );
|
||||
} else {
|
||||
/*
|
||||
* Add the (Unattached) row, then the post/page list
|
||||
*/
|
||||
$( '#mla-terms-search-response-div' ).html( response.data );
|
||||
$( '#mla-terms-search-response-div table tbody tr:eq(0)' ).before( $( '#found-0-row' ).clone() );
|
||||
|
||||
/*
|
||||
* See if we can "check" the current parent
|
||||
*/
|
||||
id = $( '#mla-terms-search-parent' ).val();
|
||||
$( '#mla-terms-search-response-div #found-' + id ).each(function(){
|
||||
$( this ).prop( 'checked', true );
|
||||
});
|
||||
}
|
||||
}).fail( function( jqXHR, status ) {
|
||||
if ( 200 == jqXHR.status ) {
|
||||
$( '#mla-terms-search-response-div' ).text( '(' + status + ') ' + jqXHR.responseText );
|
||||
} else {
|
||||
$( '#mla-terms-search-response-div' ).text( mlaTaxonomy.settings.ajaxFailError + ' (' + status + '), jqXHR( ' + jqXHR.status + ', ' + jqXHR.statusText + ', ' + jqXHR.responseText + ')' );
|
||||
}
|
||||
});
|
||||
}
|
||||
}; // mlaTaxonomy.termsSearch
|
||||
|
||||
$( document ).ready( function() {
|
||||
mlaTaxonomy.termsSearch.init();
|
||||
});
|
||||
})( jQuery );
|
||||
1
wp-content/plugins/media-library-assistant/js/mla-terms-search-scripts.min.js
vendored
Normal file
1
wp-content/plugins/media-library-assistant/js/mla-terms-search-scripts.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var jQuery,wpAjax,ajaxurl,mla_terms_search_vars,mlaTaxonomy={settings:{},utility:{},termsSearch:null};(function(a){mlaTaxonomy.settings=typeof mla_terms_search_vars==="undefined"?{}:mla_terms_search_vars;mla_terms_search_vars=void 0;mlaTaxonomy.termsSearch={init:function(){a("#mla-terms-search-open").click(function(b){b.preventDefault()});a("#mla-terms-search-submit").click(function(){mlaTaxonomy.termsSearch.close()});a("#mla-terms-search-close-div").click(mlaTaxonomy.termsSearch.close)},open:function(){var b=a("#mla-terms-search-overlay");if(b.length===0){a("body").append('<div id="mla-terms-search-overlay"></div>');mlaTaxonomy.termsSearch.overlay()}b.show();if(mlaTaxonomy.settings.useDashicons){a("#mla-terms-search-close-div").addClass("mla-terms-search-close-div-dashicons")}else{a("#mla-terms-search-close-div").html("x")}a("#mla-terms-search-div").show();a("#mla-terms-search-input ").focus().keyup(function(c){if(c.which==27){mlaTaxonomy.termsSearch.close()}});return false},close:function(){a("#mla-terms-search-response-div").html("");a("#mla-terms-search-div").hide();a("#mla-terms-search-overlay").hide()},overlay:function(){a("#mla-terms-search-overlay").on("click",function(){mlaTaxonomy.termsSearch.close()})},send:function(){var b={ps:a("#mla-terms-search-input").val(),action:"find_posts",_ajax_nonce:a("#mla-terms-search-ajax-nonce").val()},d=a("#mla-terms-search-search-div .spinner"),c=null;if(mla.settings.useSpinnerClass){d.addClass("is-active")}else{d.show()}a.ajax(ajaxurl,{type:"POST",data:b,dataType:mlaTaxonomy.settings.termsSearchDataType}).always(function(){if(mla.settings.useSpinnerClass){d.removeClass("is-active")}else{d.hide()}}).done(function(e){var f="no response.data",g=0;if("xml"===mlaTaxonomy.settings.termsSearchDataType){if("string"===typeof(e)){e={success:false,data:e}}else{c=wpAjax.parseAjaxResponse(e);if(c.errors){e={success:false,data:wpAjax.broken}}else{e={success:true,data:c.responses[0].data}}}}if(!e.success){if(e.responseData){f=e.data}a("#mla-terms-search-response-div").text(mlaTaxonomy.settings.ajaxDoneError+" ("+f+")")}else{a("#mla-terms-search-response-div").html(e.data);a("#mla-terms-search-response-div table tbody tr:eq(0)").before(a("#found-0-row").clone());g=a("#mla-terms-search-parent").val();a("#mla-terms-search-response-div #found-"+g).each(function(){a(this).prop("checked",true)})}}).fail(function(f,e){if(200==f.status){a("#mla-terms-search-response-div").text("("+e+") "+f.responseText)}else{a("#mla-terms-search-response-div").text(mlaTaxonomy.settings.ajaxFailError+" ("+e+"), jqXHR( "+f.status+", "+f.statusText+", "+f.responseText+")")}})}};a(document).ready(function(){mlaTaxonomy.termsSearch.init()})})(jQuery);
|
||||
@@ -0,0 +1,131 @@
|
||||
/* global ajaxurl */
|
||||
|
||||
var jQuery,
|
||||
mla_thumbnail_support_vars,
|
||||
mlaThumbnail = {
|
||||
// Properties
|
||||
// mlaThumbnail.settings.error
|
||||
// mlaThumbnail.settings.ntdelTitle
|
||||
// mlaThumbnail.settings.noTitle
|
||||
// mlaThumbnail.settings.bulkTitle
|
||||
// mlaThumbnail.settings.comma
|
||||
// mlaThumbnail.settings.useSpinnerClass
|
||||
settings: {},
|
||||
|
||||
// Utility functions
|
||||
utility: {
|
||||
getId : function( o ) {
|
||||
var id = jQuery( o ).closest( 'tr' ).attr( 'id' ),
|
||||
parts = id.split( '-' );
|
||||
return parts[ parts.length - 1 ];
|
||||
}
|
||||
},
|
||||
|
||||
// Components
|
||||
inlineThumbnail: null
|
||||
};
|
||||
|
||||
( function( $ ) {
|
||||
/**
|
||||
* Localized settings and strings
|
||||
*/
|
||||
mlaThumbnail.settings = typeof mla_thumbnail_support_vars === 'undefined' ? {} : mla_thumbnail_support_vars;
|
||||
mla_thumbnail_support_vars = void 0; // delete won't work on Globals
|
||||
|
||||
mlaThumbnail.inlineThumbnail = {
|
||||
init : function(){
|
||||
var t = this, bgRow = $( '#mla-bulk-thumbnail' );
|
||||
|
||||
t.type = 'attachment';
|
||||
t.what = '#attachment-';
|
||||
|
||||
// prepare the bulk-generate row
|
||||
bgRow.keyup( function( e ){
|
||||
if ( e.which == 27 )
|
||||
return mlaThumbnail.inlineThumbnail.revert();
|
||||
});
|
||||
|
||||
$( 'a.cancel', bgRow ).click( function(){
|
||||
return mlaThumbnail.inlineThumbnail.revert();
|
||||
});
|
||||
|
||||
$( '#doaction, #doaction2' ).click( function( e ){
|
||||
var n = $( this ).attr( 'id' ).substr( 2 );
|
||||
|
||||
if ( $( 'select[name="'+n+'"]' ).val() == 'mla-generate-featured-image' ) {
|
||||
e.preventDefault();
|
||||
t.openBulkGenerate();
|
||||
}
|
||||
});
|
||||
|
||||
// Filter button (dates, categories) in top nav bar
|
||||
$( '#post-query-submit' ).mousedown( function(){
|
||||
t.revert();
|
||||
$( 'select[name^="action"]' ).val( '-1' );
|
||||
});
|
||||
},
|
||||
|
||||
openBulkGenerate : function(){
|
||||
var te = '', c = true;
|
||||
this.revert();
|
||||
|
||||
// Open up the Bulk Translate area
|
||||
$( '#mla-bulk-thumbnail td' ).attr( 'colspan', $( 'th:visible, td:visible', '.widefat:first thead' ).length );
|
||||
$( 'table.widefat tbody' ).prepend( $( '#mla-bulk-thumbnail' ) );
|
||||
$( '#mla-bulk-thumbnail' ).addClass( 'inline-translator' ).show();
|
||||
|
||||
// Make sure at least one item has been selected
|
||||
$( 'tbody th.check-column input[type="checkbox"]' ).each( function(){
|
||||
if ( $( this ).prop( 'checked' ) ) {
|
||||
c = false;
|
||||
var id = $( this ).val(), theTitle;
|
||||
theTitle = $( '#inline_'+id+' .post_title' ).text() || mlaThumbnail.settings.noTitle;
|
||||
te += '<div id="ttle'+id+'"><a id="_'+id+'" class="ntdelbutton" title="'+mlaThumbnail.settings.ntdelTitle+'">X</a>'+theTitle+'</div>';
|
||||
}
|
||||
});
|
||||
|
||||
if ( c ) {
|
||||
return this.revert();
|
||||
}
|
||||
|
||||
// Populate the list of selected items
|
||||
$( '#mla-thumbnail-titles' ).html( te );
|
||||
$( '#mla-thumbnail-titles a' ).click(function(){
|
||||
var id = $( this ).attr( 'id' ).substr( 1 );
|
||||
|
||||
$( 'table.widefat input[value="' + id + '"]' ).prop( 'checked', false );
|
||||
$( '#ttle'+id ).remove();
|
||||
});
|
||||
|
||||
$( 'html, body' ).animate( { scrollTop: 0 }, 'fast' );
|
||||
},
|
||||
|
||||
revert : function(){
|
||||
var id = $( 'table.widefat tr.inline-translator ').attr( 'id' );
|
||||
|
||||
if ( id ) {
|
||||
if ( mlaThumbnail.settings.useSpinnerClass ) {
|
||||
$( 'table.widefat .pll-quick-translate-save .spinner' ).removeClass("is-active");
|
||||
} else {
|
||||
$( 'table.widefat .pll-quick-translate-save .spinner' ).hide();
|
||||
}
|
||||
|
||||
if ( 'mla-bulk-thumbnail' == id ) {
|
||||
$( 'table.widefat #mla-bulk-thumbnail ').removeClass( 'inline-translator' ).hide();
|
||||
$( '#mla-thumbnail-titles' ).html( '' );
|
||||
$( '#pll-inline-translate' ).append( $('#mla-bulk-thumbnail') );
|
||||
} else {
|
||||
$( '#'+id ).remove();
|
||||
id = id.substr( id.lastIndexOf( '-' ) + 1 );
|
||||
$( this.what+id ).show();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}; // mlaThumbnail.inlineThumbnail
|
||||
|
||||
$( document ).ready( function() {
|
||||
mlaThumbnail.inlineThumbnail.init();
|
||||
});
|
||||
})( jQuery );
|
||||
1
wp-content/plugins/media-library-assistant/js/mla-thumbnail-generation-scripts.min.js
vendored
Normal file
1
wp-content/plugins/media-library-assistant/js/mla-thumbnail-generation-scripts.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var jQuery,mla_thumbnail_support_vars,mlaThumbnail={settings:{},utility:{getId:function(b){var c=jQuery(b).closest("tr").attr("id"),a=c.split("-");return a[a.length-1]}},inlineThumbnail:null};(function(a){mlaThumbnail.settings=typeof mla_thumbnail_support_vars==="undefined"?{}:mla_thumbnail_support_vars;mla_thumbnail_support_vars=void 0;mlaThumbnail.inlineThumbnail={init:function(){var b=this,c=a("#mla-bulk-thumbnail");b.type="attachment";b.what="#attachment-";c.keyup(function(d){if(d.which==27){return mlaThumbnail.inlineThumbnail.revert()}});a("a.cancel",c).click(function(){return mlaThumbnail.inlineThumbnail.revert()});a("#doaction, #doaction2").click(function(d){var f=a(this).attr("id").substr(2);if(a('select[name="'+f+'"]').val()=="mla-generate-featured-image"){d.preventDefault();b.openBulkGenerate()}});a("#post-query-submit").mousedown(function(){b.revert();a('select[name^="action"]').val("-1")})},openBulkGenerate:function(){var b="",d=true;this.revert();a("#mla-bulk-thumbnail td").attr("colspan",a("th:visible, td:visible",".widefat:first thead").length);a("table.widefat tbody").prepend(a("#mla-bulk-thumbnail"));a("#mla-bulk-thumbnail").addClass("inline-translator").show();a('tbody th.check-column input[type="checkbox"]').each(function(){if(a(this).prop("checked")){d=false;var e=a(this).val(),c;c=a("#inline_"+e+" .post_title").text()||mlaThumbnail.settings.noTitle;b+='<div id="ttle'+e+'"><a id="_'+e+'" class="ntdelbutton" title="'+mlaThumbnail.settings.ntdelTitle+'">X</a>'+c+"</div>"}});if(d){return this.revert()}a("#mla-thumbnail-titles").html(b);a("#mla-thumbnail-titles a").click(function(){var c=a(this).attr("id").substr(1);a('table.widefat input[value="'+c+'"]').prop("checked",false);a("#ttle"+c).remove()});a("html, body").animate({scrollTop:0},"fast")},revert:function(){var b=a("table.widefat tr.inline-translator ").attr("id");if(b){if(mlaThumbnail.settings.useSpinnerClass){a("table.widefat .pll-quick-translate-save .spinner").removeClass("is-active")}else{a("table.widefat .pll-quick-translate-save .spinner").hide()}if("mla-bulk-thumbnail"==b){a("table.widefat #mla-bulk-thumbnail ").removeClass("inline-translator").hide();a("#mla-thumbnail-titles").html("");a("#pll-inline-translate").append(a("#mla-bulk-thumbnail"))}else{a("#"+b).remove();b=b.substr(b.lastIndexOf("-")+1);a(this.what+b).show()}}return false}};a(document).ready(function(){mlaThumbnail.inlineThumbnail.init()})})(jQuery);
|
||||
Reference in New Issue
Block a user