mirror of
git://develop.git.wordpress.org/
synced 2025-01-16 20:38:35 +01:00
Docs: Improve inline comments per the documentation standards.
Includes minor code layout fixes for better readability. See #48303. git-svn-id: https://develop.svn.wordpress.org/trunk@47122 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
bd2cd572aa
commit
cfc3b57488
76
Gruntfile.js
76
Gruntfile.js
@ -43,7 +43,7 @@ module.exports = function(grunt) {
|
||||
|
||||
// Load tasks.
|
||||
require('matchdep').filterDev(['grunt-*', '!grunt-legacy-util']).forEach( grunt.loadNpmTasks );
|
||||
// Load legacy utils
|
||||
// Load legacy utils.
|
||||
grunt.util = require('grunt-legacy-util');
|
||||
|
||||
// Project configuration.
|
||||
@ -144,7 +144,7 @@ module.exports = function(grunt) {
|
||||
'!assets/**', // Assets is extracted into separate copy tasks.
|
||||
'!js/**', // JavaScript is extracted into separate copy tasks.
|
||||
'!.{svn,git}', // Exclude version control folders.
|
||||
'!wp-includes/version.php', // Exclude version.php
|
||||
'!wp-includes/version.php', // Exclude version.php.
|
||||
'!**/*.map', // The build doesn't need .map files.
|
||||
'!index.php', '!wp-admin/index.php',
|
||||
'!_index.php', '!wp-admin/_index.php'
|
||||
@ -168,7 +168,7 @@ module.exports = function(grunt) {
|
||||
[ WORKING_DIR + 'wp-includes/js/clipboard.js' ]: [ './node_modules/clipboard/dist/clipboard.js' ],
|
||||
[ WORKING_DIR + 'wp-includes/js/hoverIntent.js' ]: [ './node_modules/jquery-hoverintent/jquery.hoverIntent.js' ],
|
||||
|
||||
// Renamed to avoid conflict with jQuery hoverIntent.min.js (after minifying)
|
||||
// Renamed to avoid conflict with jQuery hoverIntent.min.js (after minifying).
|
||||
[ WORKING_DIR + 'wp-includes/js/hoverintent-js.min.js' ]: [ './node_modules/hoverintent/dist/hoverintent.min.js' ],
|
||||
[ WORKING_DIR + 'wp-includes/js/imagesloaded.min.js' ]: [ './node_modules/imagesloaded/imagesloaded.pkgd.min.js' ],
|
||||
[ WORKING_DIR + 'wp-includes/js/jquery/jquery-migrate.js' ]: [ './node_modules/jquery-migrate/dist/jquery-migrate.js' ],
|
||||
@ -448,7 +448,7 @@ module.exports = function(grunt) {
|
||||
},
|
||||
rtlcss: {
|
||||
options: {
|
||||
// rtlcss options
|
||||
// rtlcss options.
|
||||
opts: {
|
||||
clean: false,
|
||||
processUrls: { atrule: true, decl: false },
|
||||
@ -516,7 +516,7 @@ module.exports = function(grunt) {
|
||||
'!wp-includes/css/*.min.css',
|
||||
'!wp-includes/css/dist',
|
||||
|
||||
// Exceptions
|
||||
// Exceptions.
|
||||
'!wp-includes/css/dashicons.css',
|
||||
'!wp-includes/css/wp-embed-template.css',
|
||||
'!wp-includes/css/wp-embed-template-ie.css'
|
||||
@ -558,7 +558,7 @@ module.exports = function(grunt) {
|
||||
src: [
|
||||
'twenty*/**/*.js',
|
||||
'!twenty{eleven,twelve,thirteen}/**',
|
||||
// Third party scripts
|
||||
// Third party scripts.
|
||||
'!twenty{fourteen,fifteen,sixteen}/js/html5.js',
|
||||
'!twentyseventeen/assets/js/html5.js',
|
||||
'!twentyseventeen/assets/js/jquery.scrollTo.js',
|
||||
@ -575,35 +575,36 @@ module.exports = function(grunt) {
|
||||
cwd: SOURCE_DIR,
|
||||
src: [
|
||||
'js/_enqueues/**/*.js',
|
||||
// Third party scripts
|
||||
// Third party scripts.
|
||||
'!js/_enqueues/vendor/**/*.js'
|
||||
],
|
||||
// Remove once other JSHint errors are resolved
|
||||
// Remove once other JSHint errors are resolved.
|
||||
options: {
|
||||
curly: false,
|
||||
eqeqeq: false
|
||||
},
|
||||
// Limit JSHint's run to a single specified file:
|
||||
//
|
||||
// grunt jshint:core --file=filename.js
|
||||
//
|
||||
// Optionally, include the file path:
|
||||
//
|
||||
// grunt jshint:core --file=path/to/filename.js
|
||||
//
|
||||
/*
|
||||
* Limit JSHint's run to a single specified file:
|
||||
*
|
||||
* grunt jshint:core --file=filename.js
|
||||
*
|
||||
* Optionally, include the file path:
|
||||
*
|
||||
* grunt jshint:core --file=path/to/filename.js
|
||||
*/
|
||||
filter: function( filepath ) {
|
||||
var index, file = grunt.option( 'file' );
|
||||
|
||||
// Don't filter when no target file is specified
|
||||
// Don't filter when no target file is specified.
|
||||
if ( ! file ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Normalize filepath for Windows
|
||||
// Normalize filepath for Windows.
|
||||
filepath = filepath.replace( /\\/g, '/' );
|
||||
index = filepath.lastIndexOf( '/' + file );
|
||||
|
||||
// Match only the filename passed from cli
|
||||
// Match only the filename passed from cli.
|
||||
if ( filepath === file || ( -1 !== index && index === filepath.length - ( file.length + 1 ) ) ) {
|
||||
return true;
|
||||
}
|
||||
@ -618,14 +619,15 @@ module.exports = function(grunt) {
|
||||
'**/*.js',
|
||||
'!**/*.min.js'
|
||||
],
|
||||
// Limit JSHint's run to a single specified plugin directory:
|
||||
//
|
||||
// grunt jshint:plugins --dir=foldername
|
||||
//
|
||||
/*
|
||||
* Limit JSHint's run to a single specified plugin directory:
|
||||
*
|
||||
* grunt jshint:plugins --dir=foldername
|
||||
*/
|
||||
filter: function( dirpath ) {
|
||||
var index, dir = grunt.option( 'dir' );
|
||||
|
||||
// Don't filter when no target folder is specified
|
||||
// Don't filter when no target folder is specified.
|
||||
if ( ! dir ) {
|
||||
return true;
|
||||
}
|
||||
@ -633,7 +635,7 @@ module.exports = function(grunt) {
|
||||
dirpath = dirpath.replace( /\\/g, '/' );
|
||||
index = dirpath.lastIndexOf( '/' + dir );
|
||||
|
||||
// Match only the folder name passed from cli
|
||||
// Match only the folder name passed from cli.
|
||||
if ( -1 !== index ) {
|
||||
return true;
|
||||
}
|
||||
@ -703,12 +705,12 @@ module.exports = function(grunt) {
|
||||
'wp-includes/js/tinymce/plugins/wordpress/plugin.js',
|
||||
'wp-includes/js/tinymce/plugins/wp*/plugin.js',
|
||||
|
||||
// Exceptions
|
||||
// Exceptions.
|
||||
'!**/*.min.js',
|
||||
'!wp-admin/js/custom-header.js', // Why? We should minify this.
|
||||
'!wp-admin/js/farbtastic.js',
|
||||
'!wp-includes/js/swfobject.js',
|
||||
'!wp-includes/js/wp-embed.js' // We have extra options for this, see uglify:embed
|
||||
'!wp-includes/js/wp-embed.js' // We have extra options for this, see uglify:embed.
|
||||
]
|
||||
},
|
||||
embed: {
|
||||
@ -1030,7 +1032,7 @@ module.exports = function(grunt) {
|
||||
|
||||
grunt.log.writeln( 'Fetching list of Twemoji files...' );
|
||||
|
||||
// Fetch a list of the files that Twemoji supplies
|
||||
// Fetch a list of the files that Twemoji supplies.
|
||||
files = spawn( 'svn', [ 'ls', 'https://github.com/twitter/twemoji.git/trunk/assets/svg' ] );
|
||||
if ( 0 !== files.status ) {
|
||||
grunt.fatal( 'Unable to fetch Twemoji file list' );
|
||||
@ -1038,33 +1040,33 @@ module.exports = function(grunt) {
|
||||
|
||||
entities = files.stdout.toString();
|
||||
|
||||
// Tidy up the file list
|
||||
// Tidy up the file list.
|
||||
entities = entities.replace( /\.svg/g, '' );
|
||||
entities = entities.replace( /^$/g, '' );
|
||||
|
||||
// Convert the emoji entities to HTML entities
|
||||
// Convert the emoji entities to HTML entities.
|
||||
partials = entities = entities.replace( /([a-z0-9]+)/g, '&#x$1;' );
|
||||
|
||||
// Remove the hyphens between the HTML entities
|
||||
// Remove the hyphens between the HTML entities.
|
||||
entities = entities.replace( /-/g, '' );
|
||||
|
||||
// Sort the entities list by length, so the longest emoji will be found first
|
||||
// Sort the entities list by length, so the longest emoji will be found first.
|
||||
emojiArray = entities.split( '\n' ).sort( function ( a, b ) {
|
||||
return b.length - a.length;
|
||||
} );
|
||||
|
||||
// Convert the entities list to PHP array syntax
|
||||
// Convert the entities list to PHP array syntax.
|
||||
entities = '\'' + emojiArray.filter( function( val ) {
|
||||
return val.length >= 8 ? val : false ;
|
||||
} ).join( '\', \'' ) + '\'';
|
||||
|
||||
// Create a list of all characters used by the emoji list
|
||||
// Create a list of all characters used by the emoji list.
|
||||
partials = partials.replace( /-/g, '\n' );
|
||||
|
||||
// Set automatically removes duplicates
|
||||
// Set automatically removes duplicates.
|
||||
partialsSet = new Set( partials.split( '\n' ) );
|
||||
|
||||
// Convert the partials list to PHP array syntax
|
||||
// Convert the partials list to PHP array syntax.
|
||||
partials = '\'' + Array.from( partialsSet ).filter( function( val ) {
|
||||
return val.length >= 8 ? val : false ;
|
||||
} ).join( '\', \'' ) + '\'';
|
||||
@ -1158,7 +1160,7 @@ module.exports = function(grunt) {
|
||||
}
|
||||
});
|
||||
|
||||
// Allow builds to be minimal
|
||||
// Allow builds to be minimal.
|
||||
if( grunt.option( 'minimal-copy' ) ) {
|
||||
var copyFilesOptions = grunt.config.get( 'copy.files.files' );
|
||||
copyFilesOptions[0].src.push( '!wp-content/plugins/**' );
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
<rule ref="PHPCompatibilityWP"/>
|
||||
|
||||
<!-- WordPress Core currently supports PHP 5.6+ -->
|
||||
<!-- WordPress Core currently supports PHP 5.6+. -->
|
||||
<config name="testVersion" value="5.6-"/>
|
||||
|
||||
<!-- Only scan PHP files. -->
|
||||
@ -25,7 +25,7 @@
|
||||
<!-- Check up to 20 files simultaneously. -->
|
||||
<arg name="parallel" value="20"/>
|
||||
|
||||
<!-- Show sniff codes in all reports -->
|
||||
<!-- Show sniff codes in all reports. -->
|
||||
<arg value="ps"/>
|
||||
|
||||
<!-- For now, only the files in src are scanned. -->
|
||||
|
@ -20,7 +20,7 @@
|
||||
<!-- Check up to 20 files simultaneously. -->
|
||||
<arg name="parallel" value="20"/>
|
||||
|
||||
<!-- Show sniff codes in all reports -->
|
||||
<!-- Show sniff codes in all reports. -->
|
||||
<arg value="ps"/>
|
||||
|
||||
<file>.</file>
|
||||
@ -48,7 +48,7 @@
|
||||
<rule ref="WordPress.NamingConventions.ValidVariableName">
|
||||
<properties>
|
||||
<property name="customPropertiesWhitelist" type="array">
|
||||
<!-- From database structure queries -->
|
||||
<!-- From database structure queries. -->
|
||||
<element value="Collation"/>
|
||||
<element value="Column_name"/>
|
||||
<element value="Default"/>
|
||||
@ -62,14 +62,14 @@
|
||||
<element value="Null"/>
|
||||
<element value="Sub_part"/>
|
||||
<element value="Type"/>
|
||||
<!-- From plugin/theme data -->
|
||||
<!-- From plugin/theme data. -->
|
||||
<element value="authorAndUri"/>
|
||||
<element value="Name"/>
|
||||
<element value="Version"/>
|
||||
<!-- From the result of wp_xmlrpc_server::wp_getPageList() -->
|
||||
<!-- From the result of wp_xmlrpc_server::wp_getPageList(). -->
|
||||
<element value="dateCreated"/>
|
||||
|
||||
<!-- From DOMDocument -->
|
||||
<!-- From DOMDocument. -->
|
||||
<element value="childNodes"/>
|
||||
<element value="formatOutput"/>
|
||||
<element value="nodeName"/>
|
||||
@ -77,7 +77,7 @@
|
||||
<element value="parentNode"/>
|
||||
<element value="preserveWhiteSpace"/>
|
||||
<element value="textContent"/>
|
||||
<!-- From PHPMailer -->
|
||||
<!-- From PHPMailer. -->
|
||||
<element value="AltBody"/>
|
||||
<element value="Body"/>
|
||||
<element value="CharSet"/>
|
||||
@ -89,11 +89,11 @@
|
||||
<element value="MIMEHeader"/>
|
||||
<element value="Sender"/>
|
||||
<element value="Subject"/>
|
||||
<!-- From PHPUnit_Util_Getopt -->
|
||||
<!-- From PHPUnit_Util_Getopt. -->
|
||||
<element value="longOptions"/>
|
||||
<!-- From POP3 -->
|
||||
<!-- From POP3. -->
|
||||
<element value="ERROR"/>
|
||||
<!-- From ZipArchive -->
|
||||
<!-- From ZipArchive. -->
|
||||
<element value="numFiles"/>
|
||||
</property>
|
||||
</properties>
|
||||
@ -102,7 +102,7 @@
|
||||
<!-- Exclude the build folder in the current directory, as Travis puts the checkout in a build directory. -->
|
||||
<exclude-pattern type="relative">^build/*</exclude-pattern>
|
||||
|
||||
<!-- Directories and third party library exclusions -->
|
||||
<!-- Directories and third party library exclusions. -->
|
||||
<exclude-pattern>/node_modules/*</exclude-pattern>
|
||||
<exclude-pattern>/vendor/*</exclude-pattern>
|
||||
|
||||
@ -140,7 +140,7 @@
|
||||
|
||||
<exclude-pattern>/tests/phpunit/includes/speed-trap-listener\.php</exclude-pattern>
|
||||
|
||||
<!-- Test data and fixtures -->
|
||||
<!-- Test data and fixtures. -->
|
||||
<exclude-pattern>/tests/phpunit/build*</exclude-pattern>
|
||||
<exclude-pattern>/tests/phpunit/data/*</exclude-pattern>
|
||||
|
||||
@ -214,7 +214,7 @@
|
||||
<rule ref="WordPress.Files.FileName">
|
||||
<properties>
|
||||
<property name="custom_test_class_whitelist" type="array">
|
||||
<!-- Test case parent classes -->
|
||||
<!-- Test case parent classes. -->
|
||||
<element value="WP_UnitTestCase"/>
|
||||
<element value="WP_Ajax_UnitTestCase"/>
|
||||
<element value="WP_Canonical_UnitTestCase"/>
|
||||
@ -229,7 +229,7 @@
|
||||
<element value="WP_Import_UnitTestCase"/>
|
||||
<element value="Tests_Query_Conditionals"/>
|
||||
|
||||
<!-- Mock classes -->
|
||||
<!-- Mock classes. -->
|
||||
<element value="Spy_REST_Server"/>
|
||||
<element value="WP_REST_Test_Controller"/>
|
||||
<element value="WP_Image_Editor_Mock"/>
|
||||
@ -238,7 +238,7 @@
|
||||
<element value="MockAction"/>
|
||||
<element value="WP_Object_Cache"/>
|
||||
|
||||
<!-- PHPUnit helpers -->
|
||||
<!-- PHPUnit helpers. -->
|
||||
<element value="TracTickets"/>
|
||||
<element value="WP_PHPUnit_Util_Getopt"/>
|
||||
<element value="PHPUnit_Util_Test"/>
|
||||
@ -270,7 +270,7 @@
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
<!-- Assignments in while conditions are a valid method of looping over iterables -->
|
||||
<!-- Assignments in while conditions are a valid method of looping over iterables. -->
|
||||
<rule ref="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition">
|
||||
<exclude-pattern>*</exclude-pattern>
|
||||
</rule>
|
||||
@ -283,7 +283,7 @@
|
||||
<exclude-pattern>/tests/phpunit/tests/*</exclude-pattern>
|
||||
</rule>
|
||||
|
||||
<!-- Exclude some old classes that can't be renamed, as it would break back compat -->
|
||||
<!-- Exclude some old classes that can't be renamed, as it would break back compat. -->
|
||||
<rule ref="PEAR.NamingConventions.ValidClassName.Invalid">
|
||||
<exclude-pattern>/src/wp-admin/includes/class-wp-filesystem-ftpsockets\.php</exclude-pattern>
|
||||
<exclude-pattern>/src/wp-includes/class-wp-oembed\.php</exclude-pattern>
|
||||
|
@ -5,12 +5,12 @@
|
||||
beStrictAboutTestsThatDoNotTestAnything="true"
|
||||
>
|
||||
<testsuites>
|
||||
<!-- Default test suite to run all tests -->
|
||||
<!-- Default test suite to run all tests. -->
|
||||
<testsuite name="default">
|
||||
<directory suffix=".php">tests/phpunit/tests</directory>
|
||||
<exclude>tests/phpunit/tests/rest-api/rest-autosaves-controller.php</exclude>
|
||||
</testsuite>
|
||||
<!-- Sets the DOING_AUTOSAVE constant, so needs to be run last -->
|
||||
<!-- Sets the DOING_AUTOSAVE constant, so needs to be run last. -->
|
||||
<testsuite name="restapi-autosave">
|
||||
<file>tests/phpunit/tests/rest-api/rest-autosaves-controller.php</file>
|
||||
</testsuite>
|
||||
@ -44,7 +44,7 @@
|
||||
<whitelist addUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">src</directory>
|
||||
<exclude>
|
||||
<!-- Third party library exclusions -->
|
||||
<!-- Third party library exclusions. -->
|
||||
<directory suffix=".php">src/wp-includes/ID3</directory>
|
||||
<directory suffix=".php">src/wp-includes/IXR</directory>
|
||||
<directory suffix=".php">src/wp-includes/random_compat</directory>
|
||||
|
@ -29,7 +29,7 @@ require_once( ABSPATH . WPINC . '/version.php' );
|
||||
wp_check_php_mysql_versions();
|
||||
wp_load_translations_early();
|
||||
|
||||
// Die with an error message
|
||||
// Die with an error message.
|
||||
$die = sprintf(
|
||||
'<p>%s</p>',
|
||||
__( 'You are running WordPress without JavaScript and CSS files. These need to be built.' )
|
||||
|
@ -70,7 +70,7 @@ jQuery(document).ready( function($) {
|
||||
* @param {Event} event The event object.
|
||||
* @return {void}
|
||||
*/
|
||||
$timestampdiv.find('.save-timestamp').click( function( event ) { // crazyhorse - multiple ok cancels
|
||||
$timestampdiv.find('.save-timestamp').click( function( event ) { // Crazyhorse - multiple OK cancels.
|
||||
var aa = $('#aa').val(), mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(),
|
||||
newD = new Date( aa, mm - 1, jj, hh, mn );
|
||||
|
||||
|
@ -168,7 +168,7 @@ window.validateForm = function( form ) {
|
||||
.length;
|
||||
};
|
||||
|
||||
// stub for doing better warnings
|
||||
// Stub for doing better warnings.
|
||||
/**
|
||||
* Shows message pop-up notice or confirmation message.
|
||||
*
|
||||
@ -334,13 +334,13 @@ $('.contextual-help-tabs').delegate('a', 'click', function(e) {
|
||||
if ( link.is('.active a') )
|
||||
return false;
|
||||
|
||||
// Links
|
||||
// Links.
|
||||
$('.contextual-help-tabs .active').removeClass('active');
|
||||
link.parent('li').addClass('active');
|
||||
|
||||
panel = $( link.attr('href') );
|
||||
|
||||
// Panels
|
||||
// Panels.
|
||||
$('.help-tab-content').not( panel ).removeClass('active').hide();
|
||||
panel.addClass('active').show();
|
||||
});
|
||||
@ -517,7 +517,7 @@ $document.ready( function() {
|
||||
$( '#collapse-button' ).on( 'click.collapse-menu', function() {
|
||||
var viewportWidth = getViewportWidth() || 961;
|
||||
|
||||
// reset any compensation for submenus near the bottom of the screen
|
||||
// Reset any compensation for submenus near the bottom of the screen.
|
||||
$('#adminmenu div.wp-submenu').css('margin-top', '');
|
||||
|
||||
if ( viewportWidth < 960 ) {
|
||||
@ -582,12 +582,12 @@ $document.ready( function() {
|
||||
|
||||
menutop = $menuItem.offset().top;
|
||||
wintop = $window.scrollTop();
|
||||
maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar
|
||||
maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar.
|
||||
|
||||
bottomOffset = menutop + $submenu.height() + 1; // Bottom offset of the menu
|
||||
pageHeight = $wpwrap.height(); // Height of the entire page
|
||||
bottomOffset = menutop + $submenu.height() + 1; // Bottom offset of the menu.
|
||||
pageHeight = $wpwrap.height(); // Height of the entire page.
|
||||
adjustment = 60 + bottomOffset - pageHeight;
|
||||
theFold = $window.height() + wintop - 50; // The fold
|
||||
theFold = $window.height() + wintop - 50; // The fold.
|
||||
|
||||
if ( theFold < ( bottomOffset - adjustment ) ) {
|
||||
adjustment = bottomOffset - theFold;
|
||||
@ -604,8 +604,8 @@ $document.ready( function() {
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'ontouchstart' in window || /IEMobile\/[1-9]/.test(navigator.userAgent) ) { // touch screen device
|
||||
// iOS Safari works with touchstart, the rest work with click
|
||||
if ( 'ontouchstart' in window || /IEMobile\/[1-9]/.test(navigator.userAgent) ) { // Touch screen device.
|
||||
// iOS Safari works with touchstart, the rest work with click.
|
||||
mobileEvent = isIOS ? 'touchstart' : 'click';
|
||||
|
||||
/**
|
||||
@ -639,9 +639,11 @@ $document.ready( function() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Show the sub instead of following the link if:
|
||||
// - the submenu is not open
|
||||
// - the submenu is not shown inline or the menu is not folded
|
||||
/*
|
||||
* Show the sub instead of following the link if:
|
||||
* - the submenu is not open.
|
||||
* - the submenu is not shown inline or the menu is not folded.
|
||||
*/
|
||||
if ( ! $menuItem.hasClass( 'opensub' ) && ( ! $menuItem.hasClass( 'wp-menu-open' ) || $menuItem.width() < 40 ) ) {
|
||||
event.preventDefault();
|
||||
adjustSubmenu( $menuItem );
|
||||
@ -664,12 +666,12 @@ $document.ready( function() {
|
||||
$submenu = $menuItem.find( '.wp-submenu' ),
|
||||
top = parseInt( $submenu.css( 'top' ), 10 );
|
||||
|
||||
if ( isNaN( top ) || top > -5 ) { // the submenu is visible
|
||||
if ( isNaN( top ) || top > -5 ) { // The submenu is visible.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $adminmenu.data( 'wp-responsive' ) ) {
|
||||
// The menu is in responsive mode, bail
|
||||
// The menu is in responsive mode, bail.
|
||||
return;
|
||||
}
|
||||
|
||||
@ -685,7 +687,7 @@ $document.ready( function() {
|
||||
*/
|
||||
out: function(){
|
||||
if ( $adminmenu.data( 'wp-responsive' ) ) {
|
||||
// The menu is in responsive mode, bail
|
||||
// The menu is in responsive mode, bail.
|
||||
return;
|
||||
}
|
||||
|
||||
@ -705,7 +707,7 @@ $document.ready( function() {
|
||||
*/
|
||||
$adminmenu.on( 'focus.adminmenu', '.wp-submenu a', function( event ) {
|
||||
if ( $adminmenu.data( 'wp-responsive' ) ) {
|
||||
// The menu is in responsive mode, bail
|
||||
// The menu is in responsive mode, bail.
|
||||
return;
|
||||
}
|
||||
|
||||
@ -759,7 +761,7 @@ $document.ready( function() {
|
||||
$button = $( '<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>' ),
|
||||
btnText = commonL10n.dismiss || '';
|
||||
|
||||
// Ensure plain text
|
||||
// Ensure plain text.
|
||||
$button.find( '.screen-reader-text' ).text( btnText );
|
||||
$button.on( 'click.wp-dismiss-notice', function( event ) {
|
||||
event.preventDefault();
|
||||
@ -776,7 +778,7 @@ $document.ready( function() {
|
||||
|
||||
$document.on( 'wp-updates-notice-added wp-plugin-install-error wp-plugin-update-error wp-plugin-delete-error wp-theme-install-error wp-theme-delete-error', makeNoticesDismissible );
|
||||
|
||||
// Init screen meta
|
||||
// Init screen meta.
|
||||
screenMeta.init();
|
||||
|
||||
/**
|
||||
@ -902,7 +904,7 @@ $document.ready( function() {
|
||||
}
|
||||
}, '.has-row-actions' );
|
||||
|
||||
// Toggle list table rows on small screens
|
||||
// Toggle list table rows on small screens.
|
||||
$( 'tbody' ).on( 'click', '.toggle-row', function() {
|
||||
$( this ).closest( 'tr' ).toggleClass( 'is-expanded' );
|
||||
});
|
||||
@ -925,7 +927,7 @@ $document.ready( function() {
|
||||
|
||||
// After pressing escape key (keyCode: 27), the tab key should tab out of the textarea.
|
||||
if ( e.keyCode == 27 ) {
|
||||
// when pressing Escape: Opera 12 and 27 blur form fields, IE 8 clears them
|
||||
// When pressing Escape: Opera 12 and 27 blur form fields, IE 8 clears them.
|
||||
e.preventDefault();
|
||||
$(el).data('tab-out', true);
|
||||
return;
|
||||
@ -1276,7 +1278,7 @@ $document.ready( function() {
|
||||
|
||||
this.maybeDisableSortables = this.maybeDisableSortables.bind( this );
|
||||
|
||||
// Modify functionality based on custom activate/deactivate event
|
||||
// Modify functionality based on custom activate/deactivate event.
|
||||
$document.on( 'wp-responsive-activate.wp-responsive', function() {
|
||||
self.activate();
|
||||
}).on( 'wp-responsive-deactivate.wp-responsive', function() {
|
||||
@ -1289,7 +1291,7 @@ $document.ready( function() {
|
||||
$( '#wp-admin-bar-menu-toggle' ).on( 'click.wp-responsive', function( event ) {
|
||||
event.preventDefault();
|
||||
|
||||
// close any open toolbar submenus.
|
||||
// Close any open toolbar submenus.
|
||||
$adminbar.find( '.hover' ).removeClass( 'hover' );
|
||||
|
||||
$wpwrap.toggleClass( 'wp-responsive-open' );
|
||||
|
@ -192,7 +192,7 @@ var getCount, updateCount, updateCountText, updatePending, updateApproved,
|
||||
var newTitle, regExMatch, titleCount, commentFrag;
|
||||
|
||||
titleRegEx = titleRegEx || new RegExp( adminCommentsL10n.docTitleCommentsCount.replace( '%s', '\\([0-9' + thousandsSeparator + ']+\\)' ) + '?' );
|
||||
// count funcs operate on a $'d element
|
||||
// Count funcs operate on a $'d element.
|
||||
titleDiv = titleDiv || $( '<div />' );
|
||||
newTitle = adminTitle;
|
||||
|
||||
@ -256,7 +256,7 @@ var getCount, updateCount, updateCountText, updatePending, updateApproved,
|
||||
return;
|
||||
}
|
||||
|
||||
// cache selectors to not get dupes
|
||||
// Cache selectors to not get dupes.
|
||||
pending = $( 'span.' + pendingClass, postSelector );
|
||||
noPending = $( 'span.' + noClass, postSelector );
|
||||
|
||||
@ -444,7 +444,7 @@ window.setCommentsList = function() {
|
||||
|
||||
a.click(function( e ){
|
||||
e.preventDefault();
|
||||
e.stopPropagation(); // ticket #35904
|
||||
e.stopPropagation(); // Ticket #35904.
|
||||
list.wpList.del(this);
|
||||
$('#undo-' + id).css( {backgroundColor:'#ceb'} ).fadeOut(350, function(){
|
||||
$(this).remove();
|
||||
@ -491,17 +491,19 @@ window.setCommentsList = function() {
|
||||
unapproved = commentRow.hasClass( 'unapproved' ),
|
||||
spammed = commentRow.hasClass( 'spam' ),
|
||||
trashed = commentRow.hasClass( 'trash' ),
|
||||
undoing = false; // ticket #35904
|
||||
undoing = false; // Ticket #35904.
|
||||
|
||||
updateDashboardText( newTotal );
|
||||
updateInModerationText( newTotal );
|
||||
|
||||
// the order of these checks is important
|
||||
// .unspam can also have .approve or .unapprove
|
||||
// .untrash can also have .approve or .unapprove
|
||||
/*
|
||||
* The order of these checks is important.
|
||||
* .unspam can also have .approve or .unapprove.
|
||||
* .untrash can also have .approve or .unapprove.
|
||||
*/
|
||||
|
||||
if ( targetParent.is( 'span.undo' ) ) {
|
||||
// the comment was spammed
|
||||
// The comment was spammed.
|
||||
if ( targetParent.hasClass( 'unspam' ) ) {
|
||||
spamDiff = -1;
|
||||
|
||||
@ -513,7 +515,7 @@ window.setCommentsList = function() {
|
||||
pendingDiff = 1;
|
||||
}
|
||||
|
||||
// the comment was trashed
|
||||
// The comment was trashed.
|
||||
} else if ( targetParent.hasClass( 'untrash' ) ) {
|
||||
trashDiff = -1;
|
||||
|
||||
@ -528,32 +530,32 @@ window.setCommentsList = function() {
|
||||
|
||||
undoing = true;
|
||||
|
||||
// user clicked "Spam"
|
||||
// User clicked "Spam".
|
||||
} else if ( targetParent.is( 'span.spam' ) ) {
|
||||
// the comment is currently approved
|
||||
// The comment is currently approved.
|
||||
if ( approved ) {
|
||||
approvedDiff = -1;
|
||||
// the comment is currently pending
|
||||
// The comment is currently pending.
|
||||
} else if ( unapproved ) {
|
||||
pendingDiff = -1;
|
||||
// the comment was in the trash
|
||||
// The comment was in the trash.
|
||||
} else if ( trashed ) {
|
||||
trashDiff = -1;
|
||||
}
|
||||
// you can't spam an item on the spam screen
|
||||
// You can't spam an item on the Spam screen.
|
||||
spamDiff = 1;
|
||||
|
||||
// user clicked "Unspam"
|
||||
// User clicked "Unspam".
|
||||
} else if ( targetParent.is( 'span.unspam' ) ) {
|
||||
if ( approved ) {
|
||||
pendingDiff = 1;
|
||||
} else if ( unapproved ) {
|
||||
approvedDiff = 1;
|
||||
} else if ( trashed ) {
|
||||
// the comment was previously approved
|
||||
// The comment was previously approved.
|
||||
if ( targetParent.hasClass( 'approve' ) ) {
|
||||
approvedDiff = 1;
|
||||
// the comment was previously pending
|
||||
// The comment was previously pending.
|
||||
} else if ( targetParent.hasClass( 'unapprove' ) ) {
|
||||
pendingDiff = 1;
|
||||
}
|
||||
@ -565,23 +567,23 @@ window.setCommentsList = function() {
|
||||
pendingDiff = 1;
|
||||
}
|
||||
}
|
||||
// you can Unspam an item on the spam screen
|
||||
// You can unspam an item on the Spam screen.
|
||||
spamDiff = -1;
|
||||
|
||||
// user clicked "Trash"
|
||||
// User clicked "Trash".
|
||||
} else if ( targetParent.is( 'span.trash' ) ) {
|
||||
if ( approved ) {
|
||||
approvedDiff = -1;
|
||||
} else if ( unapproved ) {
|
||||
pendingDiff = -1;
|
||||
// the comment was in the spam queue
|
||||
// The comment was in the spam queue.
|
||||
} else if ( spammed ) {
|
||||
spamDiff = -1;
|
||||
}
|
||||
// you can't trash an item on the trash screen
|
||||
// You can't trash an item on the Trash screen.
|
||||
trashDiff = 1;
|
||||
|
||||
// user clicked "Restore"
|
||||
// User clicked "Restore".
|
||||
} else if ( targetParent.is( 'span.untrash' ) ) {
|
||||
if ( approved ) {
|
||||
pendingDiff = 1;
|
||||
@ -594,21 +596,21 @@ window.setCommentsList = function() {
|
||||
pendingDiff = 1;
|
||||
}
|
||||
}
|
||||
// you can't go from trash to spam
|
||||
// you can untrash on the trash screen
|
||||
// You can't go from Trash to Spam.
|
||||
// You can untrash on the Trash screen.
|
||||
trashDiff = -1;
|
||||
|
||||
// User clicked "Approve"
|
||||
// User clicked "Approve".
|
||||
} else if ( targetParent.is( 'span.approve:not(.unspam):not(.untrash)' ) ) {
|
||||
approvedDiff = 1;
|
||||
pendingDiff = -1;
|
||||
|
||||
// User clicked "Unapprove"
|
||||
// User clicked "Unapprove".
|
||||
} else if ( targetParent.is( 'span.unapprove:not(.unspam):not(.untrash)' ) ) {
|
||||
approvedDiff = -1;
|
||||
pendingDiff = 1;
|
||||
|
||||
// User clicked "Delete Permanently"
|
||||
// User clicked "Delete Permanently".
|
||||
} else if ( targetParent.is( 'span.delete' ) ) {
|
||||
if ( spammed ) {
|
||||
spamDiff = -1;
|
||||
@ -713,17 +715,17 @@ window.setCommentsList = function() {
|
||||
|
||||
if (ev) {
|
||||
theExtraList.empty();
|
||||
args.number = Math.min(8, per_page); // see WP_Comments_List_Table::prepare_items() @ class-wp-comments-list-table.php
|
||||
args.number = Math.min(8, per_page); // See WP_Comments_List_Table::prepare_items() in class-wp-comments-list-table.php.
|
||||
} else {
|
||||
args.number = 1;
|
||||
args.offset = Math.min(8, per_page) - 1; // fetch only the next item on the extra list
|
||||
args.offset = Math.min(8, per_page) - 1; // Fetch only the next item on the extra list.
|
||||
}
|
||||
|
||||
args.no_placeholder = true;
|
||||
|
||||
args.paged ++;
|
||||
|
||||
// $.query.get() needs some correction to be sent into an ajax request
|
||||
// $.query.get() needs some correction to be sent into an Ajax request.
|
||||
if ( true === args.comment_type )
|
||||
args.comment_type = '';
|
||||
|
||||
@ -781,9 +783,9 @@ window.commentReply = {
|
||||
/**
|
||||
* Initializes the comment reply functionality.
|
||||
*
|
||||
* @memberof commentReply
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @memberof commentReply
|
||||
*/
|
||||
init : function() {
|
||||
var row = $('#replyrow');
|
||||
@ -798,7 +800,7 @@ window.commentReply = {
|
||||
}
|
||||
});
|
||||
|
||||
// add events
|
||||
// Add events.
|
||||
$('#the-comment-list .column-comment > p').dblclick(function(){
|
||||
commentReply.toggle($(this).parent());
|
||||
});
|
||||
@ -911,7 +913,7 @@ window.commentReply = {
|
||||
.focus();
|
||||
}
|
||||
|
||||
// reset the Quicktags buttons
|
||||
// Reset the Quicktags buttons.
|
||||
if ( typeof QTags != 'undefined' )
|
||||
QTags.closeAllTags('replycontent');
|
||||
|
||||
@ -1029,7 +1031,7 @@ window.commentReply = {
|
||||
|
||||
$('#replycontent').focus().keyup(function(e){
|
||||
if ( e.which == 27 )
|
||||
commentReply.revert(); // close on Escape
|
||||
commentReply.revert(); // Close on Escape.
|
||||
});
|
||||
}, 600);
|
||||
|
||||
@ -1130,7 +1132,7 @@ window.commentReply = {
|
||||
updateCountText( 'span.all-count', 1 );
|
||||
}
|
||||
|
||||
c = $.trim(r.data); // Trim leading whitespaces
|
||||
c = $.trim(r.data); // Trim leading whitespaces.
|
||||
$(c).hide();
|
||||
$('#replyrow').after(c);
|
||||
|
||||
|
@ -29,41 +29,42 @@ window.wp = window.wp || {};
|
||||
/**
|
||||
* Initializes the inline and bulk post editor.
|
||||
*
|
||||
* Binds event handlers to the escape key to close the inline editor
|
||||
* Binds event handlers to the Escape key to close the inline editor
|
||||
* and to the save and close buttons. Changes DOM to be ready for inline
|
||||
* editing. Adds event handler to bulk edit.
|
||||
*
|
||||
* @memberof inlineEditPost
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @memberof inlineEditPost
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
init : function(){
|
||||
var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit');
|
||||
|
||||
t.type = $('table.widefat').hasClass('pages') ? 'page' : 'post';
|
||||
// Post id prefix.
|
||||
// Post ID prefix.
|
||||
t.what = '#post-';
|
||||
|
||||
/**
|
||||
* Binds the escape key to revert the changes and close the quick editor.
|
||||
* Binds the Escape key to revert the changes and close the quick editor.
|
||||
*
|
||||
* @return {boolean} The result of revert.
|
||||
*/
|
||||
qeRow.keyup(function(e){
|
||||
// Revert changes if escape key is pressed.
|
||||
// Revert changes if Escape key is pressed.
|
||||
if ( e.which === 27 ) {
|
||||
return inlineEditPost.revert();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Binds the escape key to revert the changes and close the bulk editor.
|
||||
* Binds the Escape key to revert the changes and close the bulk editor.
|
||||
*
|
||||
* @return {boolean} The result of revert.
|
||||
*/
|
||||
bulkRow.keyup(function(e){
|
||||
// Revert changes if escape key is pressed.
|
||||
// Revert changes if Escape key is pressed.
|
||||
if ( e.which === 27 ) {
|
||||
return inlineEditPost.revert();
|
||||
}
|
||||
@ -88,7 +89,7 @@ window.wp = window.wp || {};
|
||||
});
|
||||
|
||||
/**
|
||||
* If enter is pressed, and the target is not the cancel button, save the post.
|
||||
* If Enter is pressed, and the target is not the cancel button, save the post.
|
||||
*
|
||||
* @return {boolean} The result of save.
|
||||
*/
|
||||
@ -157,9 +158,10 @@ window.wp = window.wp || {};
|
||||
* Toggles the quick edit window, hiding it when it's active and showing it when
|
||||
* inactive.
|
||||
*
|
||||
* @memberof inlineEditPost
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @memberof inlineEditPost
|
||||
*
|
||||
* @param {Object} el Element within a post table row.
|
||||
*/
|
||||
toggle : function(el){
|
||||
@ -170,8 +172,9 @@ window.wp = window.wp || {};
|
||||
/**
|
||||
* Creates the bulk editor row to edit multiple posts at once.
|
||||
*
|
||||
* @memberof inlineEditPost
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @memberof inlineEditPost
|
||||
*/
|
||||
setBulk : function(){
|
||||
var te = '', type = this.type, c = true;
|
||||
@ -242,9 +245,10 @@ window.wp = window.wp || {};
|
||||
/**
|
||||
* Creates a quick edit window for the post that has been clicked.
|
||||
*
|
||||
* @memberof inlineEditPost
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @memberof inlineEditPost
|
||||
*
|
||||
* @param {number|Object} id The id of the clicked post or an element within a post
|
||||
* table row.
|
||||
* @return {boolean} Always returns false at the end of execution.
|
||||
@ -409,7 +413,7 @@ window.wp = window.wp || {};
|
||||
fields = $('#edit-'+id).find(':input').serialize();
|
||||
params = fields + '&' + $.param(params);
|
||||
|
||||
// Make ajax request.
|
||||
// Make Ajax request.
|
||||
$.post( ajaxurl, params,
|
||||
function(r) {
|
||||
var $errorNotice = $( '#edit-' + id + ' .inline-edit-save .notice-error' ),
|
||||
@ -450,9 +454,10 @@ window.wp = window.wp || {};
|
||||
/**
|
||||
* Hides and empties the Quick Edit and/or Bulk Edit windows.
|
||||
*
|
||||
* @memberof inlineEditPost
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @memberof inlineEditPost
|
||||
*
|
||||
* @return {boolean} Always returns false.
|
||||
*/
|
||||
revert : function(){
|
||||
@ -494,9 +499,10 @@ window.wp = window.wp || {};
|
||||
* Gets the id for a the post that you want to quick edit from the row in the quick
|
||||
* edit table.
|
||||
*
|
||||
* @memberof inlineEditPost
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @memberof inlineEditPost
|
||||
*
|
||||
* @param {Object} o DOM row object to get the id for.
|
||||
* @return {string} The post id extracted from the table row in the object.
|
||||
*/
|
||||
@ -546,7 +552,7 @@ $( document ).on( 'heartbeat-tick.wp-check-locked-posts', function( e, data ) {
|
||||
}
|
||||
}).ready( function() {
|
||||
|
||||
// Set the heartbeat interval to 15 sec.
|
||||
// Set the heartbeat interval to 15 seconds.
|
||||
if ( typeof wp !== 'undefined' && wp.heartbeat ) {
|
||||
wp.heartbeat.interval( 15 );
|
||||
}
|
||||
|
@ -43,12 +43,12 @@ window.inlineEditTax = {
|
||||
});
|
||||
|
||||
/**
|
||||
* Cancels inline editing when pressing escape inside the inline editor.
|
||||
* Cancels inline editing when pressing Escape inside the inline editor.
|
||||
*
|
||||
* @param {Object} e The keyup event that has been triggered.
|
||||
*/
|
||||
row.keyup( function( e ) {
|
||||
// 27 = [escape]
|
||||
// 27 = [Escape].
|
||||
if ( e.which === 27 ) {
|
||||
return inlineEditTax.revert();
|
||||
}
|
||||
@ -69,10 +69,10 @@ window.inlineEditTax = {
|
||||
});
|
||||
|
||||
/**
|
||||
* Saves the inline edits when pressing enter inside the inline editor.
|
||||
* Saves the inline edits when pressing Enter inside the inline editor.
|
||||
*/
|
||||
$( 'input, select', row ).keydown( function( e ) {
|
||||
// 13 = [enter]
|
||||
// 13 = [Enter].
|
||||
if ( e.which === 13 ) {
|
||||
return inlineEditTax.save( this );
|
||||
}
|
||||
@ -184,7 +184,7 @@ window.inlineEditTax = {
|
||||
fields = $('#edit-'+id).find(':input').serialize();
|
||||
params = fields + '&' + $.param(params);
|
||||
|
||||
// Do the ajax request to save the data to the server.
|
||||
// Do the Ajax request to save the data to the server.
|
||||
$.post( ajaxurl, params,
|
||||
/**
|
||||
* Handles the response from the server
|
||||
|
@ -9,7 +9,7 @@ jQuery(document).ready( function($) {
|
||||
var newCat, noSyncChecks = false, syncChecks, catAddAfter;
|
||||
|
||||
$('#link_name').focus();
|
||||
// postboxes
|
||||
// Postboxes.
|
||||
postboxes.add_postbox_toggles('link');
|
||||
|
||||
/**
|
||||
@ -33,7 +33,7 @@ jQuery(document).ready( function($) {
|
||||
if ( getUserSetting('cats') )
|
||||
$('#category-tabs a[href="#categories-pop"]').click();
|
||||
|
||||
// Ajax Cat
|
||||
// Ajax Cat.
|
||||
newCat = $('#newcat').one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ); } );
|
||||
|
||||
/**
|
||||
|
@ -43,16 +43,16 @@ window.send_to_editor = function( html ) {
|
||||
editor = tinymce.get( wpActiveEditor );
|
||||
}
|
||||
|
||||
// If the editor is set and not hidden, insert the HTML into the content of the
|
||||
// editor.
|
||||
// If the editor is set and not hidden,
|
||||
// insert the HTML into the content of the editor.
|
||||
if ( editor && ! editor.isHidden() ) {
|
||||
editor.execCommand( 'mceInsertContent', false, html );
|
||||
} else if ( hasQuicktags ) {
|
||||
// If quick tags are available, insert the HTML into its content.
|
||||
QTags.insertContent( html );
|
||||
} else {
|
||||
// If neither the TinyMCE editor and the quick tags are available, add the HTML
|
||||
// to the current active editor.
|
||||
// If neither the TinyMCE editor and the quick tags are available,
|
||||
// add the HTML to the current active editor.
|
||||
document.getElementById( wpActiveEditor ).value += html;
|
||||
}
|
||||
|
||||
|
@ -183,11 +183,12 @@ jQuery( document ).ready( function( $ ) {
|
||||
var tab = $( this ).attr( 'name' );
|
||||
event.preventDefault();
|
||||
|
||||
// Flip the tab
|
||||
// Flip the tab.
|
||||
$( '#plugin-information-tabs a.current' ).removeClass( 'current' );
|
||||
$( this ).addClass( 'current' );
|
||||
|
||||
// Only show the fyi box in the description section, on smaller screen, where it's otherwise always displayed at the top.
|
||||
// Only show the fyi box in the description section, on smaller screen,
|
||||
// where it's otherwise always displayed at the top.
|
||||
if ( 'description' !== tab && $( window ).width() < 772 ) {
|
||||
$( '#plugin-information-content' ).find( '.fyi' ).hide();
|
||||
} else {
|
||||
|
@ -91,9 +91,9 @@ window.wp = window.wp || {};
|
||||
/**
|
||||
* Load the next batch of comments.
|
||||
*
|
||||
* @param {int} total Total number of comments to load.
|
||||
*
|
||||
* @memberof commentsBox
|
||||
*
|
||||
* @param {int} total Total number of comments to load.
|
||||
*/
|
||||
load: function(total){
|
||||
this.st = jQuery('#the-comment-list tr.comment:visible').length;
|
||||
@ -309,24 +309,24 @@ jQuery(document).ready( function($) {
|
||||
|
||||
// Post locks: contain focus inside the dialog. If the dialog is shown, focus the first item.
|
||||
$('#post-lock-dialog .notification-dialog').on( 'keydown', function(e) {
|
||||
// Don't do anything when [tab] is pressed.
|
||||
// Don't do anything when [Tab] is pressed.
|
||||
if ( e.which != 9 )
|
||||
return;
|
||||
|
||||
var target = $(e.target);
|
||||
|
||||
// [shift] + [tab] on first tab cycles back to last tab.
|
||||
// [Shift] + [Tab] on first tab cycles back to last tab.
|
||||
if ( target.hasClass('wp-tab-first') && e.shiftKey ) {
|
||||
$(this).find('.wp-tab-last').focus();
|
||||
e.preventDefault();
|
||||
// [tab] on last tab cycles back to first tab.
|
||||
// [Tab] on last tab cycles back to first tab.
|
||||
} else if ( target.hasClass('wp-tab-last') && ! e.shiftKey ) {
|
||||
$(this).find('.wp-tab-first').focus();
|
||||
e.preventDefault();
|
||||
}
|
||||
}).filter(':visible').find('.wp-tab-first').focus();
|
||||
|
||||
// Set the heartbeat interval to 15 sec. if post lock dialogs are enabled.
|
||||
// Set the heartbeat interval to 15 seconds if post lock dialogs are enabled.
|
||||
if ( wp.heartbeat && $('#post-lock-dialog').length ) {
|
||||
wp.heartbeat.interval( 15 );
|
||||
}
|
||||
@ -385,7 +385,7 @@ jQuery(document).ready( function($) {
|
||||
});
|
||||
});
|
||||
|
||||
// Submit the form saving a draft or an autosave, and show a preview in a new tab
|
||||
// Submit the form saving a draft or an autosave, and show a preview in a new tab.
|
||||
$('#post-preview').on( 'click.post-preview', function( event ) {
|
||||
var $this = $(this),
|
||||
$form = $('form#post'),
|
||||
@ -534,7 +534,7 @@ jQuery(document).ready( function($) {
|
||||
});
|
||||
});
|
||||
|
||||
// Multiple Taxonomies.
|
||||
// Multiple taxonomies.
|
||||
if ( $('#tagsdiv-post_tag').length ) {
|
||||
window.tagBox && window.tagBox.init();
|
||||
} else {
|
||||
@ -559,7 +559,7 @@ jQuery(document).ready( function($) {
|
||||
settingName = 'cats';
|
||||
}
|
||||
|
||||
// TODO: move to jQuery 1.3+, support for multiple hierarchical taxonomies, see wp-lists.js
|
||||
// @todo Move to jQuery 1.3+, support for multiple hierarchical taxonomies, see wp-lists.js.
|
||||
$('a', '#' + taxonomy + '-tabs').click( function( e ) {
|
||||
e.preventDefault();
|
||||
var t = $(this).attr('href');
|
||||
@ -581,7 +581,7 @@ jQuery(document).ready( function($) {
|
||||
$( this ).val( '' ).removeClass( 'form-input-tip' );
|
||||
});
|
||||
|
||||
// On [enter] submit the taxonomy.
|
||||
// On [Enter] submit the taxonomy.
|
||||
$('#new' + taxonomy).keypress( function(event){
|
||||
if( 13 === event.keyCode ) {
|
||||
event.preventDefault();
|
||||
@ -654,7 +654,7 @@ jQuery(document).ready( function($) {
|
||||
$('#in-' + taxonomy + '-' + id + ', #in-popular-' + taxonomy + '-' + id).prop( 'checked', c );
|
||||
});
|
||||
|
||||
}); // end cats
|
||||
}); // End cats.
|
||||
|
||||
// Custom Fields postbox.
|
||||
if ( $('#postcustom').length ) {
|
||||
@ -796,7 +796,8 @@ jQuery(document).ready( function($) {
|
||||
|
||||
// Update "Status:" to currently selected status.
|
||||
$('#post-status-display').text(
|
||||
wp.sanitize.stripTagsAndEncodeText( $('option:selected', postStatus).text() ) // Remove any potential tags from post status text.
|
||||
// Remove any potential tags from post status text.
|
||||
wp.sanitize.stripTagsAndEncodeText( $('option:selected', postStatus).text() )
|
||||
);
|
||||
|
||||
// Show or hide the "Save Draft" button.
|
||||
@ -838,7 +839,7 @@ jQuery(document).ready( function($) {
|
||||
});
|
||||
|
||||
// Set the selected visibility as current.
|
||||
$postVisibilitySelect.find('.save-post-visibility').click( function( event ) { // crazyhorse - multiple ok cancels
|
||||
$postVisibilitySelect.find('.save-post-visibility').click( function( event ) { // Crazyhorse - multiple OK cancels.
|
||||
$postVisibilitySelect.slideUp('fast');
|
||||
$('#visibility .edit-visibility').show().focus();
|
||||
updateText();
|
||||
@ -886,7 +887,7 @@ jQuery(document).ready( function($) {
|
||||
});
|
||||
|
||||
// Save the changed timestamp.
|
||||
$timestampdiv.find('.save-timestamp').click( function( event ) { // crazyhorse - multiple ok cancels
|
||||
$timestampdiv.find('.save-timestamp').click( function( event ) { // Crazyhorse - multiple OK cancels.
|
||||
if ( updateText() ) {
|
||||
$timestampdiv.slideUp('fast');
|
||||
$timestampdiv.siblings('a.edit-timestamp').show().focus();
|
||||
@ -1023,12 +1024,12 @@ jQuery(document).ready( function($) {
|
||||
|
||||
$el.html( '<input type="text" id="new-post-slug" value="' + slug_value + '" autocomplete="off" />' ).children( 'input' ).keydown( function( e ) {
|
||||
var key = e.which;
|
||||
// On [enter], just save the new slug, don't save the post.
|
||||
// On [Enter], just save the new slug, don't save the post.
|
||||
if ( 13 === key ) {
|
||||
e.preventDefault();
|
||||
buttons.children( '.save' ).click();
|
||||
}
|
||||
// On [esc] cancel the editing.
|
||||
// On [Esc] cancel the editing.
|
||||
if ( 27 === key ) {
|
||||
buttons.children( '.cancel' ).click();
|
||||
}
|
||||
@ -1173,7 +1174,7 @@ jQuery(document).ready( function($) {
|
||||
}
|
||||
});
|
||||
|
||||
// When changing page template, change the editor body class
|
||||
// When changing page template, change the editor body class.
|
||||
$( '#page_template' ).on( 'change.set-editor-class', function() {
|
||||
var editor, body, pageTemplate = $( this ).val() || '';
|
||||
|
||||
@ -1191,9 +1192,9 @@ jQuery(document).ready( function($) {
|
||||
|
||||
}
|
||||
|
||||
// Save on pressing [ctrl]/[command] + [s] in the Text editor.
|
||||
// Save on pressing [Ctrl]/[Command] + [S] in the Text editor.
|
||||
$textarea.on( 'keydown.wp-autosave', function( event ) {
|
||||
// Key [s] has code 83.
|
||||
// Key [S] has code 83.
|
||||
if ( event.which === 83 ) {
|
||||
if ( event.shiftKey || event.altKey || ( isMac && ( ! event.metaKey || event.ctrlKey ) ) || ( ! isMac && ! event.ctrlKey ) ) {
|
||||
return;
|
||||
|
@ -32,7 +32,9 @@
|
||||
* if the postbox has been closed.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @memberof postboxes
|
||||
*
|
||||
* @fires postboxes#postbox-toggled
|
||||
*
|
||||
* @return {void}
|
||||
@ -90,6 +92,7 @@
|
||||
* Adds event handlers to all postboxes and screen option on the current page.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @memberof postboxes
|
||||
*
|
||||
* @param {string} page The page we are currently on.
|
||||
@ -190,6 +193,7 @@
|
||||
* Initializes all the postboxes, mainly their sortable behaviour.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @memberof postboxes
|
||||
*
|
||||
* @param {string} page The page we are currently on.
|
||||
@ -272,6 +276,7 @@
|
||||
* hidden postboxes.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @memberof postboxes
|
||||
*
|
||||
* @param {string} page The page we are currently on.
|
||||
@ -303,6 +308,7 @@
|
||||
* Sends a list of all postboxes inside a sortable area to the server.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @memberof postboxes
|
||||
*
|
||||
* @param {string} page The page we are currently on.
|
||||
@ -333,9 +339,10 @@
|
||||
* present.
|
||||
*
|
||||
* @since 3.3.0
|
||||
* @memberof postboxes
|
||||
* @access private
|
||||
*
|
||||
* @memberof postboxes
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
_mark_area : function() {
|
||||
@ -365,10 +372,12 @@
|
||||
* Changes the amount of columns on the post edit page.
|
||||
*
|
||||
* @since 3.3.0
|
||||
* @memberof postboxes
|
||||
* @fires postboxes#postboxes-columnchange
|
||||
* @access private
|
||||
*
|
||||
* @memberof postboxes
|
||||
*
|
||||
* @fires postboxes#postboxes-columnchange
|
||||
*
|
||||
* @param {number} n The amount of columns to divide the post edit page in.
|
||||
* @return {void}
|
||||
*/
|
||||
@ -395,9 +404,10 @@
|
||||
* orientation of the browser.
|
||||
*
|
||||
* @since 3.3.0
|
||||
* @memberof postboxes
|
||||
* @access private
|
||||
*
|
||||
* @memberof postboxes
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
_pb_change : function() {
|
||||
@ -425,19 +435,20 @@
|
||||
|
||||
/**
|
||||
* @since 2.7.0
|
||||
* @memberof postboxes
|
||||
* @access public
|
||||
*
|
||||
* @property {Function|boolean} pbshow A callback that is called when a postbox
|
||||
* is opened.
|
||||
* @memberof postboxes
|
||||
*/
|
||||
pbshow : false,
|
||||
|
||||
/**
|
||||
* @since 2.7.0
|
||||
* @memberof postboxes
|
||||
* @access public
|
||||
* @property {Function|boolean} pbhide A callback that is called when a postbox
|
||||
* is closed.
|
||||
* @memberof postboxes
|
||||
*/
|
||||
pbhide : false
|
||||
};
|
||||
|
@ -4,7 +4,7 @@
|
||||
* @output wp-admin/js/privacy-tools.js
|
||||
*/
|
||||
|
||||
// Privacy request action handling
|
||||
// Privacy request action handling.
|
||||
jQuery( document ).ready( function( $ ) {
|
||||
var strings = window.privacyToolsL10n || {};
|
||||
|
||||
@ -111,7 +111,7 @@ jQuery( document ).ready( function( $ ) {
|
||||
|
||||
if ( ! response.success ) {
|
||||
|
||||
// e.g. invalid request ID
|
||||
// e.g. invalid request ID.
|
||||
onExportFailure( response.data );
|
||||
return;
|
||||
}
|
||||
@ -127,12 +127,12 @@ jQuery( document ).ready( function( $ ) {
|
||||
}
|
||||
}).fail( function( jqxhr, textStatus, error ) {
|
||||
|
||||
// e.g. Nonce failure
|
||||
// e.g. Nonce failure.
|
||||
onExportFailure( error );
|
||||
});
|
||||
}
|
||||
|
||||
// And now, let's begin
|
||||
// And now, let's begin.
|
||||
setActionState( $action, 'export-personal-data-processing' );
|
||||
doNextExport( 1, 1 );
|
||||
});
|
||||
@ -224,7 +224,7 @@ jQuery( document ).ready( function( $ ) {
|
||||
});
|
||||
}
|
||||
|
||||
// And now, let's begin
|
||||
// And now, let's begin.
|
||||
setActionState( $action, 'remove-personal-data-processing' );
|
||||
|
||||
doNextErasure( 1, 1 );
|
||||
|
@ -259,9 +259,11 @@ jQuery( document ).ready( function( $ ) {
|
||||
RecalculateProgression();
|
||||
|
||||
if ( delay > 3000 ) {
|
||||
// We have announced that we're waiting.
|
||||
// Announce that we're ready after giving at least 3 seconds for the first announcement
|
||||
// to be read out, or the two may collide.
|
||||
/*
|
||||
* We have announced that we're waiting.
|
||||
* Announce that we're ready after giving at least 3 seconds
|
||||
* for the first announcement to be read out, or the two may collide.
|
||||
*/
|
||||
if ( delay > 6000 ) {
|
||||
delay = 0;
|
||||
} else {
|
||||
|
@ -52,6 +52,7 @@
|
||||
* Cleans up tags by removing redundant characters.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberOf tagBox
|
||||
*
|
||||
* @param {string} tags Comma separated tags that need to be cleaned up.
|
||||
@ -76,6 +77,7 @@
|
||||
* Parses tags and makes them editable.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberOf tagBox
|
||||
*
|
||||
* @param {Object} el The tag element to retrieve the ID from.
|
||||
@ -110,6 +112,7 @@
|
||||
* Creates clickable links, buttons and fields for adding or editing tags.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberOf tagBox
|
||||
*
|
||||
* @param {Object} el The container HTML element.
|
||||
@ -134,6 +137,7 @@
|
||||
* Creates a delete button if tag editing is enabled, before adding it to the tag list.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @memberOf tagBox
|
||||
*
|
||||
* @param {string} key The index of the current tag.
|
||||
@ -209,6 +213,7 @@
|
||||
* Also ensures that the quick links are properly generated.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberOf tagBox
|
||||
*
|
||||
* @param {Object} el The container HTML element.
|
||||
@ -262,6 +267,7 @@
|
||||
* tagcloud. Clicking a tag will add it.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberOf tagBox
|
||||
*
|
||||
* @param {string} id The ID to extract the taxonomy from.
|
||||
@ -350,6 +356,7 @@
|
||||
* retrieval of tag suggestions.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberOf tagBox
|
||||
*
|
||||
* @return {void}
|
||||
|
@ -89,8 +89,8 @@
|
||||
focus: function( event, ui ) {
|
||||
$element.attr( 'aria-activedescendant', 'wp-tags-autocomplete-' + ui.item.id );
|
||||
|
||||
// Don't empty the input field when using the arrow keys to
|
||||
// highlight items. See api.jqueryui.com/autocomplete/#event-focus
|
||||
// Don't empty the input field when using the arrow keys
|
||||
// to highlight items. See api.jqueryui.com/autocomplete/#event-focus
|
||||
event.preventDefault();
|
||||
},
|
||||
select: function( event, ui ) {
|
||||
@ -113,7 +113,7 @@
|
||||
window.tagBox.flushTags( $( this ).closest( '.tagsdiv' ) );
|
||||
}
|
||||
|
||||
// Do not close Quick Edit / Bulk Edit
|
||||
// Do not close Quick Edit / Bulk Edit.
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
@ -175,14 +175,16 @@
|
||||
.attr( 'role', 'listbox' )
|
||||
.removeAttr( 'tabindex' ) // Remove the `tabindex=0` attribute added by jQuery UI.
|
||||
|
||||
// Looks like Safari and VoiceOver need an `aria-selected` attribute. See ticket #33301.
|
||||
// The `menufocus` and `menublur` events are the same events used to add and remove
|
||||
// the `ui-state-focus` CSS class on the menu items. See jQuery UI Menu Widget.
|
||||
/*
|
||||
* Looks like Safari and VoiceOver need an `aria-selected` attribute. See ticket #33301.
|
||||
* The `menufocus` and `menublur` events are the same events used to add and remove
|
||||
* the `ui-state-focus` CSS class on the menu items. See jQuery UI Menu Widget.
|
||||
*/
|
||||
.on( 'menufocus', function( event, ui ) {
|
||||
ui.item.attr( 'aria-selected', 'true' );
|
||||
})
|
||||
.on( 'menublur', function() {
|
||||
// The `menublur` event returns an object where the item is `null`
|
||||
// The `menublur` event returns an object where the item is `null`,
|
||||
// so we need to find the active item with other means.
|
||||
$( this ).find( '[aria-selected="true"]' ).removeAttr( 'aria-selected' );
|
||||
});
|
||||
|
@ -132,10 +132,14 @@ jQuery(document).ready(function($) {
|
||||
|
||||
parent = form.find( 'select#parent' ).val();
|
||||
|
||||
if ( parent > 0 && $('#tag-' + parent ).length > 0 ) // If the parent exists on this page, insert it below. Else insert it at the top of the list.
|
||||
$( '.tags #tag-' + parent ).after( res.responses[0].supplemental.noparents ); // As the parent exists, Insert the version with - - - prefixed
|
||||
else
|
||||
$( '.tags' ).prepend( res.responses[0].supplemental.parents ); // As the parent is not visible, Insert the version with Parent - Child - ThisTerm
|
||||
// If the parent exists on this page, insert it below. Else insert it at the top of the list.
|
||||
if ( parent > 0 && $('#tag-' + parent ).length > 0 ) {
|
||||
// As the parent exists, insert the version with - - - prefixed.
|
||||
$( '.tags #tag-' + parent ).after( res.responses[0].supplemental.noparents );
|
||||
} else {
|
||||
// As the parent is not visible, insert the version with Parent - Child - ThisTerm.
|
||||
$( '.tags' ).prepend( res.responses[0].supplemental.parents );
|
||||
}
|
||||
|
||||
$('.tags .no-items').remove();
|
||||
|
||||
@ -143,7 +147,7 @@ jQuery(document).ready(function($) {
|
||||
// Parents field exists, Add new term to the list.
|
||||
term = res.responses[1].supplemental;
|
||||
|
||||
// Create an indent for the Parent field
|
||||
// Create an indent for the Parent field.
|
||||
indent = '';
|
||||
for ( i = 0; i < res.responses[1].position; i++ )
|
||||
indent += ' ';
|
||||
|
@ -196,7 +196,7 @@
|
||||
resetToggle( false );
|
||||
|
||||
if ( $pass1Row.closest( 'form' ).is( '#your-profile' ) ) {
|
||||
// Clear password field to prevent update
|
||||
// Clear password field to prevent update.
|
||||
$pass1.val( '' ).trigger( 'pwupdate' );
|
||||
$submitButtons.prop( 'disabled', false );
|
||||
}
|
||||
@ -342,7 +342,7 @@
|
||||
$this.siblings( '.selected' ).removeClass( 'selected' );
|
||||
$this.addClass( 'selected' ).find( 'input[type="radio"]' ).prop( 'checked', true );
|
||||
|
||||
// Set color scheme
|
||||
// Set color scheme.
|
||||
if ( user_id === current_user_id ) {
|
||||
// Load the colors stylesheet.
|
||||
// The default color scheme won't have one, so we'll need to create an element.
|
||||
@ -351,7 +351,7 @@
|
||||
}
|
||||
$stylesheet.attr( 'href', $this.children( '.css_url' ).val() );
|
||||
|
||||
// repaint icons
|
||||
// Repaint icons.
|
||||
if ( typeof wp !== 'undefined' && wp.svgPainter ) {
|
||||
try {
|
||||
colors = $.parseJSON( $this.children( '.icon_colors' ).val() );
|
||||
@ -363,7 +363,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// update user option
|
||||
// Update user option.
|
||||
$.post( ajaxurl, {
|
||||
action: 'save-user-color-scheme',
|
||||
color_scheme: $this.children( 'input[name="admin_color"]' ).val(),
|
||||
|
@ -222,9 +222,9 @@ window.wpWidgets = {
|
||||
the_id = this.id;
|
||||
|
||||
if ( chooser.length ) {
|
||||
// Hide the chooser and move it out of the widget
|
||||
// Hide the chooser and move it out of the widget.
|
||||
$( '#wpbody-content' ).append( chooser.hide() );
|
||||
// Delete the cloned chooser from the drag helper
|
||||
// Delete the cloned chooser from the drag helper.
|
||||
ui.helper.find('.widgets-chooser').remove();
|
||||
self.clearWidgetSelection();
|
||||
}
|
||||
@ -321,7 +321,7 @@ window.wpWidgets = {
|
||||
wpWidgets.hoveredSidebar = null;
|
||||
|
||||
if ( $widget.hasClass('deleting') ) {
|
||||
wpWidgets.save( $widget, 1, 0, 1 ); // delete widget
|
||||
wpWidgets.save( $widget, 1, 0, 1 ); // Delete widget.
|
||||
$widget.remove();
|
||||
return;
|
||||
}
|
||||
@ -363,7 +363,7 @@ window.wpWidgets = {
|
||||
|
||||
$children = $sidebar.children('.widget');
|
||||
|
||||
// Make sure the dropped widget is at the top
|
||||
// Make sure the dropped widget is at the top.
|
||||
if ( $children.length > 1 ) {
|
||||
child = $children.get(0);
|
||||
item = $widget.get(0);
|
||||
@ -386,14 +386,14 @@ window.wpWidgets = {
|
||||
},
|
||||
|
||||
deactivate: function() {
|
||||
// Remove all min-height added on "start"
|
||||
// Remove all min-height added on "start".
|
||||
$(this).css( 'min-height', '' ).parent().removeClass( 'widget-hover' );
|
||||
},
|
||||
|
||||
receive: function( event, ui ) {
|
||||
var $sender = $( ui.sender );
|
||||
|
||||
// Don't add more widgets to orphaned sidebars
|
||||
// Don't add more widgets to orphaned sidebars.
|
||||
if ( this.id.indexOf('orphaned_widgets') > -1 ) {
|
||||
$sender.sortable('cancel');
|
||||
return;
|
||||
@ -431,7 +431,7 @@ window.wpWidgets = {
|
||||
}
|
||||
});
|
||||
|
||||
// Area Chooser
|
||||
// Area Chooser.
|
||||
$( '#widgets-right .widgets-holder-wrap' ).each( function( index, element ) {
|
||||
var $element = $( element ),
|
||||
name = $element.find( '.sidebar-name h2' ).text(),
|
||||
@ -465,7 +465,7 @@ window.wpWidgets = {
|
||||
toggleButton.attr( 'aria-expanded', 'false' );
|
||||
self.closeChooser();
|
||||
} else {
|
||||
// Open the chooser
|
||||
// Open the chooser.
|
||||
self.clearWidgetSelection();
|
||||
$( '#widgets-left' ).addClass( 'chooser' );
|
||||
// Add CSS class and insert the chooser after the widget description.
|
||||
@ -486,7 +486,7 @@ window.wpWidgets = {
|
||||
}
|
||||
});
|
||||
|
||||
// Add event handlers
|
||||
// Add event handlers.
|
||||
chooser.on( 'click.widgets-chooser', function( event ) {
|
||||
var $target = $( event.target );
|
||||
|
||||
@ -662,7 +662,7 @@ window.wpWidgets = {
|
||||
add = widget.find( 'input.add_new' ).val();
|
||||
n = widget.find( 'input.multi_number' ).val();
|
||||
|
||||
// Remove the cloned chooser from the widget
|
||||
// Remove the cloned chooser from the widget.
|
||||
widget.find('.widgets-chooser').remove();
|
||||
|
||||
if ( 'multi' === add ) {
|
||||
@ -689,7 +689,7 @@ window.wpWidgets = {
|
||||
sidebar.sortable('refresh');
|
||||
|
||||
wpWidgets.save( widget, 0, 0, 1 );
|
||||
// No longer "new" widget
|
||||
// No longer "new" widget.
|
||||
widget.find( 'input.add_new' ).val('');
|
||||
|
||||
$document.trigger( 'widget-added', [ widget ] );
|
||||
|
@ -35,11 +35,11 @@
|
||||
|
||||
// Expand/Collapse accordion sections on click.
|
||||
$( '.accordion-container' ).on( 'click keydown', '.accordion-section-title', function( e ) {
|
||||
if ( e.type === 'keydown' && 13 !== e.which ) { // "return" key
|
||||
if ( e.type === 'keydown' && 13 !== e.which ) { // "Return" key.
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault(); // Keep this AFTER the key filter above
|
||||
e.preventDefault(); // Keep this AFTER the key filter above.
|
||||
|
||||
accordionSwitch( $( this ) );
|
||||
});
|
||||
@ -80,7 +80,7 @@
|
||||
section.toggleClass( 'open' );
|
||||
}
|
||||
|
||||
// We have to wait for the animations to finish
|
||||
// We have to wait for the animations to finish.
|
||||
setTimeout(function(){
|
||||
container.removeClass( 'opening' );
|
||||
}, 150);
|
||||
|
@ -264,7 +264,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// (Old) IE doesn't support preventDefault, and does support returnValue
|
||||
// (Old) IE doesn't support preventDefault, and does support returnValue.
|
||||
if ( event.preventDefault ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
@ -451,7 +451,7 @@
|
||||
};
|
||||
}
|
||||
|
||||
// Get the closest matching elent
|
||||
// Get the closest matching elent.
|
||||
for ( ; el && el !== document; el = el.parentNode ) {
|
||||
if ( el.matches( selector ) ) {
|
||||
return el;
|
||||
|
@ -17,7 +17,7 @@ window.wpAjax = jQuery.extend( {
|
||||
}
|
||||
return r;
|
||||
},
|
||||
parseAjaxResponse: function( x, r, e ) { // 1 = good, 0 = strange (bad data?), -1 = you lack permission
|
||||
parseAjaxResponse: function( x, r, e ) { // 1 = good, 0 = strange (bad data?), -1 = you lack permission.
|
||||
var parsed = {}, re = jQuery('#' + r).empty(), err = '';
|
||||
|
||||
if ( x && typeof x == 'object' && x.getElementsByTagName('wp_ajax') ) {
|
||||
@ -64,7 +64,7 @@ window.wpAjax = jQuery.extend( {
|
||||
}
|
||||
}, wpAjax || { noPerm: 'Sorry, you are not allowed to do that.', broken: 'Something went wrong.' } );
|
||||
|
||||
// Basic form validation
|
||||
// Basic form validation.
|
||||
jQuery(document).ready( function($){
|
||||
$('form.validate').submit( function() { return wpAjax.validateForm( $(this) ); } );
|
||||
});
|
||||
|
@ -51,8 +51,8 @@
|
||||
else
|
||||
parent.css( 'max-height', height + 40 + 'px' );
|
||||
} else if ( ! body || ! body.length ) {
|
||||
// Catch "silent" iframe origin exceptions in WebKit after another page is
|
||||
// loaded in the iframe.
|
||||
// Catch "silent" iframe origin exceptions in WebKit
|
||||
// after another page is loaded in the iframe.
|
||||
wrap.addClass('fallback');
|
||||
parent.css( 'max-height', '' );
|
||||
form.remove();
|
||||
@ -68,9 +68,11 @@
|
||||
|
||||
if ( frame ) {
|
||||
frame.focus();
|
||||
// WebKit doesn't throw an error if the iframe fails to load because of
|
||||
// "X-Frame-Options: DENY" header.
|
||||
// Wait for 10 sec. and switch to the fallback text.
|
||||
/*
|
||||
* WebKit doesn't throw an error if the iframe fails to load
|
||||
* because of "X-Frame-Options: DENY" header.
|
||||
* Wait for 10 seconds and switch to the fallback text.
|
||||
*/
|
||||
setTimeout( function() {
|
||||
if ( ! loaded ) {
|
||||
wrap.addClass('fallback');
|
||||
@ -92,8 +94,8 @@
|
||||
function hide() {
|
||||
$(window).off( 'beforeunload.wp-auth-check' );
|
||||
|
||||
// When on the Edit Post screen, speed up heartbeat after the user logs in to
|
||||
// quickly refresh nonces.
|
||||
// When on the Edit Post screen, speed up heartbeat
|
||||
// after the user logs in to quickly refresh nonces.
|
||||
if ( typeof adminpage !== 'undefined' && ( adminpage === 'post-php' || adminpage === 'post-new-php' ) &&
|
||||
typeof wp !== 'undefined' && wp.heartbeat ) {
|
||||
|
||||
|
@ -36,7 +36,6 @@
|
||||
* Creates a color picker that only allows you to adjust the hue.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @return {void}
|
||||
@ -80,7 +79,6 @@
|
||||
* Creates the color picker, sets default values, css classes and wraps it all in HTML.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @return {void}
|
||||
@ -209,7 +207,6 @@
|
||||
* Binds event listeners to the color picker.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @return {void}
|
||||
|
@ -95,7 +95,7 @@ window.addComment = ( function( window ) {
|
||||
cancelElement.addEventListener( 'touchstart', cancelEvent );
|
||||
cancelElement.addEventListener( 'click', cancelEvent );
|
||||
|
||||
// Submit the comment form when the user types CTRL or CMD + 'Enter'.
|
||||
// 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 );
|
||||
|
@ -115,7 +115,7 @@ window.wpCookies = {
|
||||
if ( typeof( expires ) === 'object' && expires.toGMTString ) {
|
||||
expires = expires.toGMTString();
|
||||
} else if ( parseInt( expires, 10 ) ) {
|
||||
d.setTime( d.getTime() + ( parseInt( expires, 10 ) * 1000 ) ); // time must be in milliseconds
|
||||
d.setTime( d.getTime() + ( parseInt( expires, 10 ) * 1000 ) ); // Time must be in milliseconds.
|
||||
expires = d.toGMTString();
|
||||
} else {
|
||||
expires = '';
|
||||
@ -153,9 +153,11 @@ window.getUserSetting = function( name, def ) {
|
||||
return '';
|
||||
};
|
||||
|
||||
// Both name and value must be only ASCII letters, numbers or underscore
|
||||
// and the shorter, the better (cookies can store maximum 4KB). Not suitable to store text.
|
||||
// The value is converted and stored as string.
|
||||
/*
|
||||
* Both name and value must be only ASCII letters, numbers or underscore
|
||||
* and the shorter, the better (cookies can store maximum 4KB). Not suitable to store text.
|
||||
* The value is converted and stored as string.
|
||||
*/
|
||||
window.setUserSetting = function( name, value, _del ) {
|
||||
if ( 'object' !== typeof userSettings ) {
|
||||
return false;
|
||||
@ -192,7 +194,7 @@ window.deleteUserSetting = function( name ) {
|
||||
return setUserSetting( name, '', 1 );
|
||||
};
|
||||
|
||||
// Returns all settings as js object.
|
||||
// Returns all settings as JS object.
|
||||
window.getAllUserSettings = function() {
|
||||
if ( 'object' !== typeof userSettings ) {
|
||||
return {};
|
||||
|
@ -15,7 +15,7 @@ jQuery(document).ready(function($) {
|
||||
distance: 2,
|
||||
handle: 'div.filename',
|
||||
stop: function() {
|
||||
// When an update has occurred, adjust the order for each item
|
||||
// When an update has occurred, adjust the order for each item.
|
||||
var all = $('#media-items').sortable('toArray'), len = all.length;
|
||||
$.each(all, function(i, id) {
|
||||
var order = desc ? (len - i) : (1 + i);
|
||||
@ -71,7 +71,7 @@ jQuery(document).ready(function($) {
|
||||
$('img.pinkynail').toggle(true);
|
||||
});
|
||||
|
||||
// initialize sortable
|
||||
// Initialize sortable.
|
||||
gallerySortableInit();
|
||||
clearAll();
|
||||
|
||||
@ -88,7 +88,7 @@ jQuery(document).ready(function($) {
|
||||
}
|
||||
});
|
||||
|
||||
jQuery(window).unload( function () { window.tinymce = window.tinyMCE = window.wpgallery = null; } ); // Cleanup
|
||||
jQuery(window).unload( function () { window.tinymce = window.tinyMCE = window.wpgallery = null; } ); // Cleanup.
|
||||
|
||||
/* gallery settings */
|
||||
window.tinymce = null;
|
||||
@ -122,7 +122,7 @@ window.wpgallery = {
|
||||
document.domain = q.mce_rdomain;
|
||||
}
|
||||
|
||||
// Find window & API
|
||||
// Find window & API.
|
||||
window.tinymce = w.tinymce;
|
||||
window.tinyMCE = w.tinyMCE;
|
||||
t.editor = tinymce.EditorManager.activeEditor;
|
||||
|
@ -48,8 +48,9 @@
|
||||
/**
|
||||
* Converts a value to an integer.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} f The float value that should be converted.
|
||||
*
|
||||
@ -66,8 +67,9 @@
|
||||
/**
|
||||
* Adds the disabled attribute and class to a single form element or a field set.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {jQuery} el The element that should be modified.
|
||||
* @param {bool|number} s The state for the element. If set to true
|
||||
@ -95,8 +97,9 @@
|
||||
/**
|
||||
* Initializes the image editor.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} postid The post id.
|
||||
*
|
||||
@ -121,12 +124,12 @@
|
||||
$('input[type="text"]', '#imgedit-panel-' + postid).keypress(function(e) {
|
||||
var k = e.keyCode;
|
||||
|
||||
// Key codes 37 thru 40 are the arrow keys.
|
||||
// Key codes 37 through 40 are the arrow keys.
|
||||
if ( 36 < k && k < 41 ) {
|
||||
$(this).blur();
|
||||
}
|
||||
|
||||
// The key code 13 is the enter key.
|
||||
// The key code 13 is the Enter key.
|
||||
if ( 13 === k ) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
@ -138,8 +141,9 @@
|
||||
/**
|
||||
* Toggles the wait/load icon in the editor.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} postid The post id.
|
||||
* @param {number} toggle Is 0 or 1, fades the icon in then 1 and out when 0.
|
||||
@ -159,8 +163,9 @@
|
||||
/**
|
||||
* Shows or hides the image edit help box.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {HTMLElement} el The element to create the help window in.
|
||||
*
|
||||
@ -181,8 +186,9 @@
|
||||
* The image edit target contains the image sizes where the (possible) changes
|
||||
* have to be applied to.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} postid The post id.
|
||||
*
|
||||
@ -198,8 +204,9 @@
|
||||
*
|
||||
* If the original image size is exceeded a red exclamation mark is shown.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} postid The current post id.
|
||||
* @param {number} x Is 0 when it applies the y-axis
|
||||
@ -234,8 +241,9 @@
|
||||
/**
|
||||
* Gets the selected aspect ratio.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} postid The post id.
|
||||
*
|
||||
@ -261,8 +269,9 @@
|
||||
* Removes the last action from the image edit history.
|
||||
* The history consist of (edit) actions performed on the image.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} postid The post id.
|
||||
* @param {number} setSize 0 or 1, when 1 the image resets to its original size.
|
||||
@ -295,13 +304,13 @@
|
||||
// Restore original 'o'.
|
||||
o = history[history.length - 1];
|
||||
|
||||
// c = 'crop', r = 'rotate', f = 'flip'
|
||||
// c = 'crop', r = 'rotate', f = 'flip'.
|
||||
o = o.c || o.r || o.f || false;
|
||||
|
||||
if ( o ) {
|
||||
// fw = Full image width
|
||||
// fw = Full image width.
|
||||
this.hold.w = o.fw;
|
||||
// fh = Full image height
|
||||
// fh = Full image height.
|
||||
this.hold.h = o.fh;
|
||||
}
|
||||
}
|
||||
@ -326,8 +335,9 @@
|
||||
*
|
||||
* When the image source is reloaded the image will be reloaded.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} postid The post id.
|
||||
* @param {string} nonce The nonce to verify the request.
|
||||
@ -371,7 +381,7 @@
|
||||
|
||||
parent.empty().append(img);
|
||||
|
||||
// w, h are the new full size dims
|
||||
// w, h are the new full size dimensions.
|
||||
max1 = Math.max( t.hold.w, t.hold.h );
|
||||
max2 = Math.max( $(img).width(), $(img).height() );
|
||||
t.hold.sizer = max1 > max2 ? max2 / max1 : 1;
|
||||
@ -399,8 +409,9 @@
|
||||
/**
|
||||
* Performs an image edit action.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} postid The post id.
|
||||
* @param {string} nonce The nonce to verify the request.
|
||||
@ -456,7 +467,7 @@
|
||||
$.post(ajaxurl, data, function(r) {
|
||||
$('#image-editor-' + postid).empty().append(r);
|
||||
t.toggleEditor(postid, 0);
|
||||
// refresh the attachment model so that changes propagate
|
||||
// Refresh the attachment model so that changes propagate.
|
||||
if ( t._view ) {
|
||||
t._view.refresh();
|
||||
}
|
||||
@ -466,8 +477,9 @@
|
||||
/**
|
||||
* Stores the changes that are made to the image.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} postid The post id to get the image from the database.
|
||||
* @param {string} nonce The nonce to verify the request.
|
||||
@ -531,8 +543,9 @@
|
||||
/**
|
||||
* Creates the image edit window.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} postid The post id for the image.
|
||||
* @param {string} nonce The nonce to verify the request.
|
||||
@ -588,8 +601,9 @@
|
||||
/**
|
||||
* Initializes the cropping tool and sets a default cropping selection.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} postid The post id.
|
||||
*
|
||||
@ -614,8 +628,9 @@
|
||||
/**
|
||||
* Initializes the cropping tool.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} postid The post id.
|
||||
* @param {HTMLElement} image The preview image.
|
||||
@ -645,8 +660,8 @@
|
||||
* @param {jQuery} img The preview image.
|
||||
*/
|
||||
onInit: function( img ) {
|
||||
// Ensure that the imgAreaSelect wrapper elements are position:absolute.
|
||||
// (even if we're in a position:fixed modal)
|
||||
// Ensure that the imgAreaSelect wrapper elements are position:absolute
|
||||
// (even if we're in a position:fixed modal).
|
||||
$img = $( img );
|
||||
$img.next().css( 'position', 'absolute' )
|
||||
.nextAll( '.imgareaselect-outer' ).css( 'position', 'absolute' );
|
||||
@ -715,8 +730,9 @@
|
||||
/**
|
||||
* Stores the current crop selection.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} postid The post id.
|
||||
* @param {object} c The selection.
|
||||
@ -746,8 +762,9 @@
|
||||
/**
|
||||
* Closes the image editor.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} postid The post id.
|
||||
* @param {bool} warn Warning message.
|
||||
@ -764,13 +781,14 @@
|
||||
this.iasapi = {};
|
||||
this.hold = {};
|
||||
|
||||
// If we've loaded the editor in the context of a Media Modal, then switch to the previous view,
|
||||
// whatever that might have been.
|
||||
// If we've loaded the editor in the context of a Media Modal,
|
||||
// then switch to the previous view, whatever that might have been.
|
||||
if ( this._view ){
|
||||
this._view.back();
|
||||
}
|
||||
|
||||
// In case we are not accessing the image editor in the context of a View, close the editor the old-skool way
|
||||
// In case we are not accessing the image editor in the context of a View,
|
||||
// close the editor the old-school way.
|
||||
else {
|
||||
$('#image-editor-' + postid).fadeOut('fast', function() {
|
||||
$( '#media-head-' + postid ).fadeIn( 'fast', function() {
|
||||
@ -787,8 +805,9 @@
|
||||
/**
|
||||
* Checks if the image edit history is saved.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} postid The post id.
|
||||
*
|
||||
@ -811,8 +830,9 @@
|
||||
/**
|
||||
* Adds an image edit action to the history.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {object} op The original position.
|
||||
* @param {number} postid The post id.
|
||||
@ -830,7 +850,7 @@
|
||||
history.pop();
|
||||
pop--;
|
||||
}
|
||||
undone.val(0); // reset
|
||||
undone.val(0); // Reset.
|
||||
|
||||
history.push(op);
|
||||
elem.val( JSON.stringify(history) );
|
||||
@ -844,8 +864,9 @@
|
||||
/**
|
||||
* Rotates the image.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {string} angle The angle the image is rotated with.
|
||||
* @param {number} postid The post id.
|
||||
@ -865,8 +886,9 @@
|
||||
/**
|
||||
* Flips the image.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} axis The axle the image is flipped on.
|
||||
* @param {number} postid The post id.
|
||||
@ -886,8 +908,9 @@
|
||||
/**
|
||||
* Crops the image.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} postid The post id.
|
||||
* @param {string} nonce The nonce.
|
||||
@ -915,8 +938,9 @@
|
||||
/**
|
||||
* Undoes an image edit action.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} postid The post id.
|
||||
* @param {string} nonce The nonce.
|
||||
@ -948,8 +972,9 @@
|
||||
/**
|
||||
* Reverts a undo action.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} postid The post id.
|
||||
* @param {string} nonce The nonce.
|
||||
@ -978,8 +1003,9 @@
|
||||
/**
|
||||
* Sets the selection for the height and width in pixels.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} postid The post id.
|
||||
* @param {jQuery} el The element containing the values.
|
||||
@ -1035,8 +1061,9 @@
|
||||
/**
|
||||
* Rounds a number to a whole.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} num The number.
|
||||
*
|
||||
@ -1064,8 +1091,9 @@
|
||||
/**
|
||||
* Sets a locked aspect ratio for the selection.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param {number} postid The post id.
|
||||
* @param {number} n The ratio to set.
|
||||
@ -1108,8 +1136,9 @@
|
||||
/**
|
||||
* Validates if a value in a jQuery.HTMLElement is numeric.
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
* @memberof imageEdit
|
||||
* @since 4.6
|
||||
*
|
||||
* @param {jQuery} el The html element.
|
||||
*
|
||||
|
@ -36,24 +36,24 @@
|
||||
inputs.submit = $( '#wp-link-submit' );
|
||||
inputs.close = $( '#wp-link-close' );
|
||||
|
||||
// Input
|
||||
// Input.
|
||||
inputs.text = $( '#wp-link-text' );
|
||||
inputs.url = $( '#wp-link-url' );
|
||||
inputs.nonce = $( '#_ajax_linking_nonce' );
|
||||
inputs.openInNewTab = $( '#wp-link-target' );
|
||||
inputs.search = $( '#wp-link-search' );
|
||||
|
||||
// Build Rivers
|
||||
// Build rivers.
|
||||
rivers.search = new River( $( '#search-results' ) );
|
||||
rivers.recent = new River( $( '#most-recent-results' ) );
|
||||
rivers.elements = inputs.dialog.find( '.query-results' );
|
||||
|
||||
// Get search notice text
|
||||
// Get search notice text.
|
||||
inputs.queryNotice = $( '#query-notice-message' );
|
||||
inputs.queryNoticeTextDefault = inputs.queryNotice.find( '.query-notice-default' );
|
||||
inputs.queryNoticeTextHint = inputs.queryNotice.find( '.query-notice-hint' );
|
||||
|
||||
// Bind event handlers
|
||||
// Bind event handlers.
|
||||
inputs.dialog.keydown( wpLink.keydown );
|
||||
inputs.dialog.keyup( wpLink.keyup );
|
||||
inputs.submit.click( function( event ) {
|
||||
@ -68,7 +68,7 @@
|
||||
|
||||
rivers.elements.on( 'river-select', wpLink.updateFields );
|
||||
|
||||
// Display 'hint' message when search field or 'query-results' box are focused
|
||||
// Display 'hint' message when search field or 'query-results' box are focused.
|
||||
inputs.search.on( 'focus.wplink', function() {
|
||||
inputs.queryNoticeTextDefault.hide();
|
||||
inputs.queryNoticeTextHint.removeClass( 'screen-reader-text' ).show();
|
||||
@ -91,7 +91,7 @@
|
||||
inputs.url.on( 'blur', wpLink.correctURL );
|
||||
},
|
||||
|
||||
// If URL wasn't corrected last time and doesn't start with http:, https:, ? # or /, prepend http://
|
||||
// If URL wasn't corrected last time and doesn't start with http:, https:, ? # or /, prepend http://.
|
||||
correctURL: function () {
|
||||
var url = $.trim( inputs.url.val() );
|
||||
|
||||
@ -154,24 +154,24 @@
|
||||
refresh: function( url, text ) {
|
||||
var linkText = '';
|
||||
|
||||
// Refresh rivers (clear links, check visibility)
|
||||
// Refresh rivers (clear links, check visibility).
|
||||
rivers.search.refresh();
|
||||
rivers.recent.refresh();
|
||||
|
||||
if ( wpLink.isMCE() ) {
|
||||
wpLink.mceRefresh( url, text );
|
||||
} else {
|
||||
// For the Text editor the "Link text" field is always shown
|
||||
// For the Text editor the "Link text" field is always shown.
|
||||
if ( ! inputs.wrap.hasClass( 'has-text-field' ) ) {
|
||||
inputs.wrap.addClass( 'has-text-field' );
|
||||
}
|
||||
|
||||
if ( document.selection ) {
|
||||
// Old IE
|
||||
// Old IE.
|
||||
linkText = document.selection.createRange().text || text || '';
|
||||
} else if ( typeof this.textarea.selectionStart !== 'undefined' &&
|
||||
( this.textarea.selectionStart !== this.textarea.selectionEnd ) ) {
|
||||
// W3C
|
||||
// W3C.
|
||||
text = this.textarea.value.substring( this.textarea.selectionStart, this.textarea.selectionEnd ) || text || '';
|
||||
}
|
||||
|
||||
@ -180,12 +180,14 @@
|
||||
}
|
||||
|
||||
if ( isTouch ) {
|
||||
// Close the onscreen keyboard
|
||||
// Close the onscreen keyboard.
|
||||
inputs.url.focus().blur();
|
||||
} else {
|
||||
// Focus the URL field and highlight its contents.
|
||||
// If this is moved above the selection changes,
|
||||
// IE will show a flashing cursor over the dialog.
|
||||
/*
|
||||
* Focus the URL field and highlight its contents.
|
||||
* If this is moved above the selection changes,
|
||||
* IE will show a flashing cursor over the dialog.
|
||||
*/
|
||||
window.setTimeout( function() {
|
||||
inputs.url[0].select();
|
||||
inputs.url.focus();
|
||||
@ -203,7 +205,7 @@
|
||||
hasSelectedText: function( linkNode ) {
|
||||
var node, nodes, i, html = editor.selection.getContent();
|
||||
|
||||
// Partial html and not a fully selected anchor element
|
||||
// Partial html and not a fully selected anchor element.
|
||||
if ( /</.test( html ) && ( ! /^<a [^>]+>[^<]+<\/a>$/.test( html ) || html.indexOf('href=') === -1 ) ) {
|
||||
return false;
|
||||
}
|
||||
@ -259,7 +261,7 @@
|
||||
inputs.search.val( '' );
|
||||
}
|
||||
|
||||
// Always reset the search
|
||||
// Always reset the search.
|
||||
window.setTimeout( function() {
|
||||
wpLink.searchInternalLinks();
|
||||
} );
|
||||
@ -358,11 +360,11 @@
|
||||
|
||||
html = wpLink.buildHtml(attrs);
|
||||
|
||||
// Insert HTML
|
||||
// Insert HTML.
|
||||
if ( document.selection && wpLink.range ) {
|
||||
// IE
|
||||
// IE.
|
||||
// Note: If no text is selected, IE will not place the cursor
|
||||
// inside the closing tag.
|
||||
// inside the closing tag.
|
||||
textarea.focus();
|
||||
wpLink.range.text = html + ( text || wpLink.range.text ) + '</a>';
|
||||
wpLink.range.moveToBookmark( wpLink.range.getBookmark() );
|
||||
@ -370,7 +372,7 @@
|
||||
|
||||
wpLink.range = null;
|
||||
} else if ( typeof textarea.selectionStart !== 'undefined' ) {
|
||||
// W3C
|
||||
// W3C.
|
||||
begin = textarea.selectionStart;
|
||||
end = textarea.selectionEnd;
|
||||
selection = text || textarea.value.substring( begin, end );
|
||||
@ -388,7 +390,7 @@
|
||||
textarea.value.substring( end, textarea.value.length )
|
||||
);
|
||||
|
||||
// Update cursor position
|
||||
// Update cursor position.
|
||||
textarea.selectionStart = textarea.selectionEnd = cursor;
|
||||
}
|
||||
|
||||
@ -484,10 +486,10 @@
|
||||
selection = $.trim( selection );
|
||||
|
||||
if ( selection && emailRegexp.test( selection ) ) {
|
||||
// Selection is email address
|
||||
// Selection is email address.
|
||||
return 'mailto:' + selection;
|
||||
} else if ( selection && urlRegexp.test( selection ) ) {
|
||||
// Selection is URL
|
||||
// Selection is URL.
|
||||
return selection.replace( /&|�?38;/gi, '&' );
|
||||
}
|
||||
|
||||
@ -553,7 +555,7 @@
|
||||
id = event.target.id;
|
||||
|
||||
// wp-link-submit must always be the last focusable element in the dialog.
|
||||
// following focusable elements will be skipped on keyboard navigation.
|
||||
// Following focusable elements will be skipped on keyboard navigation.
|
||||
if ( id === 'wp-link-submit' && ! event.shiftKey ) {
|
||||
inputs.close.focus();
|
||||
event.preventDefault();
|
||||
@ -656,18 +658,18 @@
|
||||
|
||||
this.deselect();
|
||||
this.selected = li.addClass( 'selected' );
|
||||
// Make sure the element is visible
|
||||
// Make sure the element is visible.
|
||||
liHeight = li.outerHeight();
|
||||
elHeight = this.element.height();
|
||||
liTop = li.position().top;
|
||||
elTop = this.element.scrollTop();
|
||||
|
||||
if ( liTop < 0 ) // Make first visible element
|
||||
if ( liTop < 0 ) // Make first visible element.
|
||||
this.element.scrollTop( elTop + liTop );
|
||||
else if ( liTop + liHeight > elHeight ) // Make last visible element
|
||||
else if ( liTop + liHeight > elHeight ) // Make last visible element.
|
||||
this.element.scrollTop( elTop + liTop - elHeight + liHeight );
|
||||
|
||||
// Trigger the river-select event
|
||||
// Trigger the river-select event.
|
||||
this.element.trigger( 'river-select', [ li, event, this ] );
|
||||
},
|
||||
deselect: function() {
|
||||
|
@ -69,7 +69,7 @@
|
||||
},
|
||||
|
||||
jQueryExtensions : function() {
|
||||
// jQuery extensions
|
||||
// jQuery extensions.
|
||||
$.fn.extend({
|
||||
menuItemDepth : function() {
|
||||
var margin = api.isRTL ? this.eq(0).css('margin-right') : this.eq(0).css('margin-left');
|
||||
@ -114,7 +114,7 @@
|
||||
depth = t.menuItemDepth(),
|
||||
newDepth = depth + dir;
|
||||
|
||||
// Change .menu-item-depth-n class
|
||||
// Change .menu-item-depth-n class.
|
||||
t.moveHorizontally( newDepth, depth );
|
||||
});
|
||||
},
|
||||
@ -125,10 +125,10 @@
|
||||
diff = newDepth - depth,
|
||||
subItemText = t.find('.is-submenu');
|
||||
|
||||
// Change .menu-item-depth-n class
|
||||
// Change .menu-item-depth-n class.
|
||||
t.updateDepthClass( newDepth, depth ).updateParentMenuItemDBId();
|
||||
|
||||
// If it has children, move those too
|
||||
// If it has children, move those too.
|
||||
if ( children ) {
|
||||
children.each(function() {
|
||||
var t = $(this),
|
||||
@ -138,7 +138,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
// Show "Sub item" helper text
|
||||
// Show "Sub item" helper text.
|
||||
if (0 === newDepth)
|
||||
subItemText.hide();
|
||||
else
|
||||
@ -153,7 +153,7 @@
|
||||
parentDepth = depth - 1,
|
||||
parent = item.prevAll( '.menu-item-depth-' + parentDepth ).first();
|
||||
|
||||
if ( 0 === depth ) { // Item is on the top level, has no parent
|
||||
if ( 0 === depth ) { // Item is on the top level, has no parent.
|
||||
input.val(0);
|
||||
} else { // Find the parent item, and retrieve its object id.
|
||||
input.val( parent.find( '.menu-item-data-db-id' ).val() );
|
||||
@ -191,10 +191,10 @@
|
||||
if ( !checkboxes.length )
|
||||
return false;
|
||||
|
||||
// Show the ajax spinner
|
||||
// Show the Ajax spinner.
|
||||
t.find( '.button-controls .spinner' ).addClass( 'is-active' );
|
||||
|
||||
// Retrieve menu item data
|
||||
// Retrieve menu item data.
|
||||
$(checkboxes).each(function(){
|
||||
var t = $(this),
|
||||
listItemDBIDMatch = re.exec( t.attr('name') ),
|
||||
@ -205,9 +205,9 @@
|
||||
menuItems[listItemDBID] = t.closest('li').getItemData( 'add-menu-item', listItemDBID );
|
||||
});
|
||||
|
||||
// Add the items
|
||||
// Add the items.
|
||||
api.addItemToMenu(menuItems, processMethod, function(){
|
||||
// Deselect the items and hide the ajax spinner
|
||||
// Deselect the items and hide the Ajax spinner.
|
||||
checkboxes.prop( 'checked', false );
|
||||
t.find( '.button-controls .select-all' ).prop( 'checked', false );
|
||||
t.find( '.button-controls .spinner' ).removeClass( 'is-active' );
|
||||
@ -312,22 +312,22 @@
|
||||
case 'up':
|
||||
newItemPosition = thisItemPosition - 1;
|
||||
|
||||
// Already at top
|
||||
// Already at top.
|
||||
if ( 0 === thisItemPosition )
|
||||
break;
|
||||
|
||||
// If a sub item is moved to top, shift it to 0 depth
|
||||
// If a sub item is moved to top, shift it to 0 depth.
|
||||
if ( 0 === newItemPosition && 0 !== thisItemDepth )
|
||||
thisItem.moveHorizontally( 0, thisItemDepth );
|
||||
|
||||
// If prev item is sub item, shift to match depth
|
||||
// If prev item is sub item, shift to match depth.
|
||||
if ( 0 !== prevItemDepth )
|
||||
thisItem.moveHorizontally( prevItemDepth, thisItemDepth );
|
||||
|
||||
// Does this item have sub items?
|
||||
if ( thisItemChildren ) {
|
||||
items = thisItem.add( thisItemChildren );
|
||||
// Move the entire block
|
||||
// Move the entire block.
|
||||
items.detach().insertBefore( menuItems.eq( newItemPosition ) ).updateParentMenuItemDBId();
|
||||
} else {
|
||||
thisItem.detach().insertBefore( menuItems.eq( newItemPosition ) ).updateParentMenuItemDBId();
|
||||
@ -351,40 +351,40 @@
|
||||
|
||||
items.detach().insertAfter( menuItems.eq( thisItemPosition + items.length ) ).updateParentMenuItemDBId();
|
||||
} else {
|
||||
// If next item has sub items, shift depth
|
||||
// If next item has sub items, shift depth.
|
||||
if ( 0 !== nextItemChildren.length )
|
||||
thisItem.moveHorizontally( nextItemDepth, thisItemDepth );
|
||||
|
||||
// Have we reached the bottom
|
||||
// Have we reached the bottom?
|
||||
if ( menuItemsCount === thisItemPosition + 1 )
|
||||
break;
|
||||
thisItem.detach().insertAfter( menuItems.eq( thisItemPosition + 1 ) ).updateParentMenuItemDBId();
|
||||
}
|
||||
break;
|
||||
case 'top':
|
||||
// Already at top
|
||||
// Already at top.
|
||||
if ( 0 === thisItemPosition )
|
||||
break;
|
||||
// Does this item have sub items?
|
||||
if ( thisItemChildren ) {
|
||||
items = thisItem.add( thisItemChildren );
|
||||
// Move the entire block
|
||||
// Move the entire block.
|
||||
items.detach().insertBefore( menuItems.eq( 0 ) ).updateParentMenuItemDBId();
|
||||
} else {
|
||||
thisItem.detach().insertBefore( menuItems.eq( 0 ) ).updateParentMenuItemDBId();
|
||||
}
|
||||
break;
|
||||
case 'left':
|
||||
// As far left as possible
|
||||
// As far left as possible.
|
||||
if ( 0 === thisItemDepth )
|
||||
break;
|
||||
thisItem.shiftHorizontally( -1 );
|
||||
break;
|
||||
case 'right':
|
||||
// Can't be sub item at top
|
||||
// Can't be sub item at top.
|
||||
if ( 0 === thisItemPosition )
|
||||
break;
|
||||
// Already sub item of prevItem
|
||||
// Already sub item of prevItem.
|
||||
if ( thisItemData['menu-item-parent-id'] === prevItemId )
|
||||
break;
|
||||
thisItem.shiftHorizontally( 1 );
|
||||
@ -402,7 +402,7 @@
|
||||
api.refreshKeyboardAccessibility();
|
||||
api.refreshAdvancedAccessibility();
|
||||
|
||||
// Refresh the accessibility when the user comes close to the item in any way
|
||||
// Refresh the accessibility when the user comes close to the item in any way.
|
||||
menu.on( 'mouseenter.refreshAccessibility focus.refreshAccessibility touchstart.refreshAccessibility' , '.menu-item' , function(){
|
||||
api.refreshAdvancedAccessibilityOfItem( $( this ).find( 'a.item-edit' ) );
|
||||
} );
|
||||
@ -412,7 +412,7 @@
|
||||
api.refreshAdvancedAccessibilityOfItem( $( this ) );
|
||||
} );
|
||||
|
||||
// Links for moving items
|
||||
// Links for moving items.
|
||||
menu.on( 'click', '.menus-move', function () {
|
||||
var $this = $( this ),
|
||||
dir = $this.data( 'dir' );
|
||||
@ -433,7 +433,7 @@
|
||||
*/
|
||||
refreshAdvancedAccessibilityOfItem : function( itemToRefresh ) {
|
||||
|
||||
// Only refresh accessibility when necessary
|
||||
// Only refresh accessibility when necessary.
|
||||
if ( true !== $( itemToRefresh ).data( 'needs_accessibility_refresh' ) ) {
|
||||
return;
|
||||
}
|
||||
@ -494,7 +494,7 @@
|
||||
itemPosition = primaryItems.index( menuItem ) + 1,
|
||||
totalMenuItems = primaryItems.length,
|
||||
|
||||
// String together help text for primary menu items
|
||||
// String together help text for primary menu items.
|
||||
title = menus.menuFocus.replace( '%1$s', itemName ).replace( '%2$d', itemPosition ).replace( '%3$d', totalMenuItems );
|
||||
} else {
|
||||
parentItem = menuItem.prevAll( '.menu-item-depth-' + parseInt( depth - 1, 10 ) ).first(),
|
||||
@ -503,13 +503,13 @@
|
||||
subItems = $( '.menu-item .menu-item-data-parent-id[value="' + parentItemId + '"]' ),
|
||||
itemPosition = $( subItems.parents('.menu-item').get().reverse() ).index( menuItem ) + 1;
|
||||
|
||||
// String together help text for sub menu items
|
||||
// String together help text for sub menu items.
|
||||
title = menus.subMenuFocus.replace( '%1$s', itemName ).replace( '%2$d', itemPosition ).replace( '%3$s', parentItemName );
|
||||
}
|
||||
|
||||
$this.attr( 'aria-label', title );
|
||||
|
||||
// Mark this item's accessibility as refreshed
|
||||
// Mark this item's accessibility as refreshed.
|
||||
$this.data( 'needs_accessibility_refresh', false );
|
||||
},
|
||||
|
||||
@ -523,10 +523,10 @@
|
||||
// Hide all the move buttons by default.
|
||||
$( '.menu-item-settings .field-move .menus-move' ).hide();
|
||||
|
||||
// Mark all menu items as unprocessed
|
||||
// Mark all menu items as unprocessed.
|
||||
$( 'a.item-edit' ).data( 'needs_accessibility_refresh', true );
|
||||
|
||||
// All open items have to be refreshed or they will show no links
|
||||
// All open items have to be refreshed or they will show no links.
|
||||
$( '.menu-item-edit-active a.item-edit' ).each( function() {
|
||||
api.refreshAdvancedAccessibilityOfItem( this );
|
||||
} );
|
||||
@ -541,18 +541,18 @@
|
||||
thisItem = $this.parents( 'li.menu-item' ),
|
||||
thisItemData = thisItem.getItemData();
|
||||
|
||||
// Bail if it's not an arrow key
|
||||
// Bail if it's not an arrow key.
|
||||
if ( 37 != e.which && 38 != e.which && 39 != e.which && 40 != e.which )
|
||||
return;
|
||||
|
||||
// Avoid multiple keydown events
|
||||
// Avoid multiple keydown events.
|
||||
$this.off('keydown');
|
||||
|
||||
// Bail if there is only one menu item
|
||||
// Bail if there is only one menu item.
|
||||
if ( 1 === $('#menu-to-edit li').length )
|
||||
return;
|
||||
|
||||
// If RTL, swap left/right arrows
|
||||
// If RTL, swap left/right arrows.
|
||||
arrows = { '38': 'up', '40': 'down', '37': 'left', '39': 'right' };
|
||||
if ( $('body').hasClass('rtl') )
|
||||
arrows = { '38' : 'up', '40' : 'down', '39' : 'left', '37' : 'right' };
|
||||
@ -571,7 +571,7 @@
|
||||
api.moveMenuItem( $this, 'right' );
|
||||
break;
|
||||
}
|
||||
// Put focus back on same menu item
|
||||
// Put focus back on same menu item.
|
||||
$( '#edit-' + thisItemData['menu-item-db-id'] ).focus();
|
||||
return false;
|
||||
});
|
||||
@ -594,10 +594,10 @@
|
||||
},
|
||||
|
||||
initToggles : function() {
|
||||
// init postboxes
|
||||
// Init postboxes.
|
||||
postboxes.add_postbox_toggles('nav-menus');
|
||||
|
||||
// adjust columns functions for menus UI
|
||||
// Adjust columns functions for menus UI.
|
||||
columns.useCheckboxesForHidden();
|
||||
columns.checked = function(field) {
|
||||
$('.field-' + field).removeClass('hidden-field');
|
||||
@ -605,7 +605,7 @@
|
||||
columns.unchecked = function(field) {
|
||||
$('.field-' + field).addClass('hidden-field');
|
||||
};
|
||||
// hide fields
|
||||
// Hide fields.
|
||||
api.menuList.hideAdvancedMenuItemFields();
|
||||
|
||||
$('.hide-postbox-tog').click(function () {
|
||||
@ -639,7 +639,7 @@
|
||||
start: function(e, ui) {
|
||||
var height, width, parent, children, tempHolder;
|
||||
|
||||
// handle placement for rtl orientation
|
||||
// Handle placement for RTL orientation.
|
||||
if ( api.isRTL )
|
||||
ui.item[0].style.right = 'auto';
|
||||
|
||||
@ -649,19 +649,19 @@
|
||||
originalDepth = ui.item.menuItemDepth();
|
||||
updateCurrentDepth(ui, originalDepth);
|
||||
|
||||
// Attach child elements to parent
|
||||
// Skip the placeholder
|
||||
// Attach child elements to parent.
|
||||
// Skip the placeholder.
|
||||
parent = ( ui.item.next()[0] == ui.placeholder[0] ) ? ui.item.next() : ui.item;
|
||||
children = parent.childMenuItems();
|
||||
transport.append( children );
|
||||
|
||||
// Update the height of the placeholder to match the moving item.
|
||||
height = transport.outerHeight();
|
||||
// If there are children, account for distance between top of children and parent
|
||||
// If there are children, account for distance between top of children and parent.
|
||||
height += ( height > 0 ) ? (ui.placeholder.css('margin-top').slice(0, -2) * 1) : 0;
|
||||
height += ui.helper.outerHeight();
|
||||
helperHeight = height;
|
||||
height -= 2; // Subtract 2 for borders
|
||||
height -= 2; // Subtract 2 for borders.
|
||||
ui.placeholder.height(height);
|
||||
|
||||
// Update the width of the placeholder to match the moving item.
|
||||
@ -670,18 +670,18 @@
|
||||
var depth = $(this).menuItemDepth();
|
||||
maxChildDepth = (depth > maxChildDepth) ? depth : maxChildDepth;
|
||||
});
|
||||
width = ui.helper.find('.menu-item-handle').outerWidth(); // Get original width
|
||||
width += api.depthToPx(maxChildDepth - originalDepth); // Account for children
|
||||
width -= 2; // Subtract 2 for borders
|
||||
width = ui.helper.find('.menu-item-handle').outerWidth(); // Get original width.
|
||||
width += api.depthToPx(maxChildDepth - originalDepth); // Account for children.
|
||||
width -= 2; // Subtract 2 for borders.
|
||||
ui.placeholder.width(width);
|
||||
|
||||
// Update the list of menu items.
|
||||
tempHolder = ui.placeholder.next( '.menu-item' );
|
||||
tempHolder.css( 'margin-top', helperHeight + 'px' ); // Set the margin to absorb the placeholder
|
||||
ui.placeholder.detach(); // detach or jQuery UI will think the placeholder is a menu item
|
||||
$(this).sortable( 'refresh' ); // The children aren't sortable. We should let jQ UI know.
|
||||
ui.item.after( ui.placeholder ); // reattach the placeholder.
|
||||
tempHolder.css('margin-top', 0); // reset the margin
|
||||
tempHolder.css( 'margin-top', helperHeight + 'px' ); // Set the margin to absorb the placeholder.
|
||||
ui.placeholder.detach(); // Detach or jQuery UI will think the placeholder is a menu item.
|
||||
$(this).sortable( 'refresh' ); // The children aren't sortable. We should let jQuery UI know.
|
||||
ui.item.after( ui.placeholder ); // Reattach the placeholder.
|
||||
tempHolder.css('margin-top', 0); // Reset the margin.
|
||||
|
||||
// Now that the element is complete, we can update...
|
||||
updateSharedVars(ui);
|
||||
@ -690,31 +690,31 @@
|
||||
var children, subMenuTitle,
|
||||
depthChange = currentDepth - originalDepth;
|
||||
|
||||
// Return child elements to the list
|
||||
// Return child elements to the list.
|
||||
children = transport.children().insertAfter(ui.item);
|
||||
|
||||
// Add "sub menu" description
|
||||
// Add "sub menu" description.
|
||||
subMenuTitle = ui.item.find( '.item-title .is-submenu' );
|
||||
if ( 0 < currentDepth )
|
||||
subMenuTitle.show();
|
||||
else
|
||||
subMenuTitle.hide();
|
||||
|
||||
// Update depth classes
|
||||
// Update depth classes.
|
||||
if ( 0 !== depthChange ) {
|
||||
ui.item.updateDepthClass( currentDepth );
|
||||
children.shiftDepthClass( depthChange );
|
||||
updateMenuMaxDepth( depthChange );
|
||||
}
|
||||
// Register a change
|
||||
// Register a change.
|
||||
api.registerChange();
|
||||
// Update the item data.
|
||||
ui.item.updateParentMenuItemDBId();
|
||||
|
||||
// address sortable's incorrectly-calculated top in opera
|
||||
// Address sortable's incorrectly-calculated top in Opera.
|
||||
ui.item[0].style.top = 0;
|
||||
|
||||
// handle drop placement for rtl orientation
|
||||
// Handle drop placement for rtl orientation.
|
||||
if ( api.isRTL ) {
|
||||
ui.item[0].style.left = 'auto';
|
||||
ui.item[0].style.right = 0;
|
||||
@ -736,9 +736,11 @@
|
||||
edge = api.isRTL ? offset.left + ui.helper.width() : offset.left,
|
||||
depth = api.negateIfRTL * api.pxToDepth( edge - menuEdge );
|
||||
|
||||
// Check and correct if depth is not within range.
|
||||
// Also, if the dragged element is dragged upwards over
|
||||
// an item, shift the placeholder to a child position.
|
||||
/*
|
||||
* Check and correct if depth is not within range.
|
||||
* Also, if the dragged element is dragged upwards over an item,
|
||||
* shift the placeholder to a child position.
|
||||
*/
|
||||
if ( depth > maxDepth || offset.top < ( prevBottom - api.options.targetTolerance ) ) {
|
||||
depth = maxDepth;
|
||||
} else if ( depth < minDepth ) {
|
||||
@ -748,7 +750,7 @@
|
||||
if( depth != currentDepth )
|
||||
updateCurrentDepth(ui, depth);
|
||||
|
||||
// If we overlap the next element, manually shift downwards
|
||||
// If we overlap the next element, manually shift downwards.
|
||||
if( nextThreshold && offset.top + helperHeight > nextThreshold ) {
|
||||
next.after( ui.placeholder );
|
||||
updateSharedVars( ui );
|
||||
@ -955,12 +957,12 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
// Show the ajax spinner
|
||||
// Show the Ajax spinner.
|
||||
$( '.customlinkdiv .spinner' ).addClass( 'is-active' );
|
||||
this.addLinkToMenu( url, label, processMethod, function() {
|
||||
// Remove the ajax spinner
|
||||
// Remove the Ajax spinner.
|
||||
$( '.customlinkdiv .spinner' ).removeClass( 'is-active' );
|
||||
// Set custom link form back to defaults
|
||||
// Set custom link form back to defaults.
|
||||
$('#custom-menu-item-name').val('').blur();
|
||||
$( '#custom-menu-item-url' ).val( '' ).attr( 'placeholder', 'https://' );
|
||||
});
|
||||
@ -997,10 +999,10 @@
|
||||
$.post( ajaxurl, params, function(menuMarkup) {
|
||||
var ins = $('#menu-instructions');
|
||||
|
||||
menuMarkup = $.trim( menuMarkup ); // Trim leading whitespaces
|
||||
menuMarkup = $.trim( menuMarkup ); // Trim leading whitespaces.
|
||||
processMethod(menuMarkup, params);
|
||||
|
||||
// Make it stand out a bit more visually, by adding a fadeIn
|
||||
// Make it stand out a bit more visually, by adding a fadeIn.
|
||||
$( 'li.pending' ).hide().fadeIn('slow');
|
||||
$( '.drag-instructions' ).show();
|
||||
if( ! ins.hasClass( 'menu-instructions-inactive' ) && ins.siblings().length )
|
||||
@ -1051,7 +1053,7 @@
|
||||
return navMenuL10n.saveAlert;
|
||||
};
|
||||
} else {
|
||||
// Make the post boxes read-only, as they can't be used yet
|
||||
// Make the post boxes read-only, as they can't be used yet.
|
||||
$( '#menu-settings-column' ).find( 'input,select' ).end().find( 'a' ).attr( 'href', '#' ).unbind( 'click' );
|
||||
}
|
||||
},
|
||||
@ -1071,7 +1073,7 @@
|
||||
|
||||
wrapper = target.parents('.accordion-section-content').first();
|
||||
|
||||
// upon changing tabs, we want to uncheck all checkboxes
|
||||
// Upon changing tabs, we want to uncheck all checkboxes.
|
||||
$( 'input', wrapper ).prop( 'checked', false );
|
||||
|
||||
$('.tabs-panel-active', wrapper).removeClass('tabs-panel-active').addClass('tabs-panel-inactive');
|
||||
@ -1080,7 +1082,7 @@
|
||||
$('.tabs', wrapper).removeClass('tabs');
|
||||
target.parent().addClass('tabs');
|
||||
|
||||
// select the search bar
|
||||
// Select the search bar.
|
||||
$('.quick-search', wrapper).focus();
|
||||
|
||||
// Hide controls in the search tab if no items found.
|
||||
@ -1193,17 +1195,17 @@
|
||||
var locs = '',
|
||||
menuName = $('#menu-name'),
|
||||
menuNameVal = menuName.val();
|
||||
// Cancel and warn if invalid menu name
|
||||
// Cancel and warn if invalid menu name.
|
||||
if ( ! menuNameVal || ! menuNameVal.replace( /\s+/, '' ) ) {
|
||||
menuName.parent().addClass( 'form-invalid' );
|
||||
return false;
|
||||
}
|
||||
// Copy menu theme locations
|
||||
// Copy menu theme locations.
|
||||
$('#nav-menu-theme-locations select').each(function() {
|
||||
locs += '<input type="hidden" name="' + this.name + '" value="' + $(this).val() + '" />';
|
||||
});
|
||||
$('#update-nav-menu').append( locs );
|
||||
// Update menu item position data
|
||||
// Update menu item position data.
|
||||
api.menuList.find('.menu-item-data-position').val( function(index) { return index + 1; } );
|
||||
window.onbeforeunload = null;
|
||||
|
||||
@ -1211,7 +1213,7 @@
|
||||
},
|
||||
|
||||
eventOnClickMenuDelete : function() {
|
||||
// Delete warning AYS
|
||||
// Delete warning AYS.
|
||||
if ( window.confirm( navMenuL10n.warnDeleteMenu ) ) {
|
||||
window.onbeforeunload = null;
|
||||
return true;
|
||||
@ -1253,7 +1255,7 @@
|
||||
$items.each(function(){
|
||||
$item = $(this);
|
||||
|
||||
// make a unique DB ID number
|
||||
// Make a unique DB ID number.
|
||||
matched = pattern.exec($item.html());
|
||||
|
||||
if ( matched && matched[1] ) {
|
||||
|
@ -90,11 +90,11 @@
|
||||
var o = this.options,
|
||||
tip = this.pointer;
|
||||
|
||||
// Handle document transfer
|
||||
// Handle document transfer.
|
||||
if ( key === 'document' && value !== o.document ) {
|
||||
tip.detach().appendTo( value.body );
|
||||
|
||||
// Handle class change
|
||||
// Handle class change.
|
||||
} else if ( key === 'pointerClass' ) {
|
||||
tip.removeClass( o.pointerClass ).addClass( value );
|
||||
}
|
||||
@ -102,11 +102,11 @@
|
||||
// Call super method.
|
||||
$.Widget.prototype._setOption.apply( this, arguments );
|
||||
|
||||
// Reposition automatically
|
||||
// Reposition automatically.
|
||||
if ( key === 'position' ) {
|
||||
this.reposition();
|
||||
|
||||
// Update content automatically if pointer is open
|
||||
// Update content automatically if pointer is open.
|
||||
} else if ( key === 'content' && this.active ) {
|
||||
this.update();
|
||||
}
|
||||
@ -234,7 +234,7 @@
|
||||
}).show().position($.extend({
|
||||
of: this.element,
|
||||
collision: 'fit none'
|
||||
}, position )); // the object comes before this.options.position so the user can override position.of.
|
||||
}, position )); // The object comes before this.options.position so the user can override position.of.
|
||||
|
||||
this.repoint();
|
||||
},
|
||||
|
@ -20,7 +20,7 @@
|
||||
* @output wp-includes/js/quicktags.js
|
||||
*/
|
||||
|
||||
// new edit toolbar used with permission
|
||||
// New edit toolbar used with permission
|
||||
// by Alex King
|
||||
// http://www.alexking.org/
|
||||
|
||||
@ -52,7 +52,7 @@ window.edToolbar = function(){};
|
||||
/* jshint ignore:end */
|
||||
|
||||
(function(){
|
||||
// private stuff is prefixed with an underscore
|
||||
// Private stuff is prefixed with an underscore.
|
||||
var _domReady = function(func) {
|
||||
var t, i, DOMContentLoaded, _tryReady;
|
||||
|
||||
@ -150,7 +150,7 @@ window.edToolbar = function(){};
|
||||
t.settings = settings;
|
||||
|
||||
if ( id === 'content' && typeof(adminpage) === 'string' && ( adminpage === 'post-new-php' || adminpage === 'post-php' ) ) {
|
||||
// back compat hack :-(
|
||||
// Back compat hack :-(
|
||||
window.edCanvas = canvas;
|
||||
toolbar_id = 'ed_toolbar';
|
||||
} else {
|
||||
@ -168,19 +168,19 @@ window.edToolbar = function(){};
|
||||
canvas.parentNode.insertBefore(tb, canvas);
|
||||
t.toolbar = tb;
|
||||
|
||||
// listen for click events
|
||||
// Listen for click events.
|
||||
onclick = function(e) {
|
||||
e = e || window.event;
|
||||
var target = e.target || e.srcElement, visible = target.clientWidth || target.offsetWidth, i;
|
||||
|
||||
// don't call the callback on pressing the accesskey when the button is not visible
|
||||
// Don't call the callback on pressing the accesskey when the button is not visible.
|
||||
if ( !visible ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// as long as it has the class ed_button, execute the callback
|
||||
// As long as it has the class ed_button, execute the callback.
|
||||
if ( / ed_button /.test(' ' + target.className + ' ') ) {
|
||||
// we have to reassign canvas here
|
||||
// We have to reassign canvas here.
|
||||
t.canvas = canvas = document.getElementById(id);
|
||||
i = target.id.replace(name + '_', '');
|
||||
|
||||
@ -261,7 +261,7 @@ window.edToolbar = function(){};
|
||||
theButtons = {};
|
||||
use = '';
|
||||
|
||||
// set buttons
|
||||
// Set buttons.
|
||||
if ( settings.buttons ) {
|
||||
use = ','+settings.buttons+',';
|
||||
}
|
||||
@ -361,7 +361,7 @@ window.edToolbar = function(){};
|
||||
return;
|
||||
}
|
||||
|
||||
if ( priority === -1 ) { // back-compat
|
||||
if ( priority === -1 ) { // Back-compat.
|
||||
return btn;
|
||||
}
|
||||
|
||||
@ -376,7 +376,7 @@ window.edToolbar = function(){};
|
||||
}
|
||||
|
||||
if ( this.buttonsInitDone ) {
|
||||
this._buttonsInit(); // add the button HTML to all instances toolbars if addButton() was called too late
|
||||
this._buttonsInit(); // Add the button HTML to all instances toolbars if addButton() was called too late.
|
||||
}
|
||||
};
|
||||
|
||||
@ -387,12 +387,12 @@ window.edToolbar = function(){};
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( document.selection ) { //IE
|
||||
if ( document.selection ) { // IE.
|
||||
canvas.focus();
|
||||
sel = document.selection.createRange();
|
||||
sel.text = content;
|
||||
canvas.focus();
|
||||
} else if ( canvas.selectionStart || canvas.selectionStart === 0 ) { // FF, WebKit, Opera
|
||||
} else if ( canvas.selectionStart || canvas.selectionStart === 0 ) { // FF, WebKit, Opera.
|
||||
text = canvas.value;
|
||||
startPos = canvas.selectionStart;
|
||||
endPos = canvas.selectionEnd;
|
||||
@ -420,7 +420,7 @@ window.edToolbar = function(){};
|
||||
return true;
|
||||
};
|
||||
|
||||
// a plain, dumb button
|
||||
// A plain, dumb button.
|
||||
qt.Button = function( id, display, access, title, instance, attr ) {
|
||||
this.id = id;
|
||||
this.display = display;
|
||||
@ -450,7 +450,7 @@ window.edToolbar = function(){};
|
||||
};
|
||||
qt.Button.prototype.callback = function(){};
|
||||
|
||||
// a button that inserts HTML tag
|
||||
// A button that inserts HTML tag.
|
||||
qt.TagButton = function( id, display, tagStart, tagEnd, access, title, instance, attr ) {
|
||||
var t = this;
|
||||
qt.Button.call( t, id, display, access, title, instance, attr );
|
||||
@ -485,7 +485,7 @@ window.edToolbar = function(){};
|
||||
element.setAttribute( 'aria-label', this.attr.ariaLabel );
|
||||
}
|
||||
};
|
||||
// whether a tag is open or not. Returns false if not open, or current open depth of the tag
|
||||
// Whether a tag is open or not. Returns false if not open, or current open depth of the tag.
|
||||
qt.TagButton.prototype.isOpen = function (ed) {
|
||||
var t = this, i = 0, ret = false;
|
||||
if ( ed.openTags ) {
|
||||
@ -501,7 +501,7 @@ window.edToolbar = function(){};
|
||||
qt.TagButton.prototype.callback = function(element, canvas, ed) {
|
||||
var t = this, startPos, endPos, cursorPos, scrollTop, v = canvas.value, l, r, i, sel, endTag = v ? t.tagEnd : '', event;
|
||||
|
||||
if ( document.selection ) { // IE
|
||||
if ( document.selection ) { // IE.
|
||||
canvas.focus();
|
||||
sel = document.selection.createRange();
|
||||
if ( sel.text.length > 0 ) {
|
||||
@ -522,7 +522,7 @@ window.edToolbar = function(){};
|
||||
}
|
||||
}
|
||||
canvas.focus();
|
||||
} else if ( canvas.selectionStart || canvas.selectionStart === 0 ) { // FF, WebKit, Opera
|
||||
} else if ( canvas.selectionStart || canvas.selectionStart === 0 ) { // FF, WebKit, Opera.
|
||||
startPos = canvas.selectionStart;
|
||||
endPos = canvas.selectionEnd;
|
||||
|
||||
@ -532,12 +532,12 @@ window.edToolbar = function(){};
|
||||
|
||||
cursorPos = endPos;
|
||||
scrollTop = canvas.scrollTop;
|
||||
l = v.substring(0, startPos); // left of the selection
|
||||
r = v.substring(endPos, v.length); // right of the selection
|
||||
i = v.substring(startPos, endPos); // inside the selection
|
||||
l = v.substring(0, startPos); // Left of the selection.
|
||||
r = v.substring(endPos, v.length); // Right of the selection.
|
||||
i = v.substring(startPos, endPos); // Inside the selection.
|
||||
if ( startPos !== endPos ) {
|
||||
if ( !t.tagEnd ) {
|
||||
canvas.value = l + i + t.tagStart + r; // insert self closing tags after the selection
|
||||
canvas.value = l + i + t.tagStart + r; // Insert self-closing tags after the selection.
|
||||
cursorPos += t.tagStart.length;
|
||||
} else {
|
||||
canvas.value = l + t.tagStart + i + endTag + r;
|
||||
@ -562,7 +562,7 @@ window.edToolbar = function(){};
|
||||
canvas.selectionEnd = cursorPos;
|
||||
canvas.scrollTop = scrollTop;
|
||||
canvas.focus();
|
||||
} else { // other browsers?
|
||||
} else { // Other browsers?
|
||||
if ( !endTag ) {
|
||||
canvas.value += t.tagStart;
|
||||
} else if ( t.isOpen(ed) !== false ) {
|
||||
@ -584,10 +584,10 @@ window.edToolbar = function(){};
|
||||
}
|
||||
};
|
||||
|
||||
// removed
|
||||
// Removed.
|
||||
qt.SpellButton = function() {};
|
||||
|
||||
// the close tags button
|
||||
// The close tags button.
|
||||
qt.CloseButton = function() {
|
||||
qt.Button.call( this, 'close', quicktagsL10n.closeTags, '', quicktagsL10n.closeAllOpenTags );
|
||||
};
|
||||
@ -621,7 +621,7 @@ window.edToolbar = function(){};
|
||||
}
|
||||
};
|
||||
|
||||
// the link button
|
||||
// The link button.
|
||||
qt.LinkButton = function() {
|
||||
var attr = {
|
||||
ariaLabel: quicktagsL10n.link
|
||||
@ -653,7 +653,7 @@ window.edToolbar = function(){};
|
||||
}
|
||||
};
|
||||
|
||||
// the img button
|
||||
// The img button.
|
||||
qt.ImgButton = function() {
|
||||
var attr = {
|
||||
ariaLabel: quicktagsL10n.image
|
||||
@ -704,14 +704,14 @@ window.edToolbar = function(){};
|
||||
c.focus();
|
||||
};
|
||||
|
||||
// ensure backward compatibility
|
||||
// Ensure backward compatibility.
|
||||
edButtons[10] = new qt.TagButton( 'strong', 'b', '<strong>', '</strong>', '', '', '', { ariaLabel: quicktagsL10n.strong, ariaLabelClose: quicktagsL10n.strongClose } );
|
||||
edButtons[20] = new qt.TagButton( 'em', 'i', '<em>', '</em>', '', '', '', { ariaLabel: quicktagsL10n.em, ariaLabelClose: quicktagsL10n.emClose } );
|
||||
edButtons[30] = new qt.LinkButton(); // special case
|
||||
edButtons[30] = new qt.LinkButton(); // Special case.
|
||||
edButtons[40] = new qt.TagButton( 'block', 'b-quote', '\n\n<blockquote>', '</blockquote>\n\n', '', '', '', { ariaLabel: quicktagsL10n.blockquote, ariaLabelClose: quicktagsL10n.blockquoteClose } );
|
||||
edButtons[50] = new qt.TagButton( 'del', 'del', '<del datetime="' + _datetime + '">', '</del>', '', '', '', { ariaLabel: quicktagsL10n.del, ariaLabelClose: quicktagsL10n.delClose } );
|
||||
edButtons[60] = new qt.TagButton( 'ins', 'ins', '<ins datetime="' + _datetime + '">', '</ins>', '', '', '', { ariaLabel: quicktagsL10n.ins, ariaLabelClose: quicktagsL10n.insClose } );
|
||||
edButtons[70] = new qt.ImgButton(); // special case
|
||||
edButtons[70] = new qt.ImgButton(); // Special case.
|
||||
edButtons[80] = new qt.TagButton( 'ul', 'ul', '<ul>\n', '</ul>\n\n', '', '', '', { ariaLabel: quicktagsL10n.ul, ariaLabelClose: quicktagsL10n.ulClose } );
|
||||
edButtons[90] = new qt.TagButton( 'ol', 'ol', '<ol>\n', '</ol>\n\n', '', '', '', { ariaLabel: quicktagsL10n.ol, ariaLabelClose: quicktagsL10n.olClose } );
|
||||
edButtons[100] = new qt.TagButton( 'li', 'li', '\t<li>', '</li>\n', '', '', '', { ariaLabel: quicktagsL10n.li, ariaLabelClose: quicktagsL10n.liClose } );
|
||||
|
77
src/js/_enqueues/vendor/plupload/handlers.js
vendored
77
src/js/_enqueues/vendor/plupload/handlers.js
vendored
@ -1,18 +1,18 @@
|
||||
/* global plupload, pluploadL10n, ajaxurl, post_id, wpUploaderInit, deleteUserSetting, setUserSetting, getUserSetting, shortform */
|
||||
var topWin = window.dialogArguments || opener || parent || top, uploader, uploader_init;
|
||||
|
||||
// progress and success handlers for media multi uploads
|
||||
// Progress and success handlers for media multi uploads.
|
||||
function fileQueued( fileObj ) {
|
||||
// Get rid of unused form
|
||||
// Get rid of unused form.
|
||||
jQuery( '.media-blank' ).remove();
|
||||
|
||||
var items = jQuery( '#media-items' ).children(), postid = post_id || 0;
|
||||
|
||||
// Collapse a single item
|
||||
// Collapse a single item.
|
||||
if ( items.length == 1 ) {
|
||||
items.removeClass( 'open' ).find( '.slidetoggle' ).slideUp( 200 );
|
||||
}
|
||||
// Create a progress bar containing the filename
|
||||
// Create a progress bar containing the filename.
|
||||
jQuery( '<div class="media-item">' )
|
||||
.attr( 'id', 'media-item-' + fileObj.id )
|
||||
.addClass( 'child-of-' + postid )
|
||||
@ -20,7 +20,7 @@ function fileQueued( fileObj ) {
|
||||
jQuery( '<div class="filename original">' ).text( ' ' + fileObj.name ) )
|
||||
.appendTo( jQuery( '#media-items' ) );
|
||||
|
||||
// Disable submit
|
||||
// Disable submit.
|
||||
jQuery( '#insert-gallery' ).prop( 'disabled', true );
|
||||
}
|
||||
|
||||
@ -40,27 +40,27 @@ function uploadProgress( up, file ) {
|
||||
jQuery( '.percent', item ).html( file.percent + '%' );
|
||||
}
|
||||
|
||||
// check to see if a large file failed to upload
|
||||
// Check to see if a large file failed to upload.
|
||||
function fileUploading( up, file ) {
|
||||
var hundredmb = 100 * 1024 * 1024,
|
||||
max = parseInt( up.settings.max_file_size, 10 );
|
||||
|
||||
if ( max > hundredmb && file.size > hundredmb ) {
|
||||
setTimeout( function() {
|
||||
if ( file.status < 3 && file.loaded === 0 ) { // not uploading
|
||||
if ( file.status < 3 && file.loaded === 0 ) { // Not uploading.
|
||||
wpFileError( file, pluploadL10n.big_upload_failed.replace( '%1$s', '<a class="uploader-html" href="#">' ).replace( '%2$s', '</a>' ) );
|
||||
up.stop(); // stops the whole queue
|
||||
up.stop(); // Stop the whole queue.
|
||||
up.removeFile( file );
|
||||
up.start(); // restart the queue
|
||||
up.start(); // Restart the queue.
|
||||
}
|
||||
}, 10000 ); // wait for 10 sec. for the file to start uploading
|
||||
}, 10000 ); // Wait for 10 seconds for the file to start uploading.
|
||||
}
|
||||
}
|
||||
|
||||
function updateMediaForm() {
|
||||
var items = jQuery( '#media-items' ).children();
|
||||
|
||||
// Just one file, no need for collapsible part
|
||||
// Just one file, no need for collapsible part.
|
||||
if ( items.length == 1 ) {
|
||||
items.addClass( 'open' ).find( '.slidetoggle' ).show();
|
||||
jQuery( '.insert-gallery' ).hide();
|
||||
@ -80,11 +80,12 @@ function updateMediaForm() {
|
||||
function uploadSuccess( fileObj, serverData ) {
|
||||
var item = jQuery( '#media-item-' + fileObj.id );
|
||||
|
||||
// on success serverData should be numeric, fix bug in html4 runtime returning the serverData wrapped in a <pre> tag
|
||||
// On success serverData should be numeric,
|
||||
// fix bug in html4 runtime returning the serverData wrapped in a <pre> tag.
|
||||
if ( typeof serverData === 'string' ) {
|
||||
serverData = serverData.replace( /^<pre>(\d+)<\/pre>$/, '$1' );
|
||||
|
||||
// if async-upload returned an error message, place it in the media item div and return
|
||||
// If async-upload returned an error message, place it in the media item div and return.
|
||||
if ( /media-upload-error|error-div/.test( serverData ) ) {
|
||||
item.html( serverData );
|
||||
return;
|
||||
@ -129,25 +130,27 @@ function prepareMediaItem( fileObj, serverData ) {
|
||||
topWin.jQuery( '#TB_overlay' ).click( topWin.tb_remove );
|
||||
} catch( e ){}
|
||||
|
||||
if ( isNaN( serverData ) || !serverData ) { // Old style: Append the HTML returned by the server -- thumbnail and form inputs
|
||||
if ( isNaN( serverData ) || !serverData ) {
|
||||
// Old style: Append the HTML returned by the server -- thumbnail and form inputs.
|
||||
item.append( serverData );
|
||||
prepareMediaItemInit( fileObj );
|
||||
} else { // New style: server data is just the attachment ID, fetch the thumbnail and form html from the server
|
||||
} else {
|
||||
// New style: server data is just the attachment ID, fetch the thumbnail and form html from the server.
|
||||
item.load( 'async-upload.php', {attachment_id:serverData, fetch:f}, function(){prepareMediaItemInit( fileObj );updateMediaForm();});
|
||||
}
|
||||
}
|
||||
|
||||
function prepareMediaItemInit( fileObj ) {
|
||||
var item = jQuery( '#media-item-' + fileObj.id );
|
||||
// Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename
|
||||
// Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename.
|
||||
jQuery( '.thumbnail', item ).clone().attr( 'class', 'pinkynail toggle' ).prependTo( item );
|
||||
|
||||
// Replace the original filename with the new (unique) one assigned during upload
|
||||
// Replace the original filename with the new (unique) one assigned during upload.
|
||||
jQuery( '.filename.original', item ).replaceWith( jQuery( '.filename.new', item ) );
|
||||
|
||||
// Bind AJAX to the new Delete button
|
||||
// Bind AJAX to the new Delete button.
|
||||
jQuery( 'a.delete', item ).click( function(){
|
||||
// Tell the server to delete it. TODO: handle exceptions
|
||||
// Tell the server to delete it. TODO: Handle exceptions.
|
||||
jQuery.ajax({
|
||||
url: ajaxurl,
|
||||
type: 'post',
|
||||
@ -163,9 +166,9 @@ function prepareMediaItemInit( fileObj ) {
|
||||
return false;
|
||||
});
|
||||
|
||||
// Bind AJAX to the new Undo button
|
||||
// Bind AJAX to the new Undo button.
|
||||
jQuery( 'a.undo', item ).click( function(){
|
||||
// Tell the server to untrash it. TODO: handle exceptions
|
||||
// Tell the server to untrash it. TODO: Handle exceptions.
|
||||
jQuery.ajax({
|
||||
url: ajaxurl,
|
||||
type: 'post',
|
||||
@ -195,16 +198,16 @@ function prepareMediaItemInit( fileObj ) {
|
||||
return false;
|
||||
});
|
||||
|
||||
// Open this item if it says to start open (e.g. to display an error)
|
||||
// Open this item if it says to start open (e.g. to display an error).
|
||||
jQuery( '#media-item-' + fileObj.id + '.startopen' ).removeClass( 'startopen' ).addClass( 'open' ).find( 'slidetoggle' ).fadeIn();
|
||||
}
|
||||
|
||||
// generic error message
|
||||
// Generic error message.
|
||||
function wpQueueError( message ) {
|
||||
jQuery( '#media-upload-error' ).show().html( '<div class="error"><p>' + message + '</p></div>' );
|
||||
}
|
||||
|
||||
// file-specific error messages
|
||||
// File-specific error messages.
|
||||
function wpFileError( fileObj, message ) {
|
||||
itemAjaxError( fileObj.id, message );
|
||||
}
|
||||
@ -212,7 +215,7 @@ function wpFileError( fileObj, message ) {
|
||||
function itemAjaxError( id, message ) {
|
||||
var item = jQuery( '#media-item-' + id ), filename = item.find( '.filename' ).text(), last_err = item.data( 'last-err' );
|
||||
|
||||
if ( last_err == id ) // prevent firing an error for the same file twice
|
||||
if ( last_err == id ) // Prevent firing an error for the same file twice.
|
||||
return;
|
||||
|
||||
item.html( '<div class="error-div">' +
|
||||
@ -274,7 +277,7 @@ function switchUploader( s ) {
|
||||
if ( typeof( uploader ) == 'object' )
|
||||
uploader.refresh();
|
||||
} else {
|
||||
setUserSetting( 'uploader', '1' ); // 1 == html uploader
|
||||
setUserSetting( 'uploader', '1' ); // 1 == html uploader.
|
||||
jQuery( '.media-upload-form' ).addClass( 'html-uploader' );
|
||||
}
|
||||
}
|
||||
@ -365,7 +368,7 @@ jQuery( document ).ready( function( $ ) {
|
||||
$( '.media-upload-form' ).bind( 'click.uploader', function( e ) {
|
||||
var target = $( e.target ), tr, c;
|
||||
|
||||
if ( target.is( 'input[type="radio"]' ) ) { // remember the last used image size and alignment
|
||||
if ( target.is( 'input[type="radio"]' ) ) { // Remember the last used image size and alignment.
|
||||
tr = target.closest( 'tr' );
|
||||
|
||||
if ( tr.hasClass( 'align' ) )
|
||||
@ -373,7 +376,7 @@ jQuery( document ).ready( function( $ ) {
|
||||
else if ( tr.hasClass( 'image-size' ) )
|
||||
setUserSetting( 'imgsize', target.val() );
|
||||
|
||||
} else if ( target.is( 'button.button' ) ) { // remember the last used image link url
|
||||
} else if ( target.is( 'button.button' ) ) { // Remember the last used image link url.
|
||||
c = e.target.className || '';
|
||||
c = c.match( /url([^ '"]+)/ );
|
||||
|
||||
@ -385,15 +388,15 @@ jQuery( document ).ready( function( $ ) {
|
||||
target.parents( '.media-item' ).fadeOut( 200, function() {
|
||||
$( this ).remove();
|
||||
} );
|
||||
} else if ( target.is( '.upload-flash-bypass a' ) || target.is( 'a.uploader-html' ) ) { // switch uploader to html4
|
||||
} else if ( target.is( '.upload-flash-bypass a' ) || target.is( 'a.uploader-html' ) ) { // Switch uploader to html4.
|
||||
$( '#media-items, p.submit, span.big-file-warning' ).css( 'display', 'none' );
|
||||
switchUploader( 0 );
|
||||
e.preventDefault();
|
||||
} else if ( target.is( '.upload-html-bypass a' ) ) { // switch uploader to multi-file
|
||||
} else if ( target.is( '.upload-html-bypass a' ) ) { // Switch uploader to multi-file.
|
||||
$( '#media-items, p.submit, span.big-file-warning' ).css( 'display', '' );
|
||||
switchUploader( 1 );
|
||||
e.preventDefault();
|
||||
} else if ( target.is( 'a.describe-toggle-on' ) ) { // Show
|
||||
} else if ( target.is( 'a.describe-toggle-on' ) ) { // Show.
|
||||
target.parent().addClass( 'open' );
|
||||
target.siblings( '.slidetoggle' ).fadeIn( 250, function() {
|
||||
var S = $( window ).scrollTop(),
|
||||
@ -417,7 +420,7 @@ jQuery( document ).ready( function( $ ) {
|
||||
} );
|
||||
|
||||
e.preventDefault();
|
||||
} else if ( target.is( 'a.describe-toggle-off' ) ) { // Hide
|
||||
} else if ( target.is( 'a.describe-toggle-off' ) ) { // Hide.
|
||||
target.siblings( '.slidetoggle' ).fadeOut( 250, function() {
|
||||
target.parent().removeClass( 'open' );
|
||||
} );
|
||||
@ -450,9 +453,11 @@ jQuery( document ).ready( function( $ ) {
|
||||
times = tryAgainCount[ file.id ];
|
||||
|
||||
if ( times && times > 4 ) {
|
||||
// The file may have been uploaded and attachment post created,
|
||||
// but post-processing and resizing failed...
|
||||
// Do a cleanup then tell the user to scale down the image and upload it again.
|
||||
/*
|
||||
* The file may have been uploaded and attachment post created,
|
||||
* but post-processing and resizing failed...
|
||||
* Do a cleanup then tell the user to scale down the image and upload it again.
|
||||
*/
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: ajaxurl,
|
||||
@ -514,7 +519,7 @@ jQuery( document ).ready( function( $ ) {
|
||||
});
|
||||
}
|
||||
|
||||
// init and set the uploader
|
||||
// Init and set the uploader.
|
||||
uploader_init = function() {
|
||||
uploader = new plupload.Uploader( wpUploaderInit );
|
||||
|
||||
|
42
src/js/_enqueues/vendor/plupload/wp-plupload.js
vendored
42
src/js/_enqueues/vendor/plupload/wp-plupload.js
vendored
@ -33,7 +33,7 @@ window.wp = window.wp || {};
|
||||
*/
|
||||
Uploader = function( options ) {
|
||||
var self = this,
|
||||
isIE, // not used, back-compat
|
||||
isIE, // Not used, back-compat.
|
||||
elements = {
|
||||
container: 'container',
|
||||
browser: 'browse_button',
|
||||
@ -60,10 +60,12 @@ window.wp = window.wp || {};
|
||||
this.plupload = $.extend( true, { multipart_params: {} }, Uploader.defaults );
|
||||
this.container = document.body; // Set default container.
|
||||
|
||||
// Extend the instance with options.
|
||||
//
|
||||
// Use deep extend to allow options.plupload to override individual
|
||||
// default plupload keys.
|
||||
/*
|
||||
* Extend the instance with options.
|
||||
*
|
||||
* Use deep extend to allow options.plupload to override individual
|
||||
* default plupload keys.
|
||||
*/
|
||||
$.extend( true, this, options );
|
||||
|
||||
// Proxy all methods so this always refers to the current instance.
|
||||
@ -138,9 +140,11 @@ window.wp = window.wp || {};
|
||||
times = tryAgainCount[ file.id ];
|
||||
|
||||
if ( times && times > 4 ) {
|
||||
// The file may have been uploaded and attachment post created,
|
||||
// but post-processing and resizing failed...
|
||||
// Do a cleanup then tell the user to scale down the image and upload it again.
|
||||
/*
|
||||
* The file may have been uploaded and attachment post created,
|
||||
* but post-processing and resizing failed...
|
||||
* Do a cleanup then tell the user to scale down the image and upload it again.
|
||||
*/
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: ajaxurl,
|
||||
@ -238,7 +242,7 @@ window.wp = window.wp || {};
|
||||
fileUploaded = function( up, file, response ) {
|
||||
var complete;
|
||||
|
||||
// Remove the "uploading" UI elements
|
||||
// Remove the "uploading" UI elements.
|
||||
_.each( ['file','loaded','size','percent'], function( key ) {
|
||||
file.attachment.unset( key );
|
||||
} );
|
||||
@ -295,11 +299,13 @@ window.wp = window.wp || {};
|
||||
});
|
||||
|
||||
dropzone.bind('dragleave.wp-uploader, drop.wp-uploader', function() {
|
||||
// Using an instant timer prevents the drag-over class from
|
||||
// being quickly removed and re-added when elements inside the
|
||||
// dropzone are repositioned.
|
||||
//
|
||||
// @see https://core.trac.wordpress.org/ticket/21705
|
||||
/*
|
||||
* Using an instant timer prevents the drag-over class
|
||||
* from being quickly removed and re-added when elements
|
||||
* inside the dropzone are repositioned.
|
||||
*
|
||||
* @see https://core.trac.wordpress.org/ticket/21705
|
||||
*/
|
||||
timer = setTimeout( function() {
|
||||
active = false;
|
||||
dropzone.trigger('dropzone:leave').removeClass('drag-over');
|
||||
@ -513,9 +519,11 @@ window.wp = window.wp || {};
|
||||
node = node.parentNode;
|
||||
}
|
||||
|
||||
// If the browser node is not attached to the DOM, use a
|
||||
// temporary container to house it, as the browser button
|
||||
// shims require the button to exist in the DOM at all times.
|
||||
/*
|
||||
* If the browser node is not attached to the DOM,
|
||||
* use a temporary container to house it, as the browser button shims
|
||||
* require the button to exist in the DOM at all times.
|
||||
*/
|
||||
if ( ! attached ) {
|
||||
id = 'wp-uploader-browser-' + this.uploader.id;
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
||||
this.add = function (callback, scope, prepend) {
|
||||
log('<target>.on' + newEventName + ".add(..)");
|
||||
|
||||
// Convert callback({arg1:x, arg2:x}) -> callback(arg1, arg2)
|
||||
// Convert callback({arg1:x, arg2:x}) -> callback(arg1, arg2).
|
||||
function patchedEventCallback(e) {
|
||||
var callbackArgs = [];
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* global getUserSetting, setUserSetting */
|
||||
( function( tinymce ) {
|
||||
// Set the minimum value for the modals z-index higher than #wpadminbar (100000)
|
||||
// Set the minimum value for the modals z-index higher than #wpadminbar (100000).
|
||||
if ( ! tinymce.ui.FloatPanel.zIndex || tinymce.ui.FloatPanel.zIndex < 100100 ) {
|
||||
tinymce.ui.FloatPanel.zIndex = 100100;
|
||||
}
|
||||
@ -88,7 +88,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
}
|
||||
});
|
||||
|
||||
// Hide the toolbars after loading
|
||||
// Hide the toolbars after loading.
|
||||
editor.on( 'PostRender', function() {
|
||||
if ( editor.getParam( 'wordpress_adv_hidden', true ) && getUserSetting( 'hidetb', '0' ) === '0' ) {
|
||||
toggleToolbars( 'hide' );
|
||||
@ -191,7 +191,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
}
|
||||
});
|
||||
|
||||
// Display the tag name instead of img in element path
|
||||
// Display the tag name instead of img in element path.
|
||||
editor.on( 'ResolveName', function( event ) {
|
||||
var attr;
|
||||
|
||||
@ -200,7 +200,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
}
|
||||
});
|
||||
|
||||
// Register commands
|
||||
// Register commands.
|
||||
editor.addCommand( 'WP_More', function( tag ) {
|
||||
var parent, html, title,
|
||||
classname = 'wp-more-tag',
|
||||
@ -215,13 +215,13 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
html = '<img src="' + tinymce.Env.transparentSrc + '" alt="" title="' + title + '" class="' + classname + '" ' +
|
||||
'data-wp-more="' + tag + '" data-mce-resize="false" data-mce-placeholder="1" />';
|
||||
|
||||
// Most common case
|
||||
// Most common case.
|
||||
if ( node === rootNode || ( node.nodeName === 'P' && node.parentNode === rootNode ) ) {
|
||||
editor.insertContent( html );
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the top level parent node
|
||||
// Get the top level parent node.
|
||||
parent = dom.getParent( node, function( found ) {
|
||||
if ( found.parentNode && found.parentNode === rootNode ) {
|
||||
return true;
|
||||
@ -328,7 +328,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
|
||||
html = '<div class="wp-editor-help">';
|
||||
|
||||
// Main section, default and additional shortcuts
|
||||
// Main section, default and additional shortcuts.
|
||||
html = html +
|
||||
'<h2>' + __( 'Default shortcuts,' ) + ' ' + meta + '</h2>' +
|
||||
'<table class="wp-help-th-center fixed">' +
|
||||
@ -342,7 +342,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
'</table>';
|
||||
|
||||
if ( editor.plugins.wptextpattern && ( ! tinymce.Env.ie || tinymce.Env.ie > 8 ) ) {
|
||||
// Text pattern section
|
||||
// Text pattern section.
|
||||
html = html +
|
||||
'<h2>' + __( 'When starting a new paragraph with one of these formatting shortcuts followed by a space, the formatting will be applied automatically. Press Backspace or Escape to undo.' ) + '</h2>' +
|
||||
'<table class="wp-help-th-center fixed">' +
|
||||
@ -363,7 +363,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
'</table>';
|
||||
}
|
||||
|
||||
// Focus management section
|
||||
// Focus management section.
|
||||
html = html +
|
||||
'<h2>' + __( 'Focus shortcuts:' ) + '</h2>' +
|
||||
'<table class="wp-help-single">' +
|
||||
@ -413,7 +413,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
}
|
||||
});
|
||||
|
||||
// Register buttons
|
||||
// Register buttons.
|
||||
editor.addButton( 'wp_more', {
|
||||
tooltip: 'Insert Read More tag',
|
||||
onclick: function() {
|
||||
@ -439,7 +439,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
stateSelector: 'code'
|
||||
});
|
||||
|
||||
// Insert->Add Media
|
||||
// Insert->Add Media.
|
||||
if ( wp && wp.media && wp.media.editor ) {
|
||||
editor.addButton( 'wp_add_media', {
|
||||
tooltip: 'Add Media',
|
||||
@ -455,7 +455,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
});
|
||||
}
|
||||
|
||||
// Insert "Read More..."
|
||||
// Insert "Read More...".
|
||||
editor.addMenuItem( 'wp_more', {
|
||||
text: 'Insert Read More tag',
|
||||
icon: 'wp_more',
|
||||
@ -465,7 +465,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
}
|
||||
});
|
||||
|
||||
// Insert "Next Page"
|
||||
// Insert "Next Page".
|
||||
editor.addMenuItem( 'wp_page', {
|
||||
text: 'Page break',
|
||||
icon: 'wp_page',
|
||||
@ -496,7 +496,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
|
||||
editor.on( 'init', function() {
|
||||
var env = tinymce.Env,
|
||||
bodyClass = ['mceContentBody'], // back-compat for themes that use this in editor-style.css...
|
||||
bodyClass = ['mceContentBody'], // Back-compat for themes that use this in editor-style.css...
|
||||
doc = editor.getDoc(),
|
||||
dom = editor.dom;
|
||||
|
||||
@ -531,7 +531,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
}
|
||||
});
|
||||
|
||||
// Remove invalid parent paragraphs when inserting HTML
|
||||
// Remove invalid parent paragraphs when inserting HTML.
|
||||
editor.on( 'BeforeSetContent', function( event ) {
|
||||
if ( event.content ) {
|
||||
event.content = event.content.replace( /<p>\s*<(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre)( [^>]*)?>/gi, '<$1$2>' )
|
||||
@ -554,21 +554,21 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
|
||||
if ( editor.getParam( 'wp_paste_filters', true ) ) {
|
||||
editor.on( 'PastePreProcess', function( event ) {
|
||||
// Remove trailing <br> added by WebKit browsers to the clipboard
|
||||
// Remove trailing <br> added by WebKit browsers to the clipboard.
|
||||
event.content = event.content.replace( /<br class="?Apple-interchange-newline"?>/gi, '' );
|
||||
|
||||
// In WebKit this is handled by removeWebKitStyles()
|
||||
// In WebKit this is handled by removeWebKitStyles().
|
||||
if ( ! tinymce.Env.webkit ) {
|
||||
// Remove all inline styles
|
||||
// Remove all inline styles.
|
||||
event.content = event.content.replace( /(<[^>]+) style="[^"]*"([^>]*>)/gi, '$1$2' );
|
||||
|
||||
// Put back the internal styles
|
||||
// Put back the internal styles.
|
||||
event.content = event.content.replace(/(<[^>]+) data-mce-style=([^>]+>)/gi, '$1 style=$2' );
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'PastePostProcess', function( event ) {
|
||||
// Remove empty paragraphs
|
||||
// Remove empty paragraphs.
|
||||
editor.$( 'p', event.node ).each( function( i, node ) {
|
||||
if ( dom.isEmpty( node ) ) {
|
||||
dom.remove( node );
|
||||
@ -585,7 +585,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
});
|
||||
|
||||
editor.on( 'SaveContent', function( event ) {
|
||||
// If editor is hidden, we just want the textarea's value to be saved
|
||||
// If editor is hidden, we just want the textarea's value to be saved.
|
||||
if ( ! editor.inline && editor.isHidden() ) {
|
||||
event.content = event.element.value;
|
||||
return;
|
||||
@ -700,7 +700,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
|
||||
wpTooltips = {};
|
||||
|
||||
// For MacOS: ctrl = \u2303, cmd = \u2318, alt = \u2325
|
||||
// For MacOS: ctrl = \u2303, cmd = \u2318, alt = \u2325.
|
||||
if ( tinymce.Env.mac ) {
|
||||
access = '\u2303\u2325';
|
||||
meta = '\u2318';
|
||||
@ -761,7 +761,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
}
|
||||
|
||||
function addShortcutsToListbox() {
|
||||
// listbox for the "blocks" drop-down
|
||||
// listbox for the "blocks" drop-down.
|
||||
each( editor.theme.panel.find( 'listbox' ), function( listbox ) {
|
||||
if ( listbox && listbox.settings.text === 'Paragraph' ) {
|
||||
each( listbox.settings.values, function( item ) {
|
||||
@ -1118,9 +1118,11 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
event.type === 'resize' ||
|
||||
event.type === 'scroll'
|
||||
) && ! activeToolbar.blockHide ) {
|
||||
// Showing a tooltip may trigger a `resize` event in Chromium browsers.
|
||||
// That results in a flicketing inline menu; tooltips are shown on hovering over a button,
|
||||
// which then hides the toolbar on `resize`, then it repeats as soon as the toolbar is shown again.
|
||||
/*
|
||||
* Showing a tooltip may trigger a `resize` event in Chromium browsers.
|
||||
* That results in a flicketing inline menu; tooltips are shown on hovering over a button,
|
||||
* which then hides the toolbar on `resize`, then it repeats as soon as the toolbar is shown again.
|
||||
*/
|
||||
if ( event.type === 'resize' || event.type === 'resizewindow' ) {
|
||||
win = editor.getWin();
|
||||
size = win.innerHeight + win.innerWidth;
|
||||
@ -1187,7 +1189,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
|
||||
function noop() {}
|
||||
|
||||
// Expose some functions (back-compat)
|
||||
// Expose some functions (back-compat).
|
||||
return {
|
||||
_showButtons: noop,
|
||||
_hideButtons: noop,
|
||||
|
@ -61,13 +61,13 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
|
||||
if ( ! body || ( e && e.type === 'setcontent' && e.initial ) || isFullscreen() ) {
|
||||
if ( body && docElm ) {
|
||||
body.style.overflowY = 'auto';
|
||||
docElm.style.overflowY = 'auto'; // Old IE
|
||||
docElm.style.overflowY = 'auto'; // Old IE.
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate outer height of the body element using CSS styles
|
||||
// Calculate outer height of the body element using CSS styles.
|
||||
marginTop = editor.dom.getStyle( body, 'margin-top', true );
|
||||
marginBottom = editor.dom.getStyle( body, 'margin-bottom', true );
|
||||
paddingTop = editor.dom.getStyle( body, 'padding-top', true );
|
||||
@ -83,36 +83,36 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
|
||||
myHeight = docElm.offsetHeight;
|
||||
}
|
||||
|
||||
// Make sure we have a valid height
|
||||
// Make sure we have a valid height.
|
||||
if ( isNaN( myHeight ) || myHeight <= 0 ) {
|
||||
// Get height differently depending on the browser used
|
||||
// Get height differently depending on the browser used.
|
||||
myHeight = tinymce.Env.ie ? body.scrollHeight : ( tinymce.Env.webkit && body.clientHeight === 0 ? 0 : body.offsetHeight );
|
||||
}
|
||||
|
||||
// Don't make it smaller than the minimum height
|
||||
// Don't make it smaller than the minimum height.
|
||||
if ( myHeight > settings.autoresize_min_height ) {
|
||||
resizeHeight = myHeight;
|
||||
}
|
||||
|
||||
// If a maximum height has been defined don't exceed this height
|
||||
// If a maximum height has been defined don't exceed this height.
|
||||
if ( settings.autoresize_max_height && myHeight > settings.autoresize_max_height ) {
|
||||
resizeHeight = settings.autoresize_max_height;
|
||||
body.style.overflowY = 'auto';
|
||||
docElm.style.overflowY = 'auto'; // Old IE
|
||||
docElm.style.overflowY = 'auto'; // Old IE.
|
||||
} else {
|
||||
body.style.overflowY = 'hidden';
|
||||
docElm.style.overflowY = 'hidden'; // Old IE
|
||||
docElm.style.overflowY = 'hidden'; // Old IE.
|
||||
body.scrollTop = 0;
|
||||
}
|
||||
|
||||
// Resize content element
|
||||
// Resize content element.
|
||||
if (resizeHeight !== oldSize) {
|
||||
deltaSize = resizeHeight - oldSize;
|
||||
DOM.setStyle( editor.iframeElement, 'height', resizeHeight + 'px' );
|
||||
oldSize = resizeHeight;
|
||||
|
||||
// WebKit doesn't decrease the size of the body element until the iframe gets resized
|
||||
// So we need to continue to resize the iframe down until the size gets fixed
|
||||
// WebKit doesn't decrease the size of the body element until the iframe gets resized.
|
||||
// So we need to continue to resize the iframe down until the size gets fixed.
|
||||
if ( tinymce.isWebKit && deltaSize < 0 ) {
|
||||
resize( e );
|
||||
}
|
||||
@ -137,17 +137,17 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
|
||||
}, interval );
|
||||
}
|
||||
|
||||
// Define minimum height
|
||||
// Define minimum height.
|
||||
settings.autoresize_min_height = parseInt(editor.getParam( 'autoresize_min_height', editor.getElement().offsetHeight), 10 );
|
||||
|
||||
// Define maximum height
|
||||
// Define maximum height.
|
||||
settings.autoresize_max_height = parseInt(editor.getParam( 'autoresize_max_height', 0), 10 );
|
||||
|
||||
function on() {
|
||||
if ( ! editor.dom.hasClass( editor.getBody(), 'wp-autoresize' ) ) {
|
||||
isActive = true;
|
||||
editor.dom.addClass( editor.getBody(), 'wp-autoresize' );
|
||||
// Add appropriate listeners for resizing the content area
|
||||
// Add appropriate listeners for resizing the content area.
|
||||
editor.on( 'nodechange setcontent keyup FullscreenStateChanged', resize );
|
||||
resize();
|
||||
}
|
||||
@ -156,20 +156,20 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
|
||||
function off() {
|
||||
var doc;
|
||||
|
||||
// Don't turn off if the setting is 'on'
|
||||
// Don't turn off if the setting is 'on'.
|
||||
if ( ! settings.wp_autoresize_on ) {
|
||||
isActive = false;
|
||||
doc = editor.getDoc();
|
||||
editor.dom.removeClass( editor.getBody(), 'wp-autoresize' );
|
||||
editor.off( 'nodechange setcontent keyup FullscreenStateChanged', resize );
|
||||
doc.body.style.overflowY = 'auto';
|
||||
doc.documentElement.style.overflowY = 'auto'; // Old IE
|
||||
doc.documentElement.style.overflowY = 'auto'; // Old IE.
|
||||
oldSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( settings.wp_autoresize_on ) {
|
||||
// Turn resizing on when the editor loads
|
||||
// Turn resizing on when the editor loads.
|
||||
isActive = true;
|
||||
|
||||
editor.on( 'init', function() {
|
||||
@ -184,24 +184,24 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
|
||||
|
||||
if ( editor.getParam( 'autoresize_on_init', true ) ) {
|
||||
editor.on( 'init', function() {
|
||||
// Hit it 10 times in 200 ms intervals
|
||||
// Hit it 10 times in 200 ms intervals.
|
||||
wait( 10, 200, function() {
|
||||
// Hit it 5 times in 1 sec intervals
|
||||
// Hit it 5 times in 1 sec intervals.
|
||||
wait( 5, 1000 );
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the stored size
|
||||
// Reset the stored size.
|
||||
editor.on( 'show', function() {
|
||||
oldSize = 0;
|
||||
});
|
||||
|
||||
// Register the command
|
||||
// Register the command.
|
||||
editor.addCommand( 'wpAutoResize', resize );
|
||||
|
||||
// On/off
|
||||
// On/off.
|
||||
editor.addCommand( 'wpAutoResizeOn', on );
|
||||
editor.addCommand( 'wpAutoResizeOff', off );
|
||||
});
|
||||
|
@ -30,7 +30,7 @@ tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) {
|
||||
}
|
||||
|
||||
if ( typeof jQuery === 'undefined' || ! jQuery.wp || ! jQuery.wp.wpdialog ) {
|
||||
// wpdialog.js is not loaded
|
||||
// wpdialog.js is not loaded.
|
||||
if ( window.console && window.console.error ) {
|
||||
window.console.error('wpdialog.js is not loaded. Please set "wpdialogs" as dependency for your script when calling wp_enqueue_script(). You may also want to enqueue the "wp-jquery-ui-dialog" stylesheet.');
|
||||
}
|
||||
@ -54,7 +54,7 @@ tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) {
|
||||
// Store selection. Takes a snapshot in the FocusManager of the selection before focus is moved to the dialog.
|
||||
editor.nodeChanged();
|
||||
|
||||
// Create the dialog if necessary
|
||||
// Create the dialog if necessary.
|
||||
if ( ! $element.data('wpdialog') ) {
|
||||
$element.wpdialog({
|
||||
title: args.title,
|
||||
@ -85,7 +85,7 @@ tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) {
|
||||
};
|
||||
|
||||
tinymce.PluginManager.add( 'wpdialogs', function( editor ) {
|
||||
// Replace window manager
|
||||
// Replace window manager.
|
||||
editor.on( 'init', function() {
|
||||
editor.windowManager = new tinymce.WPWindowManager( editor );
|
||||
});
|
||||
|
@ -18,7 +18,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
} );
|
||||
|
||||
editor.addButton( 'wp_img_edit', {
|
||||
tooltip: 'Edit|button', // '|button' is not displayed, only used for context
|
||||
tooltip: 'Edit|button', // '|button' is not displayed, only used for context.
|
||||
icon: 'dashicon dashicons-edit',
|
||||
onclick: function() {
|
||||
editImage( editor.selection.getNode() );
|
||||
@ -146,7 +146,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
caption = trim( img[2] );
|
||||
img = trim( img[1] );
|
||||
} else {
|
||||
// old captions shortcode style
|
||||
// Old captions shortcode style.
|
||||
caption = trim( b ).replace( /caption=['"]/, '' ).replace( /['"]$/, '' );
|
||||
img = c;
|
||||
}
|
||||
@ -214,18 +214,18 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
}
|
||||
|
||||
caption = caption.replace( /\r\n|\r/g, '\n' ).replace( /<[a-zA-Z0-9]+( [^<>]+)?>/g, function( a ) {
|
||||
// no line breaks inside HTML tags
|
||||
// No line breaks inside HTML tags.
|
||||
return a.replace( /[\r\n\t]+/, ' ' );
|
||||
});
|
||||
|
||||
// convert remaining line breaks to <br>
|
||||
// Convert remaining line breaks to <br>.
|
||||
caption = caption.replace( /\s*\n\s*/g, '<br />' );
|
||||
|
||||
return '[caption id="' + id + '" align="' + align + '" width="' + width + '"' + classes + ']' + c + ' ' + caption + '[/caption]';
|
||||
});
|
||||
|
||||
if ( out.indexOf('[caption') === -1 ) {
|
||||
// the caption html seems broken, try to find the image that may be wrapped in a link
|
||||
// The caption html seems broken, try to find the image that may be wrapped in a link
|
||||
// and may be followed by <p> with the caption text.
|
||||
out = dl.replace( /[\s\S]*?((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)(<p>[\s\S]*<\/p>)?[\s\S]*/gi, '<p>$1</p>$2' );
|
||||
}
|
||||
@ -240,7 +240,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
dom = editor.dom,
|
||||
isIntRegExp = /^\d+$/;
|
||||
|
||||
// default attributes
|
||||
// Default attributes.
|
||||
metadata = {
|
||||
attachment_id: false,
|
||||
size: 'custom',
|
||||
@ -292,7 +292,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
|
||||
metadata.extraClasses = extraClasses.join( ' ' );
|
||||
|
||||
// Extract caption
|
||||
// Extract caption.
|
||||
captionBlock = dom.getParents( imageNode, '.wp-caption' );
|
||||
|
||||
if ( captionBlock.length ) {
|
||||
@ -318,7 +318,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
}
|
||||
}
|
||||
|
||||
// Extract linkTo
|
||||
// Extract linkTo.
|
||||
if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' ) {
|
||||
link = imageNode.parentNode;
|
||||
metadata.linkUrl = dom.getAttrib( link, 'href' );
|
||||
@ -334,7 +334,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
return node && !! ( node.textContent || node.innerText ).replace( /\ufeff/g, '' );
|
||||
}
|
||||
|
||||
// Verify HTML in captions
|
||||
// Verify HTML in captions.
|
||||
function verifyHTML( caption ) {
|
||||
if ( ! caption || ( caption.indexOf( '<' ) === -1 && caption.indexOf( '>' ) === -1 ) ) {
|
||||
return caption;
|
||||
@ -404,7 +404,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
};
|
||||
|
||||
if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' && ! hasTextContent( imageNode.parentNode ) ) {
|
||||
// Update or remove an existing link wrapped around the image
|
||||
// Update or remove an existing link wrapped around the image.
|
||||
if ( imageData.linkUrl ) {
|
||||
dom.setAttribs( imageNode.parentNode, linkAttrs );
|
||||
} else {
|
||||
@ -413,11 +413,11 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
} else if ( imageData.linkUrl ) {
|
||||
if ( linkNode = dom.getParent( imageNode, 'a' ) ) {
|
||||
// The image is inside a link together with other nodes,
|
||||
// or is nested in another node, move it out
|
||||
// or is nested in another node, move it out.
|
||||
dom.insertAfter( imageNode, linkNode );
|
||||
}
|
||||
|
||||
// Add link wrapped around the image
|
||||
// Add link wrapped around the image.
|
||||
linkNode = dom.create( 'a', linkAttrs );
|
||||
imageNode.parentNode.insertBefore( linkNode, imageNode );
|
||||
linkNode.appendChild( imageNode );
|
||||
@ -467,7 +467,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
} else {
|
||||
id = id ? 'id="'+ id +'" ' : '';
|
||||
|
||||
// should create a new function for generating the caption markup
|
||||
// Should create a new function for generating the caption markup.
|
||||
html = '<dl ' + id + 'class="' + className +'" style="width: '+ width +'px">' +
|
||||
'<dt class="wp-caption-dt"></dt><dd class="wp-caption-dd">'+ imageData.caption +'</dd></dl>';
|
||||
|
||||
@ -486,7 +486,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
}
|
||||
}
|
||||
} else if ( captionNode ) {
|
||||
// Remove the caption wrapper and place the image in new paragraph
|
||||
// Remove the caption wrapper and place the image in new paragraph.
|
||||
parent = dom.create( 'p' );
|
||||
captionNode.parentNode.insertBefore( parent, captionNode );
|
||||
parent.appendChild( node );
|
||||
@ -530,7 +530,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
// Mark the image node so we can select it later.
|
||||
editor.$( img ).attr( 'data-wp-editing', 1 );
|
||||
|
||||
// Manipulate the metadata by reference that is fed into the PostImage model used in the media modal
|
||||
// Manipulate the metadata by reference that is fed into the PostImage model used in the media modal.
|
||||
wp.media.events.trigger( 'editor:image-edit', {
|
||||
editor: editor,
|
||||
metadata: metadata,
|
||||
@ -558,9 +558,11 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
editor.focus();
|
||||
frame.detach();
|
||||
|
||||
// `close` fires first...
|
||||
// To be able to update the image node, we need to find it here,
|
||||
// and use it in the callback.
|
||||
/*
|
||||
* `close` fires first...
|
||||
* To be able to update the image node, we need to find it here,
|
||||
* and use it in the callback.
|
||||
*/
|
||||
imageNode = editor.$( 'img[data-wp-editing]' )
|
||||
imageNode.removeAttr( 'data-wp-editing' );
|
||||
});
|
||||
@ -600,12 +602,12 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
|
||||
dom.addClass( editor.getBody(), captionClass );
|
||||
|
||||
// Prevent IE11 from making dl.wp-caption resizable
|
||||
// Prevent IE11 from making dl.wp-caption resizable.
|
||||
if ( tinymce.Env.ie && tinymce.Env.ie > 10 ) {
|
||||
// The 'mscontrolselect' event is supported only in IE11+
|
||||
// The 'mscontrolselect' event is supported only in IE11+.
|
||||
dom.bind( editor.getBody(), 'mscontrolselect', function( event ) {
|
||||
if ( event.target.nodeName === 'IMG' && dom.getParent( event.target, '.wp-caption' ) ) {
|
||||
// Hide the thick border with resize handles around dl.wp-caption
|
||||
// Hide the thick border with resize handles around dl.wp-caption.
|
||||
editor.getBody().focus(); // :(
|
||||
} else if ( event.target.nodeName === 'DL' && dom.hasClass( event.target, 'wp-caption' ) ) {
|
||||
// Trigger the thick border with resize handles...
|
||||
@ -688,25 +690,31 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
if ( cmd === 'mceInsertContent' ) {
|
||||
if ( pasteInCaption ) {
|
||||
pasteInCaption = false;
|
||||
// We are in the caption element, and in 'paste' context,
|
||||
// and the pasted HTML was cleaned up on 'pastePostProcess' above.
|
||||
// Let it be pasted in the caption.
|
||||
/*
|
||||
* We are in the caption element, and in 'paste' context,
|
||||
* and the pasted HTML was cleaned up on 'pastePostProcess' above.
|
||||
* Let it be pasted in the caption.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
// The paste is somewhere else in the caption DL element.
|
||||
// Prevent pasting in there as it will break the caption.
|
||||
// Make new paragraph under the caption DL and move the caret there.
|
||||
/*
|
||||
* The paste is somewhere else in the caption DL element.
|
||||
* Prevent pasting in there as it will break the caption.
|
||||
* Make new paragraph under the caption DL and move the caret there.
|
||||
*/
|
||||
p = dom.create( 'p' );
|
||||
dom.insertAfter( p, captionParent );
|
||||
editor.selection.setCursorLocation( p, 0 );
|
||||
|
||||
// If the image is selected and the user pastes "over" it,
|
||||
// replace both the image and the caption elements with the pasted content.
|
||||
// This matches the behavior when pasting over non-caption images.
|
||||
/*
|
||||
* If the image is selected and the user pastes "over" it,
|
||||
* replace both the image and the caption elements with the pasted content.
|
||||
* This matches the behavior when pasting over non-caption images.
|
||||
*/
|
||||
if ( node.nodeName === 'IMG' ) {
|
||||
editor.$( captionParent ).remove();
|
||||
}
|
||||
editor.$( captionParent ).remove();
|
||||
}
|
||||
|
||||
editor.nodeChanged();
|
||||
} else {
|
||||
@ -759,7 +767,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
VK = tinymce.util.VK;
|
||||
|
||||
if ( keyCode === VK.ENTER ) {
|
||||
// When pressing Enter inside a caption move the caret to a new parapraph under it
|
||||
// When pressing Enter inside a caption move the caret to a new parapraph under it.
|
||||
node = selection.getNode();
|
||||
wrap = dom.getParent( node, 'div.mceTemp' );
|
||||
|
||||
@ -802,9 +810,11 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
}
|
||||
});
|
||||
|
||||
// After undo/redo FF seems to set the image height very slowly when it is set to 'auto' in the CSS.
|
||||
// This causes image.getBoundingClientRect() to return wrong values and the resize handles are shown in wrong places.
|
||||
// Collapse the selection to remove the resize handles.
|
||||
/*
|
||||
* After undo/redo FF seems to set the image height very slowly when it is set to 'auto' in the CSS.
|
||||
* This causes image.getBoundingClientRect() to return wrong values and the resize handles are shown in wrong places.
|
||||
* Collapse the selection to remove the resize handles.
|
||||
*/
|
||||
if ( tinymce.Env.gecko ) {
|
||||
editor.on( 'undo redo', function() {
|
||||
if ( editor.selection.getNode().nodeName === 'IMG' ) {
|
||||
@ -878,7 +888,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
} );
|
||||
} )();
|
||||
|
||||
// Add to editor.wp
|
||||
// Add to editor.wp.
|
||||
editor.wp = editor.wp || {};
|
||||
editor.wp.isPlaceholder = isPlaceholder;
|
||||
|
||||
|
@ -56,18 +56,22 @@
|
||||
}
|
||||
|
||||
if ( isWin8 ) {
|
||||
// Windows 8+ emoji can be "typed" with the onscreen keyboard.
|
||||
// That triggers the normal keyboard events, but not the 'input' event.
|
||||
// Thankfully it sets keyCode 231 when the onscreen keyboard inserts any emoji.
|
||||
/*
|
||||
* Windows 8+ emoji can be "typed" with the onscreen keyboard.
|
||||
* That triggers the normal keyboard events, but not the 'input' event.
|
||||
* Thankfully it sets keyCode 231 when the onscreen keyboard inserts any emoji.
|
||||
*/
|
||||
editor.on( 'keyup', function( event ) {
|
||||
if ( event.keyCode === 231 ) {
|
||||
parseNode( editor.selection.getNode() );
|
||||
}
|
||||
} );
|
||||
} else if ( ! isWin ) {
|
||||
// In MacOS inserting emoji doesn't trigger the stanradr keyboard events.
|
||||
// Thankfully it triggers the 'input' event.
|
||||
// This works in Android and iOS as well.
|
||||
/*
|
||||
* In MacOS inserting emoji doesn't trigger the stanradr keyboard events.
|
||||
* Thankfully it triggers the 'input' event.
|
||||
* This works in Android and iOS as well.
|
||||
*/
|
||||
editor.on( 'keydown keyup', function( event ) {
|
||||
typing = ( event.type === 'keydown' );
|
||||
} );
|
||||
|
@ -57,7 +57,7 @@ tinymce.PluginManager.add('wpgallery', function( editor ) {
|
||||
}
|
||||
}
|
||||
|
||||
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...');
|
||||
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...').
|
||||
editor.addCommand( 'WP_Gallery', function() {
|
||||
editMedia( editor.selection.getNode() );
|
||||
});
|
||||
@ -71,7 +71,7 @@ tinymce.PluginManager.add('wpgallery', function( editor ) {
|
||||
}
|
||||
|
||||
if ( node.nodeName === 'IMG' && dom.getAttrib( node, 'data-wp-media' ) ) {
|
||||
// Don't trigger on right-click
|
||||
// Don't trigger on right-click.
|
||||
if ( event.button !== 2 ) {
|
||||
if ( dom.hasClass( node, 'wp-media-selected' ) ) {
|
||||
editMedia( node );
|
||||
@ -85,7 +85,7 @@ tinymce.PluginManager.add('wpgallery', function( editor ) {
|
||||
}
|
||||
});
|
||||
|
||||
// Display gallery, audio or video instead of img in the element path
|
||||
// Display gallery, audio or video instead of img in the element path.
|
||||
editor.on( 'ResolveName', function( event ) {
|
||||
var dom = editor.dom,
|
||||
node = event.target;
|
||||
@ -98,7 +98,7 @@ tinymce.PluginManager.add('wpgallery', function( editor ) {
|
||||
});
|
||||
|
||||
editor.on( 'BeforeSetContent', function( event ) {
|
||||
// 'wpview' handles the gallery shortcode when present
|
||||
// 'wpview' handles the gallery shortcode when present.
|
||||
if ( ! editor.plugins.wpview || typeof wp === 'undefined' || ! wp.mce ) {
|
||||
event.content = replaceGalleryShortcodes( event.content );
|
||||
}
|
||||
|
@ -37,9 +37,9 @@
|
||||
url = this.url;
|
||||
}
|
||||
|
||||
// If the URL is longer that 40 chars, concatenate the beginning (after the domain) and ending with ...
|
||||
// If the URL is longer that 40 chars, concatenate the beginning (after the domain) and ending with '...'.
|
||||
if ( url.length > 40 && ( index = url.indexOf( '/' ) ) !== -1 && ( lastIndex = url.lastIndexOf( '/' ) ) !== -1 && lastIndex !== index ) {
|
||||
// If the beginning + ending are shorter that 40 chars, show more of the ending
|
||||
// If the beginning + ending are shorter that 40 chars, show more of the ending.
|
||||
if ( index + url.length - lastIndex < 40 ) {
|
||||
lastIndex = -( 40 - ( index + 1 ) );
|
||||
}
|
||||
@ -297,10 +297,10 @@
|
||||
editor.execCommand( 'wp_link_cancel' );
|
||||
} );
|
||||
|
||||
// WP default shortcuts
|
||||
// WP default shortcuts.
|
||||
editor.addShortcut( 'access+a', '', 'WP_Link' );
|
||||
editor.addShortcut( 'access+s', '', 'wp_unlink' );
|
||||
// The "de-facto standard" shortcut, see #27305
|
||||
// The "de-facto standard" shortcut, see #27305.
|
||||
editor.addShortcut( 'meta+k', '', 'WP_Link' );
|
||||
|
||||
editor.addButton( 'link', {
|
||||
@ -565,7 +565,7 @@
|
||||
} );
|
||||
|
||||
editor.addButton( 'wp_link_edit', {
|
||||
tooltip: 'Edit|button', // '|button' is not displayed, only used for context
|
||||
tooltip: 'Edit|button', // '|button' is not displayed, only used for context.
|
||||
icon: 'dashicon dashicons-edit',
|
||||
cmd: 'WP_Link'
|
||||
} );
|
||||
|
@ -149,9 +149,9 @@
|
||||
var before = string.charAt( startOffset - 1 );
|
||||
var after = string.charAt( startOffset + p.delimiter.length );
|
||||
|
||||
// test*test* => format applied
|
||||
// test *test* => applied
|
||||
// test* test* => not applied
|
||||
// test*test* => format applied.
|
||||
// test *test* => applied.
|
||||
// test* test* => not applied.
|
||||
if ( startOffset && /\S/.test( before ) ) {
|
||||
if ( /\s/.test( after ) || before === delimiterFirstChar ) {
|
||||
return;
|
||||
|
@ -52,7 +52,7 @@
|
||||
var className = editor.getBody().className;
|
||||
|
||||
editor.$( 'iframe[class="wpview-sandbox"]' ).each( function( i, iframe ) {
|
||||
// Make sure it is a local iframe
|
||||
// Make sure it is a local iframe.
|
||||
// jshint scripturl: true
|
||||
if ( ! iframe.src || iframe.src === 'javascript:""' ) {
|
||||
try {
|
||||
@ -79,11 +79,11 @@
|
||||
node = editor.selection.getNode();
|
||||
|
||||
if ( node && node !== editor.getBody() && /^\s*https?:\/\/\S+\s*$/i.test( event.content ) ) {
|
||||
// When a url is pasted or inserted, only try to embed it when it is in an empty paragrapgh.
|
||||
// When a url is pasted or inserted, only try to embed it when it is in an empty paragraph.
|
||||
node = editor.dom.getParent( node, 'p' );
|
||||
|
||||
if ( node && /^[\s\uFEFF\u00A0]*$/.test( editor.$( node ).text() || '' ) ) {
|
||||
// Make sure there are no empty inline elements in the <p>
|
||||
// Make sure there are no empty inline elements in the <p>.
|
||||
node.innerHTML = '';
|
||||
} else {
|
||||
return;
|
||||
@ -178,7 +178,7 @@
|
||||
} );
|
||||
|
||||
editor.addButton( 'wp_view_edit', {
|
||||
tooltip: 'Edit|button', // '|button' is not displayed, only used for context
|
||||
tooltip: 'Edit|button', // '|button' is not displayed, only used for context.
|
||||
icon: 'dashicon dashicons-edit',
|
||||
onclick: function() {
|
||||
var node = editor.selection.getNode();
|
||||
|
@ -26,10 +26,10 @@ function get_file( $path ) {
|
||||
return @file_get_contents( $path );
|
||||
}
|
||||
|
||||
$expires_offset = 31536000; // 1 year
|
||||
$expires_offset = 31536000; // 1 year.
|
||||
|
||||
header( 'Content-Type: application/javascript; charset=UTF-8' );
|
||||
header( 'Vary: Accept-Encoding' ); // Handle proxies
|
||||
header( 'Vary: Accept-Encoding' ); // Handle proxies.
|
||||
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expires_offset ) . ' GMT' );
|
||||
header( "Cache-Control: public, max-age=$expires_offset" );
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
* - 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 4.9.0
|
||||
* @output wp-includes/js/api-request.js
|
||||
*/
|
||||
|
||||
@ -42,8 +42,8 @@
|
||||
apiRoot = wpApiSettings.root;
|
||||
path = path.replace( /^\//, '' );
|
||||
|
||||
// API root may already include query parameter prefix if site is
|
||||
// configured to use plain permalinks.
|
||||
// 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( '?', '&' );
|
||||
}
|
||||
|
@ -107,9 +107,11 @@
|
||||
minutesOffset = 0,
|
||||
numericKeys = [ 1, 4, 5, 6, 7, 10, 11 ];
|
||||
|
||||
// ES5 §15.9.4.2 states that the string should attempt to be parsed as a Date Time String Format string
|
||||
// before falling back to any implementation-specific date parsing, so that’s what we do, even if native
|
||||
// implementations could be faster.
|
||||
/*
|
||||
* ES5 §15.9.4.2 states that the string should attempt to be parsed as a Date Time String Format string
|
||||
* before falling back to any implementation-specific date parsing, so that’s what we do, even if native
|
||||
* implementations could be faster.
|
||||
*/
|
||||
// 1 YYYY 2 MM 3 DD 4 HH 5 mm 6 ss 7 msec 8 Z 9 ± 10 tzHH 11 tzmm
|
||||
if ( ( struct = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec( date ) ) ) {
|
||||
|
||||
@ -855,7 +857,7 @@
|
||||
if ( _.isFunction( model.nonce ) && ! _.isEmpty( model.nonce() ) ) {
|
||||
beforeSend = options.beforeSend;
|
||||
|
||||
// @todo enable option for jsonp endpoints
|
||||
// @todo Enable option for jsonp endpoints.
|
||||
// options.dataType = 'jsonp';
|
||||
|
||||
// Include the nonce with requests.
|
||||
@ -1340,7 +1342,7 @@
|
||||
} );
|
||||
} else {
|
||||
|
||||
// This is a model without a parent in its route
|
||||
// This is a model without a parent in its route.
|
||||
modelClassName = wp.api.utils.capitalizeAndCamelCaseDashes( routeName );
|
||||
modelClassName = mapping.models[ modelClassName ] || modelClassName;
|
||||
loadingObjects.models[ modelClassName ] = wp.api.WPApiBaseModel.extend( {
|
||||
@ -1514,7 +1516,7 @@
|
||||
|
||||
if ( ! initializedDeferreds[ attributes.apiRoot + attributes.versionString ] ) {
|
||||
|
||||
// Look for an existing copy of this endpoint
|
||||
// Look for an existing copy of this endpoint.
|
||||
endpoint = wp.api.endpoints.findWhere( { 'apiRoot': attributes.apiRoot, 'versionString': attributes.versionString } );
|
||||
if ( ! endpoint ) {
|
||||
endpoint = new Endpoint( attributes );
|
||||
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
/* global tinymce, wpCookies, autosaveL10n, switchEditors */
|
||||
// Back-compat
|
||||
// Back-compat.
|
||||
window.autosave = function() {
|
||||
return true;
|
||||
};
|
||||
@ -209,7 +209,7 @@ window.autosave = function() {
|
||||
*/
|
||||
function getStorage() {
|
||||
var stored_obj = false;
|
||||
// Separate local storage containers for each blog_id
|
||||
// Separate local storage containers for each blog_id.
|
||||
if ( hasStorage && blog_id ) {
|
||||
stored_obj = sessionStorage.getItem( 'wp-autosave-' + blog_id );
|
||||
|
||||
@ -314,7 +314,7 @@ window.autosave = function() {
|
||||
/**
|
||||
* Saves post data for the current post.
|
||||
*
|
||||
* Runs on a 15 sec. interval, saves when there are differences in the post title or content.
|
||||
* Runs on a 15 seconds interval, saves when there are differences in the post title or content.
|
||||
* When the optional data is provided, updates the last saved post data.
|
||||
*
|
||||
* @since 3.9.0
|
||||
@ -378,9 +378,11 @@ window.autosave = function() {
|
||||
// Check if the local post data is different than the loaded post data.
|
||||
if ( $( '#wp-content-wrap' ).hasClass( 'tmce-active' ) ) {
|
||||
|
||||
// If TinyMCE loads first, check the post 1.5 sec. after it is ready.
|
||||
// By this time the content has been loaded in the editor and 'saved' to the textarea.
|
||||
// This prevents false positives.
|
||||
/*
|
||||
* If TinyMCE loads first, check the post 1.5 seconds after it is ready.
|
||||
* By this time the content has been loaded in the editor and 'saved' to the textarea.
|
||||
* This prevents false positives.
|
||||
*/
|
||||
$document.on( 'tinymce-editor-init.autosave', function() {
|
||||
window.setTimeout( function() {
|
||||
checkPost();
|
||||
@ -390,7 +392,7 @@ window.autosave = function() {
|
||||
checkPost();
|
||||
}
|
||||
|
||||
// Save every 15 sec.
|
||||
// Save every 15 seconds.
|
||||
intervalTimer = window.setInterval( save, 15000 );
|
||||
|
||||
$( 'form#post' ).on( 'submit.autosave-local', function() {
|
||||
@ -456,7 +458,7 @@ window.autosave = function() {
|
||||
|
||||
if ( cookie === post_id + '-saved' ) {
|
||||
wpCookies.remove( 'wp-saving-post' );
|
||||
// The post was saved properly, remove old data and bail
|
||||
// The post was saved properly, remove old data and bail.
|
||||
setData( false );
|
||||
return;
|
||||
}
|
||||
@ -519,7 +521,7 @@ window.autosave = function() {
|
||||
var editor;
|
||||
|
||||
if ( postData ) {
|
||||
// Set the last saved data
|
||||
// Set the last saved data.
|
||||
lastCompareString = getCompareString( postData );
|
||||
|
||||
if ( $( '#title' ).val() !== postData.post_title ) {
|
||||
@ -534,14 +536,14 @@ window.autosave = function() {
|
||||
postData.content = switchEditors.wpautop( postData.content );
|
||||
}
|
||||
|
||||
// Make sure there's an undo level in the editor
|
||||
// Make sure there's an undo level in the editor.
|
||||
editor.undoManager.transact( function() {
|
||||
editor.setContent( postData.content || '' );
|
||||
editor.nodeChanged();
|
||||
});
|
||||
} else {
|
||||
|
||||
// Make sure the Text editor is selected
|
||||
// Make sure the Text editor is selected.
|
||||
$( '#content-html' ).click();
|
||||
$( '#content' ).focus();
|
||||
|
||||
@ -558,9 +560,11 @@ window.autosave = function() {
|
||||
|
||||
blog_id = typeof window.autosaveL10n !== 'undefined' && window.autosaveL10n.blog_id;
|
||||
|
||||
// Check if the browser supports sessionStorage and it's not disabled,
|
||||
// then initialize and run checkPost().
|
||||
// Don't run if the post type supports neither 'editor' (textarea#content) nor 'excerpt'.
|
||||
/*
|
||||
* Check if the browser supports sessionStorage and it's not disabled,
|
||||
* then initialize and run checkPost().
|
||||
* Don't run if the post type supports neither 'editor' (textarea#content) nor 'excerpt'.
|
||||
*/
|
||||
if ( checkStorage() && blog_id && ( $('#content').length || $('#excerpt').length ) ) {
|
||||
$document.ready( run );
|
||||
}
|
||||
@ -652,7 +656,7 @@ window.autosave = function() {
|
||||
enableButtons();
|
||||
|
||||
if ( data.success ) {
|
||||
// No longer an auto-draft
|
||||
// No longer an auto-draft.
|
||||
$( '#auto_draft' ).val('');
|
||||
}
|
||||
}
|
||||
@ -698,7 +702,7 @@ window.autosave = function() {
|
||||
function save() {
|
||||
var postData, compareString;
|
||||
|
||||
// window.autosave() used for back-compat
|
||||
// window.autosave() used for back-compat.
|
||||
if ( isSuspended || _blockSave || ! window.autosave() ) {
|
||||
return false;
|
||||
}
|
||||
@ -710,12 +714,12 @@ window.autosave = function() {
|
||||
postData = getPostData();
|
||||
compareString = getCompareString( postData );
|
||||
|
||||
// First check
|
||||
// First check.
|
||||
if ( typeof lastCompareString === 'undefined' ) {
|
||||
lastCompareString = initialCompareString;
|
||||
}
|
||||
|
||||
// No change
|
||||
// No change.
|
||||
if ( compareString === lastCompareString ) {
|
||||
return false;
|
||||
}
|
||||
@ -836,7 +840,7 @@ window.autosave = function() {
|
||||
}
|
||||
}).ready( function() {
|
||||
|
||||
// Set the initial compare string in case TinyMCE is not used or not loaded first
|
||||
// Set the initial compare string in case TinyMCE is not used or not loaded first.
|
||||
initialCompareString = getCompareString();
|
||||
});
|
||||
|
||||
|
@ -79,7 +79,11 @@ if ( 'undefined' === typeof window.wp.codeEditor ) {
|
||||
options = $.extend( {}, options );
|
||||
}
|
||||
|
||||
// Note that rules must be sent in the "deprecated" lint.options property to prevent linter from complaining about unrecognized options. See <https://github.com/codemirror/CodeMirror/pull/4944>.
|
||||
/*
|
||||
* Note that rules must be sent in the "deprecated" lint.options property
|
||||
* to prevent linter from complaining about unrecognized options.
|
||||
* See <https://github.com/codemirror/CodeMirror/pull/4944>.
|
||||
*/
|
||||
if ( ! options.options ) {
|
||||
options.options = {};
|
||||
}
|
||||
|
@ -79,7 +79,7 @@
|
||||
* @return {boolean}
|
||||
*/
|
||||
supportsVideo: function() {
|
||||
// Don't load video on small screens. @todo: consider bandwidth and other factors.
|
||||
// Don't load video on small screens. @todo Consider bandwidth and other factors.
|
||||
if ( window.innerWidth < settings.minWidth || window.innerHeight < settings.minHeight ) {
|
||||
return false;
|
||||
}
|
||||
|
@ -25,17 +25,21 @@ window.wp = window.wp || {};
|
||||
inherits = function( parent, protoProps, staticProps ) {
|
||||
var child;
|
||||
|
||||
// The constructor function for the new subclass is either defined by you
|
||||
// (the "constructor" property in your `extend` definition), or defaulted
|
||||
// by us to simply call `super()`.
|
||||
/*
|
||||
* The constructor function for the new subclass is either defined by you
|
||||
* (the "constructor" property in your `extend` definition), or defaulted
|
||||
* by us to simply call `super()`.
|
||||
*/
|
||||
if ( protoProps && protoProps.hasOwnProperty( 'constructor' ) ) {
|
||||
child = protoProps.constructor;
|
||||
} else {
|
||||
child = function() {
|
||||
// Storing the result `super()` before returning the value
|
||||
// prevents a bug in Opera where, if the constructor returns
|
||||
// a function, Opera will reject the return value in favor of
|
||||
// the original object. This causes all sorts of trouble.
|
||||
/*
|
||||
* Storing the result `super()` before returning the value
|
||||
* prevents a bug in Opera where, if the constructor returns
|
||||
* a function, Opera will reject the return value in favor of
|
||||
* the original object. This causes all sorts of trouble.
|
||||
*/
|
||||
var result = parent.apply( this, arguments );
|
||||
return result;
|
||||
};
|
||||
@ -44,8 +48,8 @@ window.wp = window.wp || {};
|
||||
// Inherit class (static) properties from parent.
|
||||
$.extend( child, parent );
|
||||
|
||||
// Set the prototype chain to inherit from `parent`, without calling
|
||||
// `parent`'s constructor function.
|
||||
// Set the prototype chain to inherit from `parent`,
|
||||
// without calling `parent`'s constructor function.
|
||||
ctor.prototype = parent.prototype;
|
||||
child.prototype = new ctor();
|
||||
|
||||
@ -187,7 +191,7 @@ window.wp = window.wp || {};
|
||||
* @param {object} options
|
||||
*/
|
||||
initialize: function( initial, options ) {
|
||||
this._value = initial; // @todo: potentially change this to a this.set() call.
|
||||
this._value = initial; // @todo Potentially change this to a this.set() call.
|
||||
this.callbacks = $.Callbacks();
|
||||
this._dirty = false;
|
||||
|
||||
@ -496,7 +500,7 @@ window.wp = window.wp || {};
|
||||
ids = slice.call( arguments ),
|
||||
dfd = $.Deferred();
|
||||
|
||||
// If the last argument is a callback, bind it to .done()
|
||||
// If the last argument is a callback, bind it to .done().
|
||||
if ( $.isFunction( ids[ ids.length - 1 ] ) ) {
|
||||
dfd.done( ids.pop() );
|
||||
}
|
||||
@ -699,7 +703,7 @@ window.wp = window.wp || {};
|
||||
return urlParser.protocol + '//' + urlParser.host.replace( /:(80|443)$/, '' );
|
||||
});
|
||||
|
||||
// first add with no value
|
||||
// First add with no value.
|
||||
this.add( 'targetWindow', null );
|
||||
// This avoids SecurityErrors when setting a window object in x-origin iframe'd scenarios.
|
||||
this.targetWindow.set = function( to ) {
|
||||
@ -719,15 +723,17 @@ window.wp = window.wp || {};
|
||||
|
||||
return this;
|
||||
};
|
||||
// now set it
|
||||
// Now set it.
|
||||
this.targetWindow( params.targetWindow || defaultTarget );
|
||||
|
||||
|
||||
// Since we want jQuery to treat the receive function as unique
|
||||
// to this instance, we give the function a new guid.
|
||||
//
|
||||
// This will prevent every Messenger's receive function from being
|
||||
// unbound when calling $.off( 'message', this.receive );
|
||||
/*
|
||||
* Since we want jQuery to treat the receive function as unique
|
||||
* to this instance, we give the function a new guid.
|
||||
*
|
||||
* This will prevent every Messenger's receive function from being
|
||||
* unbound when calling $.off( 'message', this.receive );
|
||||
*/
|
||||
this.receive = $.proxy( this.receive, this );
|
||||
this.receive.guid = $.guid++;
|
||||
|
||||
|
178
src/js/_enqueues/wp/customize/controls.js
vendored
178
src/js/_enqueues/wp/customize/controls.js
vendored
@ -578,7 +578,8 @@
|
||||
return deferred.promise();
|
||||
}
|
||||
|
||||
// A status would cause a revision to be made, and for this wp.customize.previewer.save() should be used. Status is also disallowed for revisions regardless.
|
||||
// A status would cause a revision to be made, and for this wp.customize.previewer.save() should be used.
|
||||
// Status is also disallowed for revisions regardless.
|
||||
if ( submittedArgs.status ) {
|
||||
return deferred.reject( { code: 'illegal_status_in_changeset_update' } ).promise();
|
||||
}
|
||||
@ -772,13 +773,13 @@
|
||||
*/
|
||||
api.utils.areElementListsEqual = function ( listA, listB ) {
|
||||
var equal = (
|
||||
listA.length === listB.length && // if lists are different lengths, then naturally they are not equal
|
||||
-1 === _.indexOf( _.map( // are there any false values in the list returned by map?
|
||||
_.zip( listA, listB ), // pair up each element between the two lists
|
||||
listA.length === listB.length && // If lists are different lengths, then naturally they are not equal.
|
||||
-1 === _.indexOf( _.map( // Are there any false values in the list returned by map?
|
||||
_.zip( listA, listB ), // Pair up each element between the two lists.
|
||||
function ( pair ) {
|
||||
return $( pair[0] ).is( pair[1] ); // compare to see if each pair are equal
|
||||
return $( pair[0] ).is( pair[1] ); // Compare to see if each pair is equal.
|
||||
}
|
||||
), false ) // check for presence of false in map's return value
|
||||
), false ) // Check for presence of false in map's return value.
|
||||
);
|
||||
return equal;
|
||||
};
|
||||
@ -1128,7 +1129,8 @@
|
||||
}
|
||||
|
||||
if ( ! $.contains( document, headContainer.get( 0 ) ) ) {
|
||||
// If the element is not in the DOM, then jQuery.fn.slideUp() does nothing. In this case, a hard toggle is required instead.
|
||||
// If the element is not in the DOM, then jQuery.fn.slideUp() does nothing.
|
||||
// In this case, a hard toggle is required instead.
|
||||
headContainer.toggle( active );
|
||||
if ( args.completeCallback ) {
|
||||
args.completeCallback();
|
||||
@ -1479,7 +1481,7 @@
|
||||
});
|
||||
} );
|
||||
} else {
|
||||
// There is no panel, so embed the section in the root of the customizer
|
||||
// There is no panel, so embed the section in the root of the customizer.
|
||||
parentContainer = api.ensure( section.containerPaneParent );
|
||||
if ( ! section.headContainer.parent().is( parentContainer ) ) {
|
||||
parentContainer.append( section.headContainer );
|
||||
@ -1511,7 +1513,7 @@
|
||||
if ( api.utils.isKeydownButNotEnterEvent( event ) ) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault(); // Keep this AFTER the key filter above
|
||||
event.preventDefault(); // Keep this AFTER the key filter above.
|
||||
|
||||
if ( section.expanded() ) {
|
||||
section.collapse();
|
||||
@ -1718,12 +1720,12 @@
|
||||
var inject,
|
||||
section = this;
|
||||
|
||||
// Watch for changes to the panel state
|
||||
// Watch for changes to the panel state.
|
||||
inject = function( panelId ) {
|
||||
var parentContainer;
|
||||
api.panel( panelId, function( panel ) {
|
||||
|
||||
// The panel has been registered, wait for it to become ready/initialized
|
||||
// The panel has been registered, wait for it to become ready/initialized.
|
||||
panel.deferred.embedded.done( function() {
|
||||
parentContainer = panel.contentContainer;
|
||||
if ( ! section.headContainer.parent().is( parentContainer ) ) {
|
||||
@ -1737,7 +1739,7 @@
|
||||
} );
|
||||
};
|
||||
section.panel.bind( inject );
|
||||
inject( section.panel.get() ); // Since a section may never get a panel, assume that it won't ever get one
|
||||
inject( section.panel.get() ); // Since a section may never get a panel, assume that it won't ever get one.
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1758,17 +1760,17 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// Pressing the right arrow key fires a theme:next event
|
||||
// Pressing the right arrow key fires a theme:next event.
|
||||
if ( 39 === event.keyCode ) {
|
||||
section.nextTheme();
|
||||
}
|
||||
|
||||
// Pressing the left arrow key fires a theme:previous event
|
||||
// Pressing the left arrow key fires a theme:previous event.
|
||||
if ( 37 === event.keyCode ) {
|
||||
section.previousTheme();
|
||||
}
|
||||
|
||||
// Pressing the escape key fires a theme:collapse event
|
||||
// Pressing the escape key fires a theme:collapse event.
|
||||
if ( 27 === event.keyCode ) {
|
||||
if ( section.$body.hasClass( 'modal-open' ) ) {
|
||||
|
||||
@ -1818,7 +1820,7 @@
|
||||
if ( api.utils.isKeydownButNotEnterEvent( event ) ) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault(); // Keep this AFTER the key filter above
|
||||
event.preventDefault(); // Keep this AFTER the key filter above.
|
||||
section.collapse();
|
||||
});
|
||||
|
||||
@ -1957,11 +1959,11 @@
|
||||
*/
|
||||
onChangeExpanded: function ( expanded, args ) {
|
||||
|
||||
// Note: there is a second argument 'args' passed
|
||||
// Note: there is a second argument 'args' passed.
|
||||
var section = this,
|
||||
container = section.contentContainer.closest( '.customize-themes-full-container' );
|
||||
|
||||
// Immediately call the complete callback if there were no changes
|
||||
// Immediately call the complete callback if there were no changes.
|
||||
if ( args.unchanged ) {
|
||||
if ( args.completeCallback ) {
|
||||
args.completeCallback();
|
||||
@ -1976,7 +1978,7 @@
|
||||
section.loadThemes();
|
||||
}
|
||||
|
||||
// Collapse any sibling sections/panels
|
||||
// Collapse any sibling sections/panels.
|
||||
api.section.each( function ( otherSection ) {
|
||||
var searchTerm;
|
||||
|
||||
@ -2123,7 +2125,8 @@
|
||||
|
||||
_.delay( section.renderScreenshots, 100 ); // Wait for the controls to become visible.
|
||||
|
||||
if ( 'local' === section.params.filter_type || 100 > themes.length ) { // If we have less than the requested 100 themes, it's the end of the list.
|
||||
if ( 'local' === section.params.filter_type || 100 > themes.length ) {
|
||||
// If we have less than the requested 100 themes, it's the end of the list.
|
||||
section.fullyLoaded = true;
|
||||
}
|
||||
} else {
|
||||
@ -2202,7 +2205,9 @@
|
||||
container = section.container.closest( '.customize-themes-full-container' );
|
||||
|
||||
bottom = container.scrollTop() + container.height();
|
||||
threshold = container.prop( 'scrollHeight' ) - 3000; // Use a fixed distance to the bottom of loaded results to avoid unnecessarily loading results sooner when using a percentage of scroll distance.
|
||||
// Use a fixed distance to the bottom of loaded results to avoid unnecessarily
|
||||
// loading results sooner when using a percentage of scroll distance.
|
||||
threshold = container.prop( 'scrollHeight' ) - 3000;
|
||||
|
||||
if ( bottom > threshold ) {
|
||||
section.loadThemes();
|
||||
@ -2614,15 +2619,15 @@
|
||||
el.on( 'keydown', function( event ) {
|
||||
|
||||
// Return if it's not the tab key
|
||||
// When navigating with prev/next focus is already handled
|
||||
// When navigating with prev/next focus is already handled.
|
||||
if ( 9 !== event.keyCode ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// uses jQuery UI to get the tabbable elements
|
||||
// Uses jQuery UI to get the tabbable elements.
|
||||
tabbables = $( ':tabbable', el );
|
||||
|
||||
// Keep focus within the overlay
|
||||
// Keep focus within the overlay.
|
||||
if ( tabbables.last()[0] === event.target && ! event.shiftKey ) {
|
||||
tabbables.first().focus();
|
||||
return false;
|
||||
@ -2797,7 +2802,7 @@
|
||||
embed: function () {
|
||||
var panel = this,
|
||||
container = $( '#customize-theme-controls' ),
|
||||
parentContainer = $( '.customize-pane-parent' ); // @todo This should be defined elsewhere, and to be configurable
|
||||
parentContainer = $( '.customize-pane-parent' ); // @todo This should be defined elsewhere, and to be configurable.
|
||||
|
||||
if ( ! panel.headContainer.parent().is( parentContainer ) ) {
|
||||
parentContainer.append( panel.headContainer );
|
||||
@ -2821,7 +2826,7 @@
|
||||
if ( api.utils.isKeydownButNotEnterEvent( event ) ) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault(); // Keep this AFTER the key filter above
|
||||
event.preventDefault(); // Keep this AFTER the key filter above.
|
||||
|
||||
if ( ! panel.expanded() ) {
|
||||
panel.expand();
|
||||
@ -2833,7 +2838,7 @@
|
||||
if ( api.utils.isKeydownButNotEnterEvent( event ) ) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault(); // Keep this AFTER the key filter above
|
||||
event.preventDefault(); // Keep this AFTER the key filter above.
|
||||
|
||||
if ( panel.expanded() ) {
|
||||
panel.collapse();
|
||||
@ -2908,7 +2913,7 @@
|
||||
*/
|
||||
onChangeExpanded: function ( expanded, args ) {
|
||||
|
||||
// Immediately call the complete callback if there were no changes
|
||||
// Immediately call the complete callback if there were no changes.
|
||||
if ( args.unchanged ) {
|
||||
if ( args.completeCallback ) {
|
||||
args.completeCallback();
|
||||
@ -2916,7 +2921,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// Note: there is a second argument 'args' passed
|
||||
// Note: there is a second argument 'args' passed.
|
||||
var panel = this,
|
||||
accordionSection = panel.contentContainer,
|
||||
overlay = accordionSection.closest( '.wp-full-overlay' ),
|
||||
@ -2927,7 +2932,7 @@
|
||||
skipTransition;
|
||||
|
||||
if ( expanded && ! accordionSection.hasClass( 'current-panel' ) ) {
|
||||
// Collapse any sibling sections/panels
|
||||
// Collapse any sibling sections/panels.
|
||||
api.section.each( function ( section ) {
|
||||
if ( panel.id !== section.panel() ) {
|
||||
section.collapse( { duration: 0 } );
|
||||
@ -3067,7 +3072,7 @@
|
||||
// Attach regular panel events.
|
||||
api.Panel.prototype.attachEvents.apply( panel );
|
||||
|
||||
// Temporary since supplying SFTP credentials does not work yet. See #42184
|
||||
// Temporary since supplying SFTP credentials does not work yet. See #42184.
|
||||
if ( api.settings.theme._canInstall && api.settings.theme._filesystemCredentialsNeeded ) {
|
||||
panel.notifications.add( new api.Notification( 'theme_install_unavailable', {
|
||||
message: api.l10n.themeInstallUnavailable,
|
||||
@ -3140,7 +3145,7 @@
|
||||
// Expand/collapse the panel normally.
|
||||
api.Panel.prototype.onChangeExpanded.apply( this, [ expanded, args ] );
|
||||
|
||||
// Immediately call the complete callback if there were no changes
|
||||
// Immediately call the complete callback if there were no changes.
|
||||
if ( args.unchanged ) {
|
||||
if ( args.completeCallback ) {
|
||||
args.completeCallback();
|
||||
@ -3682,15 +3687,15 @@
|
||||
var control = this,
|
||||
inject;
|
||||
|
||||
// Watch for changes to the section state
|
||||
// Watch for changes to the section state.
|
||||
inject = function ( sectionId ) {
|
||||
var parentContainer;
|
||||
if ( ! sectionId ) { // @todo allow a control to be embedded without a section, for instance a control embedded in the front end.
|
||||
if ( ! sectionId ) { // @todo Allow a control to be embedded without a section, for instance a control embedded in the front end.
|
||||
return;
|
||||
}
|
||||
// Wait for the section to be registered
|
||||
// Wait for the section to be registered.
|
||||
api.section( sectionId, function ( section ) {
|
||||
// Wait for the section to be ready/initialized
|
||||
// Wait for the section to be ready/initialized.
|
||||
section.deferred.embedded.done( function () {
|
||||
parentContainer = ( section.contentContainer.is( 'ul' ) ) ? section.contentContainer : section.contentContainer.find( 'ul:first' );
|
||||
if ( ! control.container.parent().is( parentContainer ) ) {
|
||||
@ -3724,7 +3729,7 @@
|
||||
control.addNewPage();
|
||||
});
|
||||
control.container.on( 'keydown', '.create-item-input', function( e ) {
|
||||
if ( 13 === e.which ) { // Enter
|
||||
if ( 13 === e.which ) { // Enter.
|
||||
control.addNewPage();
|
||||
}
|
||||
});
|
||||
@ -3909,7 +3914,7 @@
|
||||
}
|
||||
|
||||
if ( ! $.contains( document, this.container[0] ) ) {
|
||||
// jQuery.fn.slideUp is not hiding an element if it is not in the DOM
|
||||
// jQuery.fn.slideUp is not hiding an element if it is not in the DOM.
|
||||
this.container.toggle( active );
|
||||
if ( args.completeCallback ) {
|
||||
args.completeCallback();
|
||||
@ -3957,7 +3962,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
// Support the .dropdown class to open/close complex elements
|
||||
// Support the .dropdown class to open/close complex elements.
|
||||
this.container.on( 'click keydown', '.dropdown', function( event ) {
|
||||
if ( api.utils.isKeydownButNotEnterEvent( event ) ) {
|
||||
return;
|
||||
@ -3973,7 +3978,7 @@
|
||||
control.container.parent().parent().find( 'li.library-selected' ).focus();
|
||||
}
|
||||
|
||||
// Don't want to fire focus and click at same time
|
||||
// Don't want to fire focus and click at same time.
|
||||
toggleFreeze = true;
|
||||
setTimeout(function () {
|
||||
toggleFreeze = false;
|
||||
@ -4017,7 +4022,8 @@
|
||||
|
||||
templateId = control.templateSelector;
|
||||
|
||||
// Use default content template when a standard HTML type is used, there isn't a more specific template existing, and the control container is empty.
|
||||
// Use default content template when a standard HTML type is used,
|
||||
// there isn't a more specific template existing, and the control container is empty.
|
||||
if ( templateId === 'customize-control-' + control.params.type + '-content' &&
|
||||
_.contains( standardTypes, control.params.type ) &&
|
||||
! document.getElementById( 'tmpl-' + templateId ) &&
|
||||
@ -4047,6 +4053,7 @@
|
||||
*
|
||||
* @since 4.7.0
|
||||
* @access private
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
addNewPage: function () {
|
||||
@ -4070,7 +4077,8 @@
|
||||
input.removeClass( 'invalid' );
|
||||
input.attr( 'disabled', 'disabled' );
|
||||
|
||||
// The menus functions add the page, publish when appropriate, and also add the new page to the dropdown-pages controls.
|
||||
// The menus functions add the page, publish when appropriate,
|
||||
// and also add the new page to the dropdown-pages controls.
|
||||
promise = api.Menus.insertAutoDraftPost( {
|
||||
post_title: title,
|
||||
post_type: 'page'
|
||||
@ -4199,7 +4207,7 @@
|
||||
control.container.on( 'click keydown', '.remove-button', control.removeFile );
|
||||
control.container.on( 'click keydown', '.remove-button', control.cleanupPlayer );
|
||||
|
||||
// Resize the player controls when it becomes visible (ie when section is expanded)
|
||||
// Resize the player controls when it becomes visible (ie when section is expanded).
|
||||
api.section( control.section() ).container
|
||||
.on( 'expanded', function() {
|
||||
if ( control.player ) {
|
||||
@ -5128,7 +5136,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault(); // Keep this AFTER the key filter above
|
||||
event.preventDefault(); // Keep this AFTER the key filter above.
|
||||
section = api.section( control.section() );
|
||||
section.showDetails( control.params.theme, function() {
|
||||
|
||||
@ -5196,7 +5204,7 @@
|
||||
control.params.priority = 101 - matchCount; // Sort results by match count.
|
||||
return true;
|
||||
} else {
|
||||
control.deactivate(); // Hide control
|
||||
control.deactivate(); // Hide control.
|
||||
control.params.priority = 101;
|
||||
return false;
|
||||
}
|
||||
@ -6498,13 +6506,15 @@
|
||||
urlParser.href = previewer.origin();
|
||||
previewer.add( 'scheme', urlParser.protocol.replace( /:$/, '' ) );
|
||||
|
||||
// Limit the URL to internal, front-end links.
|
||||
//
|
||||
// If the front end and the admin are served from the same domain, load the
|
||||
// preview over ssl if the Customizer is being loaded over ssl. This avoids
|
||||
// insecure content warnings. This is not attempted if the admin and front end
|
||||
// are on different domains to avoid the case where the front end doesn't have
|
||||
// ssl certs.
|
||||
/*
|
||||
* Limit the URL to internal, front-end links.
|
||||
*
|
||||
* If the front end and the admin are served from the same domain, load the
|
||||
* preview over ssl if the Customizer is being loaded over ssl. This avoids
|
||||
* insecure content warnings. This is not attempted if the admin and front end
|
||||
* are on different domains to avoid the case where the front end doesn't have
|
||||
* ssl certs.
|
||||
*/
|
||||
|
||||
previewer.add( 'previewUrl', params.previewUrl ).setter( function( to ) {
|
||||
var result = null, urlParser, queryParams, parsedAllowedUrl, parsedCandidateUrls = [];
|
||||
@ -6735,12 +6745,13 @@
|
||||
*
|
||||
* @since 3.4.0
|
||||
* @access public
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
refresh: function() {
|
||||
var previewer = this, onSettingChange;
|
||||
|
||||
// Display loading indicator
|
||||
// Display loading indicator.
|
||||
previewer.send( 'loading-initiated' );
|
||||
|
||||
previewer.abort();
|
||||
@ -7013,7 +7024,7 @@
|
||||
activeElement = $( document.activeElement );
|
||||
}
|
||||
|
||||
// Sort the sections within each panel
|
||||
// Sort the sections within each panel.
|
||||
api.panel.each( function ( panel ) {
|
||||
if ( 'themes' === panel.id ) {
|
||||
return; // Don't reflow theme sections, as doing so moves them after the themes container.
|
||||
@ -7031,7 +7042,7 @@
|
||||
}
|
||||
} );
|
||||
|
||||
// Sort the controls within each section
|
||||
// Sort the controls within each section.
|
||||
api.section.each( function ( section ) {
|
||||
var controls = section.controls(),
|
||||
controlContainers = _.pluck( controls, 'container' );
|
||||
@ -7047,10 +7058,10 @@
|
||||
}
|
||||
} );
|
||||
|
||||
// Sort the root panels and sections
|
||||
// Sort the root panels and sections.
|
||||
rootNodes.sort( api.utils.prioritySort );
|
||||
rootHeadContainers = _.pluck( rootNodes, 'headContainer' );
|
||||
appendContainer = $( '#customize-theme-controls .customize-pane-parent' ); // @todo This should be defined elsewhere, and to be configurable
|
||||
appendContainer = $( '#customize-theme-controls .customize-pane-parent' ); // @todo This should be defined elsewhere, and to be configurable.
|
||||
if ( ! api.utils.areElementListsEqual( rootHeadContainers, appendContainer.children() ) ) {
|
||||
_( rootNodes ).each( function ( rootNode ) {
|
||||
appendContainer.append( rootNode.headContainer );
|
||||
@ -7058,7 +7069,7 @@
|
||||
wasReflowed = true;
|
||||
}
|
||||
|
||||
// Now re-trigger the active Value callbacks to that the panels and sections can decide whether they can be rendered
|
||||
// Now re-trigger the active Value callbacks so that the panels and sections can decide whether they can be rendered.
|
||||
api.panel.each( function ( panel ) {
|
||||
var value = panel.active();
|
||||
panel.active.callbacks.fireWith( panel.active, [ value, value ] );
|
||||
@ -7068,7 +7079,7 @@
|
||||
section.active.callbacks.fireWith( section.active, [ value, value ] );
|
||||
} );
|
||||
|
||||
// Restore focus if there was a reflow and there was an active (focused) element
|
||||
// Restore focus if there was a reflow and there was an active (focused) element.
|
||||
if ( wasReflowed && activeElement ) {
|
||||
activeElement.focus();
|
||||
}
|
||||
@ -7208,9 +7219,11 @@
|
||||
cancelScheduleButtonReminder = api.utils.highlightButton( btnWrapper, {
|
||||
delay: 1000,
|
||||
|
||||
// Only abort the reminder when the save button is focused.
|
||||
// If the user clicks the settings button to toggle the
|
||||
// settings closed, we'll still remind them.
|
||||
/*
|
||||
* Only abort the reminder when the save button is focused.
|
||||
* If the user clicks the settings button to toggle the
|
||||
* settings closed, we'll still remind them.
|
||||
*/
|
||||
focusTarget: saveBtn
|
||||
} );
|
||||
}
|
||||
@ -7579,7 +7592,7 @@
|
||||
if ( '0' === response ) {
|
||||
response = 'not_logged_in';
|
||||
} else if ( '-1' === response ) {
|
||||
// Back-compat in case any other check_ajax_referer() call is dying
|
||||
// Back-compat in case any other check_ajax_referer() call is dying.
|
||||
response = 'invalid_nonce';
|
||||
}
|
||||
|
||||
@ -7812,7 +7825,7 @@
|
||||
api.previewer.send( 'nonce-refresh', nonce );
|
||||
});
|
||||
|
||||
// Create Settings
|
||||
// Create Settings.
|
||||
$.each( api.settings.settings, function( id, data ) {
|
||||
var Constructor = api.settingConstructor[ data.type ] || api.Setting;
|
||||
api.add( new Constructor( id, data.value, {
|
||||
@ -7822,28 +7835,31 @@
|
||||
} ) );
|
||||
});
|
||||
|
||||
// Create Panels
|
||||
// Create Panels.
|
||||
$.each( api.settings.panels, function ( id, data ) {
|
||||
var Constructor = api.panelConstructor[ data.type ] || api.Panel, options;
|
||||
options = _.extend( { params: data }, data ); // Inclusion of params alias is for back-compat for custom panels that expect to augment this property.
|
||||
// Inclusion of params alias is for back-compat for custom panels that expect to augment this property.
|
||||
options = _.extend( { params: data }, data );
|
||||
api.panel.add( new Constructor( id, options ) );
|
||||
});
|
||||
|
||||
// Create Sections
|
||||
// Create Sections.
|
||||
$.each( api.settings.sections, function ( id, data ) {
|
||||
var Constructor = api.sectionConstructor[ data.type ] || api.Section, options;
|
||||
options = _.extend( { params: data }, data ); // Inclusion of params alias is for back-compat for custom sections that expect to augment this property.
|
||||
// Inclusion of params alias is for back-compat for custom sections that expect to augment this property.
|
||||
options = _.extend( { params: data }, data );
|
||||
api.section.add( new Constructor( id, options ) );
|
||||
});
|
||||
|
||||
// Create Controls
|
||||
// Create Controls.
|
||||
$.each( api.settings.controls, function( id, data ) {
|
||||
var Constructor = api.controlConstructor[ data.type ] || api.Control, options;
|
||||
options = _.extend( { params: data }, data ); // Inclusion of params alias is for back-compat for custom controls that expect to augment this property.
|
||||
// Inclusion of params alias is for back-compat for custom controls that expect to augment this property.
|
||||
options = _.extend( { params: data }, data );
|
||||
api.control.add( new Constructor( id, options ) );
|
||||
});
|
||||
|
||||
// Focus the autofocused element
|
||||
// Focus the autofocused element.
|
||||
_.each( [ 'panel', 'section', 'control' ], function( type ) {
|
||||
var id = api.settings.autofocus[ type ];
|
||||
if ( ! id ) {
|
||||
@ -7896,7 +7912,7 @@
|
||||
api.notifications.render();
|
||||
});
|
||||
|
||||
// Save and activated states
|
||||
// Save and activated states.
|
||||
(function( state ) {
|
||||
var saved = state.instance( 'saved' ),
|
||||
saving = state.instance( 'saving' ),
|
||||
@ -8690,7 +8706,8 @@
|
||||
};
|
||||
}());
|
||||
|
||||
// Previewed device bindings. (The api.previewedDevice property is how this Value was first introduced, but since it has moved to api.state.)
|
||||
// Previewed device bindings. (The api.previewedDevice property
|
||||
// is how this Value was first introduced, but since it has moved to api.state.)
|
||||
api.previewedDevice = api.state( 'previewedDevice' );
|
||||
|
||||
// Set the default device.
|
||||
@ -8797,7 +8814,7 @@
|
||||
api.state( 'selectedChangesetStatus' ).unbind( startPromptingBeforeUnload );
|
||||
api.state( 'selectedChangesetDate' ).unbind( startPromptingBeforeUnload );
|
||||
|
||||
// Prompt user with AYS dialog if leaving the Customizer with unsaved changes
|
||||
// Prompt user with AYS dialog if leaving the Customizer with unsaved changes.
|
||||
$( window ).on( 'beforeunload.customize-confirm', function() {
|
||||
if ( ! isCleanState() && ! api.state( 'changesetLocked' ).get() ) {
|
||||
setTimeout( function() {
|
||||
@ -8882,7 +8899,7 @@
|
||||
});
|
||||
} );
|
||||
|
||||
// Pass titles to the parent
|
||||
// Pass titles to the parent.
|
||||
api.bind( 'title', function( newTitle ) {
|
||||
parent.send( 'title', newTitle );
|
||||
});
|
||||
@ -8894,7 +8911,7 @@
|
||||
// Initialize the connection with the parent frame.
|
||||
parent.send( 'ready' );
|
||||
|
||||
// Control visibility for default controls
|
||||
// Control visibility for default controls.
|
||||
$.each({
|
||||
'background_image': {
|
||||
controls: [ 'background_preset', 'background_position', 'background_size', 'background_repeat', 'background_attachment' ],
|
||||
@ -8926,7 +8943,7 @@
|
||||
api.control( 'background_preset', function( control ) {
|
||||
var visibility, defaultValues, values, toggleVisibility, updateSettings, preset;
|
||||
|
||||
visibility = { // position, size, repeat, attachment
|
||||
visibility = { // position, size, repeat, attachment.
|
||||
'default': [ false, false, false, false ],
|
||||
'fill': [ true, false, false, false ],
|
||||
'fit': [ true, false, true, false ],
|
||||
@ -8942,14 +8959,15 @@
|
||||
_wpCustomizeBackground.defaults['default-attachment']
|
||||
];
|
||||
|
||||
values = { // position_x, position_y, size, repeat, attachment
|
||||
values = { // position_x, position_y, size, repeat, attachment.
|
||||
'default': defaultValues,
|
||||
'fill': [ 'left', 'top', 'cover', 'no-repeat', 'fixed' ],
|
||||
'fit': [ 'left', 'top', 'contain', 'no-repeat', 'fixed' ],
|
||||
'repeat': [ 'left', 'top', 'auto', 'repeat', 'scroll' ]
|
||||
};
|
||||
|
||||
// @todo These should actually toggle the active state, but without the preview overriding the state in data.activeControls.
|
||||
// @todo These should actually toggle the active state,
|
||||
// but without the preview overriding the state in data.activeControls.
|
||||
toggleVisibility = function( preset ) {
|
||||
_.each( [ 'background_position', 'background_size', 'background_repeat', 'background_attachment' ], function( controlId, i ) {
|
||||
var control = api.control( controlId );
|
||||
@ -9009,7 +9027,7 @@
|
||||
} );
|
||||
} );
|
||||
|
||||
// Juggle the two controls that use header_textcolor
|
||||
// Juggle the two controls that use header_textcolor.
|
||||
api.control( 'display_header_text', function( control ) {
|
||||
var last = '';
|
||||
|
||||
|
@ -119,7 +119,7 @@ window.wp = window.wp || {};
|
||||
return window.location = src;
|
||||
}
|
||||
|
||||
// Store the document title prior to opening the Live Preview
|
||||
// Store the document title prior to opening the Live Preview.
|
||||
this.originalDocumentTitle = document.title;
|
||||
|
||||
this.active = true;
|
||||
@ -170,7 +170,7 @@ window.wp = window.wp || {};
|
||||
}
|
||||
});
|
||||
|
||||
// Prompt AYS dialog when navigating away
|
||||
// Prompt AYS dialog when navigating away.
|
||||
$( window ).on( 'beforeunload', this.beforeunload );
|
||||
|
||||
this.messenger.bind( 'saved', function () {
|
||||
@ -223,13 +223,13 @@ window.wp = window.wp || {};
|
||||
self.active = false;
|
||||
self.trigger( 'close' );
|
||||
|
||||
// Restore document title prior to opening the Live Preview
|
||||
// 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()
|
||||
// Go forward since Customizer is exited by history.back().
|
||||
history.forward();
|
||||
}
|
||||
self.messenger.unbind( 'confirmed-close', onConfirmClose );
|
||||
@ -286,6 +286,6 @@ window.wp = window.wp || {};
|
||||
Loader.initialize();
|
||||
});
|
||||
|
||||
// Expose the API publicly on window.wp.customize.Loader
|
||||
// Expose the API publicly on window.wp.customize.Loader.
|
||||
api.Loader = Loader;
|
||||
})( wp, jQuery );
|
||||
|
@ -53,8 +53,8 @@
|
||||
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 the image we're removing is also the current header,
|
||||
// unset the latter.
|
||||
if (curr && data.attachment_id === curr) {
|
||||
api.HeaderTool.currentHeader.trigger('hide');
|
||||
}
|
||||
@ -142,7 +142,7 @@
|
||||
api.HeaderTool.ChoiceList = Backbone.Collection.extend({
|
||||
model: api.HeaderTool.ImageModel,
|
||||
|
||||
// Ordered from most recently used to least
|
||||
// Ordered from most recently used to least.
|
||||
comparator: function(model) {
|
||||
return -model.get('header').timestamp;
|
||||
},
|
||||
@ -151,18 +151,18 @@
|
||||
var current = api.HeaderTool.currentHeader.get('choice').replace(/^https?:\/\//, ''),
|
||||
isRandom = this.isRandomChoice(api.get().header_image);
|
||||
|
||||
// Overridable by an extending class
|
||||
// Overridable by an extending class.
|
||||
if (!this.type) {
|
||||
this.type = 'uploaded';
|
||||
}
|
||||
|
||||
// Overridable by an extending class
|
||||
// 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
|
||||
// So that when adding data we don't hide regular images.
|
||||
current = api.get().header_image;
|
||||
}
|
||||
|
||||
|
@ -203,9 +203,11 @@
|
||||
|
||||
_.bindAll( this, 'close' );
|
||||
|
||||
// If the available menu items panel is open and the customize controls are
|
||||
// interacted with (other than an item being deleted), then close the
|
||||
// available menu items panel. Also close on back button click.
|
||||
/*
|
||||
* If the available menu items panel is open and the customize controls
|
||||
* are interacted with (other than an item being deleted), then close
|
||||
* the available menu items panel. Also close on back button click.
|
||||
*/
|
||||
$( '#customize-controls, .customize-section-back' ).on( 'click keydown', function( e ) {
|
||||
var isDeleteBtn = $( e.target ).is( '.item-delete, .item-delete *' ),
|
||||
isAddNewBtn = $( e.target ).is( '.add-new-menu-item, .add-new-menu-item *' );
|
||||
@ -252,7 +254,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
// Close the panel if the URL in the preview changes
|
||||
// Close the panel if the URL in the preview changes.
|
||||
api.previewer.bind( 'url', this.close );
|
||||
|
||||
self.delegateEvents();
|
||||
@ -496,7 +498,7 @@
|
||||
|
||||
// Submit handler for keypress and click on menu item.
|
||||
_submit: function( event ) {
|
||||
// Only proceed with keypress if it is Enter or Spacebar
|
||||
// Only proceed with keypress if it is Enter or Spacebar.
|
||||
if ( 'keypress' === event.type && ( 13 !== event.which && 32 !== event.which ) ) {
|
||||
return;
|
||||
}
|
||||
@ -717,7 +719,7 @@
|
||||
this.$search.focus();
|
||||
},
|
||||
|
||||
// Closes the panel
|
||||
// Closes the panel.
|
||||
close: function( options ) {
|
||||
options = options || {};
|
||||
|
||||
@ -741,7 +743,7 @@
|
||||
isBackTab = ( 9 === event.which && event.shiftKey ),
|
||||
isSearchFocused = $( event.target ).is( this.$search );
|
||||
|
||||
// If enter pressed but nothing entered, don't do anything
|
||||
// If enter pressed but nothing entered, don't do anything.
|
||||
if ( isEnter && ! this.$search.val() ) {
|
||||
return;
|
||||
}
|
||||
@ -781,7 +783,7 @@
|
||||
}
|
||||
event.preventDefault();
|
||||
|
||||
// Hide description
|
||||
// Hide description.
|
||||
if ( content.not( ':hidden' ) ) {
|
||||
content.slideUp( 'fast' );
|
||||
help.attr( 'aria-expanded', 'false' );
|
||||
@ -802,7 +804,7 @@
|
||||
return false;
|
||||
} );
|
||||
|
||||
// Help toggle
|
||||
// Help toggle.
|
||||
help.on( 'click keydown', function( event ) {
|
||||
if ( api.utils.isKeydownButNotEnterEvent( event ) ) {
|
||||
return;
|
||||
@ -1062,7 +1064,7 @@
|
||||
menuAutoAddControl.active.set( true );
|
||||
}
|
||||
|
||||
// Add the control for deleting the menu
|
||||
// Add the control for deleting the menu.
|
||||
menuDeleteControlId = section.id + '[delete]';
|
||||
menuDeleteControl = api.control( menuDeleteControlId );
|
||||
if ( ! menuDeleteControl ) {
|
||||
@ -1126,7 +1128,7 @@
|
||||
wpNavMenu.menuList = section.contentContainer;
|
||||
wpNavMenu.targetList = wpNavMenu.menuList;
|
||||
|
||||
// Add attributes needed by wpNavMenu
|
||||
// Add attributes needed by wpNavMenu.
|
||||
$( '#menu-to-edit' ).removeAttr( 'id' );
|
||||
wpNavMenu.menuList.attr( 'id', 'menu-to-edit' ).addClass( 'menu' );
|
||||
|
||||
@ -1145,7 +1147,8 @@
|
||||
wpNavMenu.initSortables(); // Depends on menu-to-edit ID being set above.
|
||||
section.deferred.initSortables.resolve( wpNavMenu.menuList ); // Now MenuControl can extend the sortable.
|
||||
|
||||
// @todo Note that wp.customize.reflowPaneContents() is debounced, so this immediate change will show a slight flicker while priorities get updated.
|
||||
// @todo Note that wp.customize.reflowPaneContents() is debounced,
|
||||
// so this immediate change will show a slight flicker while priorities get updated.
|
||||
api.control( 'nav_menu[' + String( section.params.menu_id ) + ']' ).reflowMenuItems();
|
||||
}
|
||||
if ( _.isFunction( completeCallback ) ) {
|
||||
@ -1415,7 +1418,7 @@
|
||||
navMenuLocationSetting = api( 'nav_menu_locations[' + checkbox.data( 'location-id' ) + ']' );
|
||||
navMenuLocationSetting.set( menuSection.params.menu_id );
|
||||
|
||||
// Reset state for next new menu
|
||||
// Reset state for next new menu.
|
||||
checkbox.prop( 'checked', false );
|
||||
}
|
||||
} );
|
||||
@ -1698,7 +1701,8 @@
|
||||
control.elements.classes = new api.Element( control.container.find( '.edit-menu-item-classes' ) );
|
||||
control.elements.xfn = new api.Element( control.container.find( '.edit-menu-item-xfn' ) );
|
||||
control.elements.description = new api.Element( control.container.find( '.edit-menu-item-description' ) );
|
||||
// @todo allow other elements, added by plugins, to be automatically picked up here; allow additional values to be added to setting array.
|
||||
// @todo Allow other elements, added by plugins, to be automatically picked up here;
|
||||
// allow additional values to be added to setting array.
|
||||
|
||||
_.each( control.elements, function( element, property ) {
|
||||
element.bind(function( value ) {
|
||||
@ -1790,7 +1794,7 @@
|
||||
$removeBtn = control.container.find( '.item-delete' );
|
||||
|
||||
$removeBtn.on( 'click', function() {
|
||||
// Find an adjacent element to add focus to when this menu item goes away
|
||||
// Find an adjacent element to add focus to when this menu item goes away.
|
||||
var addingItems = true, $adjacentFocusTarget, $next, $prev;
|
||||
|
||||
if ( ! $( 'body' ).hasClass( 'adding-menu-items' ) ) {
|
||||
@ -1811,7 +1815,7 @@
|
||||
control.container.slideUp( function() {
|
||||
control.setting.set( false );
|
||||
wp.a11y.speak( api.Menus.data.l10n.itemDeleted );
|
||||
$adjacentFocusTarget.focus(); // keyboard accessibility
|
||||
$adjacentFocusTarget.focus(); // Keyboard accessibility.
|
||||
} );
|
||||
|
||||
control.setting.set( false );
|
||||
@ -2778,13 +2782,13 @@
|
||||
action = sectionTitle.find( '.customize-action' ),
|
||||
name = displayNavMenuName( menu.name );
|
||||
|
||||
// Update the control title
|
||||
// Update the control title.
|
||||
controlTitle.text( name );
|
||||
if ( location.length ) {
|
||||
location.appendTo( controlTitle );
|
||||
}
|
||||
|
||||
// Update the section title
|
||||
// Update the section title.
|
||||
sectionTitle.text( name );
|
||||
if ( action.length ) {
|
||||
action.prependTo( sectionTitle );
|
||||
@ -2981,7 +2985,7 @@
|
||||
position: position
|
||||
}
|
||||
);
|
||||
delete item.id; // only used by Backbone
|
||||
delete item.id; // Only used by Backbone.
|
||||
|
||||
placeholderId = api.Menus.generatePlaceholderAutoIncrementId();
|
||||
customizeId = 'nav_menu_item[' + String( placeholderId ) + ']';
|
||||
|
@ -672,7 +672,7 @@ wp.customize.widgetsPreview = wp.customize.WidgetCustomizerPreview = (function(
|
||||
self.preview.send( 'highlight-widget-control', $( this ).prop( 'id' ) );
|
||||
});
|
||||
|
||||
// Open expand the widget control when shift+clicking the widget element
|
||||
// Open expand the widget control when shift+clicking the widget element.
|
||||
$( document ).on( 'click', selector, function( e ) {
|
||||
if ( ! e.shiftKey ) {
|
||||
return;
|
||||
|
@ -232,8 +232,8 @@
|
||||
*
|
||||
* @since 4.7.0
|
||||
* @access protected
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
api.addLinkPreviewing = function addLinkPreviewing() {
|
||||
@ -337,7 +337,7 @@
|
||||
api.prepareLinkPreview = function prepareLinkPreview( element ) {
|
||||
var queryParams, $element = $( element );
|
||||
|
||||
// Skip elements with no href attribute. Check first to avoid more expensive checks down the road
|
||||
// Skip elements with no href attribute. Check first to avoid more expensive checks down the road.
|
||||
if ( ! element.hasAttribute( 'href' ) ) {
|
||||
return;
|
||||
}
|
||||
@ -357,7 +357,7 @@
|
||||
element.protocol = 'https:';
|
||||
}
|
||||
|
||||
// Ignore links with class wp-playlist-caption
|
||||
// Ignore links with class wp-playlist-caption.
|
||||
if ( $element.hasClass( 'wp-playlist-caption' ) ) {
|
||||
return;
|
||||
}
|
||||
|
@ -442,7 +442,7 @@ wp.customize.selectiveRefresh = ( function( $, api ) {
|
||||
|
||||
if ( partial.params.containerInclusive ) {
|
||||
|
||||
// Note that content may be an empty string, and in this case jQuery will just remove the oldContainer
|
||||
// Note that content may be an empty string, and in this case jQuery will just remove the oldContainer.
|
||||
newContainerElement = $( content );
|
||||
|
||||
// Merge the new context on top of the old context.
|
||||
|
@ -17,7 +17,7 @@
|
||||
api.Widgets = api.Widgets || {};
|
||||
api.Widgets.savedWidgetIds = {};
|
||||
|
||||
// Link settings
|
||||
// Link settings.
|
||||
api.Widgets.data = _wpCustomizeWidgetsSettings || {};
|
||||
l10n = api.Widgets.data.l10n;
|
||||
|
||||
@ -59,16 +59,16 @@
|
||||
model: api.Widgets.WidgetModel,
|
||||
|
||||
// Controls searching on the current widget collection
|
||||
// and triggers an update event
|
||||
// and triggers an update event.
|
||||
doSearch: function( value ) {
|
||||
|
||||
// Don't do anything if we've already done this search
|
||||
// Useful because the search handler fires multiple times per keystroke
|
||||
// Don't do anything if we've already done this search.
|
||||
// Useful because the search handler fires multiple times per keystroke.
|
||||
if ( this.terms === value ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Updates terms with the value passed
|
||||
// Updates terms with the value passed.
|
||||
this.terms = value;
|
||||
|
||||
// If we have terms, run a search...
|
||||
@ -84,16 +84,16 @@
|
||||
}
|
||||
},
|
||||
|
||||
// Performs a search within the collection
|
||||
// Performs a search within the collection.
|
||||
// @uses RegExp
|
||||
search: function( term ) {
|
||||
var match, haystack;
|
||||
|
||||
// Escape the term string for RegExp meta characters
|
||||
// Escape the term string for RegExp meta characters.
|
||||
term = term.replace( /[-\/\\^$*+?.()|[\]{}]/g, '\\$&' );
|
||||
|
||||
// Consider spaces as word delimiters and match the whole string
|
||||
// so matching terms can be combined
|
||||
// so matching terms can be combined.
|
||||
term = term.replace( / /g, ')(?=.*' );
|
||||
match = new RegExp( '^(?=.*' + term + ').+', 'i' );
|
||||
|
||||
@ -150,10 +150,10 @@
|
||||
'keydown' : 'keyboardAccessible'
|
||||
},
|
||||
|
||||
// Cache current selected widget
|
||||
// Cache current selected widget.
|
||||
selected: null,
|
||||
|
||||
// Cache sidebar control which has opened panel
|
||||
// Cache sidebar control which has opened panel.
|
||||
currentSidebarControl: null,
|
||||
$search: null,
|
||||
$clearResults: null,
|
||||
@ -181,9 +181,11 @@
|
||||
// Set the initial search count to the number of available widgets.
|
||||
this.searchMatchesCount = this.collection.length;
|
||||
|
||||
// If the available widgets panel is open and the customize controls are
|
||||
// interacted with (i.e. available widgets panel is blurred) then close the
|
||||
// available widgets panel. Also close on back button click.
|
||||
/*
|
||||
* If the available widgets panel is open and the customize controls
|
||||
* are interacted with (i.e. available widgets panel is blurred) then
|
||||
* close the available widgets panel. Also close on back button click.
|
||||
*/
|
||||
$( '#customize-controls, #available-widgets .customize-section-title' ).on( 'click keydown', function( e ) {
|
||||
var isAddNewBtn = $( e.target ).is( '.add-new-widget, .add-new-widget *' );
|
||||
if ( $( 'body' ).hasClass( 'adding-widget' ) && ! isAddNewBtn ) {
|
||||
@ -197,7 +199,7 @@
|
||||
self.collection.doSearch( '' );
|
||||
} );
|
||||
|
||||
// Close the panel if the URL in the preview changes
|
||||
// Close the panel if the URL in the preview changes.
|
||||
api.previewer.bind( 'url', this.close );
|
||||
},
|
||||
|
||||
@ -213,19 +215,19 @@
|
||||
// Announce how many search results.
|
||||
this.announceSearchMatches();
|
||||
|
||||
// Remove a widget from being selected if it is no longer visible
|
||||
// Remove a widget from being selected if it is no longer visible.
|
||||
if ( this.selected && ! this.selected.is( ':visible' ) ) {
|
||||
this.selected.removeClass( 'selected' );
|
||||
this.selected = null;
|
||||
}
|
||||
|
||||
// If a widget was selected but the filter value has been cleared out, clear selection
|
||||
// If a widget was selected but the filter value has been cleared out, clear selection.
|
||||
if ( this.selected && ! event.target.value ) {
|
||||
this.selected.removeClass( 'selected' );
|
||||
this.selected = null;
|
||||
}
|
||||
|
||||
// If a filter has been entered and a widget hasn't been selected, select the first one shown
|
||||
// If a filter has been entered and a widget hasn't been selected, select the first one shown.
|
||||
if ( ! this.selected && event.target.value ) {
|
||||
firstVisible = this.$el.find( '> .widget-tpl:visible:first' );
|
||||
if ( firstVisible.length ) {
|
||||
@ -301,7 +303,7 @@
|
||||
* Handles submit for keypress and click on widget.
|
||||
*/
|
||||
_submit: function( event ) {
|
||||
// Only proceed with keypress if it is Enter or Spacebar
|
||||
// Only proceed with keypress if it is Enter or Spacebar.
|
||||
if ( event.type === 'keypress' && ( event.which !== 13 && event.which !== 32 ) ) {
|
||||
return;
|
||||
}
|
||||
@ -345,7 +347,7 @@
|
||||
open: function( sidebarControl ) {
|
||||
this.currentSidebarControl = sidebarControl;
|
||||
|
||||
// Wide widget controls appear over the preview, and so they need to be collapsed when the panel opens
|
||||
// Wide widget controls appear over the preview, and so they need to be collapsed when the panel opens.
|
||||
_( this.currentSidebarControl.getWidgetFormControls() ).each( function( control ) {
|
||||
if ( control.params.is_wide ) {
|
||||
control.collapseForm();
|
||||
@ -360,7 +362,7 @@
|
||||
|
||||
this.$el.find( '.selected' ).removeClass( 'selected' );
|
||||
|
||||
// Reset search
|
||||
// Reset search.
|
||||
this.collection.doSearch( '' );
|
||||
|
||||
if ( ! api.settings.browser.mobile ) {
|
||||
@ -428,7 +430,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// If enter pressed but nothing entered, don't do anything
|
||||
// If enter pressed but nothing entered, don't do anything.
|
||||
if ( isEnter && ! this.$search.val() ) {
|
||||
return;
|
||||
}
|
||||
@ -602,7 +604,7 @@
|
||||
_setupModel: function() {
|
||||
var self = this, rememberSavedWidgetId;
|
||||
|
||||
// Remember saved widgets so we know which to trash (move to inactive widgets sidebar)
|
||||
// Remember saved widgets so we know which to trash (move to inactive widgets sidebar).
|
||||
rememberSavedWidgetId = function() {
|
||||
api.Widgets.savedWidgetIds[self.params.widget_id] = true;
|
||||
};
|
||||
@ -613,7 +615,7 @@
|
||||
this.isWidgetUpdating = false;
|
||||
this.liveUpdateMode = true;
|
||||
|
||||
// Update widget whenever model changes
|
||||
// Update widget whenever model changes.
|
||||
this.setting.bind( function( to, from ) {
|
||||
if ( ! _( from ).isEqual( to ) && ! self.isWidgetUpdating ) {
|
||||
self.updateWidget( { instance: to } );
|
||||
@ -658,10 +660,10 @@
|
||||
top;
|
||||
$widgetInside.css( 'max-height', windowHeight );
|
||||
top = Math.max(
|
||||
0, // prevent top from going off screen
|
||||
0, // Prevent top from going off screen.
|
||||
Math.min(
|
||||
Math.max( offsetTop, 0 ), // distance widget in panel is from top of screen
|
||||
windowHeight - formHeight // flush up against bottom of screen
|
||||
Math.max( offsetTop, 0 ), // Distance widget in panel is from top of screen.
|
||||
windowHeight - formHeight // Flush up against bottom of screen.
|
||||
)
|
||||
);
|
||||
$widgetInside.css( 'top', top );
|
||||
@ -680,7 +682,7 @@
|
||||
$themeControlsContainer.off( 'expanded collapsed', positionWidget );
|
||||
} );
|
||||
|
||||
// Reposition whenever a sidebar's widgets are changed
|
||||
// Reposition whenever a sidebar's widgets are changed.
|
||||
api.each( function( setting ) {
|
||||
if ( 0 === setting.id.indexOf( 'sidebars_widgets[' ) ) {
|
||||
setting.bind( function() {
|
||||
@ -711,7 +713,7 @@
|
||||
$closeBtn = this.container.find( '.widget-control-close' );
|
||||
$closeBtn.on( 'click', function() {
|
||||
self.collapse();
|
||||
self.container.find( '.widget-top .widget-action:first' ).focus(); // keyboard accessibility
|
||||
self.container.find( '.widget-top .widget-action:first' ).focus(); // Keyboard accessibility.
|
||||
} );
|
||||
},
|
||||
|
||||
@ -838,7 +840,7 @@
|
||||
wp.a11y.speak( l10n.widgetMovedDown );
|
||||
}
|
||||
|
||||
$( this ).focus(); // re-focus after the container was moved
|
||||
$( this ).focus(); // Re-focus after the container was moved.
|
||||
}
|
||||
} );
|
||||
|
||||
@ -886,12 +888,12 @@
|
||||
_setupHighlightEffects: function() {
|
||||
var self = this;
|
||||
|
||||
// Highlight whenever hovering or clicking over the form
|
||||
// Highlight whenever hovering or clicking over the form.
|
||||
this.container.on( 'mouseenter click', function() {
|
||||
self.setting.previewer.send( 'highlight-widget', self.params.widget_id );
|
||||
} );
|
||||
|
||||
// Highlight when the setting is updated
|
||||
// Highlight when the setting is updated.
|
||||
this.setting.bind( function() {
|
||||
self.setting.previewer.send( 'highlight-widget', self.params.widget_id );
|
||||
} );
|
||||
@ -907,7 +909,7 @@
|
||||
$widgetRoot = this.container.find( '.widget:first' );
|
||||
$widgetContent = $widgetRoot.find( '.widget-content:first' );
|
||||
|
||||
// Configure update button
|
||||
// Configure update button.
|
||||
$saveBtn = this.container.find( '.widget-control-save' );
|
||||
$saveBtn.val( l10n.saveBtnLabel );
|
||||
$saveBtn.attr( 'title', l10n.saveBtnTooltip );
|
||||
@ -921,15 +923,15 @@
|
||||
self.updateWidget();
|
||||
}, 250 );
|
||||
|
||||
// Trigger widget form update when hitting Enter within an input
|
||||
// Trigger widget form update when hitting Enter within an input.
|
||||
$widgetContent.on( 'keydown', 'input', function( e ) {
|
||||
if ( 13 === e.which ) { // Enter
|
||||
if ( 13 === e.which ) { // Enter.
|
||||
e.preventDefault();
|
||||
self.updateWidget( { ignoreActiveElement: true } );
|
||||
}
|
||||
} );
|
||||
|
||||
// Handle widgets that support live previews
|
||||
// Handle widgets that support live previews.
|
||||
$widgetContent.on( 'change input propertychange', ':input', function( e ) {
|
||||
if ( ! self.liveUpdateMode ) {
|
||||
return;
|
||||
@ -939,7 +941,7 @@
|
||||
}
|
||||
} );
|
||||
|
||||
// Remove loading indicators when the setting is saved and the preview updates
|
||||
// Remove loading indicators when the setting is saved and the preview updates.
|
||||
this.setting.previewer.channel.bind( 'synced', function() {
|
||||
self.container.removeClass( 'previewer-loading' );
|
||||
} );
|
||||
@ -972,7 +974,7 @@
|
||||
* @param {function} args.completeCallback
|
||||
*/
|
||||
onChangeActive: function ( active, args ) {
|
||||
// Note: there is a second 'args' parameter being passed, merged on top of this.defaultActiveArguments
|
||||
// Note: there is a second 'args' parameter being passed, merged on top of this.defaultActiveArguments.
|
||||
this.container.toggleClass( 'widget-rendered', active );
|
||||
if ( args.completeCallback ) {
|
||||
args.completeCallback();
|
||||
@ -985,10 +987,10 @@
|
||||
_setupRemoveUI: function() {
|
||||
var self = this, $removeBtn, replaceDeleteWithRemove;
|
||||
|
||||
// Configure remove button
|
||||
// Configure remove button.
|
||||
$removeBtn = this.container.find( '.widget-control-remove' );
|
||||
$removeBtn.on( 'click', function() {
|
||||
// Find an adjacent element to add focus to when this widget goes away
|
||||
// Find an adjacent element to add focus to when this widget goes away.
|
||||
var $adjacentFocusTarget;
|
||||
if ( self.container.next().is( '.customize-control-widget_form' ) ) {
|
||||
$adjacentFocusTarget = self.container.next().find( '.widget-action:first' );
|
||||
@ -1015,12 +1017,12 @@
|
||||
sidebarWidgetIds.splice( i, 1 );
|
||||
sidebarsWidgetsControl.setting( sidebarWidgetIds );
|
||||
|
||||
$adjacentFocusTarget.focus(); // keyboard accessibility
|
||||
$adjacentFocusTarget.focus(); // Keyboard accessibility.
|
||||
} );
|
||||
} );
|
||||
|
||||
replaceDeleteWithRemove = function() {
|
||||
$removeBtn.text( l10n.removeBtnLabel ); // wp_widget_control() outputs the button as "Delete"
|
||||
$removeBtn.text( l10n.removeBtnLabel ); // wp_widget_control() outputs the button as "Delete".
|
||||
$removeBtn.attr( 'title', l10n.removeBtnTooltip );
|
||||
};
|
||||
|
||||
@ -1105,7 +1107,7 @@
|
||||
if ( ! $.isArray( state ) ) {
|
||||
state = [];
|
||||
} else {
|
||||
// Make sure all state items are strings since the DOM value is a string
|
||||
// Make sure all state items are strings since the DOM value is a string.
|
||||
state = _.map( state, function ( value ) {
|
||||
return String( value );
|
||||
} );
|
||||
@ -1169,7 +1171,7 @@
|
||||
$widgetRoot = this.container.find( '.widget:first' );
|
||||
$widgetContent = $widgetRoot.find( '.widget-content:first' );
|
||||
|
||||
// Remove a previous error message
|
||||
// Remove a previous error message.
|
||||
$widgetContent.find( '.widget-error' ).remove();
|
||||
|
||||
this.container.addClass( 'widget-form-loading' );
|
||||
@ -1191,9 +1193,11 @@
|
||||
data = $.param( params );
|
||||
$inputs = this._getInputs( $widgetContent );
|
||||
|
||||
// Store the value we're submitting in data so that when the response comes back,
|
||||
// we know if it got sanitized; if there is no difference in the sanitized value,
|
||||
// then we do not need to touch the UI and mess up the user's ongoing editing.
|
||||
/*
|
||||
* Store the value we're submitting in data so that when the response comes back,
|
||||
* we know if it got sanitized; if there is no difference in the sanitized value,
|
||||
* then we do not need to touch the UI and mess up the user's ongoing editing.
|
||||
*/
|
||||
$inputs.each( function() {
|
||||
$( this ).data( 'state' + updateNumber, self._getInputState( this ) );
|
||||
} );
|
||||
@ -1236,14 +1240,14 @@
|
||||
$sanitizedInputs = self._getInputs( sanitizedForm );
|
||||
hasSameInputsInResponse = self._getInputsSignature( $inputs ) === self._getInputsSignature( $sanitizedInputs );
|
||||
|
||||
// Restore live update mode if sanitized fields are now aligned with the existing fields
|
||||
// Restore live update mode if sanitized fields are now aligned with the existing fields.
|
||||
if ( hasSameInputsInResponse && ! self.liveUpdateMode ) {
|
||||
self.liveUpdateMode = true;
|
||||
self.container.removeClass( 'widget-form-disabled' );
|
||||
self.container.find( 'input[name="savewidget"]' ).hide();
|
||||
}
|
||||
|
||||
// Sync sanitized field states to existing fields if they are aligned
|
||||
// Sync sanitized field states to existing fields if they are aligned.
|
||||
if ( hasSameInputsInResponse && self.liveUpdateMode ) {
|
||||
$inputs.each( function( i ) {
|
||||
var $input = $( this ),
|
||||
@ -1262,13 +1266,13 @@
|
||||
|
||||
$( document ).trigger( 'widget-synced', [ $widgetRoot, r.data.form ] );
|
||||
|
||||
// Otherwise, if sanitized fields are not aligned with existing fields, disable live update mode if enabled
|
||||
// Otherwise, if sanitized fields are not aligned with existing fields, disable live update mode if enabled.
|
||||
} else if ( self.liveUpdateMode ) {
|
||||
self.liveUpdateMode = false;
|
||||
self.container.find( 'input[name="savewidget"]' ).show();
|
||||
isLiveUpdateAborted = true;
|
||||
|
||||
// Otherwise, replace existing form with the sanitized form
|
||||
// Otherwise, replace existing form with the sanitized form.
|
||||
} else {
|
||||
$widgetContent.html( r.data.form );
|
||||
|
||||
@ -1284,11 +1288,11 @@
|
||||
*/
|
||||
isChanged = ! isLiveUpdateAborted && ! _( self.setting() ).isEqual( r.data.instance );
|
||||
if ( isChanged ) {
|
||||
self.isWidgetUpdating = true; // suppress triggering another updateWidget
|
||||
self.isWidgetUpdating = true; // Suppress triggering another updateWidget.
|
||||
self.setting( r.data.instance );
|
||||
self.isWidgetUpdating = false;
|
||||
} else {
|
||||
// no change was made, so stop the spinner now instead of when the preview would updates
|
||||
// No change was made, so stop the spinner now instead of when the preview would updates.
|
||||
self.container.removeClass( 'previewer-loading' );
|
||||
}
|
||||
|
||||
@ -1296,7 +1300,7 @@
|
||||
completeCallback.call( self, null, { noChange: ! isChanged, ajaxFinished: true } );
|
||||
}
|
||||
} else {
|
||||
// General error message
|
||||
// General error message.
|
||||
message = l10n.error;
|
||||
|
||||
if ( r.data && r.data.message ) {
|
||||
@ -1406,7 +1410,7 @@
|
||||
self.embedWidgetContent();
|
||||
}
|
||||
|
||||
// If the expanded state is unchanged only manipulate container expanded states
|
||||
// If the expanded state is unchanged only manipulate container expanded states.
|
||||
if ( args.unchanged ) {
|
||||
if ( expanded ) {
|
||||
api.Control.prototype.expand.call( self, {
|
||||
@ -1422,7 +1426,7 @@
|
||||
|
||||
expandControl = function() {
|
||||
|
||||
// Close all other widget controls before expanding this one
|
||||
// Close all other widget controls before expanding this one.
|
||||
api.control.each( function( otherControl ) {
|
||||
if ( self.params.type === otherControl.params.type && self !== otherControl ) {
|
||||
otherControl.collapse();
|
||||
@ -1535,7 +1539,7 @@
|
||||
i = this.getWidgetSidebarPosition();
|
||||
|
||||
sidebarWidgetsSetting = this.getSidebarWidgetsControl().setting;
|
||||
sidebarWidgetIds = Array.prototype.slice.call( sidebarWidgetsSetting() ); // clone
|
||||
sidebarWidgetIds = Array.prototype.slice.call( sidebarWidgetsSetting() ); // Clone.
|
||||
adjacentWidgetId = sidebarWidgetIds[i + offset];
|
||||
sidebarWidgetIds[i + offset] = this.params.widget_id;
|
||||
sidebarWidgetIds[i] = adjacentWidgetId;
|
||||
@ -1558,7 +1562,7 @@
|
||||
}
|
||||
|
||||
if ( showOrHide ) {
|
||||
// reset the selected sidebar
|
||||
// Reset the selected sidebar.
|
||||
$moveWidgetArea.find( '.selected' ).removeClass( 'selected' );
|
||||
|
||||
$moveWidgetArea.find( 'li' ).filter( function() {
|
||||
@ -1781,7 +1785,7 @@
|
||||
|
||||
removedWidgetIds = _( oldWidgetIds ).difference( newWidgetIds );
|
||||
|
||||
// Filter out any persistent widget IDs for widgets which have been deactivated
|
||||
// Filter out any persistent widget IDs for widgets which have been deactivated.
|
||||
newWidgetIds = _( newWidgetIds ).filter( function( newWidgetId ) {
|
||||
var parsedWidgetId = parseWidgetId( newWidgetId );
|
||||
|
||||
@ -1798,7 +1802,7 @@
|
||||
return widgetFormControl;
|
||||
} );
|
||||
|
||||
// Sort widget controls to their new positions
|
||||
// Sort widget controls to their new positions.
|
||||
widgetFormControls.sort( function( a, b ) {
|
||||
var aIndex = _.indexOf( newWidgetIds, a.params.widget_id ),
|
||||
bIndex = _.indexOf( newWidgetIds, b.params.widget_id );
|
||||
@ -1811,25 +1815,26 @@
|
||||
control.section( self.section() );
|
||||
priority += 1;
|
||||
});
|
||||
self.priority( priority ); // Make sure sidebar control remains at end
|
||||
self.priority( priority ); // Make sure sidebar control remains at end.
|
||||
|
||||
// Re-sort widget form controls (including widgets form other sidebars newly moved here)
|
||||
// Re-sort widget form controls (including widgets form other sidebars newly moved here).
|
||||
self._applyCardinalOrderClassNames();
|
||||
|
||||
// If the widget was dragged into the sidebar, make sure the sidebar_id param is updated
|
||||
// If the widget was dragged into the sidebar, make sure the sidebar_id param is updated.
|
||||
_( widgetFormControls ).each( function( widgetFormControl ) {
|
||||
widgetFormControl.params.sidebar_id = self.params.sidebar_id;
|
||||
} );
|
||||
|
||||
// Cleanup after widget removal
|
||||
// Cleanup after widget removal.
|
||||
_( removedWidgetIds ).each( function( removedWidgetId ) {
|
||||
|
||||
// Using setTimeout so that when moving a widget to another sidebar, the other sidebars_widgets settings get a chance to update
|
||||
// Using setTimeout so that when moving a widget to another sidebar,
|
||||
// the other sidebars_widgets settings get a chance to update.
|
||||
setTimeout( function() {
|
||||
var removedControl, wasDraggedToAnotherSidebar, inactiveWidgets, removedIdBase,
|
||||
widget, isPresentInAnotherSidebar = false;
|
||||
|
||||
// Check if the widget is in another sidebar
|
||||
// Check if the widget is in another sidebar.
|
||||
api.each( function( otherSetting ) {
|
||||
if ( otherSetting.id === self.setting.id || 0 !== otherSetting.id.indexOf( 'sidebars_widgets[' ) || otherSetting.id === 'sidebars_widgets[wp_inactive_widgets]' ) {
|
||||
return;
|
||||
@ -1850,24 +1855,24 @@
|
||||
|
||||
removedControl = api.Widgets.getWidgetFormControlForWidget( removedWidgetId );
|
||||
|
||||
// Detect if widget control was dragged to another sidebar
|
||||
// Detect if widget control was dragged to another sidebar.
|
||||
wasDraggedToAnotherSidebar = removedControl && $.contains( document, removedControl.container[0] ) && ! $.contains( self.$sectionContent[0], removedControl.container[0] );
|
||||
|
||||
// Delete any widget form controls for removed widgets
|
||||
// Delete any widget form controls for removed widgets.
|
||||
if ( removedControl && ! wasDraggedToAnotherSidebar ) {
|
||||
api.control.remove( removedControl.id );
|
||||
removedControl.container.remove();
|
||||
}
|
||||
|
||||
// Move widget to inactive widgets sidebar (move it to trash) if has been previously saved
|
||||
// This prevents the inactive widgets sidebar from overflowing with throwaway widgets
|
||||
// Move widget to inactive widgets sidebar (move it to trash) if has been previously saved.
|
||||
// This prevents the inactive widgets sidebar from overflowing with throwaway widgets.
|
||||
if ( api.Widgets.savedWidgetIds[removedWidgetId] ) {
|
||||
inactiveWidgets = api.value( 'sidebars_widgets[wp_inactive_widgets]' )().slice();
|
||||
inactiveWidgets.push( removedWidgetId );
|
||||
api.value( 'sidebars_widgets[wp_inactive_widgets]' )( _( inactiveWidgets ).unique() );
|
||||
}
|
||||
|
||||
// Make old single widget available for adding again
|
||||
// Make old single widget available for adding again.
|
||||
removedIdBase = parseWidgetId( removedWidgetId ).id_base;
|
||||
widget = api.Widgets.availableWidgets.findWhere( { id_base: removedIdBase } );
|
||||
if ( widget && ! widget.get( 'is_multi' ) ) {
|
||||
@ -1916,9 +1921,9 @@
|
||||
over: function() {
|
||||
var section = api.section( self.section.get() );
|
||||
section.expand({
|
||||
allowMultiple: true, // Prevent the section being dragged from to be collapsed
|
||||
allowMultiple: true, // Prevent the section being dragged from to be collapsed.
|
||||
completeCallback: function () {
|
||||
// @todo It is not clear when refreshPositions should be called on which sections, or if it is even needed
|
||||
// @todo It is not clear when refreshPositions should be called on which sections, or if it is even needed.
|
||||
api.section.each( function ( otherSection ) {
|
||||
if ( otherSection.container.find( '.customize-control-sidebar_widgets' ).length ) {
|
||||
otherSection.container.find( '.accordion-section-content:first' ).sortable( 'refreshPositions' );
|
||||
@ -2079,7 +2084,7 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set up new multi widget
|
||||
// Set up new multi widget.
|
||||
if ( widget.get( 'is_multi' ) && ! widgetNumber ) {
|
||||
widget.set( 'multi_number', widget.get( 'multi_number' ) + 1 );
|
||||
widgetNumber = widget.get( 'multi_number' );
|
||||
@ -2091,7 +2096,7 @@
|
||||
return m.replace( /__i__|%i%/g, widgetNumber );
|
||||
} );
|
||||
} else {
|
||||
widget.set( 'is_disabled', true ); // Prevent single widget from being added again now
|
||||
widget.set( 'is_disabled', true ); // Prevent single widget from being added again now.
|
||||
}
|
||||
|
||||
$widget = $( controlHtml );
|
||||
@ -2101,7 +2106,7 @@
|
||||
.addClass( 'customize-control-' + controlType )
|
||||
.append( $widget );
|
||||
|
||||
// Remove icon which is visible inside the panel
|
||||
// Remove icon which is visible inside the panel.
|
||||
controlContainer.find( '> .widget-icon' ).remove();
|
||||
|
||||
if ( widget.get( 'is_multi' ) ) {
|
||||
@ -2111,7 +2116,7 @@
|
||||
|
||||
widgetId = controlContainer.find( '[name="widget-id"]' ).val();
|
||||
|
||||
controlContainer.hide(); // to be slid-down below
|
||||
controlContainer.hide(); // To be slid-down below.
|
||||
|
||||
settingId = 'widget_' + widget.get( 'id_base' );
|
||||
if ( widget.get( 'is_multi' ) ) {
|
||||
@ -2119,7 +2124,7 @@
|
||||
}
|
||||
controlContainer.attr( 'id', 'customize-control-' + settingId.replace( /\]/g, '' ).replace( /\[/g, '-' ) );
|
||||
|
||||
// Only create setting if it doesn't already exist (if we're adding a pre-existing inactive widget)
|
||||
// Only create setting if it doesn't already exist (if we're adding a pre-existing inactive widget).
|
||||
isExistingWidget = api.has( settingId );
|
||||
if ( ! isExistingWidget ) {
|
||||
settingArgs = {
|
||||
@ -2127,7 +2132,7 @@
|
||||
previewer: this.setting.previewer
|
||||
};
|
||||
setting = api.create( settingId, settingId, '', settingArgs );
|
||||
setting.set( {} ); // mark dirty, changing from '' to {}
|
||||
setting.set( {} ); // Mark dirty, changing from '' to {}.
|
||||
}
|
||||
|
||||
controlConstructor = api.controlConstructor[controlType];
|
||||
@ -2147,7 +2152,7 @@
|
||||
} );
|
||||
api.control.add( widgetFormControl );
|
||||
|
||||
// Make sure widget is removed from the other sidebars
|
||||
// Make sure widget is removed from the other sidebars.
|
||||
api.each( function( otherSetting ) {
|
||||
if ( otherSetting.id === self.setting.id ) {
|
||||
return;
|
||||
@ -2166,7 +2171,7 @@
|
||||
}
|
||||
} );
|
||||
|
||||
// Add widget to this sidebar
|
||||
// Add widget to this sidebar.
|
||||
sidebarWidgets = this.setting().slice();
|
||||
if ( -1 === _.indexOf( sidebarWidgets, widgetId ) ) {
|
||||
sidebarWidgets.push( widgetId );
|
||||
@ -2185,7 +2190,7 @@
|
||||
}
|
||||
} );
|
||||
|
||||
// Register models for custom panel, section, and control types
|
||||
// Register models for custom panel, section, and control types.
|
||||
$.extend( api.panelConstructor, {
|
||||
widgets: api.Widgets.WidgetsPanel
|
||||
});
|
||||
@ -2201,15 +2206,15 @@
|
||||
* Init Customizer for widgets.
|
||||
*/
|
||||
api.bind( 'ready', function() {
|
||||
// Set up the widgets panel
|
||||
// Set up the widgets panel.
|
||||
api.Widgets.availableWidgetsPanel = new api.Widgets.AvailableWidgetsPanelView({
|
||||
collection: api.Widgets.availableWidgets
|
||||
});
|
||||
|
||||
// Highlight widget control
|
||||
// Highlight widget control.
|
||||
api.previewer.bind( 'highlight-widget-control', api.Widgets.highlightWidgetFormControl );
|
||||
|
||||
// Open and focus widget control
|
||||
// Open and focus widget control.
|
||||
api.previewer.bind( 'focus-widget-control', api.Widgets.focusWidgetFormControl );
|
||||
} );
|
||||
|
||||
@ -2247,7 +2252,7 @@
|
||||
api.Widgets.getSidebarWidgetControlContainingWidget = function( widgetId ) {
|
||||
var foundControl = null;
|
||||
|
||||
// @todo this can use widgetIdToSettingId(), then pass into wp.customize.control( x ).getSidebarWidgetsControl()
|
||||
// @todo This can use widgetIdToSettingId(), then pass into wp.customize.control( x ).getSidebarWidgetsControl().
|
||||
api.control.each( function( control ) {
|
||||
if ( control.params.type === 'sidebar_widgets' && -1 !== _.indexOf( control.setting(), widgetId ) ) {
|
||||
foundControl = control;
|
||||
@ -2266,7 +2271,7 @@
|
||||
api.Widgets.getWidgetFormControlForWidget = function( widgetId ) {
|
||||
var foundControl = null;
|
||||
|
||||
// @todo We can just use widgetIdToSettingId() here
|
||||
// @todo We can just use widgetIdToSettingId() here.
|
||||
api.control.each( function( control ) {
|
||||
if ( control.params.type === 'widget_form' && control.params.widget_id === widgetId ) {
|
||||
foundControl = control;
|
||||
@ -2343,7 +2348,7 @@
|
||||
parsed.id_base = matches[1];
|
||||
parsed.number = parseInt( matches[2], 10 );
|
||||
} else {
|
||||
// likely an old single widget
|
||||
// Likely an old single widget.
|
||||
parsed.id_base = widgetId;
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ window.wp = window.wp || {};
|
||||
}
|
||||
|
||||
if ( keepSelection ) {
|
||||
// Save the selection
|
||||
// Save the selection.
|
||||
addHTMLBookmarkInTextAreaContent( $textarea );
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ window.wp = window.wp || {};
|
||||
}
|
||||
|
||||
if ( editor.getParam( 'wp_keep_scroll_position' ) ) {
|
||||
// Restore the selection
|
||||
// Restore the selection.
|
||||
focusHTMLBookmarkInVisualEditor( editor );
|
||||
}
|
||||
} else {
|
||||
@ -149,7 +149,8 @@ window.wp = window.wp || {};
|
||||
}
|
||||
|
||||
if ( editor ) {
|
||||
// Don't resize the textarea in iOS. The iframe is forced to 100% height there, we shouldn't match it.
|
||||
// Don't resize the textarea in iOS.
|
||||
// The iframe is forced to 100% height there, we shouldn't match it.
|
||||
if ( ! tinymce.Env.iOS ) {
|
||||
iframe = editor.iframeElement;
|
||||
editorHeight = iframe ? parseInt( iframe.style.height, 10 ) : 0;
|
||||
@ -177,7 +178,8 @@ window.wp = window.wp || {};
|
||||
selectTextInTextArea( editor, selectionRange );
|
||||
}
|
||||
} else {
|
||||
// There is probably a JS error on the page. The TinyMCE editor instance doesn't exist. Show the textarea.
|
||||
// There is probably a JS error on the page.
|
||||
// The TinyMCE editor instance doesn't exist. Show the textarea.
|
||||
$textarea.css({ 'display': '', 'visibility': '' });
|
||||
}
|
||||
|
||||
@ -209,7 +211,7 @@ window.wp = window.wp || {};
|
||||
lastGtPos = content.lastIndexOf( '>', cursorPosition );
|
||||
|
||||
if ( lastLtPos > lastGtPos || content.substr( cursorPosition, 1 ) === '>' ) {
|
||||
// find what the tag is
|
||||
// Find what the tag is.
|
||||
var tagContent = content.substr( lastLtPos ),
|
||||
tagMatch = tagContent.match( /<\s*(\/)?(\w+|\!-{2}.*-{2})/ );
|
||||
|
||||
@ -222,7 +224,7 @@ window.wp = window.wp || {};
|
||||
|
||||
return {
|
||||
ltPos: lastLtPos,
|
||||
gtPos: lastLtPos + closingGt + 1, // offset by one to get the position _after_ the character,
|
||||
gtPos: lastLtPos + closingGt + 1, // Offset by one to get the position _after_ the character.
|
||||
tagType: tagType,
|
||||
isClosingTag: !! tagMatch[1]
|
||||
};
|
||||
@ -248,7 +250,7 @@ window.wp = window.wp || {};
|
||||
* @param {number} cursorPosition The cursor position to check.
|
||||
*
|
||||
* @return {(undefined|Object)} Undefined if the cursor is not wrapped in a shortcode tag.
|
||||
* Information about the wrapping shortcode tag if it's wrapped in one.
|
||||
* Information about the wrapping shortcode tag if it's wrapped in one.
|
||||
*/
|
||||
function getShortcodeWrapperInfo( content, cursorPosition ) {
|
||||
var contentShortcodes = getShortCodePositionsInText( content );
|
||||
@ -403,7 +405,7 @@ window.wp = window.wp || {};
|
||||
|
||||
var cursorStart = cursorPositions.cursorStart,
|
||||
cursorEnd = cursorPositions.cursorEnd,
|
||||
// check if the cursor is in a tag and if so, adjust it
|
||||
// Check if the cursor is in a tag and if so, adjust it.
|
||||
isCursorStartInTag = getContainingTagInfo( content, cursorStart );
|
||||
|
||||
if ( isCursorStartInTag ) {
|
||||
@ -506,11 +508,11 @@ window.wp = window.wp || {};
|
||||
}
|
||||
|
||||
textArea.value = [
|
||||
textArea.value.slice( 0, htmlModeCursorStartPosition ), // text until the cursor/selection position
|
||||
cursorMarkerSkeleton.clone() // cursor/selection start marker
|
||||
textArea.value.slice( 0, htmlModeCursorStartPosition ), // Text until the cursor/selection position.
|
||||
cursorMarkerSkeleton.clone() // Cursor/selection start marker.
|
||||
.addClass( 'mce_SELRES_start' )[0].outerHTML,
|
||||
selectedText, // selected text with end cursor/position marker
|
||||
textArea.value.slice( htmlModeCursorEndPosition ) // text from last cursor/selection position to end
|
||||
selectedText, // Selected text with end cursor/position marker.
|
||||
textArea.value.slice( htmlModeCursorEndPosition ) // Text from last cursor/selection position to end.
|
||||
].join( '' );
|
||||
}
|
||||
|
||||
@ -804,7 +806,7 @@ window.wp = window.wp || {};
|
||||
endMatchIndex -= endMatch[1].length;
|
||||
}
|
||||
|
||||
// We need to adjust the end position to discard the length of the range start marker
|
||||
// We need to adjust the end position to discard the length of the range start marker.
|
||||
endIndex = endMatchIndex - startMatchLength;
|
||||
}
|
||||
|
||||
@ -826,7 +828,7 @@ window.wp = window.wp || {};
|
||||
* @param {Object} selection Selection data.
|
||||
*/
|
||||
function selectTextInTextArea( editor, selection ) {
|
||||
// only valid in the text area mode and if we have selection
|
||||
// Only valid in the text area mode and if we have selection.
|
||||
if ( ! selection ) {
|
||||
return;
|
||||
}
|
||||
@ -836,11 +838,11 @@ window.wp = window.wp || {};
|
||||
end = selection.end || selection.start;
|
||||
|
||||
if ( textArea.focus ) {
|
||||
// Wait for the Visual editor to be hidden, then focus and scroll to the position
|
||||
// Wait for the Visual editor to be hidden, then focus and scroll to the position.
|
||||
setTimeout( function() {
|
||||
textArea.setSelectionRange( start, end );
|
||||
if ( textArea.blur ) {
|
||||
// defocus before focusing
|
||||
// Defocus before focusing.
|
||||
textArea.blur();
|
||||
}
|
||||
textArea.focus();
|
||||
@ -1249,7 +1251,7 @@ window.wp = window.wp || {};
|
||||
|
||||
defaults = wp.editor.getDefaultSettings();
|
||||
|
||||
// Initialize TinyMCE by default
|
||||
// Initialize TinyMCE by default.
|
||||
if ( ! settings ) {
|
||||
settings = {
|
||||
tinymce: true
|
||||
|
@ -246,10 +246,11 @@
|
||||
function mceKeyup( event ) {
|
||||
var key = event.keyCode;
|
||||
|
||||
// Bail on special keys. Key code 47 is a /
|
||||
// Bail on special keys. Key code 47 is a '/'.
|
||||
if ( key <= 47 && ! ( key === VK.SPACEBAR || key === VK.ENTER || key === VK.DELETE || key === VK.BACKSPACE || key === VK.UP || key === VK.LEFT || key === VK.DOWN || key === VK.UP ) ) {
|
||||
return;
|
||||
// OS keys, function keys, num lock, scroll lock. Key code 91-93 are OS keys. Key code 112-123 are F1 to F12. Key code 144 is num lock. Key code 145 is scroll lock.
|
||||
// OS keys, function keys, num lock, scroll lock. Key code 91-93 are OS keys.
|
||||
// Key code 112-123 are F1 to F12. Key code 144 is num lock. Key code 145 is scroll lock.
|
||||
} else if ( ( key >= 91 && key <= 93 ) || ( key >= 112 && key <= 123 ) || key === 144 || key === 145 ) {
|
||||
return;
|
||||
}
|
||||
@ -516,7 +517,7 @@
|
||||
* If in visual mode, checks if the editorHeight is greater than the autoresizeMinHeight + topHeight.
|
||||
* If not in visual mode, checks if the editorHeight is greater than the autoresizeMinHeight + 20.
|
||||
*/
|
||||
canPin = visual ? autoresizeMinHeight + topHeight : autoresizeMinHeight + 20; // 20px from textarea padding
|
||||
canPin = visual ? autoresizeMinHeight + topHeight : autoresizeMinHeight + 20; // 20px from textarea padding.
|
||||
canPin = editorHeight > ( canPin + 5 );
|
||||
|
||||
if ( ! canPin ) {
|
||||
@ -910,7 +911,7 @@
|
||||
// Adjust when entering or exiting fullscreen mode.
|
||||
fullscreen && fullscreen.pubsub.unsubscribe( 'hidden', fullscreenHide );
|
||||
|
||||
// Reset all css
|
||||
// Reset all CSS.
|
||||
$.each( [ $visualTop, $textTop, $tools, $menuBar, $bottom, $statusBar, $contentWrap, $visualEditor, $textEditor, $sideSortables ], function( i, element ) {
|
||||
element && element.attr( 'style', '' );
|
||||
});
|
||||
@ -1179,15 +1180,15 @@
|
||||
|
||||
// Return if any of the following keys or combinations of keys is pressed.
|
||||
if ( event && ( event.metaKey || ( event.ctrlKey && ! event.altKey ) || ( event.altKey && event.shiftKey ) || ( key && (
|
||||
// Special keys ( tab, ctrl, alt, esc, arrow keys... )
|
||||
// Special keys ( tab, ctrl, alt, esc, arrow keys... ).
|
||||
( key <= 47 && key !== 8 && key !== 13 && key !== 32 && key !== 46 ) ||
|
||||
// Windows keys
|
||||
// Windows keys.
|
||||
( key >= 91 && key <= 93 ) ||
|
||||
// F keys
|
||||
// F keys.
|
||||
( key >= 112 && key <= 135 ) ||
|
||||
// Num Lock, Scroll Lock, OEM
|
||||
// Num Lock, Scroll Lock, OEM.
|
||||
( key >= 144 && key <= 150 ) ||
|
||||
// OEM or non-printable
|
||||
// OEM or non-printable.
|
||||
key >= 224
|
||||
) ) ) ) {
|
||||
return;
|
||||
|
@ -9,8 +9,8 @@
|
||||
/**
|
||||
* Replaces emoji with images when browsers don't support emoji.
|
||||
*
|
||||
* @since 4.2.0
|
||||
* @access private
|
||||
* @since 4.2.0
|
||||
* @access private
|
||||
*
|
||||
* @class
|
||||
*
|
||||
@ -22,10 +22,10 @@
|
||||
function wpEmoji() {
|
||||
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver,
|
||||
|
||||
// Compression and maintain local scope
|
||||
// Compression and maintain local scope.
|
||||
document = window.document,
|
||||
|
||||
// Private
|
||||
// Private.
|
||||
twemoji, timer,
|
||||
loaded = false,
|
||||
count = 0,
|
||||
@ -69,7 +69,7 @@
|
||||
|
||||
// Ensure twemoji is available on the global window before proceeding.
|
||||
if ( typeof window.twemoji === 'undefined' ) {
|
||||
// Break if waiting for longer than 30 sec.
|
||||
// Break if waiting for longer than 30 seconds.
|
||||
if ( count > 600 ) {
|
||||
return;
|
||||
}
|
||||
@ -245,8 +245,8 @@
|
||||
}
|
||||
|
||||
if ( settings.supports.everythingExceptFlag &&
|
||||
! /^1f1(?:e[6-9a-f]|f[0-9a-f])-1f1(?:e[6-9a-f]|f[0-9a-f])$/.test( icon ) && // Country flags
|
||||
! /^(1f3f3-fe0f-200d-1f308|1f3f4-200d-2620-fe0f)$/.test( icon ) // Rainbow and pirate flags
|
||||
! /^1f1(?:e[6-9a-f]|f[0-9a-f])-1f1(?:e[6-9a-f]|f[0-9a-f])$/.test( icon ) && // Country flags.
|
||||
! /^(1f3f3-fe0f-200d-1f308|1f3f4-200d-2620-fe0f)$/.test( icon ) // Rainbow and pirate flags.
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@
|
||||
// Connect interval (in seconds).
|
||||
mainInterval: 60,
|
||||
|
||||
// Used when the interval is set to 5 sec. temporarily.
|
||||
// Used when the interval is set to 5 seconds temporarily.
|
||||
tempInterval: 0,
|
||||
|
||||
// Used when the interval is reset.
|
||||
@ -89,7 +89,7 @@
|
||||
// Whether the current browser window is in focus and the user is active.
|
||||
hasFocus: true,
|
||||
|
||||
// Timestamp, last time the user was active. Checked every 30 sec.
|
||||
// Timestamp, last time the user was active. Checked every 30 seconds.
|
||||
userActivity: 0,
|
||||
|
||||
// Flag whether events tracking user activity were set.
|
||||
@ -106,9 +106,8 @@
|
||||
/**
|
||||
* Sets local variables and events, then starts the heartbeat.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @access private
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
@ -133,9 +132,8 @@
|
||||
}
|
||||
|
||||
/*
|
||||
* The interval can be from 15 to 120 sec. and can be set temporarily to 5 sec.
|
||||
* It can be set in the initial options or changed later through JS and/or
|
||||
* through PHP.
|
||||
* The interval can be from 15 to 120 seconds and can be set temporarily to 5 seconds.
|
||||
* It can be set in the initial options or changed later through JS and/or through PHP.
|
||||
*/
|
||||
if ( options.interval ) {
|
||||
settings.mainInterval = options.interval;
|
||||
@ -148,12 +146,12 @@
|
||||
}
|
||||
|
||||
/*
|
||||
* Used to limit the number of AJAX requests. Overrides all other intervals if
|
||||
* they are shorter. Needed for some hosts that cannot handle frequent requests
|
||||
* and the user may exceed the allocated server CPU time, etc. The minimal
|
||||
* interval can be up to 600 sec. however setting it to longer than 120 sec.
|
||||
* will limit or disable some of the functionality (like post locks). Once set
|
||||
* at initialization, minimalInterval cannot be changed/overridden.
|
||||
* Used to limit the number of AJAX requests. Overrides all other intervals
|
||||
* if they are shorter. Needed for some hosts that cannot handle frequent requests
|
||||
* and the user may exceed the allocated server CPU time, etc. The minimal interval
|
||||
* can be up to 600 seconds, however setting it to longer than 120 seconds
|
||||
* will limit or disable some of the functionality (like post locks).
|
||||
* Once set at initialization, minimalInterval cannot be changed/overridden.
|
||||
*/
|
||||
if ( options.minimalInterval ) {
|
||||
options.minimalInterval = parseInt( options.minimalInterval, 10 );
|
||||
@ -189,11 +187,11 @@
|
||||
hidden = 'hidden';
|
||||
visibilitychange = 'visibilitychange';
|
||||
visibilityState = 'visibilityState';
|
||||
} else if ( typeof document.msHidden !== 'undefined' ) { // IE10
|
||||
} else if ( typeof document.msHidden !== 'undefined' ) { // IE10.
|
||||
hidden = 'msHidden';
|
||||
visibilitychange = 'msvisibilitychange';
|
||||
visibilityState = 'msVisibilityState';
|
||||
} else if ( typeof document.webkitHidden !== 'undefined' ) { // Android
|
||||
} else if ( typeof document.webkitHidden !== 'undefined' ) { // Android.
|
||||
hidden = 'webkitHidden';
|
||||
visibilitychange = 'webkitvisibilitychange';
|
||||
visibilityState = 'webkitVisibilityState';
|
||||
@ -245,9 +243,8 @@
|
||||
/**
|
||||
* Returns the current time according to the browser.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @since 3.6.0
|
||||
* @access private
|
||||
*
|
||||
* @return {number} Returns the current time.
|
||||
*/
|
||||
@ -258,9 +255,8 @@
|
||||
/**
|
||||
* Checks if the iframe is from the same origin.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @since 3.6.0
|
||||
* @access private
|
||||
*
|
||||
* @return {boolean} Returns whether or not the iframe is from the same origin.
|
||||
*/
|
||||
@ -291,9 +287,8 @@
|
||||
/**
|
||||
* Checks if the document's focus has changed.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @since 4.1.0
|
||||
* @access private
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
@ -308,9 +303,8 @@
|
||||
/**
|
||||
* Sets error state and fires an event on XHR errors or timeout.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @access private
|
||||
*
|
||||
* @param {string} error The error type passed from the XHR.
|
||||
* @param {number} status The HTTP status code passed from jqXHR
|
||||
@ -327,7 +321,7 @@
|
||||
// Do nothing.
|
||||
break;
|
||||
case 'timeout':
|
||||
// No response for 30 sec.
|
||||
// No response for 30 seconds.
|
||||
trigger = true;
|
||||
break;
|
||||
case 'error':
|
||||
@ -359,9 +353,8 @@
|
||||
/**
|
||||
* Clears the error state and fires an event if there is a connection error.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @access private
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
@ -380,9 +373,8 @@
|
||||
/**
|
||||
* Gathers the data and connects to the server.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @since 3.6.0
|
||||
* @access private
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
@ -421,7 +413,7 @@
|
||||
settings.xhr = $.ajax({
|
||||
url: settings.url,
|
||||
type: 'post',
|
||||
timeout: 30000, // throw an error if not completed after 30 sec.
|
||||
timeout: 30000, // Throw an error if not completed after 30 seconds.
|
||||
data: ajaxData,
|
||||
dataType: 'json'
|
||||
}).always( function() {
|
||||
@ -442,7 +434,7 @@
|
||||
wp.hooks.doAction( 'heartbeat.nonces-expired' );
|
||||
}
|
||||
|
||||
// Change the interval from PHP
|
||||
// Change the interval from PHP.
|
||||
if ( response.heartbeat_interval ) {
|
||||
newInterval = response.heartbeat_interval;
|
||||
delete response.heartbeat_interval;
|
||||
@ -464,7 +456,7 @@
|
||||
$document.trigger( 'heartbeat-tick', [response, textStatus, jqXHR] );
|
||||
wp.hooks.doAction( 'heartbeat.tick', response, textStatus, jqXHR );
|
||||
|
||||
// Do this last. Can trigger the next XHR if connection time > 5 sec. and newInterval == 'fast'.
|
||||
// Do this last. Can trigger the next XHR if connection time > 5 seconds and newInterval == 'fast'.
|
||||
if ( newInterval ) {
|
||||
interval( newInterval );
|
||||
}
|
||||
@ -480,9 +472,8 @@
|
||||
*
|
||||
* Fires immediately if the connection time is longer than the interval.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @access private
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
@ -495,7 +486,7 @@
|
||||
}
|
||||
|
||||
if ( ! settings.hasFocus ) {
|
||||
interval = 120000; // 120 sec. Post locks expire after 150 sec.
|
||||
interval = 120000; // 120 seconds. Post locks expire after 150 seconds.
|
||||
} else if ( settings.countdown > 0 && settings.tempInterval ) {
|
||||
interval = settings.tempInterval;
|
||||
settings.countdown--;
|
||||
@ -526,9 +517,8 @@
|
||||
/**
|
||||
* Sets the internal state when the browser window becomes hidden or loses focus.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @since 3.6.0
|
||||
* @access private
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
@ -539,16 +529,15 @@
|
||||
/**
|
||||
* Sets the internal state when the browser window becomes visible or is in focus.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @since 3.6.0
|
||||
* @access private
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
function focused() {
|
||||
settings.userActivity = time();
|
||||
|
||||
// Resume if suspended
|
||||
// Resume if suspended.
|
||||
settings.suspend = false;
|
||||
|
||||
if ( ! settings.hasFocus ) {
|
||||
@ -560,9 +549,8 @@
|
||||
/**
|
||||
* Runs when the user becomes active after a period of inactivity.
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @since 3.6.0
|
||||
* @access private
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
@ -582,26 +570,25 @@
|
||||
/**
|
||||
* Checks for user activity.
|
||||
*
|
||||
* Runs every 30 sec. Sets 'hasFocus = true' if user is active and the window is
|
||||
* in the background. Sets 'hasFocus = false' if the user has been inactive
|
||||
* (no mouse or keyboard activity) for 5 min. even when the window has focus.
|
||||
*
|
||||
* @access private
|
||||
* Runs every 30 seconds. Sets 'hasFocus = true' if user is active and the window
|
||||
* is in the background. Sets 'hasFocus = false' if the user has been inactive
|
||||
* (no mouse or keyboard activity) for 5 minutes even when the window has focus.
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @access private
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
function checkUserActivity() {
|
||||
var lastActive = settings.userActivity ? time() - settings.userActivity : 0;
|
||||
|
||||
// Throttle down when no mouse or keyboard activity for 5 min.
|
||||
// Throttle down when no mouse or keyboard activity for 5 minutes.
|
||||
if ( lastActive > 300000 && settings.hasFocus ) {
|
||||
blurred();
|
||||
}
|
||||
|
||||
// Suspend after 10 min. of inactivity when suspending is enabled.
|
||||
// Always suspend after 60 min. of inactivity. This will release the post lock, etc.
|
||||
// Suspend after 10 minutes of inactivity when suspending is enabled.
|
||||
// Always suspend after 60 minutes of inactivity. This will release the post lock, etc.
|
||||
if ( ( settings.suspendEnabled && lastActive > 600000 ) || lastActive > 3600000 ) {
|
||||
settings.suspend = true;
|
||||
}
|
||||
@ -672,9 +659,9 @@
|
||||
* Disables suspending.
|
||||
*
|
||||
* Should be used only when Heartbeat is performing critical tasks like
|
||||
* autosave, post-locking, etc. Using this on many screens may overload the
|
||||
* user's hosting account if several browser windows/tabs are left open for a
|
||||
* long time.
|
||||
* autosave, post-locking, etc. Using this on many screens may overload
|
||||
* the user's hosting account if several browser windows/tabs are left open
|
||||
* for a long time.
|
||||
*
|
||||
* @since 3.8.0
|
||||
*
|
||||
@ -691,15 +678,15 @@
|
||||
*
|
||||
* When setting to 'fast' or 5, the interval is 5 seconds for the next 30 ticks
|
||||
* (for 2 minutes and 30 seconds) by default. In this case the number of 'ticks'
|
||||
* can be passed as second argument. If the window doesn't have focus, the
|
||||
* interval slows down to 2 min.
|
||||
* can be passed as second argument. If the window doesn't have focus,
|
||||
* the interval slows down to 2 minutes.
|
||||
*
|
||||
* @since 3.6.0
|
||||
*
|
||||
* @memberOf wp.heartbeat.prototype
|
||||
*
|
||||
* @param {string|number} speed Interval: 'fast' or 5, 15, 30, 60, 120. Fast
|
||||
* equals 5.
|
||||
* @param {string|number} speed Interval: 'fast' or 5, 15, 30, 60, 120.
|
||||
* Fast equals 5.
|
||||
* @param {string} ticks Tells how many ticks before the interval reverts
|
||||
* back. Used with speed = 'fast' or 5.
|
||||
*
|
||||
@ -728,7 +715,7 @@
|
||||
newInterval = 120000;
|
||||
break;
|
||||
case 'long-polling':
|
||||
// Allow long polling, (experimental)
|
||||
// Allow long polling (experimental).
|
||||
settings.mainInterval = 0;
|
||||
return 0;
|
||||
default:
|
||||
@ -751,9 +738,11 @@
|
||||
settings.mainInterval = newInterval;
|
||||
}
|
||||
|
||||
// Change the next connection time if new interval has been set.
|
||||
// Will connect immediately if the time since the last connection
|
||||
// is greater than the new interval.
|
||||
/*
|
||||
* Change the next connection time if new interval has been set.
|
||||
* Will connect immediately if the time since the last connection
|
||||
* is greater than the new interval.
|
||||
*/
|
||||
if ( newInterval !== oldInterval ) {
|
||||
scheduleNextTick();
|
||||
}
|
||||
|
@ -565,10 +565,12 @@
|
||||
dom.add( node, 'span', { 'class': 'wpview-end' } );
|
||||
} );
|
||||
|
||||
// Bail if the iframe node is not attached to the DOM.
|
||||
// Happens when the view is dragged in the editor.
|
||||
// There is a browser restriction when iframes are moved in the DOM. They get emptied.
|
||||
// The iframe will be rerendered after dropping the view node at the new location.
|
||||
/*
|
||||
* Bail if the iframe node is not attached to the DOM.
|
||||
* Happens when the view is dragged in the editor.
|
||||
* There is a browser restriction when iframes are moved in the DOM. They get emptied.
|
||||
* The iframe will be rerendered after dropping the view node at the new location.
|
||||
*/
|
||||
if ( ! iframe.contentWindow ) {
|
||||
return;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ wp.media.mixin = {
|
||||
return;
|
||||
}
|
||||
|
||||
// invoke features cleanup
|
||||
// Invoke features cleanup.
|
||||
for ( featureIndex in t.options.features ) {
|
||||
feature = t.options.features[featureIndex];
|
||||
if ( t['clean' + feature] ) {
|
||||
|
@ -430,9 +430,11 @@
|
||||
_.extend( attrs, attachments[this.tag].toJSON() );
|
||||
}
|
||||
|
||||
// Convert all gallery shortcodes to use the `ids` property.
|
||||
// Ignore `post__in` and `post__not_in`; the attachments in
|
||||
// the collection will already reflect those properties.
|
||||
/*
|
||||
* Convert all gallery shortcodes to use the `ids` property.
|
||||
* Ignore `post__in` and `post__not_in`; the attachments in
|
||||
* the collection will already reflect those properties.
|
||||
*/
|
||||
attrs.ids = attachments.pluck('id');
|
||||
|
||||
// Copy the `uploadedTo` post ID.
|
||||
@ -670,7 +672,7 @@
|
||||
|
||||
this.content.set( view );
|
||||
|
||||
// after bringing in the frame, load the actual editor via an ajax call
|
||||
// After bringing in the frame, load the actual editor via an Ajax call.
|
||||
view.loadEditor();
|
||||
|
||||
}, this._frame );
|
||||
@ -733,9 +735,11 @@
|
||||
wpActiveEditor = window.wpActiveEditor;
|
||||
}
|
||||
|
||||
// Delegate to the global `send_to_editor` if it exists.
|
||||
// This attempts to play nice with any themes/plugins that have
|
||||
// overridden the insert functionality.
|
||||
/*
|
||||
* Delegate to the global `send_to_editor` if it exists.
|
||||
* This attempts to play nice with any themes/plugins
|
||||
* that have overridden the insert functionality.
|
||||
*/
|
||||
if ( window.send_to_editor ) {
|
||||
return window.send_to_editor.apply( this, arguments );
|
||||
}
|
||||
@ -780,7 +784,7 @@
|
||||
add: function( id, options ) {
|
||||
var workflow = this.get( id );
|
||||
|
||||
// only add once: if exists return existing
|
||||
// Only add once: if exists return existing.
|
||||
if ( workflow ) {
|
||||
return workflow;
|
||||
}
|
||||
@ -1016,7 +1020,7 @@
|
||||
|
||||
workflow = this.get( id );
|
||||
|
||||
// Redo workflow if state has changed
|
||||
// Redo workflow if state has changed.
|
||||
if ( ! workflow || ( workflow.options && options.state !== workflow.options.state ) ) {
|
||||
workflow = this.add( id, options );
|
||||
}
|
||||
|
@ -147,9 +147,11 @@ _.extend( media, /** @lends wp.media */{
|
||||
maxHeight = dimensions.maxHeight,
|
||||
constraint;
|
||||
|
||||
// Compare ratios between the two values to determine which
|
||||
// max to constrain by. If a max value doesn't exist, then the
|
||||
// opposite side is the constraint.
|
||||
/*
|
||||
* Compare ratios between the two values to determine
|
||||
* which max to constrain by. If a max value doesn't exist,
|
||||
* then the opposite side is the constraint.
|
||||
*/
|
||||
if ( ! _.isUndefined( maxWidth ) && ! _.isUndefined( maxHeight ) ) {
|
||||
constraint = ( width / height > maxWidth / maxHeight ) ? 'width' : 'height';
|
||||
} else if ( _.isUndefined( maxHeight ) ) {
|
||||
@ -236,7 +238,7 @@ media.query = function( props ) {
|
||||
});
|
||||
};
|
||||
|
||||
// Clean up. Prevents mobile browsers caching
|
||||
// Clean up. Prevents mobile browsers caching.
|
||||
$(window).on('unload', function(){
|
||||
window.wp = null;
|
||||
});
|
||||
|
@ -18,7 +18,7 @@ delete l10n.settings;
|
||||
// Copy the `post` setting over to the model settings.
|
||||
media.model.settings.post = media.view.settings.post;
|
||||
|
||||
// Check if the browser supports CSS 3.0 transitions
|
||||
// Check if the browser supports CSS 3.0 transitions.
|
||||
$.support.transition = (function(){
|
||||
var style = document.documentElement.style,
|
||||
transitions = {
|
||||
|
@ -13,13 +13,15 @@ window.wp = window.wp || {};
|
||||
|
||||
(function(){
|
||||
wp.shortcode = {
|
||||
// ### Find the next matching shortcode
|
||||
//
|
||||
// Given a shortcode `tag`, a block of `text`, and an optional starting
|
||||
// `index`, returns the next matching shortcode or `undefined`.
|
||||
//
|
||||
// Shortcodes are formatted as an object that contains the match
|
||||
// `content`, the matching `index`, and the parsed `shortcode` object.
|
||||
/*
|
||||
* ### Find the next matching shortcode.
|
||||
*
|
||||
* Given a shortcode `tag`, a block of `text`, and an optional starting
|
||||
* `index`, returns the next matching shortcode or `undefined`.
|
||||
*
|
||||
* Shortcodes are formatted as an object that contains the match
|
||||
* `content`, the matching `index`, and the parsed `shortcode` object.
|
||||
*/
|
||||
next: function( tag, text, index ) {
|
||||
var re = wp.shortcode.regexp( tag ),
|
||||
match, result;
|
||||
@ -57,15 +59,17 @@ window.wp = window.wp || {};
|
||||
return result;
|
||||
},
|
||||
|
||||
// ### Replace matching shortcodes in a block of text
|
||||
//
|
||||
// Accepts a shortcode `tag`, content `text` to scan, and a `callback`
|
||||
// to process the shortcode matches and return a replacement string.
|
||||
// Returns the `text` with all shortcodes replaced.
|
||||
//
|
||||
// Shortcode matches are objects that contain the shortcode `tag`,
|
||||
// a shortcode `attrs` object, the `content` between shortcode tags,
|
||||
// and a boolean flag to indicate if the match was a `single` tag.
|
||||
/*
|
||||
* ### Replace matching shortcodes in a block of text.
|
||||
*
|
||||
* Accepts a shortcode `tag`, content `text` to scan, and a `callback`
|
||||
* to process the shortcode matches and return a replacement string.
|
||||
* Returns the `text` with all shortcodes replaced.
|
||||
*
|
||||
* Shortcode matches are objects that contain the shortcode `tag`,
|
||||
* a shortcode `attrs` object, the `content` between shortcode tags,
|
||||
* and a boolean flag to indicate if the match was a `single` tag.
|
||||
*/
|
||||
replace: function( tag, text, callback ) {
|
||||
return text.replace( wp.shortcode.regexp( tag ), function( match, left, tag, attrs, slash, content, closing, right ) {
|
||||
// If both extra brackets exist, the shortcode has been
|
||||
@ -83,67 +87,75 @@ window.wp = window.wp || {};
|
||||
});
|
||||
},
|
||||
|
||||
// ### Generate a string from shortcode parameters
|
||||
//
|
||||
// Creates a `wp.shortcode` instance and returns a string.
|
||||
//
|
||||
// Accepts the same `options` as the `wp.shortcode()` constructor,
|
||||
// containing a `tag` string, a string or object of `attrs`, a boolean
|
||||
// indicating whether to format the shortcode using a `single` tag, and a
|
||||
// `content` string.
|
||||
/*
|
||||
* ### Generate a string from shortcode parameters.
|
||||
*
|
||||
* Creates a `wp.shortcode` instance and returns a string.
|
||||
*
|
||||
* Accepts the same `options` as the `wp.shortcode()` constructor,
|
||||
* containing a `tag` string, a string or object of `attrs`, a boolean
|
||||
* indicating whether to format the shortcode using a `single` tag, and a
|
||||
* `content` string.
|
||||
*/
|
||||
string: function( options ) {
|
||||
return new wp.shortcode( options ).string();
|
||||
},
|
||||
|
||||
// ### Generate a RegExp to identify a shortcode
|
||||
//
|
||||
// The base regex is functionally equivalent to the one found in
|
||||
// `get_shortcode_regex()` in `wp-includes/shortcodes.php`.
|
||||
//
|
||||
// Capture groups:
|
||||
//
|
||||
// 1. An extra `[` to allow for escaping shortcodes with double `[[]]`
|
||||
// 2. The shortcode name
|
||||
// 3. The shortcode argument list
|
||||
// 4. The self closing `/`
|
||||
// 5. The content of a shortcode when it wraps some content.
|
||||
// 6. The closing tag.
|
||||
// 7. An extra `]` to allow for escaping shortcodes with double `[[]]`
|
||||
/*
|
||||
* ### Generate a RegExp to identify a shortcode.
|
||||
*
|
||||
* The base regex is functionally equivalent to the one found in
|
||||
* `get_shortcode_regex()` in `wp-includes/shortcodes.php`.
|
||||
*
|
||||
* Capture groups:
|
||||
*
|
||||
* 1. An extra `[` to allow for escaping shortcodes with double `[[]]`.
|
||||
* 2. The shortcode name.
|
||||
* 3. The shortcode argument list.
|
||||
* 4. The self closing `/`.
|
||||
* 5. The content of a shortcode when it wraps some content.
|
||||
* 6. The closing tag.
|
||||
* 7. An extra `]` to allow for escaping shortcodes with double `[[]]`.
|
||||
*/
|
||||
regexp: _.memoize( function( tag ) {
|
||||
return new RegExp( '\\[(\\[?)(' + tag + ')(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*(?:\\[(?!\\/\\2\\])[^\\[]*)*)(\\[\\/\\2\\]))?)(\\]?)', 'g' );
|
||||
}),
|
||||
|
||||
|
||||
// ### Parse shortcode attributes
|
||||
//
|
||||
// Shortcodes accept many types of attributes. These can chiefly be
|
||||
// divided into named and numeric attributes:
|
||||
//
|
||||
// Named attributes are assigned on a key/value basis, while numeric
|
||||
// attributes are treated as an array.
|
||||
//
|
||||
// Named attributes can be formatted as either `name="value"`,
|
||||
// `name='value'`, or `name=value`. Numeric attributes can be formatted
|
||||
// as `"value"` or just `value`.
|
||||
/*
|
||||
* ### Parse shortcode attributes.
|
||||
*
|
||||
* Shortcodes accept many types of attributes. These can chiefly be
|
||||
* divided into named and numeric attributes:
|
||||
*
|
||||
* Named attributes are assigned on a key/value basis, while numeric
|
||||
* attributes are treated as an array.
|
||||
*
|
||||
* Named attributes can be formatted as either `name="value"`,
|
||||
* `name='value'`, or `name=value`. Numeric attributes can be formatted
|
||||
* as `"value"` or just `value`.
|
||||
*/
|
||||
attrs: _.memoize( function( text ) {
|
||||
var named = {},
|
||||
numeric = [],
|
||||
pattern, match;
|
||||
|
||||
// This regular expression is reused from `shortcode_parse_atts()`
|
||||
// in `wp-includes/shortcodes.php`.
|
||||
//
|
||||
// Capture groups:
|
||||
//
|
||||
// 1. An attribute name, that corresponds to...
|
||||
// 2. a value in double quotes.
|
||||
// 3. An attribute name, that corresponds to...
|
||||
// 4. a value in single quotes.
|
||||
// 5. An attribute name, that corresponds to...
|
||||
// 6. an unquoted value.
|
||||
// 7. A numeric attribute in double quotes.
|
||||
// 8. A numeric attribute in single quotes.
|
||||
// 9. An unquoted numeric attribute.
|
||||
/*
|
||||
* This regular expression is reused from `shortcode_parse_atts()`
|
||||
* in `wp-includes/shortcodes.php`.
|
||||
*
|
||||
* Capture groups:
|
||||
*
|
||||
* 1. An attribute name, that corresponds to...
|
||||
* 2. a value in double quotes.
|
||||
* 3. An attribute name, that corresponds to...
|
||||
* 4. a value in single quotes.
|
||||
* 5. An attribute name, that corresponds to...
|
||||
* 6. an unquoted value.
|
||||
* 7. A numeric attribute in double quotes.
|
||||
* 8. A numeric attribute in single quotes.
|
||||
* 9. An unquoted numeric attribute.
|
||||
*/
|
||||
pattern = /([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*'([^']*)'(?:\s|$)|([\w-]+)\s*=\s*([^\s'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|'([^']*)'(?:\s|$)|(\S+)(?:\s|$)/g;
|
||||
|
||||
// Map zero-width spaces to actual spaces.
|
||||
@ -172,10 +184,13 @@ window.wp = window.wp || {};
|
||||
};
|
||||
}),
|
||||
|
||||
// ### Generate a Shortcode Object from a RegExp match
|
||||
// Accepts a `match` object from calling `regexp.exec()` on a `RegExp`
|
||||
// generated by `wp.shortcode.regexp()`. `match` can also be set to the
|
||||
// `arguments` from a callback passed to `regexp.replace()`.
|
||||
/*
|
||||
* ### Generate a Shortcode Object from a RegExp match.
|
||||
*
|
||||
* Accepts a `match` object from calling `regexp.exec()` on a `RegExp`
|
||||
* generated by `wp.shortcode.regexp()`. `match` can also be set
|
||||
* to the `arguments` from a callback passed to `regexp.replace()`.
|
||||
*/
|
||||
fromMatch: function( match ) {
|
||||
var type;
|
||||
|
||||
@ -197,16 +212,18 @@ window.wp = window.wp || {};
|
||||
};
|
||||
|
||||
|
||||
// Shortcode Objects
|
||||
// -----------------
|
||||
//
|
||||
// Shortcode objects are generated automatically when using the main
|
||||
// `wp.shortcode` methods: `next()`, `replace()`, and `string()`.
|
||||
//
|
||||
// To access a raw representation of a shortcode, pass an `options` object,
|
||||
// containing a `tag` string, a string or object of `attrs`, a string
|
||||
// indicating the `type` of the shortcode ('single', 'self-closing', or
|
||||
// 'closed'), and a `content` string.
|
||||
/*
|
||||
* Shortcode Objects
|
||||
* -----------------
|
||||
*
|
||||
* Shortcode objects are generated automatically when using the main
|
||||
* `wp.shortcode` methods: `next()`, `replace()`, and `string()`.
|
||||
*
|
||||
* To access a raw representation of a shortcode, pass an `options` object,
|
||||
* containing a `tag` string, a string or object of `attrs`, a string
|
||||
* indicating the `type` of the shortcode ('single', 'self-closing',
|
||||
* or 'closed'), and a `content` string.
|
||||
*/
|
||||
wp.shortcode = _.extend( function( options ) {
|
||||
_.extend( this, _.pick( options || {}, 'tag', 'attrs', 'type', 'content' ) );
|
||||
|
||||
@ -239,24 +256,28 @@ window.wp = window.wp || {};
|
||||
}, wp.shortcode );
|
||||
|
||||
_.extend( wp.shortcode.prototype, {
|
||||
// ### Get a shortcode attribute
|
||||
//
|
||||
// Automatically detects whether `attr` is named or numeric and routes
|
||||
// it accordingly.
|
||||
/*
|
||||
* ### Get a shortcode attribute.
|
||||
*
|
||||
* Automatically detects whether `attr` is named or numeric and routes
|
||||
* it accordingly.
|
||||
*/
|
||||
get: function( attr ) {
|
||||
return this.attrs[ _.isNumber( attr ) ? 'numeric' : 'named' ][ attr ];
|
||||
},
|
||||
|
||||
// ### Set a shortcode attribute
|
||||
//
|
||||
// Automatically detects whether `attr` is named or numeric and routes
|
||||
// it accordingly.
|
||||
/*
|
||||
* ### Set a shortcode attribute.
|
||||
*
|
||||
* Automatically detects whether `attr` is named or numeric and routes
|
||||
* it accordingly.
|
||||
*/
|
||||
set: function( attr, value ) {
|
||||
this.attrs[ _.isNumber( attr ) ? 'numeric' : 'named' ][ attr ] = value;
|
||||
return this;
|
||||
},
|
||||
|
||||
// ### Transform the shortcode match into a string
|
||||
// ### Transform the shortcode match into a string.
|
||||
string: function() {
|
||||
var text = '[' + this.tag;
|
||||
|
||||
@ -293,20 +314,24 @@ window.wp = window.wp || {};
|
||||
});
|
||||
}());
|
||||
|
||||
// HTML utility functions
|
||||
// ----------------------
|
||||
//
|
||||
// Experimental. These functions may change or be removed in the future.
|
||||
/*
|
||||
* HTML utility functions
|
||||
* ----------------------
|
||||
*
|
||||
* Experimental. These functions may change or be removed in the future.
|
||||
*/
|
||||
(function(){
|
||||
wp.html = _.extend( wp.html || {}, {
|
||||
// ### Parse HTML attributes.
|
||||
//
|
||||
// Converts `content` to a set of parsed HTML attributes.
|
||||
// Utilizes `wp.shortcode.attrs( content )`, which is a valid superset of
|
||||
// the HTML attribute specification. Reformats the attributes into an
|
||||
// object that contains the `attrs` with `key:value` mapping, and a record
|
||||
// of the attributes that were entered using `empty` attribute syntax (i.e.
|
||||
// with no value).
|
||||
/*
|
||||
* ### Parse HTML attributes.
|
||||
*
|
||||
* Converts `content` to a set of parsed HTML attributes.
|
||||
* Utilizes `wp.shortcode.attrs( content )`, which is a valid superset of
|
||||
* the HTML attribute specification. Reformats the attributes into an
|
||||
* object that contains the `attrs` with `key:value` mapping, and a record
|
||||
* of the attributes that were entered using `empty` attribute syntax (i.e.
|
||||
* with no value).
|
||||
*/
|
||||
attrs: function( content ) {
|
||||
var result, attrs;
|
||||
|
||||
|
@ -13,7 +13,7 @@ wp.svgPainter = ( function( $, window, document, undefined ) {
|
||||
elements = [];
|
||||
|
||||
$(document).ready( function() {
|
||||
// detection for browser SVG capability
|
||||
// Detection for browser SVG capability.
|
||||
if ( document.implementation.hasFeature( 'http://www.w3.org/TR/SVG11/feature#Image', '1.1' ) ) {
|
||||
$( document.body ).removeClass( 'no-svg' ).addClass( 'svg' );
|
||||
wp.svgPainter.init();
|
||||
@ -148,24 +148,24 @@ wp.svgPainter = ( function( $, window, document, undefined ) {
|
||||
},
|
||||
|
||||
paint: function() {
|
||||
// loop through all elements
|
||||
// Loop through all elements.
|
||||
$.each( elements, function( index, $element ) {
|
||||
var $menuitem = $element.parent().parent();
|
||||
|
||||
if ( $menuitem.hasClass( 'current' ) || $menuitem.hasClass( 'wp-has-current-submenu' ) ) {
|
||||
// paint icon in 'current' color
|
||||
// Paint icon in 'current' color.
|
||||
painter.paintElement( $element, 'current' );
|
||||
} else {
|
||||
// paint icon in base color
|
||||
// Paint icon in base color.
|
||||
painter.paintElement( $element, 'base' );
|
||||
|
||||
// set hover callbacks
|
||||
// Set hover callbacks.
|
||||
$menuitem.hover(
|
||||
function() {
|
||||
painter.paintElement( $element, 'focus' );
|
||||
},
|
||||
function() {
|
||||
// Match the delay from hoverIntent
|
||||
// Match the delay from hoverIntent.
|
||||
window.setTimeout( function() {
|
||||
painter.paintElement( $element, 'base' );
|
||||
}, 100 );
|
||||
@ -184,7 +184,7 @@ wp.svgPainter = ( function( $, window, document, undefined ) {
|
||||
|
||||
color = colorscheme[ colorType ];
|
||||
|
||||
// only accept hex colors: #101 or #101010
|
||||
// Only accept hex colors: #101 or #101010.
|
||||
if ( ! color.match( /^(#[0-9a-f]{3}|#[0-9a-f]{6})$/i ) ) {
|
||||
return;
|
||||
}
|
||||
@ -212,13 +212,13 @@ wp.svgPainter = ( function( $, window, document, undefined ) {
|
||||
} catch ( error ) {}
|
||||
|
||||
if ( xml ) {
|
||||
// replace `fill` attributes
|
||||
// Replace `fill` attributes.
|
||||
xml = xml.replace( /fill="(.+?)"/g, 'fill="' + color + '"');
|
||||
|
||||
// replace `style` attributes
|
||||
// Replace `style` attributes.
|
||||
xml = xml.replace( /style="(.+?)"/g, 'style="fill:' + color + '"');
|
||||
|
||||
// replace `fill` properties in `<style>` tags
|
||||
// Replace `fill` properties in `<style>` tags.
|
||||
xml = xml.replace( /fill:.*?;/g, 'fill: ' + color + ';');
|
||||
|
||||
if ( 'btoa' in window ) {
|
||||
|
@ -491,7 +491,7 @@ wp.themePluginEditor = (function( $ ) {
|
||||
|
||||
var TreeitemLink = function (node, treeObj, group) {
|
||||
|
||||
// Check whether node is a DOM element
|
||||
// Check whether node is a DOM element.
|
||||
if (typeof node !== 'object') {
|
||||
return;
|
||||
}
|
||||
@ -696,7 +696,7 @@ wp.themePluginEditor = (function( $ ) {
|
||||
|
||||
TreeitemLink.prototype.handleClick = function (event) {
|
||||
|
||||
// only process click events that directly happened on this treeitem
|
||||
// Only process click events that directly happened on this treeitem.
|
||||
if (event.target !== this.domNode && event.target !== this.domNode.firstElementChild) {
|
||||
return;
|
||||
}
|
||||
@ -773,7 +773,7 @@ wp.themePluginEditor = (function( $ ) {
|
||||
*/
|
||||
|
||||
var TreeLinks = function (node) {
|
||||
// Check whether node is a DOM element
|
||||
// Check whether node is a DOM element.
|
||||
if (typeof node !== 'object') {
|
||||
return;
|
||||
}
|
||||
@ -812,7 +812,7 @@ wp.themePluginEditor = (function( $ ) {
|
||||
}
|
||||
}
|
||||
|
||||
// initialize pop up menus
|
||||
// Initialize pop up menus.
|
||||
if (!this.domNode.getAttribute('role')) {
|
||||
this.domNode.setAttribute('role', 'tree');
|
||||
}
|
||||
@ -964,16 +964,16 @@ wp.themePluginEditor = (function( $ ) {
|
||||
var start, index;
|
||||
_char = _char.toLowerCase();
|
||||
|
||||
// Get start index for search based on position of currentItem
|
||||
// Get start index for search based on position of currentItem.
|
||||
start = this.treeitems.indexOf(currentItem) + 1;
|
||||
if (start === this.treeitems.length) {
|
||||
start = 0;
|
||||
}
|
||||
|
||||
// Check remaining slots in the menu
|
||||
// Check remaining slots in the menu.
|
||||
index = this.getIndexFirstChars(start, _char);
|
||||
|
||||
// If not found in remaining slots, check from beginning
|
||||
// If not found in remaining slots, check from beginning.
|
||||
if (index === -1) {
|
||||
index = this.getIndexFirstChars(0, _char);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -41,11 +41,13 @@ window.wp = window.wp || {};
|
||||
};
|
||||
});
|
||||
|
||||
// wp.ajax
|
||||
// ------
|
||||
//
|
||||
// Tools for sending ajax requests with JSON responses and built in error handling.
|
||||
// Mirrors and wraps jQuery's ajax APIs.
|
||||
/*
|
||||
* wp.ajax
|
||||
* ------
|
||||
*
|
||||
* Tools for sending ajax requests with JSON responses and built in error handling.
|
||||
* Mirrors and wraps jQuery's ajax APIs.
|
||||
*/
|
||||
wp.ajax = {
|
||||
settings: settings.ajax || {},
|
||||
|
||||
@ -105,7 +107,7 @@ window.wp = window.wp || {};
|
||||
delete options.success;
|
||||
delete options.error;
|
||||
|
||||
// Use with PHP's wp_send_json_success() and wp_send_json_error()
|
||||
// Use with PHP's wp_send_json_success() and wp_send_json_error().
|
||||
deferred.jqXHR = $.ajax( options ).done( function( response ) {
|
||||
// Treat a response of 1 as successful for backward compatibility with existing handlers.
|
||||
if ( response === '1' || response === 1 ) {
|
||||
|
@ -3,7 +3,8 @@
|
||||
* provided text string.
|
||||
*
|
||||
* @namespace wp.utils
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @output wp-admin/js/word-count.js
|
||||
*/
|
||||
|
||||
@ -73,17 +74,17 @@
|
||||
spaceRegExp: / | /gi,
|
||||
HTMLEntityRegExp: /&\S+?;/g,
|
||||
|
||||
// \u2014 = em-dash
|
||||
// \u2014 = em-dash.
|
||||
connectorRegExp: /--|\u2014/g,
|
||||
|
||||
// Characters to be removed from input text.
|
||||
removeRegExp: new RegExp( [
|
||||
'[',
|
||||
|
||||
// Basic Latin (extract)
|
||||
// Basic Latin (extract).
|
||||
'\u0021-\u0040\u005B-\u0060\u007B-\u007E',
|
||||
|
||||
// Latin-1 Supplement (extract)
|
||||
// Latin-1 Supplement (extract).
|
||||
'\u0080-\u00BF\u00D7\u00F7',
|
||||
|
||||
/*
|
||||
@ -115,7 +116,7 @@
|
||||
*/
|
||||
'\u2000-\u2BFF',
|
||||
|
||||
// Supplemental Punctuation
|
||||
// Supplemental Punctuation.
|
||||
'\u2E00-\u2E7F',
|
||||
']'
|
||||
].join( '' ), 'g' ),
|
||||
@ -143,7 +144,8 @@
|
||||
/**
|
||||
* Counts the number of words (or other specified type) in the specified text.
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @since 2.6.0
|
||||
*
|
||||
* @memberof wp.utils.wordcounter
|
||||
*
|
||||
* @param {String} text Text to count elements in.
|
||||
|
@ -15,8 +15,8 @@ var Selection = wp.media.model.Selection,
|
||||
* @augments Backbone.Model
|
||||
*
|
||||
* @param {object} [attributes] The attributes hash passed to the state.
|
||||
* @param {string} [attributes.id=library] Unique identifier.
|
||||
* @param {string} attributes.title Title for the state. Displays in the frame's title region.
|
||||
* @param {string} [attributes.id=library] Unique identifier.
|
||||
* @param {string} attributes.title Title for the state. Displays in the frame's title region.
|
||||
* @param {boolean} [attributes.multiple=add] Whether multi-select is enabled. @todo 'add' doesn't seem do anything special, and gets used as a boolean.
|
||||
* @param {wp.media.model.Attachments} [attributes.library] The attachments collection to browse.
|
||||
* If one is not supplied, a collection of attachments of the specified type will be created.
|
||||
@ -34,8 +34,8 @@ var Selection = wp.media.model.Selection,
|
||||
* @param {int} [attributes.priority=100] The priority for the state link in the media menu.
|
||||
* @param {boolean} [attributes.syncSelection=false] Whether the Attachments selection should be persisted from the last state.
|
||||
* Defaults to false because for this state, because the library of the Edit Gallery state is the selection.
|
||||
* @param {string} attributes.type The collection's media type. (e.g. 'video').
|
||||
* @param {string} attributes.collectionType The collection type. (e.g. 'playlist').
|
||||
* @param {string} attributes.type The collection's media type. (e.g. 'video').
|
||||
* @param {string} attributes.collectionType The collection type. (e.g. 'playlist').
|
||||
*/
|
||||
CollectionAdd = Library.extend(/** @lends wp.media.controller.CollectionAdd.prototype */{
|
||||
defaults: _.defaults( {
|
||||
@ -87,9 +87,11 @@ CollectionAdd = Library.extend(/** @lends wp.media.controller.CollectionAdd.prot
|
||||
return !! this.mirroring.get( attachment.cid ) && ! edit.get( attachment.cid ) && Selection.prototype.validator.apply( this, arguments );
|
||||
};
|
||||
|
||||
// Reset the library to ensure that all attachments are re-added
|
||||
// to the collection. Do so silently, as calling `observe` will
|
||||
// trigger the `reset` event.
|
||||
/*
|
||||
* Reset the library to ensure that all attachments are re-added
|
||||
* to the collection. Do so silently, as calling `observe` will
|
||||
* trigger the `reset` event.
|
||||
*/
|
||||
library.reset( library.mirroring.models, { silent: true });
|
||||
library.observe( edit );
|
||||
this.set('editLibrary', edit);
|
||||
|
@ -63,9 +63,11 @@ Embed = wp.media.controller.State.extend(/** @lends wp.media.controller.Embed.pr
|
||||
scanners: []
|
||||
};
|
||||
|
||||
// Scan is triggered with the list of `attributes` to set on the
|
||||
// state, useful for the 'type' attribute and 'scanners' attribute,
|
||||
// an array of promise objects for asynchronous scan operations.
|
||||
/*
|
||||
* Scan is triggered with the list of `attributes` to set on the
|
||||
* state, useful for the 'type' attribute and 'scanners' attribute,
|
||||
* an array of promise objects for asynchronous scan operations.
|
||||
*/
|
||||
if ( this.props.get('url') ) {
|
||||
this.trigger( 'scan', attributes );
|
||||
}
|
||||
|
@ -71,24 +71,24 @@ var State = Backbone.Model.extend(/** @lends wp.media.controller.State.prototype
|
||||
reset: function() {},
|
||||
|
||||
/**
|
||||
* @access private
|
||||
* @since 3.5.0
|
||||
* @access private
|
||||
*/
|
||||
_ready: function() {
|
||||
this._updateMenu();
|
||||
},
|
||||
|
||||
/**
|
||||
* @access private
|
||||
* @since 3.5.0
|
||||
* @access private
|
||||
*/
|
||||
_preActivate: function() {
|
||||
this.active = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* @access private
|
||||
* @since 3.5.0
|
||||
* @access private
|
||||
*/
|
||||
_postActivate: function() {
|
||||
this.on( 'change:menu', this._menu, this );
|
||||
@ -106,8 +106,8 @@ var State = Backbone.Model.extend(/** @lends wp.media.controller.State.prototype
|
||||
},
|
||||
|
||||
/**
|
||||
* @access private
|
||||
* @since 3.5.0
|
||||
* @access private
|
||||
*/
|
||||
_deactivate: function() {
|
||||
this.active = false;
|
||||
@ -121,24 +121,24 @@ var State = Backbone.Model.extend(/** @lends wp.media.controller.State.prototype
|
||||
},
|
||||
|
||||
/**
|
||||
* @access private
|
||||
* @since 3.5.0
|
||||
* @access private
|
||||
*/
|
||||
_title: function() {
|
||||
this.frame.title.render( this.get('titleMode') || 'default' );
|
||||
},
|
||||
|
||||
/**
|
||||
* @access private
|
||||
* @since 3.5.0
|
||||
* @access private
|
||||
*/
|
||||
_renderTitle: function( view ) {
|
||||
view.$el.text( this.get('title') || '' );
|
||||
},
|
||||
|
||||
/**
|
||||
* @access private
|
||||
* @since 3.5.0
|
||||
* @access private
|
||||
*/
|
||||
_router: function() {
|
||||
var router = this.frame.router,
|
||||
@ -159,8 +159,8 @@ var State = Backbone.Model.extend(/** @lends wp.media.controller.State.prototype
|
||||
},
|
||||
|
||||
/**
|
||||
* @access private
|
||||
* @since 3.5.0
|
||||
* @access private
|
||||
*/
|
||||
_menu: function() {
|
||||
var menu = this.frame.menu,
|
||||
@ -181,8 +181,8 @@ var State = Backbone.Model.extend(/** @lends wp.media.controller.State.prototype
|
||||
},
|
||||
|
||||
/**
|
||||
* @access private
|
||||
* @since 3.5.0
|
||||
* @access private
|
||||
*/
|
||||
_updateMenu: function() {
|
||||
var previous = this.previous('menu'),
|
||||
@ -200,8 +200,8 @@ var State = Backbone.Model.extend(/** @lends wp.media.controller.State.prototype
|
||||
/**
|
||||
* Create a view in the media menu for the state.
|
||||
*
|
||||
* @access private
|
||||
* @since 3.5.0
|
||||
* @access private
|
||||
*
|
||||
* @param {media.view.Menu} view The menu view.
|
||||
*/
|
||||
|
@ -133,9 +133,8 @@ var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen
|
||||
return;
|
||||
}
|
||||
|
||||
// If no `Attachments` model is provided to source the searches
|
||||
// from, then automatically generate a source from the existing
|
||||
// models.
|
||||
// If no `Attachments` model is provided to source the searches from,
|
||||
// then automatically generate a source from the existing models.
|
||||
if ( ! this._source ) {
|
||||
this._source = new Attachments( this.models );
|
||||
}
|
||||
@ -326,10 +325,12 @@ var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen
|
||||
if ( ! mirroring || ! mirroring.more ) {
|
||||
return deferred.resolveWith( this ).promise();
|
||||
}
|
||||
// If we're mirroring another collection, forward `more` to
|
||||
// the mirrored collection. Account for a race condition by
|
||||
// checking if we're still mirroring that collection when
|
||||
// the request resolves.
|
||||
/*
|
||||
* If we're mirroring another collection, forward `more` to
|
||||
* the mirrored collection. Account for a race condition by
|
||||
* checking if we're still mirroring that collection when
|
||||
* the request resolves.
|
||||
*/
|
||||
mirroring.more( options ).done( function() {
|
||||
if ( this === attachments.mirroring ) {
|
||||
deferred.resolveWith( this );
|
||||
@ -412,9 +413,11 @@ var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen
|
||||
return;
|
||||
}
|
||||
|
||||
// Removes any uploading attachments, updates each attachment's
|
||||
// menu order, and returns an object with an { id: menuOrder }
|
||||
// mapping to pass to the request.
|
||||
/*
|
||||
* Removes any uploading attachments, updates each attachment's
|
||||
* menu order, and returns an object with an { id: menuOrder }
|
||||
* mapping to pass to the request.
|
||||
*/
|
||||
var attachments = this.chain().filter( function( attachment ) {
|
||||
return ! _.isUndefined( attachment.id );
|
||||
}).map( function( attachment, index ) {
|
||||
|
@ -30,7 +30,7 @@ var PostImage = Backbone.Model.extend(/** @lends wp.media.model.PostImage.protot
|
||||
this.bindAttachmentListeners();
|
||||
}
|
||||
|
||||
// keep url in sync with changes to the type of link
|
||||
// Keep URL in sync with changes to the type of link.
|
||||
this.on( 'change:link', this.updateLinkUrl, this );
|
||||
this.on( 'change:size', this.updateSize, this );
|
||||
|
||||
@ -70,7 +70,7 @@ var PostImage = Backbone.Model.extend(/** @lends wp.media.model.PostImage.protot
|
||||
return;
|
||||
}
|
||||
|
||||
// default to custom if there is a linkUrl
|
||||
// Default to custom if there is a linkUrl.
|
||||
type = 'custom';
|
||||
|
||||
if ( this.attachment ) {
|
||||
|
@ -43,15 +43,19 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{
|
||||
return true;
|
||||
}
|
||||
|
||||
// We want any items that can be placed before the last
|
||||
// item in the set. If we add any items after the last
|
||||
// item, then we can't guarantee the set is complete.
|
||||
/*
|
||||
* We want any items that can be placed before the last
|
||||
* item in the set. If we add any items after the last
|
||||
* item, then we can't guarantee the set is complete.
|
||||
*/
|
||||
if ( this.length ) {
|
||||
return 1 !== this.comparator( attachment, this.last(), { ties: true });
|
||||
|
||||
// Handle the case where there are no items yet and
|
||||
// we're sorting for recent items. In that case, we want
|
||||
// changes that occurred after we created the query.
|
||||
/*
|
||||
* Handle the case where there are no items yet and
|
||||
* we're sorting for recent items. In that case, we want
|
||||
* changes that occurred after we created the query.
|
||||
*/
|
||||
} else if ( 'DESC' === order && ( 'date' === orderby || 'modified' === orderby ) ) {
|
||||
return attachment.get( orderby ) >= this.created;
|
||||
|
||||
@ -65,12 +69,14 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{
|
||||
return false;
|
||||
};
|
||||
|
||||
// Observe the central `wp.Uploader.queue` collection to watch for
|
||||
// new matches for the query.
|
||||
//
|
||||
// Only observe when a limited number of query args are set. There
|
||||
// are no filters for other properties, so observing will result in
|
||||
// false positives in those queries.
|
||||
/*
|
||||
* Observe the central `wp.Uploader.queue` collection to watch for
|
||||
* new matches for the query.
|
||||
*
|
||||
* Only observe when a limited number of query args are set. There
|
||||
* are no filters for other properties, so observing will result in
|
||||
* false positives in those queries.
|
||||
*/
|
||||
allowed = [ 's', 'order', 'orderby', 'posts_per_page', 'post_mime_type', 'post_parent', 'author' ];
|
||||
if ( wp.Uploader && _( this.args ).chain().keys().difference( allowed ).isEmpty().value() ) {
|
||||
this.observe( wp.Uploader.queue );
|
||||
@ -144,7 +150,7 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{
|
||||
options.data.query = args;
|
||||
return wp.media.ajax( options );
|
||||
|
||||
// Otherwise, fall back to Backbone.sync()
|
||||
// Otherwise, fall back to `Backbone.sync()`.
|
||||
} else {
|
||||
/**
|
||||
* Call wp.media.model.Attachments.sync or Backbone.sync
|
||||
|
@ -16,7 +16,7 @@ var Router = Backbone.Router.extend(/** @lends wp.media.view.MediaFrame.Manage.R
|
||||
'upload.php': 'reset'
|
||||
},
|
||||
|
||||
// Map routes against the page URL
|
||||
// Map routes against the page URL.
|
||||
baseUrl: function( url ) {
|
||||
return 'upload.php' + url;
|
||||
},
|
||||
@ -29,19 +29,19 @@ var Router = Backbone.Router.extend(/** @lends wp.media.view.MediaFrame.Manage.R
|
||||
}
|
||||
},
|
||||
|
||||
// Respond to the search route by filling the search field and trigggering the input event
|
||||
// Respond to the search route by filling the search field and trigggering the input event.
|
||||
search: function( query ) {
|
||||
jQuery( '#media-search-input' ).val( query ).trigger( 'input' );
|
||||
},
|
||||
|
||||
// Show the modal with a specific item
|
||||
// Show the modal with a specific item.
|
||||
showItem: function( query ) {
|
||||
var media = wp.media,
|
||||
frame = media.frames.browse,
|
||||
library = frame.state().get('library'),
|
||||
item;
|
||||
|
||||
// Trigger the media frame to open the correct item
|
||||
// Trigger the media frame to open the correct item.
|
||||
item = library.findWhere( { id: parseInt( query, 10 ) } );
|
||||
item.set( 'skipHistory', true );
|
||||
|
||||
|
@ -22,10 +22,12 @@ var selectionSync = {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the selection supports multiple items, validate the stored
|
||||
// attachments based on the new selection's conditions. Record
|
||||
// the attachments that are not included; we'll maintain a
|
||||
// reference to those. Other attachments are considered in flux.
|
||||
/*
|
||||
* If the selection supports multiple items, validate the stored
|
||||
* attachments based on the new selection's conditions. Record
|
||||
* the attachments that are not included; we'll maintain a
|
||||
* reference to those. Other attachments are considered in flux.
|
||||
*/
|
||||
if ( selection.multiple ) {
|
||||
selection.reset( [], { silent: true });
|
||||
selection.validateAll( manager.attachments );
|
||||
|
@ -167,13 +167,13 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{
|
||||
return;
|
||||
}
|
||||
|
||||
// Catch arrow events
|
||||
// Catch arrow events.
|
||||
if ( 37 === event.keyCode || 38 === event.keyCode || 39 === event.keyCode || 40 === event.keyCode ) {
|
||||
this.controller.trigger( 'attachment:keydown:arrow', event );
|
||||
return;
|
||||
}
|
||||
|
||||
// Catch enter and space events
|
||||
// Catch enter and space events.
|
||||
if ( 'keydown' === event.type && 13 !== event.keyCode && 32 !== event.keyCode ) {
|
||||
return;
|
||||
}
|
||||
@ -183,7 +183,7 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{
|
||||
// In the grid view, bubble up an edit:attachment event to the controller.
|
||||
if ( this.controller.isModeActive( 'grid' ) ) {
|
||||
if ( this.controller.isModeActive( 'edit' ) ) {
|
||||
// Pass the current target to restore focus when closing
|
||||
// Pass the current target to restore focus when closing.
|
||||
this.controller.trigger( 'edit:attachment', this.model, event.currentTarget );
|
||||
return;
|
||||
}
|
||||
@ -255,7 +255,7 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{
|
||||
return;
|
||||
}
|
||||
|
||||
// Fixes bug that loses focus when selecting a featured image
|
||||
// Fixes bug that loses focus when selecting a featured image.
|
||||
if ( ! method ) {
|
||||
method = 'add';
|
||||
}
|
||||
@ -265,14 +265,18 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{
|
||||
}
|
||||
|
||||
if ( this.selected() ) {
|
||||
// If the model is the single model, remove it.
|
||||
// If it is not the same as the single model,
|
||||
// it now becomes the single model.
|
||||
/*
|
||||
* If the model is the single model, remove it.
|
||||
* If it is not the same as the single model,
|
||||
* it now becomes the single model.
|
||||
*/
|
||||
selection[ single === model ? 'remove' : 'single' ]( model );
|
||||
} else {
|
||||
// If the model is not selected, run the `method` on the
|
||||
// selection. By default, we `reset` the selection, but the
|
||||
// `method` can be set to `add` the model to the selection.
|
||||
/*
|
||||
* If the model is not selected, run the `method` on the
|
||||
* selection. By default, we `reset` the selection, but the
|
||||
* `method` can be set to `add` the model to the selection.
|
||||
*/
|
||||
selection[ method ]( model );
|
||||
selection.single( model );
|
||||
}
|
||||
@ -298,9 +302,11 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{
|
||||
var selection = this.options.selection,
|
||||
controller = this.controller;
|
||||
|
||||
// Check if a selection exists and if it's the collection provided.
|
||||
// If they're not the same collection, bail; we're in another
|
||||
// selection's event loop.
|
||||
/*
|
||||
* Check if a selection exists and if it's the collection provided.
|
||||
* If they're not the same collection, bail; we're in another
|
||||
* selection's event loop.
|
||||
*/
|
||||
if ( ! selection || ( collection && collection !== selection ) ) {
|
||||
return;
|
||||
}
|
||||
@ -324,9 +330,11 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{
|
||||
deselect: function( model, collection ) {
|
||||
var selection = this.options.selection;
|
||||
|
||||
// Check if a selection exists and if it's the collection provided.
|
||||
// If they're not the same collection, bail; we're in another
|
||||
// selection's event loop.
|
||||
/*
|
||||
* Check if a selection exists and if it's the collection provided.
|
||||
* If they're not the same collection, bail; we're in another
|
||||
* selection's event loop.
|
||||
*/
|
||||
if ( ! selection || ( collection && collection !== selection ) ) {
|
||||
return;
|
||||
}
|
||||
@ -478,7 +486,7 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{
|
||||
* @param {Object} event
|
||||
*/
|
||||
removeFromLibrary: function( event ) {
|
||||
// Catch enter and space events
|
||||
// Catch enter and space events.
|
||||
if ( 'keydown' === event.type && 13 !== event.keyCode && 32 !== event.keyCode ) {
|
||||
return;
|
||||
}
|
||||
@ -565,10 +573,12 @@ _.each({
|
||||
return this;
|
||||
}
|
||||
|
||||
// If the updated value is in sync with the value in the DOM, there
|
||||
// is no need to re-render. If we're currently editing the value,
|
||||
// it will automatically be in sync, suppressing the re-render for
|
||||
// the view we're editing, while updating any others.
|
||||
/*
|
||||
* If the updated value is in sync with the value in the DOM, there
|
||||
* is no need to re-render. If we're currently editing the value,
|
||||
* it will automatically be in sync, suppressing the re-render for
|
||||
* the view we're editing, while updating any others.
|
||||
*/
|
||||
if ( value === $setting.find('input, textarea, select, [value]').val() ) {
|
||||
return this;
|
||||
}
|
||||
|
@ -146,10 +146,10 @@ Details = Attachment.extend(/** @lends wp.media.view.Attachment.Details.prototyp
|
||||
this.model.save().done( function() {
|
||||
library._requery( true );
|
||||
/*
|
||||
* @todo: We need to move focus back to the previous, next, or first
|
||||
* attachment but the library gets re-queried and refreshed. Thus,
|
||||
* the references to the previous attachments are lost. We need an
|
||||
* alternate method.
|
||||
* @todo We need to move focus back to the previous, next, or first
|
||||
* attachment but the library gets re-queried and refreshed.
|
||||
* Thus, the references to the previous attachments are lost.
|
||||
* We need an alternate method.
|
||||
*/
|
||||
self.moveFocusToLastFallback();
|
||||
} );
|
||||
|
@ -131,11 +131,11 @@ Attachments = View.extend(/** @lends wp.media.view.Attachments.prototype */{
|
||||
*/
|
||||
attachmentFocus: function() {
|
||||
/*
|
||||
* @todo: when uploading new attachments, this tries to move focus to the
|
||||
* attachmentz grid. Actually, a progress bar gets initially displayed
|
||||
* @todo When uploading new attachments, this tries to move focus to
|
||||
* the attachments grid. Actually, a progress bar gets initially displayed
|
||||
* and then updated when uploading completes, so focus is lost.
|
||||
* Additionally: this view is used for both the attachments list and the
|
||||
* list of selected attachments in the bottom media toolbar. Thus, when
|
||||
* Additionally: this view is used for both the attachments list and
|
||||
* the list of selected attachments in the bottom media toolbar. Thus, when
|
||||
* uploading attachments, it is called twice and returns two different `this`.
|
||||
* `this.columns` is truthy within the modal.
|
||||
*/
|
||||
@ -257,8 +257,8 @@ Attachments = View.extend(/** @lends wp.media.view.Attachments.prototype */{
|
||||
/**
|
||||
* Initializes jQuery sortable on the attachment list.
|
||||
*
|
||||
* Fails gracefully if jQuery sortable doesn't exist or isn't passed in the
|
||||
* options.
|
||||
* Fails gracefully if jQuery sortable doesn't exist or isn't passed
|
||||
* in the options.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*
|
||||
@ -278,8 +278,8 @@ Attachments = View.extend(/** @lends wp.media.view.Attachments.prototype */{
|
||||
disabled: !! collection.comparator,
|
||||
|
||||
/*
|
||||
* Change the position of the attachment as soon as the mouse pointer overlaps a
|
||||
* thumbnail.
|
||||
* Change the position of the attachment as soon as the mouse pointer
|
||||
* overlaps a thumbnail.
|
||||
*/
|
||||
tolerance: 'pointer',
|
||||
|
||||
@ -321,8 +321,8 @@ Attachments = View.extend(/** @lends wp.media.view.Attachments.prototype */{
|
||||
}, this.options.sortable ) );
|
||||
|
||||
/*
|
||||
* If the `orderby` property is changed on the `collection`, check to see if we
|
||||
* have a `comparator`. If so, disable sorting.
|
||||
* If the `orderby` property is changed on the `collection`,
|
||||
* check to see if we have a `comparator`. If so, disable sorting.
|
||||
*/
|
||||
collection.props.on( 'change:orderby', function() {
|
||||
this.$el.sortable( 'option', 'disabled', !! collection.comparator );
|
||||
|
@ -194,9 +194,11 @@ AttachmentsBrowser = View.extend(/** @lends wp.media.view.AttachmentsBrowser.pro
|
||||
}
|
||||
}
|
||||
|
||||
// Feels odd to bring the global media library switcher into the Attachment
|
||||
// browser view. Is this a use case for doAction( 'add:toolbar-items:attachments-browser', this.toolbar );
|
||||
// which the controller can tap into and add this view?
|
||||
/*
|
||||
* Feels odd to bring the global media library switcher into the Attachment browser view.
|
||||
* Is this a use case for doAction( 'add:toolbar-items:attachments-browser', this.toolbar );
|
||||
* which the controller can tap into and add this view?
|
||||
*/
|
||||
if ( this.controller.isModeActive( 'grid' ) ) {
|
||||
LibraryViewSwitcher = View.extend({
|
||||
className: 'view-switch media-grid-view-switch',
|
||||
@ -222,7 +224,7 @@ AttachmentsBrowser = View.extend(/** @lends wp.media.view.AttachmentsBrowser.pro
|
||||
priority: -75
|
||||
}).render() );
|
||||
|
||||
// BulkSelection is a <div> with subviews, including screen reader text
|
||||
// BulkSelection is a <div> with subviews, including screen reader text.
|
||||
this.toolbar.set( 'selectModeToggleButton', new wp.media.view.SelectModeToggleButton({
|
||||
text: l10n.bulkSelect,
|
||||
controller: this.controller,
|
||||
@ -437,7 +439,7 @@ AttachmentsBrowser = View.extend(/** @lends wp.media.view.AttachmentsBrowser.pro
|
||||
AttachmentView: this.options.AttachmentView
|
||||
});
|
||||
|
||||
// Add keydown listener to the instance of the Attachments view
|
||||
// Add keydown listener to the instance of the Attachments view.
|
||||
this.controller.on( 'attachment:keydown:arrow', _.bind( this.attachments.arrowEvent, this.attachments ) );
|
||||
this.controller.on( 'attachment:details:shift-tab', _.bind( this.attachments.restoreFocus, this.attachments ) );
|
||||
|
||||
@ -516,7 +518,7 @@ AttachmentsBrowser = View.extend(/** @lends wp.media.view.AttachmentsBrowser.pro
|
||||
}) );
|
||||
}
|
||||
|
||||
// Show the sidebar on mobile
|
||||
// Show the sidebar on mobile.
|
||||
if ( this.model.id === 'insert' ) {
|
||||
sidebar.$el.addClass( 'visible' );
|
||||
}
|
||||
@ -527,7 +529,7 @@ AttachmentsBrowser = View.extend(/** @lends wp.media.view.AttachmentsBrowser.pro
|
||||
sidebar.unset('details');
|
||||
sidebar.unset('compat');
|
||||
sidebar.unset('display');
|
||||
// Hide the sidebar on mobile
|
||||
// Hide the sidebar on mobile.
|
||||
sidebar.$el.removeClass( 'visible' );
|
||||
}
|
||||
});
|
||||
|
@ -49,7 +49,7 @@ SelectModeToggle = Button.extend(/** @lends wp.media.view.SelectModeToggle.proto
|
||||
|
||||
children = toolbar.$( '.media-toolbar-secondary > *, .media-toolbar-primary > *' );
|
||||
|
||||
// TODO: the Frame should be doing all of this.
|
||||
// @todo The Frame should be doing all of this.
|
||||
if ( this.controller.isModeActive( 'select' ) ) {
|
||||
this.model.set( {
|
||||
size: 'large',
|
||||
|
@ -23,11 +23,11 @@ EmbedLink = wp.media.view.Settings.extend(/** @lends wp.media.view.EmbedLink.pro
|
||||
updateoEmbed: _.debounce( function() {
|
||||
var url = this.model.get( 'url' );
|
||||
|
||||
// clear out previous results
|
||||
// Clear out previous results.
|
||||
this.$('.embed-container').hide().find('.embed-preview').empty();
|
||||
this.$( '.setting' ).hide();
|
||||
|
||||
// only proceed with embed if the field contains more than 11 characters
|
||||
// Only proceed with embed if the field contains more than 11 characters.
|
||||
// Example: http://a.io is 11 chars
|
||||
if ( url && ( url.length < 11 || ! url.match(/^http(s)?:\/\//) ) ) {
|
||||
return;
|
||||
@ -39,7 +39,7 @@ EmbedLink = wp.media.view.Settings.extend(/** @lends wp.media.view.EmbedLink.pro
|
||||
fetch: function() {
|
||||
var url = this.model.get( 'url' ), re, youTubeEmbedMatch;
|
||||
|
||||
// check if they haven't typed in 500 ms
|
||||
// Check if they haven't typed in 500 ms.
|
||||
if ( $('#embed-url-field').val() !== url ) {
|
||||
return;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ var FocusManager = wp.media.View.extend(/** @lends wp.media.view.FocusManager.pr
|
||||
|
||||
tabbables = this.getTabbables();
|
||||
|
||||
// Keep tab focus within media modal while it's open
|
||||
// Keep tab focus within media modal while it's open.
|
||||
if ( tabbables.last()[0] === event.target && ! event.shiftKey ) {
|
||||
tabbables.first().focus();
|
||||
return false;
|
||||
|
@ -255,11 +255,11 @@ EditAttachments = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.EditAtta
|
||||
return;
|
||||
}
|
||||
|
||||
// The right arrow key
|
||||
// The right arrow key.
|
||||
if ( 39 === event.keyCode ) {
|
||||
this.nextMediaItem();
|
||||
}
|
||||
// The left arrow key
|
||||
// The left arrow key.
|
||||
if ( 37 === event.keyCode ) {
|
||||
this.previousMediaItem();
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ ImageDetails = Select.extend(/** @lends wp.media.view.MediaFrame.ImageDetails.pr
|
||||
this.on( 'content:create:image-details', this.imageDetailsContent, this );
|
||||
this.on( 'content:render:edit-image', this.editImageContent, this );
|
||||
this.on( 'toolbar:render:image-details', this.renderImageDetailsToolbar, this );
|
||||
// override the select toolbar
|
||||
// Override the select toolbar.
|
||||
this.on( 'toolbar:render:replace', this.renderReplaceImageToolbar, this );
|
||||
},
|
||||
|
||||
@ -91,7 +91,7 @@ ImageDetails = Select.extend(/** @lends wp.media.view.MediaFrame.ImageDetails.pr
|
||||
|
||||
this.content.set( view );
|
||||
|
||||
// after bringing in the frame, load the actual editor via an ajax call
|
||||
// After bringing in the frame, load the actual editor via an Ajax call.
|
||||
view.loadEditor();
|
||||
|
||||
},
|
||||
@ -111,8 +111,8 @@ ImageDetails = Select.extend(/** @lends wp.media.view.MediaFrame.ImageDetails.pr
|
||||
|
||||
controller.close();
|
||||
|
||||
// not sure if we want to use wp.media.string.image which will create a shortcode or
|
||||
// perhaps wp.html.string to at least to build the <img />
|
||||
// Not sure if we want to use wp.media.string.image which will create a shortcode or
|
||||
// perhaps wp.html.string to at least to build the <img />.
|
||||
state.trigger( 'update', controller.image.toJSON() );
|
||||
|
||||
// Restore and reset the default state.
|
||||
@ -160,8 +160,8 @@ ImageDetails = Select.extend(/** @lends wp.media.view.MediaFrame.ImageDetails.pr
|
||||
|
||||
controller.image.changeAttachment( attachment, state.display( attachment ) );
|
||||
|
||||
// not sure if we want to use wp.media.string.image which will create a shortcode or
|
||||
// perhaps wp.html.string to at least to build the <img />
|
||||
// Not sure if we want to use wp.media.string.image which will create a shortcode or
|
||||
// perhaps wp.html.string to at least to build the <img />.
|
||||
state.trigger( 'replace', controller.image.toJSON() );
|
||||
|
||||
// Restore and reset the default state.
|
||||
|
@ -102,7 +102,7 @@ Manage = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.Manage.prototype
|
||||
}
|
||||
}, 1000 );
|
||||
|
||||
// Update the URL when entering search string (at most once per second)
|
||||
// Update the URL when entering search string (at most once per second).
|
||||
search.on( 'input', _.bind( input, this ) );
|
||||
|
||||
this.gridRouter
|
||||
@ -183,7 +183,7 @@ Manage = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.Manage.prototype
|
||||
$browser = this.$('.attachments-browser');
|
||||
$toolbar = $browser.find('.media-toolbar');
|
||||
|
||||
// Offset doesn't appear to take top margin into account, hence +16
|
||||
// Offset doesn't appear to take top margin into account, hence +16.
|
||||
if ( ( $browser.offset().top + 16 ) < this.$window.scrollTop() + this.$adminBar.height() ) {
|
||||
$browser.addClass( 'fixed' );
|
||||
$toolbar.css('width', $browser.width() + 'px');
|
||||
@ -271,7 +271,7 @@ Manage = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.Manage.prototype
|
||||
},
|
||||
|
||||
startHistory: function() {
|
||||
// Verify pushState support and activate
|
||||
// Verify pushState support and activate.
|
||||
if ( window.history && window.history.pushState ) {
|
||||
if ( Backbone.History.started ) {
|
||||
Backbone.history.stop();
|
||||
|
@ -180,7 +180,7 @@ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{
|
||||
|
||||
this.on( 'activate', this.activate, this );
|
||||
|
||||
// Only bother checking media type counts if one of the counts is zero
|
||||
// Only bother checking media type counts if one of the counts is zero.
|
||||
checkCounts = _.find( this.counts, function( type ) {
|
||||
return type.count === 0;
|
||||
} );
|
||||
@ -235,7 +235,7 @@ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{
|
||||
},
|
||||
|
||||
activate: function() {
|
||||
// Hide menu items for states tied to particular media types if there are no items
|
||||
// Hide menu items for states tied to particular media types if there are no items.
|
||||
_.each( this.counts, function( type ) {
|
||||
if ( type.count < 1 ) {
|
||||
this.menuItemVisibility( type.state, 'hide' );
|
||||
@ -250,7 +250,7 @@ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{
|
||||
}
|
||||
},
|
||||
|
||||
// Menus
|
||||
// Menus.
|
||||
/**
|
||||
* @param {wp.Backbone.View} view
|
||||
*/
|
||||
@ -358,7 +358,7 @@ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{
|
||||
});
|
||||
},
|
||||
|
||||
// Content
|
||||
// Content.
|
||||
embedContent: function() {
|
||||
var view = new wp.media.view.Embed({
|
||||
controller: this,
|
||||
@ -400,7 +400,7 @@ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{
|
||||
// Browse our library of attachments.
|
||||
this.content.set( view );
|
||||
|
||||
// Trigger the controller to set focus
|
||||
// Trigger the controller to set focus.
|
||||
this.trigger( 'edit:selection', this );
|
||||
},
|
||||
|
||||
@ -410,12 +410,12 @@ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{
|
||||
|
||||
this.content.set( view );
|
||||
|
||||
// after creating the wrapper view, load the actual editor via an ajax call
|
||||
// After creating the wrapper view, load the actual editor via an Ajax call.
|
||||
view.loadEditor();
|
||||
|
||||
},
|
||||
|
||||
// Toolbars
|
||||
// Toolbars.
|
||||
|
||||
/**
|
||||
* @param {wp.Backbone.View} view
|
||||
|
@ -64,7 +64,7 @@ Select = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.Select.prototype
|
||||
|
||||
this.content.set( view );
|
||||
|
||||
// after creating the wrapper view, load the actual editor via an ajax call
|
||||
// After creating the wrapper view, load the actual editor via an Ajax call.
|
||||
view.loadEditor();
|
||||
},
|
||||
|
||||
|
@ -27,7 +27,7 @@ ImageDetails = AttachmentDisplay.extend(/** @lends wp.media.view.ImageDetails.pr
|
||||
'keyup [data-setting="customHeight"]': 'onCustomSize'
|
||||
} ),
|
||||
initialize: function() {
|
||||
// used in AttachmentDisplay.prototype.updateLinkTo
|
||||
// Used in AttachmentDisplay.prototype.updateLinkTo.
|
||||
this.options.attachment = this.model.attachment;
|
||||
this.listenTo( this.model, 'change:url', this.updateUrl );
|
||||
this.listenTo( this.model, 'change:link', this.toggleLinkSettings );
|
||||
@ -109,7 +109,7 @@ ImageDetails = AttachmentDisplay.extend(/** @lends wp.media.view.ImageDetails.pr
|
||||
num = $( event.target ).val(),
|
||||
value;
|
||||
|
||||
// Ignore bogus input
|
||||
// Ignore bogus input.
|
||||
if ( ! /^\d+/.test( num ) || parseInt( num, 10 ) < 1 ) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
|
@ -42,7 +42,7 @@ MenuItem = wp.media.View.extend(/** @lends wp.media.view.MenuItem.prototype */{
|
||||
if ( state ) {
|
||||
this.controller.setState( state );
|
||||
// Toggle the menu visibility in the responsive view.
|
||||
this.views.parent.$el.removeClass( 'visible' ); // TODO: or hide on any click, see below
|
||||
this.views.parent.$el.removeClass( 'visible' ); // @todo Or hide on any click, see below.
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -102,7 +102,7 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{
|
||||
|
||||
$el.show();
|
||||
|
||||
// Try to close the onscreen keyboard
|
||||
// Try to close the onscreen keyboard.
|
||||
if ( 'ontouchend' in document ) {
|
||||
if ( ( mceEditor = window.tinymce && window.tinymce.activeEditor ) && ! mceEditor.isHidden() && mceEditor.iframeElement ) {
|
||||
mceEditor.iframeElement.focus();
|
||||
@ -135,7 +135,7 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{
|
||||
// Enable page scrolling.
|
||||
$( 'body' ).removeClass( 'modal-open' );
|
||||
|
||||
// Hide modal and remove restricted media modal tab focus once it's closed
|
||||
// Hide modal and remove restricted media modal tab focus once it's closed.
|
||||
this.$el.hide().undelegate( 'keydown' );
|
||||
|
||||
/*
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user