???????????????????????????? ??????????????/????????????????? ............/............... .........................../... ????????????????????????????? >>>>>>>>>>>>>/>>>>>>>>>>>>>>>>> ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>/>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ???????????????????????????? ??????????????/????????????????? ............/............... .........................../... ????????????????????????????? >>>>>>>>>>>>>/>>>>>>>>>>>>>>>>> ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>/>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> wp-list-revisions.min.js000066400000001125152436173310011310 0ustar00/*! This file is auto-generated */ !function(e){function t(){var e=document.getElementById("post-revisions"),n=e?e.getElementsByTagName("input"):[];e.onclick=function(){for(var e,t=0,i=0;i { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ 7145 (module) { var Selection = wp.media.model.Selection, Library = wp.media.controller.Library, CollectionAdd; /** * wp.media.controller.CollectionAdd * * A state for adding attachments to a collection (e.g. video playlist). * * @memberOf wp.media.controller * * @class * @augments wp.media.controller.Library * @augments wp.media.controller.State * @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 {boolean|string} [attributes.multiple=add] Whether multi-select is enabled. Accepts 'add' or true. * When set to true, requires Shift or Cmd/Ctrl to select multiple items. * When set to 'add', allows selecting multiple items by clicking thumbnails. * @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. * @param {boolean|string} [attributes.filterable=uploaded] Whether the library is filterable, and if so what filters should be shown. * Accepts 'all', 'uploaded', or 'unattached'. * @param {string} [attributes.menu=gallery] Initial mode for the menu region. * @param {string} [attributes.content=upload] Initial mode for the content region. * Overridden by persistent user setting if 'contentUserSetting' is true. * @param {string} [attributes.router=browse] Initial mode for the router region. * @param {string} [attributes.toolbar=gallery-add] Initial mode for the toolbar region. * @param {boolean} [attributes.searchable=true] Whether the library is searchable. * @param {boolean} [attributes.sortable=true] Whether the Attachments should be sortable. Depends on the orderby property being set to menuOrder on the attachments collection. * @param {boolean} [attributes.autoSelect=true] Whether an uploaded attachment should be automatically added to the selection. * @param {boolean} [attributes.contentUserSetting=true] Whether the content region's mode should be set and persisted per user. * @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'). */ CollectionAdd = Library.extend(/** @lends wp.media.controller.CollectionAdd.prototype */{ defaults: _.defaults( { // Selection defaults. @see media.model.Selection multiple: 'add', // Attachments browser defaults. @see media.view.AttachmentsBrowser filterable: 'uploaded', priority: 100, syncSelection: false }, Library.prototype.defaults ), /** * @since 3.9.0 */ initialize: function() { var collectionType = this.get('collectionType'); if ( 'video' === this.get( 'type' ) ) { collectionType = 'video-' + collectionType; } this.set( 'id', collectionType + '-library' ); this.set( 'toolbar', collectionType + '-add' ); this.set( 'menu', collectionType ); // If we haven't been provided a `library`, create a `Selection`. if ( ! this.get('library') ) { this.set( 'library', wp.media.query({ type: this.get('type') }) ); } Library.prototype.initialize.apply( this, arguments ); }, /** * @since 3.9.0 */ activate: function() { var library = this.get('library'), editLibrary = this.get('editLibrary'), edit = this.frame.state( this.get('collectionType') + '-edit' ).get('library'); if ( editLibrary && editLibrary !== edit ) { library.unobserve( editLibrary ); } // Accepts attachments that exist in the original library and // that do not exist in gallery's library. library.validator = function( attachment ) { 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. */ library.reset( library.mirroring.models, { silent: true }); library.observe( edit ); this.set('editLibrary', edit); Library.prototype.activate.apply( this, arguments ); } }); module.exports = CollectionAdd; /***/ }, /***/ 8612 (module) { var Library = wp.media.controller.Library, l10n = wp.media.view.l10n, $ = jQuery, CollectionEdit; /** * wp.media.controller.CollectionEdit * * A state for editing a collection, which is used by audio and video playlists, * and can be used for other collections. * * @memberOf wp.media.controller * * @class * @augments wp.media.controller.Library * @augments wp.media.controller.State * @augments Backbone.Model * * @param {object} [attributes] The attributes hash passed to the state. * @param {string} attributes.title Title for the state. Displays in the media menu and the frame's title region. * @param {wp.media.model.Attachments} [attributes.library] The attachments collection to edit. * If one is not supplied, an empty media.model.Selection collection is created. * @param {boolean} [attributes.multiple=false] Whether multi-select is enabled. * @param {string} [attributes.content=browse] Initial mode for the content region. * @param {string} attributes.menu Initial mode for the menu region. @todo this needs a better explanation. * @param {boolean} [attributes.searchable=false] Whether the library is searchable. * @param {boolean} [attributes.sortable=true] Whether the Attachments should be sortable. Depends on the orderby property being set to menuOrder on the attachments collection. * @param {boolean} [attributes.date=true] Whether to show the date filter in the browser's toolbar. * @param {boolean} [attributes.describe=true] Whether to offer UI to describe the attachments - e.g. captioning images in a gallery. * @param {boolean} [attributes.dragInfo=true] Whether to show instructional text about the attachments being sortable. * @param {boolean} [attributes.dragInfoText] Instructional text about the attachments being sortable. * @param {int} [attributes.idealColumnWidth=170] The ideal column width in pixels for attachments. * @param {boolean} [attributes.editing=false] Whether the gallery is being created, or editing an existing instance. * @param {int} [attributes.priority=60] 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 for this state, because the library passed in *is* the selection. * @param {view} [attributes.SettingsView] The view to edit the collection instance settings (e.g. Playlist settings with "Show tracklist" checkbox). * @param {view} [attributes.AttachmentView] The single `Attachment` view to be used in the `Attachments`. * If none supplied, defaults to wp.media.view.Attachment.EditLibrary. * @param {string} attributes.type The collection's media type. (e.g. 'video'). * @param {string} attributes.collectionType The collection type. (e.g. 'playlist'). */ CollectionEdit = Library.extend(/** @lends wp.media.controller.CollectionEdit.prototype */{ defaults: { multiple: false, sortable: true, date: false, searchable: false, content: 'browse', describe: true, dragInfo: true, idealColumnWidth: 170, editing: false, priority: 60, SettingsView: false, syncSelection: false }, /** * @since 3.9.0 */ initialize: function() { var collectionType = this.get('collectionType'); if ( 'video' === this.get( 'type' ) ) { collectionType = 'video-' + collectionType; } this.set( 'id', collectionType + '-edit' ); this.set( 'toolbar', collectionType + '-edit' ); // If we haven't been provided a `library`, create a `Selection`. if ( ! this.get('library') ) { this.set( 'library', new wp.media.model.Selection() ); } // The single `Attachment` view to be used in the `Attachments` view. if ( ! this.get('AttachmentView') ) { this.set( 'AttachmentView', wp.media.view.Attachment.EditLibrary ); } Library.prototype.initialize.apply( this, arguments ); }, /** * @since 3.9.0 */ activate: function() { var library = this.get('library'); // Limit the library to images only. library.props.set( 'type', this.get( 'type' ) ); // Watch for uploaded attachments. this.get('library').observe( wp.Uploader.queue ); this.frame.on( 'content:render:browse', this.renderSettings, this ); Library.prototype.activate.apply( this, arguments ); }, /** * @since 3.9.0 */ deactivate: function() { // Stop watching for uploaded attachments. this.get('library').unobserve( wp.Uploader.queue ); this.frame.off( 'content:render:browse', this.renderSettings, this ); Library.prototype.deactivate.apply( this, arguments ); }, /** * Render the collection embed settings view in the browser sidebar. * * @todo This is against the pattern elsewhere in media. Typically the frame * is responsible for adding region mode callbacks. Explain. * * @since 3.9.0 * * @param {wp.media.view.attachmentsBrowser} The attachments browser view. */ renderSettings: function( attachmentsBrowserView ) { var library = this.get('library'), collectionType = this.get('collectionType'), dragInfoText = this.get('dragInfoText'), SettingsView = this.get('SettingsView'), obj = {}; if ( ! library || ! attachmentsBrowserView ) { return; } library[ collectionType ] = library[ collectionType ] || new Backbone.Model(); obj[ collectionType ] = new SettingsView({ controller: this, model: library[ collectionType ], priority: 40 }); attachmentsBrowserView.sidebar.set( obj ); if ( dragInfoText ) { attachmentsBrowserView.toolbar.set( 'dragInfo', new wp.media.View({ el: $( '
' + dragInfoText + '
' )[0], priority: -40 }) ); } // Add the 'Reverse order' button to the toolbar. attachmentsBrowserView.toolbar.set( 'reverse', { text: l10n.reverseOrder, priority: 80, click: function() { library.reset( library.toArray().reverse() ); } }); } }); module.exports = CollectionEdit; /***/ }, /***/ 5422 (module) { var l10n = wp.media.view.l10n, Cropper; /** * wp.media.controller.Cropper * * A class for cropping an image when called from the header media customization panel. * * @memberOf wp.media.controller * * @class * @augments wp.media.controller.State * @augments Backbone.Model */ Cropper = wp.media.controller.State.extend(/** @lends wp.media.controller.Cropper.prototype */{ defaults: { id: 'cropper', title: l10n.cropImage, // Region mode defaults. toolbar: 'crop', content: 'crop', router: false, canSkipCrop: false, // Default doCrop Ajax arguments to allow the Customizer (for example) to inject state. doCropArgs: {} }, /** * Shows the crop image window when called from the Add new image button. * * @since 4.2.0 * * @return {void} */ activate: function() { this.frame.on( 'content:create:crop', this.createCropContent, this ); this.frame.on( 'close', this.removeCropper, this ); this.set('selection', new Backbone.Collection(this.frame._selection.single)); }, /** * Changes the state of the toolbar window to browse mode. * * @since 4.2.0 * * @return {void} */ deactivate: function() { this.frame.toolbar.mode('browse'); }, /** * Creates the crop image window. * * Initialized when clicking on the Select and Crop button. * * @since 4.2.0 * * @fires crop window * * @return {void} */ createCropContent: function() { this.cropperView = new wp.media.view.Cropper({ controller: this, attachment: this.get('selection').first() }); this.cropperView.on('image-loaded', this.createCropToolbar, this); this.frame.content.set(this.cropperView); }, /** * Removes the image selection and closes the cropping window. * * @since 4.2.0 * * @return {void} */ removeCropper: function() { this.imgSelect.cancelSelection(); this.imgSelect.setOptions({remove: true}); this.imgSelect.update(); this.cropperView.remove(); }, /** * Checks if cropping can be skipped and creates crop toolbar accordingly. * * @since 4.2.0 * * @return {void} */ createCropToolbar: function() { var canSkipCrop, hasRequiredAspectRatio, suggestedCropSize, toolbarOptions; suggestedCropSize = this.get( 'suggestedCropSize' ); hasRequiredAspectRatio = this.get( 'hasRequiredAspectRatio' ); canSkipCrop = this.get( 'canSkipCrop' ) || false; toolbarOptions = { controller: this.frame, items: { insert: { style: 'primary', text: l10n.cropImage, priority: 80, requires: { library: false, selection: false }, click: function() { var controller = this.controller, selection; selection = controller.state().get('selection').first(); selection.set({cropDetails: controller.state().imgSelect.getSelection()}); this.$el.text(l10n.cropping); this.$el.attr('disabled', true); controller.state().doCrop( selection ).done( function( croppedImage ) { controller.trigger('cropped', croppedImage ); controller.close(); }).fail( function() { controller.trigger('content:error:crop'); }); } } } }; if ( canSkipCrop || hasRequiredAspectRatio ) { _.extend( toolbarOptions.items, { skip: { style: 'secondary', text: l10n.skipCropping, priority: 70, requires: { library: false, selection: false }, click: function() { var controller = this.controller, selection = controller.state().get( 'selection' ).first(); controller.state().cropperView.remove(); // Apply the suggested crop size. if ( hasRequiredAspectRatio && !canSkipCrop ) { selection.set({cropDetails: suggestedCropSize}); controller.state().doCrop( selection ).done( function( croppedImage ) { controller.trigger( 'cropped', croppedImage ); controller.close(); }).fail( function() { controller.trigger( 'content:error:crop' ); }); return; } // Skip the cropping process. controller.trigger( 'skippedcrop', selection ); controller.close(); } } }); } this.frame.toolbar.set( new wp.media.view.Toolbar(toolbarOptions) ); }, /** * Creates an object with the image attachment and crop properties. * * @since 4.2.0 * * @return {$.promise} A jQuery promise with the custom header crop details. */ doCrop: function( attachment ) { return wp.ajax.post( 'custom-header-crop', _.extend( {}, this.defaults.doCropArgs, { nonce: attachment.get( 'nonces' ).edit, id: attachment.get( 'id' ), cropDetails: attachment.get( 'cropDetails' ) } ) ); } }); module.exports = Cropper; /***/ }, /***/ 9660 (module) { var Controller = wp.media.controller, CustomizeImageCropper; /** * A state for cropping an image in the customizer. * * @since 4.3.0 * * @constructs wp.media.controller.CustomizeImageCropper * @memberOf wp.media.controller * @augments wp.media.controller.CustomizeImageCropper.Cropper * @inheritDoc */ CustomizeImageCropper = Controller.Cropper.extend(/** @lends wp.media.controller.CustomizeImageCropper.prototype */{ /** * Posts the crop details to the admin. * * Uses crop measurements when flexible in both directions. * Constrains flexible side based on image ratio and size of the fixed side. * * @since 4.3.0 * * @param {Object} attachment The attachment to crop. * * @return {$.promise} A jQuery promise that represents the crop image request. */ doCrop: function( attachment ) { var cropDetails = attachment.get( 'cropDetails' ), control = this.get( 'control' ), ratio = cropDetails.width / cropDetails.height; // Use crop measurements when flexible in both directions. if ( control.params.flex_width && control.params.flex_height ) { cropDetails.dst_width = cropDetails.width; cropDetails.dst_height = cropDetails.height; // Constrain flexible side based on image ratio and size of the fixed side. } else { cropDetails.dst_width = control.params.flex_width ? control.params.height * ratio : control.params.width; cropDetails.dst_height = control.params.flex_height ? control.params.width / ratio : control.params.height; } return wp.ajax.post( 'crop-image', { wp_customize: 'on', nonce: attachment.get( 'nonces' ).edit, id: attachment.get( 'id' ), context: control.id, cropDetails: cropDetails } ); } }); module.exports = CustomizeImageCropper; /***/ }, /***/ 5663 (module) { var l10n = wp.media.view.l10n, EditImage; /** * wp.media.controller.EditImage * * A state for editing (cropping, etc.) an image. * * @memberOf wp.media.controller * * @class * @augments wp.media.controller.State * @augments Backbone.Model * * @param {object} attributes The attributes hash passed to the state. * @param {wp.media.model.Attachment} attributes.model The attachment. * @param {string} [attributes.id=edit-image] Unique identifier. * @param {string} [attributes.title=Edit Image] Title for the state. Displays in the media menu and the frame's title region. * @param {string} [attributes.content=edit-image] Initial mode for the content region. * @param {string} [attributes.toolbar=edit-image] Initial mode for the toolbar region. * @param {string} [attributes.menu=false] Initial mode for the menu region. * @param {string} [attributes.url] Unused. @todo Consider removal. */ EditImage = wp.media.controller.State.extend(/** @lends wp.media.controller.EditImage.prototype */{ defaults: { id: 'edit-image', title: l10n.editImage, menu: false, toolbar: 'edit-image', content: 'edit-image', url: '' }, /** * Activates a frame for editing a featured image. * * @since 3.9.0 * * @return {void} */ activate: function() { this.frame.on( 'toolbar:render:edit-image', _.bind( this.toolbar, this ) ); }, /** * Deactivates a frame for editing a featured image. * * @since 3.9.0 * * @return {void} */ deactivate: function() { this.frame.off( 'toolbar:render:edit-image' ); }, /** * Adds a toolbar with a back button. * * When the back button is pressed it checks whether there is a previous state. * In case there is a previous state it sets that previous state otherwise it * closes the frame. * * @since 3.9.0 * * @return {void} */ toolbar: function() { var frame = this.frame, lastState = frame.lastState(), previous = lastState && lastState.id; frame.toolbar.set( new wp.media.view.Toolbar({ controller: frame, items: { back: { style: 'primary', text: l10n.back, priority: 20, click: function() { if ( previous ) { frame.setState( previous ); } else { frame.close(); } } } } }) ); } }); module.exports = EditImage; /***/ }, /***/ 4910 (module) { var l10n = wp.media.view.l10n, $ = Backbone.$, Embed; /** * wp.media.controller.Embed * * A state for embedding media from a URL. * * @memberOf wp.media.controller * * @class * @augments wp.media.controller.State * @augments Backbone.Model * * @param {object} attributes The attributes hash passed to the state. * @param {string} [attributes.id=embed] Unique identifier. * @param {string} [attributes.title=Insert From URL] Title for the state. Displays in the media menu and the frame's title region. * @param {string} [attributes.content=embed] Initial mode for the content region. * @param {string} [attributes.menu=default] Initial mode for the menu region. * @param {string} [attributes.toolbar=main-embed] Initial mode for the toolbar region. * @param {string} [attributes.menu=false] Initial mode for the menu region. * @param {int} [attributes.priority=120] The priority for the state link in the media menu. * @param {string} [attributes.type=link] The type of embed. Currently only link is supported. * @param {string} [attributes.url] The embed URL. * @param {object} [attributes.metadata={}] Properties of the embed, which will override attributes.url if set. */ Embed = wp.media.controller.State.extend(/** @lends wp.media.controller.Embed.prototype */{ defaults: { id: 'embed', title: l10n.insertFromUrlTitle, content: 'embed', menu: 'default', toolbar: 'main-embed', priority: 120, type: 'link', url: '', metadata: {} }, // The amount of time used when debouncing the scan. sensitivity: 400, initialize: function(options) { this.metadata = options.metadata; this.debouncedScan = _.debounce( _.bind( this.scan, this ), this.sensitivity ); this.props = new Backbone.Model( this.metadata || { url: '' }); this.props.on( 'change:url', this.debouncedScan, this ); this.props.on( 'change:url', this.refresh, this ); this.on( 'scan', this.scanImage, this ); }, /** * Trigger a scan of the embedded URL's content for metadata required to embed. * * @fires wp.media.controller.Embed#scan */ scan: function() { var scanners, embed = this, attributes = { type: 'link', 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. */ if ( this.props.get('url') ) { this.trigger( 'scan', attributes ); } if ( attributes.scanners.length ) { scanners = attributes.scanners = $.when.apply( $, attributes.scanners ); scanners.always( function() { if ( embed.get('scanners') === scanners ) { embed.set( 'loading', false ); } }); } else { attributes.scanners = null; } attributes.loading = !! attributes.scanners; this.set( attributes ); }, /** * Try scanning the embed as an image to discover its dimensions. * * @param {Object} attributes */ scanImage: function( attributes ) { var frame = this.frame, state = this, url = this.props.get('url'), image = new Image(), deferred = $.Deferred(); attributes.scanners.push( deferred.promise() ); // Try to load the image and find its width/height. image.onload = function() { deferred.resolve(); if ( state !== frame.state() || url !== state.props.get('url') ) { return; } state.set({ type: 'image' }); state.props.set({ width: image.width, height: image.height }); }; image.onerror = deferred.reject; image.src = url; }, refresh: function() { this.frame.toolbar.get().refresh(); }, reset: function() { this.props.clear().set({ url: '' }); if ( this.active ) { this.refresh(); } } }); module.exports = Embed; /***/ }, /***/ 1169 (module) { var Attachment = wp.media.model.Attachment, Library = wp.media.controller.Library, l10n = wp.media.view.l10n, FeaturedImage; /** * wp.media.controller.FeaturedImage * * A state for selecting a featured image for a post. * * @memberOf wp.media.controller * * @class * @augments wp.media.controller.Library * @augments wp.media.controller.State * @augments Backbone.Model * * @param {object} [attributes] The attributes hash passed to the state. * @param {string} [attributes.id=featured-image] Unique identifier. * @param {string} [attributes.title=Set Featured Image] Title for the state. Displays in the media menu and the frame's title region. * @param {wp.media.model.Attachments} [attributes.library] The attachments collection to browse. * If one is not supplied, a collection of all images will be created. * @param {boolean} [attributes.multiple=false] Whether multi-select is enabled. * @param {string} [attributes.content=upload] Initial mode for the content region. * Overridden by persistent user setting if 'contentUserSetting' is true. * @param {string} [attributes.menu=default] Initial mode for the menu region. * @param {string} [attributes.router=browse] Initial mode for the router region. * @param {string} [attributes.toolbar=featured-image] Initial mode for the toolbar region. * @param {int} [attributes.priority=60] The priority for the state link in the media menu. * @param {boolean} [attributes.searchable=true] Whether the library is searchable. * @param {boolean|string} [attributes.filterable=false] Whether the library is filterable, and if so what filters should be shown. * Accepts 'all', 'uploaded', or 'unattached'. * @param {boolean} [attributes.sortable=true] Whether the Attachments should be sortable. Depends on the orderby property being set to menuOrder on the attachments collection. * @param {boolean} [attributes.autoSelect=true] Whether an uploaded attachment should be automatically added to the selection. * @param {boolean} [attributes.describe=false] Whether to offer UI to describe attachments - e.g. captioning images in a gallery. * @param {boolean} [attributes.contentUserSetting=true] Whether the content region's mode should be set and persisted per user. * @param {boolean} [attributes.syncSelection=true] Whether the Attachments selection should be persisted from the last state. */ FeaturedImage = Library.extend(/** @lends wp.media.controller.FeaturedImage.prototype */{ defaults: _.defaults({ id: 'featured-image', title: l10n.setFeaturedImageTitle, multiple: false, filterable: 'uploaded', toolbar: 'featured-image', priority: 60, syncSelection: true }, Library.prototype.defaults ), /** * @since 3.5.0 */ initialize: function() { var library, comparator; // If we haven't been provided a `library`, create a `Selection`. if ( ! this.get('library') ) { this.set( 'library', wp.media.query({ type: 'image' }) ); } Library.prototype.initialize.apply( this, arguments ); library = this.get('library'); comparator = library.comparator; // Overload the library's comparator to push items that are not in // the mirrored query to the front of the aggregate collection. library.comparator = function( a, b ) { var aInQuery = !! this.mirroring.get( a.cid ), bInQuery = !! this.mirroring.get( b.cid ); if ( ! aInQuery && bInQuery ) { return -1; } else if ( aInQuery && ! bInQuery ) { return 1; } else { return comparator.apply( this, arguments ); } }; // Add all items in the selection to the library, so any featured // images that are not initially loaded still appear. library.observe( this.get('selection') ); }, /** * @since 3.5.0 */ activate: function() { this.frame.on( 'open', this.updateSelection, this ); Library.prototype.activate.apply( this, arguments ); }, /** * @since 3.5.0 */ deactivate: function() { this.frame.off( 'open', this.updateSelection, this ); Library.prototype.deactivate.apply( this, arguments ); }, /** * @since 3.5.0 */ updateSelection: function() { var selection = this.get('selection'), id = wp.media.view.settings.post.featuredImageId, attachment; if ( '' !== id && -1 !== id ) { attachment = Attachment.get( id ); attachment.fetch(); } selection.reset( attachment ? [ attachment ] : [] ); } }); module.exports = FeaturedImage; /***/ }, /***/ 7127 (module) { var Selection = wp.media.model.Selection, Library = wp.media.controller.Library, l10n = wp.media.view.l10n, GalleryAdd; /** * wp.media.controller.GalleryAdd * * A state for selecting more images to add to a gallery. * * @since 3.5.0 * * @class * @augments wp.media.controller.Library * @augments wp.media.controller.State * @augments Backbone.Model * * @memberof wp.media.controller * * @param {Object} [attributes] The attributes hash passed to the state. * @param {string} [attributes.id=gallery-library] Unique identifier. * @param {string} [attributes.title=Add to Gallery] Title for the state. Displays in the frame's title region. * @param {boolean|string} [attributes.multiple=add] Whether multi-select is enabled. Accepts 'add' or true. * When set to true, requires Shift or Cmd/Ctrl to select multiple items. * When set to 'add', allows selecting multiple items by clicking thumbnails. * @param {wp.media.model.Attachments} [attributes.library] The attachments collection to browse. * If one is not supplied, a collection of all images will be created. * @param {boolean|string} [attributes.filterable=uploaded] Whether the library is filterable, and if so what filters should be shown. * Accepts 'all', 'uploaded', or 'unattached'. * @param {string} [attributes.menu=gallery] Initial mode for the menu region. * @param {string} [attributes.content=upload] Initial mode for the content region. * Overridden by persistent user setting if 'contentUserSetting' is true. * @param {string} [attributes.router=browse] Initial mode for the router region. * @param {string} [attributes.toolbar=gallery-add] Initial mode for the toolbar region. * @param {boolean} [attributes.searchable=true] Whether the library is searchable. * @param {boolean} [attributes.sortable=true] Whether the Attachments should be sortable. Depends on the orderby property being set to menuOrder on the attachments collection. * @param {boolean} [attributes.autoSelect=true] Whether an uploaded attachment should be automatically added to the selection. * @param {boolean} [attributes.contentUserSetting=true] Whether the content region's mode should be set and persisted per user. * @param {number} [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. */ GalleryAdd = Library.extend(/** @lends wp.media.controller.GalleryAdd.prototype */{ defaults: _.defaults({ id: 'gallery-library', title: l10n.addToGalleryTitle, multiple: 'add', filterable: 'uploaded', menu: 'gallery', toolbar: 'gallery-add', priority: 100, syncSelection: false }, Library.prototype.defaults ), /** * Initializes the library. Creates a library of images if a library isn't supplied. * * @since 3.5.0 * * @return {void} */ initialize: function() { if ( ! this.get('library') ) { this.set( 'library', wp.media.query({ type: 'image' }) ); } Library.prototype.initialize.apply( this, arguments ); }, /** * Activates the library. * * Removes all event listeners if in edit mode. Creates a validator to check an attachment. * Resets library and re-enables event listeners. Activates edit mode. Calls the parent's activate method. * * @since 3.5.0 * * @return {void} */ activate: function() { var library = this.get('library'), edit = this.frame.state('gallery-edit').get('library'); if ( this.editLibrary && this.editLibrary !== edit ) { library.unobserve( this.editLibrary ); } /* * Accept attachments that exist in the original library but * that do not exist in gallery's library yet. */ library.validator = function( attachment ) { 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. */ library.reset( library.mirroring.models, { silent: true }); library.observe( edit ); this.editLibrary = edit; Library.prototype.activate.apply( this, arguments ); } }); module.exports = GalleryAdd; /***/ }, /***/ 2038 (module) { var Library = wp.media.controller.Library, l10n = wp.media.view.l10n, GalleryEdit; /** * wp.media.controller.GalleryEdit * * A state for editing a gallery's images and settings. * * @since 3.5.0 * * @class * @augments wp.media.controller.Library * @augments wp.media.controller.State * @augments Backbone.Model * * @memberOf wp.media.controller * * @param {Object} [attributes] The attributes hash passed to the state. * @param {string} [attributes.id=gallery-edit] Unique identifier. * @param {string} [attributes.title=Edit Gallery] Title for the state. Displays in the frame's title region. * @param {wp.media.model.Attachments} [attributes.library] The collection of attachments in the gallery. * If one is not supplied, an empty media.model.Selection collection is created. * @param {boolean} [attributes.multiple=false] Whether multi-select is enabled. * @param {boolean} [attributes.searchable=false] Whether the library is searchable. * @param {boolean} [attributes.sortable=true] Whether the Attachments should be sortable. Depends on the orderby property being set to menuOrder on the attachments collection. * @param {boolean} [attributes.date=true] Whether to show the date filter in the browser's toolbar. * @param {string|false} [attributes.content=browse] Initial mode for the content region. * @param {string|false} [attributes.toolbar=image-details] Initial mode for the toolbar region. * @param {boolean} [attributes.describe=true] Whether to offer UI to describe attachments - e.g. captioning images in a gallery. * @param {boolean} [attributes.displaySettings=true] Whether to show the attachment display settings interface. * @param {boolean} [attributes.dragInfo=true] Whether to show instructional text about the attachments being sortable. * @param {number} [attributes.idealColumnWidth=170] The ideal column width in pixels for attachments. * @param {boolean} [attributes.editing=false] Whether the gallery is being created, or editing an existing instance. * @param {number} [attributes.priority=60] 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 for this state, because the library passed in *is* the selection. * @param {view} [attributes.AttachmentView] The single `Attachment` view to be used in the `Attachments`. * If none supplied, defaults to wp.media.view.Attachment.EditLibrary. */ GalleryEdit = Library.extend(/** @lends wp.media.controller.GalleryEdit.prototype */{ defaults: { id: 'gallery-edit', title: l10n.editGalleryTitle, multiple: false, searchable: false, sortable: true, date: false, display: false, content: 'browse', toolbar: 'gallery-edit', describe: true, displaySettings: true, dragInfo: true, idealColumnWidth: 170, editing: false, priority: 60, syncSelection: false }, /** * Initializes the library. * * Creates a selection if a library isn't supplied and creates an attachment * view if no attachment view is supplied. * * @since 3.5.0 * * @return {void} */ initialize: function() { // If we haven't been provided a `library`, create a `Selection`. if ( ! this.get('library') ) { this.set( 'library', new wp.media.model.Selection() ); } // The single `Attachment` view to be used in the `Attachments` view. if ( ! this.get('AttachmentView') ) { this.set( 'AttachmentView', wp.media.view.Attachment.EditLibrary ); } Library.prototype.initialize.apply( this, arguments ); }, /** * Activates the library. * * Limits the library to images, watches for uploaded attachments. Watches for * the browse event on the frame and binds it to gallerySettings. * * @since 3.5.0 * * @return {void} */ activate: function() { var library = this.get('library'); // Limit the library to images only. library.props.set( 'type', 'image' ); // Watch for uploaded attachments. this.get('library').observe( wp.Uploader.queue ); this.frame.on( 'content:render:browse', this.gallerySettings, this ); Library.prototype.activate.apply( this, arguments ); }, /** * Deactivates the library. * * Stops watching for uploaded attachments and browse events. * * @since 3.5.0 * * @return {void} */ deactivate: function() { // Stop watching for uploaded attachments. this.get('library').unobserve( wp.Uploader.queue ); this.frame.off( 'content:render:browse', this.gallerySettings, this ); Library.prototype.deactivate.apply( this, arguments ); }, /** * Adds the gallery settings to the sidebar and adds a reverse button to the * toolbar. * * @since 3.5.0 * * @param {wp.media.view.Frame} browser The file browser. * * @return {void} */ gallerySettings: function( browser ) { if ( ! this.get('displaySettings') ) { return; } var library = this.get('library'); if ( ! library || ! browser ) { return; } library.gallery = library.gallery || new Backbone.Model(); browser.sidebar.set({ gallery: new wp.media.view.Settings.Gallery({ controller: this, model: library.gallery, priority: 40 }) }); browser.toolbar.set( 'reverse', { text: l10n.reverseOrder, priority: 80, click: function() { library.reset( library.toArray().reverse() ); } }); } }); module.exports = GalleryEdit; /***/ }, /***/ 705 (module) { var State = wp.media.controller.State, Library = wp.media.controller.Library, l10n = wp.media.view.l10n, ImageDetails; /** * wp.media.controller.ImageDetails * * A state for editing the attachment display settings of an image that's been * inserted into the editor. * * @memberOf wp.media.controller * * @class * @augments wp.media.controller.State * @augments Backbone.Model * * @param {object} [attributes] The attributes hash passed to the state. * @param {string} [attributes.id=image-details] Unique identifier. * @param {string} [attributes.title=Image Details] Title for the state. Displays in the frame's title region. * @param {wp.media.model.Attachment} attributes.image The image's model. * @param {string|false} [attributes.content=image-details] Initial mode for the content region. * @param {string|false} [attributes.menu=false] Initial mode for the menu region. * @param {string|false} [attributes.router=false] Initial mode for the router region. * @param {string|false} [attributes.toolbar=image-details] Initial mode for the toolbar region. * @param {boolean} [attributes.editing=false] Unused. * @param {int} [attributes.priority=60] Unused. * * @todo This state inherits some defaults from media.controller.Library.prototype.defaults, * however this may not do anything. */ ImageDetails = State.extend(/** @lends wp.media.controller.ImageDetails.prototype */{ defaults: _.defaults({ id: 'image-details', title: l10n.imageDetailsTitle, content: 'image-details', menu: false, router: false, toolbar: 'image-details', editing: false, priority: 60 }, Library.prototype.defaults ), /** * @since 3.9.0 * * @param options Attributes */ initialize: function( options ) { this.image = options.image; State.prototype.initialize.apply( this, arguments ); }, /** * @since 3.9.0 */ activate: function() { this.frame.modal.$el.addClass('image-details'); } }); module.exports = ImageDetails; /***/ }, /***/ 472 (module) { var l10n = wp.media.view.l10n, getUserSetting = window.getUserSetting, setUserSetting = window.setUserSetting, Library; /** * wp.media.controller.Library * * A state for choosing an attachment or group of attachments from the media library. * * @memberOf wp.media.controller * * @class * @augments wp.media.controller.State * @augments Backbone.Model * @mixes media.selectionSync * * @param {object} [attributes] The attributes hash passed to the state. * @param {string} [attributes.id=library] Unique identifier. * @param {string} [attributes.title=Media library] Title for the state. Displays in the media menu and the frame's title region. * @param {wp.media.model.Attachments} [attributes.library] The attachments collection to browse. * If one is not supplied, a collection of all attachments will be created. * @param {wp.media.model.Selection|object} [attributes.selection] A collection to contain attachment selections within the state. * If the 'selection' attribute is a plain JS object, * a Selection will be created using its values as the selection instance's `props` model. * Otherwise, it will copy the library's `props` model. * @param {boolean} [attributes.multiple=false] Whether multi-select is enabled. * @param {string} [attributes.content=upload] Initial mode for the content region. * Overridden by persistent user setting if 'contentUserSetting' is true. * @param {string} [attributes.menu=default] Initial mode for the menu region. * @param {string} [attributes.router=browse] Initial mode for the router region. * @param {string} [attributes.toolbar=select] Initial mode for the toolbar region. * @param {boolean} [attributes.searchable=true] Whether the library is searchable. * @param {boolean|string} [attributes.filterable=false] Whether the library is filterable, and if so what filters should be shown. * Accepts 'all', 'uploaded', or 'unattached'. * @param {boolean} [attributes.sortable=true] Whether the Attachments should be sortable. Depends on the orderby property being set to menuOrder on the attachments collection. * @param {boolean} [attributes.autoSelect=true] Whether an uploaded attachment should be automatically added to the selection. * @param {boolean} [attributes.describe=false] Whether to offer UI to describe attachments - e.g. captioning images in a gallery. * @param {boolean} [attributes.contentUserSetting=true] Whether the content region's mode should be set and persisted per user. * @param {boolean} [attributes.syncSelection=true] Whether the Attachments selection should be persisted from the last state. */ Library = wp.media.controller.State.extend(/** @lends wp.media.controller.Library.prototype */{ defaults: { id: 'library', title: l10n.mediaLibraryTitle, multiple: false, content: 'upload', menu: 'default', router: 'browse', toolbar: 'select', searchable: true, filterable: false, sortable: true, autoSelect: true, describe: false, contentUserSetting: true, syncSelection: true }, /** * If a library isn't provided, query all media items. * If a selection instance isn't provided, create one. * * @since 3.5.0 */ initialize: function() { var selection = this.get('selection'), props; if ( ! this.get('library') ) { this.set( 'library', wp.media.query() ); } if ( ! ( selection instanceof wp.media.model.Selection ) ) { props = selection; if ( ! props ) { props = this.get('library').props.toJSON(); props = _.omit( props, 'orderby', 'query' ); } this.set( 'selection', new wp.media.model.Selection( null, { multiple: this.get('multiple'), props: props }) ); } this.resetDisplays(); }, /** * @since 3.5.0 */ activate: function() { this.syncSelection(); wp.Uploader.queue.on( 'add', this.uploading, this ); this.get('selection').on( 'add remove reset', this.refreshContent, this ); if ( this.get( 'router' ) && this.get('contentUserSetting') ) { this.frame.on( 'content:activate', this.saveContentMode, this ); this.set( 'content', getUserSetting( 'libraryContent', this.get('content') ) ); } }, /** * @since 3.5.0 */ deactivate: function() { this.recordSelection(); this.frame.off( 'content:activate', this.saveContentMode, this ); // Unbind all event handlers that use this state as the context // from the selection. this.get('selection').off( null, null, this ); wp.Uploader.queue.off( null, null, this ); }, /** * Reset the library to its initial state. * * @since 3.5.0 */ reset: function() { this.get('selection').reset(); this.resetDisplays(); this.refreshContent(); }, /** * Reset the attachment display settings defaults to the site options. * * If site options don't define them, fall back to a persistent user setting. * * @since 3.5.0 */ resetDisplays: function() { var defaultProps = wp.media.view.settings.defaultProps; this._displays = []; this._defaultDisplaySettings = { align: getUserSetting( 'align', defaultProps.align ) || 'none', size: getUserSetting( 'imgsize', defaultProps.size ) || 'medium', link: getUserSetting( 'urlbutton', defaultProps.link ) || 'none' }; }, /** * Create a model to represent display settings (alignment, etc.) for an attachment. * * @since 3.5.0 * * @param {wp.media.model.Attachment} attachment * @return {Backbone.Model} */ display: function( attachment ) { var displays = this._displays; if ( ! displays[ attachment.cid ] ) { displays[ attachment.cid ] = new Backbone.Model( this.defaultDisplaySettings( attachment ) ); } return displays[ attachment.cid ]; }, /** * Given an attachment, create attachment display settings properties. * * @since 3.6.0 * * @param {wp.media.model.Attachment} attachment * @return {Object} */ defaultDisplaySettings: function( attachment ) { var settings = _.clone( this._defaultDisplaySettings ); settings.canEmbed = this.canEmbed( attachment ); if ( settings.canEmbed ) { settings.link = 'embed'; } else if ( ! this.isImageAttachment( attachment ) && settings.link === 'none' ) { settings.link = 'file'; } return settings; }, /** * Whether an attachment is image. * * @since 4.4.1 * * @param {wp.media.model.Attachment} attachment * @return {boolean} */ isImageAttachment: function( attachment ) { // If uploading, we know the filename but not the mime type. if ( attachment.get('uploading') ) { return /\.(jpe?g|png|gif|webp|avif|heic|heif)$/i.test( attachment.get('filename') ); } return attachment.get('type') === 'image'; }, /** * Whether an attachment can be embedded (audio or video). * * @since 3.6.0 * * @param {wp.media.model.Attachment} attachment * @return {boolean} */ canEmbed: function( attachment ) { // If uploading, we know the filename but not the mime type. if ( ! attachment.get('uploading') ) { var type = attachment.get('type'); if ( type !== 'audio' && type !== 'video' ) { return false; } } return _.contains( wp.media.view.settings.embedExts, attachment.get('filename').split('.').pop() ); }, /** * If the state is active, no items are selected, and the current * content mode is not an option in the state's router (provided * the state has a router), reset the content mode to the default. * * @since 3.5.0 */ refreshContent: function() { var selection = this.get('selection'), frame = this.frame, router = frame.router.get(), mode = frame.content.mode(); if ( this.active && ! selection.length && router && ! router.get( mode ) ) { this.frame.content.render( this.get('content') ); } }, /** * Callback handler when an attachment is uploaded. * * Switch to the Media Library if uploaded from the 'Upload Files' tab. * * Adds any uploading attachments to the selection. * * If the state only supports one attachment to be selected and multiple * attachments are uploaded, the last attachment in the upload queue will * be selected. * * @since 3.5.0 * * @param {wp.media.model.Attachment} attachment */ uploading: function( attachment ) { var content = this.frame.content; if ( 'upload' === content.mode() ) { this.frame.content.mode('browse'); } if ( this.get( 'autoSelect' ) ) { this.get('selection').add( attachment ); this.frame.trigger( 'library:selection:add' ); } }, /** * Persist the mode of the content region as a user setting. * * @since 3.5.0 */ saveContentMode: function() { if ( 'browse' !== this.get('router') ) { return; } var mode = this.frame.content.mode(), view = this.frame.router.get(); if ( view && view.get( mode ) ) { setUserSetting( 'libraryContent', mode ); } } }); // Make selectionSync available on any Media Library state. _.extend( Library.prototype, wp.media.selectionSync ); module.exports = Library; /***/ }, /***/ 8065 (module) { /** * wp.media.controller.MediaLibrary * * @memberOf wp.media.controller * * @class * @augments wp.media.controller.Library * @augments wp.media.controller.State * @augments Backbone.Model */ var Library = wp.media.controller.Library, MediaLibrary; MediaLibrary = Library.extend(/** @lends wp.media.controller.MediaLibrary.prototype */{ defaults: _.defaults({ // Attachments browser defaults. @see media.view.AttachmentsBrowser filterable: 'uploaded', displaySettings: false, priority: 80, syncSelection: false }, Library.prototype.defaults ), /** * @since 3.9.0 * * @param options */ initialize: function( options ) { this.media = options.media; this.type = options.type; this.set( 'library', wp.media.query({ type: this.type }) ); Library.prototype.initialize.apply( this, arguments ); }, /** * @since 3.9.0 */ activate: function() { // @todo this should use this.frame. if ( wp.media.frame.lastMime ) { this.set( 'library', wp.media.query({ type: wp.media.frame.lastMime }) ); delete wp.media.frame.lastMime; } Library.prototype.activate.apply( this, arguments ); } }); module.exports = MediaLibrary; /***/ }, /***/ 9875 (module) { /** * wp.media.controller.Region * * A region is a persistent application layout area. * * A region assumes one mode at any time, and can be switched to another. * * When mode changes, events are triggered on the region's parent view. * The parent view will listen to specific events and fill the region with an * appropriate view depending on mode. For example, a frame listens for the * 'browse' mode t be activated on the 'content' view and then fills the region * with an AttachmentsBrowser view. * * @memberOf wp.media.controller * * @class * * @param {Object} options Options hash for the region. * @param {string} options.id Unique identifier for the region. * @param {Backbone.View} options.view A parent view the region exists within. * @param {string} options.selector jQuery selector for the region within the parent view. */ var Region = function( options ) { _.extend( this, _.pick( options || {}, 'id', 'view', 'selector' ) ); }; // Use Backbone's self-propagating `extend` inheritance method. Region.extend = Backbone.Model.extend; _.extend( Region.prototype,/** @lends wp.media.controller.Region.prototype */{ /** * Activate a mode. * * @since 3.5.0 * * @param {string} mode * * @fires Region#activate * @fires Region#deactivate * * @return {wp.media.controller.Region} Returns itself to allow chaining. */ mode: function( mode ) { if ( ! mode ) { return this._mode; } // Bail if we're trying to change to the current mode. if ( mode === this._mode ) { return this; } /** * Region mode deactivation event. * * @event wp.media.controller.Region#deactivate */ this.trigger('deactivate'); this._mode = mode; this.render( mode ); /** * Region mode activation event. * * @event wp.media.controller.Region#activate */ this.trigger('activate'); return this; }, /** * Render a mode. * * @since 3.5.0 * * @param {string} mode * * @fires Region#create * @fires Region#render * * @return {wp.media.controller.Region} Returns itself to allow chaining. */ render: function( mode ) { // If the mode isn't active, activate it. if ( mode && mode !== this._mode ) { return this.mode( mode ); } var set = { view: null }, view; /** * Create region view event. * * Region view creation takes place in an event callback on the frame. * * @event wp.media.controller.Region#create * @type {object} * @property {object} view */ this.trigger( 'create', set ); view = set.view; /** * Render region view event. * * Region view creation takes place in an event callback on the frame. * * @event wp.media.controller.Region#render * @type {object} */ this.trigger( 'render', view ); if ( view ) { this.set( view ); } return this; }, /** * Get the region's view. * * @since 3.5.0 * * @return {wp.media.View} */ get: function() { return this.view.views.first( this.selector ); }, /** * Set the region's view as a subview of the frame. * * @since 3.5.0 * * @param {Array|Object} views * @param {Object} [options={}] * @return {wp.Backbone.Subviews} Subviews is returned to allow chaining. */ set: function( views, options ) { if ( options ) { options.add = false; } return this.view.views.set( this.selector, views, options ); }, /** * Trigger regional view events on the frame. * * @since 3.5.0 * * @param {string} event * @return {undefined|wp.media.controller.Region} Returns itself to allow chaining. */ trigger: function( event ) { var base, args; if ( ! this._mode ) { return; } args = _.toArray( arguments ); base = this.id + ':' + event; // Trigger `{this.id}:{event}:{this._mode}` event on the frame. args[0] = base + ':' + this._mode; this.view.trigger.apply( this.view, args ); // Trigger `{this.id}:{event}` event on the frame. args[0] = base; this.view.trigger.apply( this.view, args ); return this; } }); module.exports = Region; /***/ }, /***/ 2275 (module) { var Library = wp.media.controller.Library, l10n = wp.media.view.l10n, ReplaceImage; /** * wp.media.controller.ReplaceImage * * A state for replacing an image. * * @memberOf wp.media.controller * * @class * @augments wp.media.controller.Library * @augments wp.media.controller.State * @augments Backbone.Model * * @param {object} [attributes] The attributes hash passed to the state. * @param {string} [attributes.id=replace-image] Unique identifier. * @param {string} [attributes.title=Replace Image] Title for the state. Displays in the media menu and the frame's title region. * @param {wp.media.model.Attachments} [attributes.library] The attachments collection to browse. * If one is not supplied, a collection of all images will be created. * @param {boolean} [attributes.multiple=false] Whether multi-select is enabled. * @param {string} [attributes.content=upload] Initial mode for the content region. * Overridden by persistent user setting if 'contentUserSetting' is true. * @param {string} [attributes.menu=default] Initial mode for the menu region. * @param {string} [attributes.router=browse] Initial mode for the router region. * @param {string} [attributes.toolbar=replace] Initial mode for the toolbar region. * @param {int} [attributes.priority=60] The priority for the state link in the media menu. * @param {boolean} [attributes.searchable=true] Whether the library is searchable. * @param {boolean|string} [attributes.filterable=uploaded] Whether the library is filterable, and if so what filters should be shown. * Accepts 'all', 'uploaded', or 'unattached'. * @param {boolean} [attributes.sortable=true] Whether the Attachments should be sortable. Depends on the orderby property being set to menuOrder on the attachments collection. * @param {boolean} [attributes.autoSelect=true] Whether an uploaded attachment should be automatically added to the selection. * @param {boolean} [attributes.describe=false] Whether to offer UI to describe attachments - e.g. captioning images in a gallery. * @param {boolean} [attributes.contentUserSetting=true] Whether the content region's mode should be set and persisted per user. * @param {boolean} [attributes.syncSelection=true] Whether the Attachments selection should be persisted from the last state. */ ReplaceImage = Library.extend(/** @lends wp.media.controller.ReplaceImage.prototype */{ defaults: _.defaults({ id: 'replace-image', title: l10n.replaceImageTitle, multiple: false, filterable: 'uploaded', toolbar: 'replace', menu: false, priority: 60, syncSelection: true }, Library.prototype.defaults ), /** * @since 3.9.0 * * @param options */ initialize: function( options ) { var library, comparator; this.image = options.image; // If we haven't been provided a `library`, create a `Selection`. if ( ! this.get('library') ) { this.set( 'library', wp.media.query({ type: 'image' }) ); } Library.prototype.initialize.apply( this, arguments ); library = this.get('library'); comparator = library.comparator; // Overload the library's comparator to push items that are not in // the mirrored query to the front of the aggregate collection. library.comparator = function( a, b ) { var aInQuery = !! this.mirroring.get( a.cid ), bInQuery = !! this.mirroring.get( b.cid ); if ( ! aInQuery && bInQuery ) { return -1; } else if ( aInQuery && ! bInQuery ) { return 1; } else { return comparator.apply( this, arguments ); } }; // Add all items in the selection to the library, so any featured // images that are not initially loaded still appear. library.observe( this.get('selection') ); }, /** * @since 3.9.0 */ activate: function() { this.frame.on( 'content:render:browse', this.updateSelection, this ); Library.prototype.activate.apply( this, arguments ); }, /** * @since 5.9.0 */ deactivate: function() { this.frame.off( 'content:render:browse', this.updateSelection, this ); Library.prototype.deactivate.apply( this, arguments ); }, /** * @since 3.9.0 */ updateSelection: function() { var selection = this.get('selection'), attachment = this.image.attachment; selection.reset( attachment ? [ attachment ] : [] ); } }); module.exports = ReplaceImage; /***/ }, /***/ 6172 (module) { var Controller = wp.media.controller, SiteIconCropper; /** * wp.media.controller.SiteIconCropper * * A state for cropping a Site Icon. * * @memberOf wp.media.controller * * @class * @augments wp.media.controller.Cropper * @augments wp.media.controller.State * @augments Backbone.Model */ SiteIconCropper = Controller.Cropper.extend(/** @lends wp.media.controller.SiteIconCropper.prototype */{ activate: function() { this.frame.on( 'content:create:crop', this.createCropContent, this ); this.frame.on( 'close', this.removeCropper, this ); this.set('selection', new Backbone.Collection(this.frame._selection.single)); }, createCropContent: function() { this.cropperView = new wp.media.view.SiteIconCropper({ controller: this, attachment: this.get('selection').first() }); this.cropperView.on('image-loaded', this.createCropToolbar, this); this.frame.content.set(this.cropperView); }, doCrop: function( attachment ) { var cropDetails = attachment.get( 'cropDetails' ), control = this.get( 'control' ); cropDetails.dst_width = control.params.width; cropDetails.dst_height = control.params.height; return wp.ajax.post( 'crop-image', { nonce: attachment.get( 'nonces' ).edit, id: attachment.get( 'id' ), context: 'site-icon', cropDetails: cropDetails } ); } }); module.exports = SiteIconCropper; /***/ }, /***/ 6150 (module) { /** * wp.media.controller.StateMachine * * A state machine keeps track of state. It is in one state at a time, * and can change from one state to another. * * States are stored as models in a Backbone collection. * * @memberOf wp.media.controller * * @since 3.5.0 * * @class * @augments Backbone.Model * @mixin * @mixes Backbone.Events */ var StateMachine = function() { return { // Use Backbone's self-propagating `extend` inheritance method. extend: Backbone.Model.extend }; }; _.extend( StateMachine.prototype, Backbone.Events,/** @lends wp.media.controller.StateMachine.prototype */{ /** * Fetch a state. * * If no `id` is provided, returns the active state. * * Implicitly creates states. * * Ensure that the `states` collection exists so the `StateMachine` * can be used as a mixin. * * @since 3.5.0 * * @param {string} id * @return {wp.media.controller.State} Returns a State model from * the StateMachine collection. */ state: function( id ) { this.states = this.states || new Backbone.Collection(); // Default to the active state. id = id || this._state; if ( id && ! this.states.get( id ) ) { this.states.add({ id: id }); } return this.states.get( id ); }, /** * Sets the active state. * * Bail if we're trying to select the current state, if we haven't * created the `states` collection, or are trying to select a state * that does not exist. * * @since 3.5.0 * * @param {string} id * * @fires wp.media.controller.State#deactivate * @fires wp.media.controller.State#activate * * @return {wp.media.controller.StateMachine} Returns itself to allow chaining. */ setState: function( id ) { var previous = this.state(); if ( ( previous && id === previous.id ) || ! this.states || ! this.states.get( id ) ) { return this; } if ( previous ) { previous.trigger('deactivate'); this._lastState = previous.id; } this._state = id; this.state().trigger('activate'); return this; }, /** * Returns the previous active state. * * Call the `state()` method with no parameters to retrieve the current * active state. * * @since 3.5.0 * * @return {wp.media.controller.State} Returns a State model from * the StateMachine collection. */ lastState: function() { if ( this._lastState ) { return this.state( this._lastState ); } } }); // Map all event binding and triggering on a StateMachine to its `states` collection. _.each([ 'on', 'off', 'trigger' ], function( method ) { /** * @function on * @memberOf wp.media.controller.StateMachine * @instance * @return {wp.media.controller.StateMachine} Returns itself to allow chaining. */ /** * @function off * @memberOf wp.media.controller.StateMachine * @instance * @return {wp.media.controller.StateMachine} Returns itself to allow chaining. */ /** * @function trigger * @memberOf wp.media.controller.StateMachine * @instance * @return {wp.media.controller.StateMachine} Returns itself to allow chaining. */ StateMachine.prototype[ method ] = function() { // Ensure that the `states` collection exists so the `StateMachine` // can be used as a mixin. this.states = this.states || new Backbone.Collection(); // Forward the method to the `states` collection. this.states[ method ].apply( this.states, arguments ); return this; }; }); module.exports = StateMachine; /***/ }, /***/ 5694 (module) { /** * wp.media.controller.State * * A state is a step in a workflow that when set will trigger the controllers * for the regions to be updated as specified in the frame. * * A state has an event-driven lifecycle: * * 'ready' triggers when a state is added to a state machine's collection. * 'activate' triggers when a state is activated by a state machine. * 'deactivate' triggers when a state is deactivated by a state machine. * 'reset' is not triggered automatically. It should be invoked by the * proper controller to reset the state to its default. * * @memberOf wp.media.controller * * @class * @augments Backbone.Model */ var State = Backbone.Model.extend(/** @lends wp.media.controller.State.prototype */{ /** * Constructor. * * @since 3.5.0 */ constructor: function() { this.on( 'activate', this._preActivate, this ); this.on( 'activate', this.activate, this ); this.on( 'activate', this._postActivate, this ); this.on( 'deactivate', this._deactivate, this ); this.on( 'deactivate', this.deactivate, this ); this.on( 'reset', this.reset, this ); this.on( 'ready', this._ready, this ); this.on( 'ready', this.ready, this ); /** * Call parent constructor with passed arguments */ Backbone.Model.apply( this, arguments ); this.on( 'change:menu', this._updateMenu, this ); }, /** * Ready event callback. * * @abstract * @since 3.5.0 */ ready: function() {}, /** * Activate event callback. * * @abstract * @since 3.5.0 */ activate: function() {}, /** * Deactivate event callback. * * @abstract * @since 3.5.0 */ deactivate: function() {}, /** * Reset event callback. * * @abstract * @since 3.5.0 */ reset: function() {}, /** * @since 3.5.0 * @access private */ _ready: function() { this._updateMenu(); }, /** * @since 3.5.0 * @access private */ _preActivate: function() { this.active = true; }, /** * @since 3.5.0 * @access private */ _postActivate: function() { this.on( 'change:menu', this._menu, this ); this.on( 'change:titleMode', this._title, this ); this.on( 'change:content', this._content, this ); this.on( 'change:toolbar', this._toolbar, this ); this.frame.on( 'title:render:default', this._renderTitle, this ); this._title(); this._menu(); this._toolbar(); this._content(); this._router(); }, /** * @since 3.5.0 * @access private */ _deactivate: function() { this.active = false; this.frame.off( 'title:render:default', this._renderTitle, this ); this.off( 'change:menu', this._menu, this ); this.off( 'change:titleMode', this._title, this ); this.off( 'change:content', this._content, this ); this.off( 'change:toolbar', this._toolbar, this ); }, /** * @since 3.5.0 * @access private */ _title: function() { this.frame.title.render( this.get('titleMode') || 'default' ); }, /** * @since 3.5.0 * @access private */ _renderTitle: function( view ) { view.$el.text( this.get('title') || '' ); }, /** * @since 3.5.0 * @access private */ _router: function() { var router = this.frame.router, mode = this.get('router'), view; this.frame.$el.toggleClass( 'hide-router', ! mode ); if ( ! mode ) { return; } this.frame.router.render( mode ); view = router.get(); if ( view && view.select ) { view.select( this.frame.content.mode() ); } }, /** * @since 3.5.0 * @access private */ _menu: function() { var menu = this.frame.menu, mode = this.get('menu'), actionMenuItems, actionMenuLength, view; if ( this.frame.menu ) { actionMenuItems = this.frame.menu.get('views'), actionMenuLength = actionMenuItems ? actionMenuItems.views.get().length : 0, // Show action menu only if it is active and has more than one default element. this.frame.$el.toggleClass( 'hide-menu', ! mode || actionMenuLength < 2 ); } if ( ! mode ) { return; } menu.mode( mode ); view = menu.get(); if ( view && view.select ) { view.select( this.id ); } }, /** * @since 3.5.0 * @access private */ _updateMenu: function() { var previous = this.previous('menu'), menu = this.get('menu'); if ( previous ) { this.frame.off( 'menu:render:' + previous, this._renderMenu, this ); } if ( menu ) { this.frame.on( 'menu:render:' + menu, this._renderMenu, this ); } }, /** * Create a view in the media menu for the state. * * @since 3.5.0 * @access private * * @param {media.view.Menu} view The menu view. */ _renderMenu: function( view ) { var menuItem = this.get('menuItem'), title = this.get('title'), priority = this.get('priority'); if ( ! menuItem && title ) { menuItem = { text: title }; if ( priority ) { menuItem.priority = priority; } } if ( ! menuItem ) { return; } view.set( this.id, menuItem ); } }); _.each(['toolbar','content'], function( region ) { /** * @access private */ State.prototype[ '_' + region ] = function() { var mode = this.get( region ); if ( mode ) { this.frame[ region ].render( mode ); } }; }); module.exports = State; /***/ }, /***/ 4181 (module) { /** * wp.media.selectionSync * * Sync an attachments selection in a state with another state. * * Allows for selecting multiple images in the Add Media workflow, and then * switching to the Insert Gallery workflow while preserving the attachments selection. * * @memberOf wp.media * * @mixin */ var selectionSync = { /** * @since 3.5.0 */ syncSelection: function() { var selection = this.get('selection'), manager = this.frame._selection; if ( ! this.get('syncSelection') || ! manager || ! selection ) { 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 ( selection.multiple ) { selection.reset( [], { silent: true }); selection.validateAll( manager.attachments ); manager.difference = _.difference( manager.attachments.models, selection.models ); } // Sync the selection's single item with the master. selection.single( manager.single ); }, /** * Record the currently active attachments, which is a combination * of the selection's attachments and the set of selected * attachments that this specific selection considered invalid. * Reset the difference and record the single attachment. * * @since 3.5.0 */ recordSelection: function() { var selection = this.get('selection'), manager = this.frame._selection; if ( ! this.get('syncSelection') || ! manager || ! selection ) { return; } if ( selection.multiple ) { manager.attachments.reset( selection.toArray().concat( manager.difference ) ); manager.difference = []; } else { manager.attachments.add( selection.toArray() ); } manager.single = selection._single; } }; module.exports = selectionSync; /***/ }, /***/ 2982 (module) { var View = wp.media.View, AttachmentCompat; /** * wp.media.view.AttachmentCompat * * A view to display fields added via the `attachment_fields_to_edit` filter. * * @memberOf wp.media.view * * @class * @augments wp.media.View * @augments wp.Backbone.View * @augments Backbone.View */ AttachmentCompat = View.extend(/** @lends wp.media.view.AttachmentCompat.prototype */{ tagName: 'form', className: 'compat-item', events: { 'submit': 'preventDefault', 'change input': 'save', 'change select': 'save', 'change textarea': 'save' }, initialize: function() { // Render the view when a new item is added. this.listenTo( this.model, 'add', this.render ); }, /** * @return {wp.media.view.AttachmentCompat} Returns itself to allow chaining. */ dispose: function() { if ( this.$(':focus').length ) { this.save(); } /** * call 'dispose' directly on the parent class */ return View.prototype.dispose.apply( this, arguments ); }, /** * @return {wp.media.view.AttachmentCompat} Returns itself to allow chaining. */ render: function() { var compat = this.model.get('compat'); if ( ! compat || ! compat.item ) { return; } this.views.detach(); this.$el.html( compat.item ); this.views.render(); return this; }, /** * @param {Object} event */ preventDefault: function( event ) { event.preventDefault(); }, /** * @param {Object} event */ save: function( event ) { var data = {}; if ( event ) { event.preventDefault(); } _.each( this.$el.serializeArray(), function( pair ) { data[ pair.name ] = pair.value; }); this.controller.trigger( 'attachment:compat:waiting', ['waiting'] ); this.model.saveCompat( data ).always( _.bind( this.postSave, this ) ); }, postSave: function() { this.controller.trigger( 'attachment:compat:ready', ['ready'] ); } }); module.exports = AttachmentCompat; /***/ }, /***/ 7709 (module) { var $ = jQuery, AttachmentFilters; /** * wp.media.view.AttachmentFilters * * @memberOf wp.media.view * * @class * @augments wp.media.View * @augments wp.Backbone.View * @augments Backbone.View */ AttachmentFilters = wp.media.View.extend(/** @lends wp.media.view.AttachmentFilters.prototype */{ tagName: 'select', className: 'attachment-filters', id: 'media-attachment-filters', events: { change: 'change' }, keys: [], initialize: function() { this.createFilters(); _.extend( this.filters, this.options.filters ); // Build `' ).val( value ).html( filter.text )[0], priority: filter.priority || 50 }; }, this ).sortBy('priority').pluck('el').value() ); this.listenTo( this.model, 'change', this.select ); this.select(); }, /** * @abstract */ createFilters: function() { this.filters = {}; }, /** * When the selected filter changes, update the Attachment Query properties to match. */ change: function() { var filter = this.filters[ this.el.value ]; if ( filter ) { this.model.set( filter.props ); } }, select: function() { var model = this.model, value = 'all', props = model.toJSON(); _.find( this.filters, function( filter, id ) { var equal = _.all( filter.props, function( prop, key ) { return prop === ( _.isUndefined( props[ key ] ) ? null : props[ key ] ); }); if ( equal ) { return value = id; } }); this.$el.val( value ); } }); module.exports = AttachmentFilters; /***/ }, /***/ 7349 (module) { var l10n = wp.media.view.l10n, All; /** * wp.media.view.AttachmentFilters.All * * @memberOf wp.media.view.AttachmentFilters * * @class * @augments wp.media.view.AttachmentFilters * @augments wp.media.View * @augments wp.Backbone.View * @augments Backbone.View */ All = wp.media.view.AttachmentFilters.extend(/** @lends wp.media.view.AttachmentFilters.All.prototype */{ createFilters: function() { var filters = {}, uid = window.userSettings ? parseInt( window.userSettings.uid, 10 ) : 0; _.each( wp.media.view.settings.mimeTypes || {}, function( text, key ) { filters[ key ] = { text: text, props: { status: null, type: key, uploadedTo: null, orderby: 'date', order: 'DESC', author: null } }; }); filters.all = { text: l10n.allMediaItems, props: { status: null, type: null, uploadedTo: null, orderby: 'date', order: 'DESC', author: null }, priority: 10 }; if ( wp.media.view.settings.post.id ) { filters.uploaded = { text: l10n.uploadedToThisPost, props: { status: null, type: null, uploadedTo: wp.media.view.settings.post.id, orderby: 'menuOrder', order: 'ASC', author: null }, priority: 20 }; } filters.unattached = { text: l10n.unattached, props: { status: null, uploadedTo: 0, type: null, orderby: 'menuOrder', order: 'ASC', author: null }, priority: 50 }; if ( uid ) { filters.mine = { text: l10n.mine, props: { status: null, type: null, uploadedTo: null, orderby: 'date', order: 'DESC', author: uid }, priority: 50 }; } if ( wp.media.view.settings.mediaTrash && this.controller.isModeActive( 'grid' ) ) { filters.trash = { text: l10n.trash, props: { uploadedTo: null, status: 'trash', type: null, orderby: 'date', order: 'DESC', author: null }, priority: 50 }; } this.filters = filters; } }); module.exports = All; /***/ }, /***/ 6472 (module) { var l10n = wp.media.view.l10n, DateFilter; /** * A filter dropdown for month/dates. * * @memberOf wp.media.view.AttachmentFilters * * @class * @augments wp.media.view.AttachmentFilters * @augments wp.media.View * @augments wp.Backbone.View * @augments Backbone.View */ DateFilter = wp.media.view.AttachmentFilters.extend(/** @lends wp.media.view.AttachmentFilters.Date.prototype */{ id: 'media-attachment-date-filters', createFilters: function() { var filters = {}; _.each( wp.media.view.settings.months || {}, function( value, index ) { filters[ index ] = { text: value.text, props: { year: value.year, monthnum: value.month } }; }); filters.all = { text: l10n.allDates, props: { monthnum: false, year: false }, priority: 10 }; this.filters = filters; } }); module.exports = DateFilter; /***/ }, /***/ 1368 (module) { var l10n = wp.media.view.l10n, Uploaded; /** * wp.media.view.AttachmentFilters.Uploaded * * @memberOf wp.media.view.AttachmentFilters * * @class * @augments wp.media.view.AttachmentFilters * @augments wp.media.View * @augments wp.Backbone.View * @augments Backbone.View */ Uploaded = wp.media.view.AttachmentFilters.extend(/** @lends wp.media.view.AttachmentFilters.Uploaded.prototype */{ createFilters: function() { var type = this.model.get('type'), types = wp.media.view.settings.mimeTypes, uid = window.userSettings ? parseInt( window.userSettings.uid, 10 ) : 0, text; if ( types && type ) { text = types[ type ]; } this.filters = { all: { text: text || l10n.allMediaItems, props: { uploadedTo: null, orderby: 'date', order: 'DESC', author: null }, priority: 10 }, uploaded: { text: l10n.uploadedToThisPost, props: { uploadedTo: wp.media.view.settings.post.id, orderby: 'menuOrder', order: 'ASC', author: null }, priority: 20 }, unattached: { text: l10n.unattached, props: { uploadedTo: 0, orderby: 'menuOrder', order: 'ASC', author: null }, priority: 50 } }; if ( uid ) { this.filters.mine = { text: l10n.mine, props: { orderby: 'date', order: 'DESC', author: uid }, priority: 50 }; } } }); module.exports = Uploaded; /***/ }, /***/ 4075 (module) { var View = wp.media.View, $ = jQuery, Attachment; /** * wp.media.view.Attachment * * @memberOf wp.media.view * * @class * @augments wp.media.View * @augments wp.Backbone.View * @augments Backbone.View */ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{ tagName: 'li', className: 'attachment', template: wp.template('attachment'), attributes: function() { return { 'tabIndex': 0, 'role': 'checkbox', 'aria-label': this.model.get( 'title' ) || wp.i18n.__( 'uploading…' ), 'aria-checked': false, 'data-id': this.model.get( 'id' ) }; }, events: { 'click': 'toggleSelectionHandler', 'change [data-setting]': 'updateSetting', 'change [data-setting] input': 'updateSetting', 'change [data-setting] select': 'updateSetting', 'change [data-setting] textarea': 'updateSetting', 'click .attachment-close': 'removeFromLibrary', 'click .check': 'checkClickHandler', 'keydown': 'toggleSelectionHandler' }, buttons: {}, initialize: function() { var selection = this.options.selection, options = _.defaults( this.options, { rerenderOnModelChange: true } ); if ( options.rerenderOnModelChange ) { this.listenTo( this.model, 'change', this.render ); } else { this.listenTo( this.model, 'change:percent', this.progress ); } this.listenTo( this.model, 'change:title', this._syncTitle ); this.listenTo( this.model, 'change:caption', this._syncCaption ); this.listenTo( this.model, 'change:artist', this._syncArtist ); this.listenTo( this.model, 'change:album', this._syncAlbum ); // Update the selection. this.listenTo( this.model, 'add', this.select ); this.listenTo( this.model, 'remove', this.deselect ); if ( selection ) { selection.on( 'reset', this.updateSelect, this ); // Update the model's details view. this.listenTo( this.model, 'selection:single selection:unsingle', this.details ); this.details( this.model, this.controller.state().get('selection') ); } this.listenTo( this.controller.states, 'attachment:compat:waiting attachment:compat:ready', this.updateSave ); }, /** * @return {wp.media.view.Attachment} Returns itself to allow chaining. */ dispose: function() { var selection = this.options.selection; // Make sure all settings are saved before removing the view. this.updateAll(); if ( selection ) { selection.off( null, null, this ); } /** * call 'dispose' directly on the parent class */ View.prototype.dispose.apply( this, arguments ); return this; }, /** * @return {wp.media.view.Attachment} Returns itself to allow chaining. */ render: function() { var options = _.defaults( this.model.toJSON(), { orientation: 'landscape', uploading: false, type: '', subtype: '', icon: '', filename: '', caption: '', title: '', dateFormatted: '', width: '', height: '', compat: false, alt: '', description: '' }, this.options ); options.buttons = this.buttons; options.describe = this.controller.state().get('describe'); if ( 'image' === options.type ) { options.size = this.imageSize(); } options.can = {}; if ( options.nonces ) { options.can.remove = !! options.nonces['delete']; options.can.save = !! options.nonces.update; } if ( this.controller.state().get('allowLocalEdits') && ! options.uploading ) { options.allowLocalEdits = true; } if ( options.uploading && ! options.percent ) { options.percent = 0; } this.views.detach(); this.$el.html( this.template( options ) ); this.$el.toggleClass( 'uploading', options.uploading ); if ( options.uploading ) { this.$bar = this.$('.media-progress-bar div'); } else { delete this.$bar; } // Check if the model is selected. this.updateSelect(); // Update the save status. this.updateSave(); this.views.render(); return this; }, progress: function() { if ( this.$bar && this.$bar.length ) { this.$bar.width( this.model.get('percent') + '%' ); } }, /** * @param {Object} event */ toggleSelectionHandler: function( event ) { var method; // Don't do anything inside inputs and on the attachment check and remove buttons. if ( 'INPUT' === event.target.nodeName || 'BUTTON' === event.target.nodeName ) { return; } // 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. if ( 'keydown' === event.type && 13 !== event.keyCode && 32 !== event.keyCode ) { return; } event.preventDefault(); // 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. this.controller.trigger( 'edit:attachment', this.model, event.currentTarget ); return; } if ( this.controller.isModeActive( 'select' ) ) { method = 'toggle'; } } if ( event.shiftKey ) { method = 'between'; } else if ( event.ctrlKey || event.metaKey ) { method = 'toggle'; } // Avoid toggles when the command or control key is pressed with the enter key to prevent deselecting the last selected attachment. if ( ( event.metaKey || event.ctrlKey ) && ( 13 === event.keyCode || 10 === event.keyCode ) ) { return; } this.toggleSelection({ method: method }); this.controller.trigger( 'selection:toggle' ); }, /** * @param {Object} options */ toggleSelection: function( options ) { var collection = this.collection, selection = this.options.selection, model = this.model, method = options && options.method, single, models, singleIndex, modelIndex; if ( ! selection ) { return; } single = selection.single(); method = _.isUndefined( method ) ? selection.multiple : method; // If the `method` is set to `between`, select all models that // exist between the current and the selected model. if ( 'between' === method && single && selection.multiple ) { // If the models are the same, short-circuit. if ( single === model ) { return; } singleIndex = collection.indexOf( single ); modelIndex = collection.indexOf( this.model ); if ( singleIndex < modelIndex ) { models = collection.models.slice( singleIndex, modelIndex + 1 ); } else { models = collection.models.slice( modelIndex, singleIndex + 1 ); } selection.add( models ); selection.single( model ); return; // If the `method` is set to `toggle`, just flip the selection // status, regardless of whether the model is the single model. } else if ( 'toggle' === method ) { selection[ this.selected() ? 'remove' : 'add' ]( model ); selection.single( model ); return; } else if ( 'add' === method ) { selection.add( model ); selection.single( model ); return; } // Fixes bug that loses focus when selecting a featured image. if ( ! method ) { method = 'add'; } if ( method !== 'add' ) { method = 'reset'; } 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. */ 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. */ selection[ method ]( model ); selection.single( model ); } }, updateSelect: function() { this[ this.selected() ? 'select' : 'deselect' ](); }, /** * @return {unresolved|boolean} */ selected: function() { var selection = this.options.selection; if ( selection ) { return !! selection.get( this.model.cid ); } }, /** * @param {Backbone.Model} model * @param {Backbone.Collection} collection */ select: function( model, collection ) { 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. */ if ( ! selection || ( collection && collection !== selection ) ) { return; } // Bail if the model is already selected. if ( this.$el.hasClass( 'selected' ) ) { return; } // Add 'selected' class to model, set aria-checked to true. this.$el.addClass( 'selected' ).attr( 'aria-checked', true ); // Make the checkbox tabable, except in media grid (bulk select mode). if ( ! ( controller.isModeActive( 'grid' ) && controller.isModeActive( 'select' ) ) ) { this.$( '.check' ).attr( 'tabindex', '0' ); } }, /** * @param {Backbone.Model} model * @param {Backbone.Collection} collection */ 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. */ if ( ! selection || ( collection && collection !== selection ) ) { return; } this.$el.removeClass( 'selected' ).attr( 'aria-checked', false ) .find( '.check' ).attr( 'tabindex', '-1' ); }, /** * @param {Backbone.Model} model * @param {Backbone.Collection} collection */ details: function( model, collection ) { var selection = this.options.selection, details; if ( selection !== collection ) { return; } details = selection.single(); this.$el.toggleClass( 'details', details === this.model ); }, /** * @param {string} size * @return {Object} */ imageSize: function( size ) { var sizes = this.model.get('sizes'), matched = false; size = size || 'medium'; // Use the provided image size if possible. if ( sizes ) { if ( sizes[ size ] ) { matched = sizes[ size ]; } else if ( sizes.large ) { matched = sizes.large; } else if ( sizes.thumbnail ) { matched = sizes.thumbnail; } else if ( sizes.full ) { matched = sizes.full; } if ( matched ) { return _.clone( matched ); } } return { url: this.model.get('url'), width: this.model.get('width'), height: this.model.get('height'), orientation: this.model.get('orientation') }; }, /** * @param {Object} event */ updateSetting: function( event ) { var $setting = $( event.target ).closest('[data-setting]'), setting, value; if ( ! $setting.length ) { return; } setting = $setting.data('setting'); value = event.target.value; if ( this.model.get( setting ) !== value ) { this.save( setting, value ); } }, /** * Pass all the arguments to the model's save method. * * Records the aggregate status of all save requests and updates the * view's classes accordingly. */ save: function() { var view = this, save = this._save = this._save || { status: 'ready' }, request = this.model.save.apply( this.model, arguments ), requests = save.requests ? $.when( request, save.requests ) : request; // If we're waiting to remove 'Saved.', stop. if ( save.savedTimer ) { clearTimeout( save.savedTimer ); } this.updateSave('waiting'); save.requests = requests; requests.always( function() { // If we've performed another request since this one, bail. if ( save.requests !== requests ) { return; } view.updateSave( requests.state() === 'resolved' ? 'complete' : 'error' ); save.savedTimer = setTimeout( function() { view.updateSave('ready'); delete save.savedTimer; }, 2000 ); }); }, /** * @param {string} status * @return {wp.media.view.Attachment} Returns itself to allow chaining. */ updateSave: function( status ) { var save = this._save = this._save || { status: 'ready' }; if ( status && status !== save.status ) { this.$el.removeClass( 'save-' + save.status ); save.status = status; } this.$el.addClass( 'save-' + save.status ); return this; }, updateAll: function() { var $settings = this.$('[data-setting]'), model = this.model, changed; changed = _.chain( $settings ).map( function( el ) { var $input = $('input, textarea, select, [value]', el ), setting, value; if ( ! $input.length ) { return; } setting = $(el).data('setting'); value = $input.val(); // Record the value if it changed. if ( model.get( setting ) !== value ) { return [ setting, value ]; } }).compact().object().value(); if ( ! _.isEmpty( changed ) ) { model.save( changed ); } }, /** * @param {Object} event */ removeFromLibrary: function( event ) { // Catch enter and space events. if ( 'keydown' === event.type && 13 !== event.keyCode && 32 !== event.keyCode ) { return; } // Stop propagation so the model isn't selected. event.stopPropagation(); this.collection.remove( this.model ); }, /** * Add the model if it isn't in the selection, if it is in the selection, * remove it. * * @param {[type]} event [description] * @return {[type]} [description] */ checkClickHandler: function ( event ) { var selection = this.options.selection; if ( ! selection ) { return; } event.stopPropagation(); if ( selection.where( { id: this.model.get( 'id' ) } ).length ) { selection.remove( this.model ); // Move focus back to the attachment tile (from the check). this.$el.focus(); } else { selection.add( this.model ); } // Trigger an action button update. this.controller.trigger( 'selection:toggle' ); } }); // Ensure settings remain in sync between attachment views. _.each({ caption: '_syncCaption', title: '_syncTitle', artist: '_syncArtist', album: '_syncAlbum' }, function( method, setting ) { /** * @function _syncCaption * @memberOf wp.media.view.Attachment * @instance * * @param {Backbone.Model} model * @param {string} value * @return {wp.media.view.Attachment} Returns itself to allow chaining. */ /** * @function _syncTitle * @memberOf wp.media.view.Attachment * @instance * * @param {Backbone.Model} model * @param {string} value * @return {wp.media.view.Attachment} Returns itself to allow chaining. */ /** * @function _syncArtist * @memberOf wp.media.view.Attachment * @instance * * @param {Backbone.Model} model * @param {string} value * @return {wp.media.view.Attachment} Returns itself to allow chaining. */ /** * @function _syncAlbum * @memberOf wp.media.view.Attachment * @instance * * @param {Backbone.Model} model * @param {string} value * @return {wp.media.view.Attachment} Returns itself to allow chaining. */ Attachment.prototype[ method ] = function( model, value ) { var $setting = this.$('[data-setting="' + setting + '"]'); if ( ! $setting.length ) { 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 ( value === $setting.find('input, textarea, select, [value]').val() ) { return this; } return this.render(); }; }); module.exports = Attachment; /***/ }, /***/ 6090 (module) { /* global ClipboardJS */ var Attachment = wp.media.view.Attachment, l10n = wp.media.view.l10n, $ = jQuery, Details, __ = wp.i18n.__; Details = Attachment.extend(/** @lends wp.media.view.Attachment.Details.prototype */{ tagName: 'div', className: 'attachment-details', template: wp.template('attachment-details'), /* * Reset all the attributes inherited from Attachment including role=checkbox, * tabindex, etc., as they are inappropriate for this view. See #47458 and [30483] / #30390. */ attributes: {}, events: { 'change [data-setting]': 'updateSetting', 'change [data-setting] input': 'updateSetting', 'change [data-setting] select': 'updateSetting', 'change [data-setting] textarea': 'updateSetting', 'click .delete-attachment': 'deleteAttachment', 'click .trash-attachment': 'trashAttachment', 'click .untrash-attachment': 'untrashAttachment', 'click .edit-attachment': 'editAttachment', 'keydown': 'toggleSelectionHandler' }, /** * Copies the attachment URL to the clipboard. * * @since 5.5.0 * * @param {MouseEvent} event A click event. * * @return {void} */ copyAttachmentDetailsURLClipboard: function() { var clipboard = new ClipboardJS( '.copy-attachment-url' ), successTimeout; clipboard.on( 'success', function( event ) { var triggerElement = $( event.trigger ), successElement = $( '.success', triggerElement.closest( '.copy-to-clipboard-container' ) ); // Clear the selection and move focus back to the trigger. event.clearSelection(); // Show success visual feedback. clearTimeout( successTimeout ); successElement.removeClass( 'hidden' ); // Hide success visual feedback after 3 seconds since last success. successTimeout = setTimeout( function() { successElement.addClass( 'hidden' ); }, 3000 ); // Handle success audible feedback. wp.a11y.speak( __( 'The file URL has been copied to your clipboard' ) ); } ); }, /** * Shows the details of an attachment. * * @since 3.5.0 * * @constructs wp.media.view.Attachment.Details * @augments wp.media.view.Attachment * * @return {void} */ initialize: function() { this.options = _.defaults( this.options, { rerenderOnModelChange: false }); // Call 'initialize' directly on the parent class. Attachment.prototype.initialize.apply( this, arguments ); this.copyAttachmentDetailsURLClipboard(); }, /** * Gets the focusable elements to move focus to. * * @since 5.3.0 */ getFocusableElements: function() { var editedAttachment = $( 'li[data-id="' + this.model.id + '"]' ); this.previousAttachment = editedAttachment.prev(); this.nextAttachment = editedAttachment.next(); }, /** * Moves focus to the previous or next attachment in the grid. * Fallbacks to the upload button or media frame when there are no attachments. * * @since 5.3.0 */ moveFocus: function() { if ( this.previousAttachment.length ) { this.previousAttachment.trigger( 'focus' ); return; } if ( this.nextAttachment.length ) { this.nextAttachment.trigger( 'focus' ); return; } // Fallback: move focus to the "Select Files" button in the media modal. if ( this.controller.uploader && this.controller.uploader.$browser ) { this.controller.uploader.$browser.trigger( 'focus' ); return; } // Last fallback. this.moveFocusToLastFallback(); }, /** * Moves focus to the media frame as last fallback. * * @since 5.3.0 */ moveFocusToLastFallback: function() { // Last fallback: make the frame focusable and move focus to it. $( '.media-frame' ) .attr( 'tabindex', '-1' ) .trigger( 'focus' ); }, /** * Deletes an attachment. * * Deletes an attachment after asking for confirmation. After deletion, * keeps focus in the modal. * * @since 3.5.0 * * @param {MouseEvent} event A click event. * * @return {void} */ deleteAttachment: function( event ) { event.preventDefault(); this.getFocusableElements(); if ( window.confirm( l10n.warnDelete ) ) { this.model.destroy( { wait: true, error: function() { window.alert( l10n.errorDeleting ); } } ); this.moveFocus(); } }, /** * Sets the Trash state on an attachment, or destroys the model itself. * * If the mediaTrash setting is set to true, trashes the attachment. * Otherwise, the model itself is destroyed. * * @since 3.9.0 * * @param {MouseEvent} event A click event. * * @return {void} */ trashAttachment: function( event ) { var library = this.controller.library, self = this; event.preventDefault(); this.getFocusableElements(); // When in the Media Library and the Media Trash is enabled. if ( wp.media.view.settings.mediaTrash && 'edit-metadata' === this.controller.content.mode() ) { this.model.set( 'status', 'trash' ); 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. */ self.moveFocusToLastFallback(); } ); } else { this.model.destroy(); this.moveFocus(); } }, /** * Untrashes an attachment. * * @since 4.0.0 * * @param {MouseEvent} event A click event. * * @return {void} */ untrashAttachment: function( event ) { var library = this.controller.library; event.preventDefault(); this.model.set( 'status', 'inherit' ); this.model.save().done( function() { library._requery( true ); } ); }, /** * Opens the edit page for a specific attachment. * * @since 3.5.0 * * @param {MouseEvent} event A click event. * * @return {void} */ editAttachment: function( event ) { var editState = this.controller.states.get( 'edit-image' ); if ( window.imageEdit && editState ) { event.preventDefault(); editState.set( 'image', this.model ); this.controller.setState( 'edit-image' ); } else { this.$el.addClass('needs-refresh'); } }, /** * Triggers an event on the controller when reverse tabbing (shift+tab). * * This event can be used to make sure to move the focus correctly. * * @since 4.0.0 * * @fires wp.media.controller.MediaLibrary#attachment:details:shift-tab * @fires wp.media.controller.MediaLibrary#attachment:keydown:arrow * * @param {KeyboardEvent} event A keyboard event. * * @return {boolean|void} Returns false or undefined. */ toggleSelectionHandler: function( event ) { if ( 'keydown' === event.type && 9 === event.keyCode && event.shiftKey && event.target === this.$( ':tabbable' ).get( 0 ) ) { this.controller.trigger( 'attachment:details:shift-tab', event ); return false; } }, render: function() { Attachment.prototype.render.apply( this, arguments ); wp.media.mixin.removeAllPlayers(); this.$( 'audio, video' ).each( function (i, elem) { var el = wp.media.view.MediaDetails.prepareSrc( elem ); new window.MediaElementPlayer( el, wp.media.mixin.mejsSettings ); } ); } }); module.exports = Details; /***/ }, /***/ 5232 (module) { /** * wp.media.view.Attachment.EditLibrary * * @memberOf wp.media.view.Attachment * * @class * @augments wp.media.view.Attachment * @augments wp.media.View * @augments wp.Backbone.View * @augments Backbone.View */ var EditLibrary = wp.media.view.Attachment.extend(/** @lends wp.media.view.Attachment.EditLibrary.prototype */{ buttons: { close: true } }); module.exports = EditLibrary; /***/ }, /***/ 4593 (module) { /** * wp.media.view.Attachment.EditSelection * * @memberOf wp.media.view.Attachment * * @class * @augments wp.media.view.Attachment.Selection * @augments wp.media.view.Attachment * @augments wp.media.View * @augments wp.Backbone.View * @augments Backbone.View */ var EditSelection = wp.media.view.Attachment.Selection.extend(/** @lends wp.media.view.Attachment.EditSelection.prototype */{ buttons: { close: true } }); module.exports = EditSelection; /***/ }, /***/ 3443 (module) { /** * wp.media.view.Attachment.Library * * @memberOf wp.media.view.Attachment * * @class * @augments wp.media.view.Attachment * @augments wp.media.View * @augments wp.Backbone.View * @augments Backbone.View */ var Library = wp.media.view.Attachment.extend(/** @lends wp.media.view.Attachment.Library.prototype */{ buttons: { check: true } }); module.exports = Library; /***/ }, /***/ 3962 (module) { /** * wp.media.view.Attachment.Selection * * @memberOf wp.media.view.Attachment * * @class * @augments wp.media.view.Attachment * @augments wp.media.View * @augments wp.Backbone.View * @augments Backbone.View */ var Selection = wp.media.view.Attachment.extend(/** @lends wp.media.view.Attachment.Selection.prototype */{ className: 'attachment selection', // On click, just select the model, instead of removing the model from // the selection. toggleSelection: function() { this.options.selection.single( this.model ); } }); module.exports = Selection; /***/ }, /***/ 8142 (module) { var View = wp.media.View, $ = jQuery, Attachments, infiniteScrolling = wp.media.view.settings.infiniteScrolling; Attachments = View.extend(/** @lends wp.media.view.Attachments.prototype */{ tagName: 'ul', className: 'attachments', attributes: { tabIndex: -1 }, /** * Represents the overview of attachments in the Media Library. * * The constructor binds events to the collection this view represents when * adding or removing attachments or resetting the entire collection. * * @since 3.5.0 * * @constructs * @memberof wp.media.view * * @augments wp.media.View * * @listens collection:add * @listens collection:remove * @listens collection:reset * @listens controller:library:selection:add * @listens scrollElement:scroll * @listens this:ready * @listens controller:open */ initialize: function() { this.el.id = _.uniqueId('__attachments-view-'); /** * @since 5.8.0 Added the `infiniteScrolling` parameter. * * @param infiniteScrolling Whether to enable infinite scrolling or use * the default "load more" button. * @param refreshSensitivity The time in milliseconds to throttle the scroll * handler. * @param refreshThreshold The amount of pixels that should be scrolled before * loading more attachments from the server. * @param AttachmentView The view class to be used for models in the * collection. * @param sortable A jQuery sortable options object * ( http://api.jqueryui.com/sortable/ ). * @param resize A boolean indicating whether or not to listen to * resize events. * @param idealColumnWidth The width in pixels which a column should have when * calculating the total number of columns. */ _.defaults( this.options, { infiniteScrolling: infiniteScrolling || false, refreshSensitivity: wp.media.isTouchDevice ? 300 : 200, refreshThreshold: 3, AttachmentView: wp.media.view.Attachment, sortable: false, resize: true, idealColumnWidth: $( window ).width() < 640 ? 135 : 150 }); this._viewsByCid = {}; this.$window = $( window ); this.resizeEvent = 'resize.media-modal-columns'; this.collection.on( 'add', function( attachment ) { this.views.add( this.createAttachmentView( attachment ), { at: this.collection.indexOf( attachment ) }); }, this ); /* * Find the view to be removed, delete it and call the remove function to clear * any set event handlers. */ this.collection.on( 'remove', function( attachment ) { var view = this._viewsByCid[ attachment.cid ]; delete this._viewsByCid[ attachment.cid ]; if ( view ) { view.remove(); } }, this ); this.collection.on( 'reset', this.render, this ); this.controller.on( 'library:selection:add', this.attachmentFocus, this ); if ( this.options.infiniteScrolling ) { // Throttle the scroll handler and bind this. this.scroll = _.chain( this.scroll ).bind( this ).throttle( this.options.refreshSensitivity ).value(); this.options.scrollElement = this.options.scrollElement || this.el; $( this.options.scrollElement ).on( 'scroll', this.scroll ); } this.initSortable(); _.bindAll( this, 'setColumns' ); if ( this.options.resize ) { this.on( 'ready', this.bindEvents ); this.controller.on( 'open', this.setColumns ); /* * Call this.setColumns() after this view has been rendered in the * DOM so attachments get proper width applied. */ _.defer( this.setColumns, this ); } }, /** * Listens to the resizeEvent on the window. * * Adjusts the amount of columns accordingly. First removes any existing event * handlers to prevent duplicate listeners. * * @since 4.0.0 * * @listens window:resize * * @return {void} */ bindEvents: function() { this.$window.off( this.resizeEvent ).on( this.resizeEvent, _.debounce( this.setColumns, 50 ) ); }, /** * Focuses the first item in the collection. * * @since 4.0.0 * * @return {void} */ attachmentFocus: function() { /* * @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 * uploading attachments, it is called twice and returns two different `this`. * `this.columns` is truthy within the modal. */ if ( this.columns ) { // Move focus to the grid list within the modal. this.$el.focus(); } }, /** * Restores focus to the selected item in the collection. * * Moves focus back to the first selected attachment in the grid. Used when * tabbing backwards from the attachment details sidebar. * See media.view.AttachmentsBrowser. * * @since 4.0.0 * * @return {void} */ restoreFocus: function() { this.$( 'li.selected:first' ).focus(); }, /** * Handles events for arrow key presses. * * Focuses the attachment in the direction of the used arrow key if it exists. * * @since 4.0.0 * * @param {KeyboardEvent} event The keyboard event that triggered this function. * * @return {void} */ arrowEvent: function( event ) { var attachments = this.$el.children( 'li' ), perRow = this.columns, index = attachments.filter( ':focus' ).index(), row = ( index + 1 ) <= perRow ? 1 : Math.ceil( ( index + 1 ) / perRow ); if ( index === -1 ) { return; } // Left arrow = 37. if ( 37 === event.keyCode ) { if ( 0 === index ) { return; } attachments.eq( index - 1 ).focus(); } // Up arrow = 38. if ( 38 === event.keyCode ) { if ( 1 === row ) { return; } attachments.eq( index - perRow ).focus(); } // Right arrow = 39. if ( 39 === event.keyCode ) { if ( attachments.length === index ) { return; } attachments.eq( index + 1 ).focus(); } // Down arrow = 40. if ( 40 === event.keyCode ) { if ( Math.ceil( attachments.length / perRow ) === row ) { return; } attachments.eq( index + perRow ).focus(); } }, /** * Clears any set event handlers. * * @since 3.5.0 * * @return {void} */ dispose: function() { this.collection.props.off( null, null, this ); if ( this.options.resize ) { this.$window.off( this.resizeEvent ); } // Call 'dispose' directly on the parent class. View.prototype.dispose.apply( this, arguments ); }, /** * Calculates the amount of columns. * * Calculates the amount of columns and sets it on the data-columns attribute * of .media-frame-content. * * @since 4.0.0 * * @return {void} */ setColumns: function() { var prev = this.columns, width = this.$el.width(); if ( width ) { this.columns = Math.min( Math.round( width / this.options.idealColumnWidth ), 12 ) || 1; if ( ! prev || prev !== this.columns ) { this.$el.closest( '.media-frame-content' ).attr( 'data-columns', this.columns ); } } }, /** * Initializes jQuery sortable on the attachment list. * * Fails gracefully if jQuery sortable doesn't exist or isn't passed * in the options. * * @since 3.5.0 * * @fires collection:reset * * @return {void} */ initSortable: function() { var collection = this.collection; if ( ! this.options.sortable || ! $.fn.sortable ) { return; } this.$el.sortable( _.extend({ // If the `collection` has a `comparator`, disable sorting. disabled: !! collection.comparator, /* * Change the position of the attachment as soon as the mouse pointer * overlaps a thumbnail. */ tolerance: 'pointer', // Record the initial `index` of the dragged model. start: function( event, ui ) { ui.item.data('sortableIndexStart', ui.item.index()); }, /* * Update the model's index in the collection. Do so silently, as the view * is already accurate. */ update: function( event, ui ) { var model = collection.at( ui.item.data('sortableIndexStart') ), comparator = collection.comparator; // Temporarily disable the comparator to prevent `add` // from re-sorting. delete collection.comparator; // Silently shift the model to its new index. collection.remove( model, { silent: true }); collection.add( model, { silent: true, at: ui.item.index() }); // Restore the comparator. collection.comparator = comparator; // Fire the `reset` event to ensure other collections sync. collection.trigger( 'reset', collection ); // If the collection is sorted by menu order, update the menu order. collection.saveMenuOrder(); } }, this.options.sortable ) ); /* * 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 ); }, this ); this.collection.props.on( 'change:orderby', this.refreshSortable, this ); this.refreshSortable(); }, /** * Disables jQuery sortable if collection has a comparator or collection.orderby * equals menuOrder. * * @since 3.5.0 * * @return {void} */ refreshSortable: function() { if ( ! this.options.sortable || ! $.fn.sortable ) { return; } var collection = this.collection, orderby = collection.props.get('orderby'), enabled = 'menuOrder' === orderby || ! collection.comparator; this.$el.sortable( 'option', 'disabled', ! enabled ); }, /** * Creates a new view for an attachment and adds it to _viewsByCid. * * @since 3.5.0 * * @param {wp.media.model.Attachment} attachment * * @return {wp.media.View} The created view. */ createAttachmentView: function( attachment ) { var view = new this.options.AttachmentView({ controller: this.controller, model: attachment, collection: this.collection, selection: this.options.selection }); return this._viewsByCid[ attachment.cid ] = view; }, /** * Prepares view for display. * * Creates views for every attachment in collection if the collection is not * empty, otherwise clears all views and loads more attachments. * * @since 3.5.0 * * @return {void} */ prepare: function() { if ( this.collection.length ) { this.views.set( this.collection.map( this.createAttachmentView, this ) ); } else { this.views.unset(); if ( this.options.infiniteScrolling ) { this.collection.more().done( this.scroll ); } } }, /** * Triggers the scroll function to check if we should query for additional * attachments right away. * * @since 3.5.0 * * @return {void} */ ready: function() { if ( this.options.infiniteScrolling ) { this.scroll(); } }, /** * Handles scroll events. * * Shows the spinner if we're close to the bottom. Loads more attachments from * server if we're {refreshThreshold} times away from the bottom. * * @since 3.5.0 * * @return {void} */ scroll: function() { var view = this, el = this.options.scrollElement, scrollTop = el.scrollTop, toolbar; /* * The scroll event occurs on the document, but the element that should be * checked is the document body. */ if ( el === document ) { el = document.body; scrollTop = $(document).scrollTop(); } if ( ! $(el).is(':visible') || ! this.collection.hasMore() ) { return; } toolbar = this.views.parent.toolbar; // Show the spinner only if we are close to the bottom. if ( el.scrollHeight - ( scrollTop + el.clientHeight ) < el.clientHeight / 3 ) { toolbar.get('spinner').show(); } if ( el.scrollHeight < scrollTop + ( el.clientHeight * this.options.refreshThreshold ) ) { this.collection.more().done(function() { view.scroll(); toolbar.get('spinner').hide(); }); } } }); module.exports = Attachments; /***/ }, /***/ 6829 (module) { var View = wp.media.View, mediaTrash = wp.media.view.settings.mediaTrash, l10n = wp.media.view.l10n, $ = jQuery, AttachmentsBrowser, infiniteScrolling = wp.media.view.settings.infiniteScrolling, __ = wp.i18n.__, sprintf = wp.i18n.sprintf; /** * wp.media.view.AttachmentsBrowser * * @memberOf wp.media.view * * @class * @augments wp.media.View * @augments wp.Backbone.View * @augments Backbone.View * * @param {object} [options] The options hash passed to the view. * @param {boolean|string} [options.filters=false] Which filters to show in the browser's toolbar. * Accepts 'uploaded' and 'all'. * @param {boolean} [options.search=true] Whether to show the search interface in the * browser's toolbar. * @param {boolean} [options.date=true] Whether to show the date filter in the * browser's toolbar. * @param {boolean} [options.display=false] Whether to show the attachments display settings * view in the sidebar. * @param {boolean|string} [options.sidebar=true] Whether to create a sidebar for the browser. * Accepts true, false, and 'errors'. */ AttachmentsBrowser = View.extend(/** @lends wp.media.view.AttachmentsBrowser.prototype */{ tagName: 'div', className: 'attachments-browser', initialize: function() { _.defaults( this.options, { filters: false, search: true, date: true, display: false, sidebar: true, AttachmentView: wp.media.view.Attachment.Library }); this.controller.on( 'toggle:upload:attachment', this.toggleUploader, this ); this.controller.on( 'edit:selection', this.editSelection ); // In the Media Library, the sidebar is used to display errors before the attachments grid. if ( this.options.sidebar && 'errors' === this.options.sidebar ) { this.createSidebar(); } /* * In the grid mode (the Media Library), place the Inline Uploader before * other sections so that the visual order and the DOM order match. This way, * the Inline Uploader in the Media Library is right after the "Add New" * button, see ticket #37188. */ if ( this.controller.isModeActive( 'grid' ) ) { this.createUploader(); /* * Create a multi-purpose toolbar. Used as main toolbar in the Media Library * and also for other things, for example the "Drag and drop to reorder" and * "Suggested dimensions" info in the media modal. */ this.createToolbar(); } else { this.createToolbar(); this.createUploader(); } // Add a heading before the attachments list. this.createAttachmentsHeading(); // Create the attachments wrapper view. this.createAttachmentsWrapperView(); if ( ! infiniteScrolling ) { this.$el.addClass( 'has-load-more' ); this.createLoadMoreView(); } // For accessibility reasons, place the normal sidebar after the attachments, see ticket #36909. if ( this.options.sidebar && 'errors' !== this.options.sidebar ) { this.createSidebar(); } this.updateContent(); if ( ! infiniteScrolling ) { this.updateLoadMoreView(); } if ( ! this.options.sidebar || 'errors' === this.options.sidebar ) { this.$el.addClass( 'hide-sidebar' ); if ( 'errors' === this.options.sidebar ) { this.$el.addClass( 'sidebar-for-errors' ); } } this.collection.on( 'add remove reset', this.updateContent, this ); if ( ! infiniteScrolling ) { this.collection.on( 'add remove reset', this.updateLoadMoreView, this ); } // The non-cached or cached attachments query has completed. this.collection.on( 'attachments:received', this.announceSearchResults, this ); }, /** * Updates the `wp.a11y.speak()` ARIA live region with a message to communicate * the number of search results to screen reader users. This function is * debounced because the collection updates multiple times. * * @since 5.3.0 * * @return {void} */ announceSearchResults: _.debounce( function() { var count, /* translators: Accessibility text. %d: Number of attachments found in a search. */ mediaFoundHasMoreResultsMessage = __( 'Number of media items displayed: %d. Click load more for more results.' ); if ( infiniteScrolling ) { /* translators: Accessibility text. %d: Number of attachments found in a search. */ mediaFoundHasMoreResultsMessage = __( 'Number of media items displayed: %d. Scroll the page for more results.' ); } if ( this.collection.mirroring && this.collection.mirroring.args.s ) { count = this.collection.length; if ( 0 === count ) { wp.a11y.speak( l10n.noMediaTryNewSearch ); return; } if ( this.collection.hasMore() ) { wp.a11y.speak( mediaFoundHasMoreResultsMessage.replace( '%d', count ) ); return; } wp.a11y.speak( l10n.mediaFound.replace( '%d', count ) ); } }, 200 ), editSelection: function( modal ) { // When editing a selection, move focus to the "Go to library" button. modal.$( '.media-button-backToLibrary' ).focus(); }, /** * @return {wp.media.view.AttachmentsBrowser} Returns itself to allow chaining. */ dispose: function() { this.options.selection.off( null, null, this ); View.prototype.dispose.apply( this, arguments ); return this; }, createToolbar: function() { var LibraryViewSwitcher, Filters, toolbarOptions, showFilterByType = -1 !== $.inArray( this.options.filters, [ 'uploaded', 'all' ] ); toolbarOptions = { controller: this.controller }; if ( this.controller.isModeActive( 'grid' ) ) { toolbarOptions.className = 'media-toolbar wp-filter'; } /** * @member {wp.media.view.Toolbar} */ this.toolbar = new wp.media.view.Toolbar( toolbarOptions ); this.views.add( this.toolbar ); this.toolbar.set( 'spinner', new wp.media.view.Spinner({ priority: -20 }) ); if ( showFilterByType || this.options.date ) { /* * Create a h2 heading before the select elements that filter attachments. * This heading is visible in the modal and visually hidden in the grid. */ this.toolbar.set( 'filters-heading', new wp.media.view.Heading( { priority: -100, text: l10n.filterAttachments, level: 'h2', className: 'media-attachments-filter-heading screen-reader-text' }).render() ); } if ( showFilterByType ) { // "Filters" is a , a label element needs to be rendered before. this.toolbar.set( 'dateFilter', new wp.media.view.Label({ value: l10n.filterByDate, attributes: { 'for': 'media-attachment-date-filters' }, priority: -75 }).render() ); this.toolbar.set( 'dateFilter', new wp.media.view.DateFilter({ controller: this.controller, model: this.collection.props, priority: -75, }).render() ); // BulkSelection is a
with subviews, including screen reader text. this.toolbar.set( 'selectModeToggleButton', new wp.media.view.SelectModeToggleButton({ text: l10n.bulkSelect, controller: this.controller, priority: -70 }).render() ); this.toolbar.set( 'deleteSelectedButton', new wp.media.view.DeleteSelectedButton({ filters: Filters, style: 'primary', disabled: true, text: mediaTrash ? l10n.trashSelected : l10n.deletePermanently, controller: this.controller, priority: -80, click: function() { var changed = [], removed = [], selection = this.controller.state().get( 'selection' ), library = this.controller.state().get( 'library' ); if ( ! selection.length ) { return; } if ( ! mediaTrash && ! window.confirm( l10n.warnBulkDelete ) ) { return; } if ( mediaTrash && 'trash' !== selection.at( 0 ).get( 'status' ) && ! window.confirm( l10n.warnBulkTrash ) ) { return; } selection.each( function( model ) { if ( ! model.get( 'nonces' )['delete'] ) { removed.push( model ); return; } if ( mediaTrash && 'trash' === model.get( 'status' ) ) { model.set( 'status', 'inherit' ); changed.push( model.save() ); removed.push( model ); } else if ( mediaTrash ) { model.set( 'status', 'trash' ); changed.push( model.save() ); removed.push( model ); } else { model.destroy({wait: true}); } } ); if ( changed.length ) { selection.remove( removed ); $.when.apply( null, changed ).then( _.bind( function() { library._requery( true ); this.controller.trigger( 'selection:action:done' ); }, this ) ); } else { this.controller.trigger( 'selection:action:done' ); } } }).render() ); if ( mediaTrash ) { this.toolbar.set( 'deleteSelectedPermanentlyButton', new wp.media.view.DeleteSelectedPermanentlyButton({ filters: Filters, style: 'link button-link-delete', disabled: true, text: l10n.deletePermanently, controller: this.controller, priority: -55, click: function() { var removed = [], destroy = [], selection = this.controller.state().get( 'selection' ); if ( ! selection.length || ! window.confirm( l10n.warnBulkDelete ) ) { return; } selection.each( function( model ) { if ( ! model.get( 'nonces' )['delete'] ) { removed.push( model ); return; } destroy.push( model ); } ); if ( removed.length ) { selection.remove( removed ); } if ( destroy.length ) { $.when.apply( null, destroy.map( function (item) { return item.destroy(); } ) ).then( _.bind( function() { this.controller.trigger( 'selection:action:done' ); }, this ) ); } } }).render() ); } } else if ( this.options.date ) { // DateFilter is a ' ) .attr( 'aria-label', l10n.insertFromUrlTitle ) .val( this.model.get('url') ); this.input = this.$input[0]; this.spinner = $('')[0]; this.$el.append([ this.input, this.spinner ]); this.listenTo( this.model, 'change:url', this.render ); if ( this.model.get( 'url' ) ) { _.delay( _.bind( function () { this.model.trigger( 'change:url' ); }, this ), 500 ); } }, /** * @return {wp.media.view.EmbedUrl} Returns itself to allow chaining. */ render: function() { var $input = this.$input; if ( $input.is(':focus') ) { return; } if ( this.model.get( 'url' ) ) { this.input.value = this.model.get('url'); } else { this.input.setAttribute( 'placeholder', 'https://' ); } /** * Call `render` directly on parent class with passed arguments */ View.prototype.render.apply( this, arguments ); return this; }, url: function( event ) { var url = event.target.value || ''; this.model.set( 'url', url.trim() ); } }); module.exports = EmbedUrl; /***/ }, /***/ 718 (module) { var $ = jQuery; /** * wp.media.view.FocusManager * * @memberOf wp.media.view * * @class * @augments wp.media.View * @augments wp.Backbone.View * @augments Backbone.View */ var FocusManager = wp.media.View.extend(/** @lends wp.media.view.FocusManager.prototype */{ events: { 'keydown': 'focusManagementMode' }, /** * Initializes the Focus Manager. * * @param {Object} options The Focus Manager options. * * @since 5.3.0 * * @return {void} */ initialize: function( options ) { this.mode = options.mode || 'constrainTabbing'; this.tabsAutomaticActivation = options.tabsAutomaticActivation || false; }, /** * Determines which focus management mode to use. * * @since 5.3.0 * * @param {Object} event jQuery event object. * * @return {void} */ focusManagementMode: function( event ) { if ( this.mode === 'constrainTabbing' ) { this.constrainTabbing( event ); } if ( this.mode === 'tabsNavigation' ) { this.tabsNavigation( event ); } }, /** * Gets all the tabbable elements. * * @since 5.3.0 * * @return {Object} A jQuery collection of tabbable elements. */ getTabbables: function() { // Skip the file input added by Plupload. return this.$( ':tabbable' ).not( '.moxie-shim input[type="file"]' ); }, /** * Moves focus to the modal dialog. * * @since 3.5.0 * * @return {void} */ focus: function() { this.$( '.media-modal' ).trigger( 'focus' ); }, /** * Constrains navigation with the Tab key within the media view element. * * @since 4.0.0 * * @param {Object} event A keydown jQuery event. * * @return {void} */ constrainTabbing: function( event ) { var tabbables; // Look for the tab key. if ( 9 !== event.keyCode ) { return; } tabbables = this.getTabbables(); // Keep tab focus within media modal while it's open. if ( tabbables.last()[0] === event.target && ! event.shiftKey ) { tabbables.first().focus(); return false; } else if ( tabbables.first()[0] === event.target && event.shiftKey ) { tabbables.last().focus(); return false; } }, /** * Hides from assistive technologies all the body children. * * Sets an `aria-hidden="true"` attribute on all the body children except * the provided element and other elements that should not be hidden. * * The reason why we use `aria-hidden` is that `aria-modal="true"` is buggy * in Safari 11.1 and support is spotty in other browsers. Also, `aria-modal="true"` * prevents the `wp.a11y.speak()` ARIA live regions to work as they're outside * of the modal dialog and get hidden from assistive technologies. * * @since 5.2.3 * * @param {Object} visibleElement The jQuery object representing the element that should not be hidden. * * @return {void} */ setAriaHiddenOnBodyChildren: function( visibleElement ) { var bodyChildren, self = this; if ( this.isBodyAriaHidden ) { return; } // Get all the body children. bodyChildren = document.body.children; // Loop through the body children and hide the ones that should be hidden. _.each( bodyChildren, function( element ) { // Don't hide the modal element. if ( element === visibleElement[0] ) { return; } // Determine the body children to hide. if ( self.elementShouldBeHidden( element ) ) { element.setAttribute( 'aria-hidden', 'true' ); // Store the hidden elements. self.ariaHiddenElements.push( element ); } } ); this.isBodyAriaHidden = true; }, /** * Unhides from assistive technologies all the body children. * * Makes visible again to assistive technologies all the body children * previously hidden and stored in this.ariaHiddenElements. * * @since 5.2.3 * * @return {void} */ removeAriaHiddenFromBodyChildren: function() { _.each( this.ariaHiddenElements, function( element ) { element.removeAttribute( 'aria-hidden' ); } ); this.ariaHiddenElements = []; this.isBodyAriaHidden = false; }, /** * Determines if the passed element should not be hidden from assistive technologies. * * @since 5.2.3 * * @param {Object} element The DOM element that should be checked. * * @return {boolean} Whether the element should not be hidden from assistive technologies. */ elementShouldBeHidden: function( element ) { var role = element.getAttribute( 'role' ), liveRegionsRoles = [ 'alert', 'status', 'log', 'marquee', 'timer' ]; /* * Don't hide scripts, elements that already have `aria-hidden`, and * ARIA live regions. */ return ! ( element.tagName === 'SCRIPT' || element.hasAttribute( 'aria-hidden' ) || element.hasAttribute( 'aria-live' ) || liveRegionsRoles.indexOf( role ) !== -1 ); }, /** * Whether the body children are hidden from assistive technologies. * * @since 5.2.3 */ isBodyAriaHidden: false, /** * Stores an array of DOM elements that should be hidden from assistive * technologies, for example when the media modal dialog opens. * * @since 5.2.3 */ ariaHiddenElements: [], /** * Holds the jQuery collection of ARIA tabs. * * @since 5.3.0 */ tabs: $(), /** * Sets up tabs in an ARIA tabbed interface. * * @since 5.3.0 * * @param {Object} event jQuery event object. * * @return {void} */ setupAriaTabs: function() { this.tabs = this.$( '[role="tab"]' ); // Set up initial attributes. this.tabs.attr( { 'aria-selected': 'false', tabIndex: '-1' } ); // Set up attributes on the initially active tab. this.tabs.filter( '.active' ) .removeAttr( 'tabindex' ) .attr( 'aria-selected', 'true' ); }, /** * Enables arrows navigation within the ARIA tabbed interface. * * @since 5.3.0 * * @param {Object} event jQuery event object. * * @return {void} */ tabsNavigation: function( event ) { var orientation = 'horizontal', keys = [ 32, 35, 36, 37, 38, 39, 40 ]; // Return if not Spacebar, End, Home, or Arrow keys. if ( keys.indexOf( event.which ) === -1 ) { return; } // Determine navigation direction. if ( this.$el.attr( 'aria-orientation' ) === 'vertical' ) { orientation = 'vertical'; } // Make Up and Down arrow keys do nothing with horizontal tabs. if ( orientation === 'horizontal' && [ 38, 40 ].indexOf( event.which ) !== -1 ) { return; } // Make Left and Right arrow keys do nothing with vertical tabs. if ( orientation === 'vertical' && [ 37, 39 ].indexOf( event.which ) !== -1 ) { return; } this.switchTabs( event, this.tabs ); }, /** * Switches tabs in the ARIA tabbed interface. * * @since 5.3.0 * * @param {Object} event jQuery event object. * * @return {void} */ switchTabs: function( event ) { var key = event.which, index = this.tabs.index( $( event.target ) ), newIndex; switch ( key ) { // Space bar: Activate current targeted tab. case 32: { this.activateTab( this.tabs[ index ] ); break; } // End key: Activate last tab. case 35: { event.preventDefault(); this.activateTab( this.tabs[ this.tabs.length - 1 ] ); break; } // Home key: Activate first tab. case 36: { event.preventDefault(); this.activateTab( this.tabs[ 0 ] ); break; } // Left and up keys: Activate previous tab. case 37: case 38: { event.preventDefault(); newIndex = ( index - 1 ) < 0 ? this.tabs.length - 1 : index - 1; this.activateTab( this.tabs[ newIndex ] ); break; } // Right and down keys: Activate next tab. case 39: case 40: { event.preventDefault(); newIndex = ( index + 1 ) === this.tabs.length ? 0 : index + 1; this.activateTab( this.tabs[ newIndex ] ); break; } } }, /** * Sets a single tab to be focusable and semantically selected. * * @since 5.3.0 * * @param {Object} tab The tab DOM element. * * @return {void} */ activateTab: function( tab ) { if ( ! tab ) { return; } // The tab is a DOM element: no need for jQuery methods. tab.focus(); // Handle automatic activation. if ( this.tabsAutomaticActivation ) { tab.removeAttribute( 'tabindex' ); tab.setAttribute( 'aria-selected', 'true' ); tab.click(); return; } // Handle manual activation. $( tab ).on( 'click', function() { tab.removeAttribute( 'tabindex' ); tab.setAttribute( 'aria-selected', 'true' ); } ); } }); module.exports = FocusManager; /***/ }, /***/ 1061 (module) { /** * wp.media.view.Frame * * A frame is a composite view consisting of one or more regions and one or more * states. * * @memberOf wp.media.view * * @see wp.media.controller.State * @see wp.media.controller.Region * * @class * @augments wp.media.View * @augments wp.Backbone.View * @augments Backbone.View * @mixes wp.media.controller.StateMachine */ var Frame = wp.media.View.extend(/** @lends wp.media.view.Frame.prototype */{ initialize: function() { _.defaults( this.options, { mode: [ 'select' ] }); this._createRegions(); this._createStates(); this._createModes(); }, _createRegions: function() { // Clone the regions array. this.regions = this.regions ? this.regions.slice() : []; // Initialize regions. _.each( this.regions, function( region ) { this[ region ] = new wp.media.controller.Region({ view: this, id: region, selector: '.media-frame-' + region }); }, this ); }, /** * Create the frame's states. * * @see wp.media.controller.State * @see wp.media.controller.StateMachine * * @fires wp.media.controller.State#ready */ _createStates: function() { // Create the default `states` collection. this.states = new Backbone.Collection( null, { model: wp.media.controller.State }); // Ensure states have a reference to the frame. this.states.on( 'add', function( model ) { model.frame = this; model.trigger('ready'); }, this ); if ( this.options.states ) { this.states.add( this.options.states ); } }, /** * A frame can be in a mode or multiple modes at one time. * * For example, the manage media frame can be in the `Bulk Select` or `Edit` mode. */ _createModes: function() { // Store active "modes" that the frame is in. Unrelated to region modes. this.activeModes = new Backbone.Collection(); this.activeModes.on( 'add remove reset', _.bind( this.triggerModeEvents, this ) ); _.each( this.options.mode, function( mode ) { this.activateMode( mode ); }, this ); }, /** * Reset all states on the frame to their defaults. * * @return {wp.media.view.Frame} Returns itself to allow chaining. */ reset: function() { this.states.invoke( 'trigger', 'reset' ); return this; }, /** * Map activeMode collection events to the frame. */ triggerModeEvents: function( model, collection, options ) { var collectionEvent, modeEventMap = { add: 'activate', remove: 'deactivate' }, eventToTrigger; // Probably a better way to do this. _.each( options, function( value, key ) { if ( value ) { collectionEvent = key; } } ); if ( ! _.has( modeEventMap, collectionEvent ) ) { return; } eventToTrigger = model.get('id') + ':' + modeEventMap[collectionEvent]; this.trigger( eventToTrigger ); }, /** * Activate a mode on the frame. * * @param string mode Mode ID. * @return {this} Returns itself to allow chaining. */ activateMode: function( mode ) { // Bail if the mode is already active. if ( this.isModeActive( mode ) ) { return; } this.activeModes.add( [ { id: mode } ] ); // Add a CSS class to the frame so elements can be styled for the mode. this.$el.addClass( 'mode-' + mode ); return this; }, /** * Deactivate a mode on the frame. * * @param string mode Mode ID. * @return {this} Returns itself to allow chaining. */ deactivateMode: function( mode ) { // Bail if the mode isn't active. if ( ! this.isModeActive( mode ) ) { return this; } this.activeModes.remove( this.activeModes.where( { id: mode } ) ); this.$el.removeClass( 'mode-' + mode ); /** * Frame mode deactivation event. * * @event wp.media.view.Frame#{mode}:deactivate */ this.trigger( mode + ':deactivate' ); return this; }, /** * Check if a mode is enabled on the frame. * * @param string mode Mode ID. * @return bool */ isModeActive: function( mode ) { return Boolean( this.activeModes.where( { id: mode } ).length ); } }); // Make the `Frame` a `StateMachine`. _.extend( Frame.prototype, wp.media.controller.StateMachine.prototype ); module.exports = Frame; /***/ }, /***/ 5424 (module) { var Select = wp.media.view.MediaFrame.Select, l10n = wp.media.view.l10n, ImageDetails; /** * wp.media.view.MediaFrame.ImageDetails * * A media frame for manipulating an image that's already been inserted * into a post. * * @memberOf wp.media.view.MediaFrame * * @class * @augments wp.media.view.MediaFrame.Select * @augments wp.media.view.MediaFrame * @augments wp.media.view.Frame * @augments wp.media.View * @augments wp.Backbone.View * @augments Backbone.View * @mixes wp.media.controller.StateMachine */ ImageDetails = Select.extend(/** @lends wp.media.view.MediaFrame.ImageDetails.prototype */{ defaults: { id: 'image', url: '', menu: 'image-details', content: 'image-details', toolbar: 'image-details', type: 'link', title: l10n.imageDetailsTitle, priority: 120 }, initialize: function( options ) { this.image = new wp.media.model.PostImage( options.metadata ); this.options.selection = new wp.media.model.Selection( this.image.attachment, { multiple: false } ); Select.prototype.initialize.apply( this, arguments ); }, bindHandlers: function() { Select.prototype.bindHandlers.apply( this, arguments ); this.on( 'menu:create:image-details', this.createMenu, this ); 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. this.on( 'toolbar:render:replace', this.renderReplaceImageToolbar, this ); }, createStates: function() { this.states.add([ new wp.media.controller.ImageDetails({ image: this.image, editable: false }), new wp.media.controller.ReplaceImage({ id: 'replace-image', library: wp.media.query( { type: 'image' } ), image: this.image, multiple: false, title: l10n.imageReplaceTitle, toolbar: 'replace', priority: 80, displaySettings: true }), new wp.media.controller.EditImage( { image: this.image, selection: this.options.selection } ) ]); }, imageDetailsContent: function( options ) { options.view = new wp.media.view.ImageDetails({ controller: this, model: this.state().image, attachment: this.state().image.attachment }); }, editImageContent: function() { var state = this.state(), model = state.get('image'), view; if ( ! model ) { return; } view = new wp.media.view.EditImage( { model: model, controller: this } ).render(); this.content.set( view ); // After bringing in the frame, load the actual editor via an Ajax call. view.loadEditor(); }, renderImageDetailsToolbar: function() { this.toolbar.set( new wp.media.view.Toolbar({ controller: this, items: { select: { style: 'primary', text: l10n.update, priority: 80, click: function() { var controller = this.controller, state = controller.state(); 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 . state.trigger( 'update', controller.image.toJSON() ); // Restore and reset the default state. controller.setState( controller.options.state ); controller.reset(); } } } }) ); }, renderReplaceImageToolbar: function() { var frame = this, lastState = frame.lastState(), previous = lastState && lastState.id; this.toolbar.set( new wp.media.view.Toolbar({ controller: this, items: { back: { text: l10n.back, priority: 80, click: function() { if ( previous ) { frame.setState( previous ); } else { frame.close(); } } }, replace: { style: 'primary', text: l10n.replace, priority: 20, requires: { selection: true }, click: function() { var controller = this.controller, state = controller.state(), selection = state.get( 'selection' ), attachment = selection.single(); controller.close(); 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 . state.trigger( 'replace', controller.image.toJSON() ); // Restore and reset the default state. controller.setState( controller.options.state ); controller.reset(); } } } }) ); } }); module.exports = ImageDetails; /***/ }, /***/ 4274 (module) { var Select = wp.media.view.MediaFrame.Select, Library = wp.media.controller.Library, l10n = wp.media.view.l10n, Post; /** * wp.media.view.MediaFrame.Post * * The frame for manipulating media on the Edit Post page. * * @memberOf wp.media.view.MediaFrame * * @class * @augments wp.media.view.MediaFrame.Select * @augments wp.media.view.MediaFrame * @augments wp.media.view.Frame * @augments wp.media.View * @augments wp.Backbone.View * @augments Backbone.View * @mixes wp.media.controller.StateMachine */ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{ initialize: function() { this.counts = { audio: { count: wp.media.view.settings.attachmentCounts.audio, state: 'playlist' }, video: { count: wp.media.view.settings.attachmentCounts.video, state: 'video-playlist' } }; _.defaults( this.options, { multiple: true, editing: false, state: 'insert', metadata: {} }); // Call 'initialize' directly on the parent class. Select.prototype.initialize.apply( this, arguments ); this.createIframeStates(); }, /** * Create the default states. */ createStates: function() { var options = this.options; this.states.add([ // Main states. new Library({ id: 'insert', title: l10n.insertMediaTitle, priority: 20, toolbar: 'main-insert', filterable: 'all', library: wp.media.query( options.library ), multiple: options.multiple ? 'reset' : false, editable: true, // If the user isn't allowed to edit fields, // can they still edit it locally? allowLocalEdits: true, // Show the attachment display settings. displaySettings: true, // Update user settings when users adjust the // attachment display settings. displayUserSettings: true }), new Library({ id: 'gallery', title: l10n.createGalleryTitle, priority: 40, toolbar: 'main-gallery', filterable: 'uploaded', multiple: 'add', editable: false, library: wp.media.query( _.defaults({ type: 'image' }, options.library ) ) }), // Embed states. new wp.media.controller.Embed( { metadata: options.metadata } ), new wp.media.controller.EditImage( { model: options.editImage } ), // Gallery states. new wp.media.controller.GalleryEdit({ library: options.selection, editing: options.editing, menu: 'gallery' }), new wp.media.controller.GalleryAdd(), new Library({ id: 'playlist', title: l10n.createPlaylistTitle, priority: 60, toolbar: 'main-playlist', filterable: 'uploaded', multiple: 'add', editable: false, library: wp.media.query( _.defaults({ type: 'audio' }, options.library ) ) }), // Playlist states. new wp.media.controller.CollectionEdit({ type: 'audio', collectionType: 'playlist', title: l10n.editPlaylistTitle, SettingsView: wp.media.view.Settings.Playlist, library: options.selection, editing: options.editing, menu: 'playlist', dragInfoText: l10n.playlistDragInfo, dragInfo: false }), new wp.media.controller.CollectionAdd({ type: 'audio', collectionType: 'playlist', title: l10n.addToPlaylistTitle }), new Library({ id: 'video-playlist', title: l10n.createVideoPlaylistTitle, priority: 60, toolbar: 'main-video-playlist', filterable: 'uploaded', multiple: 'add', editable: false, library: wp.media.query( _.defaults({ type: 'video' }, options.library ) ) }), new wp.media.controller.CollectionEdit({ type: 'video', collectionType: 'playlist', title: l10n.editVideoPlaylistTitle, SettingsView: wp.media.view.Settings.Playlist, library: options.selection, editing: options.editing, menu: 'video-playlist', dragInfoText: l10n.videoPlaylistDragInfo, dragInfo: false }), new wp.media.controller.CollectionAdd({ type: 'video', collectionType: 'playlist', title: l10n.addToVideoPlaylistTitle }) ]); if ( wp.media.view.settings.post.featuredImageId ) { this.states.add( new wp.media.controller.FeaturedImage() ); } }, bindHandlers: function() { var handlers, checkCounts; Select.prototype.bindHandlers.apply( this, arguments ); this.on( 'activate', this.activate, this ); // Only bother checking media type counts if one of the counts is zero. checkCounts = _.find( this.counts, function( type ) { return type.count === 0; } ); if ( typeof checkCounts !== 'undefined' ) { this.listenTo( wp.media.model.Attachments.all, 'change:type', this.mediaTypeCounts ); } this.on( 'menu:create:gallery', this.createMenu, this ); this.on( 'menu:create:playlist', this.createMenu, this ); this.on( 'menu:create:video-playlist', this.createMenu, this ); this.on( 'toolbar:create:main-insert', this.createToolbar, this ); this.on( 'toolbar:create:main-gallery', this.createToolbar, this ); this.on( 'toolbar:create:main-playlist', this.createToolbar, this ); this.on( 'toolbar:create:main-video-playlist', this.createToolbar, this ); this.on( 'toolbar:create:featured-image', this.featuredImageToolbar, this ); this.on( 'toolbar:create:main-embed', this.mainEmbedToolbar, this ); handlers = { menu: { 'default': 'mainMenu', 'gallery': 'galleryMenu', 'playlist': 'playlistMenu', 'video-playlist': 'videoPlaylistMenu' }, content: { 'embed': 'embedContent', 'edit-image': 'editImageContent', 'edit-selection': 'editSelectionContent' }, toolbar: { 'main-insert': 'mainInsertToolbar', 'main-gallery': 'mainGalleryToolbar', 'gallery-edit': 'galleryEditToolbar', 'gallery-add': 'galleryAddToolbar', 'main-playlist': 'mainPlaylistToolbar', 'playlist-edit': 'playlistEditToolbar', 'playlist-add': 'playlistAddToolbar', 'main-video-playlist': 'mainVideoPlaylistToolbar', 'video-playlist-edit': 'videoPlaylistEditToolbar', 'video-playlist-add': 'videoPlaylistAddToolbar' } }; _.each( handlers, function( regionHandlers, region ) { _.each( regionHandlers, function( callback, handler ) { this.on( region + ':render:' + handler, this[ callback ], this ); }, this ); }, this ); }, activate: function() { // 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' ); } }, this ); }, mediaTypeCounts: function( model, attr ) { if ( typeof this.counts[ attr ] !== 'undefined' && this.counts[ attr ].count < 1 ) { this.counts[ attr ].count++; this.menuItemVisibility( this.counts[ attr ].state, 'show' ); } }, // Menus. /** * @param {wp.Backbone.View} view */ mainMenu: function( view ) { view.set({ 'library-separator': new wp.media.View({ className: 'separator', priority: 100, attributes: { role: 'presentation' } }) }); }, menuItemVisibility: function( state, visibility ) { var menu = this.menu.get(); if ( visibility === 'hide' ) { menu.hide( state ); } else if ( visibility === 'show' ) { menu.show( state ); } }, /** * @param {wp.Backbone.View} view */ galleryMenu: function( view ) { var lastState = this.lastState(), previous = lastState && lastState.id, frame = this; view.set({ cancel: { text: l10n.cancelGalleryTitle, priority: 20, click: function() { if ( previous ) { frame.setState( previous ); } else { frame.close(); } // Move focus to the modal after canceling a Gallery. this.controller.modal.focusManager.focus(); } }, separateCancel: new wp.media.View({ className: 'separator', priority: 40 }) }); }, playlistMenu: function( view ) { var lastState = this.lastState(), previous = lastState && lastState.id, frame = this; view.set({ cancel: { text: l10n.cancelPlaylistTitle, priority: 20, click: function() { if ( previous ) { frame.setState( previous ); } else { frame.close(); } // Move focus to the modal after canceling an Audio Playlist. this.controller.modal.focusManager.focus(); } }, separateCancel: new wp.media.View({ className: 'separator', priority: 40 }) }); }, videoPlaylistMenu: function( view ) { var lastState = this.lastState(), previous = lastState && lastState.id, frame = this; view.set({ cancel: { text: l10n.cancelVideoPlaylistTitle, priority: 20, click: function() { if ( previous ) { frame.setState( previous ); } else { frame.close(); } // Move focus to the modal after canceling a Video Playlist. this.controller.modal.focusManager.focus(); } }, separateCancel: new wp.media.View({ className: 'separator', priority: 40 }) }); }, // Content. embedContent: function() { var view = new wp.media.view.Embed({ controller: this, model: this.state() }).render(); this.content.set( view ); }, editSelectionContent: function() { var state = this.state(), selection = state.get('selection'), view; view = new wp.media.view.AttachmentsBrowser({ controller: this, collection: selection, selection: selection, model: state, sortable: true, search: false, date: false, dragInfo: true, AttachmentView: wp.media.view.Attachments.EditSelection }).render(); view.toolbar.set( 'backToLibrary', { text: l10n.returnToLibrary, priority: -100, click: function() { this.controller.content.mode('browse'); // Move focus to the modal when jumping back from Edit Selection to Add Media view. this.controller.modal.focusManager.focus(); } }); // Browse our library of attachments. this.content.set( view ); // Trigger the controller to set focus. this.trigger( 'edit:selection', this ); }, editImageContent: function() { var image = this.state().get('image'), view = new wp.media.view.EditImage( { model: image, controller: this } ).render(); this.content.set( view ); // After creating the wrapper view, load the actual editor via an Ajax call. view.loadEditor(); }, // Toolbars. /** * @param {wp.Backbone.View} view */ selectionStatusToolbar: function( view ) { var editable = this.state().get('editable'); view.set( 'selection', new wp.media.view.Selection({ controller: this, collection: this.state().get('selection'), priority: -40, // If the selection is editable, pass the callback to // switch the content mode. editable: editable && function() { this.controller.content.mode('edit-selection'); } }).render() ); }, /** * @param {wp.Backbone.View} view */ mainInsertToolbar: function( view ) { var controller = this; this.selectionStatusToolbar( view ); view.set( 'insert', { style: 'primary', priority: 80, text: l10n.insertIntoPost, requires: { selection: true }, /** * @ignore * * @fires wp.media.controller.State#insert */ click: function() { var state = controller.state(), selection = state.get('selection'); controller.close(); state.trigger( 'insert', selection ).reset(); } }); }, /** * @param {wp.Backbone.View} view */ mainGalleryToolbar: function( view ) { var controller = this; this.selectionStatusToolbar( view ); view.set( 'gallery', { style: 'primary', text: l10n.createNewGallery, priority: 60, requires: { selection: true }, click: function() { var selection = controller.state().get('selection'), edit = controller.state('gallery-edit'), models = selection.where({ type: 'image' }); edit.set( 'library', new wp.media.model.Selection( models, { props: selection.props.toJSON(), multiple: true }) ); // Jump to Edit Gallery view. this.controller.setState( 'gallery-edit' ); // Move focus to the modal after jumping to Edit Gallery view. this.controller.modal.focusManager.focus(); } }); }, mainPlaylistToolbar: function( view ) { var controller = this; this.selectionStatusToolbar( view ); view.set( 'playlist', { style: 'primary', text: l10n.createNewPlaylist, priority: 100, requires: { selection: true }, click: function() { var selection = controller.state().get('selection'), edit = controller.state('playlist-edit'), models = selection.where({ type: 'audio' }); edit.set( 'library', new wp.media.model.Selection( models, { props: selection.props.toJSON(), multiple: true }) ); // Jump to Edit Audio Playlist view. this.controller.setState( 'playlist-edit' ); // Move focus to the modal after jumping to Edit Audio Playlist view. this.controller.modal.focusManager.focus(); } }); }, mainVideoPlaylistToolbar: function( view ) { var controller = this; this.selectionStatusToolbar( view ); view.set( 'video-playlist', { style: 'primary', text: l10n.createNewVideoPlaylist, priority: 100, requires: { selection: true }, click: function() { var selection = controller.state().get('selection'), edit = controller.state('video-playlist-edit'), models = selection.where({ type: 'video' }); edit.set( 'library', new wp.media.model.Selection( models, { props: selection.props.toJSON(), multiple: true }) ); // Jump to Edit Video Playlist view. this.controller.setState( 'video-playlist-edit' ); // Move focus to the modal after jumping to Edit Video Playlist view. this.controller.modal.focusManager.focus(); } }); }, featuredImageToolbar: function( toolbar ) { this.createSelectToolbar( toolbar, { text: l10n.setFeaturedImage, state: this.options.state }); }, mainEmbedToolbar: function( toolbar ) { toolbar.view = new wp.media.view.Toolbar.Embed({ controller: this }); }, galleryEditToolbar: function() { var editing = this.state().get('editing'); this.toolbar.set( new wp.media.view.Toolbar({ controller: this, items: { insert: { style: 'primary', text: editing ? l10n.updateGallery : l10n.insertGallery, priority: 80, requires: { library: true, uploadingComplete: true }, /** * @fires wp.media.controller.State#update */ click: function() { var controller = this.controller, state = controller.state(); controller.close(); state.trigger( 'update', state.get('library') ); // Restore and reset the default state. controller.setState( controller.options.state ); controller.reset(); } } } }) ); }, galleryAddToolbar: function() { this.toolbar.set( new wp.media.view.Toolbar({ controller: this, items: { insert: { style: 'primary', text: l10n.addToGallery, priority: 80, requires: { selection: true }, /** * @fires wp.media.controller.State#reset */ click: function() { var controller = this.controller, state = controller.state(), edit = controller.state('gallery-edit'); edit.get('library').add( state.get('selection').models ); state.trigger('reset'); controller.setState('gallery-edit'); // Move focus to the modal when jumping back from Add to Gallery to Edit Gallery view. this.controller.modal.focusManager.focus(); } } } }) ); }, playlistEditToolbar: function() { var editing = this.state().get('editing'); this.toolbar.set( new wp.media.view.Toolbar({ controller: this, items: { insert: { style: 'primary', text: editing ? l10n.updatePlaylist : l10n.insertPlaylist, priority: 80, requires: { library: true }, /** * @fires wp.media.controller.State#update */ click: function() { var controller = this.controller, state = controller.state(); controller.close(); state.trigger( 'update', state.get('library') ); // Restore and reset the default state. controller.setState( controller.options.state ); controller.reset(); } } } }) ); }, playlistAddToolbar: function() { this.toolbar.set( new wp.media.view.Toolbar({ controller: this, items: { insert: { style: 'primary', text: l10n.addToPlaylist, priority: 80, requires: { selection: true }, /** * @fires wp.media.controller.State#reset */ click: function() { var controller = this.controller, state = controller.state(), edit = controller.state('playlist-edit'); edit.get('library').add( state.get('selection').models ); state.trigger('reset'); controller.setState('playlist-edit'); // Move focus to the modal when jumping back from Add to Audio Playlist to Edit Audio Playlist view. this.controller.modal.focusManager.focus(); } } } }) ); }, videoPlaylistEditToolbar: function() { var editing = this.state().get('editing'); this.toolbar.set( new wp.media.view.Toolbar({ controller: this, items: { insert: { style: 'primary', text: editing ? l10n.updateVideoPlaylist : l10n.insertVideoPlaylist, priority: 140, requires: { library: true }, click: function() { var controller = this.controller, state = controller.state(), library = state.get('library'); library.type = 'video'; controller.close(); state.trigger( 'update', library ); // Restore and reset the default state. controller.setState( controller.options.state ); controller.reset(); } } } }) ); }, videoPlaylistAddToolbar: function() { this.toolbar.set( new wp.media.view.Toolbar({ controller: this, items: { insert: { style: 'primary', text: l10n.addToVideoPlaylist, priority: 140, requires: { selection: true }, click: function() { var controller = this.controller, state = controller.state(), edit = controller.state('video-playlist-edit'); edit.get('library').add( state.get('selection').models ); state.trigger('reset'); controller.setState('video-playlist-edit'); // Move focus to the modal when jumping back from Add to Video Playlist to Edit Video Playlist view. this.controller.modal.focusManager.focus(); } } } }) ); } }); module.exports = Post; /***/ }, /***/ 455 (module) { var MediaFrame = wp.media.view.MediaFrame, l10n = wp.media.view.l10n, Select; /** * wp.media.view.MediaFrame.Select * * A frame for selecting an item or items from the media library. * * @memberOf wp.media.view.MediaFrame * * @class * @augments wp.media.view.MediaFrame * @augments wp.media.view.Frame * @augments wp.media.View * @augments wp.Backbone.View * @augments Backbone.View * @mixes wp.media.controller.StateMachine */ Select = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.Select.prototype */{ initialize: function() { // Call 'initialize' directly on the parent class. MediaFrame.prototype.initialize.apply( this, arguments ); _.defaults( this.options, { selection: [], library: {}, multiple: false, state: 'library' }); this.createSelection(); this.createStates(); this.bindHandlers(); }, /** * Attach a selection collection to the frame. * * A selection is a collection of attachments used for a specific purpose * by a media frame. e.g. Selecting an attachment (or many) to insert into * post content. * * @see media.model.Selection */ createSelection: function() { var selection = this.options.selection; if ( ! (selection instanceof wp.media.model.Selection) ) { this.options.selection = new wp.media.model.Selection( selection, { multiple: this.options.multiple }); } this._selection = { attachments: new wp.media.model.Attachments(), difference: [] }; }, editImageContent: function() { var image = this.state().get('image'), view = new wp.media.view.EditImage( { model: image, controller: this } ).render(); this.content.set( view ); // After creating the wrapper view, load the actual editor via an Ajax call. view.loadEditor(); }, /** * Create the default states on the frame. */ createStates: function() { var options = this.options; if ( this.options.states ) { return; } // Add the default states. this.states.add([ // Main states. new wp.media.controller.Library({ library: wp.media.query( options.library ), multiple: options.multiple, title: options.title, priority: 20 }), new wp.media.controller.EditImage( { model: options.editImage } ) ]); }, /** * Bind region mode event callbacks. * * @see media.controller.Region.render */ bindHandlers: function() { this.on( 'router:create:browse', this.createRouter, this ); this.on( 'router:render:browse', this.browseRouter, this ); this.on( 'content:create:browse', this.browseContent, this ); this.on( 'content:render:upload', this.uploadContent, this ); this.on( 'toolbar:create:select', this.createSelectToolbar, this ); this.on( 'content:render:edit-image', this.editImageContent, this ); }, /** * Render callback for the router region in the `browse` mode. * * @param {wp.media.view.Router} routerView */ browseRouter: function( routerView ) { routerView.set({ upload: { text: l10n.uploadFilesTitle, priority: 20 }, browse: { text: l10n.mediaLibraryTitle, priority: 40 } }); }, /** * Render callback for the content region in the `browse` mode. * * @param {wp.media.controller.Region} contentRegion */ browseContent: function( contentRegion ) { var state = this.state(); this.$el.removeClass('hide-toolbar'); // Browse our library of attachments. contentRegion.view = new wp.media.view.AttachmentsBrowser({ controller: this, collection: state.get('library'), selection: state.get('selection'), model: state, sortable: state.get('sortable'), search: state.get('searchable'), filters: state.get('filterable'), date: state.get('date'), display: state.has('display') ? state.get('display') : state.get('displaySettings'), dragInfo: state.get('dragInfo'), idealColumnWidth: state.get('idealColumnWidth'), suggestedWidth: state.get('suggestedWidth'), suggestedHeight: state.get('suggestedHeight'), AttachmentView: state.get('AttachmentView') }); }, /** * Render callback for the content region in the `upload` mode. */ uploadContent: function() { this.$el.removeClass( 'hide-toolbar' ); this.content.set( new wp.media.view.UploaderInline({ controller: this }) ); }, /** * Toolbars * * @param {Object} toolbar * @param {Object} [options={}] * @this wp.media.controller.Region */ createSelectToolbar: function( toolbar, options ) { options = options || this.options.button || {}; options.controller = this; toolbar.view = new wp.media.view.Toolbar.Select( options ); } }); module.exports = Select; /***/ }, /***/ 170 (module) { /** * wp.media.view.Heading * * A reusable heading component for the media library * * Used to add accessibility friendly headers in the media library/modal. * * @class * @augments wp.media.View * @augments wp.Backbone.View * @augments Backbone.View */ var Heading = wp.media.View.extend( { tagName: function() { return this.options.level || 'h1'; }, className: 'media-views-heading', initialize: function() { if ( this.options.className ) { this.$el.addClass( this.options.className ); } this.text = this.options.text; }, render: function() { this.$el.html( this.text ); return this; } } ); module.exports = Heading; /***/ }, /***/ 1982 (module) { /** * wp.media.view.Iframe * * @memberOf wp.media.view * * @class * @augments wp.media.View * @augments wp.Backbone.View * @augments Backbone.View */ var Iframe = wp.media.View.extend(/** @lends wp.media.view.Iframe.prototype */{ className: 'media-iframe', /** * @return {wp.media.view.Iframe} Returns itself to allow chaining. */ render: function() { this.views.detach(); this.$el.html( '
"); jQuery("#TB_overlay").on( 'click', tb_remove ); } }else{//all others if(document.getElementById("TB_overlay") === null){ jQuery("body").append("
"); jQuery("#TB_overlay").on( 'click', tb_remove ); jQuery( 'body' ).addClass( 'modal-open' ); } } if(tb_detectMacXFF()){ jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash }else{ jQuery("#TB_overlay").addClass("TB_overlayBG");//use background and opacity } if(caption===null){caption="";} jQuery("body").append("
");//add loader to the page jQuery('#TB_load').show();//show loader var baseURL; if(url.indexOf("?")!==-1){ //ff there is a query string involved baseURL = url.substr(0, url.indexOf("?")); }else{ baseURL = url; } var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$|\.webp$|\.avif$/; var urlType = baseURL.toLowerCase().match(urlString); if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp' || urlType == '.webp' || urlType == '.avif' ){//code to show images TB_PrevCaption = ""; TB_PrevURL = ""; TB_PrevHTML = ""; TB_NextCaption = ""; TB_NextURL = ""; TB_NextHTML = ""; TB_imageCount = ""; TB_FoundURL = false; if(imageGroup){ TB_TempArray = jQuery("a[rel="+imageGroup+"]").get(); for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) { var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString); if (!(TB_TempArray[TB_Counter].href == url)) { if (TB_FoundURL) { TB_NextCaption = TB_TempArray[TB_Counter].title; TB_NextURL = TB_TempArray[TB_Counter].href; TB_NextHTML = "  "+thickboxL10n.next+""; } else { TB_PrevCaption = TB_TempArray[TB_Counter].title; TB_PrevURL = TB_TempArray[TB_Counter].href; TB_PrevHTML = "  "+thickboxL10n.prev+""; } } else { TB_FoundURL = true; TB_imageCount = thickboxL10n.image + ' ' + (TB_Counter + 1) + ' ' + thickboxL10n.of + ' ' + (TB_TempArray.length); } } } imgPreloader = new Image(); imgPreloader.onload = function(){ imgPreloader.onload = null; // Resizing large images - original by Christian Montoya edited by me. var pagesize = tb_getPageSize(); var x = pagesize[0] - 150; var y = pagesize[1] - 150; var imageWidth = imgPreloader.width; var imageHeight = imgPreloader.height; if (imageWidth > x) { imageHeight = imageHeight * (x / imageWidth); imageWidth = x; if (imageHeight > y) { imageWidth = imageWidth * (y / imageHeight); imageHeight = y; } } else if (imageHeight > y) { imageWidth = imageWidth * (y / imageHeight); imageHeight = y; if (imageWidth > x) { imageHeight = imageHeight * (x / imageWidth); imageWidth = x; } } // End Resizing TB_WIDTH = imageWidth + 30; TB_HEIGHT = imageHeight + 60; jQuery("#TB_window").append(""+thickboxL10n.close+""+caption+"" + "
"+caption+"
" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "
"); jQuery("#TB_closeWindowButton").on( 'click', tb_remove ); if (!(TB_PrevHTML === "")) { function goPrev(){ if(jQuery(document).off("click",goPrev)){jQuery(document).off("click",goPrev);} jQuery("#TB_window").remove(); jQuery("body").append("
"); tb_show(TB_PrevCaption, TB_PrevURL, imageGroup); return false; } jQuery("#TB_prev").on( 'click', goPrev ); } if (!(TB_NextHTML === "")) { function goNext(){ jQuery("#TB_window").remove(); jQuery("body").append("
"); tb_show(TB_NextCaption, TB_NextURL, imageGroup); return false; } jQuery("#TB_next").on( 'click', goNext ); } jQuery(document).on('keydown.thickbox', function(e){ if ( e.which == 27 ){ // close tb_remove(); } else if ( e.which == 190 ){ // display previous image if(!(TB_NextHTML == "")){ jQuery(document).off('thickbox'); goNext(); } } else if ( e.which == 188 ){ // display next image if(!(TB_PrevHTML == "")){ jQuery(document).off('thickbox'); goPrev(); } } return false; }); tb_position(); jQuery("#TB_load").remove(); jQuery("#TB_ImageOff").on( 'click', tb_remove ); jQuery("#TB_window").css({'visibility':'visible'}); //for safari using css instead of show }; imgPreloader.src = url; }else{//code to show html var queryString = url.replace(/^[^\?]+\??/,''); var params = tb_parseQuery( queryString ); TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no parameters were added to URL TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no parameters were added to URL ajaxContentW = TB_WIDTH - 30; ajaxContentH = TB_HEIGHT - 45; if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window urlNoQuery = url.split('TB_'); jQuery("#TB_iframeContent").remove(); if(params['modal'] != "true"){//iframe no modal jQuery("#TB_window").append("
"+caption+"
"); }else{//iframe modal jQuery("#TB_overlay").off(); jQuery("#TB_window").append(""); } }else{// not an iframe, ajax if(jQuery("#TB_window").css("visibility") != "visible"){ if(params['modal'] != "true"){//ajax no modal jQuery("#TB_window").append("
"+caption+"
"); }else{//ajax modal jQuery("#TB_overlay").off(); jQuery("#TB_window").append("
"); } }else{//this means the window is already up, we are just loading new content via ajax jQuery("#TB_ajaxContent")[0].style.width = ajaxContentW +"px"; jQuery("#TB_ajaxContent")[0].style.height = ajaxContentH +"px"; jQuery("#TB_ajaxContent")[0].scrollTop = 0; jQuery("#TB_ajaxWindowTitle").html(caption); } } jQuery("#TB_closeWindowButton").on( 'click', tb_remove ); if(url.indexOf('TB_inline') != -1){ jQuery("#TB_ajaxContent").append(jQuery('#' + params['inlineId']).children()); jQuery("#TB_window").on('tb_unload', function () { jQuery('#' + params['inlineId']).append( jQuery("#TB_ajaxContent").children() ); // move elements back when you're finished }); tb_position(); jQuery("#TB_load").remove(); jQuery("#TB_window").css({'visibility':'visible'}); }else if(url.indexOf('TB_iframe') != -1){ tb_position(); jQuery("#TB_load").remove(); jQuery("#TB_window").css({'visibility':'visible'}); }else{ var load_url = url; load_url += -1 === url.indexOf('?') ? '?' : '&'; jQuery("#TB_ajaxContent").load(load_url += "random=" + (new Date().getTime()),function(){//to do a post change this load method tb_position(); jQuery("#TB_load").remove(); tb_init("#TB_ajaxContent a.thickbox"); jQuery("#TB_window").css({'visibility':'visible'}); }); } } if(!params['modal']){ jQuery(document).on('keydown.thickbox', function(e){ if ( e.which == 27 ){ // close tb_remove(); return false; } }); } $closeBtn = jQuery( '#TB_closeWindowButton' ); /* * If the native Close button icon is visible, move focus on the button * (e.g. in the Network Admin Themes screen). * In other admin screens is hidden and replaced by a different icon. */ if ( $closeBtn.find( '.tb-close-icon' ).is( ':visible' ) ) { $closeBtn.trigger( 'focus' ); } } catch(e) { //nothing here } } //helper functions below function tb_showIframe(){ jQuery("#TB_load").remove(); jQuery("#TB_window").css({'visibility':'visible'}).trigger( 'thickbox:iframe:loaded' ); } function tb_remove() { jQuery("#TB_imageOff").off("click"); jQuery("#TB_closeWindowButton").off("click"); jQuery( '#TB_window' ).fadeOut( 'fast', function() { jQuery( '#TB_window, #TB_overlay, #TB_HideSelect' ).trigger( 'tb_unload' ).off().remove(); jQuery( 'body' ).trigger( 'thickbox:removed' ); }); jQuery( 'body' ).removeClass( 'modal-open' ); jQuery("#TB_load").remove(); if (typeof document.body.style.maxHeight == "undefined") {//if IE 6 jQuery("body","html").css({height: "auto", width: "auto"}); jQuery("html").css("overflow",""); } jQuery(document).off('.thickbox'); return false; } function tb_position() { var isIE6 = typeof document.body.style.maxHeight === "undefined"; jQuery("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'}); if ( ! isIE6 ) { // take away IE6 jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'}); } } function tb_parseQuery ( query ) { var Params = {}; if ( ! query ) {return Params;}// return empty object var Pairs = query.split(/[;&]/); for ( var i = 0; i < Pairs.length; i++ ) { var KeyVal = Pairs[i].split('='); if ( ! KeyVal || KeyVal.length != 2 ) {continue;} var key = unescape( KeyVal[0] ); var val = unescape( KeyVal[1] ); val = val.replace(/\+/g, ' '); Params[key] = val; } return Params; } function tb_getPageSize(){ var de = document.documentElement; var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth; var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight; arrayPageSize = [w,h]; return arrayPageSize; } function tb_detectMacXFF() { var userAgent = navigator.userAgent.toLowerCase(); if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) { return true; } } thickbox/macFFBgHack.png000064400000000136152436173310011106 0ustar00PNG  IHDRc%IDATH! _jM H$D"H_,!ZIENDB`thickbox/loadingAnimation.gif000064400000035606152436173310012342 0ustar00GIF89a! NETSCAPE2.0! ,DRihlp,tmx| Ȥrl:P'@0ج(E X\zlXifZunYrt|n~Yzd `w^xoE% U ~¶Ʊ̯ϺsҿeշsjF )Łl?J4aÁ'&h1 D%r#Ȑ #0$0#J#I|y0&ɏ4)dYI6;L;y PJLXf 3kT`h{׮U!%kT jmjZs}/Vu-w/Tbv+XqaÈ7X|_^-|€Ϡ=倁ӨQZ[c^eǦ]wtԼ}\pˍ778 {׽?W{֥g Do`# ^A}G ~Gp H`}1߁ Χv`\! )rx%(!. `%:DXA EciJ4d;)VLR@!:ZdY%S)&`x&ij&m#my_:%)ـXԩ@@mꀠ#2 .*飉F褙x 桜R*꟠R香Zjj) `+l`a ,Ų촽.F{.,j-^ .Ǝ, KlZJ/޶Kλ/K믻{ |K/ X 00GļT|/ h "p?{| =61/@$S.|뼾ʓ?~ˏ#[=kG~Vg-/YX'6 { ˰W=sMb ~b gAaa0 L<SM.vp!nN }D?Lx%L,xuOoDF1[zpvjq4+W fG 18c?a&:=t8n ntZt"#Q5.td#-H.F2WtV%WM*IQr2Y:RnX/=x~c1HC"m082zd&Hc>OuE$npU(7=2A'Pp ;Ce(UNԝV,5K-ELU] (i9OP֒1E^H" XͪVծz3`dhMZךZ\!! ,Ldihlp,tmx|A+Ȥrl:&DX-ƴJ,,c*ayU65{iuVV잠sd}rW{\o`y t|vq(kx)u~z)w', D,+)**()ɲë'Ĺ(ձѽ&&ٰ%&A, p@PA pEA 8ྈ.lE 28"ICU$D9eɏ,ErL1f)m9fG4i.,HEg'Xx:*ZJU [v5-[dpkDܷ'r*lִ*5W-_".!B&Q8dX5bb9`4,>iԞAv=*T´m)t^vn٭h嵍GDqWWq8 ɹ/~sѱ|ܣ(@@8hϢ~ I~}ՙ`%, x߃7 BH " 0Ha}v)lh83FXc%袊D`A-,耐CYAI+i$?RYPf$ Vɣ"%\:ejBXh& E>[)f#Ly uv)hg!~y#9g^tYܩ.6`iDbk*難Rǩ)F) V*eJ:+6jl.[ D W$"p,H ih*H;mfm~n徛.` 䚋+n ڛB0( .6 m&{S ̋1 䍋1 @Op3.Ls0}< tl4 ?|tN\4HO}B^J[]rI?m ,Mk`#k u,t1xM2|+W,Ȃ}[3k.Sy cQg92n:B6^65ֶk u>|WN{ 76og\ǣG={%x=mܫ/1oݿ=_ǿS8oz Lۧ,y>{{'rx3Hɐ#! 9I2a 쭬pyK\3n<]@:m.RէѾ$ * Jo_? D>~)\¡2֩Jq-+{& qD.'馭;Ξ֗K KG$>>z388#"3, K K GG>>ƹ;@}# =~䵫V\(q~%D N,A3P4%2Ui摜>}N6 P1BuIVG<*iMD}xY'֯=N% 2`9+]N>{D.a>+±À ~7q} wV؇eј= |9r8NC!гg zpkگK ‷ 4XEq3D9NjK/>qҩ/!=zCg9G7`!DqPXDsQuxąj&+ (fȠu,H.Zhud=8a)]K\OC*Bf9u.4$8crI@酙Txe^fgi!掇 jf iJ& v` .$Ĩ Ҋ*.ꭹk>+ڊ$L;k>JKv+ˢ.؎.Blzz&P.K; //<p.|1 KkS3 wl2 *v,)ӯb*=}j/w~Nyˌ?￷3揀_1f~T  (AEPt Y2muK=q^=݅_[XЅ%dC0UطְKF> 1^7)Fsx?T61zaDnuZDȨmC׶fz\H-3ݮBP!^$=J&lGօ(3ѕL+e5rR"IKl2l\/s5$ri %Ij@ڐ$r vf'Lbf,f5)Nd)4*Qy3>\:}3\Q;aɹ^g;멹Zp ' I8Ne{"Dȉ0ShEYl5DhⰡJ8Ҍ* eAN%?x~=OT555 ƄԦ:PTJժZXͪVU* %] XJֲhMZ! ,Ldihlp,tmx|﫣pH,ȤrtAZX i  ŕRUW 5ᵪE_c{/ysmu)ix[}pbz|Uwr{n+t')j1, ,+'**())ɫ&Ͻ%(ǹ'۷-A* ,ǂ?O_ װA U0$⿉:Da0F"-&1Ƒ'J\H~iD){̩&Lh"ESOJRf]u\6zve@ںs5WkԴ@-Aw0`vW 낁e0@),.c~ygKysϫ'.tM'D6IFm*N;Y Mܷݵ{69貱;FWX_Pˣ`_`{? Ⳡ~{@}|'w"V{`)(X(dzImx"|$&"/+*`#ӂ4hcf͸8(b==p#i LycrBVn Hb,<\:y馗k9 e‰_>h D!e9 %(H6ʣ()~.z)X('zvxsj蔈Bj*jBZ*록j+ ,V  .`wlӦ:;l,$k-BK .@+m^m ۮm«BR p(nn2̭ྛ# k/&Lqz;OuΜ~:tm з>|[>;{}CgO]O>߽:yI[^]KS 8?R0kdZo7 &KdL`B2sdwWB^0~^0?Y~ ֱ" نh"0HdD=Q\wD# 8_-Vw[I 56{XA;jNpG9 O~]fF.{[:I2zx[3?>g=IPnq#%*wJKO\`(q,d =q%!:Fё#1e&j4_KDJS{&-7n%7/6pB~-,)OM*MyO63 2LjS0PLB|hzЅ:pEf6#Q7R2ڳJ'},9ŕrQy̘/բKU9E𝲧Jqәtc*.Lk6բu*/ R^T}Tdnի]( i&hMZֶ& fm\J׺u`B! , PLdihlp,tmx|醙pH,Ȥrɜ8H( BDvѐNW֖|'V VzW%S0]5buez)m}-yj v~*s(wx`Y'|'%%, ,+$**())ΰý±Ķ('ݪڼ,O ,T/ߊ}N\!P=*p`A}VtcB -v< zH)$j & &S4$82bɖ:$(& 6Uhl:銫XJլPU bSVs[,ݭj_Vݎ \xB޴Q% kF`, >ɊΞ^!iU,P=tγY׆}jڮmz֯5[wU07s=tɱ/\o(Coh+ /ЀUaЖݡ_}ʕ,M$_ 7 8߂!|fX JH ȡ&8X !28 "a]:0 hB9#cԈ/#$ ='BE:pdE MX&) T$M~cYf$N[rg駚3bM:a[4p(A:!h{IBB)=vzߧN# jꪱ6Zi bz+"+,h :v, y ²: m&؎+m*Ϯmߞ{m%n+/.$m  Sko{0 0P13K+L22:O-{|, +|2)k3 27s/Jʹ8?3YW\p m_0Z.q 0^O-qet,7}8pn BRnӊ\3(`u!Mu$lӍNШzױ^Ԟ /mk9>շ;޻ۻS~nOV|Oا}ף-^>?ϽOݺ_m~ӟ,/]gdF<]+c] ρà6 u1궃ZDd2oe EcQZwn#ֲ.sLb+(>X|XEԋ.iS)PijwTl GGя&r-h09ՁVL*AP"QmXJֲhMZֶpk@! ,`HSihlp,tmx|AȤrl:ШCuAG+ht`xY_]>aWvk_,dfopikm}**zr)yl|(t/ %T r.. V-,ýǠ'Ƹ+*(ֿ+*,-߰)A)[U .#Dh"Z ` }Xذ`hq_F0P#CE4Y1%F+(Đ_͘8]yRdϋ$L@A ~) OYDm0ՅUTSl*ְ(f]u hOu+V*]m㚀Y|6{"0zKf;8UkױY&0p bUiC?͢'vtj٫is~"lһmVzEmL)|npUup罉6)jc_} PkY/=*~}G-ހ`~g߃),ȟ Q!~'`!+|(:E Q.N., =xD#@I;࣍Cd/FV$L9ERi% ^&–f Sy($PH5 &rhbc  KRbJ9OBz ʧ6'F䧫z%=飝"jj((pYR-(> @Ǻ`m -,| r ffA P/ j׺B0v[-2 Gnh@$p~%[̲ zr ܱo 1ܲ˼|(q> L#})EK =c)۲le/ NM=q2c'M=8߁m54cLp'R3.M z4}&yԜ;Z@[:w.۩Km{[;W>tx7ߗ7/K?Уn} /?x;;}OomL4[. isTvux[{}bm,o~gk+_w* W B,ƾ¶ǿ+ïʵռ*f)(ꗄ"#FEE (:!C&`ď"-flh#ʔ Is hQ0e>TcѝYX$ %ׯ&aѠlY1`Ӧ ۷gèv슷h oz%pm{໅7fx1Ǝqȗ1? 3qՀv1Mvm] ^m ͻ…/7䶗3-3u;~=wvǹg/ۿg>=/`kN i8 +x  a& *8 NH!a !*(!Ņ6'b?Ȣ>n\ओV8E' Y'qRy[va٧zyP4D*(Mb9Cr6 % Yn@*Tzډ>)*ꨩ©k Z뮷 kJ6ʯ(` (p .[  v;/./z |n| c[&ROL131 {01 _[ .njL3 ¼ 3w8L6"9-t/ tS?Mt;BVtZg[x?5_omtYǝ<2)g|0|2 0>8!}8K~9 ;8*~/z>:}hnL^Jov c]Í+{ '^خ>TcˢߋXٖ.0ys=?%0˿' m8Z|[8#,n@+B 0|"8lT!XX=0#|<0>a ]ݏst 8""Sb.'j̀ [ fEa[Wx1mI1\XTleB)#XF=fx#G[4 Y1<$/&{$#1EN2b|%A9GRaqĖE:)s7W.Ww0)K~sc´%+KqrafRԛXl6ώ֤Pkyڌ7׽|B& kӛ^7Yw:WK\#3y]elf7q2-EX} (G+l+a&pQltd'KɗS)җW7~vW1}晣G>{O~|wG]~&_Y})Gw1M)*PH(! Zj)x"N0 %^(4Rb ᘣ(B(-"yD ,%d6" O˜W 6p"Ș9`& bI—Pg gXYw#%s:a9%PX虖J)@ ,Х ")0 @~%Ċ +:+ **Z+"++zl ,({FZ[-b[..j-$0޻켼Po# 쯸׻pp0#<c 1 GL2\B1&k0.Rln6 mn9=Z-+CC\4G{Z_:nc8ׇ=ۏy 3oo7> x>ݏ֘ ;AvjުX/  (.zs 8AHA" %5\{` W1뱏r"ĸ){X?(qqBlbCubGǵ;<40ie ZFrl#zC1{HVPp[b6.zT"iE*iDd*IjS$>YPJыӣ 8HحQ\wlrKYޒh[+VG*j$;v8O!,jNΚ&#jS{LYiW 0L c;O"s\f_@~ 4.τvp=!: qst8hIsJ8dF14si/RBҥu@Ӛ8ͩNw@ PJT%;thickbox/.listing000064400000000631152436173310010036 0ustar00drwxr-xr-x 2 2036668 2036668 96 Dec 04 2014 . drwxr-xr-x 13 2036668 2036668 4096 Sep 03 2019 .. -rw-r--r-- 1 2036668 2036668 15238 Dec 04 2014 loadingAnimation.gif -rw-r--r-- 1 2036668 2036668 94 Dec 04 2014 macFFBgHack.png -rw-r--r-- 1 2036668 2036668 2658 Apr 25 2018 thickbox.css -rw-r--r-- 1 2036668 2036668 13163 Aug 18 2016 thickbox.js thickbox/thickbox.css000066400000005154152436173310010720 0ustar00#TB_overlay { background: #000; opacity: 0.7; filter: alpha(opacity=70); position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 100050; /* Above DFW. */ } #TB_window { position: fixed; background-color: #fff; z-index: 100050; /* Above DFW. */ visibility: hidden; text-align: left; top: 50%; left: 50%; -webkit-box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 ); box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 ); } #TB_window img#TB_Image { display: block; margin: 15px 0 0 15px; border-right: 1px solid #ccc; border-bottom: 1px solid #ccc; border-top: 1px solid #666; border-left: 1px solid #666; } #TB_caption{ height: 25px; padding: 7px 30px 10px 25px; float: left; } #TB_closeWindow { height: 25px; padding: 11px 25px 10px 0; float: right; } #TB_closeWindowButton { position: absolute; left: auto; right: 0; width: 29px; height: 29px; border: 0; padding: 0; background: none; cursor: pointer; outline: none; -webkit-transition: color .1s ease-in-out, background .1s ease-in-out; transition: color .1s ease-in-out, background .1s ease-in-out; } #TB_ajaxWindowTitle { float: left; font-weight: 600; line-height: 29px; overflow: hidden; padding: 0 29px 0 10px; text-overflow: ellipsis; white-space: nowrap; width: calc( 100% - 39px ); } #TB_title { background: #fcfcfc; border-bottom: 1px solid #ddd; height: 29px; } #TB_ajaxContent { clear: both; padding: 2px 15px 15px 15px; overflow: auto; text-align: left; line-height: 1.4em; } #TB_ajaxContent.TB_modal { padding: 15px; } #TB_ajaxContent p { padding: 5px 0px 5px 0px; } #TB_load { position: fixed; display: none; z-index: 100050; top: 50%; left: 50%; background-color: #E8E8E8; border: 1px solid #555; margin: -45px 0 0 -125px; padding: 40px 15px 15px; } #TB_HideSelect { z-index: 99; position: fixed; top: 0; left: 0; background-color: #fff; border: none; filter: alpha(opacity=0); opacity: 0; height: 100%; width: 100%; } #TB_iframeContent { clear: both; border: none; } .tb-close-icon { display: block; color: #666; text-align: center; line-height: 29px; width: 29px; height: 29px; position: absolute; top: 0; right: 0; } .tb-close-icon:before { content: "\f158"; content: "\f158" / ''; font: normal 20px/29px dashicons; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } #TB_closeWindowButton:hover .tb-close-icon, #TB_closeWindowButton:focus .tb-close-icon { color: #006799; } #TB_closeWindowButton:focus .tb-close-icon { -webkit-box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8); box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, .8); } colorpicker.js000064400000070633152436173310007434 0ustar00// =================================================================== // Author: Matt Kruse // WWW: http://www.mattkruse.com/ // // NOTICE: You may use this code for any purpose, commercial or // private, without any further permission from the author. You may // remove this notice from your final code if you wish, however it is // appreciated by the author if at least my web site address is kept. // // You may *NOT* re-distribute this code in any way except through its // use. That means, you can include it in your product, or your web // site, or any other form where the code is actually being used. You // may not put the plain javascript up on your site for download or // include it in your javascript libraries for download. // If you wish to share this code with others, please just point them // to the URL instead. // Please DO NOT link directly to my .js files from your site. Copy // the files to your server and use them there. Thank you. // =================================================================== /* SOURCE FILE: AnchorPosition.js */ /* AnchorPosition.js Author: Matt Kruse Last modified: 10/11/02 DESCRIPTION: These functions find the position of an tag in a document, so other elements can be positioned relative to it. COMPATABILITY: Netscape 4.x,6.x,Mozilla, IE 5.x,6.x on Windows. Some small positioning errors - usually with Window positioning - occur on the Macintosh platform. FUNCTIONS: getAnchorPosition(anchorname) Returns an Object() having .x and .y properties of the pixel coordinates of the upper-left corner of the anchor. Position is relative to the PAGE. getAnchorWindowPosition(anchorname) Returns an Object() having .x and .y properties of the pixel coordinates of the upper-left corner of the anchor, relative to the WHOLE SCREEN. NOTES: 1) For popping up separate browser windows, use getAnchorWindowPosition. Otherwise, use getAnchorPosition 2) Your anchor tag MUST contain both NAME and ID attributes which are the same. For example: 3) There must be at least a space between for IE5.5 to see the anchor tag correctly. Do not do with no space. */ // getAnchorPosition(anchorname) // This function returns an object having .x and .y properties which are the coordinates // of the named anchor, relative to the page. function getAnchorPosition(anchorname) { // This function will return an Object with x and y properties var useWindow=false; var coordinates=new Object(); var x=0,y=0; // Browser capability sniffing var use_gebi=false, use_css=false, use_layers=false; if (document.getElementById) { use_gebi=true; } else if (document.all) { use_css=true; } else if (document.layers) { use_layers=true; } // Logic to find position if (use_gebi && document.all) { x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]); y=AnchorPosition_getPageOffsetTop(document.all[anchorname]); } else if (use_gebi) { var o=document.getElementById(anchorname); x=AnchorPosition_getPageOffsetLeft(o); y=AnchorPosition_getPageOffsetTop(o); } else if (use_css) { x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]); y=AnchorPosition_getPageOffsetTop(document.all[anchorname]); } else if (use_layers) { var found=0; for (var i=0; i tags may cause errors. USAGE: // Create an object for a WINDOW popup var win = new PopupWindow(); // Create an object for a DIV window using the DIV named 'mydiv' var win = new PopupWindow('mydiv'); // Set the window to automatically hide itself when the user clicks // anywhere else on the page except the popup win.autoHide(); // Show the window relative to the anchor name passed in win.showPopup(anchorname); // Hide the popup win.hidePopup(); // Set the size of the popup window (only applies to WINDOW popups win.setSize(width,height); // Populate the contents of the popup window that will be shown. If you // change the contents while it is displayed, you will need to refresh() win.populate(string); // set the URL of the window, rather than populating its contents // manually win.setUrl("http://www.site.com/"); // Refresh the contents of the popup win.refresh(); // Specify how many pixels to the right of the anchor the popup will appear win.offsetX = 50; // Specify how many pixels below the anchor the popup will appear win.offsetY = 100; NOTES: 1) Requires the functions in AnchorPosition.js 2) Your anchor tag MUST contain both NAME and ID attributes which are the same. For example: 3) There must be at least a space between for IE5.5 to see the anchor tag correctly. Do not do with no space. 4) When a PopupWindow object is created, a handler for 'onmouseup' is attached to any event handler you may have already defined. Do NOT define an event handler for 'onmouseup' after you define a PopupWindow object or the autoHide() will not work correctly. */ // Set the position of the popup window based on the anchor function PopupWindow_getXYPosition(anchorname) { var coordinates; if (this.type == "WINDOW") { coordinates = getAnchorWindowPosition(anchorname); } else { coordinates = getAnchorPosition(anchorname); } this.x = coordinates.x; this.y = coordinates.y; } // Set width/height of DIV/popup window function PopupWindow_setSize(width,height) { this.width = width; this.height = height; } // Fill the window with contents function PopupWindow_populate(contents) { this.contents = contents; this.populated = false; } // Set the URL to go to function PopupWindow_setUrl(url) { this.url = url; } // Set the window popup properties function PopupWindow_setWindowProperties(props) { this.windowProperties = props; } // Refresh the displayed contents of the popup function PopupWindow_refresh() { if (this.divName != null) { // refresh the DIV object if (this.use_gebi) { document.getElementById(this.divName).innerHTML = this.contents; } else if (this.use_css) { document.all[this.divName].innerHTML = this.contents; } else if (this.use_layers) { var d = document.layers[this.divName]; d.document.open(); d.document.writeln(this.contents); d.document.close(); } } else { if (this.popupWindow != null && !this.popupWindow.closed) { if (this.url!="") { this.popupWindow.location.href=this.url; } else { this.popupWindow.document.open(); this.popupWindow.document.writeln(this.contents); this.popupWindow.document.close(); } this.popupWindow.focus(); } } } // Position and show the popup, relative to an anchor object function PopupWindow_showPopup(anchorname) { this.getXYPosition(anchorname); this.x += this.offsetX; this.y += this.offsetY; if (!this.populated && (this.contents != "")) { this.populated = true; this.refresh(); } if (this.divName != null) { // Show the DIV object if (this.use_gebi) { document.getElementById(this.divName).style.left = this.x + "px"; document.getElementById(this.divName).style.top = this.y; document.getElementById(this.divName).style.visibility = "visible"; } else if (this.use_css) { document.all[this.divName].style.left = this.x; document.all[this.divName].style.top = this.y; document.all[this.divName].style.visibility = "visible"; } else if (this.use_layers) { document.layers[this.divName].left = this.x; document.layers[this.divName].top = this.y; document.layers[this.divName].visibility = "visible"; } } else { if (this.popupWindow == null || this.popupWindow.closed) { // If the popup window will go off-screen, move it so it doesn't if (this.x<0) { this.x=0; } if (this.y<0) { this.y=0; } if (screen && screen.availHeight) { if ((this.y + this.height) > screen.availHeight) { this.y = screen.availHeight - this.height; } } if (screen && screen.availWidth) { if ((this.x + this.width) > screen.availWidth) { this.x = screen.availWidth - this.width; } } var avoidAboutBlank = window.opera || ( document.layers && !navigator.mimeTypes['*'] ) || navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled ); this.popupWindow = window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+""); } this.refresh(); } } // Hide the popup function PopupWindow_hidePopup() { if (this.divName != null) { if (this.use_gebi) { document.getElementById(this.divName).style.visibility = "hidden"; } else if (this.use_css) { document.all[this.divName].style.visibility = "hidden"; } else if (this.use_layers) { document.layers[this.divName].visibility = "hidden"; } } else { if (this.popupWindow && !this.popupWindow.closed) { this.popupWindow.close(); this.popupWindow = null; } } } // Pass an event and return whether or not it was the popup DIV that was clicked function PopupWindow_isClicked(e) { if (this.divName != null) { if (this.use_layers) { var clickX = e.pageX; var clickY = e.pageY; var t = document.layers[this.divName]; if ((clickX > t.left) && (clickX < t.left+t.clip.width) && (clickY > t.top) && (clickY < t.top+t.clip.height)) { return true; } else { return false; } } else if (document.all) { // Need to hard-code this to trap IE for error-handling var t = window.event.srcElement; while (t.parentElement != null) { if (t.id==this.divName) { return true; } t = t.parentElement; } return false; } else if (this.use_gebi && e) { var t = e.originalTarget; while (t.parentNode != null) { if (t.id==this.divName) { return true; } t = t.parentNode; } return false; } return false; } return false; } // Check an onMouseDown event to see if we should hide function PopupWindow_hideIfNotClicked(e) { if (this.autoHideEnabled && !this.isClicked(e)) { this.hidePopup(); } } // Call this to make the DIV disable automatically when mouse is clicked outside it function PopupWindow_autoHide() { this.autoHideEnabled = true; } // This global function checks all PopupWindow objects onmouseup to see if they should be hidden function PopupWindow_hidePopupWindows(e) { for (var i=0; i0) { this.type="DIV"; this.divName = arguments[0]; } else { this.type="WINDOW"; } this.use_gebi = false; this.use_css = false; this.use_layers = false; if (document.getElementById) { this.use_gebi = true; } else if (document.all) { this.use_css = true; } else if (document.layers) { this.use_layers = true; } else { this.type = "WINDOW"; } this.offsetX = 0; this.offsetY = 0; // Method mappings this.getXYPosition = PopupWindow_getXYPosition; this.populate = PopupWindow_populate; this.setUrl = PopupWindow_setUrl; this.setWindowProperties = PopupWindow_setWindowProperties; this.refresh = PopupWindow_refresh; this.showPopup = PopupWindow_showPopup; this.hidePopup = PopupWindow_hidePopup; this.setSize = PopupWindow_setSize; this.isClicked = PopupWindow_isClicked; this.autoHide = PopupWindow_autoHide; this.hideIfNotClicked = PopupWindow_hideIfNotClicked; } /* SOURCE FILE: ColorPicker2.js */ /* Last modified: 02/24/2003 DESCRIPTION: This widget is used to select a color, in hexadecimal #RRGGBB form. It uses a color "swatch" to display the standard 216-color web-safe palette. The user can then click on a color to select it. COMPATABILITY: See notes in AnchorPosition.js and PopupWindow.js. Only the latest DHTML-capable browsers will show the color and hex values at the bottom as your mouse goes over them. USAGE: // Create a new ColorPicker object using DHTML popup var cp = new ColorPicker(); // Create a new ColorPicker object using Window Popup var cp = new ColorPicker('window'); // Add a link in your page to trigger the popup. For example: Pick // Or use the built-in "select" function to do the dirty work for you: Pick // If using DHTML popup, write out the required DIV tag near the bottom // of your page. // Write the 'pickColor' function that will be called when the user clicks // a color and do something with the value. This is only required if you // want to do something other than simply populate a form field, which is // what the 'select' function will give you. function pickColor(color) { field.value = color; } NOTES: 1) Requires the functions in AnchorPosition.js and PopupWindow.js 2) Your anchor tag MUST contain both NAME and ID attributes which are the same. For example: 3) There must be at least a space between for IE5.5 to see the anchor tag correctly. Do not do with no space. 4) When a ColorPicker object is created, a handler for 'onmouseup' is attached to any event handler you may have already defined. Do NOT define an event handler for 'onmouseup' after you define a ColorPicker object or the color picker will not hide itself correctly. */ ColorPicker_targetInput = null; function ColorPicker_writeDiv() { document.writeln(""); } function ColorPicker_show(anchorname) { this.showPopup(anchorname); } function ColorPicker_pickColor(color,obj) { obj.hidePopup(); pickColor(color); } // A Default "pickColor" function to accept the color passed back from popup. // User can over-ride this with their own function. function pickColor(color) { if (ColorPicker_targetInput==null) { alert("Target Input is null, which means you either didn't use the 'select' function or you have no defined your own 'pickColor' function to handle the picked color!"); return; } ColorPicker_targetInput.value = color; } // This function is the easiest way to popup the window, select a color, and // have the value populate a form field, which is what most people want to do. function ColorPicker_select(inputobj,linkname) { if (inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea") { alert("colorpicker.select: Input object passed is not a valid form input object"); window.ColorPicker_targetInput=null; return; } window.ColorPicker_targetInput = inputobj; this.show(linkname); } // This function runs when you move your mouse over a color block, if you have a newer browser function ColorPicker_highlightColor(c) { var thedoc = (arguments.length>1)?arguments[1]:window.document; var d = thedoc.getElementById("colorPickerSelectedColor"); d.style.backgroundColor = c; d = thedoc.getElementById("colorPickerSelectedColorValue"); d.innerHTML = c; } function ColorPicker() { var windowMode = false; // Create a new PopupWindow object if (arguments.length==0) { var divname = "colorPickerDiv"; } else if (arguments[0] == "window") { var divname = ''; windowMode = true; } else { var divname = arguments[0]; } if (divname != "") { var cp = new PopupWindow(divname); } else { var cp = new PopupWindow(); cp.setSize(225,250); } // Object variables cp.currentValue = "#FFFFFF"; // Method Mappings cp.writeDiv = ColorPicker_writeDiv; cp.highlightColor = ColorPicker_highlightColor; cp.show = ColorPicker_show; cp.select = ColorPicker_select; // Code to populate color picker window var colors = new Array( "#4180B6","#69AEE7","#000000","#000033","#000066","#000099","#0000CC","#0000FF","#330000","#330033","#330066","#330099", "#3300CC","#3300FF","#660000","#660033","#660066","#660099","#6600CC","#6600FF","#990000","#990033","#990066","#990099", "#9900CC","#9900FF","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#FF0000","#FF0033","#FF0066","#FF0099", "#FF00CC","#FF00FF","#7FFFFF","#7FFFFF","#7FF7F7","#7FEFEF","#7FE7E7","#7FDFDF","#7FD7D7","#7FCFCF","#7FC7C7","#7FBFBF", "#7FB7B7","#7FAFAF","#7FA7A7","#7F9F9F","#7F9797","#7F8F8F","#7F8787","#7F7F7F","#7F7777","#7F6F6F","#7F6767","#7F5F5F", "#7F5757","#7F4F4F","#7F4747","#7F3F3F","#7F3737","#7F2F2F","#7F2727","#7F1F1F","#7F1717","#7F0F0F","#7F0707","#7F0000", "#4180B6","#69AEE7","#003300","#003333","#003366","#003399","#0033CC","#0033FF","#333300","#333333","#333366","#333399", "#3333CC","#3333FF","#663300","#663333","#663366","#663399","#6633CC","#6633FF","#993300","#993333","#993366","#993399", "#9933CC","#9933FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#FF3300","#FF3333","#FF3366","#FF3399", "#FF33CC","#FF33FF","#FF7FFF","#FF7FFF","#F77FF7","#EF7FEF","#E77FE7","#DF7FDF","#D77FD7","#CF7FCF","#C77FC7","#BF7FBF", "#B77FB7","#AF7FAF","#A77FA7","#9F7F9F","#977F97","#8F7F8F","#877F87","#7F7F7F","#777F77","#6F7F6F","#677F67","#5F7F5F", "#577F57","#4F7F4F","#477F47","#3F7F3F","#377F37","#2F7F2F","#277F27","#1F7F1F","#177F17","#0F7F0F","#077F07","#007F00", "#4180B6","#69AEE7","#006600","#006633","#006666","#006699","#0066CC","#0066FF","#336600","#336633","#336666","#336699", "#3366CC","#3366FF","#666600","#666633","#666666","#666699","#6666CC","#6666FF","#996600","#996633","#996666","#996699", "#9966CC","#9966FF","#CC6600","#CC6633","#CC6666","#CC6699","#CC66CC","#CC66FF","#FF6600","#FF6633","#FF6666","#FF6699", "#FF66CC","#FF66FF","#FFFF7F","#FFFF7F","#F7F77F","#EFEF7F","#E7E77F","#DFDF7F","#D7D77F","#CFCF7F","#C7C77F","#BFBF7F", "#B7B77F","#AFAF7F","#A7A77F","#9F9F7F","#97977F","#8F8F7F","#87877F","#7F7F7F","#77777F","#6F6F7F","#67677F","#5F5F7F", "#57577F","#4F4F7F","#47477F","#3F3F7F","#37377F","#2F2F7F","#27277F","#1F1F7F","#17177F","#0F0F7F","#07077F","#00007F", "#4180B6","#69AEE7","#009900","#009933","#009966","#009999","#0099CC","#0099FF","#339900","#339933","#339966","#339999", "#3399CC","#3399FF","#669900","#669933","#669966","#669999","#6699CC","#6699FF","#999900","#999933","#999966","#999999", "#9999CC","#9999FF","#CC9900","#CC9933","#CC9966","#CC9999","#CC99CC","#CC99FF","#FF9900","#FF9933","#FF9966","#FF9999", "#FF99CC","#FF99FF","#3FFFFF","#3FFFFF","#3FF7F7","#3FEFEF","#3FE7E7","#3FDFDF","#3FD7D7","#3FCFCF","#3FC7C7","#3FBFBF", "#3FB7B7","#3FAFAF","#3FA7A7","#3F9F9F","#3F9797","#3F8F8F","#3F8787","#3F7F7F","#3F7777","#3F6F6F","#3F6767","#3F5F5F", "#3F5757","#3F4F4F","#3F4747","#3F3F3F","#3F3737","#3F2F2F","#3F2727","#3F1F1F","#3F1717","#3F0F0F","#3F0707","#3F0000", "#4180B6","#69AEE7","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#33CC00","#33CC33","#33CC66","#33CC99", "#33CCCC","#33CCFF","#66CC00","#66CC33","#66CC66","#66CC99","#66CCCC","#66CCFF","#99CC00","#99CC33","#99CC66","#99CC99", "#99CCCC","#99CCFF","#CCCC00","#CCCC33","#CCCC66","#CCCC99","#CCCCCC","#CCCCFF","#FFCC00","#FFCC33","#FFCC66","#FFCC99", "#FFCCCC","#FFCCFF","#FF3FFF","#FF3FFF","#F73FF7","#EF3FEF","#E73FE7","#DF3FDF","#D73FD7","#CF3FCF","#C73FC7","#BF3FBF", "#B73FB7","#AF3FAF","#A73FA7","#9F3F9F","#973F97","#8F3F8F","#873F87","#7F3F7F","#773F77","#6F3F6F","#673F67","#5F3F5F", "#573F57","#4F3F4F","#473F47","#3F3F3F","#373F37","#2F3F2F","#273F27","#1F3F1F","#173F17","#0F3F0F","#073F07","#003F00", "#4180B6","#69AEE7","#00FF00","#00FF33","#00FF66","#00FF99","#00FFCC","#00FFFF","#33FF00","#33FF33","#33FF66","#33FF99", "#33FFCC","#33FFFF","#66FF00","#66FF33","#66FF66","#66FF99","#66FFCC","#66FFFF","#99FF00","#99FF33","#99FF66","#99FF99", "#99FFCC","#99FFFF","#CCFF00","#CCFF33","#CCFF66","#CCFF99","#CCFFCC","#CCFFFF","#FFFF00","#FFFF33","#FFFF66","#FFFF99", "#FFFFCC","#FFFFFF","#FFFF3F","#FFFF3F","#F7F73F","#EFEF3F","#E7E73F","#DFDF3F","#D7D73F","#CFCF3F","#C7C73F","#BFBF3F", "#B7B73F","#AFAF3F","#A7A73F","#9F9F3F","#97973F","#8F8F3F","#87873F","#7F7F3F","#77773F","#6F6F3F","#67673F","#5F5F3F", "#57573F","#4F4F3F","#47473F","#3F3F3F","#37373F","#2F2F3F","#27273F","#1F1F3F","#17173F","#0F0F3F","#07073F","#00003F", "#4180B6","#69AEE7","#FFFFFF","#FFEEEE","#FFDDDD","#FFCCCC","#FFBBBB","#FFAAAA","#FF9999","#FF8888","#FF7777","#FF6666", "#FF5555","#FF4444","#FF3333","#FF2222","#FF1111","#FF0000","#FF0000","#FF0000","#FF0000","#EE0000","#DD0000","#CC0000", "#BB0000","#AA0000","#990000","#880000","#770000","#660000","#550000","#440000","#330000","#220000","#110000","#000000", "#000000","#000000","#000000","#001111","#002222","#003333","#004444","#005555","#006666","#007777","#008888","#009999", "#00AAAA","#00BBBB","#00CCCC","#00DDDD","#00EEEE","#00FFFF","#00FFFF","#00FFFF","#00FFFF","#11FFFF","#22FFFF","#33FFFF", "#44FFFF","#55FFFF","#66FFFF","#77FFFF","#88FFFF","#99FFFF","#AAFFFF","#BBFFFF","#CCFFFF","#DDFFFF","#EEFFFF","#FFFFFF", "#4180B6","#69AEE7","#FFFFFF","#EEFFEE","#DDFFDD","#CCFFCC","#BBFFBB","#AAFFAA","#99FF99","#88FF88","#77FF77","#66FF66", "#55FF55","#44FF44","#33FF33","#22FF22","#11FF11","#00FF00","#00FF00","#00FF00","#00FF00","#00EE00","#00DD00","#00CC00", "#00BB00","#00AA00","#009900","#008800","#007700","#006600","#005500","#004400","#003300","#002200","#001100","#000000", "#000000","#000000","#000000","#110011","#220022","#330033","#440044","#550055","#660066","#770077","#880088","#990099", "#AA00AA","#BB00BB","#CC00CC","#DD00DD","#EE00EE","#FF00FF","#FF00FF","#FF00FF","#FF00FF","#FF11FF","#FF22FF","#FF33FF", "#FF44FF","#FF55FF","#FF66FF","#FF77FF","#FF88FF","#FF99FF","#FFAAFF","#FFBBFF","#FFCCFF","#FFDDFF","#FFEEFF","#FFFFFF", "#4180B6","#69AEE7","#FFFFFF","#EEEEFF","#DDDDFF","#CCCCFF","#BBBBFF","#AAAAFF","#9999FF","#8888FF","#7777FF","#6666FF", "#5555FF","#4444FF","#3333FF","#2222FF","#1111FF","#0000FF","#0000FF","#0000FF","#0000FF","#0000EE","#0000DD","#0000CC", "#0000BB","#0000AA","#000099","#000088","#000077","#000066","#000055","#000044","#000033","#000022","#000011","#000000", "#000000","#000000","#000000","#111100","#222200","#333300","#444400","#555500","#666600","#777700","#888800","#999900", "#AAAA00","#BBBB00","#CCCC00","#DDDD00","#EEEE00","#FFFF00","#FFFF00","#FFFF00","#FFFF00","#FFFF11","#FFFF22","#FFFF33", "#FFFF44","#FFFF55","#FFFF66","#FFFF77","#FFFF88","#FFFF99","#FFFFAA","#FFFFBB","#FFFFCC","#FFFFDD","#FFFFEE","#FFFFFF", "#4180B6","#69AEE7","#FFFFFF","#FFFFFF","#FBFBFB","#F7F7F7","#F3F3F3","#EFEFEF","#EBEBEB","#E7E7E7","#E3E3E3","#DFDFDF", "#DBDBDB","#D7D7D7","#D3D3D3","#CFCFCF","#CBCBCB","#C7C7C7","#C3C3C3","#BFBFBF","#BBBBBB","#B7B7B7","#B3B3B3","#AFAFAF", "#ABABAB","#A7A7A7","#A3A3A3","#9F9F9F","#9B9B9B","#979797","#939393","#8F8F8F","#8B8B8B","#878787","#838383","#7F7F7F", "#7B7B7B","#777777","#737373","#6F6F6F","#6B6B6B","#676767","#636363","#5F5F5F","#5B5B5B","#575757","#535353","#4F4F4F", "#4B4B4B","#474747","#434343","#3F3F3F","#3B3B3B","#373737","#333333","#2F2F2F","#2B2B2B","#272727","#232323","#1F1F1F", "#1B1B1B","#171717","#131313","#0F0F0F","#0B0B0B","#070707","#030303","#000000","#000000","#000000","#000000","#000000"); var total = colors.length; var width = 72; var cp_contents = ""; var windowRef = (windowMode)?"window.opener.":""; if (windowMode) { cp_contents += "Select Color"; cp_contents += ""; } cp_contents += ""; var use_highlight = (document.getElementById || document.all)?true:false; for (var i=0; i '; if ( ((i+1)>=total) || (((i+1) % width) == 0)) { cp_contents += ""; } } // If the browser supports dynamically changing TD cells, add the fancy stuff if (document.getElementById) { var width1 = Math.floor(width/2); var width2 = width = width1; cp_contents += ""; } cp_contents += "
 #FFFFFF
"; if (windowMode) { cp_contents += "
"; } // end populate code // Write the contents to the popup object cp.populate(cp_contents+"\n"); // Move the table down a bit so you can see it cp.offsetY = 25; cp.autoHide(); return cp; } customize-views.js000066400000012146152436173310010272 0ustar00/** * @output wp-includes/js/customize-views.js */ (function( $, wp, _ ) { if ( ! wp || ! wp.customize ) { return; } var api = wp.customize; /** * wp.customize.HeaderTool.CurrentView * * Displays the currently selected header image, or a placeholder in lack * thereof. * * Instantiate with model wp.customize.HeaderTool.currentHeader. * * @memberOf wp.customize.HeaderTool * @alias wp.customize.HeaderTool.CurrentView * * @constructor * @augments wp.Backbone.View */ api.HeaderTool.CurrentView = wp.Backbone.View.extend(/** @lends wp.customize.HeaderTool.CurrentView.prototype */{ template: wp.template('header-current'), initialize: function() { this.listenTo(this.model, 'change', this.render); this.render(); }, render: function() { this.$el.html(this.template(this.model.toJSON())); this.setButtons(); return this; }, setButtons: function() { var elements = $('#customize-control-header_image .actions .remove'); var addButton = $('#customize-control-header_image .actions .new'); if (this.model.get('choice')) { elements.show(); addButton.removeClass('upload-button'); } else { elements.hide(); addButton.addClass('upload-button'); } } }); /** * wp.customize.HeaderTool.ChoiceView * * Represents a choosable header image, be it user-uploaded, * theme-suggested or a special Randomize choice. * * Takes a wp.customize.HeaderTool.ImageModel. * * Manually changes model wp.customize.HeaderTool.currentHeader via the * `select` method. * * @memberOf wp.customize.HeaderTool * @alias wp.customize.HeaderTool.ChoiceView * * @constructor * @augments wp.Backbone.View */ api.HeaderTool.ChoiceView = wp.Backbone.View.extend(/** @lends wp.customize.HeaderTool.ChoiceView.prototype */{ template: wp.template('header-choice'), className: 'header-view', events: { 'click .choice,.random': 'select', 'click .close': 'removeImage' }, initialize: function() { var properties = [ this.model.get('header').url, this.model.get('choice') ]; this.listenTo(this.model, 'change:selected', this.toggleSelected); if (_.contains(properties, api.get().header_image)) { api.HeaderTool.currentHeader.set(this.extendedModel()); } }, render: function() { this.$el.html(this.template(this.extendedModel())); this.toggleSelected(); return this; }, toggleSelected: function() { this.$el.toggleClass('selected', this.model.get('selected')); }, extendedModel: function() { var c = this.model.get('collection'); return _.extend(this.model.toJSON(), { type: c.type }); }, select: function() { this.preventJump(); this.model.save(); api.HeaderTool.currentHeader.set(this.extendedModel()); }, preventJump: function() { var container = $('.wp-full-overlay-sidebar-content'), scroll = container.scrollTop(); _.defer(function() { container.scrollTop(scroll); }); }, removeImage: function(e) { e.stopPropagation(); this.model.destroy(); this.remove(); } }); /** * wp.customize.HeaderTool.ChoiceListView * * A container for ChoiceViews. These choices should be of one same type: * user-uploaded headers or theme-defined ones. * * Takes a wp.customize.HeaderTool.ChoiceList. * * @memberOf wp.customize.HeaderTool * @alias wp.customize.HeaderTool.ChoiceListView * * @constructor * @augments wp.Backbone.View */ api.HeaderTool.ChoiceListView = wp.Backbone.View.extend(/** @lends wp.customize.HeaderTool.ChoiceListView.prototype */{ initialize: function() { this.listenTo(this.collection, 'add', this.addOne); this.listenTo(this.collection, 'remove', this.render); this.listenTo(this.collection, 'sort', this.render); this.listenTo(this.collection, 'change', this.toggleList); this.render(); }, render: function() { this.$el.empty(); this.collection.each(this.addOne, this); this.toggleList(); }, addOne: function(choice) { var view; choice.set({ collection: this.collection }); view = new api.HeaderTool.ChoiceView({ model: choice }); this.$el.append(view.render().el); }, toggleList: function() { var title = this.$el.parents().prev('.customize-control-title'), randomButton = this.$el.find('.random').parent(); if (this.collection.shouldHideTitle()) { title.add(randomButton).hide(); } else { title.add(randomButton).show(); } } }); /** * wp.customize.HeaderTool.CombinedList * * Aggregates wp.customize.HeaderTool.ChoiceList collections (or any * Backbone object, really) and acts as a bus to feed them events. * * @memberOf wp.customize.HeaderTool * @alias wp.customize.HeaderTool.CombinedList * * @constructor * @augments wp.Backbone.View */ api.HeaderTool.CombinedList = wp.Backbone.View.extend(/** @lends wp.customize.HeaderTool.CombinedList.prototype */{ initialize: function(collections) { this.collections = collections; this.on('all', this.propagate, this); }, propagate: function(event, arg) { _.each(this.collections, function(collection) { collection.trigger(event, arg); }); } }); })( jQuery, window.wp, _ ); jquery/jquery.color.min.js000066400000014765152436173310011663 0ustar00/*! jQuery Color v3.0.0 https://github.com/jquery/jquery-color | jquery.org/license */ !function(r,t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof exports?module.exports=t(require("jquery")):t(r.jQuery)}(this,function(s,l){"use strict";var u,n={},t=n.toString,c=/^([\-+])=\s*(\d+\.?\d*)/,r=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(r){return[r[1],r[2],r[3],r[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(r){return[2.55*r[1],2.55*r[2],2.55*r[3],r[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})?/,parse:function(r){return[parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16),r[4]?(parseInt(r[4],16)/255).toFixed(2):1]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])([a-f0-9])?/,parse:function(r){return[parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16),parseInt(r[3]+r[3],16),r[4]?(parseInt(r[4]+r[4],16)/255).toFixed(2):1]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(r){return[r[1],r[2]/100,r[3]/100,r[4]]}}],f=s.Color=function(r,t,n,e){return new s.Color.fn.parse(r,t,n,e)},p={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},d={byte:{floor:!0,max:255},percent:{max:1},degrees:{mod:360,floor:!0}},h=s.each;function b(r){return null==r?r+"":"object"==typeof r?n[t.call(r)]||"object":typeof r}function g(r,t,n){var e=d[t.type]||{};return null==r?n||!t.def?null:t.def:(r=e.floor?~~r:parseFloat(r),e.mod?(r+e.mod)%e.mod:Math.min(e.max,Math.max(0,r)))}function m(e){var o=f(),a=o._rgba=[];return e=e.toLowerCase(),h(r,function(r,t){var n=t.re.exec(e),n=n&&t.parse(n),t=t.space||"rgba";if(n)return n=o[t](n),o[p[t].cache]=n[p[t].cache],a=o._rgba=n._rgba,!1}),a.length?("0,0,0,0"===a.join()&&s.extend(a,u.transparent),o):u[e]}function o(r,t,n){return 6*(n=(n+1)%1)<1?r+(t-r)*n*6:2*n<1?t:3*n<2?r+(t-r)*(2/3-n)*6:r}h(p,function(r,t){t.cache="_"+r,t.props.alpha={idx:3,type:"percent",def:1}}),s.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(r,t){n["[object "+t+"]"]=t.toLowerCase()}),(f.fn=s.extend(f.prototype,{parse:function(o,r,t,n){if(o===l)return this._rgba=[null,null,null,null],this;(o.jquery||o.nodeType)&&(o=s(o).css(r),r=l);var a=this,e=b(o),i=this._rgba=[];return r!==l&&(o=[o,r,t,n],e="array"),"string"===e?this.parse(m(o)||u._default):"array"===e?(h(p.rgba.props,function(r,t){i[t.idx]=g(o[t.idx],t)}),this):"object"===e?(o instanceof f?h(p,function(r,t){o[t.cache]&&(a[t.cache]=o[t.cache].slice())}):h(p,function(r,n){var e=n.cache;h(n.props,function(r,t){if(!a[e]&&n.to){if("alpha"===r||null==o[r])return;a[e]=n.to(a._rgba)}a[e][t.idx]=g(o[r],t,!0)}),a[e]&&s.inArray(null,a[e].slice(0,3))<0&&(null==a[e][3]&&(a[e][3]=1),n.from)&&(a._rgba=n.from(a[e]))}),this):void 0},is:function(r){var o=f(r),a=!0,i=this;return h(p,function(r,t){var n,e=o[t.cache];return e&&(n=i[t.cache]||t.to&&t.to(i._rgba)||[],h(t.props,function(r,t){if(null!=e[t.idx])return a=e[t.idx]===n[t.idx]})),a}),a},_space:function(){var n=[],e=this;return h(p,function(r,t){e[t.cache]&&n.push(r)}),n.pop()},transition:function(r,i){var r=(l=f(r))._space(),t=p[r],n=0===this.alpha()?f("transparent"):this,s=n[t.cache]||t.to(n._rgba),u=s.slice(),l=l[t.cache];return h(t.props,function(r,t){var n=t.idx,e=s[n],o=l[n],a=d[t.type]||{};null!==o&&(null===e?u[n]=o:(a.mod&&(o-e>a.mod/2?e+=a.mod:e-o>a.mod/2&&(e-=a.mod)),u[n]=g((o-e)*i+e,t)))}),this[r](u)},blend:function(r){var t,n,e;return 1===this._rgba[3]?this:(t=this._rgba.slice(),n=t.pop(),e=f(r)._rgba,f(s.map(t,function(r,t){return(1-n)*e[t]+n*r})))},toRgbaString:function(){var r="rgba(",t=s.map(this._rgba,function(r,t){return null!=r?r:2 v2 function compareVersions( v1, v2 ) { var i, rVersionParts = /^(\d+)\.(\d+)\.(\d+)/, v1p = rVersionParts.exec( v1 ) || [ ], v2p = rVersionParts.exec( v2 ) || [ ]; for ( i = 1; i <= 3; i++ ) { if ( +v1p[ i ] > +v2p[ i ] ) { return 1; } if ( +v1p[ i ] < +v2p[ i ] ) { return -1; } } return 0; } function jQueryVersionSince( version ) { return compareVersions( jQuery.fn.jquery, version ) >= 0; } // A map from disabled patch codes to `true`. This should really // be a `Set` but those are unsupported in IE. var disabledPatches = Object.create( null ); // Don't apply patches for specified codes. Helpful for code bases // where some Migrate warnings have been addressed and it's desirable // to avoid needless patches or false positives. jQuery.migrateDisablePatches = function() { var i; for ( i = 0; i < arguments.length; i++ ) { disabledPatches[ arguments[ i ] ] = true; } }; // Allow enabling patches disabled via `jQuery.migrateDisablePatches`. // Helpful if you want to disable a patch only for some code that won't // be updated soon to be able to focus on other warnings - and enable it // immediately after such a call: // ```js // jQuery.migrateDisablePatches( "workaroundA" ); // elem.pluginViolatingWarningA( "pluginMethod" ); // jQuery.migrateEnablePatches( "workaroundA" ); // ``` jQuery.migrateEnablePatches = function() { var i; for ( i = 0; i < arguments.length; i++ ) { delete disabledPatches[ arguments[ i ] ]; } }; jQuery.migrateIsPatchEnabled = function( patchCode ) { return !disabledPatches[ patchCode ]; }; ( function() { // Support: IE9 only // IE9 only creates console object when dev tools are first opened // IE9 console is a host object, callable but doesn't have .apply() if ( !window.console || !window.console.log ) { return; } // Need jQuery 3.x-4.x and no older Migrate loaded if ( !jQuery || !jQueryVersionSince( "3.0.0" ) || jQueryVersionSince( "5.0.0" ) ) { window.console.log( "JQMIGRATE: jQuery 3.x-4.x REQUIRED" ); } if ( jQuery.migrateWarnings ) { window.console.log( "JQMIGRATE: Migrate plugin loaded multiple times" ); } // Show a message on the console so devs know we're active window.console.log( "JQMIGRATE: Migrate is installed" + ( jQuery.migrateMute ? "" : " with logging active" ) + ", version " + jQuery.migrateVersion ); } )(); var warnedAbout = {}; // By default each warning is only reported once. jQuery.migrateDeduplicateWarnings = true; // List of warnings already given; public read only jQuery.migrateWarnings = []; // Set to false to disable traces that appear with warnings if ( jQuery.migrateTrace === undefined ) { jQuery.migrateTrace = true; } // Forget any warnings we've already given; public jQuery.migrateReset = function() { warnedAbout = {}; jQuery.migrateWarnings.length = 0; }; function migrateWarn( code, msg ) { var console = window.console; if ( jQuery.migrateIsPatchEnabled( code ) && ( !jQuery.migrateDeduplicateWarnings || !warnedAbout[ msg ] ) ) { warnedAbout[ msg ] = true; jQuery.migrateWarnings.push( msg + " [" + code + "]" ); if ( console && console.warn && !jQuery.migrateMute ) { console.warn( "JQMIGRATE: " + msg ); if ( jQuery.migrateTrace && console.trace ) { console.trace(); } } } } function migrateWarnProp( obj, prop, value, code, msg ) { Object.defineProperty( obj, prop, { configurable: true, enumerable: true, get: function() { migrateWarn( code, msg ); return value; }, set: function( newValue ) { migrateWarn( code, msg ); value = newValue; } } ); } function migrateWarnFuncInternal( obj, prop, newFunc, code, msg ) { var finalFunc, origFunc = obj[ prop ]; obj[ prop ] = function() { // If `msg` not provided, do not warn; more sophisticated warnings // logic is most likely embedded in `newFunc`, in that case here // we just care about the logic choosing the proper implementation // based on whether the patch is disabled or not. if ( msg ) { migrateWarn( code, msg ); } // Since patches can be disabled & enabled dynamically, we // need to decide which implementation to run on each invocation. finalFunc = jQuery.migrateIsPatchEnabled( code ) ? newFunc : // The function may not have existed originally so we need a fallback. ( origFunc || jQuery.noop ); return finalFunc.apply( this, arguments ); }; } function migratePatchAndWarnFunc( obj, prop, newFunc, code, msg ) { if ( !msg ) { throw new Error( "No warning message provided" ); } return migrateWarnFuncInternal( obj, prop, newFunc, code, msg ); } function migratePatchFunc( obj, prop, newFunc, code ) { return migrateWarnFuncInternal( obj, prop, newFunc, code ); } if ( window.document.compatMode === "BackCompat" ) { // jQuery has never supported or tested Quirks Mode migrateWarn( "quirks", "jQuery is not compatible with Quirks Mode" ); } var findProp, class2type = {}, oldInit = jQuery.fn.init, oldFind = jQuery.find, rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/, rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g, // Require that the "whitespace run" starts from a non-whitespace // to avoid O(N^2) behavior when the engine would try matching "\s+$" at each space position. rtrim = /^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g; migratePatchFunc( jQuery.fn, "init", function( arg1 ) { var args = Array.prototype.slice.call( arguments ); if ( jQuery.migrateIsPatchEnabled( "selector-empty-id" ) && typeof arg1 === "string" && arg1 === "#" ) { // JQuery( "#" ) is a bogus ID selector, but it returned an empty set // before jQuery 3.0 migrateWarn( "selector-empty-id", "jQuery( '#' ) is not a valid selector" ); args[ 0 ] = []; } return oldInit.apply( this, args ); }, "selector-empty-id" ); // This is already done in Core but the above patch will lose this assignment // so we need to redo it. It doesn't matter whether the patch is enabled or not // as the method is always going to be a Migrate-created wrapper. jQuery.fn.init.prototype = jQuery.fn; migratePatchFunc( jQuery, "find", function( selector ) { var args = Array.prototype.slice.call( arguments ); // Support: PhantomJS 1.x // String#match fails to match when used with a //g RegExp, only on some strings if ( typeof selector === "string" && rattrHashTest.test( selector ) ) { // The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0 // First see if qS thinks it's a valid selector, if so avoid a false positive try { window.document.querySelector( selector ); } catch ( err1 ) { // Didn't *look* valid to qSA, warn and try quoting what we think is the value selector = selector.replace( rattrHashGlob, function( _, attr, op, value ) { return "[" + attr + op + "\"" + value + "\"]"; } ); // If the regexp *may* have created an invalid selector, don't update it // Note that there may be false alarms if selector uses jQuery extensions try { window.document.querySelector( selector ); migrateWarn( "selector-hash", "Attribute selector with '#' must be quoted: " + args[ 0 ] ); args[ 0 ] = selector; } catch ( err2 ) { migrateWarn( "selector-hash", "Attribute selector with '#' was not fixed: " + args[ 0 ] ); } } } return oldFind.apply( this, args ); }, "selector-hash" ); // Copy properties attached to original jQuery.find method (e.g. .attr, .isXML) for ( findProp in oldFind ) { if ( Object.prototype.hasOwnProperty.call( oldFind, findProp ) ) { jQuery.find[ findProp ] = oldFind[ findProp ]; } } // The number of elements contained in the matched element set migratePatchAndWarnFunc( jQuery.fn, "size", function() { return this.length; }, "size", "jQuery.fn.size() is deprecated and removed; use the .length property" ); migratePatchAndWarnFunc( jQuery, "parseJSON", function() { return JSON.parse.apply( null, arguments ); }, "parseJSON", "jQuery.parseJSON is deprecated; use JSON.parse" ); migratePatchAndWarnFunc( jQuery, "holdReady", jQuery.holdReady, "holdReady", "jQuery.holdReady is deprecated" ); migratePatchAndWarnFunc( jQuery, "unique", jQuery.uniqueSort, "unique", "jQuery.unique is deprecated; use jQuery.uniqueSort" ); // Now jQuery.expr.pseudos is the standard incantation migrateWarnProp( jQuery.expr, "filters", jQuery.expr.pseudos, "expr-pre-pseudos", "jQuery.expr.filters is deprecated; use jQuery.expr.pseudos" ); migrateWarnProp( jQuery.expr, ":", jQuery.expr.pseudos, "expr-pre-pseudos", "jQuery.expr[':'] is deprecated; use jQuery.expr.pseudos" ); // Prior to jQuery 3.1.1 there were internal refs so we don't warn there if ( jQueryVersionSince( "3.1.1" ) ) { migratePatchAndWarnFunc( jQuery, "trim", function( text ) { return text == null ? "" : ( text + "" ).replace( rtrim, "$1" ); }, "trim", "jQuery.trim is deprecated; use String.prototype.trim" ); } // Prior to jQuery 3.2 there were internal refs so we don't warn there if ( jQueryVersionSince( "3.2.0" ) ) { migratePatchAndWarnFunc( jQuery, "nodeName", function( elem, name ) { return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); }, "nodeName", "jQuery.nodeName is deprecated" ); migratePatchAndWarnFunc( jQuery, "isArray", Array.isArray, "isArray", "jQuery.isArray is deprecated; use Array.isArray" ); } if ( jQueryVersionSince( "3.3.0" ) ) { migratePatchAndWarnFunc( jQuery, "isNumeric", function( obj ) { // As of jQuery 3.0, isNumeric is limited to // strings and numbers (primitives or objects) // that can be coerced to finite numbers (gh-2662) var type = typeof obj; return ( type === "number" || type === "string" ) && // parseFloat NaNs numeric-cast false positives ("") // ...but misinterprets leading-number strings, e.g. hex literals ("0x...") // subtraction forces infinities to NaN !isNaN( obj - parseFloat( obj ) ); }, "isNumeric", "jQuery.isNumeric() is deprecated" ); // Populate the class2type map jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol". split( " " ), function( _, name ) { class2type[ "[object " + name + "]" ] = name.toLowerCase(); } ); migratePatchAndWarnFunc( jQuery, "type", function( obj ) { if ( obj == null ) { return obj + ""; } // Support: Android <=2.3 only (functionish RegExp) return typeof obj === "object" || typeof obj === "function" ? class2type[ Object.prototype.toString.call( obj ) ] || "object" : typeof obj; }, "type", "jQuery.type is deprecated" ); migratePatchAndWarnFunc( jQuery, "isFunction", function( obj ) { return typeof obj === "function"; }, "isFunction", "jQuery.isFunction() is deprecated" ); migratePatchAndWarnFunc( jQuery, "isWindow", function( obj ) { return obj != null && obj === obj.window; }, "isWindow", "jQuery.isWindow() is deprecated" ); } // Support jQuery slim which excludes the ajax module if ( jQuery.ajax ) { var oldAjax = jQuery.ajax, rjsonp = /(=)\?(?=&|$)|\?\?/; migratePatchFunc( jQuery, "ajax", function() { var jQXHR = oldAjax.apply( this, arguments ); // Be sure we got a jQXHR (e.g., not sync) if ( jQXHR.promise ) { migratePatchAndWarnFunc( jQXHR, "success", jQXHR.done, "jqXHR-methods", "jQXHR.success is deprecated and removed" ); migratePatchAndWarnFunc( jQXHR, "error", jQXHR.fail, "jqXHR-methods", "jQXHR.error is deprecated and removed" ); migratePatchAndWarnFunc( jQXHR, "complete", jQXHR.always, "jqXHR-methods", "jQXHR.complete is deprecated and removed" ); } return jQXHR; }, "jqXHR-methods" ); // Only trigger the logic in jQuery <4 as the JSON-to-JSONP auto-promotion // behavior is gone in jQuery 4.0 and as it has security implications, we don't // want to restore the legacy behavior. if ( !jQueryVersionSince( "4.0.0" ) ) { // Register this prefilter before the jQuery one. Otherwise, a promoted // request is transformed into one with the script dataType and we can't // catch it anymore. jQuery.ajaxPrefilter( "+json", function( s ) { // Warn if JSON-to-JSONP auto-promotion happens. if ( s.jsonp !== false && ( rjsonp.test( s.url ) || typeof s.data === "string" && ( s.contentType || "" ) .indexOf( "application/x-www-form-urlencoded" ) === 0 && rjsonp.test( s.data ) ) ) { migrateWarn( "jsonp-promotion", "JSON-to-JSONP auto-promotion is deprecated" ); } } ); } } var oldRemoveAttr = jQuery.fn.removeAttr, oldToggleClass = jQuery.fn.toggleClass, rmatchNonSpace = /\S+/g; migratePatchFunc( jQuery.fn, "removeAttr", function( name ) { var self = this, patchNeeded = false; jQuery.each( name.match( rmatchNonSpace ), function( _i, attr ) { if ( jQuery.expr.match.bool.test( attr ) ) { // Only warn if at least a single node had the property set to // something else than `false`. Otherwise, this Migrate patch // doesn't influence the behavior and there's no need to set or warn. self.each( function() { if ( jQuery( this ).prop( attr ) !== false ) { patchNeeded = true; return false; } } ); } if ( patchNeeded ) { migrateWarn( "removeAttr-bool", "jQuery.fn.removeAttr no longer sets boolean properties: " + attr ); self.prop( attr, false ); } } ); return oldRemoveAttr.apply( this, arguments ); }, "removeAttr-bool" ); migratePatchFunc( jQuery.fn, "toggleClass", function( state ) { // Only deprecating no-args or single boolean arg if ( state !== undefined && typeof state !== "boolean" ) { return oldToggleClass.apply( this, arguments ); } migrateWarn( "toggleClass-bool", "jQuery.fn.toggleClass( boolean ) is deprecated" ); // Toggle entire class name of each element return this.each( function() { var className = this.getAttribute && this.getAttribute( "class" ) || ""; if ( className ) { jQuery.data( this, "__className__", className ); } // If the element has a class name or if we're passed `false`, // then remove the whole classname (if there was one, the above saved it). // Otherwise bring back whatever was previously saved (if anything), // falling back to the empty string if nothing was stored. if ( this.setAttribute ) { this.setAttribute( "class", className || state === false ? "" : jQuery.data( this, "__className__" ) || "" ); } } ); }, "toggleClass-bool" ); function camelCase( string ) { return string.replace( /-([a-z])/g, function( _, letter ) { return letter.toUpperCase(); } ); } var origFnCss, internalCssNumber, internalSwapCall = false, ralphaStart = /^[a-z]/, // The regex visualized: // // /----------\ // | | /-------\ // | / Top \ | | | // /--- Border ---+-| Right |-+---+- Width -+---\ // | | Bottom | | // | \ Left / | // | | // | /----------\ | // | /-------------\ | | |- END // | | | | / Top \ | | // | | / Margin \ | | | Right | | | // |---------+-| |-+---+-| Bottom |-+----| // | \ Padding / \ Left / | // BEGIN -| | // | /---------\ | // | | | | // | | / Min \ | / Width \ | // \--------------+-| |-+---| |---/ // \ Max / \ Height / rautoPx = /^(?:Border(?:Top|Right|Bottom|Left)?(?:Width|)|(?:Margin|Padding)?(?:Top|Right|Bottom|Left)?|(?:Min|Max)?(?:Width|Height))$/; // If this version of jQuery has .swap(), don't false-alarm on internal uses if ( jQuery.swap ) { jQuery.each( [ "height", "width", "reliableMarginRight" ], function( _, name ) { var oldHook = jQuery.cssHooks[ name ] && jQuery.cssHooks[ name ].get; if ( oldHook ) { jQuery.cssHooks[ name ].get = function() { var ret; internalSwapCall = true; ret = oldHook.apply( this, arguments ); internalSwapCall = false; return ret; }; } } ); } migratePatchFunc( jQuery, "swap", function( elem, options, callback, args ) { var ret, name, old = {}; if ( !internalSwapCall ) { migrateWarn( "swap", "jQuery.swap() is undocumented and deprecated" ); } // Remember the old values, and insert the new ones for ( name in options ) { old[ name ] = elem.style[ name ]; elem.style[ name ] = options[ name ]; } ret = callback.apply( elem, args || [] ); // Revert the old values for ( name in options ) { elem.style[ name ] = old[ name ]; } return ret; }, "swap" ); if ( jQueryVersionSince( "3.4.0" ) && typeof Proxy !== "undefined" ) { jQuery.cssProps = new Proxy( jQuery.cssProps || {}, { set: function() { migrateWarn( "cssProps", "jQuery.cssProps is deprecated" ); return Reflect.set.apply( this, arguments ); } } ); } // In jQuery >=4 where jQuery.cssNumber is missing fill it with the latest 3.x version: // https://github.com/jquery/jquery/blob/3.6.0/src/css.js#L212-L233 // This way, number values for the CSS properties below won't start triggering // Migrate warnings when jQuery gets updated to >=4.0.0 (gh-438). if ( jQueryVersionSince( "4.0.0" ) ) { // We need to keep this as a local variable as we need it internally // in a `jQuery.fn.css` patch and this usage shouldn't warn. internalCssNumber = { animationIterationCount: true, columnCount: true, fillOpacity: true, flexGrow: true, flexShrink: true, fontWeight: true, gridArea: true, gridColumn: true, gridColumnEnd: true, gridColumnStart: true, gridRow: true, gridRowEnd: true, gridRowStart: true, lineHeight: true, opacity: true, order: true, orphans: true, widows: true, zIndex: true, zoom: true }; if ( typeof Proxy !== "undefined" ) { jQuery.cssNumber = new Proxy( internalCssNumber, { get: function() { migrateWarn( "css-number", "jQuery.cssNumber is deprecated" ); return Reflect.get.apply( this, arguments ); }, set: function() { migrateWarn( "css-number", "jQuery.cssNumber is deprecated" ); return Reflect.set.apply( this, arguments ); } } ); } else { // Support: IE 9-11+ // IE doesn't support proxies, but we still want to restore the legacy // jQuery.cssNumber there. jQuery.cssNumber = internalCssNumber; } } else { // Make `internalCssNumber` defined for jQuery <4 as well as it's needed // in the `jQuery.fn.css` patch below. internalCssNumber = jQuery.cssNumber; } function isAutoPx( prop ) { // The first test is used to ensure that: // 1. The prop starts with a lowercase letter (as we uppercase it for the second regex). // 2. The prop is not empty. return ralphaStart.test( prop ) && rautoPx.test( prop[ 0 ].toUpperCase() + prop.slice( 1 ) ); } origFnCss = jQuery.fn.css; migratePatchFunc( jQuery.fn, "css", function( name, value ) { var camelName, origThis = this; if ( name && typeof name === "object" && !Array.isArray( name ) ) { jQuery.each( name, function( n, v ) { jQuery.fn.css.call( origThis, n, v ); } ); return this; } if ( typeof value === "number" ) { camelName = camelCase( name ); // Use `internalCssNumber` to avoid triggering our warnings in this // internal check. if ( !isAutoPx( camelName ) && !internalCssNumber[ camelName ] ) { migrateWarn( "css-number", "Number-typed values are deprecated for jQuery.fn.css( \"" + name + "\", value )" ); } } return origFnCss.apply( this, arguments ); }, "css-number" ); var origData = jQuery.data; migratePatchFunc( jQuery, "data", function( elem, name, value ) { var curData, sameKeys, key; // Name can be an object, and each entry in the object is meant to be set as data if ( name && typeof name === "object" && arguments.length === 2 ) { curData = jQuery.hasData( elem ) && origData.call( this, elem ); sameKeys = {}; for ( key in name ) { if ( key !== camelCase( key ) ) { migrateWarn( "data-camelCase", "jQuery.data() always sets/gets camelCased names: " + key ); curData[ key ] = name[ key ]; } else { sameKeys[ key ] = name[ key ]; } } origData.call( this, elem, sameKeys ); return name; } // If the name is transformed, look for the un-transformed name in the data object if ( name && typeof name === "string" && name !== camelCase( name ) ) { curData = jQuery.hasData( elem ) && origData.call( this, elem ); if ( curData && name in curData ) { migrateWarn( "data-camelCase", "jQuery.data() always sets/gets camelCased names: " + name ); if ( arguments.length > 2 ) { curData[ name ] = value; } return curData[ name ]; } } return origData.apply( this, arguments ); }, "data-camelCase" ); // Support jQuery slim which excludes the effects module if ( jQuery.fx ) { var intervalValue, intervalMsg, oldTweenRun = jQuery.Tween.prototype.run, linearEasing = function( pct ) { return pct; }; migratePatchFunc( jQuery.Tween.prototype, "run", function( ) { if ( jQuery.easing[ this.easing ].length > 1 ) { migrateWarn( "easing-one-arg", "'jQuery.easing." + this.easing.toString() + "' should use only one argument" ); jQuery.easing[ this.easing ] = linearEasing; } oldTweenRun.apply( this, arguments ); }, "easing-one-arg" ); intervalValue = jQuery.fx.interval; intervalMsg = "jQuery.fx.interval is deprecated"; // Support: IE9, Android <=4.4 // Avoid false positives on browsers that lack rAF // Don't warn if document is hidden, jQuery uses setTimeout (#292) if ( window.requestAnimationFrame ) { Object.defineProperty( jQuery.fx, "interval", { configurable: true, enumerable: true, get: function() { if ( !window.document.hidden ) { migrateWarn( "fx-interval", intervalMsg ); } // Only fallback to the default if patch is enabled if ( !jQuery.migrateIsPatchEnabled( "fx-interval" ) ) { return intervalValue; } return intervalValue === undefined ? 13 : intervalValue; }, set: function( newValue ) { migrateWarn( "fx-interval", intervalMsg ); intervalValue = newValue; } } ); } } var oldLoad = jQuery.fn.load, oldEventAdd = jQuery.event.add, originalFix = jQuery.event.fix; jQuery.event.props = []; jQuery.event.fixHooks = {}; migrateWarnProp( jQuery.event.props, "concat", jQuery.event.props.concat, "event-old-patch", "jQuery.event.props.concat() is deprecated and removed" ); migratePatchFunc( jQuery.event, "fix", function( originalEvent ) { var event, type = originalEvent.type, fixHook = this.fixHooks[ type ], props = jQuery.event.props; if ( props.length ) { migrateWarn( "event-old-patch", "jQuery.event.props are deprecated and removed: " + props.join() ); while ( props.length ) { jQuery.event.addProp( props.pop() ); } } if ( fixHook && !fixHook._migrated_ ) { fixHook._migrated_ = true; migrateWarn( "event-old-patch", "jQuery.event.fixHooks are deprecated and removed: " + type ); if ( ( props = fixHook.props ) && props.length ) { while ( props.length ) { jQuery.event.addProp( props.pop() ); } } } event = originalFix.call( this, originalEvent ); return fixHook && fixHook.filter ? fixHook.filter( event, originalEvent ) : event; }, "event-old-patch" ); migratePatchFunc( jQuery.event, "add", function( elem, types ) { // This misses the multiple-types case but that seems awfully rare if ( elem === window && types === "load" && window.document.readyState === "complete" ) { migrateWarn( "load-after-event", "jQuery(window).on('load'...) called after load event occurred" ); } return oldEventAdd.apply( this, arguments ); }, "load-after-event" ); jQuery.each( [ "load", "unload", "error" ], function( _, name ) { migratePatchFunc( jQuery.fn, name, function() { var args = Array.prototype.slice.call( arguments, 0 ); // If this is an ajax load() the first arg should be the string URL; // technically this could also be the "Anything" arg of the event .load() // which just goes to show why this dumb signature has been deprecated! // jQuery custom builds that exclude the Ajax module justifiably die here. if ( name === "load" && typeof args[ 0 ] === "string" ) { return oldLoad.apply( this, args ); } migrateWarn( "shorthand-removed-v3", "jQuery.fn." + name + "() is deprecated" ); args.splice( 0, 0, name ); if ( arguments.length ) { return this.on.apply( this, args ); } // Use .triggerHandler here because: // - load and unload events don't need to bubble, only applied to window or image // - error event should not bubble to window, although it does pre-1.7 // See http://bugs.jquery.com/ticket/11820 this.triggerHandler.apply( this, args ); return this; }, "shorthand-removed-v3" ); } ); jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + "change select submit keydown keypress keyup contextmenu" ).split( " " ), function( _i, name ) { // Handle event binding migratePatchAndWarnFunc( jQuery.fn, name, function( data, fn ) { return arguments.length > 0 ? this.on( name, null, data, fn ) : this.trigger( name ); }, "shorthand-deprecated-v3", "jQuery.fn." + name + "() event shorthand is deprecated" ); } ); // Trigger "ready" event only once, on document ready jQuery( function() { jQuery( window.document ).triggerHandler( "ready" ); } ); jQuery.event.special.ready = { setup: function() { if ( this === window.document ) { migrateWarn( "ready-event", "'ready' event is deprecated" ); } } }; migratePatchAndWarnFunc( jQuery.fn, "bind", function( types, data, fn ) { return this.on( types, null, data, fn ); }, "pre-on-methods", "jQuery.fn.bind() is deprecated" ); migratePatchAndWarnFunc( jQuery.fn, "unbind", function( types, fn ) { return this.off( types, null, fn ); }, "pre-on-methods", "jQuery.fn.unbind() is deprecated" ); migratePatchAndWarnFunc( jQuery.fn, "delegate", function( selector, types, data, fn ) { return this.on( types, selector, data, fn ); }, "pre-on-methods", "jQuery.fn.delegate() is deprecated" ); migratePatchAndWarnFunc( jQuery.fn, "undelegate", function( selector, types, fn ) { return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn ); }, "pre-on-methods", "jQuery.fn.undelegate() is deprecated" ); migratePatchAndWarnFunc( jQuery.fn, "hover", function( fnOver, fnOut ) { return this.on( "mouseenter", fnOver ).on( "mouseleave", fnOut || fnOver ); }, "pre-on-methods", "jQuery.fn.hover() is deprecated" ); var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi, makeMarkup = function( html ) { var doc = window.document.implementation.createHTMLDocument( "" ); doc.body.innerHTML = html; return doc.body && doc.body.innerHTML; }, warnIfChanged = function( html ) { var changed = html.replace( rxhtmlTag, "<$1>" ); if ( changed !== html && makeMarkup( html ) !== makeMarkup( changed ) ) { migrateWarn( "self-closed-tags", "HTML tags must be properly nested and closed: " + html ); } }; /** * Deprecated, please use `jQuery.migrateDisablePatches( "self-closed-tags" )` instead. * @deprecated */ jQuery.UNSAFE_restoreLegacyHtmlPrefilter = function() { jQuery.migrateEnablePatches( "self-closed-tags" ); }; migratePatchFunc( jQuery, "htmlPrefilter", function( html ) { warnIfChanged( html ); return html.replace( rxhtmlTag, "<$1>" ); }, "self-closed-tags" ); // This patch needs to be disabled by default as it re-introduces // security issues (CVE-2020-11022, CVE-2020-11023). jQuery.migrateDisablePatches( "self-closed-tags" ); var origOffset = jQuery.fn.offset; migratePatchFunc( jQuery.fn, "offset", function() { var elem = this[ 0 ]; if ( elem && ( !elem.nodeType || !elem.getBoundingClientRect ) ) { migrateWarn( "offset-valid-elem", "jQuery.fn.offset() requires a valid DOM element" ); return arguments.length ? this : undefined; } return origOffset.apply( this, arguments ); }, "offset-valid-elem" ); // Support jQuery slim which excludes the ajax module // The jQuery.param patch is about respecting `jQuery.ajaxSettings.traditional` // so it doesn't make sense for the slim build. if ( jQuery.ajax ) { var origParam = jQuery.param; migratePatchFunc( jQuery, "param", function( data, traditional ) { var ajaxTraditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; if ( traditional === undefined && ajaxTraditional ) { migrateWarn( "param-ajax-traditional", "jQuery.param() no longer uses jQuery.ajaxSettings.traditional" ); traditional = ajaxTraditional; } return origParam.call( this, data, traditional ); }, "param-ajax-traditional" ); } migratePatchAndWarnFunc( jQuery.fn, "andSelf", jQuery.fn.addBack, "andSelf", "jQuery.fn.andSelf() is deprecated and removed, use jQuery.fn.addBack()" ); // Support jQuery slim which excludes the deferred module in jQuery 4.0+ if ( jQuery.Deferred ) { var oldDeferred = jQuery.Deferred, tuples = [ // Action, add listener, callbacks, .then handlers, final state [ "resolve", "done", jQuery.Callbacks( "once memory" ), jQuery.Callbacks( "once memory" ), "resolved" ], [ "reject", "fail", jQuery.Callbacks( "once memory" ), jQuery.Callbacks( "once memory" ), "rejected" ], [ "notify", "progress", jQuery.Callbacks( "memory" ), jQuery.Callbacks( "memory" ) ] ]; migratePatchFunc( jQuery, "Deferred", function( func ) { var deferred = oldDeferred(), promise = deferred.promise(); function newDeferredPipe( /* fnDone, fnFail, fnProgress */ ) { var fns = arguments; return jQuery.Deferred( function( newDefer ) { jQuery.each( tuples, function( i, tuple ) { var fn = typeof fns[ i ] === "function" && fns[ i ]; // Deferred.done(function() { bind to newDefer or newDefer.resolve }) // deferred.fail(function() { bind to newDefer or newDefer.reject }) // deferred.progress(function() { bind to newDefer or newDefer.notify }) deferred[ tuple[ 1 ] ]( function() { var returned = fn && fn.apply( this, arguments ); if ( returned && typeof returned.promise === "function" ) { returned.promise() .done( newDefer.resolve ) .fail( newDefer.reject ) .progress( newDefer.notify ); } else { newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments ); } } ); } ); fns = null; } ).promise(); } migratePatchAndWarnFunc( deferred, "pipe", newDeferredPipe, "deferred-pipe", "deferred.pipe() is deprecated" ); migratePatchAndWarnFunc( promise, "pipe", newDeferredPipe, "deferred-pipe", "deferred.pipe() is deprecated" ); if ( func ) { func.call( deferred, deferred ); } return deferred; }, "deferred-pipe" ); // Preserve handler of uncaught exceptions in promise chains jQuery.Deferred.exceptionHook = oldDeferred.exceptionHook; } return jQuery; } ); jquery/suggest.min.js000064400000005661152436173310010701 0ustar00!function(a){a.suggest=function(b,c){function d(){var a=o.offset();p.css({top:a.top+b.offsetHeight+"px",left:a.left+"px"})}function e(a){if(/27$|38$|40$/.test(a.keyCode)&&p.is(":visible")||/^13$|^9$/.test(a.keyCode)&&k())switch(a.preventDefault&&a.preventDefault(),a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0,a.returnValue=!1,a.keyCode){case 38:n();break;case 40:m();break;case 9:case 13:l();break;case 27:p.hide()}else o.val().length!=r&&(q&&clearTimeout(q),q=setTimeout(f,c.delay),r=o.val().length)}function f(){var b,d,e=a.trim(o.val());c.multiple&&(b=e.lastIndexOf(c.multipleSep),-1!=b&&(e=a.trim(e.substr(b+c.multipleSep.length)))),e.length>=c.minchars?(cached=g(e),cached?i(cached.items):a.get(c.source,{q:e},function(a){p.hide(),d=j(a,e),i(d),h(e,d,a.length)})):p.hide()}function g(a){var b;for(b=0;bc.maxCacheSize;)e=s.pop(),t-=e.size;s.push({q:a,size:d,items:b}),t+=d}function i(b){var e,f="";if(b){if(!b.length)return void p.hide();for(d(),e=0;e"+b[e]+"";p.html(f).show(),p.children("li").mouseover(function(){p.children("li").removeClass(c.selectClass),a(this).addClass(c.selectClass)}).click(function(a){a.preventDefault(),a.stopPropagation(),l()})}}function j(b,d){var e,f,g=[],h=b.split(c.delimiter);for(e=0;e'+a+"
"}),g[g.length]=f);return g}function k(){var a;return p.is(":visible")?(a=p.children("li."+c.selectClass),a.length||(a=!1),a):!1}function l(){$currentResult=k(),$currentResult&&(c.multiple?(-1!=o.val().indexOf(c.multipleSep)?$currentVal=o.val().substr(0,o.val().lastIndexOf(c.multipleSep)+c.multipleSep.length)+" ":$currentVal="",o.val($currentVal+$currentResult.text()+c.multipleSep+" "),o.focus()):o.val($currentResult.text()),p.hide(),o.trigger("change"),c.onSelect&&c.onSelect.apply(o[0]))}function m(){$currentResult=k(),$currentResult?$currentResult.removeClass(c.selectClass).next().addClass(c.selectClass):p.children("li:first-child").addClass(c.selectClass)}function n(){var a=k();a?a.removeClass(c.selectClass).prev().addClass(c.selectClass):p.children("li:last-child").addClass(c.selectClass)}var o,p,q,r,s,t;o=a(b).attr("autocomplete","off"),p=a("