080600
This commit is contained in:
@@ -1,464 +1,464 @@
|
||||
/**
|
||||
* @output wp-includes/js/admin-bar.js
|
||||
*/
|
||||
/**
|
||||
* Admin bar with Vanilla JS, no external dependencies.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*
|
||||
* @param {Object} document The document object.
|
||||
* @param {Object} window The window object.
|
||||
* @param {Object} navigator The navigator object.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
( function( document, window, navigator ) {
|
||||
document.addEventListener( 'DOMContentLoaded', function() {
|
||||
var adminBar = document.getElementById( 'wpadminbar' ),
|
||||
topMenuItems,
|
||||
allMenuItems,
|
||||
adminBarLogout,
|
||||
adminBarSearchForm,
|
||||
shortlink,
|
||||
skipLink,
|
||||
mobileEvent,
|
||||
adminBarSearchInput,
|
||||
i;
|
||||
|
||||
if ( ! adminBar || ! ( 'querySelectorAll' in adminBar ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
topMenuItems = adminBar.querySelectorAll( 'li.menupop' );
|
||||
allMenuItems = adminBar.querySelectorAll( '.ab-item' );
|
||||
adminBarLogout = document.querySelector( '#wp-admin-bar-logout a' );
|
||||
adminBarSearchForm = document.getElementById( 'adminbarsearch' );
|
||||
shortlink = document.getElementById( 'wp-admin-bar-get-shortlink' );
|
||||
skipLink = adminBar.querySelector( '.screen-reader-shortcut' );
|
||||
mobileEvent = /Mobile\/.+Safari/.test( navigator.userAgent ) ? 'touchstart' : 'click';
|
||||
|
||||
// Remove nojs class after the DOM is loaded.
|
||||
removeClass( adminBar, 'nojs' );
|
||||
|
||||
if ( 'ontouchstart' in window ) {
|
||||
// Remove hover class when the user touches outside the menu items.
|
||||
document.body.addEventListener( mobileEvent, function( e ) {
|
||||
if ( ! getClosest( e.target, 'li.menupop' ) ) {
|
||||
removeAllHoverClass( topMenuItems );
|
||||
}
|
||||
} );
|
||||
|
||||
// Add listener for menu items to toggle hover class by touches.
|
||||
// Remove the callback later for better performance.
|
||||
adminBar.addEventListener( 'touchstart', function bindMobileEvents() {
|
||||
for ( var i = 0; i < topMenuItems.length; i++ ) {
|
||||
topMenuItems[i].addEventListener( 'click', mobileHover.bind( null, topMenuItems ) );
|
||||
}
|
||||
|
||||
adminBar.removeEventListener( 'touchstart', bindMobileEvents );
|
||||
} );
|
||||
}
|
||||
|
||||
// Scroll page to top when clicking on the admin bar.
|
||||
adminBar.addEventListener( 'click', scrollToTop );
|
||||
|
||||
for ( i = 0; i < topMenuItems.length; i++ ) {
|
||||
// Adds or removes the hover class based on the hover intent.
|
||||
window.hoverintent(
|
||||
topMenuItems[i],
|
||||
addClass.bind( null, topMenuItems[i], 'hover' ),
|
||||
removeClass.bind( null, topMenuItems[i], 'hover' )
|
||||
).options( {
|
||||
timeout: 180
|
||||
} );
|
||||
|
||||
// Toggle hover class if the enter key is pressed.
|
||||
topMenuItems[i].addEventListener( 'keydown', toggleHoverIfEnter );
|
||||
}
|
||||
|
||||
// Remove hover class if the escape key is pressed.
|
||||
for ( i = 0; i < allMenuItems.length; i++ ) {
|
||||
allMenuItems[i].addEventListener( 'keydown', removeHoverIfEscape );
|
||||
}
|
||||
|
||||
if ( adminBarSearchForm ) {
|
||||
adminBarSearchInput = document.getElementById( 'adminbar-search' );
|
||||
|
||||
// Adds the adminbar-focused class on focus.
|
||||
adminBarSearchInput.addEventListener( 'focus', function() {
|
||||
addClass( adminBarSearchForm, 'adminbar-focused' );
|
||||
} );
|
||||
|
||||
// Removes the adminbar-focused class on blur.
|
||||
adminBarSearchInput.addEventListener( 'blur', function() {
|
||||
removeClass( adminBarSearchForm, 'adminbar-focused' );
|
||||
} );
|
||||
}
|
||||
|
||||
if ( skipLink ) {
|
||||
// Focus the target of skip link after pressing Enter.
|
||||
skipLink.addEventListener( 'keydown', focusTargetAfterEnter );
|
||||
}
|
||||
|
||||
if ( shortlink ) {
|
||||
shortlink.addEventListener( 'click', clickShortlink );
|
||||
}
|
||||
|
||||
// Prevents the toolbar from covering up content when a hash is present in the URL.
|
||||
if ( window.location.hash ) {
|
||||
window.scrollBy( 0, -32 );
|
||||
}
|
||||
|
||||
// Clear sessionStorage on logging out.
|
||||
if ( adminBarLogout ) {
|
||||
adminBarLogout.addEventListener( 'click', emptySessionStorage );
|
||||
}
|
||||
} );
|
||||
|
||||
/**
|
||||
* Remove hover class for top level menu item when escape is pressed.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*
|
||||
* @param {Event} event The keydown event.
|
||||
*/
|
||||
function removeHoverIfEscape( event ) {
|
||||
var wrapper;
|
||||
|
||||
if ( event.which !== 27 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper = getClosest( event.target, '.menupop' );
|
||||
|
||||
if ( ! wrapper ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper.querySelector( '.menupop > .ab-item' ).focus();
|
||||
removeClass( wrapper, 'hover' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle hover class for top level menu item when enter is pressed.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*
|
||||
* @param {Event} event The keydown event.
|
||||
*/
|
||||
function toggleHoverIfEnter( event ) {
|
||||
var wrapper;
|
||||
|
||||
// Follow link if pressing Ctrl and/or Shift with Enter (opening in a new tab or window).
|
||||
if ( event.which !== 13 || event.ctrlKey || event.shiftKey ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !! getClosest( event.target, '.ab-sub-wrapper' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper = getClosest( event.target, '.menupop' );
|
||||
|
||||
if ( ! wrapper ) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
if ( hasClass( wrapper, 'hover' ) ) {
|
||||
removeClass( wrapper, 'hover' );
|
||||
} else {
|
||||
addClass( wrapper, 'hover' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Focus the target of skip link after pressing Enter.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*
|
||||
* @param {Event} event The keydown event.
|
||||
*/
|
||||
function focusTargetAfterEnter( event ) {
|
||||
var id, userAgent;
|
||||
|
||||
if ( event.which !== 13 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
id = event.target.getAttribute( 'href' );
|
||||
userAgent = navigator.userAgent.toLowerCase();
|
||||
|
||||
if ( userAgent.indexOf( 'applewebkit' ) > -1 && id && id.charAt( 0 ) === '#' ) {
|
||||
setTimeout( function() {
|
||||
var target = document.getElementById( id.replace( '#', '' ) );
|
||||
|
||||
if ( target ) {
|
||||
target.setAttribute( 'tabIndex', '0' );
|
||||
target.focus();
|
||||
}
|
||||
}, 100 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toogle hover class for mobile devices.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*
|
||||
* @param {NodeList} topMenuItems All menu items.
|
||||
* @param {Event} event The click event.
|
||||
*/
|
||||
function mobileHover( topMenuItems, event ) {
|
||||
var wrapper;
|
||||
|
||||
if ( !! getClosest( event.target, '.ab-sub-wrapper' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
wrapper = getClosest( event.target, '.menupop' );
|
||||
|
||||
if ( ! wrapper ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( hasClass( wrapper, 'hover' ) ) {
|
||||
removeClass( wrapper, 'hover' );
|
||||
} else {
|
||||
removeAllHoverClass( topMenuItems );
|
||||
addClass( wrapper, 'hover' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the click on the Shortlink link in the adminbar.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @since 5.3.1 Use querySelector to clean up the function.
|
||||
*
|
||||
* @param {Event} event The click event.
|
||||
* @return {boolean} Returns false to prevent default click behavior.
|
||||
*/
|
||||
function clickShortlink( event ) {
|
||||
var wrapper = event.target.parentNode,
|
||||
input;
|
||||
|
||||
if ( wrapper ) {
|
||||
input = wrapper.querySelector( '.shortlink-input' );
|
||||
}
|
||||
|
||||
if ( ! input ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// (Old) IE doesn't support preventDefault, and does support returnValue.
|
||||
if ( event.preventDefault ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
event.returnValue = false;
|
||||
|
||||
addClass( wrapper, 'selected' );
|
||||
|
||||
input.focus();
|
||||
input.select();
|
||||
input.onblur = function() {
|
||||
removeClass( wrapper, 'selected' );
|
||||
};
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear sessionStorage on logging out.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*/
|
||||
function emptySessionStorage() {
|
||||
if ( 'sessionStorage' in window ) {
|
||||
try {
|
||||
for ( var key in sessionStorage ) {
|
||||
if ( key.indexOf( 'wp-autosave-' ) > -1 ) {
|
||||
sessionStorage.removeItem( key );
|
||||
}
|
||||
}
|
||||
} catch ( er ) {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if element has class.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*
|
||||
* @param {HTMLElement} element The HTML element.
|
||||
* @param {string} className The class name.
|
||||
* @return {boolean} Whether the element has the className.
|
||||
*/
|
||||
function hasClass( element, className ) {
|
||||
var classNames;
|
||||
|
||||
if ( ! element ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( element.classList && element.classList.contains ) {
|
||||
return element.classList.contains( className );
|
||||
} else if ( element.className ) {
|
||||
classNames = element.className.split( ' ' );
|
||||
return classNames.indexOf( className ) > -1;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add class to an element.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*
|
||||
* @param {HTMLElement} element The HTML element.
|
||||
* @param {string} className The class name.
|
||||
*/
|
||||
function addClass( element, className ) {
|
||||
if ( ! element ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( element.classList && element.classList.add ) {
|
||||
element.classList.add( className );
|
||||
} else if ( ! hasClass( element, className ) ) {
|
||||
if ( element.className ) {
|
||||
element.className += ' ';
|
||||
}
|
||||
|
||||
element.className += className;
|
||||
}
|
||||
|
||||
var menuItemToggle = element.querySelector( 'a' );
|
||||
if ( className === 'hover' && menuItemToggle && menuItemToggle.hasAttribute( 'aria-expanded' ) ) {
|
||||
menuItemToggle.setAttribute( 'aria-expanded', 'true' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove class from an element.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*
|
||||
* @param {HTMLElement} element The HTML element.
|
||||
* @param {string} className The class name.
|
||||
*/
|
||||
function removeClass( element, className ) {
|
||||
var testName,
|
||||
classes;
|
||||
|
||||
if ( ! element || ! hasClass( element, className ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( element.classList && element.classList.remove ) {
|
||||
element.classList.remove( className );
|
||||
} else {
|
||||
testName = ' ' + className + ' ';
|
||||
classes = ' ' + element.className + ' ';
|
||||
|
||||
while ( classes.indexOf( testName ) > -1 ) {
|
||||
classes = classes.replace( testName, '' );
|
||||
}
|
||||
|
||||
element.className = classes.replace( /^[\s]+|[\s]+$/g, '' );
|
||||
}
|
||||
|
||||
var menuItemToggle = element.querySelector( 'a' );
|
||||
if ( className === 'hover' && menuItemToggle && menuItemToggle.hasAttribute( 'aria-expanded' ) ) {
|
||||
menuItemToggle.setAttribute( 'aria-expanded', 'false' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove hover class for all menu items.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*
|
||||
* @param {NodeList} topMenuItems All menu items.
|
||||
*/
|
||||
function removeAllHoverClass( topMenuItems ) {
|
||||
if ( topMenuItems && topMenuItems.length ) {
|
||||
for ( var i = 0; i < topMenuItems.length; i++ ) {
|
||||
removeClass( topMenuItems[i], 'hover' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolls to the top of the page.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {Event} event The Click event.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
function scrollToTop( event ) {
|
||||
// Only scroll when clicking on the wpadminbar, not on menus or submenus.
|
||||
if (
|
||||
event.target &&
|
||||
event.target.id !== 'wpadminbar' &&
|
||||
event.target.id !== 'wp-admin-bar-top-secondary'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
window.scrollTo( {
|
||||
top: -32,
|
||||
left: 0,
|
||||
behavior: 'smooth'
|
||||
} );
|
||||
} catch ( er ) {
|
||||
window.scrollTo( 0, -32 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get closest Element.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*
|
||||
* @param {HTMLElement} el Element to get parent.
|
||||
* @param {string} selector CSS selector to match.
|
||||
*/
|
||||
function getClosest( el, selector ) {
|
||||
if ( ! window.Element.prototype.matches ) {
|
||||
// Polyfill from https://developer.mozilla.org/en-US/docs/Web/API/Element/matches.
|
||||
window.Element.prototype.matches =
|
||||
window.Element.prototype.matchesSelector ||
|
||||
window.Element.prototype.mozMatchesSelector ||
|
||||
window.Element.prototype.msMatchesSelector ||
|
||||
window.Element.prototype.oMatchesSelector ||
|
||||
window.Element.prototype.webkitMatchesSelector ||
|
||||
function( s ) {
|
||||
var matches = ( this.document || this.ownerDocument ).querySelectorAll( s ),
|
||||
i = matches.length;
|
||||
|
||||
while ( --i >= 0 && matches.item( i ) !== this ) { }
|
||||
|
||||
return i > -1;
|
||||
};
|
||||
}
|
||||
|
||||
// Get the closest matching elent.
|
||||
for ( ; el && el !== document; el = el.parentNode ) {
|
||||
if ( el.matches( selector ) ) {
|
||||
return el;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
} )( document, window, navigator );
|
||||
/**
|
||||
* @output wp-includes/js/admin-bar.js
|
||||
*/
|
||||
/**
|
||||
* Admin bar with Vanilla JS, no external dependencies.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*
|
||||
* @param {Object} document The document object.
|
||||
* @param {Object} window The window object.
|
||||
* @param {Object} navigator The navigator object.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
( function( document, window, navigator ) {
|
||||
document.addEventListener( 'DOMContentLoaded', function() {
|
||||
var adminBar = document.getElementById( 'wpadminbar' ),
|
||||
topMenuItems,
|
||||
allMenuItems,
|
||||
adminBarLogout,
|
||||
adminBarSearchForm,
|
||||
shortlink,
|
||||
skipLink,
|
||||
mobileEvent,
|
||||
adminBarSearchInput,
|
||||
i;
|
||||
|
||||
if ( ! adminBar || ! ( 'querySelectorAll' in adminBar ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
topMenuItems = adminBar.querySelectorAll( 'li.menupop' );
|
||||
allMenuItems = adminBar.querySelectorAll( '.ab-item' );
|
||||
adminBarLogout = document.querySelector( '#wp-admin-bar-logout a' );
|
||||
adminBarSearchForm = document.getElementById( 'adminbarsearch' );
|
||||
shortlink = document.getElementById( 'wp-admin-bar-get-shortlink' );
|
||||
skipLink = adminBar.querySelector( '.screen-reader-shortcut' );
|
||||
mobileEvent = /Mobile\/.+Safari/.test( navigator.userAgent ) ? 'touchstart' : 'click';
|
||||
|
||||
// Remove nojs class after the DOM is loaded.
|
||||
removeClass( adminBar, 'nojs' );
|
||||
|
||||
if ( 'ontouchstart' in window ) {
|
||||
// Remove hover class when the user touches outside the menu items.
|
||||
document.body.addEventListener( mobileEvent, function( e ) {
|
||||
if ( ! getClosest( e.target, 'li.menupop' ) ) {
|
||||
removeAllHoverClass( topMenuItems );
|
||||
}
|
||||
} );
|
||||
|
||||
// Add listener for menu items to toggle hover class by touches.
|
||||
// Remove the callback later for better performance.
|
||||
adminBar.addEventListener( 'touchstart', function bindMobileEvents() {
|
||||
for ( var i = 0; i < topMenuItems.length; i++ ) {
|
||||
topMenuItems[i].addEventListener( 'click', mobileHover.bind( null, topMenuItems ) );
|
||||
}
|
||||
|
||||
adminBar.removeEventListener( 'touchstart', bindMobileEvents );
|
||||
} );
|
||||
}
|
||||
|
||||
// Scroll page to top when clicking on the admin bar.
|
||||
adminBar.addEventListener( 'click', scrollToTop );
|
||||
|
||||
for ( i = 0; i < topMenuItems.length; i++ ) {
|
||||
// Adds or removes the hover class based on the hover intent.
|
||||
window.hoverintent(
|
||||
topMenuItems[i],
|
||||
addClass.bind( null, topMenuItems[i], 'hover' ),
|
||||
removeClass.bind( null, topMenuItems[i], 'hover' )
|
||||
).options( {
|
||||
timeout: 180
|
||||
} );
|
||||
|
||||
// Toggle hover class if the enter key is pressed.
|
||||
topMenuItems[i].addEventListener( 'keydown', toggleHoverIfEnter );
|
||||
}
|
||||
|
||||
// Remove hover class if the escape key is pressed.
|
||||
for ( i = 0; i < allMenuItems.length; i++ ) {
|
||||
allMenuItems[i].addEventListener( 'keydown', removeHoverIfEscape );
|
||||
}
|
||||
|
||||
if ( adminBarSearchForm ) {
|
||||
adminBarSearchInput = document.getElementById( 'adminbar-search' );
|
||||
|
||||
// Adds the adminbar-focused class on focus.
|
||||
adminBarSearchInput.addEventListener( 'focus', function() {
|
||||
addClass( adminBarSearchForm, 'adminbar-focused' );
|
||||
} );
|
||||
|
||||
// Removes the adminbar-focused class on blur.
|
||||
adminBarSearchInput.addEventListener( 'blur', function() {
|
||||
removeClass( adminBarSearchForm, 'adminbar-focused' );
|
||||
} );
|
||||
}
|
||||
|
||||
if ( skipLink ) {
|
||||
// Focus the target of skip link after pressing Enter.
|
||||
skipLink.addEventListener( 'keydown', focusTargetAfterEnter );
|
||||
}
|
||||
|
||||
if ( shortlink ) {
|
||||
shortlink.addEventListener( 'click', clickShortlink );
|
||||
}
|
||||
|
||||
// Prevents the toolbar from covering up content when a hash is present in the URL.
|
||||
if ( window.location.hash ) {
|
||||
window.scrollBy( 0, -32 );
|
||||
}
|
||||
|
||||
// Clear sessionStorage on logging out.
|
||||
if ( adminBarLogout ) {
|
||||
adminBarLogout.addEventListener( 'click', emptySessionStorage );
|
||||
}
|
||||
} );
|
||||
|
||||
/**
|
||||
* Remove hover class for top level menu item when escape is pressed.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*
|
||||
* @param {Event} event The keydown event.
|
||||
*/
|
||||
function removeHoverIfEscape( event ) {
|
||||
var wrapper;
|
||||
|
||||
if ( event.which !== 27 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper = getClosest( event.target, '.menupop' );
|
||||
|
||||
if ( ! wrapper ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper.querySelector( '.menupop > .ab-item' ).focus();
|
||||
removeClass( wrapper, 'hover' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle hover class for top level menu item when enter is pressed.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*
|
||||
* @param {Event} event The keydown event.
|
||||
*/
|
||||
function toggleHoverIfEnter( event ) {
|
||||
var wrapper;
|
||||
|
||||
// Follow link if pressing Ctrl and/or Shift with Enter (opening in a new tab or window).
|
||||
if ( event.which !== 13 || event.ctrlKey || event.shiftKey ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !! getClosest( event.target, '.ab-sub-wrapper' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wrapper = getClosest( event.target, '.menupop' );
|
||||
|
||||
if ( ! wrapper ) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
if ( hasClass( wrapper, 'hover' ) ) {
|
||||
removeClass( wrapper, 'hover' );
|
||||
} else {
|
||||
addClass( wrapper, 'hover' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Focus the target of skip link after pressing Enter.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*
|
||||
* @param {Event} event The keydown event.
|
||||
*/
|
||||
function focusTargetAfterEnter( event ) {
|
||||
var id, userAgent;
|
||||
|
||||
if ( event.which !== 13 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
id = event.target.getAttribute( 'href' );
|
||||
userAgent = navigator.userAgent.toLowerCase();
|
||||
|
||||
if ( userAgent.indexOf( 'applewebkit' ) > -1 && id && id.charAt( 0 ) === '#' ) {
|
||||
setTimeout( function() {
|
||||
var target = document.getElementById( id.replace( '#', '' ) );
|
||||
|
||||
if ( target ) {
|
||||
target.setAttribute( 'tabIndex', '0' );
|
||||
target.focus();
|
||||
}
|
||||
}, 100 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toogle hover class for mobile devices.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*
|
||||
* @param {NodeList} topMenuItems All menu items.
|
||||
* @param {Event} event The click event.
|
||||
*/
|
||||
function mobileHover( topMenuItems, event ) {
|
||||
var wrapper;
|
||||
|
||||
if ( !! getClosest( event.target, '.ab-sub-wrapper' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
wrapper = getClosest( event.target, '.menupop' );
|
||||
|
||||
if ( ! wrapper ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( hasClass( wrapper, 'hover' ) ) {
|
||||
removeClass( wrapper, 'hover' );
|
||||
} else {
|
||||
removeAllHoverClass( topMenuItems );
|
||||
addClass( wrapper, 'hover' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the click on the Shortlink link in the adminbar.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @since 5.3.1 Use querySelector to clean up the function.
|
||||
*
|
||||
* @param {Event} event The click event.
|
||||
* @return {boolean} Returns false to prevent default click behavior.
|
||||
*/
|
||||
function clickShortlink( event ) {
|
||||
var wrapper = event.target.parentNode,
|
||||
input;
|
||||
|
||||
if ( wrapper ) {
|
||||
input = wrapper.querySelector( '.shortlink-input' );
|
||||
}
|
||||
|
||||
if ( ! input ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// (Old) IE doesn't support preventDefault, and does support returnValue.
|
||||
if ( event.preventDefault ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
event.returnValue = false;
|
||||
|
||||
addClass( wrapper, 'selected' );
|
||||
|
||||
input.focus();
|
||||
input.select();
|
||||
input.onblur = function() {
|
||||
removeClass( wrapper, 'selected' );
|
||||
};
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear sessionStorage on logging out.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*/
|
||||
function emptySessionStorage() {
|
||||
if ( 'sessionStorage' in window ) {
|
||||
try {
|
||||
for ( var key in sessionStorage ) {
|
||||
if ( key.indexOf( 'wp-autosave-' ) > -1 ) {
|
||||
sessionStorage.removeItem( key );
|
||||
}
|
||||
}
|
||||
} catch ( er ) {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if element has class.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*
|
||||
* @param {HTMLElement} element The HTML element.
|
||||
* @param {string} className The class name.
|
||||
* @return {boolean} Whether the element has the className.
|
||||
*/
|
||||
function hasClass( element, className ) {
|
||||
var classNames;
|
||||
|
||||
if ( ! element ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( element.classList && element.classList.contains ) {
|
||||
return element.classList.contains( className );
|
||||
} else if ( element.className ) {
|
||||
classNames = element.className.split( ' ' );
|
||||
return classNames.indexOf( className ) > -1;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add class to an element.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*
|
||||
* @param {HTMLElement} element The HTML element.
|
||||
* @param {string} className The class name.
|
||||
*/
|
||||
function addClass( element, className ) {
|
||||
if ( ! element ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( element.classList && element.classList.add ) {
|
||||
element.classList.add( className );
|
||||
} else if ( ! hasClass( element, className ) ) {
|
||||
if ( element.className ) {
|
||||
element.className += ' ';
|
||||
}
|
||||
|
||||
element.className += className;
|
||||
}
|
||||
|
||||
var menuItemToggle = element.querySelector( 'a' );
|
||||
if ( className === 'hover' && menuItemToggle && menuItemToggle.hasAttribute( 'aria-expanded' ) ) {
|
||||
menuItemToggle.setAttribute( 'aria-expanded', 'true' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove class from an element.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*
|
||||
* @param {HTMLElement} element The HTML element.
|
||||
* @param {string} className The class name.
|
||||
*/
|
||||
function removeClass( element, className ) {
|
||||
var testName,
|
||||
classes;
|
||||
|
||||
if ( ! element || ! hasClass( element, className ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( element.classList && element.classList.remove ) {
|
||||
element.classList.remove( className );
|
||||
} else {
|
||||
testName = ' ' + className + ' ';
|
||||
classes = ' ' + element.className + ' ';
|
||||
|
||||
while ( classes.indexOf( testName ) > -1 ) {
|
||||
classes = classes.replace( testName, '' );
|
||||
}
|
||||
|
||||
element.className = classes.replace( /^[\s]+|[\s]+$/g, '' );
|
||||
}
|
||||
|
||||
var menuItemToggle = element.querySelector( 'a' );
|
||||
if ( className === 'hover' && menuItemToggle && menuItemToggle.hasAttribute( 'aria-expanded' ) ) {
|
||||
menuItemToggle.setAttribute( 'aria-expanded', 'false' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove hover class for all menu items.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*
|
||||
* @param {NodeList} topMenuItems All menu items.
|
||||
*/
|
||||
function removeAllHoverClass( topMenuItems ) {
|
||||
if ( topMenuItems && topMenuItems.length ) {
|
||||
for ( var i = 0; i < topMenuItems.length; i++ ) {
|
||||
removeClass( topMenuItems[i], 'hover' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolls to the top of the page.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param {Event} event The Click event.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
function scrollToTop( event ) {
|
||||
// Only scroll when clicking on the wpadminbar, not on menus or submenus.
|
||||
if (
|
||||
event.target &&
|
||||
event.target.id !== 'wpadminbar' &&
|
||||
event.target.id !== 'wp-admin-bar-top-secondary'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
window.scrollTo( {
|
||||
top: -32,
|
||||
left: 0,
|
||||
behavior: 'smooth'
|
||||
} );
|
||||
} catch ( er ) {
|
||||
window.scrollTo( 0, -32 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get closest Element.
|
||||
*
|
||||
* @since 5.3.1
|
||||
*
|
||||
* @param {HTMLElement} el Element to get parent.
|
||||
* @param {string} selector CSS selector to match.
|
||||
*/
|
||||
function getClosest( el, selector ) {
|
||||
if ( ! window.Element.prototype.matches ) {
|
||||
// Polyfill from https://developer.mozilla.org/en-US/docs/Web/API/Element/matches.
|
||||
window.Element.prototype.matches =
|
||||
window.Element.prototype.matchesSelector ||
|
||||
window.Element.prototype.mozMatchesSelector ||
|
||||
window.Element.prototype.msMatchesSelector ||
|
||||
window.Element.prototype.oMatchesSelector ||
|
||||
window.Element.prototype.webkitMatchesSelector ||
|
||||
function( s ) {
|
||||
var matches = ( this.document || this.ownerDocument ).querySelectorAll( s ),
|
||||
i = matches.length;
|
||||
|
||||
while ( --i >= 0 && matches.item( i ) !== this ) { }
|
||||
|
||||
return i > -1;
|
||||
};
|
||||
}
|
||||
|
||||
// Get the closest matching elent.
|
||||
for ( ; el && el !== document; el = el.parentNode ) {
|
||||
if ( el.matches( selector ) ) {
|
||||
return el;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
} )( document, window, navigator );
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
/*! This file is auto-generated */
|
||||
!function(l,u,d){function f(e){27===e.which&&(e=w(e.target,".menupop"))&&(e.querySelector(".menupop > .ab-item").focus(),y(e,"hover"))}function p(e){var t;13!==e.which||e.ctrlKey||e.shiftKey||w(e.target,".ab-sub-wrapper")||(t=w(e.target,".menupop"))&&(e.preventDefault(),(a(t,"hover")?y:g)(t,"hover"))}function h(e){var t;13===e.which&&(t=e.target.getAttribute("href"),-1<d.userAgent.toLowerCase().indexOf("applewebkit"))&&t&&"#"===t.charAt(0)&&setTimeout(function(){var e=l.getElementById(t.replace("#",""));e&&(e.setAttribute("tabIndex","0"),e.focus())},100)}function m(e,t){!w(t.target,".ab-sub-wrapper")&&(t.preventDefault(),t=w(t.target,".menupop"))&&(a(t,"hover")?y:(E(e),g))(t,"hover")}function v(e){var t,r=e.target.parentNode;if(t=r?r.querySelector(".shortlink-input"):t)return e.preventDefault&&e.preventDefault(),e.returnValue=!1,g(r,"selected"),t.focus(),t.select(),!(t.onblur=function(){y(r,"selected")})}function b(){if("sessionStorage"in u)try{for(var e in sessionStorage)-1<e.indexOf("wp-autosave-")&&sessionStorage.removeItem(e)}catch(e){}}function a(e,t){return e&&(e.classList&&e.classList.contains?e.classList.contains(t):e.className&&-1<e.className.split(" ").indexOf(t))}function g(e,t){e&&(e.classList&&e.classList.add?e.classList.add(t):a(e,t)||(e.className&&(e.className+=" "),e.className+=t),e=e.querySelector("a"),"hover"===t)&&e&&e.hasAttribute("aria-expanded")&&e.setAttribute("aria-expanded","true")}function y(e,t){var r,n;if(e&&a(e,t)){if(e.classList&&e.classList.remove)e.classList.remove(t);else{for(r=" "+t+" ",n=" "+e.className+" ";-1<n.indexOf(r);)n=n.replace(r,"");e.className=n.replace(/^[\s]+|[\s]+$/g,"")}e=e.querySelector("a");"hover"===t&&e&&e.hasAttribute("aria-expanded")&&e.setAttribute("aria-expanded","false")}}function E(e){if(e&&e.length)for(var t=0;t<e.length;t++)y(e[t],"hover")}function L(e){if(!e.target||"wpadminbar"===e.target.id||"wp-admin-bar-top-secondary"===e.target.id)try{u.scrollTo({top:-32,left:0,behavior:"smooth"})}catch(e){u.scrollTo(0,-32)}}function w(e,t){for(u.Element.prototype.matches||(u.Element.prototype.matches=u.Element.prototype.matchesSelector||u.Element.prototype.mozMatchesSelector||u.Element.prototype.msMatchesSelector||u.Element.prototype.oMatchesSelector||u.Element.prototype.webkitMatchesSelector||function(e){for(var t=(this.document||this.ownerDocument).querySelectorAll(e),r=t.length;0<=--r&&t.item(r)!==this;);return-1<r});e&&e!==l;e=e.parentNode)if(e.matches(t))return e;return null}l.addEventListener("DOMContentLoaded",function(){var r,e,t,n,a,o,s,i,c=l.getElementById("wpadminbar");if(c&&"querySelectorAll"in c){r=c.querySelectorAll("li.menupop"),e=c.querySelectorAll(".ab-item"),t=l.querySelector("#wp-admin-bar-logout a"),n=l.getElementById("adminbarsearch"),a=l.getElementById("wp-admin-bar-get-shortlink"),o=c.querySelector(".screen-reader-shortcut"),s=/Mobile\/.+Safari/.test(d.userAgent)?"touchstart":"click",y(c,"nojs"),"ontouchstart"in u&&(l.body.addEventListener(s,function(e){w(e.target,"li.menupop")||E(r)}),c.addEventListener("touchstart",function e(){for(var t=0;t<r.length;t++)r[t].addEventListener("click",m.bind(null,r));c.removeEventListener("touchstart",e)})),c.addEventListener("click",L);for(i=0;i<r.length;i++)u.hoverintent(r[i],g.bind(null,r[i],"hover"),y.bind(null,r[i],"hover")).options({timeout:180}),r[i].addEventListener("keydown",p);for(i=0;i<e.length;i++)e[i].addEventListener("keydown",f);n&&((s=l.getElementById("adminbar-search")).addEventListener("focus",function(){g(n,"adminbar-focused")}),s.addEventListener("blur",function(){y(n,"adminbar-focused")})),o&&o.addEventListener("keydown",h),a&&a.addEventListener("click",v),u.location.hash&&u.scrollBy(0,-32),t&&t.addEventListener("click",b)}})}(document,window,navigator);
|
||||
@@ -1,124 +1,124 @@
|
||||
/**
|
||||
* Thin jQuery.ajax wrapper for WP REST API requests.
|
||||
*
|
||||
* Currently only applies to requests that do not use the `wp-api.js` Backbone
|
||||
* client library, though this may change. Serves several purposes:
|
||||
*
|
||||
* - Allows overriding these requests as needed by customized WP installations.
|
||||
* - Sends the REST API nonce as a request header.
|
||||
* - Allows specifying only an endpoint namespace/path instead of a full URL.
|
||||
*
|
||||
* @since 4.9.0
|
||||
* @since 5.6.0 Added overriding of the "PUT" and "DELETE" methods with "POST".
|
||||
* Added an "application/json" Accept header to all requests.
|
||||
* @output wp-includes/js/api-request.js
|
||||
*/
|
||||
|
||||
( function( $ ) {
|
||||
var wpApiSettings = window.wpApiSettings;
|
||||
|
||||
function apiRequest( options ) {
|
||||
options = apiRequest.buildAjaxOptions( options );
|
||||
return apiRequest.transport( options );
|
||||
}
|
||||
|
||||
apiRequest.buildAjaxOptions = function( options ) {
|
||||
var url = options.url;
|
||||
var path = options.path;
|
||||
var method = options.method;
|
||||
var namespaceTrimmed, endpointTrimmed, apiRoot;
|
||||
var headers, addNonceHeader, addAcceptHeader, headerName;
|
||||
|
||||
if (
|
||||
typeof options.namespace === 'string' &&
|
||||
typeof options.endpoint === 'string'
|
||||
) {
|
||||
namespaceTrimmed = options.namespace.replace( /^\/|\/$/g, '' );
|
||||
endpointTrimmed = options.endpoint.replace( /^\//, '' );
|
||||
if ( endpointTrimmed ) {
|
||||
path = namespaceTrimmed + '/' + endpointTrimmed;
|
||||
} else {
|
||||
path = namespaceTrimmed;
|
||||
}
|
||||
}
|
||||
if ( typeof path === 'string' ) {
|
||||
apiRoot = wpApiSettings.root;
|
||||
path = path.replace( /^\//, '' );
|
||||
|
||||
// API root may already include query parameter prefix
|
||||
// if site is configured to use plain permalinks.
|
||||
if ( 'string' === typeof apiRoot && -1 !== apiRoot.indexOf( '?' ) ) {
|
||||
path = path.replace( '?', '&' );
|
||||
}
|
||||
|
||||
url = apiRoot + path;
|
||||
}
|
||||
|
||||
// If ?_wpnonce=... is present, no need to add a nonce header.
|
||||
addNonceHeader = ! ( options.data && options.data._wpnonce );
|
||||
addAcceptHeader = true;
|
||||
|
||||
headers = options.headers || {};
|
||||
|
||||
for ( headerName in headers ) {
|
||||
if ( ! headers.hasOwnProperty( headerName ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If an 'X-WP-Nonce' or 'Accept' header (or any case-insensitive variation
|
||||
// thereof) was specified, no need to add the header again.
|
||||
switch ( headerName.toLowerCase() ) {
|
||||
case 'x-wp-nonce':
|
||||
addNonceHeader = false;
|
||||
break;
|
||||
case 'accept':
|
||||
addAcceptHeader = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( addNonceHeader ) {
|
||||
// Do not mutate the original headers object, if any.
|
||||
headers = $.extend( {
|
||||
'X-WP-Nonce': wpApiSettings.nonce
|
||||
}, headers );
|
||||
}
|
||||
|
||||
if ( addAcceptHeader ) {
|
||||
headers = $.extend( {
|
||||
'Accept': 'application/json, */*;q=0.1'
|
||||
}, headers );
|
||||
}
|
||||
|
||||
if ( typeof method === 'string' ) {
|
||||
method = method.toUpperCase();
|
||||
|
||||
if ( 'PUT' === method || 'DELETE' === method ) {
|
||||
headers = $.extend( {
|
||||
'X-HTTP-Method-Override': method
|
||||
}, headers );
|
||||
|
||||
method = 'POST';
|
||||
}
|
||||
}
|
||||
|
||||
// Do not mutate the original options object.
|
||||
options = $.extend( {}, options, {
|
||||
headers: headers,
|
||||
url: url,
|
||||
method: method
|
||||
} );
|
||||
|
||||
delete options.path;
|
||||
delete options.namespace;
|
||||
delete options.endpoint;
|
||||
|
||||
return options;
|
||||
};
|
||||
|
||||
apiRequest.transport = $.ajax;
|
||||
|
||||
/** @namespace wp */
|
||||
window.wp = window.wp || {};
|
||||
window.wp.apiRequest = apiRequest;
|
||||
} )( jQuery );
|
||||
/**
|
||||
* Thin jQuery.ajax wrapper for WP REST API requests.
|
||||
*
|
||||
* Currently only applies to requests that do not use the `wp-api.js` Backbone
|
||||
* client library, though this may change. Serves several purposes:
|
||||
*
|
||||
* - Allows overriding these requests as needed by customized WP installations.
|
||||
* - Sends the REST API nonce as a request header.
|
||||
* - Allows specifying only an endpoint namespace/path instead of a full URL.
|
||||
*
|
||||
* @since 4.9.0
|
||||
* @since 5.6.0 Added overriding of the "PUT" and "DELETE" methods with "POST".
|
||||
* Added an "application/json" Accept header to all requests.
|
||||
* @output wp-includes/js/api-request.js
|
||||
*/
|
||||
|
||||
( function( $ ) {
|
||||
var wpApiSettings = window.wpApiSettings;
|
||||
|
||||
function apiRequest( options ) {
|
||||
options = apiRequest.buildAjaxOptions( options );
|
||||
return apiRequest.transport( options );
|
||||
}
|
||||
|
||||
apiRequest.buildAjaxOptions = function( options ) {
|
||||
var url = options.url;
|
||||
var path = options.path;
|
||||
var method = options.method;
|
||||
var namespaceTrimmed, endpointTrimmed, apiRoot;
|
||||
var headers, addNonceHeader, addAcceptHeader, headerName;
|
||||
|
||||
if (
|
||||
typeof options.namespace === 'string' &&
|
||||
typeof options.endpoint === 'string'
|
||||
) {
|
||||
namespaceTrimmed = options.namespace.replace( /^\/|\/$/g, '' );
|
||||
endpointTrimmed = options.endpoint.replace( /^\//, '' );
|
||||
if ( endpointTrimmed ) {
|
||||
path = namespaceTrimmed + '/' + endpointTrimmed;
|
||||
} else {
|
||||
path = namespaceTrimmed;
|
||||
}
|
||||
}
|
||||
if ( typeof path === 'string' ) {
|
||||
apiRoot = wpApiSettings.root;
|
||||
path = path.replace( /^\//, '' );
|
||||
|
||||
// API root may already include query parameter prefix
|
||||
// if site is configured to use plain permalinks.
|
||||
if ( 'string' === typeof apiRoot && -1 !== apiRoot.indexOf( '?' ) ) {
|
||||
path = path.replace( '?', '&' );
|
||||
}
|
||||
|
||||
url = apiRoot + path;
|
||||
}
|
||||
|
||||
// If ?_wpnonce=... is present, no need to add a nonce header.
|
||||
addNonceHeader = ! ( options.data && options.data._wpnonce );
|
||||
addAcceptHeader = true;
|
||||
|
||||
headers = options.headers || {};
|
||||
|
||||
for ( headerName in headers ) {
|
||||
if ( ! headers.hasOwnProperty( headerName ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If an 'X-WP-Nonce' or 'Accept' header (or any case-insensitive variation
|
||||
// thereof) was specified, no need to add the header again.
|
||||
switch ( headerName.toLowerCase() ) {
|
||||
case 'x-wp-nonce':
|
||||
addNonceHeader = false;
|
||||
break;
|
||||
case 'accept':
|
||||
addAcceptHeader = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( addNonceHeader ) {
|
||||
// Do not mutate the original headers object, if any.
|
||||
headers = $.extend( {
|
||||
'X-WP-Nonce': wpApiSettings.nonce
|
||||
}, headers );
|
||||
}
|
||||
|
||||
if ( addAcceptHeader ) {
|
||||
headers = $.extend( {
|
||||
'Accept': 'application/json, */*;q=0.1'
|
||||
}, headers );
|
||||
}
|
||||
|
||||
if ( typeof method === 'string' ) {
|
||||
method = method.toUpperCase();
|
||||
|
||||
if ( 'PUT' === method || 'DELETE' === method ) {
|
||||
headers = $.extend( {
|
||||
'X-HTTP-Method-Override': method
|
||||
}, headers );
|
||||
|
||||
method = 'POST';
|
||||
}
|
||||
}
|
||||
|
||||
// Do not mutate the original options object.
|
||||
options = $.extend( {}, options, {
|
||||
headers: headers,
|
||||
url: url,
|
||||
method: method
|
||||
} );
|
||||
|
||||
delete options.path;
|
||||
delete options.namespace;
|
||||
delete options.endpoint;
|
||||
|
||||
return options;
|
||||
};
|
||||
|
||||
apiRequest.transport = $.ajax;
|
||||
|
||||
/** @namespace wp */
|
||||
window.wp = window.wp || {};
|
||||
window.wp.apiRequest = apiRequest;
|
||||
} )( jQuery );
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
/*! This file is auto-generated */
|
||||
!function(c){var w=window.wpApiSettings;function t(e){return e=t.buildAjaxOptions(e),t.transport(e)}t.buildAjaxOptions=function(e){var t,n,a,p,o,r,i=e.url,d=e.path,s=e.method;for(r in"string"==typeof e.namespace&&"string"==typeof e.endpoint&&(t=e.namespace.replace(/^\/|\/$/g,""),d=(n=e.endpoint.replace(/^\//,""))?t+"/"+n:t),"string"==typeof d&&(n=w.root,d=d.replace(/^\//,""),"string"==typeof n&&-1!==n.indexOf("?")&&(d=d.replace("?","&")),i=n+d),p=!(e.data&&e.data._wpnonce),o=!0,a=e.headers||{})if(a.hasOwnProperty(r))switch(r.toLowerCase()){case"x-wp-nonce":p=!1;break;case"accept":o=!1}return p&&(a=c.extend({"X-WP-Nonce":w.nonce},a)),o&&(a=c.extend({Accept:"application/json, */*;q=0.1"},a)),"string"!=typeof s||"PUT"!==(s=s.toUpperCase())&&"DELETE"!==s||(a=c.extend({"X-HTTP-Method-Override":s},a),s="POST"),delete(e=c.extend({},e,{headers:a,url:i,method:s})).path,delete e.namespace,delete e.endpoint,e},t.transport=c.ajax,window.wp=window.wp||{},window.wp.apiRequest=t}(jQuery);
|
||||
File diff suppressed because it is too large
Load Diff
+1
-1
File diff suppressed because one or more lines are too long
+2137
-2137
File diff suppressed because it is too large
Load Diff
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
+1
-1
File diff suppressed because one or more lines are too long
+10
-10
File diff suppressed because one or more lines are too long
+28
-28
File diff suppressed because one or more lines are too long
+10858
-10858
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,43 +1,43 @@
|
||||
// JSHINT has some GPL Compatability issues, so we are faking it out and using esprima for validation
|
||||
// Based on https://github.com/jquery/esprima/blob/gh-pages/demo/validate.js which is MIT licensed
|
||||
|
||||
var fakeJSHINT = new function() {
|
||||
var syntax, errors;
|
||||
var that = this;
|
||||
this.data = [];
|
||||
this.convertError = function( error ){
|
||||
return {
|
||||
line: error.lineNumber,
|
||||
character: error.column,
|
||||
reason: error.description,
|
||||
code: 'E'
|
||||
};
|
||||
};
|
||||
this.parse = function( code ){
|
||||
try {
|
||||
syntax = window.esprima.parse(code, { tolerant: true, loc: true });
|
||||
errors = syntax.errors;
|
||||
if ( errors.length > 0 ) {
|
||||
for ( var i = 0; i < errors.length; i++) {
|
||||
var error = errors[i];
|
||||
that.data.push( that.convertError( error ) );
|
||||
}
|
||||
} else {
|
||||
that.data = [];
|
||||
}
|
||||
} catch (e) {
|
||||
that.data.push( that.convertError( e ) );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
window.JSHINT = function( text ){
|
||||
fakeJSHINT.parse( text );
|
||||
};
|
||||
window.JSHINT.data = function(){
|
||||
return {
|
||||
errors: fakeJSHINT.data
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// JSHINT has some GPL Compatability issues, so we are faking it out and using esprima for validation
|
||||
// Based on https://github.com/jquery/esprima/blob/gh-pages/demo/validate.js which is MIT licensed
|
||||
|
||||
var fakeJSHINT = new function() {
|
||||
var syntax, errors;
|
||||
var that = this;
|
||||
this.data = [];
|
||||
this.convertError = function( error ){
|
||||
return {
|
||||
line: error.lineNumber,
|
||||
character: error.column,
|
||||
reason: error.description,
|
||||
code: 'E'
|
||||
};
|
||||
};
|
||||
this.parse = function( code ){
|
||||
try {
|
||||
syntax = window.esprima.parse(code, { tolerant: true, loc: true });
|
||||
errors = syntax.errors;
|
||||
if ( errors.length > 0 ) {
|
||||
for ( var i = 0; i < errors.length; i++) {
|
||||
var error = errors[i];
|
||||
that.data.push( that.convertError( error ) );
|
||||
}
|
||||
} else {
|
||||
that.data = [];
|
||||
}
|
||||
} catch (e) {
|
||||
that.data.push( that.convertError( e ) );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
window.JSHINT = function( text ){
|
||||
fakeJSHINT.parse( text );
|
||||
};
|
||||
window.JSHINT.data = function(){
|
||||
return {
|
||||
errors: fakeJSHINT.data
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
/* global HTMLHint */
|
||||
/* eslint no-magic-numbers: ["error", { "ignore": [0, 1] }] */
|
||||
HTMLHint.addRule({
|
||||
id: 'kses',
|
||||
description: 'Element or attribute cannot be used.',
|
||||
init: function( parser, reporter, options ) {
|
||||
'use strict';
|
||||
|
||||
var self = this;
|
||||
parser.addListener( 'tagstart', function( event ) {
|
||||
var attr, col, attrName, allowedAttributes, i, len, tagName;
|
||||
|
||||
tagName = event.tagName.toLowerCase();
|
||||
if ( ! options[ tagName ] ) {
|
||||
reporter.error( 'Tag <' + event.tagName + '> is not allowed.', event.line, event.col, self, event.raw );
|
||||
return;
|
||||
}
|
||||
|
||||
allowedAttributes = options[ tagName ];
|
||||
col = event.col + event.tagName.length + 1;
|
||||
for ( i = 0, len = event.attrs.length; i < len; i++ ) {
|
||||
attr = event.attrs[ i ];
|
||||
attrName = attr.name.toLowerCase();
|
||||
if ( ! allowedAttributes[ attrName ] ) {
|
||||
reporter.error( 'Tag attribute [' + attr.raw + ' ] is not allowed.', event.line, col + attr.index, self, attr.raw );
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
/* global HTMLHint */
|
||||
/* eslint no-magic-numbers: ["error", { "ignore": [0, 1] }] */
|
||||
HTMLHint.addRule({
|
||||
id: 'kses',
|
||||
description: 'Element or attribute cannot be used.',
|
||||
init: function( parser, reporter, options ) {
|
||||
'use strict';
|
||||
|
||||
var self = this;
|
||||
parser.addListener( 'tagstart', function( event ) {
|
||||
var attr, col, attrName, allowedAttributes, i, len, tagName;
|
||||
|
||||
tagName = event.tagName.toLowerCase();
|
||||
if ( ! options[ tagName ] ) {
|
||||
reporter.error( 'Tag <' + event.tagName + '> is not allowed.', event.line, event.col, self, event.raw );
|
||||
return;
|
||||
}
|
||||
|
||||
allowedAttributes = options[ tagName ];
|
||||
col = event.col + event.tagName.length + 1;
|
||||
for ( i = 0, len = event.attrs.length; i < len; i++ ) {
|
||||
attr = event.attrs[ i ];
|
||||
attrName = attr.name.toLowerCase();
|
||||
if ( ! allowedAttributes[ attrName ] ) {
|
||||
reporter.error( 'Tag attribute [' + attr.raw + ' ] is not allowed.', event.line, col + attr.index, self, attr.raw );
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,432 +1,432 @@
|
||||
/* Jison generated parser */
|
||||
var jsonlint = (function(){
|
||||
var parser = {trace: function trace() { },
|
||||
yy: {},
|
||||
symbols_: {"error":2,"JSONString":3,"STRING":4,"JSONNumber":5,"NUMBER":6,"JSONNullLiteral":7,"NULL":8,"JSONBooleanLiteral":9,"TRUE":10,"FALSE":11,"JSONText":12,"JSONValue":13,"EOF":14,"JSONObject":15,"JSONArray":16,"{":17,"}":18,"JSONMemberList":19,"JSONMember":20,":":21,",":22,"[":23,"]":24,"JSONElementList":25,"$accept":0,"$end":1},
|
||||
terminals_: {2:"error",4:"STRING",6:"NUMBER",8:"NULL",10:"TRUE",11:"FALSE",14:"EOF",17:"{",18:"}",21:":",22:",",23:"[",24:"]"},
|
||||
productions_: [0,[3,1],[5,1],[7,1],[9,1],[9,1],[12,2],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[15,2],[15,3],[20,3],[19,1],[19,3],[16,2],[16,3],[25,1],[25,3]],
|
||||
performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
|
||||
|
||||
var $0 = $$.length - 1;
|
||||
switch (yystate) {
|
||||
case 1: // replace escaped characters with actual character
|
||||
this.$ = yytext.replace(/\\(\\|")/g, "$"+"1")
|
||||
.replace(/\\n/g,'\n')
|
||||
.replace(/\\r/g,'\r')
|
||||
.replace(/\\t/g,'\t')
|
||||
.replace(/\\v/g,'\v')
|
||||
.replace(/\\f/g,'\f')
|
||||
.replace(/\\b/g,'\b');
|
||||
|
||||
break;
|
||||
case 2:this.$ = Number(yytext);
|
||||
break;
|
||||
case 3:this.$ = null;
|
||||
break;
|
||||
case 4:this.$ = true;
|
||||
break;
|
||||
case 5:this.$ = false;
|
||||
break;
|
||||
case 6:return this.$ = $$[$0-1];
|
||||
break;
|
||||
case 13:this.$ = {};
|
||||
break;
|
||||
case 14:this.$ = $$[$0-1];
|
||||
break;
|
||||
case 15:this.$ = [$$[$0-2], $$[$0]];
|
||||
break;
|
||||
case 16:this.$ = {}; this.$[$$[$0][0]] = $$[$0][1];
|
||||
break;
|
||||
case 17:this.$ = $$[$0-2]; $$[$0-2][$$[$0][0]] = $$[$0][1];
|
||||
break;
|
||||
case 18:this.$ = [];
|
||||
break;
|
||||
case 19:this.$ = $$[$0-1];
|
||||
break;
|
||||
case 20:this.$ = [$$[$0]];
|
||||
break;
|
||||
case 21:this.$ = $$[$0-2]; $$[$0-2].push($$[$0]);
|
||||
break;
|
||||
}
|
||||
},
|
||||
table: [{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],12:1,13:2,15:7,16:8,17:[1,14],23:[1,15]},{1:[3]},{14:[1,16]},{14:[2,7],18:[2,7],22:[2,7],24:[2,7]},{14:[2,8],18:[2,8],22:[2,8],24:[2,8]},{14:[2,9],18:[2,9],22:[2,9],24:[2,9]},{14:[2,10],18:[2,10],22:[2,10],24:[2,10]},{14:[2,11],18:[2,11],22:[2,11],24:[2,11]},{14:[2,12],18:[2,12],22:[2,12],24:[2,12]},{14:[2,3],18:[2,3],22:[2,3],24:[2,3]},{14:[2,4],18:[2,4],22:[2,4],24:[2,4]},{14:[2,5],18:[2,5],22:[2,5],24:[2,5]},{14:[2,1],18:[2,1],21:[2,1],22:[2,1],24:[2,1]},{14:[2,2],18:[2,2],22:[2,2],24:[2,2]},{3:20,4:[1,12],18:[1,17],19:18,20:19},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:23,15:7,16:8,17:[1,14],23:[1,15],24:[1,21],25:22},{1:[2,6]},{14:[2,13],18:[2,13],22:[2,13],24:[2,13]},{18:[1,24],22:[1,25]},{18:[2,16],22:[2,16]},{21:[1,26]},{14:[2,18],18:[2,18],22:[2,18],24:[2,18]},{22:[1,28],24:[1,27]},{22:[2,20],24:[2,20]},{14:[2,14],18:[2,14],22:[2,14],24:[2,14]},{3:20,4:[1,12],20:29},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:30,15:7,16:8,17:[1,14],23:[1,15]},{14:[2,19],18:[2,19],22:[2,19],24:[2,19]},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:31,15:7,16:8,17:[1,14],23:[1,15]},{18:[2,17],22:[2,17]},{18:[2,15],22:[2,15]},{22:[2,21],24:[2,21]}],
|
||||
defaultActions: {16:[2,6]},
|
||||
parseError: function parseError(str, hash) {
|
||||
throw new Error(str);
|
||||
},
|
||||
parse: function parse(input) {
|
||||
var self = this,
|
||||
stack = [0],
|
||||
vstack = [null], // semantic value stack
|
||||
lstack = [], // location stack
|
||||
table = this.table,
|
||||
yytext = '',
|
||||
yylineno = 0,
|
||||
yyleng = 0,
|
||||
recovering = 0,
|
||||
TERROR = 2,
|
||||
EOF = 1;
|
||||
|
||||
//this.reductionCount = this.shiftCount = 0;
|
||||
|
||||
this.lexer.setInput(input);
|
||||
this.lexer.yy = this.yy;
|
||||
this.yy.lexer = this.lexer;
|
||||
if (typeof this.lexer.yylloc == 'undefined')
|
||||
this.lexer.yylloc = {};
|
||||
var yyloc = this.lexer.yylloc;
|
||||
lstack.push(yyloc);
|
||||
|
||||
if (typeof this.yy.parseError === 'function')
|
||||
this.parseError = this.yy.parseError;
|
||||
|
||||
function popStack (n) {
|
||||
stack.length = stack.length - 2*n;
|
||||
vstack.length = vstack.length - n;
|
||||
lstack.length = lstack.length - n;
|
||||
}
|
||||
|
||||
function lex() {
|
||||
var token;
|
||||
token = self.lexer.lex() || 1; // $end = 1
|
||||
// if token isn't its numeric value, convert
|
||||
if (typeof token !== 'number') {
|
||||
token = self.symbols_[token] || token;
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
var symbol, preErrorSymbol, state, action, a, r, yyval={},p,len,newState, expected;
|
||||
while (true) {
|
||||
// retreive state number from top of stack
|
||||
state = stack[stack.length-1];
|
||||
|
||||
// use default actions if available
|
||||
if (this.defaultActions[state]) {
|
||||
action = this.defaultActions[state];
|
||||
} else {
|
||||
if (symbol == null)
|
||||
symbol = lex();
|
||||
// read action for current state and first input
|
||||
action = table[state] && table[state][symbol];
|
||||
}
|
||||
|
||||
// handle parse error
|
||||
_handle_error:
|
||||
if (typeof action === 'undefined' || !action.length || !action[0]) {
|
||||
|
||||
if (!recovering) {
|
||||
// Report error
|
||||
expected = [];
|
||||
for (p in table[state]) if (this.terminals_[p] && p > 2) {
|
||||
expected.push("'"+this.terminals_[p]+"'");
|
||||
}
|
||||
var errStr = '';
|
||||
if (this.lexer.showPosition) {
|
||||
errStr = 'Parse error on line '+(yylineno+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+expected.join(', ') + ", got '" + this.terminals_[symbol]+ "'";
|
||||
} else {
|
||||
errStr = 'Parse error on line '+(yylineno+1)+": Unexpected " +
|
||||
(symbol == 1 /*EOF*/ ? "end of input" :
|
||||
("'"+(this.terminals_[symbol] || symbol)+"'"));
|
||||
}
|
||||
this.parseError(errStr,
|
||||
{text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
|
||||
}
|
||||
|
||||
// just recovered from another error
|
||||
if (recovering == 3) {
|
||||
if (symbol == EOF) {
|
||||
throw new Error(errStr || 'Parsing halted.');
|
||||
}
|
||||
|
||||
// discard current lookahead and grab another
|
||||
yyleng = this.lexer.yyleng;
|
||||
yytext = this.lexer.yytext;
|
||||
yylineno = this.lexer.yylineno;
|
||||
yyloc = this.lexer.yylloc;
|
||||
symbol = lex();
|
||||
}
|
||||
|
||||
// try to recover from error
|
||||
while (1) {
|
||||
// check for error recovery rule in this state
|
||||
if ((TERROR.toString()) in table[state]) {
|
||||
break;
|
||||
}
|
||||
if (state == 0) {
|
||||
throw new Error(errStr || 'Parsing halted.');
|
||||
}
|
||||
popStack(1);
|
||||
state = stack[stack.length-1];
|
||||
}
|
||||
|
||||
preErrorSymbol = symbol; // save the lookahead token
|
||||
symbol = TERROR; // insert generic error symbol as new lookahead
|
||||
state = stack[stack.length-1];
|
||||
action = table[state] && table[state][TERROR];
|
||||
recovering = 3; // allow 3 real symbols to be shifted before reporting a new error
|
||||
}
|
||||
|
||||
// this shouldn't happen, unless resolve defaults are off
|
||||
if (action[0] instanceof Array && action.length > 1) {
|
||||
throw new Error('Parse Error: multiple actions possible at state: '+state+', token: '+symbol);
|
||||
}
|
||||
|
||||
switch (action[0]) {
|
||||
|
||||
case 1: // shift
|
||||
//this.shiftCount++;
|
||||
|
||||
stack.push(symbol);
|
||||
vstack.push(this.lexer.yytext);
|
||||
lstack.push(this.lexer.yylloc);
|
||||
stack.push(action[1]); // push state
|
||||
symbol = null;
|
||||
if (!preErrorSymbol) { // normal execution/no error
|
||||
yyleng = this.lexer.yyleng;
|
||||
yytext = this.lexer.yytext;
|
||||
yylineno = this.lexer.yylineno;
|
||||
yyloc = this.lexer.yylloc;
|
||||
if (recovering > 0)
|
||||
recovering--;
|
||||
} else { // error just occurred, resume old lookahead f/ before error
|
||||
symbol = preErrorSymbol;
|
||||
preErrorSymbol = null;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: // reduce
|
||||
//this.reductionCount++;
|
||||
|
||||
len = this.productions_[action[1]][1];
|
||||
|
||||
// perform semantic action
|
||||
yyval.$ = vstack[vstack.length-len]; // default to $$ = $1
|
||||
// default location, uses first token for firsts, last for lasts
|
||||
yyval._$ = {
|
||||
first_line: lstack[lstack.length-(len||1)].first_line,
|
||||
last_line: lstack[lstack.length-1].last_line,
|
||||
first_column: lstack[lstack.length-(len||1)].first_column,
|
||||
last_column: lstack[lstack.length-1].last_column
|
||||
};
|
||||
r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
|
||||
|
||||
if (typeof r !== 'undefined') {
|
||||
return r;
|
||||
}
|
||||
|
||||
// pop off stack
|
||||
if (len) {
|
||||
stack = stack.slice(0,-1*len*2);
|
||||
vstack = vstack.slice(0, -1*len);
|
||||
lstack = lstack.slice(0, -1*len);
|
||||
}
|
||||
|
||||
stack.push(this.productions_[action[1]][0]); // push nonterminal (reduce)
|
||||
vstack.push(yyval.$);
|
||||
lstack.push(yyval._$);
|
||||
// goto new state = table[STATE][NONTERMINAL]
|
||||
newState = table[stack[stack.length-2]][stack[stack.length-1]];
|
||||
stack.push(newState);
|
||||
break;
|
||||
|
||||
case 3: // accept
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}};
|
||||
/* Jison generated lexer */
|
||||
var lexer = (function(){
|
||||
var lexer = ({EOF:1,
|
||||
parseError:function parseError(str, hash) {
|
||||
if (this.yy.parseError) {
|
||||
this.yy.parseError(str, hash);
|
||||
} else {
|
||||
throw new Error(str);
|
||||
}
|
||||
},
|
||||
setInput:function (input) {
|
||||
this._input = input;
|
||||
this._more = this._less = this.done = false;
|
||||
this.yylineno = this.yyleng = 0;
|
||||
this.yytext = this.matched = this.match = '';
|
||||
this.conditionStack = ['INITIAL'];
|
||||
this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0};
|
||||
return this;
|
||||
},
|
||||
input:function () {
|
||||
var ch = this._input[0];
|
||||
this.yytext+=ch;
|
||||
this.yyleng++;
|
||||
this.match+=ch;
|
||||
this.matched+=ch;
|
||||
var lines = ch.match(/\n/);
|
||||
if (lines) this.yylineno++;
|
||||
this._input = this._input.slice(1);
|
||||
return ch;
|
||||
},
|
||||
unput:function (ch) {
|
||||
this._input = ch + this._input;
|
||||
return this;
|
||||
},
|
||||
more:function () {
|
||||
this._more = true;
|
||||
return this;
|
||||
},
|
||||
less:function (n) {
|
||||
this._input = this.match.slice(n) + this._input;
|
||||
},
|
||||
pastInput:function () {
|
||||
var past = this.matched.substr(0, this.matched.length - this.match.length);
|
||||
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
|
||||
},
|
||||
upcomingInput:function () {
|
||||
var next = this.match;
|
||||
if (next.length < 20) {
|
||||
next += this._input.substr(0, 20-next.length);
|
||||
}
|
||||
return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, "");
|
||||
},
|
||||
showPosition:function () {
|
||||
var pre = this.pastInput();
|
||||
var c = new Array(pre.length + 1).join("-");
|
||||
return pre + this.upcomingInput() + "\n" + c+"^";
|
||||
},
|
||||
next:function () {
|
||||
if (this.done) {
|
||||
return this.EOF;
|
||||
}
|
||||
if (!this._input) this.done = true;
|
||||
|
||||
var token,
|
||||
match,
|
||||
tempMatch,
|
||||
index,
|
||||
col,
|
||||
lines;
|
||||
if (!this._more) {
|
||||
this.yytext = '';
|
||||
this.match = '';
|
||||
}
|
||||
var rules = this._currentRules();
|
||||
for (var i=0;i < rules.length; i++) {
|
||||
tempMatch = this._input.match(this.rules[rules[i]]);
|
||||
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
||||
match = tempMatch;
|
||||
index = i;
|
||||
if (!this.options.flex) break;
|
||||
}
|
||||
}
|
||||
if (match) {
|
||||
lines = match[0].match(/\n.*/g);
|
||||
if (lines) this.yylineno += lines.length;
|
||||
this.yylloc = {first_line: this.yylloc.last_line,
|
||||
last_line: this.yylineno+1,
|
||||
first_column: this.yylloc.last_column,
|
||||
last_column: lines ? lines[lines.length-1].length-1 : this.yylloc.last_column + match[0].length}
|
||||
this.yytext += match[0];
|
||||
this.match += match[0];
|
||||
this.yyleng = this.yytext.length;
|
||||
this._more = false;
|
||||
this._input = this._input.slice(match[0].length);
|
||||
this.matched += match[0];
|
||||
token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]);
|
||||
if (this.done && this._input) this.done = false;
|
||||
if (token) return token;
|
||||
else return;
|
||||
}
|
||||
if (this._input === "") {
|
||||
return this.EOF;
|
||||
} else {
|
||||
this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
|
||||
{text: "", token: null, line: this.yylineno});
|
||||
}
|
||||
},
|
||||
lex:function lex() {
|
||||
var r = this.next();
|
||||
if (typeof r !== 'undefined') {
|
||||
return r;
|
||||
} else {
|
||||
return this.lex();
|
||||
}
|
||||
},
|
||||
begin:function begin(condition) {
|
||||
this.conditionStack.push(condition);
|
||||
},
|
||||
popState:function popState() {
|
||||
return this.conditionStack.pop();
|
||||
},
|
||||
_currentRules:function _currentRules() {
|
||||
return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;
|
||||
},
|
||||
topState:function () {
|
||||
return this.conditionStack[this.conditionStack.length-2];
|
||||
},
|
||||
pushState:function begin(condition) {
|
||||
this.begin(condition);
|
||||
}});
|
||||
lexer.options = {};
|
||||
lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
|
||||
|
||||
var YYSTATE=YY_START
|
||||
switch($avoiding_name_collisions) {
|
||||
case 0:/* skip whitespace */
|
||||
break;
|
||||
case 1:return 6
|
||||
break;
|
||||
case 2:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2); return 4
|
||||
break;
|
||||
case 3:return 17
|
||||
break;
|
||||
case 4:return 18
|
||||
break;
|
||||
case 5:return 23
|
||||
break;
|
||||
case 6:return 24
|
||||
break;
|
||||
case 7:return 22
|
||||
break;
|
||||
case 8:return 21
|
||||
break;
|
||||
case 9:return 10
|
||||
break;
|
||||
case 10:return 11
|
||||
break;
|
||||
case 11:return 8
|
||||
break;
|
||||
case 12:return 14
|
||||
break;
|
||||
case 13:return 'INVALID'
|
||||
break;
|
||||
}
|
||||
};
|
||||
lexer.rules = [/^(?:\s+)/,/^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/,/^(?:"(?:\\[\\"bfnrt/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/,/^(?:\{)/,/^(?:\})/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?::)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:null\b)/,/^(?:$)/,/^(?:.)/];
|
||||
lexer.conditions = {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13],"inclusive":true}};
|
||||
|
||||
|
||||
;
|
||||
return lexer;})()
|
||||
parser.lexer = lexer;
|
||||
return parser;
|
||||
})();
|
||||
if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
|
||||
exports.parser = jsonlint;
|
||||
exports.parse = function () { return jsonlint.parse.apply(jsonlint, arguments); }
|
||||
exports.main = function commonjsMain(args) {
|
||||
if (!args[1])
|
||||
throw new Error('Usage: '+args[0]+' FILE');
|
||||
if (typeof process !== 'undefined') {
|
||||
var source = require('fs').readFileSync(require('path').join(process.cwd(), args[1]), "utf8");
|
||||
} else {
|
||||
var cwd = require("file").path(require("file").cwd());
|
||||
var source = cwd.join(args[1]).read({charset: "utf-8"});
|
||||
}
|
||||
return exports.parser.parse(source);
|
||||
}
|
||||
if (typeof module !== 'undefined' && require.main === module) {
|
||||
exports.main(typeof process !== 'undefined' ? process.argv.slice(1) : require("system").args);
|
||||
}
|
||||
/* Jison generated parser */
|
||||
var jsonlint = (function(){
|
||||
var parser = {trace: function trace() { },
|
||||
yy: {},
|
||||
symbols_: {"error":2,"JSONString":3,"STRING":4,"JSONNumber":5,"NUMBER":6,"JSONNullLiteral":7,"NULL":8,"JSONBooleanLiteral":9,"TRUE":10,"FALSE":11,"JSONText":12,"JSONValue":13,"EOF":14,"JSONObject":15,"JSONArray":16,"{":17,"}":18,"JSONMemberList":19,"JSONMember":20,":":21,",":22,"[":23,"]":24,"JSONElementList":25,"$accept":0,"$end":1},
|
||||
terminals_: {2:"error",4:"STRING",6:"NUMBER",8:"NULL",10:"TRUE",11:"FALSE",14:"EOF",17:"{",18:"}",21:":",22:",",23:"[",24:"]"},
|
||||
productions_: [0,[3,1],[5,1],[7,1],[9,1],[9,1],[12,2],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[15,2],[15,3],[20,3],[19,1],[19,3],[16,2],[16,3],[25,1],[25,3]],
|
||||
performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
|
||||
|
||||
var $0 = $$.length - 1;
|
||||
switch (yystate) {
|
||||
case 1: // replace escaped characters with actual character
|
||||
this.$ = yytext.replace(/\\(\\|")/g, "$"+"1")
|
||||
.replace(/\\n/g,'\n')
|
||||
.replace(/\\r/g,'\r')
|
||||
.replace(/\\t/g,'\t')
|
||||
.replace(/\\v/g,'\v')
|
||||
.replace(/\\f/g,'\f')
|
||||
.replace(/\\b/g,'\b');
|
||||
|
||||
break;
|
||||
case 2:this.$ = Number(yytext);
|
||||
break;
|
||||
case 3:this.$ = null;
|
||||
break;
|
||||
case 4:this.$ = true;
|
||||
break;
|
||||
case 5:this.$ = false;
|
||||
break;
|
||||
case 6:return this.$ = $$[$0-1];
|
||||
break;
|
||||
case 13:this.$ = {};
|
||||
break;
|
||||
case 14:this.$ = $$[$0-1];
|
||||
break;
|
||||
case 15:this.$ = [$$[$0-2], $$[$0]];
|
||||
break;
|
||||
case 16:this.$ = {}; this.$[$$[$0][0]] = $$[$0][1];
|
||||
break;
|
||||
case 17:this.$ = $$[$0-2]; $$[$0-2][$$[$0][0]] = $$[$0][1];
|
||||
break;
|
||||
case 18:this.$ = [];
|
||||
break;
|
||||
case 19:this.$ = $$[$0-1];
|
||||
break;
|
||||
case 20:this.$ = [$$[$0]];
|
||||
break;
|
||||
case 21:this.$ = $$[$0-2]; $$[$0-2].push($$[$0]);
|
||||
break;
|
||||
}
|
||||
},
|
||||
table: [{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],12:1,13:2,15:7,16:8,17:[1,14],23:[1,15]},{1:[3]},{14:[1,16]},{14:[2,7],18:[2,7],22:[2,7],24:[2,7]},{14:[2,8],18:[2,8],22:[2,8],24:[2,8]},{14:[2,9],18:[2,9],22:[2,9],24:[2,9]},{14:[2,10],18:[2,10],22:[2,10],24:[2,10]},{14:[2,11],18:[2,11],22:[2,11],24:[2,11]},{14:[2,12],18:[2,12],22:[2,12],24:[2,12]},{14:[2,3],18:[2,3],22:[2,3],24:[2,3]},{14:[2,4],18:[2,4],22:[2,4],24:[2,4]},{14:[2,5],18:[2,5],22:[2,5],24:[2,5]},{14:[2,1],18:[2,1],21:[2,1],22:[2,1],24:[2,1]},{14:[2,2],18:[2,2],22:[2,2],24:[2,2]},{3:20,4:[1,12],18:[1,17],19:18,20:19},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:23,15:7,16:8,17:[1,14],23:[1,15],24:[1,21],25:22},{1:[2,6]},{14:[2,13],18:[2,13],22:[2,13],24:[2,13]},{18:[1,24],22:[1,25]},{18:[2,16],22:[2,16]},{21:[1,26]},{14:[2,18],18:[2,18],22:[2,18],24:[2,18]},{22:[1,28],24:[1,27]},{22:[2,20],24:[2,20]},{14:[2,14],18:[2,14],22:[2,14],24:[2,14]},{3:20,4:[1,12],20:29},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:30,15:7,16:8,17:[1,14],23:[1,15]},{14:[2,19],18:[2,19],22:[2,19],24:[2,19]},{3:5,4:[1,12],5:6,6:[1,13],7:3,8:[1,9],9:4,10:[1,10],11:[1,11],13:31,15:7,16:8,17:[1,14],23:[1,15]},{18:[2,17],22:[2,17]},{18:[2,15],22:[2,15]},{22:[2,21],24:[2,21]}],
|
||||
defaultActions: {16:[2,6]},
|
||||
parseError: function parseError(str, hash) {
|
||||
throw new Error(str);
|
||||
},
|
||||
parse: function parse(input) {
|
||||
var self = this,
|
||||
stack = [0],
|
||||
vstack = [null], // semantic value stack
|
||||
lstack = [], // location stack
|
||||
table = this.table,
|
||||
yytext = '',
|
||||
yylineno = 0,
|
||||
yyleng = 0,
|
||||
recovering = 0,
|
||||
TERROR = 2,
|
||||
EOF = 1;
|
||||
|
||||
//this.reductionCount = this.shiftCount = 0;
|
||||
|
||||
this.lexer.setInput(input);
|
||||
this.lexer.yy = this.yy;
|
||||
this.yy.lexer = this.lexer;
|
||||
if (typeof this.lexer.yylloc == 'undefined')
|
||||
this.lexer.yylloc = {};
|
||||
var yyloc = this.lexer.yylloc;
|
||||
lstack.push(yyloc);
|
||||
|
||||
if (typeof this.yy.parseError === 'function')
|
||||
this.parseError = this.yy.parseError;
|
||||
|
||||
function popStack (n) {
|
||||
stack.length = stack.length - 2*n;
|
||||
vstack.length = vstack.length - n;
|
||||
lstack.length = lstack.length - n;
|
||||
}
|
||||
|
||||
function lex() {
|
||||
var token;
|
||||
token = self.lexer.lex() || 1; // $end = 1
|
||||
// if token isn't its numeric value, convert
|
||||
if (typeof token !== 'number') {
|
||||
token = self.symbols_[token] || token;
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
var symbol, preErrorSymbol, state, action, a, r, yyval={},p,len,newState, expected;
|
||||
while (true) {
|
||||
// retreive state number from top of stack
|
||||
state = stack[stack.length-1];
|
||||
|
||||
// use default actions if available
|
||||
if (this.defaultActions[state]) {
|
||||
action = this.defaultActions[state];
|
||||
} else {
|
||||
if (symbol == null)
|
||||
symbol = lex();
|
||||
// read action for current state and first input
|
||||
action = table[state] && table[state][symbol];
|
||||
}
|
||||
|
||||
// handle parse error
|
||||
_handle_error:
|
||||
if (typeof action === 'undefined' || !action.length || !action[0]) {
|
||||
|
||||
if (!recovering) {
|
||||
// Report error
|
||||
expected = [];
|
||||
for (p in table[state]) if (this.terminals_[p] && p > 2) {
|
||||
expected.push("'"+this.terminals_[p]+"'");
|
||||
}
|
||||
var errStr = '';
|
||||
if (this.lexer.showPosition) {
|
||||
errStr = 'Parse error on line '+(yylineno+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+expected.join(', ') + ", got '" + this.terminals_[symbol]+ "'";
|
||||
} else {
|
||||
errStr = 'Parse error on line '+(yylineno+1)+": Unexpected " +
|
||||
(symbol == 1 /*EOF*/ ? "end of input" :
|
||||
("'"+(this.terminals_[symbol] || symbol)+"'"));
|
||||
}
|
||||
this.parseError(errStr,
|
||||
{text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
|
||||
}
|
||||
|
||||
// just recovered from another error
|
||||
if (recovering == 3) {
|
||||
if (symbol == EOF) {
|
||||
throw new Error(errStr || 'Parsing halted.');
|
||||
}
|
||||
|
||||
// discard current lookahead and grab another
|
||||
yyleng = this.lexer.yyleng;
|
||||
yytext = this.lexer.yytext;
|
||||
yylineno = this.lexer.yylineno;
|
||||
yyloc = this.lexer.yylloc;
|
||||
symbol = lex();
|
||||
}
|
||||
|
||||
// try to recover from error
|
||||
while (1) {
|
||||
// check for error recovery rule in this state
|
||||
if ((TERROR.toString()) in table[state]) {
|
||||
break;
|
||||
}
|
||||
if (state == 0) {
|
||||
throw new Error(errStr || 'Parsing halted.');
|
||||
}
|
||||
popStack(1);
|
||||
state = stack[stack.length-1];
|
||||
}
|
||||
|
||||
preErrorSymbol = symbol; // save the lookahead token
|
||||
symbol = TERROR; // insert generic error symbol as new lookahead
|
||||
state = stack[stack.length-1];
|
||||
action = table[state] && table[state][TERROR];
|
||||
recovering = 3; // allow 3 real symbols to be shifted before reporting a new error
|
||||
}
|
||||
|
||||
// this shouldn't happen, unless resolve defaults are off
|
||||
if (action[0] instanceof Array && action.length > 1) {
|
||||
throw new Error('Parse Error: multiple actions possible at state: '+state+', token: '+symbol);
|
||||
}
|
||||
|
||||
switch (action[0]) {
|
||||
|
||||
case 1: // shift
|
||||
//this.shiftCount++;
|
||||
|
||||
stack.push(symbol);
|
||||
vstack.push(this.lexer.yytext);
|
||||
lstack.push(this.lexer.yylloc);
|
||||
stack.push(action[1]); // push state
|
||||
symbol = null;
|
||||
if (!preErrorSymbol) { // normal execution/no error
|
||||
yyleng = this.lexer.yyleng;
|
||||
yytext = this.lexer.yytext;
|
||||
yylineno = this.lexer.yylineno;
|
||||
yyloc = this.lexer.yylloc;
|
||||
if (recovering > 0)
|
||||
recovering--;
|
||||
} else { // error just occurred, resume old lookahead f/ before error
|
||||
symbol = preErrorSymbol;
|
||||
preErrorSymbol = null;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: // reduce
|
||||
//this.reductionCount++;
|
||||
|
||||
len = this.productions_[action[1]][1];
|
||||
|
||||
// perform semantic action
|
||||
yyval.$ = vstack[vstack.length-len]; // default to $$ = $1
|
||||
// default location, uses first token for firsts, last for lasts
|
||||
yyval._$ = {
|
||||
first_line: lstack[lstack.length-(len||1)].first_line,
|
||||
last_line: lstack[lstack.length-1].last_line,
|
||||
first_column: lstack[lstack.length-(len||1)].first_column,
|
||||
last_column: lstack[lstack.length-1].last_column
|
||||
};
|
||||
r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
|
||||
|
||||
if (typeof r !== 'undefined') {
|
||||
return r;
|
||||
}
|
||||
|
||||
// pop off stack
|
||||
if (len) {
|
||||
stack = stack.slice(0,-1*len*2);
|
||||
vstack = vstack.slice(0, -1*len);
|
||||
lstack = lstack.slice(0, -1*len);
|
||||
}
|
||||
|
||||
stack.push(this.productions_[action[1]][0]); // push nonterminal (reduce)
|
||||
vstack.push(yyval.$);
|
||||
lstack.push(yyval._$);
|
||||
// goto new state = table[STATE][NONTERMINAL]
|
||||
newState = table[stack[stack.length-2]][stack[stack.length-1]];
|
||||
stack.push(newState);
|
||||
break;
|
||||
|
||||
case 3: // accept
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}};
|
||||
/* Jison generated lexer */
|
||||
var lexer = (function(){
|
||||
var lexer = ({EOF:1,
|
||||
parseError:function parseError(str, hash) {
|
||||
if (this.yy.parseError) {
|
||||
this.yy.parseError(str, hash);
|
||||
} else {
|
||||
throw new Error(str);
|
||||
}
|
||||
},
|
||||
setInput:function (input) {
|
||||
this._input = input;
|
||||
this._more = this._less = this.done = false;
|
||||
this.yylineno = this.yyleng = 0;
|
||||
this.yytext = this.matched = this.match = '';
|
||||
this.conditionStack = ['INITIAL'];
|
||||
this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0};
|
||||
return this;
|
||||
},
|
||||
input:function () {
|
||||
var ch = this._input[0];
|
||||
this.yytext+=ch;
|
||||
this.yyleng++;
|
||||
this.match+=ch;
|
||||
this.matched+=ch;
|
||||
var lines = ch.match(/\n/);
|
||||
if (lines) this.yylineno++;
|
||||
this._input = this._input.slice(1);
|
||||
return ch;
|
||||
},
|
||||
unput:function (ch) {
|
||||
this._input = ch + this._input;
|
||||
return this;
|
||||
},
|
||||
more:function () {
|
||||
this._more = true;
|
||||
return this;
|
||||
},
|
||||
less:function (n) {
|
||||
this._input = this.match.slice(n) + this._input;
|
||||
},
|
||||
pastInput:function () {
|
||||
var past = this.matched.substr(0, this.matched.length - this.match.length);
|
||||
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
|
||||
},
|
||||
upcomingInput:function () {
|
||||
var next = this.match;
|
||||
if (next.length < 20) {
|
||||
next += this._input.substr(0, 20-next.length);
|
||||
}
|
||||
return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, "");
|
||||
},
|
||||
showPosition:function () {
|
||||
var pre = this.pastInput();
|
||||
var c = new Array(pre.length + 1).join("-");
|
||||
return pre + this.upcomingInput() + "\n" + c+"^";
|
||||
},
|
||||
next:function () {
|
||||
if (this.done) {
|
||||
return this.EOF;
|
||||
}
|
||||
if (!this._input) this.done = true;
|
||||
|
||||
var token,
|
||||
match,
|
||||
tempMatch,
|
||||
index,
|
||||
col,
|
||||
lines;
|
||||
if (!this._more) {
|
||||
this.yytext = '';
|
||||
this.match = '';
|
||||
}
|
||||
var rules = this._currentRules();
|
||||
for (var i=0;i < rules.length; i++) {
|
||||
tempMatch = this._input.match(this.rules[rules[i]]);
|
||||
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
||||
match = tempMatch;
|
||||
index = i;
|
||||
if (!this.options.flex) break;
|
||||
}
|
||||
}
|
||||
if (match) {
|
||||
lines = match[0].match(/\n.*/g);
|
||||
if (lines) this.yylineno += lines.length;
|
||||
this.yylloc = {first_line: this.yylloc.last_line,
|
||||
last_line: this.yylineno+1,
|
||||
first_column: this.yylloc.last_column,
|
||||
last_column: lines ? lines[lines.length-1].length-1 : this.yylloc.last_column + match[0].length}
|
||||
this.yytext += match[0];
|
||||
this.match += match[0];
|
||||
this.yyleng = this.yytext.length;
|
||||
this._more = false;
|
||||
this._input = this._input.slice(match[0].length);
|
||||
this.matched += match[0];
|
||||
token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]);
|
||||
if (this.done && this._input) this.done = false;
|
||||
if (token) return token;
|
||||
else return;
|
||||
}
|
||||
if (this._input === "") {
|
||||
return this.EOF;
|
||||
} else {
|
||||
this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
|
||||
{text: "", token: null, line: this.yylineno});
|
||||
}
|
||||
},
|
||||
lex:function lex() {
|
||||
var r = this.next();
|
||||
if (typeof r !== 'undefined') {
|
||||
return r;
|
||||
} else {
|
||||
return this.lex();
|
||||
}
|
||||
},
|
||||
begin:function begin(condition) {
|
||||
this.conditionStack.push(condition);
|
||||
},
|
||||
popState:function popState() {
|
||||
return this.conditionStack.pop();
|
||||
},
|
||||
_currentRules:function _currentRules() {
|
||||
return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;
|
||||
},
|
||||
topState:function () {
|
||||
return this.conditionStack[this.conditionStack.length-2];
|
||||
},
|
||||
pushState:function begin(condition) {
|
||||
this.begin(condition);
|
||||
}});
|
||||
lexer.options = {};
|
||||
lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
|
||||
|
||||
var YYSTATE=YY_START
|
||||
switch($avoiding_name_collisions) {
|
||||
case 0:/* skip whitespace */
|
||||
break;
|
||||
case 1:return 6
|
||||
break;
|
||||
case 2:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2); return 4
|
||||
break;
|
||||
case 3:return 17
|
||||
break;
|
||||
case 4:return 18
|
||||
break;
|
||||
case 5:return 23
|
||||
break;
|
||||
case 6:return 24
|
||||
break;
|
||||
case 7:return 22
|
||||
break;
|
||||
case 8:return 21
|
||||
break;
|
||||
case 9:return 10
|
||||
break;
|
||||
case 10:return 11
|
||||
break;
|
||||
case 11:return 8
|
||||
break;
|
||||
case 12:return 14
|
||||
break;
|
||||
case 13:return 'INVALID'
|
||||
break;
|
||||
}
|
||||
};
|
||||
lexer.rules = [/^(?:\s+)/,/^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/,/^(?:"(?:\\[\\"bfnrt/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/,/^(?:\{)/,/^(?:\})/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?::)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:null\b)/,/^(?:$)/,/^(?:.)/];
|
||||
lexer.conditions = {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13],"inclusive":true}};
|
||||
|
||||
|
||||
;
|
||||
return lexer;})()
|
||||
parser.lexer = lexer;
|
||||
return parser;
|
||||
})();
|
||||
if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
|
||||
exports.parser = jsonlint;
|
||||
exports.parse = function () { return jsonlint.parse.apply(jsonlint, arguments); }
|
||||
exports.main = function commonjsMain(args) {
|
||||
if (!args[1])
|
||||
throw new Error('Usage: '+args[0]+' FILE');
|
||||
if (typeof process !== 'undefined') {
|
||||
var source = require('fs').readFileSync(require('path').join(process.cwd(), args[1]), "utf8");
|
||||
} else {
|
||||
var cwd = require("file").path(require("file").cwd());
|
||||
var source = cwd.join(args[1]).read({charset: "utf-8"});
|
||||
}
|
||||
return exports.parser.parse(source);
|
||||
}
|
||||
if (typeof module !== 'undefined' && require.main === module) {
|
||||
exports.main(typeof process !== 'undefined' ? process.argv.slice(1) : require("system").args);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+1
-1
File diff suppressed because one or more lines are too long
@@ -1,444 +1,444 @@
|
||||
/**
|
||||
* Handles the addition of the comment form.
|
||||
*
|
||||
* @since 2.7.0
|
||||
* @output wp-includes/js/comment-reply.js
|
||||
*
|
||||
* @namespace addComment
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
window.addComment = ( function( window ) {
|
||||
// Avoid scope lookups on commonly used variables.
|
||||
var document = window.document;
|
||||
|
||||
// Settings.
|
||||
var config = {
|
||||
commentReplyClass : 'comment-reply-link',
|
||||
commentReplyTitleId : 'reply-title',
|
||||
cancelReplyId : 'cancel-comment-reply-link',
|
||||
commentFormId : 'commentform',
|
||||
temporaryFormId : 'wp-temp-form-div',
|
||||
parentIdFieldId : 'comment_parent',
|
||||
postIdFieldId : 'comment_post_ID'
|
||||
};
|
||||
|
||||
// Cross browser MutationObserver.
|
||||
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
|
||||
|
||||
// Check browser cuts the mustard.
|
||||
var cutsTheMustard = 'querySelector' in document && 'addEventListener' in window;
|
||||
|
||||
/*
|
||||
* Check browser supports dataset.
|
||||
* !! sets the variable to true if the property exists.
|
||||
*/
|
||||
var supportsDataset = !! document.documentElement.dataset;
|
||||
|
||||
// For holding the cancel element.
|
||||
var cancelElement;
|
||||
|
||||
// For holding the comment form element.
|
||||
var commentFormElement;
|
||||
|
||||
// The respond element.
|
||||
var respondElement;
|
||||
|
||||
// The mutation observer.
|
||||
var observer;
|
||||
|
||||
if ( cutsTheMustard && document.readyState !== 'loading' ) {
|
||||
ready();
|
||||
} else if ( cutsTheMustard ) {
|
||||
window.addEventListener( 'DOMContentLoaded', ready, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up object variables after the DOM is ready.
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
function ready() {
|
||||
// Initialize the events.
|
||||
init();
|
||||
|
||||
// Set up a MutationObserver to check for comments loaded late.
|
||||
observeChanges();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add events to links classed .comment-reply-link.
|
||||
*
|
||||
* Searches the context for reply links and adds the JavaScript events
|
||||
* required to move the comment form. To allow for lazy loading of
|
||||
* comments this method is exposed as window.commentReply.init().
|
||||
*
|
||||
* @since 5.1.0
|
||||
*
|
||||
* @memberOf addComment
|
||||
*
|
||||
* @param {HTMLElement} context The parent DOM element to search for links.
|
||||
*/
|
||||
function init( context ) {
|
||||
if ( ! cutsTheMustard ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get required elements.
|
||||
cancelElement = getElementById( config.cancelReplyId );
|
||||
commentFormElement = getElementById( config.commentFormId );
|
||||
|
||||
// No cancel element, no replies.
|
||||
if ( ! cancelElement ) {
|
||||
return;
|
||||
}
|
||||
|
||||
cancelElement.addEventListener( 'touchstart', cancelEvent );
|
||||
cancelElement.addEventListener( 'click', cancelEvent );
|
||||
|
||||
// Submit the comment form when the user types [Ctrl] or [Cmd] + [Enter].
|
||||
var submitFormHandler = function( e ) {
|
||||
if ( ( e.metaKey || e.ctrlKey ) && e.keyCode === 13 ) {
|
||||
commentFormElement.removeEventListener( 'keydown', submitFormHandler );
|
||||
e.preventDefault();
|
||||
// The submit button ID is 'submit' so we can't call commentFormElement.submit(). Click it instead.
|
||||
commentFormElement.submit.click();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
if ( commentFormElement ) {
|
||||
commentFormElement.addEventListener( 'keydown', submitFormHandler );
|
||||
}
|
||||
|
||||
var links = replyLinks( context );
|
||||
var element;
|
||||
|
||||
for ( var i = 0, l = links.length; i < l; i++ ) {
|
||||
element = links[i];
|
||||
|
||||
element.addEventListener( 'touchstart', clickEvent );
|
||||
element.addEventListener( 'click', clickEvent );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all links classed .comment-reply-link.
|
||||
*
|
||||
* @since 5.1.0
|
||||
*
|
||||
* @param {HTMLElement} context The parent DOM element to search for links.
|
||||
*
|
||||
* @return {HTMLCollection|NodeList|Array}
|
||||
*/
|
||||
function replyLinks( context ) {
|
||||
var selectorClass = config.commentReplyClass;
|
||||
var allReplyLinks;
|
||||
|
||||
// childNodes is a handy check to ensure the context is a HTMLElement.
|
||||
if ( ! context || ! context.childNodes ) {
|
||||
context = document;
|
||||
}
|
||||
|
||||
if ( document.getElementsByClassName ) {
|
||||
// Fastest.
|
||||
allReplyLinks = context.getElementsByClassName( selectorClass );
|
||||
}
|
||||
else {
|
||||
// Fast.
|
||||
allReplyLinks = context.querySelectorAll( '.' + selectorClass );
|
||||
}
|
||||
|
||||
return allReplyLinks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel event handler.
|
||||
*
|
||||
* @since 5.1.0
|
||||
*
|
||||
* @param {Event} event The calling event.
|
||||
*/
|
||||
function cancelEvent( event ) {
|
||||
var cancelLink = this;
|
||||
var temporaryFormId = config.temporaryFormId;
|
||||
var temporaryElement = getElementById( temporaryFormId );
|
||||
|
||||
if ( ! temporaryElement || ! respondElement ) {
|
||||
// Conditions for cancel link fail.
|
||||
return;
|
||||
}
|
||||
|
||||
getElementById( config.parentIdFieldId ).value = '0';
|
||||
|
||||
// Move the respond form back in place of the temporary element.
|
||||
var headingText = temporaryElement.textContent;
|
||||
temporaryElement.parentNode.replaceChild( respondElement, temporaryElement );
|
||||
cancelLink.style.display = 'none';
|
||||
|
||||
var replyHeadingElement = getElementById( config.commentReplyTitleId );
|
||||
var replyHeadingTextNode = replyHeadingElement && replyHeadingElement.firstChild;
|
||||
var replyLinkToParent = replyHeadingTextNode && replyHeadingTextNode.nextSibling;
|
||||
|
||||
if ( replyHeadingTextNode && replyHeadingTextNode.nodeType === Node.TEXT_NODE && headingText ) {
|
||||
if ( replyLinkToParent && 'A' === replyLinkToParent.nodeName && replyLinkToParent.id !== config.cancelReplyId ) {
|
||||
replyLinkToParent.style.display = '';
|
||||
}
|
||||
|
||||
replyHeadingTextNode.textContent = headingText;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
/**
|
||||
* Click event handler.
|
||||
*
|
||||
* @since 5.1.0
|
||||
*
|
||||
* @param {Event} event The calling event.
|
||||
*/
|
||||
function clickEvent( event ) {
|
||||
var replyNode = getElementById( config.commentReplyTitleId );
|
||||
var defaultReplyHeading = replyNode && replyNode.firstChild.textContent;
|
||||
var replyLink = this,
|
||||
commId = getDataAttribute( replyLink, 'belowelement' ),
|
||||
parentId = getDataAttribute( replyLink, 'commentid' ),
|
||||
respondId = getDataAttribute( replyLink, 'respondelement' ),
|
||||
postId = getDataAttribute( replyLink, 'postid' ),
|
||||
replyTo = getDataAttribute( replyLink, 'replyto' ) || defaultReplyHeading,
|
||||
follow;
|
||||
|
||||
if ( ! commId || ! parentId || ! respondId || ! postId ) {
|
||||
/*
|
||||
* Theme or plugin defines own link via custom `wp_list_comments()` callback
|
||||
* and calls `moveForm()` either directly or via a custom event hook.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Third party comments systems can hook into this function via the global scope,
|
||||
* therefore the click event needs to reference the global scope.
|
||||
*/
|
||||
follow = window.addComment.moveForm( commId, parentId, respondId, postId, replyTo );
|
||||
if ( false === follow ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a mutation observer to check for newly inserted comments.
|
||||
*
|
||||
* @since 5.1.0
|
||||
*/
|
||||
function observeChanges() {
|
||||
if ( ! MutationObserver ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var observerOptions = {
|
||||
childList: true,
|
||||
subtree: true
|
||||
};
|
||||
|
||||
observer = new MutationObserver( handleChanges );
|
||||
observer.observe( document.body, observerOptions );
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles DOM changes, calling init() if any new nodes are added.
|
||||
*
|
||||
* @since 5.1.0
|
||||
*
|
||||
* @param {Array} mutationRecords Array of MutationRecord objects.
|
||||
*/
|
||||
function handleChanges( mutationRecords ) {
|
||||
var i = mutationRecords.length;
|
||||
|
||||
while ( i-- ) {
|
||||
// Call init() once if any record in this set adds nodes.
|
||||
if ( mutationRecords[ i ].addedNodes.length ) {
|
||||
init();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Backward compatible getter of data-* attribute.
|
||||
*
|
||||
* Uses element.dataset if it exists, otherwise uses getAttribute.
|
||||
*
|
||||
* @since 5.1.0
|
||||
*
|
||||
* @param {HTMLElement} Element DOM element with the attribute.
|
||||
* @param {string} Attribute the attribute to get.
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
function getDataAttribute( element, attribute ) {
|
||||
if ( supportsDataset ) {
|
||||
return element.dataset[attribute];
|
||||
}
|
||||
else {
|
||||
return element.getAttribute( 'data-' + attribute );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get element by ID.
|
||||
*
|
||||
* Local alias for document.getElementById.
|
||||
*
|
||||
* @since 5.1.0
|
||||
*
|
||||
* @param {HTMLElement} The requested element.
|
||||
*/
|
||||
function getElementById( elementId ) {
|
||||
return document.getElementById( elementId );
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the reply form from its current position to the reply location.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @memberOf addComment
|
||||
*
|
||||
* @param {string} addBelowId HTML ID of element the form follows.
|
||||
* @param {string} commentId Database ID of comment being replied to.
|
||||
* @param {string} respondId HTML ID of 'respond' element.
|
||||
* @param {string} postId Database ID of the post.
|
||||
* @param {string} replyTo Form heading content.
|
||||
*/
|
||||
function moveForm( addBelowId, commentId, respondId, postId, replyTo ) {
|
||||
// Get elements based on their IDs.
|
||||
var addBelowElement = getElementById( addBelowId );
|
||||
respondElement = getElementById( respondId );
|
||||
|
||||
// Get the hidden fields.
|
||||
var parentIdField = getElementById( config.parentIdFieldId );
|
||||
var postIdField = getElementById( config.postIdFieldId );
|
||||
var element, cssHidden, style;
|
||||
|
||||
var replyHeading = getElementById( config.commentReplyTitleId );
|
||||
var replyHeadingTextNode = replyHeading && replyHeading.firstChild;
|
||||
var replyLinkToParent = replyHeadingTextNode && replyHeadingTextNode.nextSibling;
|
||||
|
||||
if ( ! addBelowElement || ! respondElement || ! parentIdField ) {
|
||||
// Missing key elements, fail.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'undefined' === typeof replyTo ) {
|
||||
replyTo = replyHeadingTextNode && replyHeadingTextNode.textContent;
|
||||
}
|
||||
|
||||
addPlaceHolder( respondElement );
|
||||
|
||||
// Set the value of the post.
|
||||
if ( postId && postIdField ) {
|
||||
postIdField.value = postId;
|
||||
}
|
||||
|
||||
parentIdField.value = commentId;
|
||||
|
||||
cancelElement.style.display = '';
|
||||
addBelowElement.parentNode.insertBefore( respondElement, addBelowElement.nextSibling );
|
||||
|
||||
if ( replyHeadingTextNode && replyHeadingTextNode.nodeType === Node.TEXT_NODE ) {
|
||||
if ( replyLinkToParent && 'A' === replyLinkToParent.nodeName && replyLinkToParent.id !== config.cancelReplyId ) {
|
||||
replyLinkToParent.style.display = 'none';
|
||||
}
|
||||
|
||||
replyHeadingTextNode.textContent = replyTo;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is for backward compatibility with third party commenting systems
|
||||
* hooking into the event using older techniques.
|
||||
*/
|
||||
cancelElement.onclick = function() {
|
||||
return false;
|
||||
};
|
||||
|
||||
// Focus on the first field in the comment form.
|
||||
try {
|
||||
for ( var i = 0; i < commentFormElement.elements.length; i++ ) {
|
||||
element = commentFormElement.elements[i];
|
||||
cssHidden = false;
|
||||
|
||||
// Get elements computed style.
|
||||
if ( 'getComputedStyle' in window ) {
|
||||
// Modern browsers.
|
||||
style = window.getComputedStyle( element );
|
||||
} else if ( document.documentElement.currentStyle ) {
|
||||
// IE 8.
|
||||
style = element.currentStyle;
|
||||
}
|
||||
|
||||
/*
|
||||
* For display none, do the same thing jQuery does. For visibility,
|
||||
* check the element computed style since browsers are already doing
|
||||
* the job for us. In fact, the visibility computed style is the actual
|
||||
* computed value and already takes into account the element ancestors.
|
||||
*/
|
||||
if ( ( element.offsetWidth <= 0 && element.offsetHeight <= 0 ) || style.visibility === 'hidden' ) {
|
||||
cssHidden = true;
|
||||
}
|
||||
|
||||
// Skip form elements that are hidden or disabled.
|
||||
if ( 'hidden' === element.type || element.disabled || cssHidden ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
element.focus();
|
||||
// Stop after the first focusable element.
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* false is returned for backward compatibility with third party commenting systems
|
||||
* hooking into this function.
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add placeholder element.
|
||||
*
|
||||
* Places a place holder element above the #respond element for
|
||||
* the form to be returned to if needs be.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param {HTMLelement} respondElement the #respond element holding comment form.
|
||||
*/
|
||||
function addPlaceHolder( respondElement ) {
|
||||
var temporaryFormId = config.temporaryFormId;
|
||||
var temporaryElement = getElementById( temporaryFormId );
|
||||
var replyElement = getElementById( config.commentReplyTitleId );
|
||||
var initialHeadingText = replyElement ? replyElement.firstChild.textContent : '';
|
||||
|
||||
if ( temporaryElement ) {
|
||||
// The element already exists, no need to recreate.
|
||||
return;
|
||||
}
|
||||
|
||||
temporaryElement = document.createElement( 'div' );
|
||||
temporaryElement.id = temporaryFormId;
|
||||
temporaryElement.style.display = 'none';
|
||||
temporaryElement.textContent = initialHeadingText;
|
||||
respondElement.parentNode.insertBefore( temporaryElement, respondElement );
|
||||
}
|
||||
|
||||
return {
|
||||
init: init,
|
||||
moveForm: moveForm
|
||||
};
|
||||
})( window );
|
||||
/**
|
||||
* Handles the addition of the comment form.
|
||||
*
|
||||
* @since 2.7.0
|
||||
* @output wp-includes/js/comment-reply.js
|
||||
*
|
||||
* @namespace addComment
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
window.addComment = ( function( window ) {
|
||||
// Avoid scope lookups on commonly used variables.
|
||||
var document = window.document;
|
||||
|
||||
// Settings.
|
||||
var config = {
|
||||
commentReplyClass : 'comment-reply-link',
|
||||
commentReplyTitleId : 'reply-title',
|
||||
cancelReplyId : 'cancel-comment-reply-link',
|
||||
commentFormId : 'commentform',
|
||||
temporaryFormId : 'wp-temp-form-div',
|
||||
parentIdFieldId : 'comment_parent',
|
||||
postIdFieldId : 'comment_post_ID'
|
||||
};
|
||||
|
||||
// Cross browser MutationObserver.
|
||||
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
|
||||
|
||||
// Check browser cuts the mustard.
|
||||
var cutsTheMustard = 'querySelector' in document && 'addEventListener' in window;
|
||||
|
||||
/*
|
||||
* Check browser supports dataset.
|
||||
* !! sets the variable to true if the property exists.
|
||||
*/
|
||||
var supportsDataset = !! document.documentElement.dataset;
|
||||
|
||||
// For holding the cancel element.
|
||||
var cancelElement;
|
||||
|
||||
// For holding the comment form element.
|
||||
var commentFormElement;
|
||||
|
||||
// The respond element.
|
||||
var respondElement;
|
||||
|
||||
// The mutation observer.
|
||||
var observer;
|
||||
|
||||
if ( cutsTheMustard && document.readyState !== 'loading' ) {
|
||||
ready();
|
||||
} else if ( cutsTheMustard ) {
|
||||
window.addEventListener( 'DOMContentLoaded', ready, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up object variables after the DOM is ready.
|
||||
*
|
||||
* @since 5.1.1
|
||||
*/
|
||||
function ready() {
|
||||
// Initialize the events.
|
||||
init();
|
||||
|
||||
// Set up a MutationObserver to check for comments loaded late.
|
||||
observeChanges();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add events to links classed .comment-reply-link.
|
||||
*
|
||||
* Searches the context for reply links and adds the JavaScript events
|
||||
* required to move the comment form. To allow for lazy loading of
|
||||
* comments this method is exposed as window.commentReply.init().
|
||||
*
|
||||
* @since 5.1.0
|
||||
*
|
||||
* @memberOf addComment
|
||||
*
|
||||
* @param {HTMLElement} context The parent DOM element to search for links.
|
||||
*/
|
||||
function init( context ) {
|
||||
if ( ! cutsTheMustard ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get required elements.
|
||||
cancelElement = getElementById( config.cancelReplyId );
|
||||
commentFormElement = getElementById( config.commentFormId );
|
||||
|
||||
// No cancel element, no replies.
|
||||
if ( ! cancelElement ) {
|
||||
return;
|
||||
}
|
||||
|
||||
cancelElement.addEventListener( 'touchstart', cancelEvent );
|
||||
cancelElement.addEventListener( 'click', cancelEvent );
|
||||
|
||||
// Submit the comment form when the user types [Ctrl] or [Cmd] + [Enter].
|
||||
var submitFormHandler = function( e ) {
|
||||
if ( ( e.metaKey || e.ctrlKey ) && e.keyCode === 13 ) {
|
||||
commentFormElement.removeEventListener( 'keydown', submitFormHandler );
|
||||
e.preventDefault();
|
||||
// The submit button ID is 'submit' so we can't call commentFormElement.submit(). Click it instead.
|
||||
commentFormElement.submit.click();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
if ( commentFormElement ) {
|
||||
commentFormElement.addEventListener( 'keydown', submitFormHandler );
|
||||
}
|
||||
|
||||
var links = replyLinks( context );
|
||||
var element;
|
||||
|
||||
for ( var i = 0, l = links.length; i < l; i++ ) {
|
||||
element = links[i];
|
||||
|
||||
element.addEventListener( 'touchstart', clickEvent );
|
||||
element.addEventListener( 'click', clickEvent );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all links classed .comment-reply-link.
|
||||
*
|
||||
* @since 5.1.0
|
||||
*
|
||||
* @param {HTMLElement} context The parent DOM element to search for links.
|
||||
*
|
||||
* @return {HTMLCollection|NodeList|Array}
|
||||
*/
|
||||
function replyLinks( context ) {
|
||||
var selectorClass = config.commentReplyClass;
|
||||
var allReplyLinks;
|
||||
|
||||
// childNodes is a handy check to ensure the context is a HTMLElement.
|
||||
if ( ! context || ! context.childNodes ) {
|
||||
context = document;
|
||||
}
|
||||
|
||||
if ( document.getElementsByClassName ) {
|
||||
// Fastest.
|
||||
allReplyLinks = context.getElementsByClassName( selectorClass );
|
||||
}
|
||||
else {
|
||||
// Fast.
|
||||
allReplyLinks = context.querySelectorAll( '.' + selectorClass );
|
||||
}
|
||||
|
||||
return allReplyLinks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel event handler.
|
||||
*
|
||||
* @since 5.1.0
|
||||
*
|
||||
* @param {Event} event The calling event.
|
||||
*/
|
||||
function cancelEvent( event ) {
|
||||
var cancelLink = this;
|
||||
var temporaryFormId = config.temporaryFormId;
|
||||
var temporaryElement = getElementById( temporaryFormId );
|
||||
|
||||
if ( ! temporaryElement || ! respondElement ) {
|
||||
// Conditions for cancel link fail.
|
||||
return;
|
||||
}
|
||||
|
||||
getElementById( config.parentIdFieldId ).value = '0';
|
||||
|
||||
// Move the respond form back in place of the temporary element.
|
||||
var headingText = temporaryElement.textContent;
|
||||
temporaryElement.parentNode.replaceChild( respondElement, temporaryElement );
|
||||
cancelLink.style.display = 'none';
|
||||
|
||||
var replyHeadingElement = getElementById( config.commentReplyTitleId );
|
||||
var replyHeadingTextNode = replyHeadingElement && replyHeadingElement.firstChild;
|
||||
var replyLinkToParent = replyHeadingTextNode && replyHeadingTextNode.nextSibling;
|
||||
|
||||
if ( replyHeadingTextNode && replyHeadingTextNode.nodeType === Node.TEXT_NODE && headingText ) {
|
||||
if ( replyLinkToParent && 'A' === replyLinkToParent.nodeName && replyLinkToParent.id !== config.cancelReplyId ) {
|
||||
replyLinkToParent.style.display = '';
|
||||
}
|
||||
|
||||
replyHeadingTextNode.textContent = headingText;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
/**
|
||||
* Click event handler.
|
||||
*
|
||||
* @since 5.1.0
|
||||
*
|
||||
* @param {Event} event The calling event.
|
||||
*/
|
||||
function clickEvent( event ) {
|
||||
var replyNode = getElementById( config.commentReplyTitleId );
|
||||
var defaultReplyHeading = replyNode && replyNode.firstChild.textContent;
|
||||
var replyLink = this,
|
||||
commId = getDataAttribute( replyLink, 'belowelement' ),
|
||||
parentId = getDataAttribute( replyLink, 'commentid' ),
|
||||
respondId = getDataAttribute( replyLink, 'respondelement' ),
|
||||
postId = getDataAttribute( replyLink, 'postid' ),
|
||||
replyTo = getDataAttribute( replyLink, 'replyto' ) || defaultReplyHeading,
|
||||
follow;
|
||||
|
||||
if ( ! commId || ! parentId || ! respondId || ! postId ) {
|
||||
/*
|
||||
* Theme or plugin defines own link via custom `wp_list_comments()` callback
|
||||
* and calls `moveForm()` either directly or via a custom event hook.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Third party comments systems can hook into this function via the global scope,
|
||||
* therefore the click event needs to reference the global scope.
|
||||
*/
|
||||
follow = window.addComment.moveForm( commId, parentId, respondId, postId, replyTo );
|
||||
if ( false === follow ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a mutation observer to check for newly inserted comments.
|
||||
*
|
||||
* @since 5.1.0
|
||||
*/
|
||||
function observeChanges() {
|
||||
if ( ! MutationObserver ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var observerOptions = {
|
||||
childList: true,
|
||||
subtree: true
|
||||
};
|
||||
|
||||
observer = new MutationObserver( handleChanges );
|
||||
observer.observe( document.body, observerOptions );
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles DOM changes, calling init() if any new nodes are added.
|
||||
*
|
||||
* @since 5.1.0
|
||||
*
|
||||
* @param {Array} mutationRecords Array of MutationRecord objects.
|
||||
*/
|
||||
function handleChanges( mutationRecords ) {
|
||||
var i = mutationRecords.length;
|
||||
|
||||
while ( i-- ) {
|
||||
// Call init() once if any record in this set adds nodes.
|
||||
if ( mutationRecords[ i ].addedNodes.length ) {
|
||||
init();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Backward compatible getter of data-* attribute.
|
||||
*
|
||||
* Uses element.dataset if it exists, otherwise uses getAttribute.
|
||||
*
|
||||
* @since 5.1.0
|
||||
*
|
||||
* @param {HTMLElement} Element DOM element with the attribute.
|
||||
* @param {string} Attribute the attribute to get.
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
function getDataAttribute( element, attribute ) {
|
||||
if ( supportsDataset ) {
|
||||
return element.dataset[attribute];
|
||||
}
|
||||
else {
|
||||
return element.getAttribute( 'data-' + attribute );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get element by ID.
|
||||
*
|
||||
* Local alias for document.getElementById.
|
||||
*
|
||||
* @since 5.1.0
|
||||
*
|
||||
* @param {HTMLElement} The requested element.
|
||||
*/
|
||||
function getElementById( elementId ) {
|
||||
return document.getElementById( elementId );
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the reply form from its current position to the reply location.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @memberOf addComment
|
||||
*
|
||||
* @param {string} addBelowId HTML ID of element the form follows.
|
||||
* @param {string} commentId Database ID of comment being replied to.
|
||||
* @param {string} respondId HTML ID of 'respond' element.
|
||||
* @param {string} postId Database ID of the post.
|
||||
* @param {string} replyTo Form heading content.
|
||||
*/
|
||||
function moveForm( addBelowId, commentId, respondId, postId, replyTo ) {
|
||||
// Get elements based on their IDs.
|
||||
var addBelowElement = getElementById( addBelowId );
|
||||
respondElement = getElementById( respondId );
|
||||
|
||||
// Get the hidden fields.
|
||||
var parentIdField = getElementById( config.parentIdFieldId );
|
||||
var postIdField = getElementById( config.postIdFieldId );
|
||||
var element, cssHidden, style;
|
||||
|
||||
var replyHeading = getElementById( config.commentReplyTitleId );
|
||||
var replyHeadingTextNode = replyHeading && replyHeading.firstChild;
|
||||
var replyLinkToParent = replyHeadingTextNode && replyHeadingTextNode.nextSibling;
|
||||
|
||||
if ( ! addBelowElement || ! respondElement || ! parentIdField ) {
|
||||
// Missing key elements, fail.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'undefined' === typeof replyTo ) {
|
||||
replyTo = replyHeadingTextNode && replyHeadingTextNode.textContent;
|
||||
}
|
||||
|
||||
addPlaceHolder( respondElement );
|
||||
|
||||
// Set the value of the post.
|
||||
if ( postId && postIdField ) {
|
||||
postIdField.value = postId;
|
||||
}
|
||||
|
||||
parentIdField.value = commentId;
|
||||
|
||||
cancelElement.style.display = '';
|
||||
addBelowElement.parentNode.insertBefore( respondElement, addBelowElement.nextSibling );
|
||||
|
||||
if ( replyHeadingTextNode && replyHeadingTextNode.nodeType === Node.TEXT_NODE ) {
|
||||
if ( replyLinkToParent && 'A' === replyLinkToParent.nodeName && replyLinkToParent.id !== config.cancelReplyId ) {
|
||||
replyLinkToParent.style.display = 'none';
|
||||
}
|
||||
|
||||
replyHeadingTextNode.textContent = replyTo;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is for backward compatibility with third party commenting systems
|
||||
* hooking into the event using older techniques.
|
||||
*/
|
||||
cancelElement.onclick = function() {
|
||||
return false;
|
||||
};
|
||||
|
||||
// Focus on the first field in the comment form.
|
||||
try {
|
||||
for ( var i = 0; i < commentFormElement.elements.length; i++ ) {
|
||||
element = commentFormElement.elements[i];
|
||||
cssHidden = false;
|
||||
|
||||
// Get elements computed style.
|
||||
if ( 'getComputedStyle' in window ) {
|
||||
// Modern browsers.
|
||||
style = window.getComputedStyle( element );
|
||||
} else if ( document.documentElement.currentStyle ) {
|
||||
// IE 8.
|
||||
style = element.currentStyle;
|
||||
}
|
||||
|
||||
/*
|
||||
* For display none, do the same thing jQuery does. For visibility,
|
||||
* check the element computed style since browsers are already doing
|
||||
* the job for us. In fact, the visibility computed style is the actual
|
||||
* computed value and already takes into account the element ancestors.
|
||||
*/
|
||||
if ( ( element.offsetWidth <= 0 && element.offsetHeight <= 0 ) || style.visibility === 'hidden' ) {
|
||||
cssHidden = true;
|
||||
}
|
||||
|
||||
// Skip form elements that are hidden or disabled.
|
||||
if ( 'hidden' === element.type || element.disabled || cssHidden ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
element.focus();
|
||||
// Stop after the first focusable element.
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* false is returned for backward compatibility with third party commenting systems
|
||||
* hooking into this function.
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add placeholder element.
|
||||
*
|
||||
* Places a place holder element above the #respond element for
|
||||
* the form to be returned to if needs be.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param {HTMLelement} respondElement the #respond element holding comment form.
|
||||
*/
|
||||
function addPlaceHolder( respondElement ) {
|
||||
var temporaryFormId = config.temporaryFormId;
|
||||
var temporaryElement = getElementById( temporaryFormId );
|
||||
var replyElement = getElementById( config.commentReplyTitleId );
|
||||
var initialHeadingText = replyElement ? replyElement.firstChild.textContent : '';
|
||||
|
||||
if ( temporaryElement ) {
|
||||
// The element already exists, no need to recreate.
|
||||
return;
|
||||
}
|
||||
|
||||
temporaryElement = document.createElement( 'div' );
|
||||
temporaryElement.id = temporaryFormId;
|
||||
temporaryElement.style.display = 'none';
|
||||
temporaryElement.textContent = initialHeadingText;
|
||||
respondElement.parentNode.insertBefore( temporaryElement, respondElement );
|
||||
}
|
||||
|
||||
return {
|
||||
init: init,
|
||||
moveForm: moveForm
|
||||
};
|
||||
})( window );
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
/*! This file is auto-generated */
|
||||
window.addComment=function(v){var I,C,h,E=v.document,b={commentReplyClass:"comment-reply-link",commentReplyTitleId:"reply-title",cancelReplyId:"cancel-comment-reply-link",commentFormId:"commentform",temporaryFormId:"wp-temp-form-div",parentIdFieldId:"comment_parent",postIdFieldId:"comment_post_ID"},e=v.MutationObserver||v.WebKitMutationObserver||v.MozMutationObserver,r="querySelector"in E&&"addEventListener"in v,n=!!E.documentElement.dataset;function t(){d(),e&&new e(o).observe(E.body,{childList:!0,subtree:!0})}function d(e){if(r&&(I=g(b.cancelReplyId),C=g(b.commentFormId),I)){I.addEventListener("touchstart",l),I.addEventListener("click",l);function t(e){if((e.metaKey||e.ctrlKey)&&13===e.keyCode)return C.removeEventListener("keydown",t),e.preventDefault(),C.submit.click(),!1}C&&C.addEventListener("keydown",t);for(var n,d=function(e){var t=b.commentReplyClass;e&&e.childNodes||(e=E);e=E.getElementsByClassName?e.getElementsByClassName(t):e.querySelectorAll("."+t);return e}(e),o=0,i=d.length;o<i;o++)(n=d[o]).addEventListener("touchstart",a),n.addEventListener("click",a)}}function l(e){var t,n,d=g(b.temporaryFormId);d&&h&&(g(b.parentIdFieldId).value="0",t=d.textContent,d.parentNode.replaceChild(h,d),this.style.display="none",n=(d=(d=g(b.commentReplyTitleId))&&d.firstChild)&&d.nextSibling,d&&d.nodeType===Node.TEXT_NODE&&t&&(n&&"A"===n.nodeName&&n.id!==b.cancelReplyId&&(n.style.display=""),d.textContent=t),e.preventDefault())}function a(e){var t=g(b.commentReplyTitleId),t=t&&t.firstChild.textContent,n=this,d=m(n,"belowelement"),o=m(n,"commentid"),i=m(n,"respondelement"),r=m(n,"postid"),n=m(n,"replyto")||t;d&&o&&i&&r&&!1===v.addComment.moveForm(d,o,i,r,n)&&e.preventDefault()}function o(e){for(var t=e.length;t--;)if(e[t].addedNodes.length)return void d()}function m(e,t){return n?e.dataset[t]:e.getAttribute("data-"+t)}function g(e){return E.getElementById(e)}return r&&"loading"!==E.readyState?t():r&&v.addEventListener("DOMContentLoaded",t,!1),{init:d,moveForm:function(e,t,n,d,o){var i,r,l,a,m,c,s,e=g(e),n=(h=g(n),g(b.parentIdFieldId)),y=g(b.postIdFieldId),p=g(b.commentReplyTitleId),u=(p=p&&p.firstChild)&&p.nextSibling;if(e&&h&&n){void 0===o&&(o=p&&p.textContent),a=h,m=b.temporaryFormId,c=g(m),s=(s=g(b.commentReplyTitleId))?s.firstChild.textContent:"",c||((c=E.createElement("div")).id=m,c.style.display="none",c.textContent=s,a.parentNode.insertBefore(c,a)),d&&y&&(y.value=d),n.value=t,I.style.display="",e.parentNode.insertBefore(h,e.nextSibling),p&&p.nodeType===Node.TEXT_NODE&&(u&&"A"===u.nodeName&&u.id!==b.cancelReplyId&&(u.style.display="none"),p.textContent=o),I.onclick=function(){return!1};try{for(var f=0;f<C.elements.length;f++)if(i=C.elements[f],r=!1,"getComputedStyle"in v?l=v.getComputedStyle(i):E.documentElement.currentStyle&&(l=i.currentStyle),(i.offsetWidth<=0&&i.offsetHeight<=0||"hidden"===l.visibility)&&(r=!0),"hidden"!==i.type&&!i.disabled&&!r){i.focus();break}}catch(e){}return!1}}}}(window);
|
||||
@@ -1,165 +1,165 @@
|
||||
.imgCrop_wrap {
|
||||
/* width: 500px; @done_in_js */
|
||||
/* height: 375px; @done_in_js */
|
||||
position: relative;
|
||||
cursor: crosshair;
|
||||
}
|
||||
|
||||
/* an extra classname is applied for Opera < 9.0 to fix its lack of opacity support */
|
||||
.imgCrop_wrap.opera8 .imgCrop_overlay,
|
||||
.imgCrop_wrap.opera8 .imgCrop_clickArea {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/* fix for IE displaying all boxes at line-height by default, although they are still 1 pixel high until we combine them with the pointless span */
|
||||
.imgCrop_wrap,
|
||||
.imgCrop_wrap * {
|
||||
font-size: 0;
|
||||
}
|
||||
|
||||
.imgCrop_overlay {
|
||||
background-color: #000;
|
||||
opacity: 0.5;
|
||||
filter:alpha(opacity=50);
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.imgCrop_selArea {
|
||||
position: absolute;
|
||||
/* @done_in_js
|
||||
top: 20px;
|
||||
left: 20px;
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
background: transparent url(castle.jpg) no-repeat -210px -110px;
|
||||
*/
|
||||
cursor: move;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
/* clickArea is all a fix for IE 5.5 & 6 to allow the user to click on the given area */
|
||||
.imgCrop_clickArea {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #FFF;
|
||||
opacity: 0.01;
|
||||
filter:alpha(opacity=01);
|
||||
}
|
||||
|
||||
.imgCrop_marqueeHoriz {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 1px;
|
||||
background: transparent url(marqueeHoriz.gif) repeat-x 0 0;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.imgCrop_marqueeVert {
|
||||
position: absolute;
|
||||
height: 100%;
|
||||
width: 1px;
|
||||
background: transparent url(marqueeVert.gif) repeat-y 0 0;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.imgCrop_marqueeNorth { top: 0; left: 0; }
|
||||
.imgCrop_marqueeEast { top: 0; right: 0; }
|
||||
.imgCrop_marqueeSouth { bottom: 0px; left: 0; }
|
||||
.imgCrop_marqueeWest { top: 0; left: 0; }
|
||||
|
||||
|
||||
.imgCrop_handle {
|
||||
position: absolute;
|
||||
border: 1px solid #333;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
background: #FFF;
|
||||
opacity: 0.5;
|
||||
filter:alpha(opacity=50);
|
||||
z-index: 4;
|
||||
}
|
||||
|
||||
/* fix IE 5 box model */
|
||||
* html .imgCrop_handle {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
wid\th: 6px;
|
||||
hei\ght: 6px;
|
||||
}
|
||||
|
||||
.imgCrop_handleN {
|
||||
top: -3px;
|
||||
left: 0;
|
||||
/* margin-left: 49%; @done_in_js */
|
||||
cursor: n-resize;
|
||||
}
|
||||
|
||||
.imgCrop_handleNE {
|
||||
top: -3px;
|
||||
right: -3px;
|
||||
cursor: ne-resize;
|
||||
}
|
||||
|
||||
.imgCrop_handleE {
|
||||
top: 0;
|
||||
right: -3px;
|
||||
/* margin-top: 49%; @done_in_js */
|
||||
cursor: e-resize;
|
||||
}
|
||||
|
||||
.imgCrop_handleSE {
|
||||
right: -3px;
|
||||
bottom: -3px;
|
||||
cursor: se-resize;
|
||||
}
|
||||
|
||||
.imgCrop_handleS {
|
||||
right: 0;
|
||||
bottom: -3px;
|
||||
/* margin-right: 49%; @done_in_js */
|
||||
cursor: s-resize;
|
||||
}
|
||||
|
||||
.imgCrop_handleSW {
|
||||
left: -3px;
|
||||
bottom: -3px;
|
||||
cursor: sw-resize;
|
||||
}
|
||||
|
||||
.imgCrop_handleW {
|
||||
top: 0;
|
||||
left: -3px;
|
||||
/* margin-top: 49%; @done_in_js */
|
||||
cursor: e-resize;
|
||||
}
|
||||
|
||||
.imgCrop_handleNW {
|
||||
top: -3px;
|
||||
left: -3px;
|
||||
cursor: nw-resize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an area to click & drag around on as the default browser behaviour is to let you drag the image
|
||||
*/
|
||||
.imgCrop_dragArea {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 200;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.imgCrop_previewWrap {
|
||||
/* width: 200px; @done_in_js */
|
||||
/* height: 200px; @done_in_js */
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.imgCrop_previewWrap img {
|
||||
position: absolute;
|
||||
.imgCrop_wrap {
|
||||
/* width: 500px; @done_in_js */
|
||||
/* height: 375px; @done_in_js */
|
||||
position: relative;
|
||||
cursor: crosshair;
|
||||
}
|
||||
|
||||
/* an extra classname is applied for Opera < 9.0 to fix its lack of opacity support */
|
||||
.imgCrop_wrap.opera8 .imgCrop_overlay,
|
||||
.imgCrop_wrap.opera8 .imgCrop_clickArea {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/* fix for IE displaying all boxes at line-height by default, although they are still 1 pixel high until we combine them with the pointless span */
|
||||
.imgCrop_wrap,
|
||||
.imgCrop_wrap * {
|
||||
font-size: 0;
|
||||
}
|
||||
|
||||
.imgCrop_overlay {
|
||||
background-color: #000;
|
||||
opacity: 0.5;
|
||||
filter:alpha(opacity=50);
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.imgCrop_selArea {
|
||||
position: absolute;
|
||||
/* @done_in_js
|
||||
top: 20px;
|
||||
left: 20px;
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
background: transparent url(castle.jpg) no-repeat -210px -110px;
|
||||
*/
|
||||
cursor: move;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
/* clickArea is all a fix for IE 5.5 & 6 to allow the user to click on the given area */
|
||||
.imgCrop_clickArea {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: #FFF;
|
||||
opacity: 0.01;
|
||||
filter:alpha(opacity=01);
|
||||
}
|
||||
|
||||
.imgCrop_marqueeHoriz {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 1px;
|
||||
background: transparent url(marqueeHoriz.gif) repeat-x 0 0;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.imgCrop_marqueeVert {
|
||||
position: absolute;
|
||||
height: 100%;
|
||||
width: 1px;
|
||||
background: transparent url(marqueeVert.gif) repeat-y 0 0;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.imgCrop_marqueeNorth { top: 0; left: 0; }
|
||||
.imgCrop_marqueeEast { top: 0; right: 0; }
|
||||
.imgCrop_marqueeSouth { bottom: 0px; left: 0; }
|
||||
.imgCrop_marqueeWest { top: 0; left: 0; }
|
||||
|
||||
|
||||
.imgCrop_handle {
|
||||
position: absolute;
|
||||
border: 1px solid #333;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
background: #FFF;
|
||||
opacity: 0.5;
|
||||
filter:alpha(opacity=50);
|
||||
z-index: 4;
|
||||
}
|
||||
|
||||
/* fix IE 5 box model */
|
||||
* html .imgCrop_handle {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
wid\th: 6px;
|
||||
hei\ght: 6px;
|
||||
}
|
||||
|
||||
.imgCrop_handleN {
|
||||
top: -3px;
|
||||
left: 0;
|
||||
/* margin-left: 49%; @done_in_js */
|
||||
cursor: n-resize;
|
||||
}
|
||||
|
||||
.imgCrop_handleNE {
|
||||
top: -3px;
|
||||
right: -3px;
|
||||
cursor: ne-resize;
|
||||
}
|
||||
|
||||
.imgCrop_handleE {
|
||||
top: 0;
|
||||
right: -3px;
|
||||
/* margin-top: 49%; @done_in_js */
|
||||
cursor: e-resize;
|
||||
}
|
||||
|
||||
.imgCrop_handleSE {
|
||||
right: -3px;
|
||||
bottom: -3px;
|
||||
cursor: se-resize;
|
||||
}
|
||||
|
||||
.imgCrop_handleS {
|
||||
right: 0;
|
||||
bottom: -3px;
|
||||
/* margin-right: 49%; @done_in_js */
|
||||
cursor: s-resize;
|
||||
}
|
||||
|
||||
.imgCrop_handleSW {
|
||||
left: -3px;
|
||||
bottom: -3px;
|
||||
cursor: sw-resize;
|
||||
}
|
||||
|
||||
.imgCrop_handleW {
|
||||
top: 0;
|
||||
left: -3px;
|
||||
/* margin-top: 49%; @done_in_js */
|
||||
cursor: e-resize;
|
||||
}
|
||||
|
||||
.imgCrop_handleNW {
|
||||
top: -3px;
|
||||
left: -3px;
|
||||
cursor: nw-resize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an area to click & drag around on as the default browser behaviour is to let you drag the image
|
||||
*/
|
||||
.imgCrop_dragArea {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 200;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.imgCrop_previewWrap {
|
||||
/* width: 200px; @done_in_js */
|
||||
/* height: 200px; @done_in_js */
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.imgCrop_previewWrap img {
|
||||
position: absolute;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+1
-1
File diff suppressed because one or more lines are too long
@@ -1,291 +1,291 @@
|
||||
/**
|
||||
* @output wp-includes/js/customize-loader.js
|
||||
*/
|
||||
|
||||
/* global _wpCustomizeLoaderSettings */
|
||||
|
||||
/**
|
||||
* Expose a public API that allows the customizer to be
|
||||
* loaded on any page.
|
||||
*
|
||||
* @namespace wp
|
||||
*/
|
||||
window.wp = window.wp || {};
|
||||
|
||||
(function( exports, $ ){
|
||||
var api = wp.customize,
|
||||
Loader;
|
||||
|
||||
$.extend( $.support, {
|
||||
history: !! ( window.history && history.pushState ),
|
||||
hashchange: ('onhashchange' in window) && (document.documentMode === undefined || document.documentMode > 7)
|
||||
});
|
||||
|
||||
/**
|
||||
* Allows the Customizer to be overlayed on any page.
|
||||
*
|
||||
* By default, any element in the body with the load-customize class will open
|
||||
* an iframe overlay with the URL specified.
|
||||
*
|
||||
* e.g. <a class="load-customize" href="<?php echo wp_customize_url(); ?>">Open Customizer</a>
|
||||
*
|
||||
* @memberOf wp.customize
|
||||
*
|
||||
* @class
|
||||
* @augments wp.customize.Events
|
||||
*/
|
||||
Loader = $.extend( {}, api.Events,/** @lends wp.customize.Loader.prototype */{
|
||||
/**
|
||||
* Setup the Loader; triggered on document#ready.
|
||||
*/
|
||||
initialize: function() {
|
||||
this.body = $( document.body );
|
||||
|
||||
// Ensure the loader is supported.
|
||||
// Check for settings, postMessage support, and whether we require CORS support.
|
||||
if ( ! Loader.settings || ! $.support.postMessage || ( ! $.support.cors && Loader.settings.isCrossDomain ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.window = $( window );
|
||||
this.element = $( '<div id="customize-container" />' ).appendTo( this.body );
|
||||
|
||||
// Bind events for opening and closing the overlay.
|
||||
this.bind( 'open', this.overlay.show );
|
||||
this.bind( 'close', this.overlay.hide );
|
||||
|
||||
// Any element in the body with the `load-customize` class opens
|
||||
// the Customizer.
|
||||
$('#wpbody').on( 'click', '.load-customize', function( event ) {
|
||||
event.preventDefault();
|
||||
|
||||
// Store a reference to the link that opened the Customizer.
|
||||
Loader.link = $(this);
|
||||
// Load the theme.
|
||||
Loader.open( Loader.link.attr('href') );
|
||||
});
|
||||
|
||||
// Add navigation listeners.
|
||||
if ( $.support.history ) {
|
||||
this.window.on( 'popstate', Loader.popstate );
|
||||
}
|
||||
|
||||
if ( $.support.hashchange ) {
|
||||
this.window.on( 'hashchange', Loader.hashchange );
|
||||
this.window.triggerHandler( 'hashchange' );
|
||||
}
|
||||
},
|
||||
|
||||
popstate: function( e ) {
|
||||
var state = e.originalEvent.state;
|
||||
if ( state && state.customize ) {
|
||||
Loader.open( state.customize );
|
||||
} else if ( Loader.active ) {
|
||||
Loader.close();
|
||||
}
|
||||
},
|
||||
|
||||
hashchange: function() {
|
||||
var hash = window.location.toString().split('#')[1];
|
||||
|
||||
if ( hash && 0 === hash.indexOf( 'wp_customize=on' ) ) {
|
||||
Loader.open( Loader.settings.url + '?' + hash );
|
||||
}
|
||||
|
||||
if ( ! hash && ! $.support.history ) {
|
||||
Loader.close();
|
||||
}
|
||||
},
|
||||
|
||||
beforeunload: function () {
|
||||
if ( ! Loader.saved() ) {
|
||||
return Loader.settings.l10n.saveAlert;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Open the Customizer overlay for a specific URL.
|
||||
*
|
||||
* @param string src URL to load in the Customizer.
|
||||
*/
|
||||
open: function( src ) {
|
||||
|
||||
if ( this.active ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Load the full page on mobile devices.
|
||||
if ( Loader.settings.browser.mobile ) {
|
||||
return window.location = src;
|
||||
}
|
||||
|
||||
// Store the document title prior to opening the Live Preview.
|
||||
this.originalDocumentTitle = document.title;
|
||||
|
||||
this.active = true;
|
||||
this.body.addClass('customize-loading');
|
||||
|
||||
/*
|
||||
* Track the dirtiness state (whether the drafted changes have been published)
|
||||
* of the Customizer in the iframe. This is used to decide whether to display
|
||||
* an AYS alert if the user tries to close the window before saving changes.
|
||||
*/
|
||||
this.saved = new api.Value( true );
|
||||
|
||||
this.iframe = $( '<iframe />', { 'src': src, 'title': Loader.settings.l10n.mainIframeTitle } ).appendTo( this.element );
|
||||
this.iframe.one( 'load', this.loaded );
|
||||
|
||||
// Create a postMessage connection with the iframe.
|
||||
this.messenger = new api.Messenger({
|
||||
url: src,
|
||||
channel: 'loader',
|
||||
targetWindow: this.iframe[0].contentWindow
|
||||
});
|
||||
|
||||
// Expose the changeset UUID on the parent window's URL so that the customized state can survive a refresh.
|
||||
if ( history.replaceState ) {
|
||||
this.messenger.bind( 'changeset-uuid', function( changesetUuid ) {
|
||||
var urlParser = document.createElement( 'a' );
|
||||
urlParser.href = location.href;
|
||||
urlParser.search = $.param( _.extend(
|
||||
api.utils.parseQueryString( urlParser.search.substr( 1 ) ),
|
||||
{ changeset_uuid: changesetUuid }
|
||||
) );
|
||||
history.replaceState( { customize: urlParser.href }, '', urlParser.href );
|
||||
} );
|
||||
}
|
||||
|
||||
// Wait for the connection from the iframe before sending any postMessage events.
|
||||
this.messenger.bind( 'ready', function() {
|
||||
Loader.messenger.send( 'back' );
|
||||
});
|
||||
|
||||
this.messenger.bind( 'close', function() {
|
||||
if ( $.support.history ) {
|
||||
history.back();
|
||||
} else if ( $.support.hashchange ) {
|
||||
window.location.hash = '';
|
||||
} else {
|
||||
Loader.close();
|
||||
}
|
||||
});
|
||||
|
||||
// Prompt AYS dialog when navigating away.
|
||||
$( window ).on( 'beforeunload', this.beforeunload );
|
||||
|
||||
this.messenger.bind( 'saved', function () {
|
||||
Loader.saved( true );
|
||||
} );
|
||||
this.messenger.bind( 'change', function () {
|
||||
Loader.saved( false );
|
||||
} );
|
||||
|
||||
this.messenger.bind( 'title', function( newTitle ){
|
||||
window.document.title = newTitle;
|
||||
});
|
||||
|
||||
this.pushState( src );
|
||||
|
||||
this.trigger( 'open' );
|
||||
},
|
||||
|
||||
pushState: function ( src ) {
|
||||
var hash = src.split( '?' )[1];
|
||||
|
||||
// Ensure we don't call pushState if the user hit the forward button.
|
||||
if ( $.support.history && window.location.href !== src ) {
|
||||
history.pushState( { customize: src }, '', src );
|
||||
} else if ( ! $.support.history && $.support.hashchange && hash ) {
|
||||
window.location.hash = 'wp_customize=on&' + hash;
|
||||
}
|
||||
|
||||
this.trigger( 'open' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback after the Customizer has been opened.
|
||||
*/
|
||||
opened: function() {
|
||||
Loader.body.addClass( 'customize-active full-overlay-active' ).attr( 'aria-busy', 'true' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Close the Customizer overlay.
|
||||
*/
|
||||
close: function() {
|
||||
var self = this, onConfirmClose;
|
||||
if ( ! self.active ) {
|
||||
return;
|
||||
}
|
||||
|
||||
onConfirmClose = function( confirmed ) {
|
||||
if ( confirmed ) {
|
||||
self.active = false;
|
||||
self.trigger( 'close' );
|
||||
|
||||
// Restore document title prior to opening the Live Preview.
|
||||
if ( self.originalDocumentTitle ) {
|
||||
document.title = self.originalDocumentTitle;
|
||||
}
|
||||
} else {
|
||||
|
||||
// Go forward since Customizer is exited by history.back().
|
||||
history.forward();
|
||||
}
|
||||
self.messenger.unbind( 'confirmed-close', onConfirmClose );
|
||||
};
|
||||
self.messenger.bind( 'confirmed-close', onConfirmClose );
|
||||
|
||||
Loader.messenger.send( 'confirm-close' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback after the Customizer has been closed.
|
||||
*/
|
||||
closed: function() {
|
||||
Loader.iframe.remove();
|
||||
Loader.messenger.destroy();
|
||||
Loader.iframe = null;
|
||||
Loader.messenger = null;
|
||||
Loader.saved = null;
|
||||
Loader.body.removeClass( 'customize-active full-overlay-active' ).removeClass( 'customize-loading' );
|
||||
$( window ).off( 'beforeunload', Loader.beforeunload );
|
||||
/*
|
||||
* Return focus to the link that opened the Customizer overlay after
|
||||
* the body element visibility is restored.
|
||||
*/
|
||||
if ( Loader.link ) {
|
||||
Loader.link.focus();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback for the `load` event on the Customizer iframe.
|
||||
*/
|
||||
loaded: function() {
|
||||
Loader.body.removeClass( 'customize-loading' ).attr( 'aria-busy', 'false' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Overlay hide/show utility methods.
|
||||
*/
|
||||
overlay: {
|
||||
show: function() {
|
||||
this.element.fadeIn( 200, Loader.opened );
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.element.fadeOut( 200, Loader.closed );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Bootstrap the Loader on document#ready.
|
||||
$( function() {
|
||||
Loader.settings = _wpCustomizeLoaderSettings;
|
||||
Loader.initialize();
|
||||
});
|
||||
|
||||
// Expose the API publicly on window.wp.customize.Loader.
|
||||
api.Loader = Loader;
|
||||
})( wp, jQuery );
|
||||
/**
|
||||
* @output wp-includes/js/customize-loader.js
|
||||
*/
|
||||
|
||||
/* global _wpCustomizeLoaderSettings */
|
||||
|
||||
/**
|
||||
* Expose a public API that allows the customizer to be
|
||||
* loaded on any page.
|
||||
*
|
||||
* @namespace wp
|
||||
*/
|
||||
window.wp = window.wp || {};
|
||||
|
||||
(function( exports, $ ){
|
||||
var api = wp.customize,
|
||||
Loader;
|
||||
|
||||
$.extend( $.support, {
|
||||
history: !! ( window.history && history.pushState ),
|
||||
hashchange: ('onhashchange' in window) && (document.documentMode === undefined || document.documentMode > 7)
|
||||
});
|
||||
|
||||
/**
|
||||
* Allows the Customizer to be overlayed on any page.
|
||||
*
|
||||
* By default, any element in the body with the load-customize class will open
|
||||
* an iframe overlay with the URL specified.
|
||||
*
|
||||
* e.g. <a class="load-customize" href="<?php echo wp_customize_url(); ?>">Open Customizer</a>
|
||||
*
|
||||
* @memberOf wp.customize
|
||||
*
|
||||
* @class
|
||||
* @augments wp.customize.Events
|
||||
*/
|
||||
Loader = $.extend( {}, api.Events,/** @lends wp.customize.Loader.prototype */{
|
||||
/**
|
||||
* Setup the Loader; triggered on document#ready.
|
||||
*/
|
||||
initialize: function() {
|
||||
this.body = $( document.body );
|
||||
|
||||
// Ensure the loader is supported.
|
||||
// Check for settings, postMessage support, and whether we require CORS support.
|
||||
if ( ! Loader.settings || ! $.support.postMessage || ( ! $.support.cors && Loader.settings.isCrossDomain ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.window = $( window );
|
||||
this.element = $( '<div id="customize-container" />' ).appendTo( this.body );
|
||||
|
||||
// Bind events for opening and closing the overlay.
|
||||
this.bind( 'open', this.overlay.show );
|
||||
this.bind( 'close', this.overlay.hide );
|
||||
|
||||
// Any element in the body with the `load-customize` class opens
|
||||
// the Customizer.
|
||||
$('#wpbody').on( 'click', '.load-customize', function( event ) {
|
||||
event.preventDefault();
|
||||
|
||||
// Store a reference to the link that opened the Customizer.
|
||||
Loader.link = $(this);
|
||||
// Load the theme.
|
||||
Loader.open( Loader.link.attr('href') );
|
||||
});
|
||||
|
||||
// Add navigation listeners.
|
||||
if ( $.support.history ) {
|
||||
this.window.on( 'popstate', Loader.popstate );
|
||||
}
|
||||
|
||||
if ( $.support.hashchange ) {
|
||||
this.window.on( 'hashchange', Loader.hashchange );
|
||||
this.window.triggerHandler( 'hashchange' );
|
||||
}
|
||||
},
|
||||
|
||||
popstate: function( e ) {
|
||||
var state = e.originalEvent.state;
|
||||
if ( state && state.customize ) {
|
||||
Loader.open( state.customize );
|
||||
} else if ( Loader.active ) {
|
||||
Loader.close();
|
||||
}
|
||||
},
|
||||
|
||||
hashchange: function() {
|
||||
var hash = window.location.toString().split('#')[1];
|
||||
|
||||
if ( hash && 0 === hash.indexOf( 'wp_customize=on' ) ) {
|
||||
Loader.open( Loader.settings.url + '?' + hash );
|
||||
}
|
||||
|
||||
if ( ! hash && ! $.support.history ) {
|
||||
Loader.close();
|
||||
}
|
||||
},
|
||||
|
||||
beforeunload: function () {
|
||||
if ( ! Loader.saved() ) {
|
||||
return Loader.settings.l10n.saveAlert;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Open the Customizer overlay for a specific URL.
|
||||
*
|
||||
* @param string src URL to load in the Customizer.
|
||||
*/
|
||||
open: function( src ) {
|
||||
|
||||
if ( this.active ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Load the full page on mobile devices.
|
||||
if ( Loader.settings.browser.mobile ) {
|
||||
return window.location = src;
|
||||
}
|
||||
|
||||
// Store the document title prior to opening the Live Preview.
|
||||
this.originalDocumentTitle = document.title;
|
||||
|
||||
this.active = true;
|
||||
this.body.addClass('customize-loading');
|
||||
|
||||
/*
|
||||
* Track the dirtiness state (whether the drafted changes have been published)
|
||||
* of the Customizer in the iframe. This is used to decide whether to display
|
||||
* an AYS alert if the user tries to close the window before saving changes.
|
||||
*/
|
||||
this.saved = new api.Value( true );
|
||||
|
||||
this.iframe = $( '<iframe />', { 'src': src, 'title': Loader.settings.l10n.mainIframeTitle } ).appendTo( this.element );
|
||||
this.iframe.one( 'load', this.loaded );
|
||||
|
||||
// Create a postMessage connection with the iframe.
|
||||
this.messenger = new api.Messenger({
|
||||
url: src,
|
||||
channel: 'loader',
|
||||
targetWindow: this.iframe[0].contentWindow
|
||||
});
|
||||
|
||||
// Expose the changeset UUID on the parent window's URL so that the customized state can survive a refresh.
|
||||
if ( history.replaceState ) {
|
||||
this.messenger.bind( 'changeset-uuid', function( changesetUuid ) {
|
||||
var urlParser = document.createElement( 'a' );
|
||||
urlParser.href = location.href;
|
||||
urlParser.search = $.param( _.extend(
|
||||
api.utils.parseQueryString( urlParser.search.substr( 1 ) ),
|
||||
{ changeset_uuid: changesetUuid }
|
||||
) );
|
||||
history.replaceState( { customize: urlParser.href }, '', urlParser.href );
|
||||
} );
|
||||
}
|
||||
|
||||
// Wait for the connection from the iframe before sending any postMessage events.
|
||||
this.messenger.bind( 'ready', function() {
|
||||
Loader.messenger.send( 'back' );
|
||||
});
|
||||
|
||||
this.messenger.bind( 'close', function() {
|
||||
if ( $.support.history ) {
|
||||
history.back();
|
||||
} else if ( $.support.hashchange ) {
|
||||
window.location.hash = '';
|
||||
} else {
|
||||
Loader.close();
|
||||
}
|
||||
});
|
||||
|
||||
// Prompt AYS dialog when navigating away.
|
||||
$( window ).on( 'beforeunload', this.beforeunload );
|
||||
|
||||
this.messenger.bind( 'saved', function () {
|
||||
Loader.saved( true );
|
||||
} );
|
||||
this.messenger.bind( 'change', function () {
|
||||
Loader.saved( false );
|
||||
} );
|
||||
|
||||
this.messenger.bind( 'title', function( newTitle ){
|
||||
window.document.title = newTitle;
|
||||
});
|
||||
|
||||
this.pushState( src );
|
||||
|
||||
this.trigger( 'open' );
|
||||
},
|
||||
|
||||
pushState: function ( src ) {
|
||||
var hash = src.split( '?' )[1];
|
||||
|
||||
// Ensure we don't call pushState if the user hit the forward button.
|
||||
if ( $.support.history && window.location.href !== src ) {
|
||||
history.pushState( { customize: src }, '', src );
|
||||
} else if ( ! $.support.history && $.support.hashchange && hash ) {
|
||||
window.location.hash = 'wp_customize=on&' + hash;
|
||||
}
|
||||
|
||||
this.trigger( 'open' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback after the Customizer has been opened.
|
||||
*/
|
||||
opened: function() {
|
||||
Loader.body.addClass( 'customize-active full-overlay-active' ).attr( 'aria-busy', 'true' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Close the Customizer overlay.
|
||||
*/
|
||||
close: function() {
|
||||
var self = this, onConfirmClose;
|
||||
if ( ! self.active ) {
|
||||
return;
|
||||
}
|
||||
|
||||
onConfirmClose = function( confirmed ) {
|
||||
if ( confirmed ) {
|
||||
self.active = false;
|
||||
self.trigger( 'close' );
|
||||
|
||||
// Restore document title prior to opening the Live Preview.
|
||||
if ( self.originalDocumentTitle ) {
|
||||
document.title = self.originalDocumentTitle;
|
||||
}
|
||||
} else {
|
||||
|
||||
// Go forward since Customizer is exited by history.back().
|
||||
history.forward();
|
||||
}
|
||||
self.messenger.unbind( 'confirmed-close', onConfirmClose );
|
||||
};
|
||||
self.messenger.bind( 'confirmed-close', onConfirmClose );
|
||||
|
||||
Loader.messenger.send( 'confirm-close' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback after the Customizer has been closed.
|
||||
*/
|
||||
closed: function() {
|
||||
Loader.iframe.remove();
|
||||
Loader.messenger.destroy();
|
||||
Loader.iframe = null;
|
||||
Loader.messenger = null;
|
||||
Loader.saved = null;
|
||||
Loader.body.removeClass( 'customize-active full-overlay-active' ).removeClass( 'customize-loading' );
|
||||
$( window ).off( 'beforeunload', Loader.beforeunload );
|
||||
/*
|
||||
* Return focus to the link that opened the Customizer overlay after
|
||||
* the body element visibility is restored.
|
||||
*/
|
||||
if ( Loader.link ) {
|
||||
Loader.link.focus();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback for the `load` event on the Customizer iframe.
|
||||
*/
|
||||
loaded: function() {
|
||||
Loader.body.removeClass( 'customize-loading' ).attr( 'aria-busy', 'false' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Overlay hide/show utility methods.
|
||||
*/
|
||||
overlay: {
|
||||
show: function() {
|
||||
this.element.fadeIn( 200, Loader.opened );
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.element.fadeOut( 200, Loader.closed );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Bootstrap the Loader on document#ready.
|
||||
$( function() {
|
||||
Loader.settings = _wpCustomizeLoaderSettings;
|
||||
Loader.initialize();
|
||||
});
|
||||
|
||||
// Expose the API publicly on window.wp.customize.Loader.
|
||||
api.Loader = Loader;
|
||||
})( wp, jQuery );
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
/*! This file is auto-generated */
|
||||
window.wp=window.wp||{},function(i){var n,o=wp.customize;i.extend(i.support,{history:!(!window.history||!history.pushState),hashchange:"onhashchange"in window&&(void 0===document.documentMode||7<document.documentMode)}),n=i.extend({},o.Events,{initialize:function(){this.body=i(document.body),n.settings&&i.support.postMessage&&(i.support.cors||!n.settings.isCrossDomain)&&(this.window=i(window),this.element=i('<div id="customize-container" />').appendTo(this.body),this.bind("open",this.overlay.show),this.bind("close",this.overlay.hide),i("#wpbody").on("click",".load-customize",function(e){e.preventDefault(),n.link=i(this),n.open(n.link.attr("href"))}),i.support.history&&this.window.on("popstate",n.popstate),i.support.hashchange)&&(this.window.on("hashchange",n.hashchange),this.window.triggerHandler("hashchange"))},popstate:function(e){e=e.originalEvent.state;e&&e.customize?n.open(e.customize):n.active&&n.close()},hashchange:function(){var e=window.location.toString().split("#")[1];e&&0===e.indexOf("wp_customize=on")&&n.open(n.settings.url+"?"+e),e||i.support.history||n.close()},beforeunload:function(){if(!n.saved())return n.settings.l10n.saveAlert},open:function(e){if(!this.active){if(n.settings.browser.mobile)return window.location=e;this.originalDocumentTitle=document.title,this.active=!0,this.body.addClass("customize-loading"),this.saved=new o.Value(!0),this.iframe=i("<iframe />",{src:e,title:n.settings.l10n.mainIframeTitle}).appendTo(this.element),this.iframe.one("load",this.loaded),this.messenger=new o.Messenger({url:e,channel:"loader",targetWindow:this.iframe[0].contentWindow}),history.replaceState&&this.messenger.bind("changeset-uuid",function(e){var t=document.createElement("a");t.href=location.href,t.search=i.param(_.extend(o.utils.parseQueryString(t.search.substr(1)),{changeset_uuid:e})),history.replaceState({customize:t.href},"",t.href)}),this.messenger.bind("ready",function(){n.messenger.send("back")}),this.messenger.bind("close",function(){i.support.history?history.back():i.support.hashchange?window.location.hash="":n.close()}),i(window).on("beforeunload",this.beforeunload),this.messenger.bind("saved",function(){n.saved(!0)}),this.messenger.bind("change",function(){n.saved(!1)}),this.messenger.bind("title",function(e){window.document.title=e}),this.pushState(e),this.trigger("open")}},pushState:function(e){var t=e.split("?")[1];i.support.history&&window.location.href!==e?history.pushState({customize:e},"",e):!i.support.history&&i.support.hashchange&&t&&(window.location.hash="wp_customize=on&"+t),this.trigger("open")},opened:function(){n.body.addClass("customize-active full-overlay-active").attr("aria-busy","true")},close:function(){var t,i=this;i.active&&(i.messenger.bind("confirmed-close",t=function(e){e?(i.active=!1,i.trigger("close"),i.originalDocumentTitle&&(document.title=i.originalDocumentTitle)):history.forward(),i.messenger.unbind("confirmed-close",t)}),n.messenger.send("confirm-close"))},closed:function(){n.iframe.remove(),n.messenger.destroy(),n.iframe=null,n.messenger=null,n.saved=null,n.body.removeClass("customize-active full-overlay-active").removeClass("customize-loading"),i(window).off("beforeunload",n.beforeunload),n.link&&n.link.focus()},loaded:function(){n.body.removeClass("customize-loading").attr("aria-busy","false")},overlay:{show:function(){this.element.fadeIn(200,n.opened)},hide:function(){this.element.fadeOut(200,n.closed)}}}),i(function(){n.settings=_wpCustomizeLoaderSettings,n.initialize()}),o.Loader=n}((wp,jQuery));
|
||||
@@ -1,281 +1,281 @@
|
||||
/**
|
||||
* @output wp-includes/js/customize-models.js
|
||||
*/
|
||||
|
||||
/* global _wpCustomizeHeader */
|
||||
(function( $, wp ) {
|
||||
var api = wp.customize;
|
||||
/** @namespace wp.customize.HeaderTool */
|
||||
api.HeaderTool = {};
|
||||
|
||||
|
||||
/**
|
||||
* wp.customize.HeaderTool.ImageModel
|
||||
*
|
||||
* A header image. This is where saves via the Customizer API are
|
||||
* abstracted away, plus our own Ajax calls to add images to and remove
|
||||
* images from the user's recently uploaded images setting on the server.
|
||||
* These calls are made regardless of whether the user actually saves new
|
||||
* Customizer settings.
|
||||
*
|
||||
* @memberOf wp.customize.HeaderTool
|
||||
* @alias wp.customize.HeaderTool.ImageModel
|
||||
*
|
||||
* @constructor
|
||||
* @augments Backbone.Model
|
||||
*/
|
||||
api.HeaderTool.ImageModel = Backbone.Model.extend(/** @lends wp.customize.HeaderTool.ImageModel.prototype */{
|
||||
defaults: function() {
|
||||
return {
|
||||
header: {
|
||||
attachment_id: 0,
|
||||
url: '',
|
||||
timestamp: _.now(),
|
||||
thumbnail_url: ''
|
||||
},
|
||||
choice: '',
|
||||
selected: false,
|
||||
random: false
|
||||
};
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
this.on('hide', this.hide, this);
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.set('choice', '');
|
||||
api('header_image').set('remove-header');
|
||||
api('header_image_data').set('remove-header');
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
var data = this.get('header'),
|
||||
curr = api.HeaderTool.currentHeader.get('header').attachment_id;
|
||||
|
||||
// If the image we're removing is also the current header,
|
||||
// unset the latter.
|
||||
if (curr && data.attachment_id === curr) {
|
||||
api.HeaderTool.currentHeader.trigger('hide');
|
||||
}
|
||||
|
||||
wp.ajax.post( 'custom-header-remove', {
|
||||
nonce: _wpCustomizeHeader.nonces.remove,
|
||||
wp_customize: 'on',
|
||||
theme: api.settings.theme.stylesheet,
|
||||
attachment_id: data.attachment_id
|
||||
});
|
||||
|
||||
this.trigger('destroy', this, this.collection);
|
||||
},
|
||||
|
||||
save: function() {
|
||||
if (this.get('random')) {
|
||||
api('header_image').set(this.get('header').random);
|
||||
api('header_image_data').set(this.get('header').random);
|
||||
} else {
|
||||
if (this.get('header').defaultName) {
|
||||
api('header_image').set(this.get('header').url);
|
||||
api('header_image_data').set(this.get('header').defaultName);
|
||||
} else {
|
||||
api('header_image').set(this.get('header').url);
|
||||
api('header_image_data').set(this.get('header'));
|
||||
}
|
||||
}
|
||||
|
||||
api.HeaderTool.combinedList.trigger('control:setImage', this);
|
||||
},
|
||||
|
||||
importImage: function() {
|
||||
var data = this.get('header');
|
||||
if (data.attachment_id === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp.ajax.post( 'custom-header-add', {
|
||||
nonce: _wpCustomizeHeader.nonces.add,
|
||||
wp_customize: 'on',
|
||||
theme: api.settings.theme.stylesheet,
|
||||
attachment_id: data.attachment_id
|
||||
} );
|
||||
},
|
||||
|
||||
shouldBeCropped: function() {
|
||||
if (this.get('themeFlexWidth') === true &&
|
||||
this.get('themeFlexHeight') === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.get('themeFlexWidth') === true &&
|
||||
this.get('themeHeight') === this.get('imageHeight')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.get('themeFlexHeight') === true &&
|
||||
this.get('themeWidth') === this.get('imageWidth')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.get('themeWidth') === this.get('imageWidth') &&
|
||||
this.get('themeHeight') === this.get('imageHeight')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.get('imageWidth') <= this.get('themeWidth')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* wp.customize.HeaderTool.ChoiceList
|
||||
*
|
||||
* @memberOf wp.customize.HeaderTool
|
||||
* @alias wp.customize.HeaderTool.ChoiceList
|
||||
*
|
||||
* @constructor
|
||||
* @augments Backbone.Collection
|
||||
*/
|
||||
api.HeaderTool.ChoiceList = Backbone.Collection.extend({
|
||||
model: api.HeaderTool.ImageModel,
|
||||
|
||||
// Ordered from most recently used to least.
|
||||
comparator: function(model) {
|
||||
return -model.get('header').timestamp;
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
var current = api.HeaderTool.currentHeader.get('choice').replace(/^https?:\/\//, ''),
|
||||
isRandom = this.isRandomChoice(api.get().header_image);
|
||||
|
||||
// Overridable by an extending class.
|
||||
if (!this.type) {
|
||||
this.type = 'uploaded';
|
||||
}
|
||||
|
||||
// Overridable by an extending class.
|
||||
if (typeof this.data === 'undefined') {
|
||||
this.data = _wpCustomizeHeader.uploads;
|
||||
}
|
||||
|
||||
if (isRandom) {
|
||||
// So that when adding data we don't hide regular images.
|
||||
current = api.get().header_image;
|
||||
}
|
||||
|
||||
this.on('control:setImage', this.setImage, this);
|
||||
this.on('control:removeImage', this.removeImage, this);
|
||||
this.on('add', this.maybeRemoveOldCrop, this);
|
||||
this.on('add', this.maybeAddRandomChoice, this);
|
||||
|
||||
_.each(this.data, function(elt, index) {
|
||||
if (!elt.attachment_id) {
|
||||
elt.defaultName = index;
|
||||
}
|
||||
|
||||
if (typeof elt.timestamp === 'undefined') {
|
||||
elt.timestamp = 0;
|
||||
}
|
||||
|
||||
this.add({
|
||||
header: elt,
|
||||
choice: elt.url.split('/').pop(),
|
||||
selected: current === elt.url.replace(/^https?:\/\//, '')
|
||||
}, { silent: true });
|
||||
}, this);
|
||||
|
||||
if (this.size() > 0) {
|
||||
this.addRandomChoice(current);
|
||||
}
|
||||
},
|
||||
|
||||
maybeRemoveOldCrop: function( model ) {
|
||||
var newID = model.get( 'header' ).attachment_id || false,
|
||||
oldCrop;
|
||||
|
||||
// Bail early if we don't have a new attachment ID.
|
||||
if ( ! newID ) {
|
||||
return;
|
||||
}
|
||||
|
||||
oldCrop = this.find( function( item ) {
|
||||
return ( item.cid !== model.cid && item.get( 'header' ).attachment_id === newID );
|
||||
} );
|
||||
|
||||
// If we found an old crop, remove it from the collection.
|
||||
if ( oldCrop ) {
|
||||
this.remove( oldCrop );
|
||||
}
|
||||
},
|
||||
|
||||
maybeAddRandomChoice: function() {
|
||||
if (this.size() === 1) {
|
||||
this.addRandomChoice();
|
||||
}
|
||||
},
|
||||
|
||||
addRandomChoice: function(initialChoice) {
|
||||
var isRandomSameType = RegExp(this.type).test(initialChoice),
|
||||
randomChoice = 'random-' + this.type + '-image';
|
||||
|
||||
this.add({
|
||||
header: {
|
||||
timestamp: 0,
|
||||
random: randomChoice,
|
||||
width: 245,
|
||||
height: 41
|
||||
},
|
||||
choice: randomChoice,
|
||||
random: true,
|
||||
selected: isRandomSameType
|
||||
});
|
||||
},
|
||||
|
||||
isRandomChoice: function(choice) {
|
||||
return (/^random-(uploaded|default)-image$/).test(choice);
|
||||
},
|
||||
|
||||
shouldHideTitle: function() {
|
||||
return this.size() < 2;
|
||||
},
|
||||
|
||||
setImage: function(model) {
|
||||
this.each(function(m) {
|
||||
m.set('selected', false);
|
||||
});
|
||||
|
||||
if (model) {
|
||||
model.set('selected', true);
|
||||
}
|
||||
},
|
||||
|
||||
removeImage: function() {
|
||||
this.each(function(m) {
|
||||
m.set('selected', false);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* wp.customize.HeaderTool.DefaultsList
|
||||
*
|
||||
* @memberOf wp.customize.HeaderTool
|
||||
* @alias wp.customize.HeaderTool.DefaultsList
|
||||
*
|
||||
* @constructor
|
||||
* @augments wp.customize.HeaderTool.ChoiceList
|
||||
* @augments Backbone.Collection
|
||||
*/
|
||||
api.HeaderTool.DefaultsList = api.HeaderTool.ChoiceList.extend({
|
||||
initialize: function() {
|
||||
this.type = 'default';
|
||||
this.data = _wpCustomizeHeader.defaults;
|
||||
api.HeaderTool.ChoiceList.prototype.initialize.apply(this);
|
||||
}
|
||||
});
|
||||
|
||||
})( jQuery, window.wp );
|
||||
/**
|
||||
* @output wp-includes/js/customize-models.js
|
||||
*/
|
||||
|
||||
/* global _wpCustomizeHeader */
|
||||
(function( $, wp ) {
|
||||
var api = wp.customize;
|
||||
/** @namespace wp.customize.HeaderTool */
|
||||
api.HeaderTool = {};
|
||||
|
||||
|
||||
/**
|
||||
* wp.customize.HeaderTool.ImageModel
|
||||
*
|
||||
* A header image. This is where saves via the Customizer API are
|
||||
* abstracted away, plus our own Ajax calls to add images to and remove
|
||||
* images from the user's recently uploaded images setting on the server.
|
||||
* These calls are made regardless of whether the user actually saves new
|
||||
* Customizer settings.
|
||||
*
|
||||
* @memberOf wp.customize.HeaderTool
|
||||
* @alias wp.customize.HeaderTool.ImageModel
|
||||
*
|
||||
* @constructor
|
||||
* @augments Backbone.Model
|
||||
*/
|
||||
api.HeaderTool.ImageModel = Backbone.Model.extend(/** @lends wp.customize.HeaderTool.ImageModel.prototype */{
|
||||
defaults: function() {
|
||||
return {
|
||||
header: {
|
||||
attachment_id: 0,
|
||||
url: '',
|
||||
timestamp: _.now(),
|
||||
thumbnail_url: ''
|
||||
},
|
||||
choice: '',
|
||||
selected: false,
|
||||
random: false
|
||||
};
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
this.on('hide', this.hide, this);
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
this.set('choice', '');
|
||||
api('header_image').set('remove-header');
|
||||
api('header_image_data').set('remove-header');
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
var data = this.get('header'),
|
||||
curr = api.HeaderTool.currentHeader.get('header').attachment_id;
|
||||
|
||||
// If the image we're removing is also the current header,
|
||||
// unset the latter.
|
||||
if (curr && data.attachment_id === curr) {
|
||||
api.HeaderTool.currentHeader.trigger('hide');
|
||||
}
|
||||
|
||||
wp.ajax.post( 'custom-header-remove', {
|
||||
nonce: _wpCustomizeHeader.nonces.remove,
|
||||
wp_customize: 'on',
|
||||
theme: api.settings.theme.stylesheet,
|
||||
attachment_id: data.attachment_id
|
||||
});
|
||||
|
||||
this.trigger('destroy', this, this.collection);
|
||||
},
|
||||
|
||||
save: function() {
|
||||
if (this.get('random')) {
|
||||
api('header_image').set(this.get('header').random);
|
||||
api('header_image_data').set(this.get('header').random);
|
||||
} else {
|
||||
if (this.get('header').defaultName) {
|
||||
api('header_image').set(this.get('header').url);
|
||||
api('header_image_data').set(this.get('header').defaultName);
|
||||
} else {
|
||||
api('header_image').set(this.get('header').url);
|
||||
api('header_image_data').set(this.get('header'));
|
||||
}
|
||||
}
|
||||
|
||||
api.HeaderTool.combinedList.trigger('control:setImage', this);
|
||||
},
|
||||
|
||||
importImage: function() {
|
||||
var data = this.get('header');
|
||||
if (data.attachment_id === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp.ajax.post( 'custom-header-add', {
|
||||
nonce: _wpCustomizeHeader.nonces.add,
|
||||
wp_customize: 'on',
|
||||
theme: api.settings.theme.stylesheet,
|
||||
attachment_id: data.attachment_id
|
||||
} );
|
||||
},
|
||||
|
||||
shouldBeCropped: function() {
|
||||
if (this.get('themeFlexWidth') === true &&
|
||||
this.get('themeFlexHeight') === true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.get('themeFlexWidth') === true &&
|
||||
this.get('themeHeight') === this.get('imageHeight')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.get('themeFlexHeight') === true &&
|
||||
this.get('themeWidth') === this.get('imageWidth')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.get('themeWidth') === this.get('imageWidth') &&
|
||||
this.get('themeHeight') === this.get('imageHeight')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.get('imageWidth') <= this.get('themeWidth')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* wp.customize.HeaderTool.ChoiceList
|
||||
*
|
||||
* @memberOf wp.customize.HeaderTool
|
||||
* @alias wp.customize.HeaderTool.ChoiceList
|
||||
*
|
||||
* @constructor
|
||||
* @augments Backbone.Collection
|
||||
*/
|
||||
api.HeaderTool.ChoiceList = Backbone.Collection.extend({
|
||||
model: api.HeaderTool.ImageModel,
|
||||
|
||||
// Ordered from most recently used to least.
|
||||
comparator: function(model) {
|
||||
return -model.get('header').timestamp;
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
var current = api.HeaderTool.currentHeader.get('choice').replace(/^https?:\/\//, ''),
|
||||
isRandom = this.isRandomChoice(api.get().header_image);
|
||||
|
||||
// Overridable by an extending class.
|
||||
if (!this.type) {
|
||||
this.type = 'uploaded';
|
||||
}
|
||||
|
||||
// Overridable by an extending class.
|
||||
if (typeof this.data === 'undefined') {
|
||||
this.data = _wpCustomizeHeader.uploads;
|
||||
}
|
||||
|
||||
if (isRandom) {
|
||||
// So that when adding data we don't hide regular images.
|
||||
current = api.get().header_image;
|
||||
}
|
||||
|
||||
this.on('control:setImage', this.setImage, this);
|
||||
this.on('control:removeImage', this.removeImage, this);
|
||||
this.on('add', this.maybeRemoveOldCrop, this);
|
||||
this.on('add', this.maybeAddRandomChoice, this);
|
||||
|
||||
_.each(this.data, function(elt, index) {
|
||||
if (!elt.attachment_id) {
|
||||
elt.defaultName = index;
|
||||
}
|
||||
|
||||
if (typeof elt.timestamp === 'undefined') {
|
||||
elt.timestamp = 0;
|
||||
}
|
||||
|
||||
this.add({
|
||||
header: elt,
|
||||
choice: elt.url.split('/').pop(),
|
||||
selected: current === elt.url.replace(/^https?:\/\//, '')
|
||||
}, { silent: true });
|
||||
}, this);
|
||||
|
||||
if (this.size() > 0) {
|
||||
this.addRandomChoice(current);
|
||||
}
|
||||
},
|
||||
|
||||
maybeRemoveOldCrop: function( model ) {
|
||||
var newID = model.get( 'header' ).attachment_id || false,
|
||||
oldCrop;
|
||||
|
||||
// Bail early if we don't have a new attachment ID.
|
||||
if ( ! newID ) {
|
||||
return;
|
||||
}
|
||||
|
||||
oldCrop = this.find( function( item ) {
|
||||
return ( item.cid !== model.cid && item.get( 'header' ).attachment_id === newID );
|
||||
} );
|
||||
|
||||
// If we found an old crop, remove it from the collection.
|
||||
if ( oldCrop ) {
|
||||
this.remove( oldCrop );
|
||||
}
|
||||
},
|
||||
|
||||
maybeAddRandomChoice: function() {
|
||||
if (this.size() === 1) {
|
||||
this.addRandomChoice();
|
||||
}
|
||||
},
|
||||
|
||||
addRandomChoice: function(initialChoice) {
|
||||
var isRandomSameType = RegExp(this.type).test(initialChoice),
|
||||
randomChoice = 'random-' + this.type + '-image';
|
||||
|
||||
this.add({
|
||||
header: {
|
||||
timestamp: 0,
|
||||
random: randomChoice,
|
||||
width: 245,
|
||||
height: 41
|
||||
},
|
||||
choice: randomChoice,
|
||||
random: true,
|
||||
selected: isRandomSameType
|
||||
});
|
||||
},
|
||||
|
||||
isRandomChoice: function(choice) {
|
||||
return (/^random-(uploaded|default)-image$/).test(choice);
|
||||
},
|
||||
|
||||
shouldHideTitle: function() {
|
||||
return this.size() < 2;
|
||||
},
|
||||
|
||||
setImage: function(model) {
|
||||
this.each(function(m) {
|
||||
m.set('selected', false);
|
||||
});
|
||||
|
||||
if (model) {
|
||||
model.set('selected', true);
|
||||
}
|
||||
},
|
||||
|
||||
removeImage: function() {
|
||||
this.each(function(m) {
|
||||
m.set('selected', false);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* wp.customize.HeaderTool.DefaultsList
|
||||
*
|
||||
* @memberOf wp.customize.HeaderTool
|
||||
* @alias wp.customize.HeaderTool.DefaultsList
|
||||
*
|
||||
* @constructor
|
||||
* @augments wp.customize.HeaderTool.ChoiceList
|
||||
* @augments Backbone.Collection
|
||||
*/
|
||||
api.HeaderTool.DefaultsList = api.HeaderTool.ChoiceList.extend({
|
||||
initialize: function() {
|
||||
this.type = 'default';
|
||||
this.data = _wpCustomizeHeader.defaults;
|
||||
api.HeaderTool.ChoiceList.prototype.initialize.apply(this);
|
||||
}
|
||||
});
|
||||
|
||||
})( jQuery, window.wp );
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
/*! This file is auto-generated */
|
||||
!function(i){var a=i.customize;a.HeaderTool={},a.HeaderTool.ImageModel=Backbone.Model.extend({defaults:function(){return{header:{attachment_id:0,url:"",timestamp:_.now(),thumbnail_url:""},choice:"",selected:!1,random:!1}},initialize:function(){this.on("hide",this.hide,this)},hide:function(){this.set("choice",""),a("header_image").set("remove-header"),a("header_image_data").set("remove-header")},destroy:function(){var e=this.get("header"),t=a.HeaderTool.currentHeader.get("header").attachment_id;t&&e.attachment_id===t&&a.HeaderTool.currentHeader.trigger("hide"),i.ajax.post("custom-header-remove",{nonce:_wpCustomizeHeader.nonces.remove,wp_customize:"on",theme:a.settings.theme.stylesheet,attachment_id:e.attachment_id}),this.trigger("destroy",this,this.collection)},save:function(){this.get("random")?(a("header_image").set(this.get("header").random),a("header_image_data").set(this.get("header").random)):this.get("header").defaultName?(a("header_image").set(this.get("header").url),a("header_image_data").set(this.get("header").defaultName)):(a("header_image").set(this.get("header").url),a("header_image_data").set(this.get("header"))),a.HeaderTool.combinedList.trigger("control:setImage",this)},importImage:function(){var e=this.get("header");void 0!==e.attachment_id&&i.ajax.post("custom-header-add",{nonce:_wpCustomizeHeader.nonces.add,wp_customize:"on",theme:a.settings.theme.stylesheet,attachment_id:e.attachment_id})},shouldBeCropped:function(){return(!0!==this.get("themeFlexWidth")||!0!==this.get("themeFlexHeight"))&&!(!0===this.get("themeFlexWidth")&&this.get("themeHeight")===this.get("imageHeight")||!0===this.get("themeFlexHeight")&&this.get("themeWidth")===this.get("imageWidth")||this.get("themeWidth")===this.get("imageWidth")&&this.get("themeHeight")===this.get("imageHeight")||this.get("imageWidth")<=this.get("themeWidth"))}}),a.HeaderTool.ChoiceList=Backbone.Collection.extend({model:a.HeaderTool.ImageModel,comparator:function(e){return-e.get("header").timestamp},initialize:function(){var i=a.HeaderTool.currentHeader.get("choice").replace(/^https?:\/\//,""),e=this.isRandomChoice(a.get().header_image);this.type||(this.type="uploaded"),void 0===this.data&&(this.data=_wpCustomizeHeader.uploads),e&&(i=a.get().header_image),this.on("control:setImage",this.setImage,this),this.on("control:removeImage",this.removeImage,this),this.on("add",this.maybeRemoveOldCrop,this),this.on("add",this.maybeAddRandomChoice,this),_.each(this.data,function(e,t){e.attachment_id||(e.defaultName=t),void 0===e.timestamp&&(e.timestamp=0),this.add({header:e,choice:e.url.split("/").pop(),selected:i===e.url.replace(/^https?:\/\//,"")},{silent:!0})},this),0<this.size()&&this.addRandomChoice(i)},maybeRemoveOldCrop:function(t){var e,i=t.get("header").attachment_id||!1;i&&(e=this.find(function(e){return e.cid!==t.cid&&e.get("header").attachment_id===i}))&&this.remove(e)},maybeAddRandomChoice:function(){1===this.size()&&this.addRandomChoice()},addRandomChoice:function(e){var e=RegExp(this.type).test(e),t="random-"+this.type+"-image";this.add({header:{timestamp:0,random:t,width:245,height:41},choice:t,random:!0,selected:e})},isRandomChoice:function(e){return/^random-(uploaded|default)-image$/.test(e)},shouldHideTitle:function(){return this.size()<2},setImage:function(e){this.each(function(e){e.set("selected",!1)}),e&&e.set("selected",!0)},removeImage:function(){this.each(function(e){e.set("selected",!1)})}}),a.HeaderTool.DefaultsList=a.HeaderTool.ChoiceList.extend({initialize:function(){this.type="default",this.data=_wpCustomizeHeader.defaults,a.HeaderTool.ChoiceList.prototype.initialize.apply(this)}})}((jQuery,window.wp));
|
||||
@@ -1,446 +1,446 @@
|
||||
/**
|
||||
* @output wp-includes/js/customize-preview-nav-menus.js
|
||||
*/
|
||||
|
||||
/* global _wpCustomizePreviewNavMenusExports */
|
||||
|
||||
/** @namespace wp.customize.navMenusPreview */
|
||||
wp.customize.navMenusPreview = wp.customize.MenusCustomizerPreview = ( function( $, _, wp, api ) {
|
||||
'use strict';
|
||||
|
||||
var self = {
|
||||
data: {
|
||||
navMenuInstanceArgs: {}
|
||||
}
|
||||
};
|
||||
if ( 'undefined' !== typeof _wpCustomizePreviewNavMenusExports ) {
|
||||
_.extend( self.data, _wpCustomizePreviewNavMenusExports );
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize nav menus preview.
|
||||
*/
|
||||
self.init = function() {
|
||||
var self = this, synced = false;
|
||||
|
||||
/*
|
||||
* Keep track of whether we synced to determine whether or not bindSettingListener
|
||||
* should also initially fire the listener. This initial firing needs to wait until
|
||||
* after all of the settings have been synced from the pane in order to prevent
|
||||
* an infinite selective fallback-refresh. Note that this sync handler will be
|
||||
* added after the sync handler in customize-preview.js, so it will be triggered
|
||||
* after all of the settings are added.
|
||||
*/
|
||||
api.preview.bind( 'sync', function() {
|
||||
synced = true;
|
||||
} );
|
||||
|
||||
if ( api.selectiveRefresh ) {
|
||||
// Listen for changes to settings related to nav menus.
|
||||
api.each( function( setting ) {
|
||||
self.bindSettingListener( setting );
|
||||
} );
|
||||
api.bind( 'add', function( setting ) {
|
||||
|
||||
/*
|
||||
* Handle case where an invalid nav menu item (one for which its associated object has been deleted)
|
||||
* is synced from the controls into the preview. Since invalid nav menu items are filtered out from
|
||||
* being exported to the frontend by the _is_valid_nav_menu_item filter in wp_get_nav_menu_items(),
|
||||
* the customizer controls will have a nav_menu_item setting where the preview will have none, and
|
||||
* this can trigger an infinite fallback refresh when the nav menu item lacks any valid items.
|
||||
*/
|
||||
if ( setting.get() && ! setting.get()._invalid ) {
|
||||
self.bindSettingListener( setting, { fire: synced } );
|
||||
}
|
||||
} );
|
||||
api.bind( 'remove', function( setting ) {
|
||||
self.unbindSettingListener( setting );
|
||||
} );
|
||||
|
||||
/*
|
||||
* Ensure that wp_nav_menu() instances nested inside of other partials
|
||||
* will be recognized as being present on the page.
|
||||
*/
|
||||
api.selectiveRefresh.bind( 'render-partials-response', function( response ) {
|
||||
if ( response.nav_menu_instance_args ) {
|
||||
_.extend( self.data.navMenuInstanceArgs, response.nav_menu_instance_args );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
api.preview.bind( 'active', function() {
|
||||
self.highlightControls();
|
||||
} );
|
||||
};
|
||||
|
||||
if ( api.selectiveRefresh ) {
|
||||
|
||||
/**
|
||||
* Partial representing an invocation of wp_nav_menu().
|
||||
*
|
||||
* @memberOf wp.customize.navMenusPreview
|
||||
* @alias wp.customize.navMenusPreview.NavMenuInstancePartial
|
||||
*
|
||||
* @class
|
||||
* @augments wp.customize.selectiveRefresh.Partial
|
||||
* @since 4.5.0
|
||||
*/
|
||||
self.NavMenuInstancePartial = api.selectiveRefresh.Partial.extend(/** @lends wp.customize.navMenusPreview.NavMenuInstancePartial.prototype */{
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 4.5.0
|
||||
* @param {string} id - Partial ID.
|
||||
* @param {Object} options
|
||||
* @param {Object} options.params
|
||||
* @param {Object} options.params.navMenuArgs
|
||||
* @param {string} options.params.navMenuArgs.args_hmac
|
||||
* @param {string} [options.params.navMenuArgs.theme_location]
|
||||
* @param {number} [options.params.navMenuArgs.menu]
|
||||
* @param {Object} [options.constructingContainerContext]
|
||||
*/
|
||||
initialize: function( id, options ) {
|
||||
var partial = this, matches, argsHmac;
|
||||
matches = id.match( /^nav_menu_instance\[([0-9a-f]{32})]$/ );
|
||||
if ( ! matches ) {
|
||||
throw new Error( 'Illegal id for nav_menu_instance partial. The key corresponds with the args HMAC.' );
|
||||
}
|
||||
argsHmac = matches[1];
|
||||
|
||||
options = options || {};
|
||||
options.params = _.extend(
|
||||
{
|
||||
selector: '[data-customize-partial-id="' + id + '"]',
|
||||
navMenuArgs: options.constructingContainerContext || {},
|
||||
containerInclusive: true
|
||||
},
|
||||
options.params || {}
|
||||
);
|
||||
api.selectiveRefresh.Partial.prototype.initialize.call( partial, id, options );
|
||||
|
||||
if ( ! _.isObject( partial.params.navMenuArgs ) ) {
|
||||
throw new Error( 'Missing navMenuArgs' );
|
||||
}
|
||||
if ( partial.params.navMenuArgs.args_hmac !== argsHmac ) {
|
||||
throw new Error( 'args_hmac mismatch with id' );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Return whether the setting is related to this partial.
|
||||
*
|
||||
* @since 4.5.0
|
||||
* @param {wp.customize.Value|string} setting - Object or ID.
|
||||
* @param {number|Object|false|null} newValue - New value, or null if the setting was just removed.
|
||||
* @param {number|Object|false|null} oldValue - Old value, or null if the setting was just added.
|
||||
* @return {boolean}
|
||||
*/
|
||||
isRelatedSetting: function( setting, newValue, oldValue ) {
|
||||
var partial = this, navMenuLocationSetting, navMenuId, isNavMenuItemSetting, _newValue, _oldValue, urlParser;
|
||||
if ( _.isString( setting ) ) {
|
||||
setting = api( setting );
|
||||
}
|
||||
|
||||
/*
|
||||
* Prevent nav_menu_item changes only containing type_label differences triggering a refresh.
|
||||
* These settings in the preview do not include type_label property, and so if one of these
|
||||
* nav_menu_item settings is dirty, after a refresh the nav menu instance would do a selective
|
||||
* refresh immediately because the setting from the pane would have the type_label whereas
|
||||
* the setting in the preview would not, thus triggering a change event. The following
|
||||
* condition short-circuits this unnecessary selective refresh and also prevents an infinite
|
||||
* loop in the case where a nav_menu_instance partial had done a fallback refresh.
|
||||
* @todo Nav menu item settings should not include a type_label property to begin with.
|
||||
*/
|
||||
isNavMenuItemSetting = /^nav_menu_item\[/.test( setting.id );
|
||||
if ( isNavMenuItemSetting && _.isObject( newValue ) && _.isObject( oldValue ) ) {
|
||||
_newValue = _.clone( newValue );
|
||||
_oldValue = _.clone( oldValue );
|
||||
delete _newValue.type_label;
|
||||
delete _oldValue.type_label;
|
||||
|
||||
// Normalize URL scheme when parent frame is HTTPS to prevent selective refresh upon initial page load.
|
||||
if ( 'https' === api.preview.scheme.get() ) {
|
||||
urlParser = document.createElement( 'a' );
|
||||
urlParser.href = _newValue.url;
|
||||
urlParser.protocol = 'https:';
|
||||
_newValue.url = urlParser.href;
|
||||
urlParser.href = _oldValue.url;
|
||||
urlParser.protocol = 'https:';
|
||||
_oldValue.url = urlParser.href;
|
||||
}
|
||||
|
||||
// Prevent original_title differences from causing refreshes if title is present.
|
||||
if ( newValue.title ) {
|
||||
delete _oldValue.original_title;
|
||||
delete _newValue.original_title;
|
||||
}
|
||||
|
||||
if ( _.isEqual( _oldValue, _newValue ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( partial.params.navMenuArgs.theme_location ) {
|
||||
if ( 'nav_menu_locations[' + partial.params.navMenuArgs.theme_location + ']' === setting.id ) {
|
||||
return true;
|
||||
}
|
||||
navMenuLocationSetting = api( 'nav_menu_locations[' + partial.params.navMenuArgs.theme_location + ']' );
|
||||
}
|
||||
|
||||
navMenuId = partial.params.navMenuArgs.menu;
|
||||
if ( ! navMenuId && navMenuLocationSetting ) {
|
||||
navMenuId = navMenuLocationSetting();
|
||||
}
|
||||
|
||||
if ( ! navMenuId ) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
( 'nav_menu[' + navMenuId + ']' === setting.id ) ||
|
||||
( isNavMenuItemSetting && (
|
||||
( newValue && newValue.nav_menu_term_id === navMenuId ) ||
|
||||
( oldValue && oldValue.nav_menu_term_id === navMenuId )
|
||||
) )
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Make sure that partial fallback behavior is invoked if there is no associated menu.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @return {Promise}
|
||||
*/
|
||||
refresh: function() {
|
||||
var partial = this, menuId, deferred = $.Deferred();
|
||||
|
||||
// Make sure the fallback behavior is invoked when the partial is no longer associated with a menu.
|
||||
if ( _.isNumber( partial.params.navMenuArgs.menu ) ) {
|
||||
menuId = partial.params.navMenuArgs.menu;
|
||||
} else if ( partial.params.navMenuArgs.theme_location && api.has( 'nav_menu_locations[' + partial.params.navMenuArgs.theme_location + ']' ) ) {
|
||||
menuId = api( 'nav_menu_locations[' + partial.params.navMenuArgs.theme_location + ']' ).get();
|
||||
}
|
||||
if ( ! menuId ) {
|
||||
partial.fallback();
|
||||
deferred.reject();
|
||||
return deferred.promise();
|
||||
}
|
||||
|
||||
return api.selectiveRefresh.Partial.prototype.refresh.call( partial );
|
||||
},
|
||||
|
||||
/**
|
||||
* Render content.
|
||||
*
|
||||
* @inheritdoc
|
||||
* @param {wp.customize.selectiveRefresh.Placement} placement
|
||||
*/
|
||||
renderContent: function( placement ) {
|
||||
var partial = this, previousContainer = placement.container;
|
||||
|
||||
// Do fallback behavior to refresh preview if menu is now empty.
|
||||
if ( '' === placement.addedContent ) {
|
||||
placement.partial.fallback();
|
||||
}
|
||||
|
||||
if ( api.selectiveRefresh.Partial.prototype.renderContent.call( partial, placement ) ) {
|
||||
|
||||
// Trigger deprecated event.
|
||||
$( document ).trigger( 'customize-preview-menu-refreshed', [ {
|
||||
instanceNumber: null, // @deprecated
|
||||
wpNavArgs: placement.context, // @deprecated
|
||||
wpNavMenuArgs: placement.context,
|
||||
oldContainer: previousContainer,
|
||||
newContainer: placement.container
|
||||
} ] );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
api.selectiveRefresh.partialConstructor.nav_menu_instance = self.NavMenuInstancePartial;
|
||||
|
||||
/**
|
||||
* Request full refresh if there are nav menu instances that lack partials which also match the supplied args.
|
||||
*
|
||||
* @param {Object} navMenuInstanceArgs
|
||||
*/
|
||||
self.handleUnplacedNavMenuInstances = function( navMenuInstanceArgs ) {
|
||||
var unplacedNavMenuInstances;
|
||||
unplacedNavMenuInstances = _.filter( _.values( self.data.navMenuInstanceArgs ), function( args ) {
|
||||
return ! api.selectiveRefresh.partial.has( 'nav_menu_instance[' + args.args_hmac + ']' );
|
||||
} );
|
||||
if ( _.findWhere( unplacedNavMenuInstances, navMenuInstanceArgs ) ) {
|
||||
api.selectiveRefresh.requestFullRefresh();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add change listener for a nav_menu[], nav_menu_item[], or nav_menu_locations[] setting.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param {wp.customize.Value} setting
|
||||
* @param {Object} [options]
|
||||
* @param {boolean} options.fire Whether to invoke the callback after binding.
|
||||
* This is used when a dynamic setting is added.
|
||||
* @return {boolean} Whether the setting was bound.
|
||||
*/
|
||||
self.bindSettingListener = function( setting, options ) {
|
||||
var matches;
|
||||
options = options || {};
|
||||
|
||||
matches = setting.id.match( /^nav_menu\[(-?\d+)]$/ );
|
||||
if ( matches ) {
|
||||
setting._navMenuId = parseInt( matches[1], 10 );
|
||||
setting.bind( this.onChangeNavMenuSetting );
|
||||
if ( options.fire ) {
|
||||
this.onChangeNavMenuSetting.call( setting, setting(), false );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
matches = setting.id.match( /^nav_menu_item\[(-?\d+)]$/ );
|
||||
if ( matches ) {
|
||||
setting._navMenuItemId = parseInt( matches[1], 10 );
|
||||
setting.bind( this.onChangeNavMenuItemSetting );
|
||||
if ( options.fire ) {
|
||||
this.onChangeNavMenuItemSetting.call( setting, setting(), false );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
matches = setting.id.match( /^nav_menu_locations\[(.+?)]/ );
|
||||
if ( matches ) {
|
||||
setting._navMenuThemeLocation = matches[1];
|
||||
setting.bind( this.onChangeNavMenuLocationsSetting );
|
||||
if ( options.fire ) {
|
||||
this.onChangeNavMenuLocationsSetting.call( setting, setting(), false );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove change listeners for nav_menu[], nav_menu_item[], or nav_menu_locations[] setting.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param {wp.customize.Value} setting
|
||||
*/
|
||||
self.unbindSettingListener = function( setting ) {
|
||||
setting.unbind( this.onChangeNavMenuSetting );
|
||||
setting.unbind( this.onChangeNavMenuItemSetting );
|
||||
setting.unbind( this.onChangeNavMenuLocationsSetting );
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle change for nav_menu[] setting for nav menu instances lacking partials.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @this {wp.customize.Value}
|
||||
*/
|
||||
self.onChangeNavMenuSetting = function() {
|
||||
var setting = this;
|
||||
|
||||
self.handleUnplacedNavMenuInstances( {
|
||||
menu: setting._navMenuId
|
||||
} );
|
||||
|
||||
// Ensure all nav menu instances with a theme_location assigned to this menu are handled.
|
||||
api.each( function( otherSetting ) {
|
||||
if ( ! otherSetting._navMenuThemeLocation ) {
|
||||
return;
|
||||
}
|
||||
if ( setting._navMenuId === otherSetting() ) {
|
||||
self.handleUnplacedNavMenuInstances( {
|
||||
theme_location: otherSetting._navMenuThemeLocation
|
||||
} );
|
||||
}
|
||||
} );
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle change for nav_menu_item[] setting for nav menu instances lacking partials.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param {Object} newItem New value for nav_menu_item[] setting.
|
||||
* @param {Object} oldItem Old value for nav_menu_item[] setting.
|
||||
* @this {wp.customize.Value}
|
||||
*/
|
||||
self.onChangeNavMenuItemSetting = function( newItem, oldItem ) {
|
||||
var item = newItem || oldItem, navMenuSetting;
|
||||
navMenuSetting = api( 'nav_menu[' + String( item.nav_menu_term_id ) + ']' );
|
||||
if ( navMenuSetting ) {
|
||||
self.onChangeNavMenuSetting.call( navMenuSetting );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle change for nav_menu_locations[] setting for nav menu instances lacking partials.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @this {wp.customize.Value}
|
||||
*/
|
||||
self.onChangeNavMenuLocationsSetting = function() {
|
||||
var setting = this, hasNavMenuInstance;
|
||||
self.handleUnplacedNavMenuInstances( {
|
||||
theme_location: setting._navMenuThemeLocation
|
||||
} );
|
||||
|
||||
// If there are no wp_nav_menu() instances that refer to the theme location, do full refresh.
|
||||
hasNavMenuInstance = !! _.findWhere( _.values( self.data.navMenuInstanceArgs ), {
|
||||
theme_location: setting._navMenuThemeLocation
|
||||
} );
|
||||
if ( ! hasNavMenuInstance ) {
|
||||
api.selectiveRefresh.requestFullRefresh();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect nav menu items with their corresponding controls in the pane.
|
||||
*
|
||||
* Setup shift-click on nav menu items which are more granular than the nav menu partial itself.
|
||||
* Also this applies even if a nav menu is not partial-refreshable.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*/
|
||||
self.highlightControls = function() {
|
||||
var selector = '.menu-item';
|
||||
|
||||
// Skip adding highlights if not in the customizer preview iframe.
|
||||
if ( ! api.settings.channel ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Focus on the menu item control when shift+clicking the menu item.
|
||||
$( document ).on( 'click', selector, function( e ) {
|
||||
var navMenuItemParts;
|
||||
if ( ! e.shiftKey ) {
|
||||
return;
|
||||
}
|
||||
|
||||
navMenuItemParts = $( this ).attr( 'class' ).match( /(?:^|\s)menu-item-(-?\d+)(?:\s|$)/ );
|
||||
if ( navMenuItemParts ) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation(); // Make sure a sub-nav menu item will get focused instead of parent items.
|
||||
api.preview.send( 'focus-nav-menu-item-control', parseInt( navMenuItemParts[1], 10 ) );
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
api.bind( 'preview-ready', function() {
|
||||
self.init();
|
||||
} );
|
||||
|
||||
return self;
|
||||
|
||||
}( jQuery, _, wp, wp.customize ) );
|
||||
/**
|
||||
* @output wp-includes/js/customize-preview-nav-menus.js
|
||||
*/
|
||||
|
||||
/* global _wpCustomizePreviewNavMenusExports */
|
||||
|
||||
/** @namespace wp.customize.navMenusPreview */
|
||||
wp.customize.navMenusPreview = wp.customize.MenusCustomizerPreview = ( function( $, _, wp, api ) {
|
||||
'use strict';
|
||||
|
||||
var self = {
|
||||
data: {
|
||||
navMenuInstanceArgs: {}
|
||||
}
|
||||
};
|
||||
if ( 'undefined' !== typeof _wpCustomizePreviewNavMenusExports ) {
|
||||
_.extend( self.data, _wpCustomizePreviewNavMenusExports );
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize nav menus preview.
|
||||
*/
|
||||
self.init = function() {
|
||||
var self = this, synced = false;
|
||||
|
||||
/*
|
||||
* Keep track of whether we synced to determine whether or not bindSettingListener
|
||||
* should also initially fire the listener. This initial firing needs to wait until
|
||||
* after all of the settings have been synced from the pane in order to prevent
|
||||
* an infinite selective fallback-refresh. Note that this sync handler will be
|
||||
* added after the sync handler in customize-preview.js, so it will be triggered
|
||||
* after all of the settings are added.
|
||||
*/
|
||||
api.preview.bind( 'sync', function() {
|
||||
synced = true;
|
||||
} );
|
||||
|
||||
if ( api.selectiveRefresh ) {
|
||||
// Listen for changes to settings related to nav menus.
|
||||
api.each( function( setting ) {
|
||||
self.bindSettingListener( setting );
|
||||
} );
|
||||
api.bind( 'add', function( setting ) {
|
||||
|
||||
/*
|
||||
* Handle case where an invalid nav menu item (one for which its associated object has been deleted)
|
||||
* is synced from the controls into the preview. Since invalid nav menu items are filtered out from
|
||||
* being exported to the frontend by the _is_valid_nav_menu_item filter in wp_get_nav_menu_items(),
|
||||
* the customizer controls will have a nav_menu_item setting where the preview will have none, and
|
||||
* this can trigger an infinite fallback refresh when the nav menu item lacks any valid items.
|
||||
*/
|
||||
if ( setting.get() && ! setting.get()._invalid ) {
|
||||
self.bindSettingListener( setting, { fire: synced } );
|
||||
}
|
||||
} );
|
||||
api.bind( 'remove', function( setting ) {
|
||||
self.unbindSettingListener( setting );
|
||||
} );
|
||||
|
||||
/*
|
||||
* Ensure that wp_nav_menu() instances nested inside of other partials
|
||||
* will be recognized as being present on the page.
|
||||
*/
|
||||
api.selectiveRefresh.bind( 'render-partials-response', function( response ) {
|
||||
if ( response.nav_menu_instance_args ) {
|
||||
_.extend( self.data.navMenuInstanceArgs, response.nav_menu_instance_args );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
api.preview.bind( 'active', function() {
|
||||
self.highlightControls();
|
||||
} );
|
||||
};
|
||||
|
||||
if ( api.selectiveRefresh ) {
|
||||
|
||||
/**
|
||||
* Partial representing an invocation of wp_nav_menu().
|
||||
*
|
||||
* @memberOf wp.customize.navMenusPreview
|
||||
* @alias wp.customize.navMenusPreview.NavMenuInstancePartial
|
||||
*
|
||||
* @class
|
||||
* @augments wp.customize.selectiveRefresh.Partial
|
||||
* @since 4.5.0
|
||||
*/
|
||||
self.NavMenuInstancePartial = api.selectiveRefresh.Partial.extend(/** @lends wp.customize.navMenusPreview.NavMenuInstancePartial.prototype */{
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 4.5.0
|
||||
* @param {string} id - Partial ID.
|
||||
* @param {Object} options
|
||||
* @param {Object} options.params
|
||||
* @param {Object} options.params.navMenuArgs
|
||||
* @param {string} options.params.navMenuArgs.args_hmac
|
||||
* @param {string} [options.params.navMenuArgs.theme_location]
|
||||
* @param {number} [options.params.navMenuArgs.menu]
|
||||
* @param {Object} [options.constructingContainerContext]
|
||||
*/
|
||||
initialize: function( id, options ) {
|
||||
var partial = this, matches, argsHmac;
|
||||
matches = id.match( /^nav_menu_instance\[([0-9a-f]{32})]$/ );
|
||||
if ( ! matches ) {
|
||||
throw new Error( 'Illegal id for nav_menu_instance partial. The key corresponds with the args HMAC.' );
|
||||
}
|
||||
argsHmac = matches[1];
|
||||
|
||||
options = options || {};
|
||||
options.params = _.extend(
|
||||
{
|
||||
selector: '[data-customize-partial-id="' + id + '"]',
|
||||
navMenuArgs: options.constructingContainerContext || {},
|
||||
containerInclusive: true
|
||||
},
|
||||
options.params || {}
|
||||
);
|
||||
api.selectiveRefresh.Partial.prototype.initialize.call( partial, id, options );
|
||||
|
||||
if ( ! _.isObject( partial.params.navMenuArgs ) ) {
|
||||
throw new Error( 'Missing navMenuArgs' );
|
||||
}
|
||||
if ( partial.params.navMenuArgs.args_hmac !== argsHmac ) {
|
||||
throw new Error( 'args_hmac mismatch with id' );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Return whether the setting is related to this partial.
|
||||
*
|
||||
* @since 4.5.0
|
||||
* @param {wp.customize.Value|string} setting - Object or ID.
|
||||
* @param {number|Object|false|null} newValue - New value, or null if the setting was just removed.
|
||||
* @param {number|Object|false|null} oldValue - Old value, or null if the setting was just added.
|
||||
* @return {boolean}
|
||||
*/
|
||||
isRelatedSetting: function( setting, newValue, oldValue ) {
|
||||
var partial = this, navMenuLocationSetting, navMenuId, isNavMenuItemSetting, _newValue, _oldValue, urlParser;
|
||||
if ( _.isString( setting ) ) {
|
||||
setting = api( setting );
|
||||
}
|
||||
|
||||
/*
|
||||
* Prevent nav_menu_item changes only containing type_label differences triggering a refresh.
|
||||
* These settings in the preview do not include type_label property, and so if one of these
|
||||
* nav_menu_item settings is dirty, after a refresh the nav menu instance would do a selective
|
||||
* refresh immediately because the setting from the pane would have the type_label whereas
|
||||
* the setting in the preview would not, thus triggering a change event. The following
|
||||
* condition short-circuits this unnecessary selective refresh and also prevents an infinite
|
||||
* loop in the case where a nav_menu_instance partial had done a fallback refresh.
|
||||
* @todo Nav menu item settings should not include a type_label property to begin with.
|
||||
*/
|
||||
isNavMenuItemSetting = /^nav_menu_item\[/.test( setting.id );
|
||||
if ( isNavMenuItemSetting && _.isObject( newValue ) && _.isObject( oldValue ) ) {
|
||||
_newValue = _.clone( newValue );
|
||||
_oldValue = _.clone( oldValue );
|
||||
delete _newValue.type_label;
|
||||
delete _oldValue.type_label;
|
||||
|
||||
// Normalize URL scheme when parent frame is HTTPS to prevent selective refresh upon initial page load.
|
||||
if ( 'https' === api.preview.scheme.get() ) {
|
||||
urlParser = document.createElement( 'a' );
|
||||
urlParser.href = _newValue.url;
|
||||
urlParser.protocol = 'https:';
|
||||
_newValue.url = urlParser.href;
|
||||
urlParser.href = _oldValue.url;
|
||||
urlParser.protocol = 'https:';
|
||||
_oldValue.url = urlParser.href;
|
||||
}
|
||||
|
||||
// Prevent original_title differences from causing refreshes if title is present.
|
||||
if ( newValue.title ) {
|
||||
delete _oldValue.original_title;
|
||||
delete _newValue.original_title;
|
||||
}
|
||||
|
||||
if ( _.isEqual( _oldValue, _newValue ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( partial.params.navMenuArgs.theme_location ) {
|
||||
if ( 'nav_menu_locations[' + partial.params.navMenuArgs.theme_location + ']' === setting.id ) {
|
||||
return true;
|
||||
}
|
||||
navMenuLocationSetting = api( 'nav_menu_locations[' + partial.params.navMenuArgs.theme_location + ']' );
|
||||
}
|
||||
|
||||
navMenuId = partial.params.navMenuArgs.menu;
|
||||
if ( ! navMenuId && navMenuLocationSetting ) {
|
||||
navMenuId = navMenuLocationSetting();
|
||||
}
|
||||
|
||||
if ( ! navMenuId ) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
( 'nav_menu[' + navMenuId + ']' === setting.id ) ||
|
||||
( isNavMenuItemSetting && (
|
||||
( newValue && newValue.nav_menu_term_id === navMenuId ) ||
|
||||
( oldValue && oldValue.nav_menu_term_id === navMenuId )
|
||||
) )
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Make sure that partial fallback behavior is invoked if there is no associated menu.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @return {Promise}
|
||||
*/
|
||||
refresh: function() {
|
||||
var partial = this, menuId, deferred = $.Deferred();
|
||||
|
||||
// Make sure the fallback behavior is invoked when the partial is no longer associated with a menu.
|
||||
if ( _.isNumber( partial.params.navMenuArgs.menu ) ) {
|
||||
menuId = partial.params.navMenuArgs.menu;
|
||||
} else if ( partial.params.navMenuArgs.theme_location && api.has( 'nav_menu_locations[' + partial.params.navMenuArgs.theme_location + ']' ) ) {
|
||||
menuId = api( 'nav_menu_locations[' + partial.params.navMenuArgs.theme_location + ']' ).get();
|
||||
}
|
||||
if ( ! menuId ) {
|
||||
partial.fallback();
|
||||
deferred.reject();
|
||||
return deferred.promise();
|
||||
}
|
||||
|
||||
return api.selectiveRefresh.Partial.prototype.refresh.call( partial );
|
||||
},
|
||||
|
||||
/**
|
||||
* Render content.
|
||||
*
|
||||
* @inheritdoc
|
||||
* @param {wp.customize.selectiveRefresh.Placement} placement
|
||||
*/
|
||||
renderContent: function( placement ) {
|
||||
var partial = this, previousContainer = placement.container;
|
||||
|
||||
// Do fallback behavior to refresh preview if menu is now empty.
|
||||
if ( '' === placement.addedContent ) {
|
||||
placement.partial.fallback();
|
||||
}
|
||||
|
||||
if ( api.selectiveRefresh.Partial.prototype.renderContent.call( partial, placement ) ) {
|
||||
|
||||
// Trigger deprecated event.
|
||||
$( document ).trigger( 'customize-preview-menu-refreshed', [ {
|
||||
instanceNumber: null, // @deprecated
|
||||
wpNavArgs: placement.context, // @deprecated
|
||||
wpNavMenuArgs: placement.context,
|
||||
oldContainer: previousContainer,
|
||||
newContainer: placement.container
|
||||
} ] );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
api.selectiveRefresh.partialConstructor.nav_menu_instance = self.NavMenuInstancePartial;
|
||||
|
||||
/**
|
||||
* Request full refresh if there are nav menu instances that lack partials which also match the supplied args.
|
||||
*
|
||||
* @param {Object} navMenuInstanceArgs
|
||||
*/
|
||||
self.handleUnplacedNavMenuInstances = function( navMenuInstanceArgs ) {
|
||||
var unplacedNavMenuInstances;
|
||||
unplacedNavMenuInstances = _.filter( _.values( self.data.navMenuInstanceArgs ), function( args ) {
|
||||
return ! api.selectiveRefresh.partial.has( 'nav_menu_instance[' + args.args_hmac + ']' );
|
||||
} );
|
||||
if ( _.findWhere( unplacedNavMenuInstances, navMenuInstanceArgs ) ) {
|
||||
api.selectiveRefresh.requestFullRefresh();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add change listener for a nav_menu[], nav_menu_item[], or nav_menu_locations[] setting.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param {wp.customize.Value} setting
|
||||
* @param {Object} [options]
|
||||
* @param {boolean} options.fire Whether to invoke the callback after binding.
|
||||
* This is used when a dynamic setting is added.
|
||||
* @return {boolean} Whether the setting was bound.
|
||||
*/
|
||||
self.bindSettingListener = function( setting, options ) {
|
||||
var matches;
|
||||
options = options || {};
|
||||
|
||||
matches = setting.id.match( /^nav_menu\[(-?\d+)]$/ );
|
||||
if ( matches ) {
|
||||
setting._navMenuId = parseInt( matches[1], 10 );
|
||||
setting.bind( this.onChangeNavMenuSetting );
|
||||
if ( options.fire ) {
|
||||
this.onChangeNavMenuSetting.call( setting, setting(), false );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
matches = setting.id.match( /^nav_menu_item\[(-?\d+)]$/ );
|
||||
if ( matches ) {
|
||||
setting._navMenuItemId = parseInt( matches[1], 10 );
|
||||
setting.bind( this.onChangeNavMenuItemSetting );
|
||||
if ( options.fire ) {
|
||||
this.onChangeNavMenuItemSetting.call( setting, setting(), false );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
matches = setting.id.match( /^nav_menu_locations\[(.+?)]/ );
|
||||
if ( matches ) {
|
||||
setting._navMenuThemeLocation = matches[1];
|
||||
setting.bind( this.onChangeNavMenuLocationsSetting );
|
||||
if ( options.fire ) {
|
||||
this.onChangeNavMenuLocationsSetting.call( setting, setting(), false );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove change listeners for nav_menu[], nav_menu_item[], or nav_menu_locations[] setting.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param {wp.customize.Value} setting
|
||||
*/
|
||||
self.unbindSettingListener = function( setting ) {
|
||||
setting.unbind( this.onChangeNavMenuSetting );
|
||||
setting.unbind( this.onChangeNavMenuItemSetting );
|
||||
setting.unbind( this.onChangeNavMenuLocationsSetting );
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle change for nav_menu[] setting for nav menu instances lacking partials.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @this {wp.customize.Value}
|
||||
*/
|
||||
self.onChangeNavMenuSetting = function() {
|
||||
var setting = this;
|
||||
|
||||
self.handleUnplacedNavMenuInstances( {
|
||||
menu: setting._navMenuId
|
||||
} );
|
||||
|
||||
// Ensure all nav menu instances with a theme_location assigned to this menu are handled.
|
||||
api.each( function( otherSetting ) {
|
||||
if ( ! otherSetting._navMenuThemeLocation ) {
|
||||
return;
|
||||
}
|
||||
if ( setting._navMenuId === otherSetting() ) {
|
||||
self.handleUnplacedNavMenuInstances( {
|
||||
theme_location: otherSetting._navMenuThemeLocation
|
||||
} );
|
||||
}
|
||||
} );
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle change for nav_menu_item[] setting for nav menu instances lacking partials.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param {Object} newItem New value for nav_menu_item[] setting.
|
||||
* @param {Object} oldItem Old value for nav_menu_item[] setting.
|
||||
* @this {wp.customize.Value}
|
||||
*/
|
||||
self.onChangeNavMenuItemSetting = function( newItem, oldItem ) {
|
||||
var item = newItem || oldItem, navMenuSetting;
|
||||
navMenuSetting = api( 'nav_menu[' + String( item.nav_menu_term_id ) + ']' );
|
||||
if ( navMenuSetting ) {
|
||||
self.onChangeNavMenuSetting.call( navMenuSetting );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle change for nav_menu_locations[] setting for nav menu instances lacking partials.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @this {wp.customize.Value}
|
||||
*/
|
||||
self.onChangeNavMenuLocationsSetting = function() {
|
||||
var setting = this, hasNavMenuInstance;
|
||||
self.handleUnplacedNavMenuInstances( {
|
||||
theme_location: setting._navMenuThemeLocation
|
||||
} );
|
||||
|
||||
// If there are no wp_nav_menu() instances that refer to the theme location, do full refresh.
|
||||
hasNavMenuInstance = !! _.findWhere( _.values( self.data.navMenuInstanceArgs ), {
|
||||
theme_location: setting._navMenuThemeLocation
|
||||
} );
|
||||
if ( ! hasNavMenuInstance ) {
|
||||
api.selectiveRefresh.requestFullRefresh();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect nav menu items with their corresponding controls in the pane.
|
||||
*
|
||||
* Setup shift-click on nav menu items which are more granular than the nav menu partial itself.
|
||||
* Also this applies even if a nav menu is not partial-refreshable.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*/
|
||||
self.highlightControls = function() {
|
||||
var selector = '.menu-item';
|
||||
|
||||
// Skip adding highlights if not in the customizer preview iframe.
|
||||
if ( ! api.settings.channel ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Focus on the menu item control when shift+clicking the menu item.
|
||||
$( document ).on( 'click', selector, function( e ) {
|
||||
var navMenuItemParts;
|
||||
if ( ! e.shiftKey ) {
|
||||
return;
|
||||
}
|
||||
|
||||
navMenuItemParts = $( this ).attr( 'class' ).match( /(?:^|\s)menu-item-(-?\d+)(?:\s|$)/ );
|
||||
if ( navMenuItemParts ) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation(); // Make sure a sub-nav menu item will get focused instead of parent items.
|
||||
api.preview.send( 'focus-nav-menu-item-control', parseInt( navMenuItemParts[1], 10 ) );
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
api.bind( 'preview-ready', function() {
|
||||
self.init();
|
||||
} );
|
||||
|
||||
return self;
|
||||
|
||||
}( jQuery, _, wp, wp.customize ) );
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,202 +1,202 @@
|
||||
/**
|
||||
* @output wp-includes/js/customize-views.js
|
||||
*/
|
||||
|
||||
(function( $, wp, _ ) {
|
||||
|
||||
if ( ! wp || ! wp.customize ) { return; }
|
||||
var api = wp.customize;
|
||||
|
||||
/**
|
||||
* wp.customize.HeaderTool.CurrentView
|
||||
*
|
||||
* Displays the currently selected header image, or a placeholder in lack
|
||||
* thereof.
|
||||
*
|
||||
* Instantiate with model wp.customize.HeaderTool.currentHeader.
|
||||
*
|
||||
* @memberOf wp.customize.HeaderTool
|
||||
* @alias wp.customize.HeaderTool.CurrentView
|
||||
*
|
||||
* @constructor
|
||||
* @augments wp.Backbone.View
|
||||
*/
|
||||
api.HeaderTool.CurrentView = wp.Backbone.View.extend(/** @lends wp.customize.HeaderTool.CurrentView.prototype */{
|
||||
template: wp.template('header-current'),
|
||||
|
||||
initialize: function() {
|
||||
this.listenTo(this.model, 'change', this.render);
|
||||
this.render();
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.template(this.model.toJSON()));
|
||||
this.setButtons();
|
||||
return this;
|
||||
},
|
||||
|
||||
setButtons: function() {
|
||||
var elements = $('#customize-control-header_image .actions .remove');
|
||||
if (this.model.get('choice')) {
|
||||
elements.show();
|
||||
} else {
|
||||
elements.hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* wp.customize.HeaderTool.ChoiceView
|
||||
*
|
||||
* Represents a choosable header image, be it user-uploaded,
|
||||
* theme-suggested or a special Randomize choice.
|
||||
*
|
||||
* Takes a wp.customize.HeaderTool.ImageModel.
|
||||
*
|
||||
* Manually changes model wp.customize.HeaderTool.currentHeader via the
|
||||
* `select` method.
|
||||
*
|
||||
* @memberOf wp.customize.HeaderTool
|
||||
* @alias wp.customize.HeaderTool.ChoiceView
|
||||
*
|
||||
* @constructor
|
||||
* @augments wp.Backbone.View
|
||||
*/
|
||||
api.HeaderTool.ChoiceView = wp.Backbone.View.extend(/** @lends wp.customize.HeaderTool.ChoiceView.prototype */{
|
||||
template: wp.template('header-choice'),
|
||||
|
||||
className: 'header-view',
|
||||
|
||||
events: {
|
||||
'click .choice,.random': 'select',
|
||||
'click .close': 'removeImage'
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
var properties = [
|
||||
this.model.get('header').url,
|
||||
this.model.get('choice')
|
||||
];
|
||||
|
||||
this.listenTo(this.model, 'change:selected', this.toggleSelected);
|
||||
|
||||
if (_.contains(properties, api.get().header_image)) {
|
||||
api.HeaderTool.currentHeader.set(this.extendedModel());
|
||||
}
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.template(this.extendedModel()));
|
||||
|
||||
this.toggleSelected();
|
||||
return this;
|
||||
},
|
||||
|
||||
toggleSelected: function() {
|
||||
this.$el.toggleClass('selected', this.model.get('selected'));
|
||||
},
|
||||
|
||||
extendedModel: function() {
|
||||
var c = this.model.get('collection');
|
||||
return _.extend(this.model.toJSON(), {
|
||||
type: c.type
|
||||
});
|
||||
},
|
||||
|
||||
select: function() {
|
||||
this.preventJump();
|
||||
this.model.save();
|
||||
api.HeaderTool.currentHeader.set(this.extendedModel());
|
||||
},
|
||||
|
||||
preventJump: function() {
|
||||
var container = $('.wp-full-overlay-sidebar-content'),
|
||||
scroll = container.scrollTop();
|
||||
|
||||
_.defer(function() {
|
||||
container.scrollTop(scroll);
|
||||
});
|
||||
},
|
||||
|
||||
removeImage: function(e) {
|
||||
e.stopPropagation();
|
||||
this.model.destroy();
|
||||
this.remove();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* wp.customize.HeaderTool.ChoiceListView
|
||||
*
|
||||
* A container for ChoiceViews. These choices should be of one same type:
|
||||
* user-uploaded headers or theme-defined ones.
|
||||
*
|
||||
* Takes a wp.customize.HeaderTool.ChoiceList.
|
||||
*
|
||||
* @memberOf wp.customize.HeaderTool
|
||||
* @alias wp.customize.HeaderTool.ChoiceListView
|
||||
*
|
||||
* @constructor
|
||||
* @augments wp.Backbone.View
|
||||
*/
|
||||
api.HeaderTool.ChoiceListView = wp.Backbone.View.extend(/** @lends wp.customize.HeaderTool.ChoiceListView.prototype */{
|
||||
initialize: function() {
|
||||
this.listenTo(this.collection, 'add', this.addOne);
|
||||
this.listenTo(this.collection, 'remove', this.render);
|
||||
this.listenTo(this.collection, 'sort', this.render);
|
||||
this.listenTo(this.collection, 'change', this.toggleList);
|
||||
this.render();
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.empty();
|
||||
this.collection.each(this.addOne, this);
|
||||
this.toggleList();
|
||||
},
|
||||
|
||||
addOne: function(choice) {
|
||||
var view;
|
||||
choice.set({ collection: this.collection });
|
||||
view = new api.HeaderTool.ChoiceView({ model: choice });
|
||||
this.$el.append(view.render().el);
|
||||
},
|
||||
|
||||
toggleList: function() {
|
||||
var title = this.$el.parents().prev('.customize-control-title'),
|
||||
randomButton = this.$el.find('.random').parent();
|
||||
if (this.collection.shouldHideTitle()) {
|
||||
title.add(randomButton).hide();
|
||||
} else {
|
||||
title.add(randomButton).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* wp.customize.HeaderTool.CombinedList
|
||||
*
|
||||
* Aggregates wp.customize.HeaderTool.ChoiceList collections (or any
|
||||
* Backbone object, really) and acts as a bus to feed them events.
|
||||
*
|
||||
* @memberOf wp.customize.HeaderTool
|
||||
* @alias wp.customize.HeaderTool.CombinedList
|
||||
*
|
||||
* @constructor
|
||||
* @augments wp.Backbone.View
|
||||
*/
|
||||
api.HeaderTool.CombinedList = wp.Backbone.View.extend(/** @lends wp.customize.HeaderTool.CombinedList.prototype */{
|
||||
initialize: function(collections) {
|
||||
this.collections = collections;
|
||||
this.on('all', this.propagate, this);
|
||||
},
|
||||
propagate: function(event, arg) {
|
||||
_.each(this.collections, function(collection) {
|
||||
collection.trigger(event, arg);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
})( jQuery, window.wp, _ );
|
||||
/**
|
||||
* @output wp-includes/js/customize-views.js
|
||||
*/
|
||||
|
||||
(function( $, wp, _ ) {
|
||||
|
||||
if ( ! wp || ! wp.customize ) { return; }
|
||||
var api = wp.customize;
|
||||
|
||||
/**
|
||||
* wp.customize.HeaderTool.CurrentView
|
||||
*
|
||||
* Displays the currently selected header image, or a placeholder in lack
|
||||
* thereof.
|
||||
*
|
||||
* Instantiate with model wp.customize.HeaderTool.currentHeader.
|
||||
*
|
||||
* @memberOf wp.customize.HeaderTool
|
||||
* @alias wp.customize.HeaderTool.CurrentView
|
||||
*
|
||||
* @constructor
|
||||
* @augments wp.Backbone.View
|
||||
*/
|
||||
api.HeaderTool.CurrentView = wp.Backbone.View.extend(/** @lends wp.customize.HeaderTool.CurrentView.prototype */{
|
||||
template: wp.template('header-current'),
|
||||
|
||||
initialize: function() {
|
||||
this.listenTo(this.model, 'change', this.render);
|
||||
this.render();
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.template(this.model.toJSON()));
|
||||
this.setButtons();
|
||||
return this;
|
||||
},
|
||||
|
||||
setButtons: function() {
|
||||
var elements = $('#customize-control-header_image .actions .remove');
|
||||
if (this.model.get('choice')) {
|
||||
elements.show();
|
||||
} else {
|
||||
elements.hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* wp.customize.HeaderTool.ChoiceView
|
||||
*
|
||||
* Represents a choosable header image, be it user-uploaded,
|
||||
* theme-suggested or a special Randomize choice.
|
||||
*
|
||||
* Takes a wp.customize.HeaderTool.ImageModel.
|
||||
*
|
||||
* Manually changes model wp.customize.HeaderTool.currentHeader via the
|
||||
* `select` method.
|
||||
*
|
||||
* @memberOf wp.customize.HeaderTool
|
||||
* @alias wp.customize.HeaderTool.ChoiceView
|
||||
*
|
||||
* @constructor
|
||||
* @augments wp.Backbone.View
|
||||
*/
|
||||
api.HeaderTool.ChoiceView = wp.Backbone.View.extend(/** @lends wp.customize.HeaderTool.ChoiceView.prototype */{
|
||||
template: wp.template('header-choice'),
|
||||
|
||||
className: 'header-view',
|
||||
|
||||
events: {
|
||||
'click .choice,.random': 'select',
|
||||
'click .close': 'removeImage'
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
var properties = [
|
||||
this.model.get('header').url,
|
||||
this.model.get('choice')
|
||||
];
|
||||
|
||||
this.listenTo(this.model, 'change:selected', this.toggleSelected);
|
||||
|
||||
if (_.contains(properties, api.get().header_image)) {
|
||||
api.HeaderTool.currentHeader.set(this.extendedModel());
|
||||
}
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.template(this.extendedModel()));
|
||||
|
||||
this.toggleSelected();
|
||||
return this;
|
||||
},
|
||||
|
||||
toggleSelected: function() {
|
||||
this.$el.toggleClass('selected', this.model.get('selected'));
|
||||
},
|
||||
|
||||
extendedModel: function() {
|
||||
var c = this.model.get('collection');
|
||||
return _.extend(this.model.toJSON(), {
|
||||
type: c.type
|
||||
});
|
||||
},
|
||||
|
||||
select: function() {
|
||||
this.preventJump();
|
||||
this.model.save();
|
||||
api.HeaderTool.currentHeader.set(this.extendedModel());
|
||||
},
|
||||
|
||||
preventJump: function() {
|
||||
var container = $('.wp-full-overlay-sidebar-content'),
|
||||
scroll = container.scrollTop();
|
||||
|
||||
_.defer(function() {
|
||||
container.scrollTop(scroll);
|
||||
});
|
||||
},
|
||||
|
||||
removeImage: function(e) {
|
||||
e.stopPropagation();
|
||||
this.model.destroy();
|
||||
this.remove();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* wp.customize.HeaderTool.ChoiceListView
|
||||
*
|
||||
* A container for ChoiceViews. These choices should be of one same type:
|
||||
* user-uploaded headers or theme-defined ones.
|
||||
*
|
||||
* Takes a wp.customize.HeaderTool.ChoiceList.
|
||||
*
|
||||
* @memberOf wp.customize.HeaderTool
|
||||
* @alias wp.customize.HeaderTool.ChoiceListView
|
||||
*
|
||||
* @constructor
|
||||
* @augments wp.Backbone.View
|
||||
*/
|
||||
api.HeaderTool.ChoiceListView = wp.Backbone.View.extend(/** @lends wp.customize.HeaderTool.ChoiceListView.prototype */{
|
||||
initialize: function() {
|
||||
this.listenTo(this.collection, 'add', this.addOne);
|
||||
this.listenTo(this.collection, 'remove', this.render);
|
||||
this.listenTo(this.collection, 'sort', this.render);
|
||||
this.listenTo(this.collection, 'change', this.toggleList);
|
||||
this.render();
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.empty();
|
||||
this.collection.each(this.addOne, this);
|
||||
this.toggleList();
|
||||
},
|
||||
|
||||
addOne: function(choice) {
|
||||
var view;
|
||||
choice.set({ collection: this.collection });
|
||||
view = new api.HeaderTool.ChoiceView({ model: choice });
|
||||
this.$el.append(view.render().el);
|
||||
},
|
||||
|
||||
toggleList: function() {
|
||||
var title = this.$el.parents().prev('.customize-control-title'),
|
||||
randomButton = this.$el.find('.random').parent();
|
||||
if (this.collection.shouldHideTitle()) {
|
||||
title.add(randomButton).hide();
|
||||
} else {
|
||||
title.add(randomButton).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* wp.customize.HeaderTool.CombinedList
|
||||
*
|
||||
* Aggregates wp.customize.HeaderTool.ChoiceList collections (or any
|
||||
* Backbone object, really) and acts as a bus to feed them events.
|
||||
*
|
||||
* @memberOf wp.customize.HeaderTool
|
||||
* @alias wp.customize.HeaderTool.CombinedList
|
||||
*
|
||||
* @constructor
|
||||
* @augments wp.Backbone.View
|
||||
*/
|
||||
api.HeaderTool.CombinedList = wp.Backbone.View.extend(/** @lends wp.customize.HeaderTool.CombinedList.prototype */{
|
||||
initialize: function(collections) {
|
||||
this.collections = collections;
|
||||
this.on('all', this.propagate, this);
|
||||
},
|
||||
propagate: function(event, arg) {
|
||||
_.each(this.collections, function(collection) {
|
||||
collection.trigger(event, arg);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
})( jQuery, window.wp, _ );
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
/*! This file is auto-generated */
|
||||
!function(i,e,o){var t;e&&e.customize&&((t=e.customize).HeaderTool.CurrentView=e.Backbone.View.extend({template:e.template("header-current"),initialize:function(){this.listenTo(this.model,"change",this.render),this.render()},render:function(){return this.$el.html(this.template(this.model.toJSON())),this.setButtons(),this},setButtons:function(){var e=i("#customize-control-header_image .actions .remove");this.model.get("choice")?e.show():e.hide()}}),t.HeaderTool.ChoiceView=e.Backbone.View.extend({template:e.template("header-choice"),className:"header-view",events:{"click .choice,.random":"select","click .close":"removeImage"},initialize:function(){var e=[this.model.get("header").url,this.model.get("choice")];this.listenTo(this.model,"change:selected",this.toggleSelected),o.contains(e,t.get().header_image)&&t.HeaderTool.currentHeader.set(this.extendedModel())},render:function(){return this.$el.html(this.template(this.extendedModel())),this.toggleSelected(),this},toggleSelected:function(){this.$el.toggleClass("selected",this.model.get("selected"))},extendedModel:function(){var e=this.model.get("collection");return o.extend(this.model.toJSON(),{type:e.type})},select:function(){this.preventJump(),this.model.save(),t.HeaderTool.currentHeader.set(this.extendedModel())},preventJump:function(){var e=i(".wp-full-overlay-sidebar-content"),t=e.scrollTop();o.defer(function(){e.scrollTop(t)})},removeImage:function(e){e.stopPropagation(),this.model.destroy(),this.remove()}}),t.HeaderTool.ChoiceListView=e.Backbone.View.extend({initialize:function(){this.listenTo(this.collection,"add",this.addOne),this.listenTo(this.collection,"remove",this.render),this.listenTo(this.collection,"sort",this.render),this.listenTo(this.collection,"change",this.toggleList),this.render()},render:function(){this.$el.empty(),this.collection.each(this.addOne,this),this.toggleList()},addOne:function(e){e.set({collection:this.collection}),e=new t.HeaderTool.ChoiceView({model:e}),this.$el.append(e.render().el)},toggleList:function(){var e=this.$el.parents().prev(".customize-control-title"),t=this.$el.find(".random").parent();this.collection.shouldHideTitle()?e.add(t).hide():e.add(t).show()}}),t.HeaderTool.CombinedList=e.Backbone.View.extend({initialize:function(e){this.collections=e,this.on("all",this.propagate,this)},propagate:function(t,i){o.each(this.collections,function(e){e.trigger(t,i)})}}))}(jQuery,window.wp,_);
|
||||
File diff suppressed because it is too large
Load Diff
+1
-1
File diff suppressed because one or more lines are too long
@@ -1,169 +1,169 @@
|
||||
/*!
|
||||
* hoverIntent v1.10.2 // 2020.04.28 // jQuery v1.7.0+
|
||||
* http://briancherne.github.io/jquery-hoverIntent/
|
||||
*
|
||||
* You may use hoverIntent under the terms of the MIT license. Basically that
|
||||
* means you are free to use hoverIntent as long as this header is left intact.
|
||||
* Copyright 2007-2019 Brian Cherne
|
||||
*/
|
||||
|
||||
/**
|
||||
* hoverIntent is similar to jQuery's built-in "hover" method except that
|
||||
* instead of firing the handlerIn function immediately, hoverIntent checks
|
||||
* to see if the user's mouse has slowed down (beneath the sensitivity
|
||||
* threshold) before firing the event. The handlerOut function is only
|
||||
* called after a matching handlerIn.
|
||||
*
|
||||
* // basic usage ... just like .hover()
|
||||
* .hoverIntent( handlerIn, handlerOut )
|
||||
* .hoverIntent( handlerInOut )
|
||||
*
|
||||
* // basic usage ... with event delegation!
|
||||
* .hoverIntent( handlerIn, handlerOut, selector )
|
||||
* .hoverIntent( handlerInOut, selector )
|
||||
*
|
||||
* // using a basic configuration object
|
||||
* .hoverIntent( config )
|
||||
*
|
||||
* @param handlerIn function OR configuration object
|
||||
* @param handlerOut function OR selector for delegation OR undefined
|
||||
* @param selector selector OR undefined
|
||||
* @author Brian Cherne <brian(at)cherne(dot)net>
|
||||
*/
|
||||
|
||||
;(function(factory) {
|
||||
'use strict';
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof module === 'object' && module.exports) {
|
||||
module.exports = factory(require('jquery'));
|
||||
} else if (jQuery && !jQuery.fn.hoverIntent) {
|
||||
factory(jQuery);
|
||||
}
|
||||
})(function($) {
|
||||
'use strict';
|
||||
|
||||
// default configuration values
|
||||
var _cfg = {
|
||||
interval: 100,
|
||||
sensitivity: 6,
|
||||
timeout: 0
|
||||
};
|
||||
|
||||
// counter used to generate an ID for each instance
|
||||
var INSTANCE_COUNT = 0;
|
||||
|
||||
// current X and Y position of mouse, updated during mousemove tracking (shared across instances)
|
||||
var cX, cY;
|
||||
|
||||
// saves the current pointer position coordinates based on the given mousemove event
|
||||
var track = function(ev) {
|
||||
cX = ev.pageX;
|
||||
cY = ev.pageY;
|
||||
};
|
||||
|
||||
// compares current and previous mouse positions
|
||||
var compare = function(ev,$el,s,cfg) {
|
||||
// compare mouse positions to see if pointer has slowed enough to trigger `over` function
|
||||
if ( Math.sqrt( (s.pX-cX)*(s.pX-cX) + (s.pY-cY)*(s.pY-cY) ) < cfg.sensitivity ) {
|
||||
$el.off(s.event,track);
|
||||
delete s.timeoutId;
|
||||
// set hoverIntent state as active for this element (permits `out` handler to trigger)
|
||||
s.isActive = true;
|
||||
// overwrite old mouseenter event coordinates with most recent pointer position
|
||||
ev.pageX = cX; ev.pageY = cY;
|
||||
// clear coordinate data from state object
|
||||
delete s.pX; delete s.pY;
|
||||
return cfg.over.apply($el[0],[ev]);
|
||||
} else {
|
||||
// set previous coordinates for next comparison
|
||||
s.pX = cX; s.pY = cY;
|
||||
// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
|
||||
s.timeoutId = setTimeout( function(){compare(ev, $el, s, cfg);} , cfg.interval );
|
||||
}
|
||||
};
|
||||
|
||||
// triggers given `out` function at configured `timeout` after a mouseleave and clears state
|
||||
var delay = function(ev,$el,s,out) {
|
||||
var data = $el.data('hoverIntent');
|
||||
if (data) {
|
||||
delete data[s.id];
|
||||
}
|
||||
return out.apply($el[0],[ev]);
|
||||
};
|
||||
|
||||
// checks if `value` is a function
|
||||
var isFunction = function(value) {
|
||||
return typeof value === 'function';
|
||||
};
|
||||
|
||||
$.fn.hoverIntent = function(handlerIn,handlerOut,selector) {
|
||||
// instance ID, used as a key to store and retrieve state information on an element
|
||||
var instanceId = INSTANCE_COUNT++;
|
||||
|
||||
// extend the default configuration and parse parameters
|
||||
var cfg = $.extend({}, _cfg);
|
||||
if ( $.isPlainObject(handlerIn) ) {
|
||||
cfg = $.extend(cfg, handlerIn);
|
||||
if ( !isFunction(cfg.out) ) {
|
||||
cfg.out = cfg.over;
|
||||
}
|
||||
} else if ( isFunction(handlerOut) ) {
|
||||
cfg = $.extend(cfg, { over: handlerIn, out: handlerOut, selector: selector } );
|
||||
} else {
|
||||
cfg = $.extend(cfg, { over: handlerIn, out: handlerIn, selector: handlerOut } );
|
||||
}
|
||||
|
||||
// A private function for handling mouse 'hovering'
|
||||
var handleHover = function(e) {
|
||||
// cloned event to pass to handlers (copy required for event object to be passed in IE)
|
||||
var ev = $.extend({},e);
|
||||
|
||||
// the current target of the mouse event, wrapped in a jQuery object
|
||||
var $el = $(this);
|
||||
|
||||
// read hoverIntent data from element (or initialize if not present)
|
||||
var hoverIntentData = $el.data('hoverIntent');
|
||||
if (!hoverIntentData) { $el.data('hoverIntent', (hoverIntentData = {})); }
|
||||
|
||||
// read per-instance state from element (or initialize if not present)
|
||||
var state = hoverIntentData[instanceId];
|
||||
if (!state) { hoverIntentData[instanceId] = state = { id: instanceId }; }
|
||||
|
||||
// state properties:
|
||||
// id = instance ID, used to clean up data
|
||||
// timeoutId = timeout ID, reused for tracking mouse position and delaying "out" handler
|
||||
// isActive = plugin state, true after `over` is called just until `out` is called
|
||||
// pX, pY = previously-measured pointer coordinates, updated at each polling interval
|
||||
// event = string representing the namespaced event used for mouse tracking
|
||||
|
||||
// clear any existing timeout
|
||||
if (state.timeoutId) { state.timeoutId = clearTimeout(state.timeoutId); }
|
||||
|
||||
// namespaced event used to register and unregister mousemove tracking
|
||||
var mousemove = state.event = 'mousemove.hoverIntent.hoverIntent'+instanceId;
|
||||
|
||||
// handle the event, based on its type
|
||||
if (e.type === 'mouseenter') {
|
||||
// do nothing if already active
|
||||
if (state.isActive) { return; }
|
||||
// set "previous" X and Y position based on initial entry point
|
||||
state.pX = ev.pageX; state.pY = ev.pageY;
|
||||
// update "current" X and Y position based on mousemove
|
||||
$el.off(mousemove,track).on(mousemove,track);
|
||||
// start polling interval (self-calling timeout) to compare mouse coordinates over time
|
||||
state.timeoutId = setTimeout( function(){compare(ev,$el,state,cfg);} , cfg.interval );
|
||||
} else { // "mouseleave"
|
||||
// do nothing if not already active
|
||||
if (!state.isActive) { return; }
|
||||
// unbind expensive mousemove event
|
||||
$el.off(mousemove,track);
|
||||
// if hoverIntent state is true, then call the mouseOut function after the specified delay
|
||||
state.timeoutId = setTimeout( function(){delay(ev,$el,state,cfg.out);} , cfg.timeout );
|
||||
}
|
||||
};
|
||||
|
||||
// listen for mouseenter and mouseleave
|
||||
return this.on({'mouseenter.hoverIntent':handleHover,'mouseleave.hoverIntent':handleHover}, cfg.selector);
|
||||
};
|
||||
});
|
||||
/*!
|
||||
* hoverIntent v1.10.2 // 2020.04.28 // jQuery v1.7.0+
|
||||
* http://briancherne.github.io/jquery-hoverIntent/
|
||||
*
|
||||
* You may use hoverIntent under the terms of the MIT license. Basically that
|
||||
* means you are free to use hoverIntent as long as this header is left intact.
|
||||
* Copyright 2007-2019 Brian Cherne
|
||||
*/
|
||||
|
||||
/**
|
||||
* hoverIntent is similar to jQuery's built-in "hover" method except that
|
||||
* instead of firing the handlerIn function immediately, hoverIntent checks
|
||||
* to see if the user's mouse has slowed down (beneath the sensitivity
|
||||
* threshold) before firing the event. The handlerOut function is only
|
||||
* called after a matching handlerIn.
|
||||
*
|
||||
* // basic usage ... just like .hover()
|
||||
* .hoverIntent( handlerIn, handlerOut )
|
||||
* .hoverIntent( handlerInOut )
|
||||
*
|
||||
* // basic usage ... with event delegation!
|
||||
* .hoverIntent( handlerIn, handlerOut, selector )
|
||||
* .hoverIntent( handlerInOut, selector )
|
||||
*
|
||||
* // using a basic configuration object
|
||||
* .hoverIntent( config )
|
||||
*
|
||||
* @param handlerIn function OR configuration object
|
||||
* @param handlerOut function OR selector for delegation OR undefined
|
||||
* @param selector selector OR undefined
|
||||
* @author Brian Cherne <brian(at)cherne(dot)net>
|
||||
*/
|
||||
|
||||
;(function(factory) {
|
||||
'use strict';
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof module === 'object' && module.exports) {
|
||||
module.exports = factory(require('jquery'));
|
||||
} else if (jQuery && !jQuery.fn.hoverIntent) {
|
||||
factory(jQuery);
|
||||
}
|
||||
})(function($) {
|
||||
'use strict';
|
||||
|
||||
// default configuration values
|
||||
var _cfg = {
|
||||
interval: 100,
|
||||
sensitivity: 6,
|
||||
timeout: 0
|
||||
};
|
||||
|
||||
// counter used to generate an ID for each instance
|
||||
var INSTANCE_COUNT = 0;
|
||||
|
||||
// current X and Y position of mouse, updated during mousemove tracking (shared across instances)
|
||||
var cX, cY;
|
||||
|
||||
// saves the current pointer position coordinates based on the given mousemove event
|
||||
var track = function(ev) {
|
||||
cX = ev.pageX;
|
||||
cY = ev.pageY;
|
||||
};
|
||||
|
||||
// compares current and previous mouse positions
|
||||
var compare = function(ev,$el,s,cfg) {
|
||||
// compare mouse positions to see if pointer has slowed enough to trigger `over` function
|
||||
if ( Math.sqrt( (s.pX-cX)*(s.pX-cX) + (s.pY-cY)*(s.pY-cY) ) < cfg.sensitivity ) {
|
||||
$el.off(s.event,track);
|
||||
delete s.timeoutId;
|
||||
// set hoverIntent state as active for this element (permits `out` handler to trigger)
|
||||
s.isActive = true;
|
||||
// overwrite old mouseenter event coordinates with most recent pointer position
|
||||
ev.pageX = cX; ev.pageY = cY;
|
||||
// clear coordinate data from state object
|
||||
delete s.pX; delete s.pY;
|
||||
return cfg.over.apply($el[0],[ev]);
|
||||
} else {
|
||||
// set previous coordinates for next comparison
|
||||
s.pX = cX; s.pY = cY;
|
||||
// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
|
||||
s.timeoutId = setTimeout( function(){compare(ev, $el, s, cfg);} , cfg.interval );
|
||||
}
|
||||
};
|
||||
|
||||
// triggers given `out` function at configured `timeout` after a mouseleave and clears state
|
||||
var delay = function(ev,$el,s,out) {
|
||||
var data = $el.data('hoverIntent');
|
||||
if (data) {
|
||||
delete data[s.id];
|
||||
}
|
||||
return out.apply($el[0],[ev]);
|
||||
};
|
||||
|
||||
// checks if `value` is a function
|
||||
var isFunction = function(value) {
|
||||
return typeof value === 'function';
|
||||
};
|
||||
|
||||
$.fn.hoverIntent = function(handlerIn,handlerOut,selector) {
|
||||
// instance ID, used as a key to store and retrieve state information on an element
|
||||
var instanceId = INSTANCE_COUNT++;
|
||||
|
||||
// extend the default configuration and parse parameters
|
||||
var cfg = $.extend({}, _cfg);
|
||||
if ( $.isPlainObject(handlerIn) ) {
|
||||
cfg = $.extend(cfg, handlerIn);
|
||||
if ( !isFunction(cfg.out) ) {
|
||||
cfg.out = cfg.over;
|
||||
}
|
||||
} else if ( isFunction(handlerOut) ) {
|
||||
cfg = $.extend(cfg, { over: handlerIn, out: handlerOut, selector: selector } );
|
||||
} else {
|
||||
cfg = $.extend(cfg, { over: handlerIn, out: handlerIn, selector: handlerOut } );
|
||||
}
|
||||
|
||||
// A private function for handling mouse 'hovering'
|
||||
var handleHover = function(e) {
|
||||
// cloned event to pass to handlers (copy required for event object to be passed in IE)
|
||||
var ev = $.extend({},e);
|
||||
|
||||
// the current target of the mouse event, wrapped in a jQuery object
|
||||
var $el = $(this);
|
||||
|
||||
// read hoverIntent data from element (or initialize if not present)
|
||||
var hoverIntentData = $el.data('hoverIntent');
|
||||
if (!hoverIntentData) { $el.data('hoverIntent', (hoverIntentData = {})); }
|
||||
|
||||
// read per-instance state from element (or initialize if not present)
|
||||
var state = hoverIntentData[instanceId];
|
||||
if (!state) { hoverIntentData[instanceId] = state = { id: instanceId }; }
|
||||
|
||||
// state properties:
|
||||
// id = instance ID, used to clean up data
|
||||
// timeoutId = timeout ID, reused for tracking mouse position and delaying "out" handler
|
||||
// isActive = plugin state, true after `over` is called just until `out` is called
|
||||
// pX, pY = previously-measured pointer coordinates, updated at each polling interval
|
||||
// event = string representing the namespaced event used for mouse tracking
|
||||
|
||||
// clear any existing timeout
|
||||
if (state.timeoutId) { state.timeoutId = clearTimeout(state.timeoutId); }
|
||||
|
||||
// namespaced event used to register and unregister mousemove tracking
|
||||
var mousemove = state.event = 'mousemove.hoverIntent.hoverIntent'+instanceId;
|
||||
|
||||
// handle the event, based on its type
|
||||
if (e.type === 'mouseenter') {
|
||||
// do nothing if already active
|
||||
if (state.isActive) { return; }
|
||||
// set "previous" X and Y position based on initial entry point
|
||||
state.pX = ev.pageX; state.pY = ev.pageY;
|
||||
// update "current" X and Y position based on mousemove
|
||||
$el.off(mousemove,track).on(mousemove,track);
|
||||
// start polling interval (self-calling timeout) to compare mouse coordinates over time
|
||||
state.timeoutId = setTimeout( function(){compare(ev,$el,state,cfg);} , cfg.interval );
|
||||
} else { // "mouseleave"
|
||||
// do nothing if not already active
|
||||
if (!state.isActive) { return; }
|
||||
// unbind expensive mousemove event
|
||||
$el.off(mousemove,track);
|
||||
// if hoverIntent state is true, then call the mouseOut function after the specified delay
|
||||
state.timeoutId = setTimeout( function(){delay(ev,$el,state,cfg.out);} , cfg.timeout );
|
||||
}
|
||||
};
|
||||
|
||||
// listen for mouseenter and mouseleave
|
||||
return this.on({'mouseenter.hoverIntent':handleHover,'mouseleave.hoverIntent':handleHover}, cfg.selector);
|
||||
};
|
||||
});
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
/*! This file is auto-generated */
|
||||
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=e(require("jquery")):jQuery&&!jQuery.fn.hoverIntent&&e(jQuery)}(function(f){"use strict";function u(e){return"function"==typeof e}var i,r,v={interval:100,sensitivity:6,timeout:0},s=0,a=function(e){i=e.pageX,r=e.pageY},p=function(e,t,n,o){if(Math.sqrt((n.pX-i)*(n.pX-i)+(n.pY-r)*(n.pY-r))<o.sensitivity)return t.off(n.event,a),delete n.timeoutId,n.isActive=!0,e.pageX=i,e.pageY=r,delete n.pX,delete n.pY,o.over.apply(t[0],[e]);n.pX=i,n.pY=r,n.timeoutId=setTimeout(function(){p(e,t,n,o)},o.interval)};f.fn.hoverIntent=function(e,t,n){function o(e){var u=f.extend({},e),r=f(this),v=((t=r.data("hoverIntent"))||r.data("hoverIntent",t={}),t[i]),t=(v||(t[i]=v={id:i}),v.timeoutId&&(v.timeoutId=clearTimeout(v.timeoutId)),v.event="mousemove.hoverIntent.hoverIntent"+i);"mouseenter"===e.type?v.isActive||(v.pX=u.pageX,v.pY=u.pageY,r.off(t,a).on(t,a),v.timeoutId=setTimeout(function(){p(u,r,v,d)},d.interval)):v.isActive&&(r.off(t,a),v.timeoutId=setTimeout(function(){var e,t,n,o,i;e=u,t=r,n=v,o=d.out,(i=t.data("hoverIntent"))&&delete i[n.id],o.apply(t[0],[e])},d.timeout))}var i=s++,d=f.extend({},v);f.isPlainObject(e)?(d=f.extend(d,e),u(d.out)||(d.out=d.over)):d=u(t)?f.extend(d,{over:e,out:t,selector:n}):f.extend(d,{over:e,out:e,selector:t});return this.on({"mouseenter.hoverIntent":o,"mouseleave.hoverIntent":o},d.selector)}});
|
||||
+2
-2
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(e,t){if("function"==typeof define&&define.amd)define("hoverintent",["module"],t);else if("undefined"!=typeof exports)t(module);else{var n={exports:{}};t(n),e.hoverintent=n.exports}}(this,function(e){"use strict";var t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e};e.exports=function(e,n,o){function i(e,t){return y&&(y=clearTimeout(y)),b=0,p?void 0:o.call(e,t)}function r(e){m=e.clientX,d=e.clientY}function u(e,t){if(y&&(y=clearTimeout(y)),Math.abs(h-m)+Math.abs(E-d)<x.sensitivity)return b=1,p?void 0:n.call(e,t);h=m,E=d,y=setTimeout(function(){u(e,t)},x.interval)}function s(t){return L=!0,y&&(y=clearTimeout(y)),e.removeEventListener("mousemove",r,!1),1!==b&&(h=t.clientX,E=t.clientY,e.addEventListener("mousemove",r,!1),y=setTimeout(function(){u(e,t)},x.interval)),this}function c(t){return L=!1,y&&(y=clearTimeout(y)),e.removeEventListener("mousemove",r,!1),1===b&&(y=setTimeout(function(){i(e,t)},x.timeout)),this}function v(t){L||(p=!0,n.call(e,t))}function a(t){!L&&p&&(p=!1,o.call(e,t))}function f(){e.addEventListener("focus",v,!1),e.addEventListener("blur",a,!1)}function l(){e.removeEventListener("focus",v,!1),e.removeEventListener("blur",a,!1)}var m,d,h,E,L=!1,p=!1,T={},b=0,y=0,x={sensitivity:7,interval:100,timeout:0,handleFocus:!1};return T.options=function(e){var n=e.handleFocus!==x.handleFocus;return x=t({},x,e),n&&(x.handleFocus?f():l()),T},T.remove=function(){e&&(e.removeEventListener("mouseover",s,!1),e.removeEventListener("mouseout",c,!1),l())},e&&(e.addEventListener("mouseover",s,!1),e.addEventListener("mouseout",c,!1)),T}});
|
||||
/*! This file is auto-generated */
|
||||
!function(e,t){if("function"==typeof define&&define.amd)define("hoverintent",["module"],t);else if("undefined"!=typeof exports)t(module);else{var n={exports:{}};t(n),e.hoverintent=n.exports}}(this,function(e){"use strict";var t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e};e.exports=function(e,n,o){function i(e,t){return y&&(y=clearTimeout(y)),b=0,p?void 0:o.call(e,t)}function r(e){m=e.clientX,d=e.clientY}function u(e,t){if(y&&(y=clearTimeout(y)),Math.abs(h-m)+Math.abs(E-d)<x.sensitivity)return b=1,p?void 0:n.call(e,t);h=m,E=d,y=setTimeout(function(){u(e,t)},x.interval)}function s(t){return L=!0,y&&(y=clearTimeout(y)),e.removeEventListener("mousemove",r,!1),1!==b&&(h=t.clientX,E=t.clientY,e.addEventListener("mousemove",r,!1),y=setTimeout(function(){u(e,t)},x.interval)),this}function c(t){return L=!1,y&&(y=clearTimeout(y)),e.removeEventListener("mousemove",r,!1),1===b&&(y=setTimeout(function(){i(e,t)},x.timeout)),this}function v(t){L||(p=!0,n.call(e,t))}function a(t){!L&&p&&(p=!1,o.call(e,t))}function f(){e.addEventListener("focus",v,!1),e.addEventListener("blur",a,!1)}function l(){e.removeEventListener("focus",v,!1),e.removeEventListener("blur",a,!1)}var m,d,h,E,L=!1,p=!1,T={},b=0,y=0,x={sensitivity:7,interval:100,timeout:0,handleFocus:!1};return T.options=function(e){var n=e.handleFocus!==x.handleFocus;return x=t({},x,e),n&&(x.handleFocus?f():l()),T},T.remove=function(){e&&(e.removeEventListener("mouseover",s,!1),e.removeEventListener("mouseout",c,!1),l())},e&&(e.addEventListener("mouseover",s,!1),e.addEventListener("mouseout",c,!1)),T}});
|
||||
|
||||
+12
-12
@@ -1,13 +1,13 @@
|
||||
/*! This file is auto-generated */
|
||||
/*!
|
||||
* imagesLoaded PACKAGED v5.0.0
|
||||
* JavaScript is all like "You images are done yet or what?"
|
||||
* MIT License
|
||||
*/
|
||||
!function(t,e){"object"==typeof module&&module.exports?module.exports=e():t.EvEmitter=e()}("undefined"!=typeof window?window:this,(function(){function t(){}let e=t.prototype;return e.on=function(t,e){if(!t||!e)return this;let i=this._events=this._events||{},s=i[t]=i[t]||[];return s.includes(e)||s.push(e),this},e.once=function(t,e){if(!t||!e)return this;this.on(t,e);let i=this._onceEvents=this._onceEvents||{};return(i[t]=i[t]||{})[e]=!0,this},e.off=function(t,e){let i=this._events&&this._events[t];if(!i||!i.length)return this;let s=i.indexOf(e);return-1!=s&&i.splice(s,1),this},e.emitEvent=function(t,e){let i=this._events&&this._events[t];if(!i||!i.length)return this;i=i.slice(0),e=e||[];let s=this._onceEvents&&this._onceEvents[t];for(let n of i){s&&s[n]&&(this.off(t,n),delete s[n]),n.apply(this,e)}return this},e.allOff=function(){return delete this._events,delete this._onceEvents,this},t})),
|
||||
/*!
|
||||
* imagesLoaded v5.0.0
|
||||
* JavaScript is all like "You images are done yet or what?"
|
||||
* MIT License
|
||||
*/
|
||||
/*! This file is auto-generated */
|
||||
/*!
|
||||
* imagesLoaded PACKAGED v5.0.0
|
||||
* JavaScript is all like "You images are done yet or what?"
|
||||
* MIT License
|
||||
*/
|
||||
!function(t,e){"object"==typeof module&&module.exports?module.exports=e():t.EvEmitter=e()}("undefined"!=typeof window?window:this,(function(){function t(){}let e=t.prototype;return e.on=function(t,e){if(!t||!e)return this;let i=this._events=this._events||{},s=i[t]=i[t]||[];return s.includes(e)||s.push(e),this},e.once=function(t,e){if(!t||!e)return this;this.on(t,e);let i=this._onceEvents=this._onceEvents||{};return(i[t]=i[t]||{})[e]=!0,this},e.off=function(t,e){let i=this._events&&this._events[t];if(!i||!i.length)return this;let s=i.indexOf(e);return-1!=s&&i.splice(s,1),this},e.emitEvent=function(t,e){let i=this._events&&this._events[t];if(!i||!i.length)return this;i=i.slice(0),e=e||[];let s=this._onceEvents&&this._onceEvents[t];for(let n of i){s&&s[n]&&(this.off(t,n),delete s[n]),n.apply(this,e)}return this},e.allOff=function(){return delete this._events,delete this._onceEvents,this},t})),
|
||||
/*!
|
||||
* imagesLoaded v5.0.0
|
||||
* JavaScript is all like "You images are done yet or what?"
|
||||
* MIT License
|
||||
*/
|
||||
function(t,e){"object"==typeof module&&module.exports?module.exports=e(t,require("ev-emitter")):t.imagesLoaded=e(t,t.EvEmitter)}("undefined"!=typeof window?window:this,(function(t,e){let i=t.jQuery,s=t.console;function n(t,e,o){if(!(this instanceof n))return new n(t,e,o);let r=t;var h;("string"==typeof t&&(r=document.querySelectorAll(t)),r)?(this.elements=(h=r,Array.isArray(h)?h:"object"==typeof h&&"number"==typeof h.length?[...h]:[h]),this.options={},"function"==typeof e?o=e:Object.assign(this.options,e),o&&this.on("always",o),this.getImages(),i&&(this.jqDeferred=new i.Deferred),setTimeout(this.check.bind(this))):s.error(`Bad element for imagesLoaded ${r||t}`)}n.prototype=Object.create(e.prototype),n.prototype.getImages=function(){this.images=[],this.elements.forEach(this.addElementImages,this)};const o=[1,9,11];n.prototype.addElementImages=function(t){"IMG"===t.nodeName&&this.addImage(t),!0===this.options.background&&this.addElementBackgroundImages(t);let{nodeType:e}=t;if(!e||!o.includes(e))return;let i=t.querySelectorAll("img");for(let t of i)this.addImage(t);if("string"==typeof this.options.background){let e=t.querySelectorAll(this.options.background);for(let t of e)this.addElementBackgroundImages(t)}};const r=/url\((['"])?(.*?)\1\)/gi;function h(t){this.img=t}function d(t,e){this.url=t,this.element=e,this.img=new Image}return n.prototype.addElementBackgroundImages=function(t){let e=getComputedStyle(t);if(!e)return;let i=r.exec(e.backgroundImage);for(;null!==i;){let s=i&&i[2];s&&this.addBackground(s,t),i=r.exec(e.backgroundImage)}},n.prototype.addImage=function(t){let e=new h(t);this.images.push(e)},n.prototype.addBackground=function(t,e){let i=new d(t,e);this.images.push(i)},n.prototype.check=function(){if(this.progressedCount=0,this.hasAnyBroken=!1,!this.images.length)return void this.complete();let t=(t,e,i)=>{setTimeout((()=>{this.progress(t,e,i)}))};this.images.forEach((function(e){e.once("progress",t),e.check()}))},n.prototype.progress=function(t,e,i){this.progressedCount++,this.hasAnyBroken=this.hasAnyBroken||!t.isLoaded,this.emitEvent("progress",[this,t,e]),this.jqDeferred&&this.jqDeferred.notify&&this.jqDeferred.notify(this,t),this.progressedCount===this.images.length&&this.complete(),this.options.debug&&s&&s.log(`progress: ${i}`,t,e)},n.prototype.complete=function(){let t=this.hasAnyBroken?"fail":"done";if(this.isComplete=!0,this.emitEvent(t,[this]),this.emitEvent("always",[this]),this.jqDeferred){let t=this.hasAnyBroken?"reject":"resolve";this.jqDeferred[t](this)}},h.prototype=Object.create(e.prototype),h.prototype.check=function(){this.getIsImageComplete()?this.confirm(0!==this.img.naturalWidth,"naturalWidth"):(this.proxyImage=new Image,this.img.crossOrigin&&(this.proxyImage.crossOrigin=this.img.crossOrigin),this.proxyImage.addEventListener("load",this),this.proxyImage.addEventListener("error",this),this.img.addEventListener("load",this),this.img.addEventListener("error",this),this.proxyImage.src=this.img.currentSrc||this.img.src)},h.prototype.getIsImageComplete=function(){return this.img.complete&&this.img.naturalWidth},h.prototype.confirm=function(t,e){this.isLoaded=t;let{parentNode:i}=this.img,s="PICTURE"===i.nodeName?i:this.img;this.emitEvent("progress",[this,s,e])},h.prototype.handleEvent=function(t){let e="on"+t.type;this[e]&&this[e](t)},h.prototype.onload=function(){this.confirm(!0,"onload"),this.unbindEvents()},h.prototype.onerror=function(){this.confirm(!1,"onerror"),this.unbindEvents()},h.prototype.unbindEvents=function(){this.proxyImage.removeEventListener("load",this),this.proxyImage.removeEventListener("error",this),this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},d.prototype=Object.create(h.prototype),d.prototype.check=function(){this.img.addEventListener("load",this),this.img.addEventListener("error",this),this.img.src=this.url,this.getIsImageComplete()&&(this.confirm(0!==this.img.naturalWidth,"naturalWidth"),this.unbindEvents())},d.prototype.unbindEvents=function(){this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},d.prototype.confirm=function(t,e){this.isLoaded=t,this.emitEvent("progress",[this,this.element,e])},n.makeJQueryPlugin=function(e){(e=e||t.jQuery)&&(i=e,i.fn.imagesLoaded=function(t,e){return new n(this,t,e).jqDeferred.promise(i(this))})},n.makeJQueryPlugin(),n}));
|
||||
@@ -1,41 +1,41 @@
|
||||
/*
|
||||
* imgAreaSelect animated border style
|
||||
*/
|
||||
|
||||
.imgareaselect-border1 {
|
||||
background: url(border-anim-v.gif) repeat-y left top;
|
||||
}
|
||||
|
||||
.imgareaselect-border2 {
|
||||
background: url(border-anim-h.gif) repeat-x left top;
|
||||
}
|
||||
|
||||
.imgareaselect-border3 {
|
||||
background: url(border-anim-v.gif) repeat-y right top;
|
||||
}
|
||||
|
||||
.imgareaselect-border4 {
|
||||
background: url(border-anim-h.gif) repeat-x left bottom;
|
||||
}
|
||||
|
||||
.imgareaselect-border1, .imgareaselect-border2,
|
||||
.imgareaselect-border3, .imgareaselect-border4 {
|
||||
filter: alpha(opacity=50);
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.imgareaselect-handle {
|
||||
background-color: #fff;
|
||||
border: solid 1px #000;
|
||||
filter: alpha(opacity=50);
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.imgareaselect-outer {
|
||||
background-color: #000;
|
||||
filter: alpha(opacity=50);
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.imgareaselect-selection {
|
||||
}
|
||||
/*
|
||||
* imgAreaSelect animated border style
|
||||
*/
|
||||
|
||||
.imgareaselect-border1 {
|
||||
background: url(border-anim-v.gif) repeat-y left top;
|
||||
}
|
||||
|
||||
.imgareaselect-border2 {
|
||||
background: url(border-anim-h.gif) repeat-x left top;
|
||||
}
|
||||
|
||||
.imgareaselect-border3 {
|
||||
background: url(border-anim-v.gif) repeat-y right top;
|
||||
}
|
||||
|
||||
.imgareaselect-border4 {
|
||||
background: url(border-anim-h.gif) repeat-x left bottom;
|
||||
}
|
||||
|
||||
.imgareaselect-border1, .imgareaselect-border2,
|
||||
.imgareaselect-border3, .imgareaselect-border4 {
|
||||
filter: alpha(opacity=50);
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.imgareaselect-handle {
|
||||
background-color: #fff;
|
||||
border: solid 1px #000;
|
||||
filter: alpha(opacity=50);
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.imgareaselect-outer {
|
||||
background-color: #000;
|
||||
filter: alpha(opacity=50);
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.imgareaselect-selection {
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -1,2 +1,2 @@
|
||||
/* jquery.Jcrop.min.css v0.9.15 (build:20180819) */
|
||||
.jcrop-holder{direction:ltr;text-align:left;-ms-touch-action:none}.jcrop-hline,.jcrop-vline{background:#fff url(Jcrop.gif);font-size:0;position:absolute}.jcrop-vline{height:100%;width:1px!important}.jcrop-vline.right{right:0}.jcrop-hline{height:1px!important;width:100%}.jcrop-hline.bottom{bottom:0}.jcrop-tracker{height:100%;width:100%;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;-webkit-user-select:none}.jcrop-handle{background-color:#333;border:1px #eee solid;width:7px;height:7px;font-size:1px}.jcrop-handle.ord-n{left:50%;margin-left:-4px;margin-top:-4px;top:0}.jcrop-handle.ord-s{bottom:0;left:50%;margin-bottom:-4px;margin-left:-4px}.jcrop-handle.ord-e{margin-right:-4px;margin-top:-4px;right:0;top:50%}.jcrop-handle.ord-w{left:0;margin-left:-4px;margin-top:-4px;top:50%}.jcrop-handle.ord-nw{left:0;margin-left:-4px;margin-top:-4px;top:0}.jcrop-handle.ord-ne{margin-right:-4px;margin-top:-4px;right:0;top:0}.jcrop-handle.ord-se{bottom:0;margin-bottom:-4px;margin-right:-4px;right:0}.jcrop-handle.ord-sw{bottom:0;left:0;margin-bottom:-4px;margin-left:-4px}.jcrop-dragbar.ord-n,.jcrop-dragbar.ord-s{height:7px;width:100%}.jcrop-dragbar.ord-e,.jcrop-dragbar.ord-w{height:100%;width:7px}.jcrop-dragbar.ord-n{margin-top:-4px}.jcrop-dragbar.ord-s{bottom:0;margin-bottom:-4px}.jcrop-dragbar.ord-e{margin-right:-4px;right:0}.jcrop-dragbar.ord-w{margin-left:-4px}.jcrop-light .jcrop-hline,.jcrop-light .jcrop-vline{background:#fff;filter:alpha(opacity=70)!important;opacity:.7!important}.jcrop-light .jcrop-handle{-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#000;border-color:#fff;border-radius:3px}.jcrop-dark .jcrop-hline,.jcrop-dark .jcrop-vline{background:#000;filter:alpha(opacity=70)!important;opacity:.7!important}.jcrop-dark .jcrop-handle{-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#fff;border-color:#000;border-radius:3px}.solid-line .jcrop-hline,.solid-line .jcrop-vline{background:#fff}.jcrop-holder img,img.jcrop-preview{max-width:none}
|
||||
/* jquery.Jcrop.min.css v0.9.15 (build:20180819) */
|
||||
.jcrop-holder{direction:ltr;text-align:left;-ms-touch-action:none}.jcrop-hline,.jcrop-vline{background:#fff url(Jcrop.gif);font-size:0;position:absolute}.jcrop-vline{height:100%;width:1px!important}.jcrop-vline.right{right:0}.jcrop-hline{height:1px!important;width:100%}.jcrop-hline.bottom{bottom:0}.jcrop-tracker{height:100%;width:100%;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;-webkit-user-select:none}.jcrop-handle{background-color:#333;border:1px #eee solid;width:7px;height:7px;font-size:1px}.jcrop-handle.ord-n{left:50%;margin-left:-4px;margin-top:-4px;top:0}.jcrop-handle.ord-s{bottom:0;left:50%;margin-bottom:-4px;margin-left:-4px}.jcrop-handle.ord-e{margin-right:-4px;margin-top:-4px;right:0;top:50%}.jcrop-handle.ord-w{left:0;margin-left:-4px;margin-top:-4px;top:50%}.jcrop-handle.ord-nw{left:0;margin-left:-4px;margin-top:-4px;top:0}.jcrop-handle.ord-ne{margin-right:-4px;margin-top:-4px;right:0;top:0}.jcrop-handle.ord-se{bottom:0;margin-bottom:-4px;margin-right:-4px;right:0}.jcrop-handle.ord-sw{bottom:0;left:0;margin-bottom:-4px;margin-left:-4px}.jcrop-dragbar.ord-n,.jcrop-dragbar.ord-s{height:7px;width:100%}.jcrop-dragbar.ord-e,.jcrop-dragbar.ord-w{height:100%;width:7px}.jcrop-dragbar.ord-n{margin-top:-4px}.jcrop-dragbar.ord-s{bottom:0;margin-bottom:-4px}.jcrop-dragbar.ord-e{margin-right:-4px;right:0}.jcrop-dragbar.ord-w{margin-left:-4px}.jcrop-light .jcrop-hline,.jcrop-light .jcrop-vline{background:#fff;filter:alpha(opacity=70)!important;opacity:.7!important}.jcrop-light .jcrop-handle{-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#000;border-color:#fff;border-radius:3px}.jcrop-dark .jcrop-hline,.jcrop-dark .jcrop-vline{background:#000;filter:alpha(opacity=70)!important;opacity:.7!important}.jcrop-dark .jcrop-handle{-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#fff;border-color:#000;border-radius:3px}.solid-line .jcrop-hline,.solid-line .jcrop-vline{background:#fff}.jcrop-holder img,img.jcrop-preview{max-width:none}
|
||||
|
||||
+7
-7
File diff suppressed because one or more lines are too long
+1018
-1018
File diff suppressed because it is too large
Load Diff
+2
-2
File diff suppressed because one or more lines are too long
+2
-2
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -1,134 +1,134 @@
|
||||
/******************************************************************************************************************************
|
||||
|
||||
* @ Original idea by by Binny V A, Original version: 2.00.A
|
||||
* @ http://www.openjs.com/scripts/events/keyboard_shortcuts/
|
||||
* @ Original License : BSD
|
||||
|
||||
* @ jQuery Plugin by Tzury Bar Yochay
|
||||
mail: tzury.by@gmail.com
|
||||
blog: evalinux.wordpress.com
|
||||
face: facebook.com/profile.php?id=513676303
|
||||
|
||||
(c) Copyrights 2007
|
||||
|
||||
* @ jQuery Plugin version Beta (0.0.2)
|
||||
* @ License: jQuery-License.
|
||||
|
||||
TODO:
|
||||
add queue support (as in gmail) e.g. 'x' then 'y', etc.
|
||||
add mouse + mouse wheel events.
|
||||
|
||||
USAGE:
|
||||
$.hotkeys.add('Ctrl+c', function(){ alert('copy anyone?');});
|
||||
$.hotkeys.add('Ctrl+c', {target:'div#editor', type:'keyup', propagate: true},function(){ alert('copy anyone?');});>
|
||||
$.hotkeys.remove('Ctrl+c');
|
||||
$.hotkeys.remove('Ctrl+c', {target:'div#editor', type:'keypress'});
|
||||
|
||||
******************************************************************************************************************************/
|
||||
(function (jQuery){
|
||||
this.version = '(beta)(0.0.3)';
|
||||
this.all = {};
|
||||
this.special_keys = {
|
||||
27: 'esc', 9: 'tab', 32:'space', 13: 'return', 8:'backspace', 145: 'scroll', 20: 'capslock',
|
||||
144: 'numlock', 19:'pause', 45:'insert', 36:'home', 46:'del',35:'end', 33: 'pageup',
|
||||
34:'pagedown', 37:'left', 38:'up', 39:'right',40:'down', 112:'f1',113:'f2', 114:'f3',
|
||||
115:'f4', 116:'f5', 117:'f6', 118:'f7', 119:'f8', 120:'f9', 121:'f10', 122:'f11', 123:'f12'};
|
||||
|
||||
this.shift_nums = { "`":"~", "1":"!", "2":"@", "3":"#", "4":"$", "5":"%", "6":"^", "7":"&",
|
||||
"8":"*", "9":"(", "0":")", "-":"_", "=":"+", ";":":", "'":"\"", ",":"<",
|
||||
".":">", "/":"?", "\\":"|" };
|
||||
|
||||
this.add = function(combi, options, callback) {
|
||||
if ( typeof options === 'function' ){
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
var opt = {},
|
||||
defaults = {type: 'keydown', propagate: false, disableInInput: false, target: jQuery('html')[0]},
|
||||
that = this;
|
||||
opt = jQuery.extend( opt , defaults, options || {} );
|
||||
combi = combi.toLowerCase();
|
||||
|
||||
// inspect if keystroke matches
|
||||
var inspector = function(event) {
|
||||
// WP: not needed with newer jQuery
|
||||
// event = jQuery.event.fix(event); // jQuery event normalization.
|
||||
var element = event.target;
|
||||
// @ TextNode -> nodeType == 3
|
||||
// WP: not needed with newer jQuery
|
||||
// element = (element.nodeType==3) ? element.parentNode : element;
|
||||
|
||||
if ( opt['disableInInput'] ) { // Disable shortcut keys in Input, Textarea fields
|
||||
var target = jQuery(element);
|
||||
|
||||
if ( ( target.is('input') || target.is('textarea') ) &&
|
||||
( ! opt.noDisable || ! target.is( opt.noDisable ) ) ) {
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
var code = event.which,
|
||||
type = event.type,
|
||||
character = String.fromCharCode(code).toLowerCase(),
|
||||
special = that.special_keys[code],
|
||||
shift = event.shiftKey,
|
||||
ctrl = event.ctrlKey,
|
||||
alt= event.altKey,
|
||||
meta = event.metaKey,
|
||||
propagate = true, // default behaivour
|
||||
mapPoint = null;
|
||||
|
||||
// in opera + safari, the event.target is unpredictable.
|
||||
// for example: 'keydown' might be associated with HtmlBodyElement
|
||||
// or the element where you last clicked with your mouse.
|
||||
// WP: needed for all browsers
|
||||
// if (jQuery.browser.opera || jQuery.browser.safari){
|
||||
while (!that.all[element] && element.parentNode){
|
||||
element = element.parentNode;
|
||||
}
|
||||
// }
|
||||
var cbMap = that.all[element].events[type].callbackMap;
|
||||
if(!shift && !ctrl && !alt && !meta) { // No Modifiers
|
||||
mapPoint = cbMap[special] || cbMap[character]
|
||||
}
|
||||
// deals with combinaitons (alt|ctrl|shift+anything)
|
||||
else{
|
||||
var modif = '';
|
||||
if(alt) modif +='alt+';
|
||||
if(ctrl) modif+= 'ctrl+';
|
||||
if(shift) modif += 'shift+';
|
||||
if(meta) modif += 'meta+';
|
||||
// modifiers + special keys or modifiers + characters or modifiers + shift characters
|
||||
mapPoint = cbMap[modif+special] || cbMap[modif+character] || cbMap[modif+that.shift_nums[character]]
|
||||
}
|
||||
if (mapPoint){
|
||||
mapPoint.cb(event);
|
||||
if(!mapPoint.propagate) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
// first hook for this element
|
||||
if (!this.all[opt.target]){
|
||||
this.all[opt.target] = {events:{}};
|
||||
}
|
||||
if (!this.all[opt.target].events[opt.type]){
|
||||
this.all[opt.target].events[opt.type] = {callbackMap: {}}
|
||||
jQuery.event.add(opt.target, opt.type, inspector);
|
||||
}
|
||||
this.all[opt.target].events[opt.type].callbackMap[combi] = {cb: callback, propagate:opt.propagate};
|
||||
return jQuery;
|
||||
};
|
||||
this.remove = function(exp, opt) {
|
||||
opt = opt || {};
|
||||
target = opt.target || jQuery('html')[0];
|
||||
type = opt.type || 'keydown';
|
||||
exp = exp.toLowerCase();
|
||||
delete this.all[target].events[type].callbackMap[exp]
|
||||
return jQuery;
|
||||
};
|
||||
jQuery.hotkeys = this;
|
||||
return jQuery;
|
||||
})(jQuery);
|
||||
/******************************************************************************************************************************
|
||||
|
||||
* @ Original idea by by Binny V A, Original version: 2.00.A
|
||||
* @ http://www.openjs.com/scripts/events/keyboard_shortcuts/
|
||||
* @ Original License : BSD
|
||||
|
||||
* @ jQuery Plugin by Tzury Bar Yochay
|
||||
mail: tzury.by@gmail.com
|
||||
blog: evalinux.wordpress.com
|
||||
face: facebook.com/profile.php?id=513676303
|
||||
|
||||
(c) Copyrights 2007
|
||||
|
||||
* @ jQuery Plugin version Beta (0.0.2)
|
||||
* @ License: jQuery-License.
|
||||
|
||||
TODO:
|
||||
add queue support (as in gmail) e.g. 'x' then 'y', etc.
|
||||
add mouse + mouse wheel events.
|
||||
|
||||
USAGE:
|
||||
$.hotkeys.add('Ctrl+c', function(){ alert('copy anyone?');});
|
||||
$.hotkeys.add('Ctrl+c', {target:'div#editor', type:'keyup', propagate: true},function(){ alert('copy anyone?');});>
|
||||
$.hotkeys.remove('Ctrl+c');
|
||||
$.hotkeys.remove('Ctrl+c', {target:'div#editor', type:'keypress'});
|
||||
|
||||
******************************************************************************************************************************/
|
||||
(function (jQuery){
|
||||
this.version = '(beta)(0.0.3)';
|
||||
this.all = {};
|
||||
this.special_keys = {
|
||||
27: 'esc', 9: 'tab', 32:'space', 13: 'return', 8:'backspace', 145: 'scroll', 20: 'capslock',
|
||||
144: 'numlock', 19:'pause', 45:'insert', 36:'home', 46:'del',35:'end', 33: 'pageup',
|
||||
34:'pagedown', 37:'left', 38:'up', 39:'right',40:'down', 112:'f1',113:'f2', 114:'f3',
|
||||
115:'f4', 116:'f5', 117:'f6', 118:'f7', 119:'f8', 120:'f9', 121:'f10', 122:'f11', 123:'f12'};
|
||||
|
||||
this.shift_nums = { "`":"~", "1":"!", "2":"@", "3":"#", "4":"$", "5":"%", "6":"^", "7":"&",
|
||||
"8":"*", "9":"(", "0":")", "-":"_", "=":"+", ";":":", "'":"\"", ",":"<",
|
||||
".":">", "/":"?", "\\":"|" };
|
||||
|
||||
this.add = function(combi, options, callback) {
|
||||
if ( typeof options === 'function' ){
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
var opt = {},
|
||||
defaults = {type: 'keydown', propagate: false, disableInInput: false, target: jQuery('html')[0]},
|
||||
that = this;
|
||||
opt = jQuery.extend( opt , defaults, options || {} );
|
||||
combi = combi.toLowerCase();
|
||||
|
||||
// inspect if keystroke matches
|
||||
var inspector = function(event) {
|
||||
// WP: not needed with newer jQuery
|
||||
// event = jQuery.event.fix(event); // jQuery event normalization.
|
||||
var element = event.target;
|
||||
// @ TextNode -> nodeType == 3
|
||||
// WP: not needed with newer jQuery
|
||||
// element = (element.nodeType==3) ? element.parentNode : element;
|
||||
|
||||
if ( opt['disableInInput'] ) { // Disable shortcut keys in Input, Textarea fields
|
||||
var target = jQuery(element);
|
||||
|
||||
if ( ( target.is('input') || target.is('textarea') ) &&
|
||||
( ! opt.noDisable || ! target.is( opt.noDisable ) ) ) {
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
var code = event.which,
|
||||
type = event.type,
|
||||
character = String.fromCharCode(code).toLowerCase(),
|
||||
special = that.special_keys[code],
|
||||
shift = event.shiftKey,
|
||||
ctrl = event.ctrlKey,
|
||||
alt= event.altKey,
|
||||
meta = event.metaKey,
|
||||
propagate = true, // default behaivour
|
||||
mapPoint = null;
|
||||
|
||||
// in opera + safari, the event.target is unpredictable.
|
||||
// for example: 'keydown' might be associated with HtmlBodyElement
|
||||
// or the element where you last clicked with your mouse.
|
||||
// WP: needed for all browsers
|
||||
// if (jQuery.browser.opera || jQuery.browser.safari){
|
||||
while (!that.all[element] && element.parentNode){
|
||||
element = element.parentNode;
|
||||
}
|
||||
// }
|
||||
var cbMap = that.all[element].events[type].callbackMap;
|
||||
if(!shift && !ctrl && !alt && !meta) { // No Modifiers
|
||||
mapPoint = cbMap[special] || cbMap[character]
|
||||
}
|
||||
// deals with combinaitons (alt|ctrl|shift+anything)
|
||||
else{
|
||||
var modif = '';
|
||||
if(alt) modif +='alt+';
|
||||
if(ctrl) modif+= 'ctrl+';
|
||||
if(shift) modif += 'shift+';
|
||||
if(meta) modif += 'meta+';
|
||||
// modifiers + special keys or modifiers + characters or modifiers + shift characters
|
||||
mapPoint = cbMap[modif+special] || cbMap[modif+character] || cbMap[modif+that.shift_nums[character]]
|
||||
}
|
||||
if (mapPoint){
|
||||
mapPoint.cb(event);
|
||||
if(!mapPoint.propagate) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
// first hook for this element
|
||||
if (!this.all[opt.target]){
|
||||
this.all[opt.target] = {events:{}};
|
||||
}
|
||||
if (!this.all[opt.target].events[opt.type]){
|
||||
this.all[opt.target].events[opt.type] = {callbackMap: {}}
|
||||
jQuery.event.add(opt.target, opt.type, inspector);
|
||||
}
|
||||
this.all[opt.target].events[opt.type].callbackMap[combi] = {cb: callback, propagate:opt.propagate};
|
||||
return jQuery;
|
||||
};
|
||||
this.remove = function(exp, opt) {
|
||||
opt = opt || {};
|
||||
target = opt.target || jQuery('html')[0];
|
||||
type = opt.type || 'keydown';
|
||||
exp = exp.toLowerCase();
|
||||
delete this.all[target].events[type].callbackMap[exp]
|
||||
return jQuery;
|
||||
};
|
||||
jQuery.hotkeys = this;
|
||||
return jQuery;
|
||||
})(jQuery);
|
||||
|
||||
+10716
-10716
File diff suppressed because it is too large
Load Diff
+10
-10
@@ -1,11 +1,11 @@
|
||||
/*!
|
||||
* Masonry v2 shim
|
||||
* to maintain backwards compatibility
|
||||
* as of Masonry v3.1.2
|
||||
*
|
||||
* Cascading grid layout library
|
||||
* http://masonry.desandro.com
|
||||
* MIT License
|
||||
* by David DeSandro
|
||||
*/
|
||||
/*!
|
||||
* Masonry v2 shim
|
||||
* to maintain backwards compatibility
|
||||
* as of Masonry v3.1.2
|
||||
*
|
||||
* Cascading grid layout library
|
||||
* http://masonry.desandro.com
|
||||
* MIT License
|
||||
* by David DeSandro
|
||||
*/
|
||||
!function(a){"use strict";var b=a.Masonry;b.prototype._remapV2Options=function(){this._remapOption("gutterWidth","gutter"),this._remapOption("isResizable","isResizeBound"),this._remapOption("isRTL","isOriginLeft",function(a){return!a});var a=this.options.isAnimated;if(void 0!==a&&(this.options.transitionDuration=a?this.options.transitionDuration:0),void 0===a||a){var b=this.options.animationOptions,c=b&&b.duration;c&&(this.options.transitionDuration="string"==typeof c?c:c+"ms")}},b.prototype._remapOption=function(a,b,c){var d=this.options[a];void 0!==d&&(this.options[b]=c?c(d):d)};var c=b.prototype._create;b.prototype._create=function(){var a=this;this._remapV2Options(),c.apply(this,arguments),setTimeout(function(){jQuery(a.element).addClass("masonry")},0)};var d=b.prototype.layout;b.prototype.layout=function(){this._remapV2Options(),d.apply(this,arguments)};var e=b.prototype.option;b.prototype.option=function(){e.apply(this,arguments),this._remapV2Options()};var f=b.prototype._itemize;b.prototype._itemize=function(a){var b=f.apply(this,arguments);return jQuery(a).addClass("masonry-brick"),b};var g=b.prototype.measureColumns;b.prototype.measureColumns=function(){var a=this.options.columnWidth;a&&"function"==typeof a&&(this.getContainerWidth(),this.columnWidth=a(this.containerWidth)),g.apply(this,arguments)},b.prototype.reload=function(){this.reloadItems.apply(this,arguments),this.layout.apply(this)};var h=b.prototype.destroy;b.prototype.destroy=function(){var a=this.getItemElements();jQuery(this.element).removeClass("masonry"),jQuery(a).removeClass("masonry-brick"),h.apply(this,arguments)}}(window);
|
||||
+2
-2
File diff suppressed because one or more lines are too long
@@ -1,11 +1,11 @@
|
||||
/**
|
||||
* jQuery.query - Query String Modification and Creation for jQuery
|
||||
* Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
|
||||
* Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
|
||||
* Date: 2009/8/13
|
||||
*
|
||||
* @author Blair Mitchelmore
|
||||
* @version 2.2.3
|
||||
*
|
||||
**/
|
||||
!function(e){var t=e.separator||"&",l=!1!==e.spaces,n=(e.suffix,!1!==e.prefix?!0===e.hash?"#":"?":""),i=!1!==e.numbers;jQuery.query=new function(){function c(e,t){return null!=e&&null!==e&&(!t||e.constructor==t)}function u(e){for(var t,n=/\[([^[]*)\]/g,r=/^([^[]+)(\[.*\])?$/.exec(e),e=r[1],u=[];t=n.exec(r[2]);)u.push(t[1]);return[e,u]}function o(e,t,n){var r=t.shift();if("object"!=typeof e&&(e=null),""===r)if(c(e=e||[],Array))e.push(0==t.length?n:o(null,t.slice(0),n));else if(c(e,Object)){for(var u=0;null!=e[u++];);e[--u]=0==t.length?n:o(e[u],t.slice(0),n)}else(e=[]).push(0==t.length?n:o(null,t.slice(0),n));else if(r&&r.match(/^\s*[0-9]+\s*$/))(e=e||[])[i=parseInt(r,10)]=0==t.length?n:o(e[i],t.slice(0),n);else{if(!r)return n;var i=r.replace(/^\s*|\s*$/g,"");if(c(e=e||{},Array)){for(var s={},u=0;u<e.length;++u)s[u]=e[u];e=s}e[i]=0==t.length?n:o(e[i],t.slice(0),n)}return e}function r(e){var n=this;return n.keys={},e.queryObject?jQuery.each(e.get(),function(e,t){n.SET(e,t)}):n.parseNew.apply(n,arguments),n}return r.prototype={queryObject:!0,parseNew:function(){var n=this;return n.keys={},jQuery.each(arguments,function(){var e=""+this;e=(e=e.replace(/^[?#]/,"")).replace(/[;&]$/,""),l&&(e=e.replace(/[+]/g," ")),jQuery.each(e.split(/[&;]/),function(){var e=decodeURIComponent(this.split("=")[0]||""),t=decodeURIComponent(this.split("=")[1]||"");e&&(i&&(/^[+-]?[0-9]+\.[0-9]*$/.test(t)?t=parseFloat(t):/^[+-]?[1-9][0-9]*$/.test(t)&&(t=parseInt(t,10))),n.SET(e,t=!t&&0!==t||t))})}),n},has:function(e,t){e=this.get(e);return c(e,t)},GET:function(e){if(!c(e))return this.keys;for(var e=u(e),t=e[0],n=e[1],r=this.keys[t];null!=r&&0!=n.length;)r=r[n.shift()];return"number"==typeof r?r:r||""},get:function(e){e=this.GET(e);return c(e,Object)?jQuery.extend(!0,{},e):c(e,Array)?e.slice(0):e},SET:function(e,t){var n,r;return e.includes("__proto__")||e.includes("constructor")||e.includes("prototype")||(t=c(t)?t:null,n=(e=u(e))[0],e=e[1],r=this.keys[n],this.keys[n]=o(r,e.slice(0),t)),this},set:function(e,t){return this.copy().SET(e,t)},REMOVE:function(e,t){if(t){var n=this.GET(e);if(c(n,Array)){for(tval in n)n[tval]=n[tval].toString();var r=$.inArray(t,n);if(!(0<=r))return;e=(e=n.splice(r,1))[r]}else if(t!=n)return}return this.SET(e,null).COMPACT()},remove:function(e,t){return this.copy().REMOVE(e,t)},EMPTY:function(){var n=this;return jQuery.each(n.keys,function(e,t){delete n.keys[e]}),n},load:function(e){var t=e.replace(/^.*?[#](.+?)(?:\?.+)?$/,"$1"),n=e.replace(/^.*?[?](.+?)(?:#.+)?$/,"$1");return new r(e.length==n.length?"":n,e.length==t.length?"":t)},empty:function(){return this.copy().EMPTY()},copy:function(){return new r(this)},COMPACT:function(){return this.keys=function r(e){var u="object"==typeof e?c(e,Array)?[]:{}:e;return"object"==typeof e&&jQuery.each(e,function(e,t){if(!c(t))return!0;var n;n=u,t=r(t),c(n,Array)?n.push(t):n[e]=t}),u}(this.keys),this},compact:function(){return this.copy().COMPACT()},toString:function(){function u(e,t){function r(e){return(t&&""!=t?[t,"[",e,"]"]:[e]).join("")}jQuery.each(e,function(e,t){var n;"object"==typeof t?u(t,r(e)):(n=i,e=r(e),c(t=t)&&!1!==t&&(e=[s(e)],!0!==t&&(e.push("="),e.push(s(t))),n.push(e.join(""))))})}var e=[],i=[],s=function(e){return e+="",e=encodeURIComponent(e),e=l?e.replace(/%20/g,"+"):e};return u(this.keys),0<i.length&&e.push(n),e.push(i.join(t)),e.join("")}},new r(location.search,location.hash)}}(jQuery.query||{});
|
||||
/**
|
||||
* jQuery.query - Query String Modification and Creation for jQuery
|
||||
* Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
|
||||
* Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
|
||||
* Date: 2009/8/13
|
||||
*
|
||||
* @author Blair Mitchelmore
|
||||
* @version 2.2.3
|
||||
*
|
||||
**/
|
||||
!function(e){var t=e.separator||"&",l=!1!==e.spaces,n=(e.suffix,!1!==e.prefix?!0===e.hash?"#":"?":""),i=!1!==e.numbers;jQuery.query=new function(){function c(e,t){return null!=e&&null!==e&&(!t||e.constructor==t)}function u(e){for(var t,n=/\[([^[]*)\]/g,r=/^([^[]+)(\[.*\])?$/.exec(e),e=r[1],u=[];t=n.exec(r[2]);)u.push(t[1]);return[e,u]}function o(e,t,n){var r=t.shift();if("object"!=typeof e&&(e=null),""===r)if(c(e=e||[],Array))e.push(0==t.length?n:o(null,t.slice(0),n));else if(c(e,Object)){for(var u=0;null!=e[u++];);e[--u]=0==t.length?n:o(e[u],t.slice(0),n)}else(e=[]).push(0==t.length?n:o(null,t.slice(0),n));else if(r&&r.match(/^\s*[0-9]+\s*$/))(e=e||[])[i=parseInt(r,10)]=0==t.length?n:o(e[i],t.slice(0),n);else{if(!r)return n;var i=r.replace(/^\s*|\s*$/g,"");if(c(e=e||{},Array)){for(var s={},u=0;u<e.length;++u)s[u]=e[u];e=s}e[i]=0==t.length?n:o(e[i],t.slice(0),n)}return e}function r(e){var n=this;return n.keys={},e.queryObject?jQuery.each(e.get(),function(e,t){n.SET(e,t)}):n.parseNew.apply(n,arguments),n}return r.prototype={queryObject:!0,parseNew:function(){var n=this;return n.keys={},jQuery.each(arguments,function(){var e=""+this;e=(e=e.replace(/^[?#]/,"")).replace(/[;&]$/,""),l&&(e=e.replace(/[+]/g," ")),jQuery.each(e.split(/[&;]/),function(){var e=decodeURIComponent(this.split("=")[0]||""),t=decodeURIComponent(this.split("=")[1]||"");e&&(i&&(/^[+-]?[0-9]+\.[0-9]*$/.test(t)?t=parseFloat(t):/^[+-]?[1-9][0-9]*$/.test(t)&&(t=parseInt(t,10))),n.SET(e,t=!t&&0!==t||t))})}),n},has:function(e,t){e=this.get(e);return c(e,t)},GET:function(e){if(!c(e))return this.keys;for(var e=u(e),t=e[0],n=e[1],r=this.keys[t];null!=r&&0!=n.length;)r=r[n.shift()];return"number"==typeof r?r:r||""},get:function(e){e=this.GET(e);return c(e,Object)?jQuery.extend(!0,{},e):c(e,Array)?e.slice(0):e},SET:function(e,t){var n,r;return e.includes("__proto__")||e.includes("constructor")||e.includes("prototype")||(t=c(t)?t:null,n=(e=u(e))[0],e=e[1],r=this.keys[n],this.keys[n]=o(r,e.slice(0),t)),this},set:function(e,t){return this.copy().SET(e,t)},REMOVE:function(e,t){if(t){var n=this.GET(e);if(c(n,Array)){for(tval in n)n[tval]=n[tval].toString();var r=$.inArray(t,n);if(!(0<=r))return;e=(e=n.splice(r,1))[r]}else if(t!=n)return}return this.SET(e,null).COMPACT()},remove:function(e,t){return this.copy().REMOVE(e,t)},EMPTY:function(){var n=this;return jQuery.each(n.keys,function(e,t){delete n.keys[e]}),n},load:function(e){var t=e.replace(/^.*?[#](.+?)(?:\?.+)?$/,"$1"),n=e.replace(/^.*?[?](.+?)(?:#.+)?$/,"$1");return new r(e.length==n.length?"":n,e.length==t.length?"":t)},empty:function(){return this.copy().EMPTY()},copy:function(){return new r(this)},COMPACT:function(){return this.keys=function r(e){var u="object"==typeof e?c(e,Array)?[]:{}:e;return"object"==typeof e&&jQuery.each(e,function(e,t){if(!c(t))return!0;var n;n=u,t=r(t),c(n,Array)?n.push(t):n[e]=t}),u}(this.keys),this},compact:function(){return this.copy().COMPACT()},toString:function(){function u(e,t){function r(e){return(t&&""!=t?[t,"[",e,"]"]:[e]).join("")}jQuery.each(e,function(e,t){var n;"object"==typeof t?u(t,r(e)):(n=i,e=r(e),c(t=t)&&!1!==t&&(e=[s(e)],!0!==t&&(e.push("="),e.push(s(t))),n.push(e.join(""))))})}var e=[],i=[],s=function(e){return e+="",e=encodeURIComponent(e),e=l?e.replace(/%20/g,"+"):e};return u(this.keys),0<i.length&&e.push(n),e.push(i.join(t)),e.join("")}},new r(location.search,location.hash)}}(jQuery.query||{});
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
|
||||
(function($){$.scheduler=function(){this.bucket={};return;};$.scheduler.prototype={schedule:function(){var ctx={"id":null,"time":1000,"repeat":false,"protect":false,"obj":null,"func":function(){},"args":[]};function _isfn(fn){return(!!fn&&typeof fn!="string"&&typeof fn[0]=="undefined"&&RegExp("function","i").test(fn+""));};var i=0;var override=false;if(typeof arguments[i]=="object"&&arguments.length>1){override=true;i++;}
|
||||
if(typeof arguments[i]=="object"){for(var option in arguments[i])
|
||||
if(typeof ctx[option]!="undefined")
|
||||
ctx[option]=arguments[i][option];i++;}
|
||||
if(typeof arguments[i]=="number"||(typeof arguments[i]=="string"&&arguments[i].match(RegExp("^[0-9]+[smhdw]$"))))
|
||||
ctx["time"]=arguments[i++];if(typeof arguments[i]=="boolean")
|
||||
ctx["repeat"]=arguments[i++];if(typeof arguments[i]=="boolean")
|
||||
ctx["protect"]=arguments[i++];if(typeof arguments[i]=="object"&&typeof arguments[i+1]=="string"&&_isfn(arguments[i][arguments[i+1]])){ctx["obj"]=arguments[i++];ctx["func"]=arguments[i++];}
|
||||
else if(typeof arguments[i]!="undefined"&&(_isfn(arguments[i])||typeof arguments[i]=="string"))
|
||||
ctx["func"]=arguments[i++];while(typeof arguments[i]!="undefined")
|
||||
ctx["args"].push(arguments[i++]);if(override){if(typeof arguments[1]=="object"){for(var option in arguments[0])
|
||||
if(typeof ctx[option]!="undefined"&&typeof arguments[1][option]=="undefined")
|
||||
ctx[option]=arguments[0][option];}
|
||||
else{for(var option in arguments[0])
|
||||
if(typeof ctx[option]!="undefined")
|
||||
ctx[option]=arguments[0][option];}
|
||||
i++;}
|
||||
ctx["_scheduler"]=this;ctx["_handle"]=null;var match=String(ctx["time"]).match(RegExp("^([0-9]+)([smhdw])$"));if(match&&match[0]!="undefined"&&match[1]!="undefined")
|
||||
ctx["time"]=String(parseInt(match[1])*{s:1000,m:1000*60,h:1000*60*60,d:1000*60*60*24,w:1000*60*60*24*7}[match[2]]);if(ctx["id"]==null)
|
||||
ctx["id"]=(String(ctx["repeat"])+":"
|
||||
+String(ctx["protect"])+":"
|
||||
+String(ctx["time"])+":"
|
||||
+String(ctx["obj"])+":"
|
||||
+String(ctx["func"])+":"
|
||||
+String(ctx["args"]));if(ctx["protect"])
|
||||
if(typeof this.bucket[ctx["id"]]!="undefined")
|
||||
return this.bucket[ctx["id"]];if(!_isfn(ctx["func"])){if(ctx["obj"]!=null&&typeof ctx["obj"]=="object"&&typeof ctx["func"]=="string"&&_isfn(ctx["obj"][ctx["func"]]))
|
||||
ctx["func"]=ctx["obj"][ctx["func"]];else
|
||||
ctx["func"]=eval("function () { "+ctx["func"]+" }");}
|
||||
ctx["_handle"]=this._schedule(ctx);this.bucket[ctx["id"]]=ctx;return ctx;},reschedule:function(ctx){if(typeof ctx=="string")
|
||||
ctx=this.bucket[ctx];ctx["_handle"]=this._schedule(ctx);return ctx;},_schedule:function(ctx){var trampoline=function(){var obj=(ctx["obj"]!=null?ctx["obj"]:ctx);(ctx["func"]).apply(obj,ctx["args"]);if(typeof(ctx["_scheduler"]).bucket[ctx["id"]]!="undefined"&&ctx["repeat"])
|
||||
(ctx["_scheduler"])._schedule(ctx);else
|
||||
delete(ctx["_scheduler"]).bucket[ctx["id"]];};return setTimeout(trampoline,ctx["time"]);},cancel:function(ctx){if(typeof ctx=="string")
|
||||
ctx=this.bucket[ctx];if(typeof ctx=="object"){clearTimeout(ctx["_handle"]);delete this.bucket[ctx["id"]];}}};$.extend({scheduler$:new $.scheduler(),schedule:function(){return $.scheduler$.schedule.apply($.scheduler$,arguments)},reschedule:function(){return $.scheduler$.reschedule.apply($.scheduler$,arguments)},cancel:function(){return $.scheduler$.cancel.apply($.scheduler$,arguments)}});$.fn.extend({schedule:function(){var a=[{}];for(var i=0;i<arguments.length;i++)
|
||||
|
||||
(function($){$.scheduler=function(){this.bucket={};return;};$.scheduler.prototype={schedule:function(){var ctx={"id":null,"time":1000,"repeat":false,"protect":false,"obj":null,"func":function(){},"args":[]};function _isfn(fn){return(!!fn&&typeof fn!="string"&&typeof fn[0]=="undefined"&&RegExp("function","i").test(fn+""));};var i=0;var override=false;if(typeof arguments[i]=="object"&&arguments.length>1){override=true;i++;}
|
||||
if(typeof arguments[i]=="object"){for(var option in arguments[i])
|
||||
if(typeof ctx[option]!="undefined")
|
||||
ctx[option]=arguments[i][option];i++;}
|
||||
if(typeof arguments[i]=="number"||(typeof arguments[i]=="string"&&arguments[i].match(RegExp("^[0-9]+[smhdw]$"))))
|
||||
ctx["time"]=arguments[i++];if(typeof arguments[i]=="boolean")
|
||||
ctx["repeat"]=arguments[i++];if(typeof arguments[i]=="boolean")
|
||||
ctx["protect"]=arguments[i++];if(typeof arguments[i]=="object"&&typeof arguments[i+1]=="string"&&_isfn(arguments[i][arguments[i+1]])){ctx["obj"]=arguments[i++];ctx["func"]=arguments[i++];}
|
||||
else if(typeof arguments[i]!="undefined"&&(_isfn(arguments[i])||typeof arguments[i]=="string"))
|
||||
ctx["func"]=arguments[i++];while(typeof arguments[i]!="undefined")
|
||||
ctx["args"].push(arguments[i++]);if(override){if(typeof arguments[1]=="object"){for(var option in arguments[0])
|
||||
if(typeof ctx[option]!="undefined"&&typeof arguments[1][option]=="undefined")
|
||||
ctx[option]=arguments[0][option];}
|
||||
else{for(var option in arguments[0])
|
||||
if(typeof ctx[option]!="undefined")
|
||||
ctx[option]=arguments[0][option];}
|
||||
i++;}
|
||||
ctx["_scheduler"]=this;ctx["_handle"]=null;var match=String(ctx["time"]).match(RegExp("^([0-9]+)([smhdw])$"));if(match&&match[0]!="undefined"&&match[1]!="undefined")
|
||||
ctx["time"]=String(parseInt(match[1])*{s:1000,m:1000*60,h:1000*60*60,d:1000*60*60*24,w:1000*60*60*24*7}[match[2]]);if(ctx["id"]==null)
|
||||
ctx["id"]=(String(ctx["repeat"])+":"
|
||||
+String(ctx["protect"])+":"
|
||||
+String(ctx["time"])+":"
|
||||
+String(ctx["obj"])+":"
|
||||
+String(ctx["func"])+":"
|
||||
+String(ctx["args"]));if(ctx["protect"])
|
||||
if(typeof this.bucket[ctx["id"]]!="undefined")
|
||||
return this.bucket[ctx["id"]];if(!_isfn(ctx["func"])){if(ctx["obj"]!=null&&typeof ctx["obj"]=="object"&&typeof ctx["func"]=="string"&&_isfn(ctx["obj"][ctx["func"]]))
|
||||
ctx["func"]=ctx["obj"][ctx["func"]];else
|
||||
ctx["func"]=eval("function () { "+ctx["func"]+" }");}
|
||||
ctx["_handle"]=this._schedule(ctx);this.bucket[ctx["id"]]=ctx;return ctx;},reschedule:function(ctx){if(typeof ctx=="string")
|
||||
ctx=this.bucket[ctx];ctx["_handle"]=this._schedule(ctx);return ctx;},_schedule:function(ctx){var trampoline=function(){var obj=(ctx["obj"]!=null?ctx["obj"]:ctx);(ctx["func"]).apply(obj,ctx["args"]);if(typeof(ctx["_scheduler"]).bucket[ctx["id"]]!="undefined"&&ctx["repeat"])
|
||||
(ctx["_scheduler"])._schedule(ctx);else
|
||||
delete(ctx["_scheduler"]).bucket[ctx["id"]];};return setTimeout(trampoline,ctx["time"]);},cancel:function(ctx){if(typeof ctx=="string")
|
||||
ctx=this.bucket[ctx];if(typeof ctx=="object"){clearTimeout(ctx["_handle"]);delete this.bucket[ctx["id"]];}}};$.extend({scheduler$:new $.scheduler(),schedule:function(){return $.scheduler$.schedule.apply($.scheduler$,arguments)},reschedule:function(){return $.scheduler$.reschedule.apply($.scheduler$,arguments)},cancel:function(){return $.scheduler$.cancel.apply($.scheduler$,arguments)}});$.fn.extend({schedule:function(){var a=[{}];for(var i=0;i<arguments.length;i++)
|
||||
a.push(arguments[i]);return this.each(function(){a[0]={"id":this,"obj":this};return $.schedule.apply($,a);});}});})(jQuery);
|
||||
@@ -1,31 +1,31 @@
|
||||
/*!
|
||||
* jQuery serializeObject - v0.2-wp - 1/20/2010
|
||||
* http://benalman.com/projects/jquery-misc-plugins/
|
||||
*
|
||||
* Copyright (c) 2010 "Cowboy" Ben Alman
|
||||
* Dual licensed under the MIT and GPL licenses.
|
||||
* http://benalman.com/about/license/
|
||||
*/
|
||||
|
||||
// Whereas .serializeArray() serializes a form into an array, .serializeObject()
|
||||
// serializes a form into an (arguably more useful) object.
|
||||
|
||||
(function($,undefined){
|
||||
'$:nomunge'; // Used by YUI compressor.
|
||||
|
||||
$.fn.serializeObject = function(){
|
||||
var obj = {};
|
||||
|
||||
$.each( this.serializeArray(), function(i,o){
|
||||
var n = o.name,
|
||||
v = o.value;
|
||||
|
||||
obj[n] = obj[n] === undefined ? v
|
||||
: Array.isArray( obj[n] ) ? obj[n].concat( v )
|
||||
: [ obj[n], v ];
|
||||
});
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
/*!
|
||||
* jQuery serializeObject - v0.2-wp - 1/20/2010
|
||||
* http://benalman.com/projects/jquery-misc-plugins/
|
||||
*
|
||||
* Copyright (c) 2010 "Cowboy" Ben Alman
|
||||
* Dual licensed under the MIT and GPL licenses.
|
||||
* http://benalman.com/about/license/
|
||||
*/
|
||||
|
||||
// Whereas .serializeArray() serializes a form into an array, .serializeObject()
|
||||
// serializes a form into an (arguably more useful) object.
|
||||
|
||||
(function($,undefined){
|
||||
'$:nomunge'; // Used by YUI compressor.
|
||||
|
||||
$.fn.serializeObject = function(){
|
||||
var obj = {};
|
||||
|
||||
$.each( this.serializeArray(), function(i,o){
|
||||
var n = o.name,
|
||||
v = o.value;
|
||||
|
||||
obj[n] = obj[n] === undefined ? v
|
||||
: Array.isArray( obj[n] ) ? obj[n].concat( v )
|
||||
: [ obj[n], v ];
|
||||
});
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
@@ -1,99 +1,99 @@
|
||||
(function($){
|
||||
$.fn.filter_visible = function(depth) {
|
||||
depth = depth || 3;
|
||||
var is_visible = function() {
|
||||
var p = $(this), i;
|
||||
for(i=0; i<depth-1; ++i) {
|
||||
if (!p.is(':visible')) return false;
|
||||
p = p.parent();
|
||||
}
|
||||
return true;
|
||||
};
|
||||
return this.filter(is_visible);
|
||||
};
|
||||
$.table_hotkeys = function(table, keys, opts) {
|
||||
opts = $.extend($.table_hotkeys.defaults, opts);
|
||||
var selected_class, destructive_class, set_current_row, adjacent_row_callback, get_adjacent_row, adjacent_row, prev_row, next_row, check, get_first_row, get_last_row, make_key_callback, first_row;
|
||||
|
||||
selected_class = opts.class_prefix + opts.selected_suffix;
|
||||
destructive_class = opts.class_prefix + opts.destructive_suffix;
|
||||
set_current_row = function (tr) {
|
||||
if ($.table_hotkeys.current_row) $.table_hotkeys.current_row.removeClass(selected_class);
|
||||
tr.addClass(selected_class);
|
||||
tr[0].scrollIntoView(false);
|
||||
$.table_hotkeys.current_row = tr;
|
||||
};
|
||||
adjacent_row_callback = function(which) {
|
||||
if (!adjacent_row(which) && typeof opts[which+'_page_link_cb'] === 'function' ) {
|
||||
opts[which+'_page_link_cb']();
|
||||
}
|
||||
};
|
||||
get_adjacent_row = function(which) {
|
||||
var first_row, method;
|
||||
|
||||
if (!$.table_hotkeys.current_row) {
|
||||
first_row = get_first_row();
|
||||
$.table_hotkeys.current_row = first_row;
|
||||
return first_row[0];
|
||||
}
|
||||
method = 'prev' == which? $.fn.prevAll : $.fn.nextAll;
|
||||
return method.call($.table_hotkeys.current_row, opts.cycle_expr).filter_visible()[0];
|
||||
};
|
||||
adjacent_row = function(which) {
|
||||
var adj = get_adjacent_row(which);
|
||||
if (!adj) return false;
|
||||
set_current_row($(adj));
|
||||
return true;
|
||||
};
|
||||
prev_row = function() { return adjacent_row('prev'); };
|
||||
next_row = function() { return adjacent_row('next'); };
|
||||
check = function() {
|
||||
$(opts.checkbox_expr, $.table_hotkeys.current_row).each(function() {
|
||||
this.checked = !this.checked;
|
||||
});
|
||||
};
|
||||
get_first_row = function() {
|
||||
return $(opts.cycle_expr, table).filter_visible().eq(opts.start_row_index);
|
||||
};
|
||||
get_last_row = function() {
|
||||
var rows = $(opts.cycle_expr, table).filter_visible();
|
||||
return rows.eq(rows.length-1);
|
||||
};
|
||||
make_key_callback = function(expr) {
|
||||
return function() {
|
||||
if ( null == $.table_hotkeys.current_row ) return false;
|
||||
var clickable = $(expr, $.table_hotkeys.current_row);
|
||||
if (!clickable.length) return false;
|
||||
if (clickable.is('.'+destructive_class)) next_row() || prev_row();
|
||||
clickable.trigger( 'click' );
|
||||
};
|
||||
};
|
||||
first_row = get_first_row();
|
||||
if (!first_row.length) return;
|
||||
if (opts.highlight_first)
|
||||
set_current_row(first_row);
|
||||
else if (opts.highlight_last)
|
||||
set_current_row(get_last_row());
|
||||
$.hotkeys.add(opts.prev_key, opts.hotkeys_opts, function() {return adjacent_row_callback('prev');});
|
||||
$.hotkeys.add(opts.next_key, opts.hotkeys_opts, function() {return adjacent_row_callback('next');});
|
||||
$.hotkeys.add(opts.mark_key, opts.hotkeys_opts, check);
|
||||
$.each(keys, function() {
|
||||
var callback, key;
|
||||
|
||||
if ( typeof this[1] === 'function' ) {
|
||||
callback = this[1];
|
||||
key = this[0];
|
||||
$.hotkeys.add(key, opts.hotkeys_opts, function(event) { return callback(event, $.table_hotkeys.current_row); });
|
||||
} else {
|
||||
key = this;
|
||||
$.hotkeys.add(key, opts.hotkeys_opts, make_key_callback('.'+opts.class_prefix+key));
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
$.table_hotkeys.current_row = null;
|
||||
$.table_hotkeys.defaults = {cycle_expr: 'tr', class_prefix: 'vim-', selected_suffix: 'current',
|
||||
destructive_suffix: 'destructive', hotkeys_opts: {disableInInput: true, type: 'keypress'},
|
||||
checkbox_expr: ':checkbox', next_key: 'j', prev_key: 'k', mark_key: 'x',
|
||||
start_row_index: 2, highlight_first: false, highlight_last: false, next_page_link_cb: false, prev_page_link_cb: false};
|
||||
})(jQuery);
|
||||
(function($){
|
||||
$.fn.filter_visible = function(depth) {
|
||||
depth = depth || 3;
|
||||
var is_visible = function() {
|
||||
var p = $(this), i;
|
||||
for(i=0; i<depth-1; ++i) {
|
||||
if (!p.is(':visible')) return false;
|
||||
p = p.parent();
|
||||
}
|
||||
return true;
|
||||
};
|
||||
return this.filter(is_visible);
|
||||
};
|
||||
$.table_hotkeys = function(table, keys, opts) {
|
||||
opts = $.extend($.table_hotkeys.defaults, opts);
|
||||
var selected_class, destructive_class, set_current_row, adjacent_row_callback, get_adjacent_row, adjacent_row, prev_row, next_row, check, get_first_row, get_last_row, make_key_callback, first_row;
|
||||
|
||||
selected_class = opts.class_prefix + opts.selected_suffix;
|
||||
destructive_class = opts.class_prefix + opts.destructive_suffix;
|
||||
set_current_row = function (tr) {
|
||||
if ($.table_hotkeys.current_row) $.table_hotkeys.current_row.removeClass(selected_class);
|
||||
tr.addClass(selected_class);
|
||||
tr[0].scrollIntoView(false);
|
||||
$.table_hotkeys.current_row = tr;
|
||||
};
|
||||
adjacent_row_callback = function(which) {
|
||||
if (!adjacent_row(which) && typeof opts[which+'_page_link_cb'] === 'function' ) {
|
||||
opts[which+'_page_link_cb']();
|
||||
}
|
||||
};
|
||||
get_adjacent_row = function(which) {
|
||||
var first_row, method;
|
||||
|
||||
if (!$.table_hotkeys.current_row) {
|
||||
first_row = get_first_row();
|
||||
$.table_hotkeys.current_row = first_row;
|
||||
return first_row[0];
|
||||
}
|
||||
method = 'prev' == which? $.fn.prevAll : $.fn.nextAll;
|
||||
return method.call($.table_hotkeys.current_row, opts.cycle_expr).filter_visible()[0];
|
||||
};
|
||||
adjacent_row = function(which) {
|
||||
var adj = get_adjacent_row(which);
|
||||
if (!adj) return false;
|
||||
set_current_row($(adj));
|
||||
return true;
|
||||
};
|
||||
prev_row = function() { return adjacent_row('prev'); };
|
||||
next_row = function() { return adjacent_row('next'); };
|
||||
check = function() {
|
||||
$(opts.checkbox_expr, $.table_hotkeys.current_row).each(function() {
|
||||
this.checked = !this.checked;
|
||||
});
|
||||
};
|
||||
get_first_row = function() {
|
||||
return $(opts.cycle_expr, table).filter_visible().eq(opts.start_row_index);
|
||||
};
|
||||
get_last_row = function() {
|
||||
var rows = $(opts.cycle_expr, table).filter_visible();
|
||||
return rows.eq(rows.length-1);
|
||||
};
|
||||
make_key_callback = function(expr) {
|
||||
return function() {
|
||||
if ( null == $.table_hotkeys.current_row ) return false;
|
||||
var clickable = $(expr, $.table_hotkeys.current_row);
|
||||
if (!clickable.length) return false;
|
||||
if (clickable.is('.'+destructive_class)) next_row() || prev_row();
|
||||
clickable.trigger( 'click' );
|
||||
};
|
||||
};
|
||||
first_row = get_first_row();
|
||||
if (!first_row.length) return;
|
||||
if (opts.highlight_first)
|
||||
set_current_row(first_row);
|
||||
else if (opts.highlight_last)
|
||||
set_current_row(get_last_row());
|
||||
$.hotkeys.add(opts.prev_key, opts.hotkeys_opts, function() {return adjacent_row_callback('prev');});
|
||||
$.hotkeys.add(opts.next_key, opts.hotkeys_opts, function() {return adjacent_row_callback('next');});
|
||||
$.hotkeys.add(opts.mark_key, opts.hotkeys_opts, check);
|
||||
$.each(keys, function() {
|
||||
var callback, key;
|
||||
|
||||
if ( typeof this[1] === 'function' ) {
|
||||
callback = this[1];
|
||||
key = this[0];
|
||||
$.hotkeys.add(key, opts.hotkeys_opts, function(event) { return callback(event, $.table_hotkeys.current_row); });
|
||||
} else {
|
||||
key = this;
|
||||
$.hotkeys.add(key, opts.hotkeys_opts, make_key_callback('.'+opts.class_prefix+key));
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
$.table_hotkeys.current_row = null;
|
||||
$.table_hotkeys.defaults = {cycle_expr: 'tr', class_prefix: 'vim-', selected_suffix: 'current',
|
||||
destructive_suffix: 'destructive', hotkeys_opts: {disableInInput: true, type: 'keypress'},
|
||||
checkbox_expr: ':checkbox', next_key: 'j', prev_key: 'k', mark_key: 'x',
|
||||
start_row_index: 2, highlight_first: false, highlight_last: false, next_page_link_cb: false, prev_page_link_cb: false};
|
||||
})(jQuery);
|
||||
|
||||
+10
-10
@@ -1,11 +1,11 @@
|
||||
/*!
|
||||
* jQuery UI Touch Punch 0.2.2
|
||||
*
|
||||
* Copyright 2011, Dave Furfero
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
*
|
||||
* Depends:
|
||||
* jquery.ui.widget.js
|
||||
* jquery.ui.mouse.js
|
||||
*/
|
||||
/*!
|
||||
* jQuery UI Touch Punch 0.2.2
|
||||
*
|
||||
* Copyright 2011, Dave Furfero
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
*
|
||||
* Depends:
|
||||
* jquery.ui.widget.js
|
||||
* jquery.ui.mouse.js
|
||||
*/
|
||||
(function(b){b.support.touch="ontouchend" in document;if(!b.support.touch){return}var c=b.ui.mouse.prototype,e=c._mouseInit,a;function d(g,h){if(g.originalEvent.touches.length>1){return}g.preventDefault();var i=g.originalEvent.changedTouches[0],f=document.createEvent("MouseEvents");f.initMouseEvent(h,true,true,window,1,i.screenX,i.screenY,i.clientX,i.clientY,false,false,false,false,0,null);g.target.dispatchEvent(f)}c._touchStart=function(g){var f=this;if(a||!f._mouseCapture(g.originalEvent.changedTouches[0])){return}a=true;f._touchMoved=false;d(g,"mouseover");d(g,"mousemove");d(g,"mousedown")};c._touchMove=function(f){if(!a){return}this._touchMoved=true;d(f,"mousemove")};c._touchEnd=function(f){if(!a){return}d(f,"mouseup");d(f,"mouseout");if(!this._touchMoved){d(f,"click")}a=false};c._mouseInit=function(){var f=this;f.element.bind("touchstart",b.proxy(f,"_touchStart")).bind("touchmove",b.proxy(f,"_touchMove")).bind("touchend",b.proxy(f,"_touchEnd"));e.call(f)}})(jQuery);
|
||||
+316
-316
@@ -1,316 +1,316 @@
|
||||
/*
|
||||
* jquery.suggest 1.1b - 2007-08-06
|
||||
* Patched by Mark Jaquith with Alexander Dick's "multiple items" patch to allow for auto-suggesting of more than one tag before submitting
|
||||
* See: http://www.vulgarisoip.com/2007/06/29/jquerysuggest-an-alternative-jquery-based-autocomplete-library/#comment-7228
|
||||
*
|
||||
* Uses code and techniques from following libraries:
|
||||
* 1. http://www.dyve.net/jquery/?autocomplete
|
||||
* 2. http://dev.jquery.com/browser/trunk/plugins/interface/iautocompleter.js
|
||||
*
|
||||
* All the new stuff written by Peter Vulgaris (www.vulgarisoip.com)
|
||||
* Feel free to do whatever you want with this file
|
||||
*
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
|
||||
$.suggest = function(input, options) {
|
||||
var $input, $results, timeout, prevLength, cache, cacheSize;
|
||||
|
||||
$input = $(input).attr("autocomplete", "off");
|
||||
$results = $("<ul/>");
|
||||
|
||||
timeout = false; // hold timeout ID for suggestion results to appear
|
||||
prevLength = 0; // last recorded length of $input.val()
|
||||
cache = []; // cache MRU list
|
||||
cacheSize = 0; // size of cache in chars (bytes?)
|
||||
|
||||
$results.addClass(options.resultsClass).appendTo('body');
|
||||
|
||||
|
||||
resetPosition();
|
||||
$(window)
|
||||
.on( 'load', resetPosition ) // just in case user is changing size of page while loading
|
||||
.on( 'resize', resetPosition );
|
||||
|
||||
$input.blur(function() {
|
||||
setTimeout(function() { $results.hide() }, 200);
|
||||
});
|
||||
|
||||
$input.keydown(processKey);
|
||||
|
||||
function resetPosition() {
|
||||
// requires jquery.dimension plugin
|
||||
var offset = $input.offset();
|
||||
$results.css({
|
||||
top: (offset.top + input.offsetHeight) + 'px',
|
||||
left: offset.left + 'px'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function processKey(e) {
|
||||
|
||||
// handling up/down/escape requires results to be visible
|
||||
// handling enter/tab requires that AND a result to be selected
|
||||
if ((/27$|38$|40$/.test(e.keyCode) && $results.is(':visible')) ||
|
||||
(/^13$|^9$/.test(e.keyCode) && getCurrentResult())) {
|
||||
|
||||
if (e.preventDefault)
|
||||
e.preventDefault();
|
||||
if (e.stopPropagation)
|
||||
e.stopPropagation();
|
||||
|
||||
e.cancelBubble = true;
|
||||
e.returnValue = false;
|
||||
|
||||
switch(e.keyCode) {
|
||||
|
||||
case 38: // up
|
||||
prevResult();
|
||||
break;
|
||||
|
||||
case 40: // down
|
||||
nextResult();
|
||||
break;
|
||||
|
||||
case 9: // tab
|
||||
case 13: // return
|
||||
selectCurrentResult();
|
||||
break;
|
||||
|
||||
case 27: // escape
|
||||
$results.hide();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
} else if ($input.val().length != prevLength) {
|
||||
|
||||
if (timeout)
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(suggest, options.delay);
|
||||
prevLength = $input.val().length;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function suggest() {
|
||||
|
||||
var q = $.trim($input.val()), multipleSepPos, items;
|
||||
|
||||
if ( options.multiple ) {
|
||||
multipleSepPos = q.lastIndexOf(options.multipleSep);
|
||||
if ( multipleSepPos != -1 ) {
|
||||
q = $.trim(q.substr(multipleSepPos + options.multipleSep.length));
|
||||
}
|
||||
}
|
||||
if (q.length >= options.minchars) {
|
||||
|
||||
cached = checkCache(q);
|
||||
|
||||
if (cached) {
|
||||
|
||||
displayItems(cached['items']);
|
||||
|
||||
} else {
|
||||
|
||||
$.get(options.source, {q: q}, function(txt) {
|
||||
|
||||
$results.hide();
|
||||
|
||||
items = parseTxt(txt, q);
|
||||
|
||||
displayItems(items);
|
||||
addToCache(q, items, txt.length);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$results.hide();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function checkCache(q) {
|
||||
var i;
|
||||
for (i = 0; i < cache.length; i++)
|
||||
if (cache[i]['q'] == q) {
|
||||
cache.unshift(cache.splice(i, 1)[0]);
|
||||
return cache[0];
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
function addToCache(q, items, size) {
|
||||
var cached;
|
||||
while (cache.length && (cacheSize + size > options.maxCacheSize)) {
|
||||
cached = cache.pop();
|
||||
cacheSize -= cached['size'];
|
||||
}
|
||||
|
||||
cache.push({
|
||||
q: q,
|
||||
size: size,
|
||||
items: items
|
||||
});
|
||||
|
||||
cacheSize += size;
|
||||
|
||||
}
|
||||
|
||||
function displayItems(items) {
|
||||
var html = '', i;
|
||||
if (!items)
|
||||
return;
|
||||
|
||||
if (!items.length) {
|
||||
$results.hide();
|
||||
return;
|
||||
}
|
||||
|
||||
resetPosition(); // when the form moves after the page has loaded
|
||||
|
||||
for (i = 0; i < items.length; i++)
|
||||
html += '<li>' + items[i] + '</li>';
|
||||
|
||||
$results.html(html).show();
|
||||
|
||||
$results
|
||||
.children('li')
|
||||
.mouseover(function() {
|
||||
$results.children('li').removeClass(options.selectClass);
|
||||
$(this).addClass(options.selectClass);
|
||||
})
|
||||
.click(function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
selectCurrentResult();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function parseTxt(txt, q) {
|
||||
|
||||
var items = [], tokens = txt.split(options.delimiter), i, token;
|
||||
|
||||
// parse returned data for non-empty items
|
||||
for (i = 0; i < tokens.length; i++) {
|
||||
token = $.trim(tokens[i]);
|
||||
if (token) {
|
||||
token = token.replace(
|
||||
new RegExp(q, 'ig'),
|
||||
function(q) { return '<span class="' + options.matchClass + '">' + q + '</span>' }
|
||||
);
|
||||
items[items.length] = token;
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
function getCurrentResult() {
|
||||
var $currentResult;
|
||||
if (!$results.is(':visible'))
|
||||
return false;
|
||||
|
||||
$currentResult = $results.children('li.' + options.selectClass);
|
||||
|
||||
if (!$currentResult.length)
|
||||
$currentResult = false;
|
||||
|
||||
return $currentResult;
|
||||
|
||||
}
|
||||
|
||||
function selectCurrentResult() {
|
||||
|
||||
$currentResult = getCurrentResult();
|
||||
|
||||
if ($currentResult) {
|
||||
if ( options.multiple ) {
|
||||
if ( $input.val().indexOf(options.multipleSep) != -1 ) {
|
||||
$currentVal = $input.val().substr( 0, ( $input.val().lastIndexOf(options.multipleSep) + options.multipleSep.length ) ) + ' ';
|
||||
} else {
|
||||
$currentVal = "";
|
||||
}
|
||||
$input.val( $currentVal + $currentResult.text() + options.multipleSep + ' ' );
|
||||
$input.focus();
|
||||
} else {
|
||||
$input.val($currentResult.text());
|
||||
}
|
||||
$results.hide();
|
||||
$input.trigger('change');
|
||||
|
||||
if (options.onSelect)
|
||||
options.onSelect.apply($input[0]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function nextResult() {
|
||||
|
||||
$currentResult = getCurrentResult();
|
||||
|
||||
if ($currentResult)
|
||||
$currentResult
|
||||
.removeClass(options.selectClass)
|
||||
.next()
|
||||
.addClass(options.selectClass);
|
||||
else
|
||||
$results.children('li:first-child').addClass(options.selectClass);
|
||||
|
||||
}
|
||||
|
||||
function prevResult() {
|
||||
var $currentResult = getCurrentResult();
|
||||
|
||||
if ($currentResult)
|
||||
$currentResult
|
||||
.removeClass(options.selectClass)
|
||||
.prev()
|
||||
.addClass(options.selectClass);
|
||||
else
|
||||
$results.children('li:last-child').addClass(options.selectClass);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$.fn.suggest = function(source, options) {
|
||||
|
||||
if (!source)
|
||||
return;
|
||||
|
||||
options = options || {};
|
||||
options.multiple = options.multiple || false;
|
||||
options.multipleSep = options.multipleSep || ",";
|
||||
options.source = source;
|
||||
options.delay = options.delay || 100;
|
||||
options.resultsClass = options.resultsClass || 'ac_results';
|
||||
options.selectClass = options.selectClass || 'ac_over';
|
||||
options.matchClass = options.matchClass || 'ac_match';
|
||||
options.minchars = options.minchars || 2;
|
||||
options.delimiter = options.delimiter || '\n';
|
||||
options.onSelect = options.onSelect || false;
|
||||
options.maxCacheSize = options.maxCacheSize || 65536;
|
||||
|
||||
this.each(function() {
|
||||
new $.suggest(this, options);
|
||||
});
|
||||
|
||||
return this;
|
||||
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
/*
|
||||
* jquery.suggest 1.1b - 2007-08-06
|
||||
* Patched by Mark Jaquith with Alexander Dick's "multiple items" patch to allow for auto-suggesting of more than one tag before submitting
|
||||
* See: http://www.vulgarisoip.com/2007/06/29/jquerysuggest-an-alternative-jquery-based-autocomplete-library/#comment-7228
|
||||
*
|
||||
* Uses code and techniques from following libraries:
|
||||
* 1. http://www.dyve.net/jquery/?autocomplete
|
||||
* 2. http://dev.jquery.com/browser/trunk/plugins/interface/iautocompleter.js
|
||||
*
|
||||
* All the new stuff written by Peter Vulgaris (www.vulgarisoip.com)
|
||||
* Feel free to do whatever you want with this file
|
||||
*
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
|
||||
$.suggest = function(input, options) {
|
||||
var $input, $results, timeout, prevLength, cache, cacheSize;
|
||||
|
||||
$input = $(input).attr("autocomplete", "off");
|
||||
$results = $("<ul/>");
|
||||
|
||||
timeout = false; // hold timeout ID for suggestion results to appear
|
||||
prevLength = 0; // last recorded length of $input.val()
|
||||
cache = []; // cache MRU list
|
||||
cacheSize = 0; // size of cache in chars (bytes?)
|
||||
|
||||
$results.addClass(options.resultsClass).appendTo('body');
|
||||
|
||||
|
||||
resetPosition();
|
||||
$(window)
|
||||
.on( 'load', resetPosition ) // just in case user is changing size of page while loading
|
||||
.on( 'resize', resetPosition );
|
||||
|
||||
$input.blur(function() {
|
||||
setTimeout(function() { $results.hide() }, 200);
|
||||
});
|
||||
|
||||
$input.keydown(processKey);
|
||||
|
||||
function resetPosition() {
|
||||
// requires jquery.dimension plugin
|
||||
var offset = $input.offset();
|
||||
$results.css({
|
||||
top: (offset.top + input.offsetHeight) + 'px',
|
||||
left: offset.left + 'px'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function processKey(e) {
|
||||
|
||||
// handling up/down/escape requires results to be visible
|
||||
// handling enter/tab requires that AND a result to be selected
|
||||
if ((/27$|38$|40$/.test(e.keyCode) && $results.is(':visible')) ||
|
||||
(/^13$|^9$/.test(e.keyCode) && getCurrentResult())) {
|
||||
|
||||
if (e.preventDefault)
|
||||
e.preventDefault();
|
||||
if (e.stopPropagation)
|
||||
e.stopPropagation();
|
||||
|
||||
e.cancelBubble = true;
|
||||
e.returnValue = false;
|
||||
|
||||
switch(e.keyCode) {
|
||||
|
||||
case 38: // up
|
||||
prevResult();
|
||||
break;
|
||||
|
||||
case 40: // down
|
||||
nextResult();
|
||||
break;
|
||||
|
||||
case 9: // tab
|
||||
case 13: // return
|
||||
selectCurrentResult();
|
||||
break;
|
||||
|
||||
case 27: // escape
|
||||
$results.hide();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
} else if ($input.val().length != prevLength) {
|
||||
|
||||
if (timeout)
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(suggest, options.delay);
|
||||
prevLength = $input.val().length;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function suggest() {
|
||||
|
||||
var q = $.trim($input.val()), multipleSepPos, items;
|
||||
|
||||
if ( options.multiple ) {
|
||||
multipleSepPos = q.lastIndexOf(options.multipleSep);
|
||||
if ( multipleSepPos != -1 ) {
|
||||
q = $.trim(q.substr(multipleSepPos + options.multipleSep.length));
|
||||
}
|
||||
}
|
||||
if (q.length >= options.minchars) {
|
||||
|
||||
cached = checkCache(q);
|
||||
|
||||
if (cached) {
|
||||
|
||||
displayItems(cached['items']);
|
||||
|
||||
} else {
|
||||
|
||||
$.get(options.source, {q: q}, function(txt) {
|
||||
|
||||
$results.hide();
|
||||
|
||||
items = parseTxt(txt, q);
|
||||
|
||||
displayItems(items);
|
||||
addToCache(q, items, txt.length);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$results.hide();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function checkCache(q) {
|
||||
var i;
|
||||
for (i = 0; i < cache.length; i++)
|
||||
if (cache[i]['q'] == q) {
|
||||
cache.unshift(cache.splice(i, 1)[0]);
|
||||
return cache[0];
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
function addToCache(q, items, size) {
|
||||
var cached;
|
||||
while (cache.length && (cacheSize + size > options.maxCacheSize)) {
|
||||
cached = cache.pop();
|
||||
cacheSize -= cached['size'];
|
||||
}
|
||||
|
||||
cache.push({
|
||||
q: q,
|
||||
size: size,
|
||||
items: items
|
||||
});
|
||||
|
||||
cacheSize += size;
|
||||
|
||||
}
|
||||
|
||||
function displayItems(items) {
|
||||
var html = '', i;
|
||||
if (!items)
|
||||
return;
|
||||
|
||||
if (!items.length) {
|
||||
$results.hide();
|
||||
return;
|
||||
}
|
||||
|
||||
resetPosition(); // when the form moves after the page has loaded
|
||||
|
||||
for (i = 0; i < items.length; i++)
|
||||
html += '<li>' + items[i] + '</li>';
|
||||
|
||||
$results.html(html).show();
|
||||
|
||||
$results
|
||||
.children('li')
|
||||
.mouseover(function() {
|
||||
$results.children('li').removeClass(options.selectClass);
|
||||
$(this).addClass(options.selectClass);
|
||||
})
|
||||
.click(function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
selectCurrentResult();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function parseTxt(txt, q) {
|
||||
|
||||
var items = [], tokens = txt.split(options.delimiter), i, token;
|
||||
|
||||
// parse returned data for non-empty items
|
||||
for (i = 0; i < tokens.length; i++) {
|
||||
token = $.trim(tokens[i]);
|
||||
if (token) {
|
||||
token = token.replace(
|
||||
new RegExp(q, 'ig'),
|
||||
function(q) { return '<span class="' + options.matchClass + '">' + q + '</span>' }
|
||||
);
|
||||
items[items.length] = token;
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
function getCurrentResult() {
|
||||
var $currentResult;
|
||||
if (!$results.is(':visible'))
|
||||
return false;
|
||||
|
||||
$currentResult = $results.children('li.' + options.selectClass);
|
||||
|
||||
if (!$currentResult.length)
|
||||
$currentResult = false;
|
||||
|
||||
return $currentResult;
|
||||
|
||||
}
|
||||
|
||||
function selectCurrentResult() {
|
||||
|
||||
$currentResult = getCurrentResult();
|
||||
|
||||
if ($currentResult) {
|
||||
if ( options.multiple ) {
|
||||
if ( $input.val().indexOf(options.multipleSep) != -1 ) {
|
||||
$currentVal = $input.val().substr( 0, ( $input.val().lastIndexOf(options.multipleSep) + options.multipleSep.length ) ) + ' ';
|
||||
} else {
|
||||
$currentVal = "";
|
||||
}
|
||||
$input.val( $currentVal + $currentResult.text() + options.multipleSep + ' ' );
|
||||
$input.focus();
|
||||
} else {
|
||||
$input.val($currentResult.text());
|
||||
}
|
||||
$results.hide();
|
||||
$input.trigger('change');
|
||||
|
||||
if (options.onSelect)
|
||||
options.onSelect.apply($input[0]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function nextResult() {
|
||||
|
||||
$currentResult = getCurrentResult();
|
||||
|
||||
if ($currentResult)
|
||||
$currentResult
|
||||
.removeClass(options.selectClass)
|
||||
.next()
|
||||
.addClass(options.selectClass);
|
||||
else
|
||||
$results.children('li:first-child').addClass(options.selectClass);
|
||||
|
||||
}
|
||||
|
||||
function prevResult() {
|
||||
var $currentResult = getCurrentResult();
|
||||
|
||||
if ($currentResult)
|
||||
$currentResult
|
||||
.removeClass(options.selectClass)
|
||||
.prev()
|
||||
.addClass(options.selectClass);
|
||||
else
|
||||
$results.children('li:last-child').addClass(options.selectClass);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$.fn.suggest = function(source, options) {
|
||||
|
||||
if (!source)
|
||||
return;
|
||||
|
||||
options = options || {};
|
||||
options.multiple = options.multiple || false;
|
||||
options.multipleSep = options.multipleSep || ",";
|
||||
options.source = source;
|
||||
options.delay = options.delay || 100;
|
||||
options.resultsClass = options.resultsClass || 'ac_results';
|
||||
options.selectClass = options.selectClass || 'ac_over';
|
||||
options.matchClass = options.matchClass || 'ac_match';
|
||||
options.minchars = options.minchars || 2;
|
||||
options.delimiter = options.delimiter || '\n';
|
||||
options.onSelect = options.onSelect || false;
|
||||
options.maxCacheSize = options.maxCacheSize || 65536;
|
||||
|
||||
this.each(function() {
|
||||
new $.suggest(this, options);
|
||||
});
|
||||
|
||||
return this;
|
||||
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
!function(a){a.suggest=function(b,c){function d(){var a=o.offset();p.css({top:a.top+b.offsetHeight+"px",left:a.left+"px"})}function e(a){if(/27$|38$|40$/.test(a.keyCode)&&p.is(":visible")||/^13$|^9$/.test(a.keyCode)&&k())switch(a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0,a.returnValue=!1,a.keyCode){case 38:n();break;case 40:m();break;case 9:case 13:l();break;case 27:p.hide()}else o.val().length!=r&&(q&&clearTimeout(q),q=setTimeout(f,c.delay),r=o.val().length)}function f(){var b,d,e=a.trim(o.val());c.multiple&&(b=e.lastIndexOf(c.multipleSep),-1!=b&&(e=a.trim(e.substr(b+c.multipleSep.length)))),e.length>=c.minchars?(cached=g(e),cached?i(cached.items):a.get(c.source,{q:e},function(a){p.hide(),d=j(a,e),i(d),h(e,d,a.length)})):p.hide()}function g(a){var b;for(b=0;b<s.length;b++)if(s[b].q==a)return s.unshift(s.splice(b,1)[0]),s[0];return!1}function h(a,b,d){for(var e;s.length&&t+d>c.maxCacheSize;)e=s.pop(),t-=e.size;s.push({q:a,size:d,items:b}),t+=d}function i(b){var e,f="";if(b){if(!b.length)return void p.hide();for(d(),e=0;e<b.length;e++)f+="<li>"+b[e]+"</li>";p.html(f).show(),p.children("li").mouseover(function(){p.children("li").removeClass(c.selectClass),a(this).addClass(c.selectClass)}).click(function(a){a.preventDefault(),a.stopPropagation(),l()})}}function j(b,d){var e,f,g=[],h=b.split(c.delimiter);for(e=0;e<h.length;e++)f=a.trim(h[e]),f&&(f=f.replace(new RegExp(d,"ig"),function(a){return'<span class="'+c.matchClass+'">'+a+"</span>"}),g[g.length]=f);return g}function k(){var a;return p.is(":visible")?(a=p.children("li."+c.selectClass),a.length||(a=!1),a):!1}function l(){$currentResult=k(),$currentResult&&(c.multiple?(-1!=o.val().indexOf(c.multipleSep)?$currentVal=o.val().substr(0,o.val().lastIndexOf(c.multipleSep)+c.multipleSep.length)+" ":$currentVal="",o.val($currentVal+$currentResult.text()+c.multipleSep+" "),o.focus()):o.val($currentResult.text()),p.hide(),o.trigger("change"),c.onSelect&&c.onSelect.apply(o[0]))}function m(){$currentResult=k(),$currentResult?$currentResult.removeClass(c.selectClass).next().addClass(c.selectClass):p.children("li:first-child").addClass(c.selectClass)}function n(){var a=k();a?a.removeClass(c.selectClass).prev().addClass(c.selectClass):p.children("li:last-child").addClass(c.selectClass)}var o,p,q,r,s,t;o=a(b).attr("autocomplete","off"),p=a("<ul/>"),q=!1,r=0,s=[],t=0,p.addClass(c.resultsClass).appendTo("body"),d(),a(window).on("load",d).on("resize",d),o.blur(function(){setTimeout(function(){p.hide()},200)}),o.keydown(e)},a.fn.suggest=function(b,c){return b?(c=c||{},c.multiple=c.multiple||!1,c.multipleSep=c.multipleSep||",",c.source=b,c.delay=c.delay||100,c.resultsClass=c.resultsClass||"ac_results",c.selectClass=c.selectClass||"ac_over",c.matchClass=c.matchClass||"ac_match",c.minchars=c.minchars||2,c.delimiter=c.delimiter||"\n",c.onSelect=c.onSelect||!1,c.maxCacheSize=c.maxCacheSize||65536,this.each(function(){new a.suggest(this,c)}),this):void 0}}(jQuery);
|
||||
!function(a){a.suggest=function(b,c){function d(){var a=o.offset();p.css({top:a.top+b.offsetHeight+"px",left:a.left+"px"})}function e(a){if(/27$|38$|40$/.test(a.keyCode)&&p.is(":visible")||/^13$|^9$/.test(a.keyCode)&&k())switch(a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0,a.returnValue=!1,a.keyCode){case 38:n();break;case 40:m();break;case 9:case 13:l();break;case 27:p.hide()}else o.val().length!=r&&(q&&clearTimeout(q),q=setTimeout(f,c.delay),r=o.val().length)}function f(){var b,d,e=a.trim(o.val());c.multiple&&(b=e.lastIndexOf(c.multipleSep),-1!=b&&(e=a.trim(e.substr(b+c.multipleSep.length)))),e.length>=c.minchars?(cached=g(e),cached?i(cached.items):a.get(c.source,{q:e},function(a){p.hide(),d=j(a,e),i(d),h(e,d,a.length)})):p.hide()}function g(a){var b;for(b=0;b<s.length;b++)if(s[b].q==a)return s.unshift(s.splice(b,1)[0]),s[0];return!1}function h(a,b,d){for(var e;s.length&&t+d>c.maxCacheSize;)e=s.pop(),t-=e.size;s.push({q:a,size:d,items:b}),t+=d}function i(b){var e,f="";if(b){if(!b.length)return void p.hide();for(d(),e=0;e<b.length;e++)f+="<li>"+b[e]+"</li>";p.html(f).show(),p.children("li").mouseover(function(){p.children("li").removeClass(c.selectClass),a(this).addClass(c.selectClass)}).click(function(a){a.preventDefault(),a.stopPropagation(),l()})}}function j(b,d){var e,f,g=[],h=b.split(c.delimiter);for(e=0;e<h.length;e++)f=a.trim(h[e]),f&&(f=f.replace(new RegExp(d,"ig"),function(a){return'<span class="'+c.matchClass+'">'+a+"</span>"}),g[g.length]=f);return g}function k(){var a;return p.is(":visible")?(a=p.children("li."+c.selectClass),a.length||(a=!1),a):!1}function l(){$currentResult=k(),$currentResult&&(c.multiple?(-1!=o.val().indexOf(c.multipleSep)?$currentVal=o.val().substr(0,o.val().lastIndexOf(c.multipleSep)+c.multipleSep.length)+" ":$currentVal="",o.val($currentVal+$currentResult.text()+c.multipleSep+" "),o.focus()):o.val($currentResult.text()),p.hide(),o.trigger("change"),c.onSelect&&c.onSelect.apply(o[0]))}function m(){$currentResult=k(),$currentResult?$currentResult.removeClass(c.selectClass).next().addClass(c.selectClass):p.children("li:first-child").addClass(c.selectClass)}function n(){var a=k();a?a.removeClass(c.selectClass).prev().addClass(c.selectClass):p.children("li:last-child").addClass(c.selectClass)}var o,p,q,r,s,t;o=a(b).attr("autocomplete","off"),p=a("<ul/>"),q=!1,r=0,s=[],t=0,p.addClass(c.resultsClass).appendTo("body"),d(),a(window).on("load",d).on("resize",d),o.blur(function(){setTimeout(function(){p.hide()},200)}),o.keydown(e)},a.fn.suggest=function(b,c){return b?(c=c||{},c.multiple=c.multiple||!1,c.multipleSep=c.multipleSep||",",c.source=b,c.delay=c.delay||100,c.resultsClass=c.resultsClass||"ac_results",c.selectClass=c.selectClass||"ac_over",c.matchClass=c.matchClass||"ac_match",c.minchars=c.minchars||2,c.delimiter=c.delimiter||"\n",c.onSelect=c.onSelect||!1,c.maxCacheSize=c.maxCacheSize||65536,this.each(function(){new a.suggest(this,c)}),this):void 0}}(jQuery);
|
||||
|
||||
+619
-619
File diff suppressed because it is too large
Load Diff
+8
-8
File diff suppressed because one or more lines are too long
+674
-674
File diff suppressed because it is too large
Load Diff
+8
-8
File diff suppressed because one or more lines are too long
+448
-448
@@ -1,448 +1,448 @@
|
||||
/*!
|
||||
* jQuery UI Button 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Button
|
||||
//>>group: Widgets
|
||||
//>>description: Enhances a form with themeable buttons.
|
||||
//>>docs: http://api.jqueryui.com/button/
|
||||
//>>demos: http://jqueryui.com/button/
|
||||
//>>css.structure: ../../themes/base/core.css
|
||||
//>>css.structure: ../../themes/base/button.css
|
||||
//>>css.theme: ../../themes/base/theme.css
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
|
||||
// These are only for backcompat
|
||||
// TODO: Remove after 1.12
|
||||
"./controlgroup",
|
||||
"./checkboxradio",
|
||||
|
||||
"./core"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
$.widget( "ui.button", {
|
||||
version: "1.13.2",
|
||||
defaultElement: "<button>",
|
||||
options: {
|
||||
classes: {
|
||||
"ui-button": "ui-corner-all"
|
||||
},
|
||||
disabled: null,
|
||||
icon: null,
|
||||
iconPosition: "beginning",
|
||||
label: null,
|
||||
showLabel: true
|
||||
},
|
||||
|
||||
_getCreateOptions: function() {
|
||||
var disabled,
|
||||
|
||||
// This is to support cases like in jQuery Mobile where the base widget does have
|
||||
// an implementation of _getCreateOptions
|
||||
options = this._super() || {};
|
||||
|
||||
this.isInput = this.element.is( "input" );
|
||||
|
||||
disabled = this.element[ 0 ].disabled;
|
||||
if ( disabled != null ) {
|
||||
options.disabled = disabled;
|
||||
}
|
||||
|
||||
this.originalLabel = this.isInput ? this.element.val() : this.element.html();
|
||||
if ( this.originalLabel ) {
|
||||
options.label = this.originalLabel;
|
||||
}
|
||||
|
||||
return options;
|
||||
},
|
||||
|
||||
_create: function() {
|
||||
if ( !this.option.showLabel & !this.options.icon ) {
|
||||
this.options.showLabel = true;
|
||||
}
|
||||
|
||||
// We have to check the option again here even though we did in _getCreateOptions,
|
||||
// because null may have been passed on init which would override what was set in
|
||||
// _getCreateOptions
|
||||
if ( this.options.disabled == null ) {
|
||||
this.options.disabled = this.element[ 0 ].disabled || false;
|
||||
}
|
||||
|
||||
this.hasTitle = !!this.element.attr( "title" );
|
||||
|
||||
// Check to see if the label needs to be set or if its already correct
|
||||
if ( this.options.label && this.options.label !== this.originalLabel ) {
|
||||
if ( this.isInput ) {
|
||||
this.element.val( this.options.label );
|
||||
} else {
|
||||
this.element.html( this.options.label );
|
||||
}
|
||||
}
|
||||
this._addClass( "ui-button", "ui-widget" );
|
||||
this._setOption( "disabled", this.options.disabled );
|
||||
this._enhance();
|
||||
|
||||
if ( this.element.is( "a" ) ) {
|
||||
this._on( {
|
||||
"keyup": function( event ) {
|
||||
if ( event.keyCode === $.ui.keyCode.SPACE ) {
|
||||
event.preventDefault();
|
||||
|
||||
// Support: PhantomJS <= 1.9, IE 8 Only
|
||||
// If a native click is available use it so we actually cause navigation
|
||||
// otherwise just trigger a click event
|
||||
if ( this.element[ 0 ].click ) {
|
||||
this.element[ 0 ].click();
|
||||
} else {
|
||||
this.element.trigger( "click" );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
},
|
||||
|
||||
_enhance: function() {
|
||||
if ( !this.element.is( "button" ) ) {
|
||||
this.element.attr( "role", "button" );
|
||||
}
|
||||
|
||||
if ( this.options.icon ) {
|
||||
this._updateIcon( "icon", this.options.icon );
|
||||
this._updateTooltip();
|
||||
}
|
||||
},
|
||||
|
||||
_updateTooltip: function() {
|
||||
this.title = this.element.attr( "title" );
|
||||
|
||||
if ( !this.options.showLabel && !this.title ) {
|
||||
this.element.attr( "title", this.options.label );
|
||||
}
|
||||
},
|
||||
|
||||
_updateIcon: function( option, value ) {
|
||||
var icon = option !== "iconPosition",
|
||||
position = icon ? this.options.iconPosition : value,
|
||||
displayBlock = position === "top" || position === "bottom";
|
||||
|
||||
// Create icon
|
||||
if ( !this.icon ) {
|
||||
this.icon = $( "<span>" );
|
||||
|
||||
this._addClass( this.icon, "ui-button-icon", "ui-icon" );
|
||||
|
||||
if ( !this.options.showLabel ) {
|
||||
this._addClass( "ui-button-icon-only" );
|
||||
}
|
||||
} else if ( icon ) {
|
||||
|
||||
// If we are updating the icon remove the old icon class
|
||||
this._removeClass( this.icon, null, this.options.icon );
|
||||
}
|
||||
|
||||
// If we are updating the icon add the new icon class
|
||||
if ( icon ) {
|
||||
this._addClass( this.icon, null, value );
|
||||
}
|
||||
|
||||
this._attachIcon( position );
|
||||
|
||||
// If the icon is on top or bottom we need to add the ui-widget-icon-block class and remove
|
||||
// the iconSpace if there is one.
|
||||
if ( displayBlock ) {
|
||||
this._addClass( this.icon, null, "ui-widget-icon-block" );
|
||||
if ( this.iconSpace ) {
|
||||
this.iconSpace.remove();
|
||||
}
|
||||
} else {
|
||||
|
||||
// Position is beginning or end so remove the ui-widget-icon-block class and add the
|
||||
// space if it does not exist
|
||||
if ( !this.iconSpace ) {
|
||||
this.iconSpace = $( "<span> </span>" );
|
||||
this._addClass( this.iconSpace, "ui-button-icon-space" );
|
||||
}
|
||||
this._removeClass( this.icon, null, "ui-wiget-icon-block" );
|
||||
this._attachIconSpace( position );
|
||||
}
|
||||
},
|
||||
|
||||
_destroy: function() {
|
||||
this.element.removeAttr( "role" );
|
||||
|
||||
if ( this.icon ) {
|
||||
this.icon.remove();
|
||||
}
|
||||
if ( this.iconSpace ) {
|
||||
this.iconSpace.remove();
|
||||
}
|
||||
if ( !this.hasTitle ) {
|
||||
this.element.removeAttr( "title" );
|
||||
}
|
||||
},
|
||||
|
||||
_attachIconSpace: function( iconPosition ) {
|
||||
this.icon[ /^(?:end|bottom)/.test( iconPosition ) ? "before" : "after" ]( this.iconSpace );
|
||||
},
|
||||
|
||||
_attachIcon: function( iconPosition ) {
|
||||
this.element[ /^(?:end|bottom)/.test( iconPosition ) ? "append" : "prepend" ]( this.icon );
|
||||
},
|
||||
|
||||
_setOptions: function( options ) {
|
||||
var newShowLabel = options.showLabel === undefined ?
|
||||
this.options.showLabel :
|
||||
options.showLabel,
|
||||
newIcon = options.icon === undefined ? this.options.icon : options.icon;
|
||||
|
||||
if ( !newShowLabel && !newIcon ) {
|
||||
options.showLabel = true;
|
||||
}
|
||||
this._super( options );
|
||||
},
|
||||
|
||||
_setOption: function( key, value ) {
|
||||
if ( key === "icon" ) {
|
||||
if ( value ) {
|
||||
this._updateIcon( key, value );
|
||||
} else if ( this.icon ) {
|
||||
this.icon.remove();
|
||||
if ( this.iconSpace ) {
|
||||
this.iconSpace.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( key === "iconPosition" ) {
|
||||
this._updateIcon( key, value );
|
||||
}
|
||||
|
||||
// Make sure we can't end up with a button that has neither text nor icon
|
||||
if ( key === "showLabel" ) {
|
||||
this._toggleClass( "ui-button-icon-only", null, !value );
|
||||
this._updateTooltip();
|
||||
}
|
||||
|
||||
if ( key === "label" ) {
|
||||
if ( this.isInput ) {
|
||||
this.element.val( value );
|
||||
} else {
|
||||
|
||||
// If there is an icon, append it, else nothing then append the value
|
||||
// this avoids removal of the icon when setting label text
|
||||
this.element.html( value );
|
||||
if ( this.icon ) {
|
||||
this._attachIcon( this.options.iconPosition );
|
||||
this._attachIconSpace( this.options.iconPosition );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._super( key, value );
|
||||
|
||||
if ( key === "disabled" ) {
|
||||
this._toggleClass( null, "ui-state-disabled", value );
|
||||
this.element[ 0 ].disabled = value;
|
||||
if ( value ) {
|
||||
this.element.trigger( "blur" );
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
|
||||
// Make sure to only check disabled if its an element that supports this otherwise
|
||||
// check for the disabled class to determine state
|
||||
var isDisabled = this.element.is( "input, button" ) ?
|
||||
this.element[ 0 ].disabled : this.element.hasClass( "ui-button-disabled" );
|
||||
|
||||
if ( isDisabled !== this.options.disabled ) {
|
||||
this._setOptions( { disabled: isDisabled } );
|
||||
}
|
||||
|
||||
this._updateTooltip();
|
||||
}
|
||||
} );
|
||||
|
||||
// DEPRECATED
|
||||
if ( $.uiBackCompat !== false ) {
|
||||
|
||||
// Text and Icons options
|
||||
$.widget( "ui.button", $.ui.button, {
|
||||
options: {
|
||||
text: true,
|
||||
icons: {
|
||||
primary: null,
|
||||
secondary: null
|
||||
}
|
||||
},
|
||||
|
||||
_create: function() {
|
||||
if ( this.options.showLabel && !this.options.text ) {
|
||||
this.options.showLabel = this.options.text;
|
||||
}
|
||||
if ( !this.options.showLabel && this.options.text ) {
|
||||
this.options.text = this.options.showLabel;
|
||||
}
|
||||
if ( !this.options.icon && ( this.options.icons.primary ||
|
||||
this.options.icons.secondary ) ) {
|
||||
if ( this.options.icons.primary ) {
|
||||
this.options.icon = this.options.icons.primary;
|
||||
} else {
|
||||
this.options.icon = this.options.icons.secondary;
|
||||
this.options.iconPosition = "end";
|
||||
}
|
||||
} else if ( this.options.icon ) {
|
||||
this.options.icons.primary = this.options.icon;
|
||||
}
|
||||
this._super();
|
||||
},
|
||||
|
||||
_setOption: function( key, value ) {
|
||||
if ( key === "text" ) {
|
||||
this._super( "showLabel", value );
|
||||
return;
|
||||
}
|
||||
if ( key === "showLabel" ) {
|
||||
this.options.text = value;
|
||||
}
|
||||
if ( key === "icon" ) {
|
||||
this.options.icons.primary = value;
|
||||
}
|
||||
if ( key === "icons" ) {
|
||||
if ( value.primary ) {
|
||||
this._super( "icon", value.primary );
|
||||
this._super( "iconPosition", "beginning" );
|
||||
} else if ( value.secondary ) {
|
||||
this._super( "icon", value.secondary );
|
||||
this._super( "iconPosition", "end" );
|
||||
}
|
||||
}
|
||||
this._superApply( arguments );
|
||||
}
|
||||
} );
|
||||
|
||||
$.fn.button = ( function( orig ) {
|
||||
return function( options ) {
|
||||
var isMethodCall = typeof options === "string";
|
||||
var args = Array.prototype.slice.call( arguments, 1 );
|
||||
var returnValue = this;
|
||||
|
||||
if ( isMethodCall ) {
|
||||
|
||||
// If this is an empty collection, we need to have the instance method
|
||||
// return undefined instead of the jQuery instance
|
||||
if ( !this.length && options === "instance" ) {
|
||||
returnValue = undefined;
|
||||
} else {
|
||||
this.each( function() {
|
||||
var methodValue;
|
||||
var type = $( this ).attr( "type" );
|
||||
var name = type !== "checkbox" && type !== "radio" ?
|
||||
"button" :
|
||||
"checkboxradio";
|
||||
var instance = $.data( this, "ui-" + name );
|
||||
|
||||
if ( options === "instance" ) {
|
||||
returnValue = instance;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !instance ) {
|
||||
return $.error( "cannot call methods on button" +
|
||||
" prior to initialization; " +
|
||||
"attempted to call method '" + options + "'" );
|
||||
}
|
||||
|
||||
if ( typeof instance[ options ] !== "function" ||
|
||||
options.charAt( 0 ) === "_" ) {
|
||||
return $.error( "no such method '" + options + "' for button" +
|
||||
" widget instance" );
|
||||
}
|
||||
|
||||
methodValue = instance[ options ].apply( instance, args );
|
||||
|
||||
if ( methodValue !== instance && methodValue !== undefined ) {
|
||||
returnValue = methodValue && methodValue.jquery ?
|
||||
returnValue.pushStack( methodValue.get() ) :
|
||||
methodValue;
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
}
|
||||
} else {
|
||||
|
||||
// Allow multiple hashes to be passed on init
|
||||
if ( args.length ) {
|
||||
options = $.widget.extend.apply( null, [ options ].concat( args ) );
|
||||
}
|
||||
|
||||
this.each( function() {
|
||||
var type = $( this ).attr( "type" );
|
||||
var name = type !== "checkbox" && type !== "radio" ? "button" : "checkboxradio";
|
||||
var instance = $.data( this, "ui-" + name );
|
||||
|
||||
if ( instance ) {
|
||||
instance.option( options || {} );
|
||||
if ( instance._init ) {
|
||||
instance._init();
|
||||
}
|
||||
} else {
|
||||
if ( name === "button" ) {
|
||||
orig.call( $( this ), options );
|
||||
return;
|
||||
}
|
||||
|
||||
$( this ).checkboxradio( $.extend( { icon: false }, options ) );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
};
|
||||
} )( $.fn.button );
|
||||
|
||||
$.fn.buttonset = function() {
|
||||
if ( !$.ui.controlgroup ) {
|
||||
$.error( "Controlgroup widget missing" );
|
||||
}
|
||||
if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" && arguments[ 2 ] ) {
|
||||
return this.controlgroup.apply( this,
|
||||
[ arguments[ 0 ], "items.button", arguments[ 2 ] ] );
|
||||
}
|
||||
if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" ) {
|
||||
return this.controlgroup.apply( this, [ arguments[ 0 ], "items.button" ] );
|
||||
}
|
||||
if ( typeof arguments[ 0 ] === "object" && arguments[ 0 ].items ) {
|
||||
arguments[ 0 ].items = {
|
||||
button: arguments[ 0 ].items
|
||||
};
|
||||
}
|
||||
return this.controlgroup.apply( this, arguments );
|
||||
};
|
||||
}
|
||||
|
||||
return $.ui.button;
|
||||
|
||||
} );
|
||||
/*!
|
||||
* jQuery UI Button 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Button
|
||||
//>>group: Widgets
|
||||
//>>description: Enhances a form with themeable buttons.
|
||||
//>>docs: http://api.jqueryui.com/button/
|
||||
//>>demos: http://jqueryui.com/button/
|
||||
//>>css.structure: ../../themes/base/core.css
|
||||
//>>css.structure: ../../themes/base/button.css
|
||||
//>>css.theme: ../../themes/base/theme.css
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
|
||||
// These are only for backcompat
|
||||
// TODO: Remove after 1.12
|
||||
"./controlgroup",
|
||||
"./checkboxradio",
|
||||
|
||||
"./core"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
$.widget( "ui.button", {
|
||||
version: "1.13.2",
|
||||
defaultElement: "<button>",
|
||||
options: {
|
||||
classes: {
|
||||
"ui-button": "ui-corner-all"
|
||||
},
|
||||
disabled: null,
|
||||
icon: null,
|
||||
iconPosition: "beginning",
|
||||
label: null,
|
||||
showLabel: true
|
||||
},
|
||||
|
||||
_getCreateOptions: function() {
|
||||
var disabled,
|
||||
|
||||
// This is to support cases like in jQuery Mobile where the base widget does have
|
||||
// an implementation of _getCreateOptions
|
||||
options = this._super() || {};
|
||||
|
||||
this.isInput = this.element.is( "input" );
|
||||
|
||||
disabled = this.element[ 0 ].disabled;
|
||||
if ( disabled != null ) {
|
||||
options.disabled = disabled;
|
||||
}
|
||||
|
||||
this.originalLabel = this.isInput ? this.element.val() : this.element.html();
|
||||
if ( this.originalLabel ) {
|
||||
options.label = this.originalLabel;
|
||||
}
|
||||
|
||||
return options;
|
||||
},
|
||||
|
||||
_create: function() {
|
||||
if ( !this.option.showLabel & !this.options.icon ) {
|
||||
this.options.showLabel = true;
|
||||
}
|
||||
|
||||
// We have to check the option again here even though we did in _getCreateOptions,
|
||||
// because null may have been passed on init which would override what was set in
|
||||
// _getCreateOptions
|
||||
if ( this.options.disabled == null ) {
|
||||
this.options.disabled = this.element[ 0 ].disabled || false;
|
||||
}
|
||||
|
||||
this.hasTitle = !!this.element.attr( "title" );
|
||||
|
||||
// Check to see if the label needs to be set or if its already correct
|
||||
if ( this.options.label && this.options.label !== this.originalLabel ) {
|
||||
if ( this.isInput ) {
|
||||
this.element.val( this.options.label );
|
||||
} else {
|
||||
this.element.html( this.options.label );
|
||||
}
|
||||
}
|
||||
this._addClass( "ui-button", "ui-widget" );
|
||||
this._setOption( "disabled", this.options.disabled );
|
||||
this._enhance();
|
||||
|
||||
if ( this.element.is( "a" ) ) {
|
||||
this._on( {
|
||||
"keyup": function( event ) {
|
||||
if ( event.keyCode === $.ui.keyCode.SPACE ) {
|
||||
event.preventDefault();
|
||||
|
||||
// Support: PhantomJS <= 1.9, IE 8 Only
|
||||
// If a native click is available use it so we actually cause navigation
|
||||
// otherwise just trigger a click event
|
||||
if ( this.element[ 0 ].click ) {
|
||||
this.element[ 0 ].click();
|
||||
} else {
|
||||
this.element.trigger( "click" );
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
},
|
||||
|
||||
_enhance: function() {
|
||||
if ( !this.element.is( "button" ) ) {
|
||||
this.element.attr( "role", "button" );
|
||||
}
|
||||
|
||||
if ( this.options.icon ) {
|
||||
this._updateIcon( "icon", this.options.icon );
|
||||
this._updateTooltip();
|
||||
}
|
||||
},
|
||||
|
||||
_updateTooltip: function() {
|
||||
this.title = this.element.attr( "title" );
|
||||
|
||||
if ( !this.options.showLabel && !this.title ) {
|
||||
this.element.attr( "title", this.options.label );
|
||||
}
|
||||
},
|
||||
|
||||
_updateIcon: function( option, value ) {
|
||||
var icon = option !== "iconPosition",
|
||||
position = icon ? this.options.iconPosition : value,
|
||||
displayBlock = position === "top" || position === "bottom";
|
||||
|
||||
// Create icon
|
||||
if ( !this.icon ) {
|
||||
this.icon = $( "<span>" );
|
||||
|
||||
this._addClass( this.icon, "ui-button-icon", "ui-icon" );
|
||||
|
||||
if ( !this.options.showLabel ) {
|
||||
this._addClass( "ui-button-icon-only" );
|
||||
}
|
||||
} else if ( icon ) {
|
||||
|
||||
// If we are updating the icon remove the old icon class
|
||||
this._removeClass( this.icon, null, this.options.icon );
|
||||
}
|
||||
|
||||
// If we are updating the icon add the new icon class
|
||||
if ( icon ) {
|
||||
this._addClass( this.icon, null, value );
|
||||
}
|
||||
|
||||
this._attachIcon( position );
|
||||
|
||||
// If the icon is on top or bottom we need to add the ui-widget-icon-block class and remove
|
||||
// the iconSpace if there is one.
|
||||
if ( displayBlock ) {
|
||||
this._addClass( this.icon, null, "ui-widget-icon-block" );
|
||||
if ( this.iconSpace ) {
|
||||
this.iconSpace.remove();
|
||||
}
|
||||
} else {
|
||||
|
||||
// Position is beginning or end so remove the ui-widget-icon-block class and add the
|
||||
// space if it does not exist
|
||||
if ( !this.iconSpace ) {
|
||||
this.iconSpace = $( "<span> </span>" );
|
||||
this._addClass( this.iconSpace, "ui-button-icon-space" );
|
||||
}
|
||||
this._removeClass( this.icon, null, "ui-wiget-icon-block" );
|
||||
this._attachIconSpace( position );
|
||||
}
|
||||
},
|
||||
|
||||
_destroy: function() {
|
||||
this.element.removeAttr( "role" );
|
||||
|
||||
if ( this.icon ) {
|
||||
this.icon.remove();
|
||||
}
|
||||
if ( this.iconSpace ) {
|
||||
this.iconSpace.remove();
|
||||
}
|
||||
if ( !this.hasTitle ) {
|
||||
this.element.removeAttr( "title" );
|
||||
}
|
||||
},
|
||||
|
||||
_attachIconSpace: function( iconPosition ) {
|
||||
this.icon[ /^(?:end|bottom)/.test( iconPosition ) ? "before" : "after" ]( this.iconSpace );
|
||||
},
|
||||
|
||||
_attachIcon: function( iconPosition ) {
|
||||
this.element[ /^(?:end|bottom)/.test( iconPosition ) ? "append" : "prepend" ]( this.icon );
|
||||
},
|
||||
|
||||
_setOptions: function( options ) {
|
||||
var newShowLabel = options.showLabel === undefined ?
|
||||
this.options.showLabel :
|
||||
options.showLabel,
|
||||
newIcon = options.icon === undefined ? this.options.icon : options.icon;
|
||||
|
||||
if ( !newShowLabel && !newIcon ) {
|
||||
options.showLabel = true;
|
||||
}
|
||||
this._super( options );
|
||||
},
|
||||
|
||||
_setOption: function( key, value ) {
|
||||
if ( key === "icon" ) {
|
||||
if ( value ) {
|
||||
this._updateIcon( key, value );
|
||||
} else if ( this.icon ) {
|
||||
this.icon.remove();
|
||||
if ( this.iconSpace ) {
|
||||
this.iconSpace.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( key === "iconPosition" ) {
|
||||
this._updateIcon( key, value );
|
||||
}
|
||||
|
||||
// Make sure we can't end up with a button that has neither text nor icon
|
||||
if ( key === "showLabel" ) {
|
||||
this._toggleClass( "ui-button-icon-only", null, !value );
|
||||
this._updateTooltip();
|
||||
}
|
||||
|
||||
if ( key === "label" ) {
|
||||
if ( this.isInput ) {
|
||||
this.element.val( value );
|
||||
} else {
|
||||
|
||||
// If there is an icon, append it, else nothing then append the value
|
||||
// this avoids removal of the icon when setting label text
|
||||
this.element.html( value );
|
||||
if ( this.icon ) {
|
||||
this._attachIcon( this.options.iconPosition );
|
||||
this._attachIconSpace( this.options.iconPosition );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._super( key, value );
|
||||
|
||||
if ( key === "disabled" ) {
|
||||
this._toggleClass( null, "ui-state-disabled", value );
|
||||
this.element[ 0 ].disabled = value;
|
||||
if ( value ) {
|
||||
this.element.trigger( "blur" );
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
|
||||
// Make sure to only check disabled if its an element that supports this otherwise
|
||||
// check for the disabled class to determine state
|
||||
var isDisabled = this.element.is( "input, button" ) ?
|
||||
this.element[ 0 ].disabled : this.element.hasClass( "ui-button-disabled" );
|
||||
|
||||
if ( isDisabled !== this.options.disabled ) {
|
||||
this._setOptions( { disabled: isDisabled } );
|
||||
}
|
||||
|
||||
this._updateTooltip();
|
||||
}
|
||||
} );
|
||||
|
||||
// DEPRECATED
|
||||
if ( $.uiBackCompat !== false ) {
|
||||
|
||||
// Text and Icons options
|
||||
$.widget( "ui.button", $.ui.button, {
|
||||
options: {
|
||||
text: true,
|
||||
icons: {
|
||||
primary: null,
|
||||
secondary: null
|
||||
}
|
||||
},
|
||||
|
||||
_create: function() {
|
||||
if ( this.options.showLabel && !this.options.text ) {
|
||||
this.options.showLabel = this.options.text;
|
||||
}
|
||||
if ( !this.options.showLabel && this.options.text ) {
|
||||
this.options.text = this.options.showLabel;
|
||||
}
|
||||
if ( !this.options.icon && ( this.options.icons.primary ||
|
||||
this.options.icons.secondary ) ) {
|
||||
if ( this.options.icons.primary ) {
|
||||
this.options.icon = this.options.icons.primary;
|
||||
} else {
|
||||
this.options.icon = this.options.icons.secondary;
|
||||
this.options.iconPosition = "end";
|
||||
}
|
||||
} else if ( this.options.icon ) {
|
||||
this.options.icons.primary = this.options.icon;
|
||||
}
|
||||
this._super();
|
||||
},
|
||||
|
||||
_setOption: function( key, value ) {
|
||||
if ( key === "text" ) {
|
||||
this._super( "showLabel", value );
|
||||
return;
|
||||
}
|
||||
if ( key === "showLabel" ) {
|
||||
this.options.text = value;
|
||||
}
|
||||
if ( key === "icon" ) {
|
||||
this.options.icons.primary = value;
|
||||
}
|
||||
if ( key === "icons" ) {
|
||||
if ( value.primary ) {
|
||||
this._super( "icon", value.primary );
|
||||
this._super( "iconPosition", "beginning" );
|
||||
} else if ( value.secondary ) {
|
||||
this._super( "icon", value.secondary );
|
||||
this._super( "iconPosition", "end" );
|
||||
}
|
||||
}
|
||||
this._superApply( arguments );
|
||||
}
|
||||
} );
|
||||
|
||||
$.fn.button = ( function( orig ) {
|
||||
return function( options ) {
|
||||
var isMethodCall = typeof options === "string";
|
||||
var args = Array.prototype.slice.call( arguments, 1 );
|
||||
var returnValue = this;
|
||||
|
||||
if ( isMethodCall ) {
|
||||
|
||||
// If this is an empty collection, we need to have the instance method
|
||||
// return undefined instead of the jQuery instance
|
||||
if ( !this.length && options === "instance" ) {
|
||||
returnValue = undefined;
|
||||
} else {
|
||||
this.each( function() {
|
||||
var methodValue;
|
||||
var type = $( this ).attr( "type" );
|
||||
var name = type !== "checkbox" && type !== "radio" ?
|
||||
"button" :
|
||||
"checkboxradio";
|
||||
var instance = $.data( this, "ui-" + name );
|
||||
|
||||
if ( options === "instance" ) {
|
||||
returnValue = instance;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !instance ) {
|
||||
return $.error( "cannot call methods on button" +
|
||||
" prior to initialization; " +
|
||||
"attempted to call method '" + options + "'" );
|
||||
}
|
||||
|
||||
if ( typeof instance[ options ] !== "function" ||
|
||||
options.charAt( 0 ) === "_" ) {
|
||||
return $.error( "no such method '" + options + "' for button" +
|
||||
" widget instance" );
|
||||
}
|
||||
|
||||
methodValue = instance[ options ].apply( instance, args );
|
||||
|
||||
if ( methodValue !== instance && methodValue !== undefined ) {
|
||||
returnValue = methodValue && methodValue.jquery ?
|
||||
returnValue.pushStack( methodValue.get() ) :
|
||||
methodValue;
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
}
|
||||
} else {
|
||||
|
||||
// Allow multiple hashes to be passed on init
|
||||
if ( args.length ) {
|
||||
options = $.widget.extend.apply( null, [ options ].concat( args ) );
|
||||
}
|
||||
|
||||
this.each( function() {
|
||||
var type = $( this ).attr( "type" );
|
||||
var name = type !== "checkbox" && type !== "radio" ? "button" : "checkboxradio";
|
||||
var instance = $.data( this, "ui-" + name );
|
||||
|
||||
if ( instance ) {
|
||||
instance.option( options || {} );
|
||||
if ( instance._init ) {
|
||||
instance._init();
|
||||
}
|
||||
} else {
|
||||
if ( name === "button" ) {
|
||||
orig.call( $( this ), options );
|
||||
return;
|
||||
}
|
||||
|
||||
$( this ).checkboxradio( $.extend( { icon: false }, options ) );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
};
|
||||
} )( $.fn.button );
|
||||
|
||||
$.fn.buttonset = function() {
|
||||
if ( !$.ui.controlgroup ) {
|
||||
$.error( "Controlgroup widget missing" );
|
||||
}
|
||||
if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" && arguments[ 2 ] ) {
|
||||
return this.controlgroup.apply( this,
|
||||
[ arguments[ 0 ], "items.button", arguments[ 2 ] ] );
|
||||
}
|
||||
if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" ) {
|
||||
return this.controlgroup.apply( this, [ arguments[ 0 ], "items.button" ] );
|
||||
}
|
||||
if ( typeof arguments[ 0 ] === "object" && arguments[ 0 ].items ) {
|
||||
arguments[ 0 ].items = {
|
||||
button: arguments[ 0 ].items
|
||||
};
|
||||
}
|
||||
return this.controlgroup.apply( this, arguments );
|
||||
};
|
||||
}
|
||||
|
||||
return $.ui.button;
|
||||
|
||||
} );
|
||||
|
||||
+8
-8
File diff suppressed because one or more lines are too long
+288
-288
@@ -1,288 +1,288 @@
|
||||
/*!
|
||||
* jQuery UI Checkboxradio 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Checkboxradio
|
||||
//>>group: Widgets
|
||||
//>>description: Enhances a form with multiple themeable checkboxes or radio buttons.
|
||||
//>>docs: http://api.jqueryui.com/checkboxradio/
|
||||
//>>demos: http://jqueryui.com/checkboxradio/
|
||||
//>>css.structure: ../../themes/base/core.css
|
||||
//>>css.structure: ../../themes/base/button.css
|
||||
//>>css.structure: ../../themes/base/checkboxradio.css
|
||||
//>>css.theme: ../../themes/base/theme.css
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"./core"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
$.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
|
||||
version: "1.13.2",
|
||||
options: {
|
||||
disabled: null,
|
||||
label: null,
|
||||
icon: true,
|
||||
classes: {
|
||||
"ui-checkboxradio-label": "ui-corner-all",
|
||||
"ui-checkboxradio-icon": "ui-corner-all"
|
||||
}
|
||||
},
|
||||
|
||||
_getCreateOptions: function() {
|
||||
var disabled, labels, labelContents;
|
||||
var options = this._super() || {};
|
||||
|
||||
// We read the type here, because it makes more sense to throw a element type error first,
|
||||
// rather then the error for lack of a label. Often if its the wrong type, it
|
||||
// won't have a label (e.g. calling on a div, btn, etc)
|
||||
this._readType();
|
||||
|
||||
labels = this.element.labels();
|
||||
|
||||
// If there are multiple labels, use the last one
|
||||
this.label = $( labels[ labels.length - 1 ] );
|
||||
if ( !this.label.length ) {
|
||||
$.error( "No label found for checkboxradio widget" );
|
||||
}
|
||||
|
||||
this.originalLabel = "";
|
||||
|
||||
// We need to get the label text but this may also need to make sure it does not contain the
|
||||
// input itself.
|
||||
// The label contents could be text, html, or a mix. We wrap all elements
|
||||
// and read the wrapper's `innerHTML` to get a string representation of
|
||||
// the label, without the input as part of it.
|
||||
labelContents = this.label.contents().not( this.element[ 0 ] );
|
||||
|
||||
if ( labelContents.length ) {
|
||||
this.originalLabel += labelContents
|
||||
.clone()
|
||||
.wrapAll( "<div></div>" )
|
||||
.parent()
|
||||
.html();
|
||||
}
|
||||
|
||||
// Set the label option if we found label text
|
||||
if ( this.originalLabel ) {
|
||||
options.label = this.originalLabel;
|
||||
}
|
||||
|
||||
disabled = this.element[ 0 ].disabled;
|
||||
if ( disabled != null ) {
|
||||
options.disabled = disabled;
|
||||
}
|
||||
return options;
|
||||
},
|
||||
|
||||
_create: function() {
|
||||
var checked = this.element[ 0 ].checked;
|
||||
|
||||
this._bindFormResetHandler();
|
||||
|
||||
if ( this.options.disabled == null ) {
|
||||
this.options.disabled = this.element[ 0 ].disabled;
|
||||
}
|
||||
|
||||
this._setOption( "disabled", this.options.disabled );
|
||||
this._addClass( "ui-checkboxradio", "ui-helper-hidden-accessible" );
|
||||
this._addClass( this.label, "ui-checkboxradio-label", "ui-button ui-widget" );
|
||||
|
||||
if ( this.type === "radio" ) {
|
||||
this._addClass( this.label, "ui-checkboxradio-radio-label" );
|
||||
}
|
||||
|
||||
if ( this.options.label && this.options.label !== this.originalLabel ) {
|
||||
this._updateLabel();
|
||||
} else if ( this.originalLabel ) {
|
||||
this.options.label = this.originalLabel;
|
||||
}
|
||||
|
||||
this._enhance();
|
||||
|
||||
if ( checked ) {
|
||||
this._addClass( this.label, "ui-checkboxradio-checked", "ui-state-active" );
|
||||
}
|
||||
|
||||
this._on( {
|
||||
change: "_toggleClasses",
|
||||
focus: function() {
|
||||
this._addClass( this.label, null, "ui-state-focus ui-visual-focus" );
|
||||
},
|
||||
blur: function() {
|
||||
this._removeClass( this.label, null, "ui-state-focus ui-visual-focus" );
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
_readType: function() {
|
||||
var nodeName = this.element[ 0 ].nodeName.toLowerCase();
|
||||
this.type = this.element[ 0 ].type;
|
||||
if ( nodeName !== "input" || !/radio|checkbox/.test( this.type ) ) {
|
||||
$.error( "Can't create checkboxradio on element.nodeName=" + nodeName +
|
||||
" and element.type=" + this.type );
|
||||
}
|
||||
},
|
||||
|
||||
// Support jQuery Mobile enhanced option
|
||||
_enhance: function() {
|
||||
this._updateIcon( this.element[ 0 ].checked );
|
||||
},
|
||||
|
||||
widget: function() {
|
||||
return this.label;
|
||||
},
|
||||
|
||||
_getRadioGroup: function() {
|
||||
var group;
|
||||
var name = this.element[ 0 ].name;
|
||||
var nameSelector = "input[name='" + $.escapeSelector( name ) + "']";
|
||||
|
||||
if ( !name ) {
|
||||
return $( [] );
|
||||
}
|
||||
|
||||
if ( this.form.length ) {
|
||||
group = $( this.form[ 0 ].elements ).filter( nameSelector );
|
||||
} else {
|
||||
|
||||
// Not inside a form, check all inputs that also are not inside a form
|
||||
group = $( nameSelector ).filter( function() {
|
||||
return $( this )._form().length === 0;
|
||||
} );
|
||||
}
|
||||
|
||||
return group.not( this.element );
|
||||
},
|
||||
|
||||
_toggleClasses: function() {
|
||||
var checked = this.element[ 0 ].checked;
|
||||
this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
|
||||
|
||||
if ( this.options.icon && this.type === "checkbox" ) {
|
||||
this._toggleClass( this.icon, null, "ui-icon-check ui-state-checked", checked )
|
||||
._toggleClass( this.icon, null, "ui-icon-blank", !checked );
|
||||
}
|
||||
|
||||
if ( this.type === "radio" ) {
|
||||
this._getRadioGroup()
|
||||
.each( function() {
|
||||
var instance = $( this ).checkboxradio( "instance" );
|
||||
|
||||
if ( instance ) {
|
||||
instance._removeClass( instance.label,
|
||||
"ui-checkboxradio-checked", "ui-state-active" );
|
||||
}
|
||||
} );
|
||||
}
|
||||
},
|
||||
|
||||
_destroy: function() {
|
||||
this._unbindFormResetHandler();
|
||||
|
||||
if ( this.icon ) {
|
||||
this.icon.remove();
|
||||
this.iconSpace.remove();
|
||||
}
|
||||
},
|
||||
|
||||
_setOption: function( key, value ) {
|
||||
|
||||
// We don't allow the value to be set to nothing
|
||||
if ( key === "label" && !value ) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._super( key, value );
|
||||
|
||||
if ( key === "disabled" ) {
|
||||
this._toggleClass( this.label, null, "ui-state-disabled", value );
|
||||
this.element[ 0 ].disabled = value;
|
||||
|
||||
// Don't refresh when setting disabled
|
||||
return;
|
||||
}
|
||||
this.refresh();
|
||||
},
|
||||
|
||||
_updateIcon: function( checked ) {
|
||||
var toAdd = "ui-icon ui-icon-background ";
|
||||
|
||||
if ( this.options.icon ) {
|
||||
if ( !this.icon ) {
|
||||
this.icon = $( "<span>" );
|
||||
this.iconSpace = $( "<span> </span>" );
|
||||
this._addClass( this.iconSpace, "ui-checkboxradio-icon-space" );
|
||||
}
|
||||
|
||||
if ( this.type === "checkbox" ) {
|
||||
toAdd += checked ? "ui-icon-check ui-state-checked" : "ui-icon-blank";
|
||||
this._removeClass( this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check" );
|
||||
} else {
|
||||
toAdd += "ui-icon-blank";
|
||||
}
|
||||
this._addClass( this.icon, "ui-checkboxradio-icon", toAdd );
|
||||
if ( !checked ) {
|
||||
this._removeClass( this.icon, null, "ui-icon-check ui-state-checked" );
|
||||
}
|
||||
this.icon.prependTo( this.label ).after( this.iconSpace );
|
||||
} else if ( this.icon !== undefined ) {
|
||||
this.icon.remove();
|
||||
this.iconSpace.remove();
|
||||
delete this.icon;
|
||||
}
|
||||
},
|
||||
|
||||
_updateLabel: function() {
|
||||
|
||||
// Remove the contents of the label ( minus the icon, icon space, and input )
|
||||
var contents = this.label.contents().not( this.element[ 0 ] );
|
||||
if ( this.icon ) {
|
||||
contents = contents.not( this.icon[ 0 ] );
|
||||
}
|
||||
if ( this.iconSpace ) {
|
||||
contents = contents.not( this.iconSpace[ 0 ] );
|
||||
}
|
||||
contents.remove();
|
||||
|
||||
this.label.append( this.options.label );
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
var checked = this.element[ 0 ].checked,
|
||||
isDisabled = this.element[ 0 ].disabled;
|
||||
|
||||
this._updateIcon( checked );
|
||||
this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
|
||||
if ( this.options.label !== null ) {
|
||||
this._updateLabel();
|
||||
}
|
||||
|
||||
if ( isDisabled !== this.options.disabled ) {
|
||||
this._setOptions( { "disabled": isDisabled } );
|
||||
}
|
||||
}
|
||||
|
||||
} ] );
|
||||
|
||||
return $.ui.checkboxradio;
|
||||
|
||||
} );
|
||||
/*!
|
||||
* jQuery UI Checkboxradio 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Checkboxradio
|
||||
//>>group: Widgets
|
||||
//>>description: Enhances a form with multiple themeable checkboxes or radio buttons.
|
||||
//>>docs: http://api.jqueryui.com/checkboxradio/
|
||||
//>>demos: http://jqueryui.com/checkboxradio/
|
||||
//>>css.structure: ../../themes/base/core.css
|
||||
//>>css.structure: ../../themes/base/button.css
|
||||
//>>css.structure: ../../themes/base/checkboxradio.css
|
||||
//>>css.theme: ../../themes/base/theme.css
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"./core"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
$.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
|
||||
version: "1.13.2",
|
||||
options: {
|
||||
disabled: null,
|
||||
label: null,
|
||||
icon: true,
|
||||
classes: {
|
||||
"ui-checkboxradio-label": "ui-corner-all",
|
||||
"ui-checkboxradio-icon": "ui-corner-all"
|
||||
}
|
||||
},
|
||||
|
||||
_getCreateOptions: function() {
|
||||
var disabled, labels, labelContents;
|
||||
var options = this._super() || {};
|
||||
|
||||
// We read the type here, because it makes more sense to throw a element type error first,
|
||||
// rather then the error for lack of a label. Often if its the wrong type, it
|
||||
// won't have a label (e.g. calling on a div, btn, etc)
|
||||
this._readType();
|
||||
|
||||
labels = this.element.labels();
|
||||
|
||||
// If there are multiple labels, use the last one
|
||||
this.label = $( labels[ labels.length - 1 ] );
|
||||
if ( !this.label.length ) {
|
||||
$.error( "No label found for checkboxradio widget" );
|
||||
}
|
||||
|
||||
this.originalLabel = "";
|
||||
|
||||
// We need to get the label text but this may also need to make sure it does not contain the
|
||||
// input itself.
|
||||
// The label contents could be text, html, or a mix. We wrap all elements
|
||||
// and read the wrapper's `innerHTML` to get a string representation of
|
||||
// the label, without the input as part of it.
|
||||
labelContents = this.label.contents().not( this.element[ 0 ] );
|
||||
|
||||
if ( labelContents.length ) {
|
||||
this.originalLabel += labelContents
|
||||
.clone()
|
||||
.wrapAll( "<div></div>" )
|
||||
.parent()
|
||||
.html();
|
||||
}
|
||||
|
||||
// Set the label option if we found label text
|
||||
if ( this.originalLabel ) {
|
||||
options.label = this.originalLabel;
|
||||
}
|
||||
|
||||
disabled = this.element[ 0 ].disabled;
|
||||
if ( disabled != null ) {
|
||||
options.disabled = disabled;
|
||||
}
|
||||
return options;
|
||||
},
|
||||
|
||||
_create: function() {
|
||||
var checked = this.element[ 0 ].checked;
|
||||
|
||||
this._bindFormResetHandler();
|
||||
|
||||
if ( this.options.disabled == null ) {
|
||||
this.options.disabled = this.element[ 0 ].disabled;
|
||||
}
|
||||
|
||||
this._setOption( "disabled", this.options.disabled );
|
||||
this._addClass( "ui-checkboxradio", "ui-helper-hidden-accessible" );
|
||||
this._addClass( this.label, "ui-checkboxradio-label", "ui-button ui-widget" );
|
||||
|
||||
if ( this.type === "radio" ) {
|
||||
this._addClass( this.label, "ui-checkboxradio-radio-label" );
|
||||
}
|
||||
|
||||
if ( this.options.label && this.options.label !== this.originalLabel ) {
|
||||
this._updateLabel();
|
||||
} else if ( this.originalLabel ) {
|
||||
this.options.label = this.originalLabel;
|
||||
}
|
||||
|
||||
this._enhance();
|
||||
|
||||
if ( checked ) {
|
||||
this._addClass( this.label, "ui-checkboxradio-checked", "ui-state-active" );
|
||||
}
|
||||
|
||||
this._on( {
|
||||
change: "_toggleClasses",
|
||||
focus: function() {
|
||||
this._addClass( this.label, null, "ui-state-focus ui-visual-focus" );
|
||||
},
|
||||
blur: function() {
|
||||
this._removeClass( this.label, null, "ui-state-focus ui-visual-focus" );
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
_readType: function() {
|
||||
var nodeName = this.element[ 0 ].nodeName.toLowerCase();
|
||||
this.type = this.element[ 0 ].type;
|
||||
if ( nodeName !== "input" || !/radio|checkbox/.test( this.type ) ) {
|
||||
$.error( "Can't create checkboxradio on element.nodeName=" + nodeName +
|
||||
" and element.type=" + this.type );
|
||||
}
|
||||
},
|
||||
|
||||
// Support jQuery Mobile enhanced option
|
||||
_enhance: function() {
|
||||
this._updateIcon( this.element[ 0 ].checked );
|
||||
},
|
||||
|
||||
widget: function() {
|
||||
return this.label;
|
||||
},
|
||||
|
||||
_getRadioGroup: function() {
|
||||
var group;
|
||||
var name = this.element[ 0 ].name;
|
||||
var nameSelector = "input[name='" + $.escapeSelector( name ) + "']";
|
||||
|
||||
if ( !name ) {
|
||||
return $( [] );
|
||||
}
|
||||
|
||||
if ( this.form.length ) {
|
||||
group = $( this.form[ 0 ].elements ).filter( nameSelector );
|
||||
} else {
|
||||
|
||||
// Not inside a form, check all inputs that also are not inside a form
|
||||
group = $( nameSelector ).filter( function() {
|
||||
return $( this )._form().length === 0;
|
||||
} );
|
||||
}
|
||||
|
||||
return group.not( this.element );
|
||||
},
|
||||
|
||||
_toggleClasses: function() {
|
||||
var checked = this.element[ 0 ].checked;
|
||||
this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
|
||||
|
||||
if ( this.options.icon && this.type === "checkbox" ) {
|
||||
this._toggleClass( this.icon, null, "ui-icon-check ui-state-checked", checked )
|
||||
._toggleClass( this.icon, null, "ui-icon-blank", !checked );
|
||||
}
|
||||
|
||||
if ( this.type === "radio" ) {
|
||||
this._getRadioGroup()
|
||||
.each( function() {
|
||||
var instance = $( this ).checkboxradio( "instance" );
|
||||
|
||||
if ( instance ) {
|
||||
instance._removeClass( instance.label,
|
||||
"ui-checkboxradio-checked", "ui-state-active" );
|
||||
}
|
||||
} );
|
||||
}
|
||||
},
|
||||
|
||||
_destroy: function() {
|
||||
this._unbindFormResetHandler();
|
||||
|
||||
if ( this.icon ) {
|
||||
this.icon.remove();
|
||||
this.iconSpace.remove();
|
||||
}
|
||||
},
|
||||
|
||||
_setOption: function( key, value ) {
|
||||
|
||||
// We don't allow the value to be set to nothing
|
||||
if ( key === "label" && !value ) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._super( key, value );
|
||||
|
||||
if ( key === "disabled" ) {
|
||||
this._toggleClass( this.label, null, "ui-state-disabled", value );
|
||||
this.element[ 0 ].disabled = value;
|
||||
|
||||
// Don't refresh when setting disabled
|
||||
return;
|
||||
}
|
||||
this.refresh();
|
||||
},
|
||||
|
||||
_updateIcon: function( checked ) {
|
||||
var toAdd = "ui-icon ui-icon-background ";
|
||||
|
||||
if ( this.options.icon ) {
|
||||
if ( !this.icon ) {
|
||||
this.icon = $( "<span>" );
|
||||
this.iconSpace = $( "<span> </span>" );
|
||||
this._addClass( this.iconSpace, "ui-checkboxradio-icon-space" );
|
||||
}
|
||||
|
||||
if ( this.type === "checkbox" ) {
|
||||
toAdd += checked ? "ui-icon-check ui-state-checked" : "ui-icon-blank";
|
||||
this._removeClass( this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check" );
|
||||
} else {
|
||||
toAdd += "ui-icon-blank";
|
||||
}
|
||||
this._addClass( this.icon, "ui-checkboxradio-icon", toAdd );
|
||||
if ( !checked ) {
|
||||
this._removeClass( this.icon, null, "ui-icon-check ui-state-checked" );
|
||||
}
|
||||
this.icon.prependTo( this.label ).after( this.iconSpace );
|
||||
} else if ( this.icon !== undefined ) {
|
||||
this.icon.remove();
|
||||
this.iconSpace.remove();
|
||||
delete this.icon;
|
||||
}
|
||||
},
|
||||
|
||||
_updateLabel: function() {
|
||||
|
||||
// Remove the contents of the label ( minus the icon, icon space, and input )
|
||||
var contents = this.label.contents().not( this.element[ 0 ] );
|
||||
if ( this.icon ) {
|
||||
contents = contents.not( this.icon[ 0 ] );
|
||||
}
|
||||
if ( this.iconSpace ) {
|
||||
contents = contents.not( this.iconSpace[ 0 ] );
|
||||
}
|
||||
contents.remove();
|
||||
|
||||
this.label.append( this.options.label );
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
var checked = this.element[ 0 ].checked,
|
||||
isDisabled = this.element[ 0 ].disabled;
|
||||
|
||||
this._updateIcon( checked );
|
||||
this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
|
||||
if ( this.options.label !== null ) {
|
||||
this._updateLabel();
|
||||
}
|
||||
|
||||
if ( isDisabled !== this.options.disabled ) {
|
||||
this._setOptions( { "disabled": isDisabled } );
|
||||
}
|
||||
}
|
||||
|
||||
} ] );
|
||||
|
||||
return $.ui.checkboxradio;
|
||||
|
||||
} );
|
||||
|
||||
+8
-8
@@ -1,9 +1,9 @@
|
||||
/*!
|
||||
* jQuery UI Checkboxradio 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
/*!
|
||||
* jQuery UI Checkboxradio 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery","./core"],e):e(jQuery)}(function(t){"use strict";return t.widget("ui.checkboxradio",[t.ui.formResetMixin,{version:"1.13.2",options:{disabled:null,label:null,icon:!0,classes:{"ui-checkboxradio-label":"ui-corner-all","ui-checkboxradio-icon":"ui-corner-all"}},_getCreateOptions:function(){var e,i=this._super()||{};return this._readType(),e=this.element.labels(),this.label=t(e[e.length-1]),this.label.length||t.error("No label found for checkboxradio widget"),this.originalLabel="",(e=this.label.contents().not(this.element[0])).length&&(this.originalLabel+=e.clone().wrapAll("<div></div>").parent().html()),this.originalLabel&&(i.label=this.originalLabel),null!=(e=this.element[0].disabled)&&(i.disabled=e),i},_create:function(){var e=this.element[0].checked;this._bindFormResetHandler(),null==this.options.disabled&&(this.options.disabled=this.element[0].disabled),this._setOption("disabled",this.options.disabled),this._addClass("ui-checkboxradio","ui-helper-hidden-accessible"),this._addClass(this.label,"ui-checkboxradio-label","ui-button ui-widget"),"radio"===this.type&&this._addClass(this.label,"ui-checkboxradio-radio-label"),this.options.label&&this.options.label!==this.originalLabel?this._updateLabel():this.originalLabel&&(this.options.label=this.originalLabel),this._enhance(),e&&this._addClass(this.label,"ui-checkboxradio-checked","ui-state-active"),this._on({change:"_toggleClasses",focus:function(){this._addClass(this.label,null,"ui-state-focus ui-visual-focus")},blur:function(){this._removeClass(this.label,null,"ui-state-focus ui-visual-focus")}})},_readType:function(){var e=this.element[0].nodeName.toLowerCase();this.type=this.element[0].type,"input"===e&&/radio|checkbox/.test(this.type)||t.error("Can't create checkboxradio on element.nodeName="+e+" and element.type="+this.type)},_enhance:function(){this._updateIcon(this.element[0].checked)},widget:function(){return this.label},_getRadioGroup:function(){var e=this.element[0].name,i="input[name='"+t.escapeSelector(e)+"']";return e?(this.form.length?t(this.form[0].elements).filter(i):t(i).filter(function(){return 0===t(this)._form().length})).not(this.element):t([])},_toggleClasses:function(){var e=this.element[0].checked;this._toggleClass(this.label,"ui-checkboxradio-checked","ui-state-active",e),this.options.icon&&"checkbox"===this.type&&this._toggleClass(this.icon,null,"ui-icon-check ui-state-checked",e)._toggleClass(this.icon,null,"ui-icon-blank",!e),"radio"===this.type&&this._getRadioGroup().each(function(){var e=t(this).checkboxradio("instance");e&&e._removeClass(e.label,"ui-checkboxradio-checked","ui-state-active")})},_destroy:function(){this._unbindFormResetHandler(),this.icon&&(this.icon.remove(),this.iconSpace.remove())},_setOption:function(e,i){"label"===e&&!i||(this._super(e,i),"disabled"===e?(this._toggleClass(this.label,null,"ui-state-disabled",i),this.element[0].disabled=i):this.refresh())},_updateIcon:function(e){var i="ui-icon ui-icon-background ";this.options.icon?(this.icon||(this.icon=t("<span>"),this.iconSpace=t("<span> </span>"),this._addClass(this.iconSpace,"ui-checkboxradio-icon-space")),"checkbox"===this.type?(i+=e?"ui-icon-check ui-state-checked":"ui-icon-blank",this._removeClass(this.icon,null,e?"ui-icon-blank":"ui-icon-check")):i+="ui-icon-blank",this._addClass(this.icon,"ui-checkboxradio-icon",i),e||this._removeClass(this.icon,null,"ui-icon-check ui-state-checked"),this.icon.prependTo(this.label).after(this.iconSpace)):void 0!==this.icon&&(this.icon.remove(),this.iconSpace.remove(),delete this.icon)},_updateLabel:function(){var e=this.label.contents().not(this.element[0]);this.icon&&(e=e.not(this.icon[0])),(e=this.iconSpace?e.not(this.iconSpace[0]):e).remove(),this.label.append(this.options.label)},refresh:function(){var e=this.element[0].checked,i=this.element[0].disabled;this._updateIcon(e),this._toggleClass(this.label,"ui-checkboxradio-checked","ui-state-active",e),null!==this.options.label&&this._updateLabel(),i!==this.options.disabled&&this._setOptions({disabled:i})}}]),t.ui.checkboxradio});
|
||||
+302
-302
@@ -1,302 +1,302 @@
|
||||
/*!
|
||||
* jQuery UI Controlgroup 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Controlgroup
|
||||
//>>group: Widgets
|
||||
//>>description: Visually groups form control widgets
|
||||
//>>docs: http://api.jqueryui.com/controlgroup/
|
||||
//>>demos: http://jqueryui.com/controlgroup/
|
||||
//>>css.structure: ../../themes/base/core.css
|
||||
//>>css.structure: ../../themes/base/controlgroup.css
|
||||
//>>css.theme: ../../themes/base/theme.css
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"./core"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
var controlgroupCornerRegex = /ui-corner-([a-z]){2,6}/g;
|
||||
|
||||
$.widget( "ui.controlgroup", {
|
||||
version: "1.13.2",
|
||||
defaultElement: "<div>",
|
||||
options: {
|
||||
direction: "horizontal",
|
||||
disabled: null,
|
||||
onlyVisible: true,
|
||||
items: {
|
||||
"button": "input[type=button], input[type=submit], input[type=reset], button, a",
|
||||
"controlgroupLabel": ".ui-controlgroup-label",
|
||||
"checkboxradio": "input[type='checkbox'], input[type='radio']",
|
||||
"selectmenu": "select",
|
||||
"spinner": ".ui-spinner-input"
|
||||
}
|
||||
},
|
||||
|
||||
_create: function() {
|
||||
this._enhance();
|
||||
},
|
||||
|
||||
// To support the enhanced option in jQuery Mobile, we isolate DOM manipulation
|
||||
_enhance: function() {
|
||||
this.element.attr( "role", "toolbar" );
|
||||
this.refresh();
|
||||
},
|
||||
|
||||
_destroy: function() {
|
||||
this._callChildMethod( "destroy" );
|
||||
this.childWidgets.removeData( "ui-controlgroup-data" );
|
||||
this.element.removeAttr( "role" );
|
||||
if ( this.options.items.controlgroupLabel ) {
|
||||
this.element
|
||||
.find( this.options.items.controlgroupLabel )
|
||||
.find( ".ui-controlgroup-label-contents" )
|
||||
.contents().unwrap();
|
||||
}
|
||||
},
|
||||
|
||||
_initWidgets: function() {
|
||||
var that = this,
|
||||
childWidgets = [];
|
||||
|
||||
// First we iterate over each of the items options
|
||||
$.each( this.options.items, function( widget, selector ) {
|
||||
var labels;
|
||||
var options = {};
|
||||
|
||||
// Make sure the widget has a selector set
|
||||
if ( !selector ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( widget === "controlgroupLabel" ) {
|
||||
labels = that.element.find( selector );
|
||||
labels.each( function() {
|
||||
var element = $( this );
|
||||
|
||||
if ( element.children( ".ui-controlgroup-label-contents" ).length ) {
|
||||
return;
|
||||
}
|
||||
element.contents()
|
||||
.wrapAll( "<span class='ui-controlgroup-label-contents'></span>" );
|
||||
} );
|
||||
that._addClass( labels, null, "ui-widget ui-widget-content ui-state-default" );
|
||||
childWidgets = childWidgets.concat( labels.get() );
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure the widget actually exists
|
||||
if ( !$.fn[ widget ] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We assume everything is in the middle to start because we can't determine
|
||||
// first / last elements until all enhancments are done.
|
||||
if ( that[ "_" + widget + "Options" ] ) {
|
||||
options = that[ "_" + widget + "Options" ]( "middle" );
|
||||
} else {
|
||||
options = { classes: {} };
|
||||
}
|
||||
|
||||
// Find instances of this widget inside controlgroup and init them
|
||||
that.element
|
||||
.find( selector )
|
||||
.each( function() {
|
||||
var element = $( this );
|
||||
var instance = element[ widget ]( "instance" );
|
||||
|
||||
// We need to clone the default options for this type of widget to avoid
|
||||
// polluting the variable options which has a wider scope than a single widget.
|
||||
var instanceOptions = $.widget.extend( {}, options );
|
||||
|
||||
// If the button is the child of a spinner ignore it
|
||||
// TODO: Find a more generic solution
|
||||
if ( widget === "button" && element.parent( ".ui-spinner" ).length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the widget if it doesn't exist
|
||||
if ( !instance ) {
|
||||
instance = element[ widget ]()[ widget ]( "instance" );
|
||||
}
|
||||
if ( instance ) {
|
||||
instanceOptions.classes =
|
||||
that._resolveClassesValues( instanceOptions.classes, instance );
|
||||
}
|
||||
element[ widget ]( instanceOptions );
|
||||
|
||||
// Store an instance of the controlgroup to be able to reference
|
||||
// from the outermost element for changing options and refresh
|
||||
var widgetElement = element[ widget ]( "widget" );
|
||||
$.data( widgetElement[ 0 ], "ui-controlgroup-data",
|
||||
instance ? instance : element[ widget ]( "instance" ) );
|
||||
|
||||
childWidgets.push( widgetElement[ 0 ] );
|
||||
} );
|
||||
} );
|
||||
|
||||
this.childWidgets = $( $.uniqueSort( childWidgets ) );
|
||||
this._addClass( this.childWidgets, "ui-controlgroup-item" );
|
||||
},
|
||||
|
||||
_callChildMethod: function( method ) {
|
||||
this.childWidgets.each( function() {
|
||||
var element = $( this ),
|
||||
data = element.data( "ui-controlgroup-data" );
|
||||
if ( data && data[ method ] ) {
|
||||
data[ method ]();
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
_updateCornerClass: function( element, position ) {
|
||||
var remove = "ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-corner-all";
|
||||
var add = this._buildSimpleOptions( position, "label" ).classes.label;
|
||||
|
||||
this._removeClass( element, null, remove );
|
||||
this._addClass( element, null, add );
|
||||
},
|
||||
|
||||
_buildSimpleOptions: function( position, key ) {
|
||||
var direction = this.options.direction === "vertical";
|
||||
var result = {
|
||||
classes: {}
|
||||
};
|
||||
result.classes[ key ] = {
|
||||
"middle": "",
|
||||
"first": "ui-corner-" + ( direction ? "top" : "left" ),
|
||||
"last": "ui-corner-" + ( direction ? "bottom" : "right" ),
|
||||
"only": "ui-corner-all"
|
||||
}[ position ];
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
_spinnerOptions: function( position ) {
|
||||
var options = this._buildSimpleOptions( position, "ui-spinner" );
|
||||
|
||||
options.classes[ "ui-spinner-up" ] = "";
|
||||
options.classes[ "ui-spinner-down" ] = "";
|
||||
|
||||
return options;
|
||||
},
|
||||
|
||||
_buttonOptions: function( position ) {
|
||||
return this._buildSimpleOptions( position, "ui-button" );
|
||||
},
|
||||
|
||||
_checkboxradioOptions: function( position ) {
|
||||
return this._buildSimpleOptions( position, "ui-checkboxradio-label" );
|
||||
},
|
||||
|
||||
_selectmenuOptions: function( position ) {
|
||||
var direction = this.options.direction === "vertical";
|
||||
return {
|
||||
width: direction ? "auto" : false,
|
||||
classes: {
|
||||
middle: {
|
||||
"ui-selectmenu-button-open": "",
|
||||
"ui-selectmenu-button-closed": ""
|
||||
},
|
||||
first: {
|
||||
"ui-selectmenu-button-open": "ui-corner-" + ( direction ? "top" : "tl" ),
|
||||
"ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "top" : "left" )
|
||||
},
|
||||
last: {
|
||||
"ui-selectmenu-button-open": direction ? "" : "ui-corner-tr",
|
||||
"ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "bottom" : "right" )
|
||||
},
|
||||
only: {
|
||||
"ui-selectmenu-button-open": "ui-corner-top",
|
||||
"ui-selectmenu-button-closed": "ui-corner-all"
|
||||
}
|
||||
|
||||
}[ position ]
|
||||
};
|
||||
},
|
||||
|
||||
_resolveClassesValues: function( classes, instance ) {
|
||||
var result = {};
|
||||
$.each( classes, function( key ) {
|
||||
var current = instance.options.classes[ key ] || "";
|
||||
current = String.prototype.trim.call( current.replace( controlgroupCornerRegex, "" ) );
|
||||
result[ key ] = ( current + " " + classes[ key ] ).replace( /\s+/g, " " );
|
||||
} );
|
||||
return result;
|
||||
},
|
||||
|
||||
_setOption: function( key, value ) {
|
||||
if ( key === "direction" ) {
|
||||
this._removeClass( "ui-controlgroup-" + this.options.direction );
|
||||
}
|
||||
|
||||
this._super( key, value );
|
||||
if ( key === "disabled" ) {
|
||||
this._callChildMethod( value ? "disable" : "enable" );
|
||||
return;
|
||||
}
|
||||
|
||||
this.refresh();
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
var children,
|
||||
that = this;
|
||||
|
||||
this._addClass( "ui-controlgroup ui-controlgroup-" + this.options.direction );
|
||||
|
||||
if ( this.options.direction === "horizontal" ) {
|
||||
this._addClass( null, "ui-helper-clearfix" );
|
||||
}
|
||||
this._initWidgets();
|
||||
|
||||
children = this.childWidgets;
|
||||
|
||||
// We filter here because we need to track all childWidgets not just the visible ones
|
||||
if ( this.options.onlyVisible ) {
|
||||
children = children.filter( ":visible" );
|
||||
}
|
||||
|
||||
if ( children.length ) {
|
||||
|
||||
// We do this last because we need to make sure all enhancment is done
|
||||
// before determining first and last
|
||||
$.each( [ "first", "last" ], function( index, value ) {
|
||||
var instance = children[ value ]().data( "ui-controlgroup-data" );
|
||||
|
||||
if ( instance && that[ "_" + instance.widgetName + "Options" ] ) {
|
||||
var options = that[ "_" + instance.widgetName + "Options" ](
|
||||
children.length === 1 ? "only" : value
|
||||
);
|
||||
options.classes = that._resolveClassesValues( options.classes, instance );
|
||||
instance.element[ instance.widgetName ]( options );
|
||||
} else {
|
||||
that._updateCornerClass( children[ value ](), value );
|
||||
}
|
||||
} );
|
||||
|
||||
// Finally call the refresh method on each of the child widgets.
|
||||
this._callChildMethod( "refresh" );
|
||||
}
|
||||
}
|
||||
} );
|
||||
} );
|
||||
/*!
|
||||
* jQuery UI Controlgroup 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Controlgroup
|
||||
//>>group: Widgets
|
||||
//>>description: Visually groups form control widgets
|
||||
//>>docs: http://api.jqueryui.com/controlgroup/
|
||||
//>>demos: http://jqueryui.com/controlgroup/
|
||||
//>>css.structure: ../../themes/base/core.css
|
||||
//>>css.structure: ../../themes/base/controlgroup.css
|
||||
//>>css.theme: ../../themes/base/theme.css
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"./core"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
var controlgroupCornerRegex = /ui-corner-([a-z]){2,6}/g;
|
||||
|
||||
$.widget( "ui.controlgroup", {
|
||||
version: "1.13.2",
|
||||
defaultElement: "<div>",
|
||||
options: {
|
||||
direction: "horizontal",
|
||||
disabled: null,
|
||||
onlyVisible: true,
|
||||
items: {
|
||||
"button": "input[type=button], input[type=submit], input[type=reset], button, a",
|
||||
"controlgroupLabel": ".ui-controlgroup-label",
|
||||
"checkboxradio": "input[type='checkbox'], input[type='radio']",
|
||||
"selectmenu": "select",
|
||||
"spinner": ".ui-spinner-input"
|
||||
}
|
||||
},
|
||||
|
||||
_create: function() {
|
||||
this._enhance();
|
||||
},
|
||||
|
||||
// To support the enhanced option in jQuery Mobile, we isolate DOM manipulation
|
||||
_enhance: function() {
|
||||
this.element.attr( "role", "toolbar" );
|
||||
this.refresh();
|
||||
},
|
||||
|
||||
_destroy: function() {
|
||||
this._callChildMethod( "destroy" );
|
||||
this.childWidgets.removeData( "ui-controlgroup-data" );
|
||||
this.element.removeAttr( "role" );
|
||||
if ( this.options.items.controlgroupLabel ) {
|
||||
this.element
|
||||
.find( this.options.items.controlgroupLabel )
|
||||
.find( ".ui-controlgroup-label-contents" )
|
||||
.contents().unwrap();
|
||||
}
|
||||
},
|
||||
|
||||
_initWidgets: function() {
|
||||
var that = this,
|
||||
childWidgets = [];
|
||||
|
||||
// First we iterate over each of the items options
|
||||
$.each( this.options.items, function( widget, selector ) {
|
||||
var labels;
|
||||
var options = {};
|
||||
|
||||
// Make sure the widget has a selector set
|
||||
if ( !selector ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( widget === "controlgroupLabel" ) {
|
||||
labels = that.element.find( selector );
|
||||
labels.each( function() {
|
||||
var element = $( this );
|
||||
|
||||
if ( element.children( ".ui-controlgroup-label-contents" ).length ) {
|
||||
return;
|
||||
}
|
||||
element.contents()
|
||||
.wrapAll( "<span class='ui-controlgroup-label-contents'></span>" );
|
||||
} );
|
||||
that._addClass( labels, null, "ui-widget ui-widget-content ui-state-default" );
|
||||
childWidgets = childWidgets.concat( labels.get() );
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure the widget actually exists
|
||||
if ( !$.fn[ widget ] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We assume everything is in the middle to start because we can't determine
|
||||
// first / last elements until all enhancments are done.
|
||||
if ( that[ "_" + widget + "Options" ] ) {
|
||||
options = that[ "_" + widget + "Options" ]( "middle" );
|
||||
} else {
|
||||
options = { classes: {} };
|
||||
}
|
||||
|
||||
// Find instances of this widget inside controlgroup and init them
|
||||
that.element
|
||||
.find( selector )
|
||||
.each( function() {
|
||||
var element = $( this );
|
||||
var instance = element[ widget ]( "instance" );
|
||||
|
||||
// We need to clone the default options for this type of widget to avoid
|
||||
// polluting the variable options which has a wider scope than a single widget.
|
||||
var instanceOptions = $.widget.extend( {}, options );
|
||||
|
||||
// If the button is the child of a spinner ignore it
|
||||
// TODO: Find a more generic solution
|
||||
if ( widget === "button" && element.parent( ".ui-spinner" ).length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the widget if it doesn't exist
|
||||
if ( !instance ) {
|
||||
instance = element[ widget ]()[ widget ]( "instance" );
|
||||
}
|
||||
if ( instance ) {
|
||||
instanceOptions.classes =
|
||||
that._resolveClassesValues( instanceOptions.classes, instance );
|
||||
}
|
||||
element[ widget ]( instanceOptions );
|
||||
|
||||
// Store an instance of the controlgroup to be able to reference
|
||||
// from the outermost element for changing options and refresh
|
||||
var widgetElement = element[ widget ]( "widget" );
|
||||
$.data( widgetElement[ 0 ], "ui-controlgroup-data",
|
||||
instance ? instance : element[ widget ]( "instance" ) );
|
||||
|
||||
childWidgets.push( widgetElement[ 0 ] );
|
||||
} );
|
||||
} );
|
||||
|
||||
this.childWidgets = $( $.uniqueSort( childWidgets ) );
|
||||
this._addClass( this.childWidgets, "ui-controlgroup-item" );
|
||||
},
|
||||
|
||||
_callChildMethod: function( method ) {
|
||||
this.childWidgets.each( function() {
|
||||
var element = $( this ),
|
||||
data = element.data( "ui-controlgroup-data" );
|
||||
if ( data && data[ method ] ) {
|
||||
data[ method ]();
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
_updateCornerClass: function( element, position ) {
|
||||
var remove = "ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-corner-all";
|
||||
var add = this._buildSimpleOptions( position, "label" ).classes.label;
|
||||
|
||||
this._removeClass( element, null, remove );
|
||||
this._addClass( element, null, add );
|
||||
},
|
||||
|
||||
_buildSimpleOptions: function( position, key ) {
|
||||
var direction = this.options.direction === "vertical";
|
||||
var result = {
|
||||
classes: {}
|
||||
};
|
||||
result.classes[ key ] = {
|
||||
"middle": "",
|
||||
"first": "ui-corner-" + ( direction ? "top" : "left" ),
|
||||
"last": "ui-corner-" + ( direction ? "bottom" : "right" ),
|
||||
"only": "ui-corner-all"
|
||||
}[ position ];
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
_spinnerOptions: function( position ) {
|
||||
var options = this._buildSimpleOptions( position, "ui-spinner" );
|
||||
|
||||
options.classes[ "ui-spinner-up" ] = "";
|
||||
options.classes[ "ui-spinner-down" ] = "";
|
||||
|
||||
return options;
|
||||
},
|
||||
|
||||
_buttonOptions: function( position ) {
|
||||
return this._buildSimpleOptions( position, "ui-button" );
|
||||
},
|
||||
|
||||
_checkboxradioOptions: function( position ) {
|
||||
return this._buildSimpleOptions( position, "ui-checkboxradio-label" );
|
||||
},
|
||||
|
||||
_selectmenuOptions: function( position ) {
|
||||
var direction = this.options.direction === "vertical";
|
||||
return {
|
||||
width: direction ? "auto" : false,
|
||||
classes: {
|
||||
middle: {
|
||||
"ui-selectmenu-button-open": "",
|
||||
"ui-selectmenu-button-closed": ""
|
||||
},
|
||||
first: {
|
||||
"ui-selectmenu-button-open": "ui-corner-" + ( direction ? "top" : "tl" ),
|
||||
"ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "top" : "left" )
|
||||
},
|
||||
last: {
|
||||
"ui-selectmenu-button-open": direction ? "" : "ui-corner-tr",
|
||||
"ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "bottom" : "right" )
|
||||
},
|
||||
only: {
|
||||
"ui-selectmenu-button-open": "ui-corner-top",
|
||||
"ui-selectmenu-button-closed": "ui-corner-all"
|
||||
}
|
||||
|
||||
}[ position ]
|
||||
};
|
||||
},
|
||||
|
||||
_resolveClassesValues: function( classes, instance ) {
|
||||
var result = {};
|
||||
$.each( classes, function( key ) {
|
||||
var current = instance.options.classes[ key ] || "";
|
||||
current = String.prototype.trim.call( current.replace( controlgroupCornerRegex, "" ) );
|
||||
result[ key ] = ( current + " " + classes[ key ] ).replace( /\s+/g, " " );
|
||||
} );
|
||||
return result;
|
||||
},
|
||||
|
||||
_setOption: function( key, value ) {
|
||||
if ( key === "direction" ) {
|
||||
this._removeClass( "ui-controlgroup-" + this.options.direction );
|
||||
}
|
||||
|
||||
this._super( key, value );
|
||||
if ( key === "disabled" ) {
|
||||
this._callChildMethod( value ? "disable" : "enable" );
|
||||
return;
|
||||
}
|
||||
|
||||
this.refresh();
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
var children,
|
||||
that = this;
|
||||
|
||||
this._addClass( "ui-controlgroup ui-controlgroup-" + this.options.direction );
|
||||
|
||||
if ( this.options.direction === "horizontal" ) {
|
||||
this._addClass( null, "ui-helper-clearfix" );
|
||||
}
|
||||
this._initWidgets();
|
||||
|
||||
children = this.childWidgets;
|
||||
|
||||
// We filter here because we need to track all childWidgets not just the visible ones
|
||||
if ( this.options.onlyVisible ) {
|
||||
children = children.filter( ":visible" );
|
||||
}
|
||||
|
||||
if ( children.length ) {
|
||||
|
||||
// We do this last because we need to make sure all enhancment is done
|
||||
// before determining first and last
|
||||
$.each( [ "first", "last" ], function( index, value ) {
|
||||
var instance = children[ value ]().data( "ui-controlgroup-data" );
|
||||
|
||||
if ( instance && that[ "_" + instance.widgetName + "Options" ] ) {
|
||||
var options = that[ "_" + instance.widgetName + "Options" ](
|
||||
children.length === 1 ? "only" : value
|
||||
);
|
||||
options.classes = that._resolveClassesValues( options.classes, instance );
|
||||
instance.element[ instance.widgetName ]( options );
|
||||
} else {
|
||||
that._updateCornerClass( children[ value ](), value );
|
||||
}
|
||||
} );
|
||||
|
||||
// Finally call the refresh method on each of the child widgets.
|
||||
this._callChildMethod( "refresh" );
|
||||
}
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
+8
-8
@@ -1,9 +1,9 @@
|
||||
/*!
|
||||
* jQuery UI Controlgroup 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
/*!
|
||||
* jQuery UI Controlgroup 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery","./core"],t):t(jQuery)}(function(r){"use strict";var s=/ui-corner-([a-z]){2,6}/g;r.widget("ui.controlgroup",{version:"1.13.2",defaultElement:"<div>",options:{direction:"horizontal",disabled:null,onlyVisible:!0,items:{button:"input[type=button], input[type=submit], input[type=reset], button, a",controlgroupLabel:".ui-controlgroup-label",checkboxradio:"input[type='checkbox'], input[type='radio']",selectmenu:"select",spinner:".ui-spinner-input"}},_create:function(){this._enhance()},_enhance:function(){this.element.attr("role","toolbar"),this.refresh()},_destroy:function(){this._callChildMethod("destroy"),this.childWidgets.removeData("ui-controlgroup-data"),this.element.removeAttr("role"),this.options.items.controlgroupLabel&&this.element.find(this.options.items.controlgroupLabel).find(".ui-controlgroup-label-contents").contents().unwrap()},_initWidgets:function(){var s=this,l=[];r.each(this.options.items,function(n,t){var e,o={};t&&("controlgroupLabel"===n?((e=s.element.find(t)).each(function(){var t=r(this);t.children(".ui-controlgroup-label-contents").length||t.contents().wrapAll("<span class='ui-controlgroup-label-contents'></span>")}),s._addClass(e,null,"ui-widget ui-widget-content ui-state-default"),l=l.concat(e.get())):r.fn[n]&&(o=s["_"+n+"Options"]?s["_"+n+"Options"]("middle"):{classes:{}},s.element.find(t).each(function(){var t=r(this),e=t[n]("instance"),i=r.widget.extend({},o);"button"===n&&t.parent(".ui-spinner").length||((e=e||t[n]()[n]("instance"))&&(i.classes=s._resolveClassesValues(i.classes,e)),t[n](i),i=t[n]("widget"),r.data(i[0],"ui-controlgroup-data",e||t[n]("instance")),l.push(i[0]))})))}),this.childWidgets=r(r.uniqueSort(l)),this._addClass(this.childWidgets,"ui-controlgroup-item")},_callChildMethod:function(e){this.childWidgets.each(function(){var t=r(this).data("ui-controlgroup-data");t&&t[e]&&t[e]()})},_updateCornerClass:function(t,e){e=this._buildSimpleOptions(e,"label").classes.label;this._removeClass(t,null,"ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-corner-all"),this._addClass(t,null,e)},_buildSimpleOptions:function(t,e){var i="vertical"===this.options.direction,n={classes:{}};return n.classes[e]={middle:"",first:"ui-corner-"+(i?"top":"left"),last:"ui-corner-"+(i?"bottom":"right"),only:"ui-corner-all"}[t],n},_spinnerOptions:function(t){t=this._buildSimpleOptions(t,"ui-spinner");return t.classes["ui-spinner-up"]="",t.classes["ui-spinner-down"]="",t},_buttonOptions:function(t){return this._buildSimpleOptions(t,"ui-button")},_checkboxradioOptions:function(t){return this._buildSimpleOptions(t,"ui-checkboxradio-label")},_selectmenuOptions:function(t){var e="vertical"===this.options.direction;return{width:e&&"auto",classes:{middle:{"ui-selectmenu-button-open":"","ui-selectmenu-button-closed":""},first:{"ui-selectmenu-button-open":"ui-corner-"+(e?"top":"tl"),"ui-selectmenu-button-closed":"ui-corner-"+(e?"top":"left")},last:{"ui-selectmenu-button-open":e?"":"ui-corner-tr","ui-selectmenu-button-closed":"ui-corner-"+(e?"bottom":"right")},only:{"ui-selectmenu-button-open":"ui-corner-top","ui-selectmenu-button-closed":"ui-corner-all"}}[t]}},_resolveClassesValues:function(i,n){var o={};return r.each(i,function(t){var e=n.options.classes[t]||"",e=String.prototype.trim.call(e.replace(s,""));o[t]=(e+" "+i[t]).replace(/\s+/g," ")}),o},_setOption:function(t,e){"direction"===t&&this._removeClass("ui-controlgroup-"+this.options.direction),this._super(t,e),"disabled"===t?this._callChildMethod(e?"disable":"enable"):this.refresh()},refresh:function(){var o,s=this;this._addClass("ui-controlgroup ui-controlgroup-"+this.options.direction),"horizontal"===this.options.direction&&this._addClass(null,"ui-helper-clearfix"),this._initWidgets(),o=this.childWidgets,(o=this.options.onlyVisible?o.filter(":visible"):o).length&&(r.each(["first","last"],function(t,e){var i,n=o[e]().data("ui-controlgroup-data");n&&s["_"+n.widgetName+"Options"]?((i=s["_"+n.widgetName+"Options"](1===o.length?"only":e)).classes=s._resolveClassesValues(i.classes,n),n.element[n.widgetName](i)):s._updateCornerClass(o[e](),e)}),this._callChildMethod("refresh"))}})});
|
||||
+1790
-1790
File diff suppressed because it is too large
Load Diff
+115
-115
File diff suppressed because one or more lines are too long
+2239
-2239
File diff suppressed because it is too large
Load Diff
+8
-8
File diff suppressed because one or more lines are too long
+946
-946
File diff suppressed because it is too large
Load Diff
+8
-8
File diff suppressed because one or more lines are too long
+1253
-1253
File diff suppressed because it is too large
Load Diff
+8
-8
File diff suppressed because one or more lines are too long
+502
-502
File diff suppressed because it is too large
Load Diff
+8
-8
File diff suppressed because one or more lines are too long
+72
-72
@@ -1,72 +1,72 @@
|
||||
/*!
|
||||
* jQuery UI Effects Blind 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Blind Effect
|
||||
//>>group: Effects
|
||||
//>>description: Blinds the element.
|
||||
//>>docs: http://api.jqueryui.com/blind-effect/
|
||||
//>>demos: http://jqueryui.com/effect/
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"./effect"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
return $.effects.define( "blind", "hide", function( options, done ) {
|
||||
var map = {
|
||||
up: [ "bottom", "top" ],
|
||||
vertical: [ "bottom", "top" ],
|
||||
down: [ "top", "bottom" ],
|
||||
left: [ "right", "left" ],
|
||||
horizontal: [ "right", "left" ],
|
||||
right: [ "left", "right" ]
|
||||
},
|
||||
element = $( this ),
|
||||
direction = options.direction || "up",
|
||||
start = element.cssClip(),
|
||||
animate = { clip: $.extend( {}, start ) },
|
||||
placeholder = $.effects.createPlaceholder( element );
|
||||
|
||||
animate.clip[ map[ direction ][ 0 ] ] = animate.clip[ map[ direction ][ 1 ] ];
|
||||
|
||||
if ( options.mode === "show" ) {
|
||||
element.cssClip( animate.clip );
|
||||
if ( placeholder ) {
|
||||
placeholder.css( $.effects.clipToBox( animate ) );
|
||||
}
|
||||
|
||||
animate.clip = start;
|
||||
}
|
||||
|
||||
if ( placeholder ) {
|
||||
placeholder.animate( $.effects.clipToBox( animate ), options.duration, options.easing );
|
||||
}
|
||||
|
||||
element.animate( animate, {
|
||||
queue: false,
|
||||
duration: options.duration,
|
||||
easing: options.easing,
|
||||
complete: done
|
||||
} );
|
||||
} );
|
||||
|
||||
} );
|
||||
/*!
|
||||
* jQuery UI Effects Blind 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Blind Effect
|
||||
//>>group: Effects
|
||||
//>>description: Blinds the element.
|
||||
//>>docs: http://api.jqueryui.com/blind-effect/
|
||||
//>>demos: http://jqueryui.com/effect/
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"./effect"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
return $.effects.define( "blind", "hide", function( options, done ) {
|
||||
var map = {
|
||||
up: [ "bottom", "top" ],
|
||||
vertical: [ "bottom", "top" ],
|
||||
down: [ "top", "bottom" ],
|
||||
left: [ "right", "left" ],
|
||||
horizontal: [ "right", "left" ],
|
||||
right: [ "left", "right" ]
|
||||
},
|
||||
element = $( this ),
|
||||
direction = options.direction || "up",
|
||||
start = element.cssClip(),
|
||||
animate = { clip: $.extend( {}, start ) },
|
||||
placeholder = $.effects.createPlaceholder( element );
|
||||
|
||||
animate.clip[ map[ direction ][ 0 ] ] = animate.clip[ map[ direction ][ 1 ] ];
|
||||
|
||||
if ( options.mode === "show" ) {
|
||||
element.cssClip( animate.clip );
|
||||
if ( placeholder ) {
|
||||
placeholder.css( $.effects.clipToBox( animate ) );
|
||||
}
|
||||
|
||||
animate.clip = start;
|
||||
}
|
||||
|
||||
if ( placeholder ) {
|
||||
placeholder.animate( $.effects.clipToBox( animate ), options.duration, options.easing );
|
||||
}
|
||||
|
||||
element.animate( animate, {
|
||||
queue: false,
|
||||
duration: options.duration,
|
||||
easing: options.easing,
|
||||
complete: done
|
||||
} );
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
+8
-8
@@ -1,9 +1,9 @@
|
||||
/*!
|
||||
* jQuery UI Effects Blind 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
/*!
|
||||
* jQuery UI Effects Blind 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery","./effect"],e):e(jQuery)}(function(r){"use strict";return r.effects.define("blind","hide",function(e,t){var i={up:["bottom","top"],vertical:["bottom","top"],down:["top","bottom"],left:["right","left"],horizontal:["right","left"],right:["left","right"]},o=r(this),c=e.direction||"up",n=o.cssClip(),f={clip:r.extend({},n)},l=r.effects.createPlaceholder(o);f.clip[i[c][0]]=f.clip[i[c][1]],"show"===e.mode&&(o.cssClip(f.clip),l&&l.css(r.effects.clipToBox(f)),f.clip=n),l&&l.animate(r.effects.clipToBox(f),e.duration,e.easing),o.animate(f,{queue:!1,duration:e.duration,easing:e.easing,complete:t})})});
|
||||
+112
-112
@@ -1,112 +1,112 @@
|
||||
/*!
|
||||
* jQuery UI Effects Bounce 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Bounce Effect
|
||||
//>>group: Effects
|
||||
//>>description: Bounces an element horizontally or vertically n times.
|
||||
//>>docs: http://api.jqueryui.com/bounce-effect/
|
||||
//>>demos: http://jqueryui.com/effect/
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"./effect"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
return $.effects.define( "bounce", function( options, done ) {
|
||||
var upAnim, downAnim, refValue,
|
||||
element = $( this ),
|
||||
|
||||
// Defaults:
|
||||
mode = options.mode,
|
||||
hide = mode === "hide",
|
||||
show = mode === "show",
|
||||
direction = options.direction || "up",
|
||||
distance = options.distance,
|
||||
times = options.times || 5,
|
||||
|
||||
// Number of internal animations
|
||||
anims = times * 2 + ( show || hide ? 1 : 0 ),
|
||||
speed = options.duration / anims,
|
||||
easing = options.easing,
|
||||
|
||||
// Utility:
|
||||
ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
|
||||
motion = ( direction === "up" || direction === "left" ),
|
||||
i = 0,
|
||||
|
||||
queuelen = element.queue().length;
|
||||
|
||||
$.effects.createPlaceholder( element );
|
||||
|
||||
refValue = element.css( ref );
|
||||
|
||||
// Default distance for the BIGGEST bounce is the outer Distance / 3
|
||||
if ( !distance ) {
|
||||
distance = element[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
|
||||
}
|
||||
|
||||
if ( show ) {
|
||||
downAnim = { opacity: 1 };
|
||||
downAnim[ ref ] = refValue;
|
||||
|
||||
// If we are showing, force opacity 0 and set the initial position
|
||||
// then do the "first" animation
|
||||
element
|
||||
.css( "opacity", 0 )
|
||||
.css( ref, motion ? -distance * 2 : distance * 2 )
|
||||
.animate( downAnim, speed, easing );
|
||||
}
|
||||
|
||||
// Start at the smallest distance if we are hiding
|
||||
if ( hide ) {
|
||||
distance = distance / Math.pow( 2, times - 1 );
|
||||
}
|
||||
|
||||
downAnim = {};
|
||||
downAnim[ ref ] = refValue;
|
||||
|
||||
// Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
|
||||
for ( ; i < times; i++ ) {
|
||||
upAnim = {};
|
||||
upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
|
||||
|
||||
element
|
||||
.animate( upAnim, speed, easing )
|
||||
.animate( downAnim, speed, easing );
|
||||
|
||||
distance = hide ? distance * 2 : distance / 2;
|
||||
}
|
||||
|
||||
// Last Bounce when Hiding
|
||||
if ( hide ) {
|
||||
upAnim = { opacity: 0 };
|
||||
upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
|
||||
|
||||
element.animate( upAnim, speed, easing );
|
||||
}
|
||||
|
||||
element.queue( done );
|
||||
|
||||
$.effects.unshift( element, queuelen, anims + 1 );
|
||||
} );
|
||||
|
||||
} );
|
||||
/*!
|
||||
* jQuery UI Effects Bounce 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Bounce Effect
|
||||
//>>group: Effects
|
||||
//>>description: Bounces an element horizontally or vertically n times.
|
||||
//>>docs: http://api.jqueryui.com/bounce-effect/
|
||||
//>>demos: http://jqueryui.com/effect/
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"./effect"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
return $.effects.define( "bounce", function( options, done ) {
|
||||
var upAnim, downAnim, refValue,
|
||||
element = $( this ),
|
||||
|
||||
// Defaults:
|
||||
mode = options.mode,
|
||||
hide = mode === "hide",
|
||||
show = mode === "show",
|
||||
direction = options.direction || "up",
|
||||
distance = options.distance,
|
||||
times = options.times || 5,
|
||||
|
||||
// Number of internal animations
|
||||
anims = times * 2 + ( show || hide ? 1 : 0 ),
|
||||
speed = options.duration / anims,
|
||||
easing = options.easing,
|
||||
|
||||
// Utility:
|
||||
ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
|
||||
motion = ( direction === "up" || direction === "left" ),
|
||||
i = 0,
|
||||
|
||||
queuelen = element.queue().length;
|
||||
|
||||
$.effects.createPlaceholder( element );
|
||||
|
||||
refValue = element.css( ref );
|
||||
|
||||
// Default distance for the BIGGEST bounce is the outer Distance / 3
|
||||
if ( !distance ) {
|
||||
distance = element[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
|
||||
}
|
||||
|
||||
if ( show ) {
|
||||
downAnim = { opacity: 1 };
|
||||
downAnim[ ref ] = refValue;
|
||||
|
||||
// If we are showing, force opacity 0 and set the initial position
|
||||
// then do the "first" animation
|
||||
element
|
||||
.css( "opacity", 0 )
|
||||
.css( ref, motion ? -distance * 2 : distance * 2 )
|
||||
.animate( downAnim, speed, easing );
|
||||
}
|
||||
|
||||
// Start at the smallest distance if we are hiding
|
||||
if ( hide ) {
|
||||
distance = distance / Math.pow( 2, times - 1 );
|
||||
}
|
||||
|
||||
downAnim = {};
|
||||
downAnim[ ref ] = refValue;
|
||||
|
||||
// Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
|
||||
for ( ; i < times; i++ ) {
|
||||
upAnim = {};
|
||||
upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
|
||||
|
||||
element
|
||||
.animate( upAnim, speed, easing )
|
||||
.animate( downAnim, speed, easing );
|
||||
|
||||
distance = hide ? distance * 2 : distance / 2;
|
||||
}
|
||||
|
||||
// Last Bounce when Hiding
|
||||
if ( hide ) {
|
||||
upAnim = { opacity: 0 };
|
||||
upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
|
||||
|
||||
element.animate( upAnim, speed, easing );
|
||||
}
|
||||
|
||||
element.queue( done );
|
||||
|
||||
$.effects.unshift( element, queuelen, anims + 1 );
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
+8
-8
@@ -1,9 +1,9 @@
|
||||
/*!
|
||||
* jQuery UI Effects Bounce 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
/*!
|
||||
* jQuery UI Effects Bounce 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery","./effect"],e):e(jQuery)}(function(l){"use strict";return l.effects.define("bounce",function(e,t){var i,n,c=l(this),f=e.mode,o="hide"===f,f="show"===f,u=e.direction||"up",a=e.distance,s=e.times||5,r=2*s+(f||o?1:0),d=e.duration/r,p=e.easing,h="up"===u||"down"===u?"top":"left",m="up"===u||"left"===u,y=0,e=c.queue().length;for(l.effects.createPlaceholder(c),u=c.css(h),a=a||c["top"==h?"outerHeight":"outerWidth"]()/3,f&&((n={opacity:1})[h]=u,c.css("opacity",0).css(h,m?2*-a:2*a).animate(n,d,p)),o&&(a/=Math.pow(2,s-1)),(n={})[h]=u;y<s;y++)(i={})[h]=(m?"-=":"+=")+a,c.animate(i,d,p).animate(n,d,p),a=o?2*a:a/2;o&&((i={opacity:0})[h]=(m?"-=":"+=")+a,c.animate(i,d,p)),c.queue(t),l.effects.unshift(c,e,1+r)})});
|
||||
+67
-67
@@ -1,67 +1,67 @@
|
||||
/*!
|
||||
* jQuery UI Effects Clip 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Clip Effect
|
||||
//>>group: Effects
|
||||
//>>description: Clips the element on and off like an old TV.
|
||||
//>>docs: http://api.jqueryui.com/clip-effect/
|
||||
//>>demos: http://jqueryui.com/effect/
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"./effect"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
return $.effects.define( "clip", "hide", function( options, done ) {
|
||||
var start,
|
||||
animate = {},
|
||||
element = $( this ),
|
||||
direction = options.direction || "vertical",
|
||||
both = direction === "both",
|
||||
horizontal = both || direction === "horizontal",
|
||||
vertical = both || direction === "vertical";
|
||||
|
||||
start = element.cssClip();
|
||||
animate.clip = {
|
||||
top: vertical ? ( start.bottom - start.top ) / 2 : start.top,
|
||||
right: horizontal ? ( start.right - start.left ) / 2 : start.right,
|
||||
bottom: vertical ? ( start.bottom - start.top ) / 2 : start.bottom,
|
||||
left: horizontal ? ( start.right - start.left ) / 2 : start.left
|
||||
};
|
||||
|
||||
$.effects.createPlaceholder( element );
|
||||
|
||||
if ( options.mode === "show" ) {
|
||||
element.cssClip( animate.clip );
|
||||
animate.clip = start;
|
||||
}
|
||||
|
||||
element.animate( animate, {
|
||||
queue: false,
|
||||
duration: options.duration,
|
||||
easing: options.easing,
|
||||
complete: done
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
} );
|
||||
/*!
|
||||
* jQuery UI Effects Clip 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Clip Effect
|
||||
//>>group: Effects
|
||||
//>>description: Clips the element on and off like an old TV.
|
||||
//>>docs: http://api.jqueryui.com/clip-effect/
|
||||
//>>demos: http://jqueryui.com/effect/
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"./effect"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
return $.effects.define( "clip", "hide", function( options, done ) {
|
||||
var start,
|
||||
animate = {},
|
||||
element = $( this ),
|
||||
direction = options.direction || "vertical",
|
||||
both = direction === "both",
|
||||
horizontal = both || direction === "horizontal",
|
||||
vertical = both || direction === "vertical";
|
||||
|
||||
start = element.cssClip();
|
||||
animate.clip = {
|
||||
top: vertical ? ( start.bottom - start.top ) / 2 : start.top,
|
||||
right: horizontal ? ( start.right - start.left ) / 2 : start.right,
|
||||
bottom: vertical ? ( start.bottom - start.top ) / 2 : start.bottom,
|
||||
left: horizontal ? ( start.right - start.left ) / 2 : start.left
|
||||
};
|
||||
|
||||
$.effects.createPlaceholder( element );
|
||||
|
||||
if ( options.mode === "show" ) {
|
||||
element.cssClip( animate.clip );
|
||||
animate.clip = start;
|
||||
}
|
||||
|
||||
element.animate( animate, {
|
||||
queue: false,
|
||||
duration: options.duration,
|
||||
easing: options.easing,
|
||||
complete: done
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
+8
-8
@@ -1,9 +1,9 @@
|
||||
/*!
|
||||
* jQuery UI Effects Clip 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
/*!
|
||||
* jQuery UI Effects Clip 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery","./effect"],t):t(jQuery)}(function(r){"use strict";return r.effects.define("clip","hide",function(t,e){var i={},o=r(this),c=t.direction||"vertical",n="both"===c,f=n||"horizontal"===c,n=n||"vertical"===c,c=o.cssClip();i.clip={top:n?(c.bottom-c.top)/2:c.top,right:f?(c.right-c.left)/2:c.right,bottom:n?(c.bottom-c.top)/2:c.bottom,left:f?(c.right-c.left)/2:c.left},r.effects.createPlaceholder(o),"show"===t.mode&&(o.cssClip(i.clip),i.clip=c),o.animate(i,{queue:!1,duration:t.duration,easing:t.easing,complete:e})})});
|
||||
+71
-71
@@ -1,71 +1,71 @@
|
||||
/*!
|
||||
* jQuery UI Effects Drop 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Drop Effect
|
||||
//>>group: Effects
|
||||
//>>description: Moves an element in one direction and hides it at the same time.
|
||||
//>>docs: http://api.jqueryui.com/drop-effect/
|
||||
//>>demos: http://jqueryui.com/effect/
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"./effect"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
return $.effects.define( "drop", "hide", function( options, done ) {
|
||||
|
||||
var distance,
|
||||
element = $( this ),
|
||||
mode = options.mode,
|
||||
show = mode === "show",
|
||||
direction = options.direction || "left",
|
||||
ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
|
||||
motion = ( direction === "up" || direction === "left" ) ? "-=" : "+=",
|
||||
oppositeMotion = ( motion === "+=" ) ? "-=" : "+=",
|
||||
animation = {
|
||||
opacity: 0
|
||||
};
|
||||
|
||||
$.effects.createPlaceholder( element );
|
||||
|
||||
distance = options.distance ||
|
||||
element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
|
||||
|
||||
animation[ ref ] = motion + distance;
|
||||
|
||||
if ( show ) {
|
||||
element.css( animation );
|
||||
|
||||
animation[ ref ] = oppositeMotion + distance;
|
||||
animation.opacity = 1;
|
||||
}
|
||||
|
||||
// Animate
|
||||
element.animate( animation, {
|
||||
queue: false,
|
||||
duration: options.duration,
|
||||
easing: options.easing,
|
||||
complete: done
|
||||
} );
|
||||
} );
|
||||
|
||||
} );
|
||||
/*!
|
||||
* jQuery UI Effects Drop 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Drop Effect
|
||||
//>>group: Effects
|
||||
//>>description: Moves an element in one direction and hides it at the same time.
|
||||
//>>docs: http://api.jqueryui.com/drop-effect/
|
||||
//>>demos: http://jqueryui.com/effect/
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"./effect"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
return $.effects.define( "drop", "hide", function( options, done ) {
|
||||
|
||||
var distance,
|
||||
element = $( this ),
|
||||
mode = options.mode,
|
||||
show = mode === "show",
|
||||
direction = options.direction || "left",
|
||||
ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
|
||||
motion = ( direction === "up" || direction === "left" ) ? "-=" : "+=",
|
||||
oppositeMotion = ( motion === "+=" ) ? "-=" : "+=",
|
||||
animation = {
|
||||
opacity: 0
|
||||
};
|
||||
|
||||
$.effects.createPlaceholder( element );
|
||||
|
||||
distance = options.distance ||
|
||||
element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
|
||||
|
||||
animation[ ref ] = motion + distance;
|
||||
|
||||
if ( show ) {
|
||||
element.css( animation );
|
||||
|
||||
animation[ ref ] = oppositeMotion + distance;
|
||||
animation.opacity = 1;
|
||||
}
|
||||
|
||||
// Animate
|
||||
element.animate( animation, {
|
||||
queue: false,
|
||||
duration: options.duration,
|
||||
easing: options.easing,
|
||||
complete: done
|
||||
} );
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
+8
-8
@@ -1,9 +1,9 @@
|
||||
/*!
|
||||
* jQuery UI Effects Drop 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
/*!
|
||||
* jQuery UI Effects Drop 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery","./effect"],e):e(jQuery)}(function(r){"use strict";return r.effects.define("drop","hide",function(e,t){var i,n=r(this),o="show"===e.mode,f=e.direction||"left",c="up"===f||"down"===f?"top":"left",f="up"===f||"left"===f?"-=":"+=",u="+="==f?"-=":"+=",d={opacity:0};r.effects.createPlaceholder(n),i=e.distance||n["top"==c?"outerHeight":"outerWidth"](!0)/2,d[c]=f+i,o&&(n.css(d),d[c]=u+i,d.opacity=1),n.animate(d,{queue:!1,duration:e.duration,easing:e.easing,complete:t})})});
|
||||
+113
-113
@@ -1,113 +1,113 @@
|
||||
/*!
|
||||
* jQuery UI Effects Explode 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Explode Effect
|
||||
//>>group: Effects
|
||||
/* eslint-disable max-len */
|
||||
//>>description: Explodes an element in all directions into n pieces. Implodes an element to its original wholeness.
|
||||
/* eslint-enable max-len */
|
||||
//>>docs: http://api.jqueryui.com/explode-effect/
|
||||
//>>demos: http://jqueryui.com/effect/
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"./effect"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
return $.effects.define( "explode", "hide", function( options, done ) {
|
||||
|
||||
var i, j, left, top, mx, my,
|
||||
rows = options.pieces ? Math.round( Math.sqrt( options.pieces ) ) : 3,
|
||||
cells = rows,
|
||||
element = $( this ),
|
||||
mode = options.mode,
|
||||
show = mode === "show",
|
||||
|
||||
// Show and then visibility:hidden the element before calculating offset
|
||||
offset = element.show().css( "visibility", "hidden" ).offset(),
|
||||
|
||||
// Width and height of a piece
|
||||
width = Math.ceil( element.outerWidth() / cells ),
|
||||
height = Math.ceil( element.outerHeight() / rows ),
|
||||
pieces = [];
|
||||
|
||||
// Children animate complete:
|
||||
function childComplete() {
|
||||
pieces.push( this );
|
||||
if ( pieces.length === rows * cells ) {
|
||||
animComplete();
|
||||
}
|
||||
}
|
||||
|
||||
// Clone the element for each row and cell.
|
||||
for ( i = 0; i < rows; i++ ) { // ===>
|
||||
top = offset.top + i * height;
|
||||
my = i - ( rows - 1 ) / 2;
|
||||
|
||||
for ( j = 0; j < cells; j++ ) { // |||
|
||||
left = offset.left + j * width;
|
||||
mx = j - ( cells - 1 ) / 2;
|
||||
|
||||
// Create a clone of the now hidden main element that will be absolute positioned
|
||||
// within a wrapper div off the -left and -top equal to size of our pieces
|
||||
element
|
||||
.clone()
|
||||
.appendTo( "body" )
|
||||
.wrap( "<div></div>" )
|
||||
.css( {
|
||||
position: "absolute",
|
||||
visibility: "visible",
|
||||
left: -j * width,
|
||||
top: -i * height
|
||||
} )
|
||||
|
||||
// Select the wrapper - make it overflow: hidden and absolute positioned based on
|
||||
// where the original was located +left and +top equal to the size of pieces
|
||||
.parent()
|
||||
.addClass( "ui-effects-explode" )
|
||||
.css( {
|
||||
position: "absolute",
|
||||
overflow: "hidden",
|
||||
width: width,
|
||||
height: height,
|
||||
left: left + ( show ? mx * width : 0 ),
|
||||
top: top + ( show ? my * height : 0 ),
|
||||
opacity: show ? 0 : 1
|
||||
} )
|
||||
.animate( {
|
||||
left: left + ( show ? 0 : mx * width ),
|
||||
top: top + ( show ? 0 : my * height ),
|
||||
opacity: show ? 1 : 0
|
||||
}, options.duration || 500, options.easing, childComplete );
|
||||
}
|
||||
}
|
||||
|
||||
function animComplete() {
|
||||
element.css( {
|
||||
visibility: "visible"
|
||||
} );
|
||||
$( pieces ).remove();
|
||||
done();
|
||||
}
|
||||
} );
|
||||
|
||||
} );
|
||||
/*!
|
||||
* jQuery UI Effects Explode 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Explode Effect
|
||||
//>>group: Effects
|
||||
/* eslint-disable max-len */
|
||||
//>>description: Explodes an element in all directions into n pieces. Implodes an element to its original wholeness.
|
||||
/* eslint-enable max-len */
|
||||
//>>docs: http://api.jqueryui.com/explode-effect/
|
||||
//>>demos: http://jqueryui.com/effect/
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"./effect"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
return $.effects.define( "explode", "hide", function( options, done ) {
|
||||
|
||||
var i, j, left, top, mx, my,
|
||||
rows = options.pieces ? Math.round( Math.sqrt( options.pieces ) ) : 3,
|
||||
cells = rows,
|
||||
element = $( this ),
|
||||
mode = options.mode,
|
||||
show = mode === "show",
|
||||
|
||||
// Show and then visibility:hidden the element before calculating offset
|
||||
offset = element.show().css( "visibility", "hidden" ).offset(),
|
||||
|
||||
// Width and height of a piece
|
||||
width = Math.ceil( element.outerWidth() / cells ),
|
||||
height = Math.ceil( element.outerHeight() / rows ),
|
||||
pieces = [];
|
||||
|
||||
// Children animate complete:
|
||||
function childComplete() {
|
||||
pieces.push( this );
|
||||
if ( pieces.length === rows * cells ) {
|
||||
animComplete();
|
||||
}
|
||||
}
|
||||
|
||||
// Clone the element for each row and cell.
|
||||
for ( i = 0; i < rows; i++ ) { // ===>
|
||||
top = offset.top + i * height;
|
||||
my = i - ( rows - 1 ) / 2;
|
||||
|
||||
for ( j = 0; j < cells; j++ ) { // |||
|
||||
left = offset.left + j * width;
|
||||
mx = j - ( cells - 1 ) / 2;
|
||||
|
||||
// Create a clone of the now hidden main element that will be absolute positioned
|
||||
// within a wrapper div off the -left and -top equal to size of our pieces
|
||||
element
|
||||
.clone()
|
||||
.appendTo( "body" )
|
||||
.wrap( "<div></div>" )
|
||||
.css( {
|
||||
position: "absolute",
|
||||
visibility: "visible",
|
||||
left: -j * width,
|
||||
top: -i * height
|
||||
} )
|
||||
|
||||
// Select the wrapper - make it overflow: hidden and absolute positioned based on
|
||||
// where the original was located +left and +top equal to the size of pieces
|
||||
.parent()
|
||||
.addClass( "ui-effects-explode" )
|
||||
.css( {
|
||||
position: "absolute",
|
||||
overflow: "hidden",
|
||||
width: width,
|
||||
height: height,
|
||||
left: left + ( show ? mx * width : 0 ),
|
||||
top: top + ( show ? my * height : 0 ),
|
||||
opacity: show ? 0 : 1
|
||||
} )
|
||||
.animate( {
|
||||
left: left + ( show ? 0 : mx * width ),
|
||||
top: top + ( show ? 0 : my * height ),
|
||||
opacity: show ? 1 : 0
|
||||
}, options.duration || 500, options.easing, childComplete );
|
||||
}
|
||||
}
|
||||
|
||||
function animComplete() {
|
||||
element.css( {
|
||||
visibility: "visible"
|
||||
} );
|
||||
$( pieces ).remove();
|
||||
done();
|
||||
}
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*!
|
||||
* jQuery UI Effects Explode 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
/*!
|
||||
* jQuery UI Effects Explode 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery","./effect"],e):e(jQuery)}(function(b){"use strict";return b.effects.define("explode","hide",function(e,i){var t,o,s,n,f,d,c=e.pieces?Math.round(Math.sqrt(e.pieces)):3,a=c,l=b(this),h="show"===e.mode,p=l.show().css("visibility","hidden").offset(),r=Math.ceil(l.outerWidth()/a),u=Math.ceil(l.outerHeight()/c),v=[];function y(){v.push(this),v.length===c*a&&(l.css({visibility:"visible"}),b(v).remove(),i())}for(t=0;t<c;t++)for(n=p.top+t*u,d=t-(c-1)/2,o=0;o<a;o++)s=p.left+o*r,f=o-(a-1)/2,l.clone().appendTo("body").wrap("<div></div>").css({position:"absolute",visibility:"visible",left:-o*r,top:-t*u}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:r,height:u,left:s+(h?f*r:0),top:n+(h?d*u:0),opacity:h?0:1}).animate({left:s+(h?0:f*r),top:n+(h?0:d*u),opacity:h?1:0},e.duration||500,e.easing,y)})});
|
||||
+49
-49
@@ -1,49 +1,49 @@
|
||||
/*!
|
||||
* jQuery UI Effects Fade 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Fade Effect
|
||||
//>>group: Effects
|
||||
//>>description: Fades the element.
|
||||
//>>docs: http://api.jqueryui.com/fade-effect/
|
||||
//>>demos: http://jqueryui.com/effect/
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"./effect"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
return $.effects.define( "fade", "toggle", function( options, done ) {
|
||||
var show = options.mode === "show";
|
||||
|
||||
$( this )
|
||||
.css( "opacity", show ? 0 : 1 )
|
||||
.animate( {
|
||||
opacity: show ? 1 : 0
|
||||
}, {
|
||||
queue: false,
|
||||
duration: options.duration,
|
||||
easing: options.easing,
|
||||
complete: done
|
||||
} );
|
||||
} );
|
||||
|
||||
} );
|
||||
/*!
|
||||
* jQuery UI Effects Fade 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Fade Effect
|
||||
//>>group: Effects
|
||||
//>>description: Fades the element.
|
||||
//>>docs: http://api.jqueryui.com/fade-effect/
|
||||
//>>demos: http://jqueryui.com/effect/
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"./effect"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
return $.effects.define( "fade", "toggle", function( options, done ) {
|
||||
var show = options.mode === "show";
|
||||
|
||||
$( this )
|
||||
.css( "opacity", show ? 0 : 1 )
|
||||
.animate( {
|
||||
opacity: show ? 1 : 0
|
||||
}, {
|
||||
queue: false,
|
||||
duration: options.duration,
|
||||
easing: options.easing,
|
||||
complete: done
|
||||
} );
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
+8
-8
@@ -1,9 +1,9 @@
|
||||
/*!
|
||||
* jQuery UI Effects Fade 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
/*!
|
||||
* jQuery UI Effects Fade 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery","./effect"],e):e(jQuery)}(function(n){"use strict";return n.effects.define("fade","toggle",function(e,t){var i="show"===e.mode;n(this).css("opacity",i?0:1).animate({opacity:i?1:0},{queue:!1,duration:e.duration,easing:e.easing,complete:t})})});
|
||||
+91
-91
@@ -1,91 +1,91 @@
|
||||
/*!
|
||||
* jQuery UI Effects Fold 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Fold Effect
|
||||
//>>group: Effects
|
||||
//>>description: Folds an element first horizontally and then vertically.
|
||||
//>>docs: http://api.jqueryui.com/fold-effect/
|
||||
//>>demos: http://jqueryui.com/effect/
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"./effect"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
return $.effects.define( "fold", "hide", function( options, done ) {
|
||||
|
||||
// Create element
|
||||
var element = $( this ),
|
||||
mode = options.mode,
|
||||
show = mode === "show",
|
||||
hide = mode === "hide",
|
||||
size = options.size || 15,
|
||||
percent = /([0-9]+)%/.exec( size ),
|
||||
horizFirst = !!options.horizFirst,
|
||||
ref = horizFirst ? [ "right", "bottom" ] : [ "bottom", "right" ],
|
||||
duration = options.duration / 2,
|
||||
|
||||
placeholder = $.effects.createPlaceholder( element ),
|
||||
|
||||
start = element.cssClip(),
|
||||
animation1 = { clip: $.extend( {}, start ) },
|
||||
animation2 = { clip: $.extend( {}, start ) },
|
||||
|
||||
distance = [ start[ ref[ 0 ] ], start[ ref[ 1 ] ] ],
|
||||
|
||||
queuelen = element.queue().length;
|
||||
|
||||
if ( percent ) {
|
||||
size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
|
||||
}
|
||||
animation1.clip[ ref[ 0 ] ] = size;
|
||||
animation2.clip[ ref[ 0 ] ] = size;
|
||||
animation2.clip[ ref[ 1 ] ] = 0;
|
||||
|
||||
if ( show ) {
|
||||
element.cssClip( animation2.clip );
|
||||
if ( placeholder ) {
|
||||
placeholder.css( $.effects.clipToBox( animation2 ) );
|
||||
}
|
||||
|
||||
animation2.clip = start;
|
||||
}
|
||||
|
||||
// Animate
|
||||
element
|
||||
.queue( function( next ) {
|
||||
if ( placeholder ) {
|
||||
placeholder
|
||||
.animate( $.effects.clipToBox( animation1 ), duration, options.easing )
|
||||
.animate( $.effects.clipToBox( animation2 ), duration, options.easing );
|
||||
}
|
||||
|
||||
next();
|
||||
} )
|
||||
.animate( animation1, duration, options.easing )
|
||||
.animate( animation2, duration, options.easing )
|
||||
.queue( done );
|
||||
|
||||
$.effects.unshift( element, queuelen, 4 );
|
||||
} );
|
||||
|
||||
} );
|
||||
/*!
|
||||
* jQuery UI Effects Fold 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Fold Effect
|
||||
//>>group: Effects
|
||||
//>>description: Folds an element first horizontally and then vertically.
|
||||
//>>docs: http://api.jqueryui.com/fold-effect/
|
||||
//>>demos: http://jqueryui.com/effect/
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"./effect"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
return $.effects.define( "fold", "hide", function( options, done ) {
|
||||
|
||||
// Create element
|
||||
var element = $( this ),
|
||||
mode = options.mode,
|
||||
show = mode === "show",
|
||||
hide = mode === "hide",
|
||||
size = options.size || 15,
|
||||
percent = /([0-9]+)%/.exec( size ),
|
||||
horizFirst = !!options.horizFirst,
|
||||
ref = horizFirst ? [ "right", "bottom" ] : [ "bottom", "right" ],
|
||||
duration = options.duration / 2,
|
||||
|
||||
placeholder = $.effects.createPlaceholder( element ),
|
||||
|
||||
start = element.cssClip(),
|
||||
animation1 = { clip: $.extend( {}, start ) },
|
||||
animation2 = { clip: $.extend( {}, start ) },
|
||||
|
||||
distance = [ start[ ref[ 0 ] ], start[ ref[ 1 ] ] ],
|
||||
|
||||
queuelen = element.queue().length;
|
||||
|
||||
if ( percent ) {
|
||||
size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
|
||||
}
|
||||
animation1.clip[ ref[ 0 ] ] = size;
|
||||
animation2.clip[ ref[ 0 ] ] = size;
|
||||
animation2.clip[ ref[ 1 ] ] = 0;
|
||||
|
||||
if ( show ) {
|
||||
element.cssClip( animation2.clip );
|
||||
if ( placeholder ) {
|
||||
placeholder.css( $.effects.clipToBox( animation2 ) );
|
||||
}
|
||||
|
||||
animation2.clip = start;
|
||||
}
|
||||
|
||||
// Animate
|
||||
element
|
||||
.queue( function( next ) {
|
||||
if ( placeholder ) {
|
||||
placeholder
|
||||
.animate( $.effects.clipToBox( animation1 ), duration, options.easing )
|
||||
.animate( $.effects.clipToBox( animation2 ), duration, options.easing );
|
||||
}
|
||||
|
||||
next();
|
||||
} )
|
||||
.animate( animation1, duration, options.easing )
|
||||
.animate( animation2, duration, options.easing )
|
||||
.queue( done );
|
||||
|
||||
$.effects.unshift( element, queuelen, 4 );
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
+8
-8
@@ -1,9 +1,9 @@
|
||||
/*!
|
||||
* jQuery UI Effects Fold 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
/*!
|
||||
* jQuery UI Effects Fold 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery","./effect"],e):e(jQuery)}(function(m){"use strict";return m.effects.define("fold","hide",function(i,e){var t=m(this),c=i.mode,n="show"===c,c="hide"===c,f=i.size||15,s=/([0-9]+)%/.exec(f),o=!!i.horizFirst?["right","bottom"]:["bottom","right"],a=i.duration/2,u=m.effects.createPlaceholder(t),l=t.cssClip(),r={clip:m.extend({},l)},p={clip:m.extend({},l)},d=[l[o[0]],l[o[1]]],h=t.queue().length;s&&(f=parseInt(s[1],10)/100*d[c?0:1]),r.clip[o[0]]=f,p.clip[o[0]]=f,p.clip[o[1]]=0,n&&(t.cssClip(p.clip),u&&u.css(m.effects.clipToBox(p)),p.clip=l),t.queue(function(e){u&&u.animate(m.effects.clipToBox(r),a,i.easing).animate(m.effects.clipToBox(p),a,i.easing),e()}).animate(r,a,i.easing).animate(p,a,i.easing).queue(e),m.effects.unshift(t,h,4)})});
|
||||
+59
-59
@@ -1,59 +1,59 @@
|
||||
/*!
|
||||
* jQuery UI Effects Highlight 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Highlight Effect
|
||||
//>>group: Effects
|
||||
//>>description: Highlights the background of an element in a defined color for a custom duration.
|
||||
//>>docs: http://api.jqueryui.com/highlight-effect/
|
||||
//>>demos: http://jqueryui.com/effect/
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"./effect"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
return $.effects.define( "highlight", "show", function( options, done ) {
|
||||
var element = $( this ),
|
||||
animation = {
|
||||
backgroundColor: element.css( "backgroundColor" )
|
||||
};
|
||||
|
||||
if ( options.mode === "hide" ) {
|
||||
animation.opacity = 0;
|
||||
}
|
||||
|
||||
$.effects.saveStyle( element );
|
||||
|
||||
element
|
||||
.css( {
|
||||
backgroundImage: "none",
|
||||
backgroundColor: options.color || "#ffff99"
|
||||
} )
|
||||
.animate( animation, {
|
||||
queue: false,
|
||||
duration: options.duration,
|
||||
easing: options.easing,
|
||||
complete: done
|
||||
} );
|
||||
} );
|
||||
|
||||
} );
|
||||
/*!
|
||||
* jQuery UI Effects Highlight 1.13.2
|
||||
* http://jqueryui.com
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license.
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
//>>label: Highlight Effect
|
||||
//>>group: Effects
|
||||
//>>description: Highlights the background of an element in a defined color for a custom duration.
|
||||
//>>docs: http://api.jqueryui.com/highlight-effect/
|
||||
//>>demos: http://jqueryui.com/effect/
|
||||
|
||||
( function( factory ) {
|
||||
"use strict";
|
||||
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD. Register as an anonymous module.
|
||||
define( [
|
||||
"jquery",
|
||||
"./effect"
|
||||
], factory );
|
||||
} else {
|
||||
|
||||
// Browser globals
|
||||
factory( jQuery );
|
||||
}
|
||||
} )( function( $ ) {
|
||||
"use strict";
|
||||
|
||||
return $.effects.define( "highlight", "show", function( options, done ) {
|
||||
var element = $( this ),
|
||||
animation = {
|
||||
backgroundColor: element.css( "backgroundColor" )
|
||||
};
|
||||
|
||||
if ( options.mode === "hide" ) {
|
||||
animation.opacity = 0;
|
||||
}
|
||||
|
||||
$.effects.saveStyle( element );
|
||||
|
||||
element
|
||||
.css( {
|
||||
backgroundImage: "none",
|
||||
backgroundColor: options.color || "#ffff99"
|
||||
} )
|
||||
.animate( animation, {
|
||||
queue: false,
|
||||
duration: options.duration,
|
||||
easing: options.easing,
|
||||
complete: done
|
||||
} );
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user