mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-05 02:10:45 +01:00
d568679946
* Add a new folder in `wp-includes/js`, `media` * Create manifest files for `views`, `models`, `grid`, and `audio-video` * Make `browserify` an `npm` dependency * Add Grunt tasks for `browserify` and `uglify:media` on `build` and `watch` * Update the paths loaded for media files in `script-loader` * All new files were created using `svn cp` from their original location Please run `npm install`. While developing media JS, you must run `grunt watch`. See #28510. Built from https://develop.svn.wordpress.org/trunk@31373 git-svn-id: http://core.svn.wordpress.org/trunk@31354 1a063a9b-81f0-0310-95a4-ce76da25c4cd
148 lines
6.6 KiB
JavaScript
148 lines
6.6 KiB
JavaScript
/* global _wpMediaViewsL10n, confirm, getUserSetting, setUserSetting */
|
|
( function( $, _ ) {
|
|
var l10n,
|
|
media = wp.media;
|
|
|
|
media.isTouchDevice = ( 'ontouchend' in document );
|
|
|
|
// Link any localized strings.
|
|
l10n = media.view.l10n = typeof _wpMediaViewsL10n === 'undefined' ? {} : _wpMediaViewsL10n;
|
|
|
|
// Link any settings.
|
|
media.view.settings = l10n.settings || {};
|
|
delete l10n.settings;
|
|
|
|
// Copy the `post` setting over to the model settings.
|
|
media.model.settings.post = media.view.settings.post;
|
|
|
|
// Check if the browser supports CSS 3.0 transitions
|
|
$.support.transition = (function(){
|
|
var style = document.documentElement.style,
|
|
transitions = {
|
|
WebkitTransition: 'webkitTransitionEnd',
|
|
MozTransition: 'transitionend',
|
|
OTransition: 'oTransitionEnd otransitionend',
|
|
transition: 'transitionend'
|
|
}, transition;
|
|
|
|
transition = _.find( _.keys( transitions ), function( transition ) {
|
|
return ! _.isUndefined( style[ transition ] );
|
|
});
|
|
|
|
return transition && {
|
|
end: transitions[ transition ]
|
|
};
|
|
}());
|
|
|
|
/**
|
|
* A shared event bus used to provide events into
|
|
* the media workflows that 3rd-party devs can use to hook
|
|
* in.
|
|
*/
|
|
media.events = _.extend( {}, Backbone.Events );
|
|
|
|
/**
|
|
* Makes it easier to bind events using transitions.
|
|
*
|
|
* @param {string} selector
|
|
* @param {Number} sensitivity
|
|
* @returns {Promise}
|
|
*/
|
|
media.transition = function( selector, sensitivity ) {
|
|
var deferred = $.Deferred();
|
|
|
|
sensitivity = sensitivity || 2000;
|
|
|
|
if ( $.support.transition ) {
|
|
if ( ! (selector instanceof $) ) {
|
|
selector = $( selector );
|
|
}
|
|
|
|
// Resolve the deferred when the first element finishes animating.
|
|
selector.first().one( $.support.transition.end, deferred.resolve );
|
|
|
|
// Just in case the event doesn't trigger, fire a callback.
|
|
_.delay( deferred.resolve, sensitivity );
|
|
|
|
// Otherwise, execute on the spot.
|
|
} else {
|
|
deferred.resolve();
|
|
}
|
|
|
|
return deferred.promise();
|
|
};
|
|
|
|
media.controller.Region = require( './controllers/region.js' );
|
|
media.controller.StateMachine = require( './controllers/state-machine.js' );
|
|
media.controller.State = require( './controllers/state.js' );
|
|
|
|
media.selectionSync = require( './utils/selection-sync.js' );
|
|
media.controller.Library = require( './controllers/library.js' );
|
|
media.controller.ImageDetails = require( './controllers/image-details.js' );
|
|
media.controller.GalleryEdit = require( './controllers/gallery-edit.js' );
|
|
media.controller.GalleryAdd = require( './controllers/gallery-add.js' );
|
|
media.controller.CollectionEdit = require( './controllers/collection-edit.js' );
|
|
media.controller.CollectionAdd = require( './controllers/collection-add.js' );
|
|
media.controller.FeaturedImage = require( './controllers/featured-image.js' );
|
|
media.controller.ReplaceImage = require( './controllers/replace-image.js' );
|
|
media.controller.EditImage = require( './controllers/edit-image.js' );
|
|
media.controller.MediaLibrary = require( './controllers/media-library.js' );
|
|
media.controller.Embed = require( './controllers/embed.js' );
|
|
media.controller.Cropper = require( './controllers/cropper.js' );
|
|
|
|
media.View = require( './views/view.js' );
|
|
media.view.Frame = require( './views/view.js' );
|
|
media.view.MediaFrame = require( './views/media-frame.js' );
|
|
media.view.MediaFrame.Select = require( './views/frame/select.js' );
|
|
media.view.MediaFrame.Post = require( './views/frame/post.js' );
|
|
media.view.MediaFrame.ImageDetails = require( './views/frame/image-details.js' );
|
|
media.view.Modal = require( './views/modal.js' );
|
|
media.view.FocusManager = require( './views/focus-manager.js' );
|
|
media.view.UploaderWindow = require( './views/uploader/window.js' );
|
|
media.view.EditorUploader = require( './views/uploader/editor.js' );
|
|
media.view.UploaderInline = require( './views/uploader/inline.js' );
|
|
media.view.UploaderStatus = require( './views/uploader/status.js' );
|
|
media.view.UploaderStatusError = require( './views/uploader/status-error.js' );
|
|
media.view.Toolbar = require( './views/toolbar.js' );
|
|
media.view.Toolbar.Select = require( './views/toolbar/select.js' );
|
|
media.view.Toolbar.Embed = require( './views/toolbar/embed.js' );
|
|
media.view.Button = require( './views/button.js' );
|
|
media.view.ButtonGroup = require( './views/button-group.js' );
|
|
media.view.PriorityList = require( './views/priority-list.js' );
|
|
media.view.MenuItem = require( './views/menu-item.js' );
|
|
media.view.Menu = require( './views/menu.js' );
|
|
media.view.RouterItem = require( './views/router-item.js' );
|
|
media.view.Router = require( './views/router.js' );
|
|
media.view.Sidebar = require( './views/sidebar.js' );
|
|
media.view.Attachment = require( './views/attachment.js' );
|
|
media.view.Attachment.Library = require( './views/attachment/library.js' );
|
|
media.view.Attachment.EditLibrary = require( './views/attachment/edit-library.js' );
|
|
media.view.Attachments = require( './views/attachments.js' );
|
|
media.view.Search = require( './views/search.js' );
|
|
media.view.AttachmentFilters = require( './views/attachment-filters.js' );
|
|
media.view.DateFilter = require( './views/attachment-filters/date.js' );
|
|
media.view.AttachmentFilters.Uploaded = require( './views/attachment-filters/uploaded.js' );
|
|
media.view.AttachmentFilters.All = require( './views/attachment-filters/all.js' );
|
|
media.view.AttachmentsBrowser = require( './views/attachments/browser.js' );
|
|
media.view.Selection = require( './views/selection.js' );
|
|
media.view.Attachment.Selection = require( './views/attachment/selection.js' );
|
|
media.view.Attachments.Selection = require( './views/attachments/selection.js' );
|
|
media.view.Attachment.EditSelection = require( './views/attachment/edit-selection.js' );
|
|
media.view.Settings = require( './views/settings.js' );
|
|
media.view.Settings.AttachmentDisplay = require( './views/settings/attachment-display.js' );
|
|
media.view.Settings.Gallery = require( './views/settings/gallery.js' );
|
|
media.view.Settings.Playlist = require( './views/settings/playlist.js' );
|
|
media.view.Attachment.Details = require( './views/attachment/details.js' );
|
|
media.view.AttachmentCompat = require( './views/attachment-compat.js' );
|
|
media.view.Iframe = require( './views/iframe.js' );
|
|
media.view.Embed = require( './views/embed.js' );
|
|
media.view.Label = require( './views/label.js' );
|
|
media.view.EmbedUrl = require( './views/embed/url.js' );
|
|
media.view.EmbedLink = require( './views/embed/link.js' );
|
|
media.view.EmbedImage = require( './views/embed/image.js' );
|
|
media.view.ImageDetails = require( './views/image-details.js' );
|
|
media.view.Cropper = require( './views/cropper.js' );
|
|
media.view.EditImage = require( './views/edit-image.js' );
|
|
media.view.Spinner = require( './views/spinner.js' );
|
|
|
|
}(jQuery, _)); |