Changeset 27615
- Timestamp:
- 03/19/2014 07:01:56 AM (11 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/mce-view.js
r27581 r27615 32 32 // Search all tinymce editor instances and update the placeholders 33 33 _.each( tinymce.editors, function( editor ) { 34 var doc ;34 var doc, self = this; 35 35 if ( editor.plugins.wpview ) { 36 36 doc = editor.getDoc(); 37 $( doc ).find( '[data-wpview-text="' + this.encodedText + '"]' ).html( html ); 37 $( doc ).find( '[data-wpview-text="' + this.encodedText + '"]' ).each(function (i, elem) { 38 var node = $( elem ); 39 node.html( html ); 40 $( self ).trigger( 'ready', elem ); 41 }); 38 42 } 39 43 }, this ); … … 179 183 /** 180 184 * Refresh views after an update is made 181 * 185 * 182 186 * @param view {object} being refreshed 183 187 * @param text {string} textual representation of the view … … 205 209 }, 206 210 207 /** 211 /** 208 212 * render( scope ) 209 * 213 * 210 214 * Renders any view instances inside a DOM node `scope`. 211 215 * -
trunk/src/wp-includes/js/media-audiovideo.js
r27608 r27615 1 /* global _wpMediaViewsL10n */1 /* global _wpMediaViewsL10n, _wpmejsSettings, MediaElementPlayer */ 2 2 3 3 (function ($, _, Backbone) { … … 62 62 }, 63 63 'chrome' : { 64 audio: ['ogg', 'mpeg' , 'x-ms-wma'],64 audio: ['ogg', 'mpeg'], 65 65 video: ['ogg', 'webm', 'mp4', 'm4v', 'mpeg'] 66 66 }, … … 228 228 }, 229 229 230 shortcode : function (shortcode) {231 var self = this ;232 233 _.each( wp.media.audio.defaults, function( value, key ) {234 shortcode[ key ] = self.coerce( shortcode, key );235 236 if ( value === shortcode[ key ] ) {237 delete shortcode[ key ];230 update : function (model) { 231 var self = this, content; 232 233 _.each( this.defaults, function( value, key ) { 234 model[ key ] = self.coerce( model, key ); 235 236 if ( value === model[ key ] ) { 237 delete model[ key ]; 238 238 } 239 239 }); 240 240 241 return wp.shortcode.string({ 242 tag: 'audio', 243 attrs: shortcode 241 content = model.content; 242 delete model.content; 243 244 return new wp.shortcode({ 245 tag: 'audio', 246 attrs: model, 247 content: content 244 248 }); 245 249 } … … 284 288 }, 285 289 286 shortcode : function (shortcode) { 287 var self = this, content = shortcode.content; 288 delete shortcode.content; 290 update : function (model) { 291 var self = this, content; 289 292 290 293 _.each( this.defaults, function( value, key ) { 291 shortcode[ key ] = self.coerce( shortcode, key );292 293 if ( value === shortcode[ key ] ) {294 delete shortcode[ key ];294 model[ key ] = self.coerce( model, key ); 295 296 if ( value === model[ key ] ) { 297 delete model[ key ]; 295 298 } 296 299 }); 297 300 298 return wp.shortcode.string({ 299 tag: 'video', 300 attrs: shortcode, 301 content = model.content; 302 delete model.content; 303 304 return new wp.shortcode({ 305 tag: 'video', 306 attrs: model, 301 307 content: content 302 308 }); … … 973 979 } ); 974 980 981 wp.mce.media = { 982 toView: function( content ) { 983 var match = wp.shortcode.next( this.shortcode, content ); 984 985 if ( ! match ) { 986 return; 987 } 988 989 return { 990 index: match.index, 991 content: match.content, 992 options: { 993 shortcode: match.shortcode 994 } 995 }; 996 }, 997 998 edit: function( node ) { 999 var p, 1000 media = wp.media[ this.shortcode ], 1001 self = this, 1002 frame, data; 1003 1004 wp.media.mixin.pauseAllPlayers(); 1005 1006 data = window.decodeURIComponent( $( node ).data('wpview-text') ); 1007 frame = media.edit( data ); 1008 frame.on( 'close', function () { 1009 frame.detach(); 1010 } ); 1011 frame.state( self.shortcode + '-details' ).on( 'update', function( selection ) { 1012 var shortcode = wp.media[ self.shortcode ].update( selection ).string(); 1013 $( node ).attr( 'data-wpview-text', window.encodeURIComponent( shortcode ) ); 1014 wp.mce.views.refreshView( self, shortcode ); 1015 frame.detach(); 1016 } ); 1017 frame.open(); 1018 } 1019 }; 1020 1021 wp.mce.media.View = wp.mce.View.extend({ 1022 initialize: function( options ) { 1023 this.shortcode = options.shortcode; 1024 _.bindAll( this, 'setPlayer' ); 1025 $(this).on( 'ready', this.setPlayer ); 1026 }, 1027 1028 setPlayer: function (e, node) { 1029 // if the ready event fires on an empty node 1030 if ( ! node ) { 1031 return; 1032 } 1033 1034 var self = this, 1035 media, 1036 settings = {}, 1037 className = '.wp-' + this.shortcode.tag + '-shortcode'; 1038 1039 if ( this.player ) { 1040 this.unsetPlayer(); 1041 } 1042 1043 media = $( node ).find( className ); 1044 1045 if ( ! _.isUndefined( window._wpmejsSettings ) ) { 1046 settings.pluginPath = _wpmejsSettings.pluginPath; 1047 } 1048 1049 if ( ! this.isCompatible( media ) ) { 1050 media.closest( '.wpview-wrap' ).addClass( 'wont-play' ); 1051 if ( ! media.parent().hasClass( 'wpview-wrap' ) ) { 1052 media.parent().replaceWith( media ); 1053 } 1054 media.replaceWith( '<p>' + media.find( 'source' ).eq(0).prop( 'src' ) + '</p>' ); 1055 return; 1056 } else { 1057 media.closest( '.wpview-wrap' ).removeClass( 'wont-play' ); 1058 if ( this.ua.is( 'ff' ) ) { 1059 media.prop( 'preload', 'metadata' ); 1060 } else { 1061 media.prop( 'preload', 'none' ); 1062 } 1063 } 1064 1065 media = wp.media.view.MediaDetails.prepareSrc( media.get(0) ); 1066 1067 // Thanks, Firefox! 1068 setTimeout(function () { 1069 self.player = new MediaElementPlayer( media, settings ); 1070 }, 50); 1071 }, 1072 1073 getHtml: function() { 1074 var attrs = this.shortcode.attrs.named; 1075 return this.template({ model: attrs }); 1076 } 1077 }); 1078 _.extend( wp.mce.media.View.prototype, wp.media.mixin ); 1079 1080 wp.mce.video = _.extend( {}, wp.mce.media, { 1081 shortcode: 'video', 1082 View: wp.mce.media.View.extend({ 1083 className: 'editor-video', 1084 template: media.template('editor-video') 1085 }) 1086 } ); 1087 1088 wp.mce.views.register( 'video', wp.mce.video ); 1089 1090 wp.mce.audio = _.extend( {}, wp.mce.media, { 1091 shortcode: 'audio', 1092 View: wp.mce.media.View.extend({ 1093 className: 'editor-audio', 1094 template: media.template('editor-audio') 1095 }) 1096 } ); 1097 1098 wp.mce.views.register( 'audio', wp.mce.audio ); 1099 975 1100 function init() { 976 1101 $(document.body) -
trunk/src/wp-includes/js/tinymce/plugins/wpgallery/plugin.js
r27530 r27615 26 26 27 27 function replaceAVShortcodes( content ) { 28 var testRegex = /\[(video-playlist| audio|video|playlist)[^\]]*\]/,29 replaceRegex = /\[(video-playlist| audio|video|playlist)[^\]]*\]([\s\S]*?\[\/\1\])?/;28 var testRegex = /\[(video-playlist|playlist)[^\]]*\]/, 29 replaceRegex = /\[(video-playlist|playlist)[^\]]*\]([\s\S]*?\[\/\1\])?/; 30 30 31 31 while ( testRegex.test( content ) ) { … … 93 93 frame.detach(); 94 94 }); 95 } else if ( editor.dom.hasClass( node, 'wp-video' ) ) {96 frame = wp.media.video.edit( data );97 frame.on( 'close', function () {98 frame.detach();99 } );100 frame.state( 'video-details' ).on(101 'update replace add-source select-poster-image add-track',102 function ( selection ) {103 var shortcode = wp.media.video.shortcode( selection );104 editor.dom.setAttrib( node, 'data-wp-media', window.encodeURIComponent( shortcode ) );105 frame.detach();106 }107 );108 frame.open();109 } else if ( editor.dom.hasClass( node, 'wp-audio' ) ) {110 frame = wp.media.audio.edit( data );111 frame.on( 'close', function () {112 frame.detach();113 } );114 frame.state( 'audio-details' ).on( 'update replace add-source', function ( selection ) {115 var shortcode = wp.media.audio.shortcode( selection );116 editor.dom.setAttrib( node, 'data-wp-media', window.encodeURIComponent( shortcode ) );117 frame.detach();118 } );119 frame.open();120 95 } else { 121 96 // temp … … 178 153 if ( dom.hasClass( node, 'wp-gallery' ) ) { 179 154 event.name = 'gallery'; 180 } else if ( dom.hasClass( node, 'wp-video' ) ) {181 event.name = 'video';182 } else if ( dom.hasClass( node, 'wp-audio' ) ) {183 event.name = 'audio';184 155 } else if ( dom.hasClass( node, 'wp-playlist' ) ) { 185 156 event.name = 'playlist'; -
trunk/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css
r27601 r27615 142 142 } 143 143 144 .mce-content-body img.wp-media.wp-video {145 background-image: url(images/video.png);146 }147 148 .mce-content-body img.wp-media.wp-audio {149 height: 70px;150 background-image: url(images/audio.png);151 }152 153 144 .mce-content-body img.wp-media.wp-playlist { 154 145 background-image: url("images/playlist-audio.png"); … … 224 215 225 216 /** 226 * Gallery preview217 * Media previews 227 218 */ 228 .wpview-type-gallery { 219 .wpview-type-gallery, 220 .wpview-type-audio, 221 .wpview-type-video { 229 222 position: relative; 230 223 margin-bottom: 16px; … … 233 226 } 234 227 235 .wpview-type-gallery:after { 228 .wpview-type-audio { 229 padding: 24px 0 0; 230 } 231 232 .wpview-type-video { 233 padding: 0; 234 } 235 236 .wont-play { 237 padding: 4px 0; 238 } 239 240 .wont-play p { 241 font-size: 13px; 242 line-height: 1.3; 243 display: block; 244 width: 70%; 245 margin: 0 15%; 246 text-align: center; 247 } 248 249 .wpview-type-gallery:after { 236 250 content: ''; 237 251 display: table; … … 239 253 } 240 254 241 .wpview-type-gallery.selected { 255 .wpview-type-gallery.selected, 256 .wpview-type-audio, 257 .wpview-type-video { 242 258 background-color: #f2f8ff; 243 259 border-color: #777; 244 260 } 245 261 246 .wpview-type-gallery .toolbar { 247 position: absolute; 248 top: 0; 249 right: 0; 250 background-color: #333; 251 color: white; 262 .wpview-type-gallery .toolbar, 263 .wpview-type-audio .toolbar, 264 .wpview-type-video .toolbar { 265 position: absolute; 266 top: 0; 267 right: 0; 268 background-color: #333; 269 color: white; 252 270 display: none; 253 } 254 271 z-index: 100; 272 } 273 274 .wpview-type-video .toolbar div, 255 275 .wpview-type-gallery .toolbar div, 256 276 #wp-image-toolbar div { … … 258 278 } 259 279 280 .wpview-type-audio .toolbar div { 281 margin: 2px 5px; 282 } 283 284 .wpview-type-audio .toolbar, 285 .wpview-type-video .toolbar, 260 286 .wpview-type-gallery.selected .toolbar { 261 287 display: block; 262 288 } 263 289 290 .wpview-type-audio .toolbar span, 291 .wpview-type-video .toolbar span, 264 292 .wpview-type-gallery .toolbar span { 265 293 cursor: pointer; -
trunk/src/wp-includes/media-template.php
r27608 r27615 962 962 </div> 963 963 </script> 964 965 <script type="text/html" id="tmpl-editor-audio"> 966 <div class="toolbar"> 967 <div class="dashicons dashicons-format-audio edit"></div> 968 <div class="dashicons dashicons-no-alt remove"></div> 969 </div> 970 <?php wp_underscore_audio_template() ?> 971 </script> 972 973 <script type="text/html" id="tmpl-editor-video"> 974 <div class="toolbar"> 975 <div class="dashicons dashicons-format-video edit"></div> 976 <div class="dashicons dashicons-no-alt remove"></div> 977 </div> 978 <?php wp_underscore_video_template() ?> 979 </script> 980 964 981 <?php 965 982 -
trunk/src/wp-includes/script-loader.php
r27608 r27615 397 397 $scripts->add( 'media-views', "/wp-includes/js/media-views$suffix.js", array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement', 'image-edit' ), false, 1 ); 398 398 $scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 ); 399 $scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 );399 $scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor', 'mce-view' ), false, 1 ); 400 400 $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'media-models' ), false, 1 ); 401 401
Note: See TracChangeset
for help on using the changeset viewer.