r71779 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71778‎ | r71779 | r71780 >
Date:04:55, 27 August 2010
Author:dale
Status:deferred
Tags:
Comment:
* stubs for sequencer AddByUrl support
* some minor usability fixes for editor 'edit clip' selection
* some clean up of remote search driver variables
* removed not used iScroll lib ref
Modified paths:
  • /branches/MwEmbedStandAlone/modules/AddMedia/mw.RemoteSearchDriver.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/AddMedia/searchLibs/flickrSearch.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Playlist/MediaRss.i18n.php (deleted) (history)
  • /branches/MwEmbedStandAlone/modules/Playlist/loader.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/actions/mw.SequencerActionsSequence.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/loader.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.Sequencer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddByUrl.js (added) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddMedia.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerConfig.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTimeline.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTools.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/remotes/mw.MediaWikiRemoteSequencer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBuffer.js (modified) (history)
  • /branches/MwEmbedStandAlone/mwEmbed.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/mwEmbed.js
@@ -1158,7 +1158,7 @@
11591159 * undefined
11601160 */
11611161 mw.isset = function( objectPath ) {
1162 - if ( !objectPath ) {
 1162+ if ( !objectPath || typeof objectPath != 'string') {
11631163 return false;
11641164 }
11651165 var pathSet = objectPath.split( '.' );
Index: branches/MwEmbedStandAlone/modules/Playlist/MediaRss.i18n.php
@@ -1,12 +0,0 @@
2 -<?php
3 -/**
4 - * Internationalisation for SmilPlayer
5 - *
6 - * @file
7 - * @ingroup Extensions
8 - */
9 -
10 -$messages = array();
11 -$messages['en'] = array(
12 - 'mwe-mediarss-untitled' => 'Untitled media asset'
13 -);
Index: branches/MwEmbedStandAlone/modules/Playlist/loader.js
@@ -6,7 +6,6 @@
77 ( function( mw ) {
88
99 mw.addResourcePaths( {
10 - "iScroll" : "iScroll.js",
1110 "mw.Playlist" : "mw.Playlist.js",
1211 "mw.PlaylistHandlerMediaRss" : "mw.PlaylistHandlerMediaRss.js"
1312 });
@@ -32,10 +31,6 @@
3332 // Module loader
3433 mw.addModuleLoader( 'Playlist', function(){
3534 var resourceList = ["mw.Playlist", "mw.PlaylistHandlerMediaRss" ]
36 - // xxx should detect touch support rather than mobile safari check
37 - if( mw.isMobileSafari() ){
38 - resourceList.push( "iScroll" );
39 - }
4035 return resourceList;
4136 });
4237
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBuffer.js
@@ -386,12 +386,12 @@
387387 var assetId = this.smil.getPageDomId( smilElement );
388388 // Make sure the image is in the dom ( load it )
389389 this.loadElement( smilElement );
390 - mw.log("loadImageCallback:: drwa img: " + assetId + $j( '#' + assetId ).length );
 390+ mw.log( "loadImageCallback:: drwa img: " + assetId + $j( '#' + assetId ).length );
391391 // If we already have naturalHeight no need for loading callback
392 - if( $j( '#' + assetId).get(0).naturalHeight ){
 392+ if( $j( '#' + assetId ).get(0).naturalHeight ){
393393 callback();
394 - }else {
395 - $j( '#' + assetId).load( callback );
 394+ } else {
 395+ $j( '#' + assetId ).load( callback );
396396 }
397397 },
398398
@@ -437,8 +437,12 @@
438438 }
439439 }
440440
441 - // Issue the seek
442 - vid.currentTime = seekTime;
 441+ // Issue the seek if the vid still exists
 442+ try{
 443+ vid.currentTime = seekTime;
 444+ } catch ( e ){
 445+ mw.log( 'Error: in SmilBuffer could not set currentTime' );
 446+ }
443447 }
444448
445449 // Read the video state: http://www.w3.org/TR/html5/video.html#dom-media-have_nothing
Index: branches/MwEmbedStandAlone/modules/AddMedia/searchLibs/flickrSearch.js
@@ -16,7 +16,7 @@
1717 this.init( options );
1818 }
1919 flickrSearch.prototype = {
20 - dtUrl : 'http://www.flickr.com/photos/',
 20+ detailsUrl : 'http://www.flickr.com/photos/',
2121 // @@todo probably would be good to read the api-key from configuration
2222 apikey : '2867787a545cc66c0bce6f2e57aca1d1',
2323 // What license we are interested in
@@ -102,7 +102,7 @@
103103 var resource = {
104104 'titleKey' : flickrResource.title + '.jpg',
105105 'resourceKey': flickrResource.id,
106 - 'link' : _this.dtUrl + flickrResource.pathalias + '/' + flickrResource.id,
 106+ 'link' : _this.detailsUrl + flickrResource.pathalias + '/' + flickrResource.id,
107107 'title' : flickrResource.title,
108108 'thumbwidth' : flickrResource.width_t,
109109 'thumbheight': flickrResource.height_t,
Index: branches/MwEmbedStandAlone/modules/AddMedia/mw.RemoteSearchDriver.js
@@ -278,7 +278,10 @@
279279 'this_wiki': {
280280 'enabled': 1,
281281 'apiUrl': ( wgServer && wgScriptPath ) ?
282 - wgServer + wgScriptPath + '/api.php' : null,
 282+ wgServer + wgScriptPath + '/api.php' : null,
 283+
 284+ 'detailsUrl' : wgServer + wgArticlePath,
 285+
283286 'lib': 'mediaWiki',
284287 'homepage' : ( wgServer && wgScript ) ?
285288 wgServer + wgScript : null,
@@ -293,6 +296,8 @@
294297 'enabled': 1,
295298 'homepage': 'http://kaltura.com',
296299 'apiUrl': 'http://kaldev.kaltura.com/michael/aggregator.php',
 300+
 301+ 'detailsUrl' : wgServer + wgArticlePath,
297302 'lib': 'kaltura',
298303 'resource_prefix' : '',
299304 'tab_image':false
@@ -536,6 +541,8 @@
537542 }
538543 return this;
539544 },
 545+
 546+
540547
541548 /**
542549 * Get license icon html
@@ -936,40 +943,50 @@
937944 // Setup base cancel button binding
938945 this.onCancelResourceEdit();
939946 },
 947+ /**
 948+ * public function to get enabled content providers
 949+ */
 950+ getEnabledProviders: function(){
 951+ var enabledProviders = {};
 952+ for ( var providerName in this.content_providers ) {
 953+ var content_providers = this.content_providers;
 954+ var provider = content_providers[ providerName ];
 955+ if ( provider.enabled && provider.apiUrl ) {
 956+ enabledProviders[providerName] = provider;
 957+ }
 958+ }
 959+ return enabledProviders;
 960+ },
940961
941962 createProviderSelection: function(){
942963 var _this = this;
943964 var $providerSelection = $j( '<ul />' )
944965 .addClass( "ui-provider-selection" );
945966 // Add enabled search providers.
946 - for ( var providerName in this.content_providers ) {
947 - var content_providers = this.content_providers;
948 - var provider = content_providers[ providerName ];
949 - if ( provider.enabled && provider.apiUrl ) {
950 - var $anchor = $j( '<div />' )
951 - .text( gM( 'rsd-' + providerName + '-title' ) )
952 - .attr({
953 - name: providerName
954 - });
955 - if ( this.current_provider == providerName) {
956 - $anchor.addClass( 'ui-selected' );
957 - }
958 -
959 - $anchor.click( function() {
960 - $j( this ).parent().parent().find( '.ui-selected' )
961 - .removeClass( 'ui-selected' );
962 - $j( this ).addClass( 'ui-selected' );
963 - _this.current_provider = $j( this ).attr( "name" );
964 - // Update the search results on provider selection
965 - _this.updateResults( _this.current_provider, true );
966 - return false;
 967+ $j.each( _this.getEnabledProviders(), function(providerName, provider){
 968+ var $anchor = $j( '<div />' )
 969+ .text( gM( 'rsd-' + providerName + '-title' ) )
 970+ .attr({
 971+ name: providerName
967972 });
968 -
969 - var $listItem = $j( '<li />' );
970 - $listItem.append( $anchor );
971 - $providerSelection.append( $listItem );
 973+ if ( _this.current_provider == providerName) {
 974+ $anchor.addClass( 'ui-selected' );
972975 }
973 - }
 976+
 977+ $anchor.click( function() {
 978+ $j( this ).parent().parent().find( '.ui-selected' )
 979+ .removeClass( 'ui-selected' );
 980+ $j( this ).addClass( 'ui-selected' );
 981+ _this.current_provider = $j( this ).attr( "name" );
 982+ // Update the search results on provider selection
 983+ _this.updateResults( _this.current_provider, true );
 984+ return false;
 985+ });
 986+
 987+ var $listItem = $j( '<li />' );
 988+ $listItem.append( $anchor );
 989+ $providerSelection.append( $listItem );
 990+ });
974991 return $providerSelection;
975992 },
976993 /**
@@ -3229,7 +3246,7 @@
32303247 },
32313248
32323249 /*
3233 - * Sets the dispaly mode
 3250+ * Sets the display mode
32343251 * @param {String} mode Either "box" or "list"
32353252 */
32363253 setDisplayMode: function( mode ) {
Index: branches/MwEmbedStandAlone/modules/Sequencer/loader.js
@@ -13,6 +13,7 @@
1414
1515 "mw.SequencerServer" : "mw.SequencerServer.js",
1616 "mw.SequencerAddMedia" : "mw.SequencerAddMedia.js",
 17+ "mw.SequencerAddByUrl" : "mw.SequencerAddByUrl.js",
1718 "mw.SequencerPlayer" : "mw.SequencerPlayer.js",
1819 "mw.SequencerTimeline" : "mw.SequencerTimeline.js",
1920 "mw.SequencerKeyBindings" : "mw.SequencerKeyBindings.js",
@@ -56,7 +57,8 @@
5758 [
5859 '$j.contextMenu',
5960
60 - 'mw.SequencerServer',
 61+ 'mw.SequencerServer',
 62+ 'mw.SequencerAddByUrl',
6163 'mw.SequencerAddMedia',
6264 'mw.SequencerPlayer',
6365 'mw.SequencerRender',
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.Sequencer.js
@@ -272,7 +272,7 @@
273273 }
274274 return this.timeline;
275275 },
276 - getEditTools: function(){
 276+ getTools: function(){
277277 if( !this.editTools ){
278278 this.editTools = new mw.SequencerTools( this );
279279 }
@@ -284,6 +284,12 @@
285285 }
286286 return this.addMedia;
287287 },
 288+ getAddByUrl: function(){
 289+ if( ! this.addByUrl ){
 290+ this.addByUrl = new mw.SequencerAddByUrl( this );
 291+ }
 292+ return this.addByUrl
 293+ },
288294 getKeyBindings:function(){
289295 if( ! this.keyBindings ){
290296 this.keyBindings = new mw.SequencerKeyBindings( this );
@@ -319,6 +325,7 @@
320326 * Get the UI layout
321327 */
322328 getUiLayout: function(){
 329+ var _this = this;
323330 // xxx There is probably a cleaner way to generate a list of jQuery objects than $j('new').children();
324331 return $j('<div />').append(
325332 $j('<div />')
@@ -346,7 +353,7 @@
347354 .append(
348355 $j('<div />')
349356 .addClass( "ui-layout-center mwseq-edit" )
350 - .html( gM('mwe-sequencer-no_selected_resource') ),
 357+ .html( _this.getTools().getDefaultText() ),
351358 $j('<div />')
352359 .addClass( "ui-layout-east mwseq-player" )
353360 .text( gM('mwe-sequencer-loading-player') ),
Index: branches/MwEmbedStandAlone/modules/Sequencer/actions/mw.SequencerActionsSequence.js
@@ -146,7 +146,7 @@
147147 } else {
148148 $dialog.empty().text( gM('mwe-sequencer-already-published') )
149149 var buttons = {};
150 - buttons[ gm('mwe-ok') ] = function(){
 150+ buttons[ gM('mwe-ok') ] = function(){
151151 $j( this ).dialog( 'close' );
152152 }
153153 $dialog.dialog( 'option', 'buttons', buttons);
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddMedia.js
@@ -14,8 +14,49 @@
1515
1616 init: function( sequencer ){
1717 this.sequencer = sequencer;
 18+ },
 19+ getDefaultSearchText: function(){
 20+ return gM( 'mwe-sequencer-url-or-search');
1821 },
19 -
 22+ getSearchDriver: function( callback ){
 23+ var _this = this;
 24+ if( ! _this.remoteSearchDriver ){
 25+ // Get any sequencer configured options
 26+ var addMediaOptions = _this.sequencer.getOption('AddMedia');
 27+ addMediaOptions = $j.extend( {
 28+ 'target_container' : _this.sequencer.getEditToolTarget(),
 29+ 'target_search_input' : _this.sequencer.getMenuTarget().find('input.searchMedia'),
 30+ 'displaySearchInput': false,
 31+ 'displayResourceInfoIcons' : false,
 32+ 'resourceSelectionCallback' : function( resource ){
 33+ mw.addLoaderDialog( gM( 'mwe-sequencer-loading-asset' ) );
 34+ // Get convert resource to smilClip and insert into the timeline
 35+ _this.getSmilClipFromResource( resource, function( smilClip ) {
 36+ _this.sequencer.getTimeline().insertSmilClipEdit( smilClip );
 37+ mw.closeLoaderDialog();
 38+ });
 39+ return false;
 40+ },
 41+ 'displaySearchResultsCallback' : function(){
 42+ _this.addSearchResultsDrag();
 43+ }
 44+ }, addMediaOptions );
 45+
 46+ // Update the search value if has changed from the default search text helper:
 47+ var inputValue = _this.sequencer.getMenuTarget().find('input.searchMedia').val();
 48+ if( inputValue != _this.getDefaultSearchText() )
 49+ addMediaOptions.default_query = inputValue;
 50+
 51+
 52+ // set the tool target to loading
 53+ mw.load( 'AddMedia.addMediaWizard', function(){
 54+ _this.remoteSearchDriver = new mw.RemoteSearchDriver( addMediaOptions );
 55+ callback( _this.remoteSearchDriver );
 56+ });
 57+ } else {
 58+ callback (_this.remoteSearchDriver )
 59+ }
 60+ },
2061 // Get the menu widget that drives the search and upload tab selection
2162 getMenuWidget: function(){
2263 var _this = this;
@@ -26,7 +67,7 @@
2768 $j('<input />')
2869 .addClass( 'searchMedia')
2970 .val(
30 - gM( 'mwe-sequencer-url-or-search')
 71+ _this.getDefaultSearchText()
3172 )
3273 .css({'color': '#888', 'zindex': 2})
3374 .focus( function(){
@@ -61,7 +102,7 @@
62103 'icon' : 'plus'
63104 })
64105 .click(function(){
65 - // only do the search if the user has given the search input focus
 106+ // Only do the search if the user has given the search input focus
66107 if( widgetFocus ){
67108 _this.proccessRequest();
68109 }
@@ -72,43 +113,39 @@
73114 },
74115 proccessRequest: function(){
75116 var _this = this;
76 - // get the input text
77 - var inputValue = this.sequencer.getMenuTarget().find('input.searchMedia').val();
78 -
 117+
79118 this.sequencer.getEditToolTarget()
80119 .empty()
81120 .loadingSpinner();
82121
83 - if( ! _this.remoteSearchDriver ){
84 - // set the tool target to loading
85 - mw.load( 'AddMedia.addMediaWizard', function(){
86 - _this.remoteSearchDriver = new mw.RemoteSearchDriver({
87 - 'target_container' : _this.sequencer.getEditToolTarget(),
88 - 'target_search_input' : _this.sequencer.getMenuTarget().find('input.searchMedia'),
89 - 'displaySearchInput': false,
90 - 'default_query' : inputValue,
91 - 'displayResourceInfoIcons' : false,
92 - 'resourceSelectionCallback' : function( resource ){
93 - mw.addLoaderDialog( gM( 'mwe-sequencer-loading-asset' ) );
94 - // Get convert resource to smilClip and insert into the timeline
95 - _this.getSmilClipFromResource( resource, function( smilClip ) {
96 - _this.sequencer.getTimeline().insertSmilClipEdit( smilClip );
97 - mw.closeLoaderDialog();
98 - });
99 - return false;
100 - },
101 - 'displaySearchResultsCallback' : function(){
102 - _this.addSearchResultsDrag();
103 - }
104 - });
105 - // Create the search user interface:
106 - _this.remoteSearchDriver.createUI();
107 - });
108 - } else {
109 - this.remoteSearchDriver.createUI()
110 - }
 122+ this.getSearchDriver( function( remoteSearchDriver ){
 123+ // Check if input value can be handled by url
 124+ var inputValue = _this.sequencer.getMenuTarget().find('input.searchMedia').val();
 125+ if( _this.sequencer.getAddByUrl().isUrl( inputValue) ){
 126+ _this.sequencer.addByUrlDialog().addByUrl( remoteSearchDriver, inputValue );
 127+ } else {
 128+ // Else just use the remoteSearchDriver search interface
 129+ remoteSearchDriver.createUI();
 130+ }
 131+ });
 132+ },
 133+ /**
 134+ * Handles url asset importing
 135+ * xxx should probably re factor into separate class
 136+ *
 137+ * Checks for commons ulr profile, future profiles could include flickr, youtube etc.
 138+ * tries to ascertain content type by url and directly load the media
 139+ * @param {String} url to be imported to the sequence
 140+ */
 141+ proccessUrlRequest: function( url ){
 142+ // Check if its a local domain ( we can directly request the "head" of the file to get its type )
 143+
 144+ // Check url type
 145+ var parsedUrl = mw.parseUri( url );
 146+ if( host == 'commons.wikimedia.org' ){
 147+ }
 148+ },
111149
112 - },
113150 /**
114151 * Get the resource object from a provided asset
115152 */
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTools.js
@@ -92,7 +92,7 @@
9393
9494 // Close / empty the toolWindow
9595 _this.sequencer.getEditToolTarget().html(
96 - _this.defaultText
 96+ _this.getDefaultText()
9797 )
9898 }
9999 }
@@ -217,11 +217,13 @@
218218 }
219219 }
220220 },
 221+ getDefaultText: function(){
 222+ return gM('mwe-sequencer-no_selected_resource');
 223+ },
221224 getEditToolId: function( toolId, attributeName){
222225 return 'editTool_' + toolId + '_' + attributeName;
223 - },
 226+ },
224227
225 -
226228 drawClipEditTools: function( $target, smilClip){
227229
228230 var toolId = '';
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerConfig.js
@@ -21,8 +21,12 @@
2222 "Sequencer.AddMediaImageDuration" : 2,
2323
2424 // Default image source width
25 - "Sequencer.AddMediaImageWidth" : 640,
 25+ "Sequencer.AddMediaImageWidth" : 640,
2626
 27+ // If a asset can be directly added to the sequence by url
 28+ // ( if disabled only urls that are part addMedia can be added )
 29+ "Sequencer.AddAssetByUrl" : true,
 30+
2731 // Default timeline clip timeline track height
2832 "Sequencer.TimelineTrackHeight" : 100,
2933
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTimeline.js
@@ -306,7 +306,7 @@
307307 // get the smil element for the edit tool:
308308 var smilClip = smil.$dom.find( '#' + $j( selectedClip ).data('smilId') );
309309 var toolTarget = this.sequencer.getEditToolTarget();
310 - this.sequencer.getEditTools().drawClipEditTools( toolTarget, smilClip );
 310+ this.sequencer.getTools().drawClipEditTools( toolTarget, smilClip );
311311 },
312312
313313 /**
@@ -453,7 +453,7 @@
454454 },
455455
456456 /**
457 - * Handle multiple selections based on what clips was just "cliked"
 457+ * Handle multiple selections based on what clips was just selected
458458 */
459459 handleMultiSelect: function( clickClip ){
460460 var _this = this;
@@ -535,7 +535,7 @@
536536 )
537537 } else {
538538 // A single clip is selected edit that clip
539 - _this.editClip( clickClip );
 539+ _this.editClip( clickClip );
540540 }
541541 // Register the edit tools update for undo
542542 _this.sequencer.getActionsEdit().registerEdit();
@@ -593,8 +593,11 @@
594594 .hide()
595595 .buttonHover()
596596 .click( function(){
 597+ _this.getTimelineContainer().find('.selectedClip').removeClass( 'selectedClip' );
597598 _this.editClip( $timelineClip )
598599 $timelineClip.addClass( 'selectedClip' );
 600+ // Seek to the edit clip
 601+ _this.seekToStartOfClip( $timelineClip );
599602 return false;
600603 }),
601604
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddByUrl.js
@@ -0,0 +1,42 @@
 2+/**
 3+* Sequencer add by url support ( ties into mwEmbed AddMedia remoteSearchDriver module )
 4+*/
 5+
 6+//Wrap in mw closure
 7+( function( mw ) {
 8+
 9+mw.SequencerAddByUrl = function( sequencer ) {
 10+ return this.init( sequencer );
 11+};
 12+mw.SequencerAddByUrl.prototype = {
 13+ init: function( sequencer ){
 14+ this.sequencer = sequencer;
 15+ },
 16+
 17+ /**
 18+ * Does a basic parseUri check to see if a string is likely a url:
 19+ */
 20+ isUrl: function( inputString ){
 21+ return ( mw.parseUri( inputString ).authority != mw.parseUri( inputString ).host ) ;
 22+ },
 23+
 24+ /**
 25+ * Try to add media via url and present a dialog if failed
 26+ * or user input is required
 27+ *
 28+ * Uses remoteSearchDriver to help in retrieving entry info
 29+ * @param {Object} remoteSearchDriver The remote search driver
 30+ */
 31+ addByUrlDialog: function( remoteSearchDriver, url ){
 32+ // see if the asset matches the key type of any enabled content provider:
 33+ $j.each( remoteSearchDriver.getEnabledProviders(), function(providerName, provider){
 34+
 35+ });
 36+
 37+ if( mw.getConfig( 'Sequencer.AddAssetByUrl' )){
 38+ // try directly adding the asset
 39+ }
 40+ }
 41+}
 42+
 43+} )( window.mw );
\ No newline at end of file
Index: branches/MwEmbedStandAlone/modules/Sequencer/remotes/mw.MediaWikiRemoteSequencer.js
@@ -1,6 +1,6 @@
22 /**
33 * Stop-gap for php sequencer support does some transformations
4 -* to normal page views to support sequences edits
 4+* to page views to support sequence namespace
55 *
66 * Supports basic "sequencer" functionality as a javascript rewrite system.
77 */
@@ -77,128 +77,128 @@
7878 },
7979 displayPlayerEmbed: function(){
8080 var _this = this;
81 -
82 - // Check if the sequence has been flattened and is up to date:
83 - var request = {
84 - 'action': 'query',
85 - 'titles': _this.getSequenceFileKey( wgPageName ),
86 - 'prop': 'imageinfo|revisions',
87 - 'iiprop': 'url|metadata',
88 - 'iiurlwidth': '400',
89 - 'redirects' : true // automatically follow redirects
90 - };
91 - var $embedPlayer = $j('<div />');
92 - mw.getJSON( request, function( data ){
93 - if(!data.query || !data.query.pages || data.query.pages[-1]){
94 - // no flattened file found
95 - $embedPlayer.append(
96 - $j( '<div />').append(
97 - gM('mwe-sequencer-not-published')
 81+ // load the embedPlayer module:
 82+ mw.load('EmbedPlayer', function(){
 83+ // Check if the sequence has been flattened and is up to date:
 84+ var request = {
 85+ 'action': 'query',
 86+ 'titles': _this.getSequenceFileKey( wgPageName ),
 87+ 'prop': 'imageinfo|revisions',
 88+ 'iiprop': 'url|metadata',
 89+ 'iiurlwidth': '400',
 90+ 'redirects' : true // automatically follow redirects
 91+ };
 92+ var $embedPlayer = $j('<div />');
 93+ mw.getJSON( request, function( data ){
 94+ if(!data.query || !data.query.pages || data.query.pages[-1]){
 95+ // no flattened file found
 96+ $embedPlayer.append(
 97+ $j( '<div />').append(
 98+ gM('mwe-sequencer-not-published')
 99+ )
 100+ .addClass( 'ui-state-highlight' )
98101 )
99 - .addClass( 'ui-state-highlight' )
100 - )
101 - return ;
102 - }
103 - for( var pageId in data.query.pages) {
104 - var page = data.query.pages[ pageId ];
105 -
106 - // Check that the file has a later revision than the
107 - // page. ( up to date sequences always are later than
108 - // the revision of the page saved ).
109 - if( page.revisions && page.revisions[0] ){
110 - if( page.revisions[0].revid < wgCurRevisionId ){
111 - // flattened file out of date
112 - $embedPlayer.append(
113 - $j('<div />').append(
114 - gM('mwe-sequencer-published-out-of-date')
115 - ).addClass( 'ui-state-highlight' )
116 - )
 102+ return ;
 103+ }
 104+ for( var pageId in data.query.pages) {
 105+ var page = data.query.pages[ pageId ];
 106+
 107+ // Check that the file has a later revision than the
 108+ // page. ( up to date sequences always are later than
 109+ // the revision of the page saved ).
 110+ if( page.revisions && page.revisions[0] ){
 111+ if( page.revisions[0].revid < wgCurRevisionId ){
 112+ // flattened file out of date
 113+ $embedPlayer.append(
 114+ $j('<div />').append(
 115+ gM('mwe-sequencer-published-out-of-date')
 116+ ).addClass( 'ui-state-highlight' )
 117+ )
 118+ }
117119 }
118 - }
119 - if( page.imageinfo && page.imageinfo[0] ){
120 - var imageinfo = page.imageinfo[0];
121 - var duration = 0;
122 - for( var i=0;i< imageinfo.metadata.length; i++){
123 - if( imageinfo.metadata[i].name == 'length' ){
124 - duration = Math.round(
125 - imageinfo.metadata[i].value * 1000
126 - ) / 1000;
 120+ if( page.imageinfo && page.imageinfo[0] ){
 121+ var imageinfo = page.imageinfo[0];
 122+ var duration = 0;
 123+ for( var i=0;i< imageinfo.metadata.length; i++){
 124+ if( imageinfo.metadata[i].name == 'length' ){
 125+ duration = Math.round(
 126+ imageinfo.metadata[i].value * 1000
 127+ ) / 1000;
 128+ }
127129 }
 130+ // Append a player to the embedPlayer target
 131+ // -- special title key sequence name bound
 132+ $embedPlayer.append(
 133+ $j('<video />')
 134+ .attr({
 135+ 'id' : 'embedSequencePlayer',
 136+ 'poster' : imageinfo.thumburl,
 137+ 'durationHint' : duration,
 138+ 'apiTitleKey' : page.title.replace('File:',''),
 139+ })
 140+ .addClass('kskin')
 141+ .css({
 142+ 'width': imageinfo.thumbwidth,
 143+ 'height' : imageinfo.thumbheight
 144+ })
 145+ .append(
 146+ // ogg source
 147+ $j('<source />')
 148+ .attr({
 149+ 'type': 'video/ogg',
 150+ 'src' : imageinfo.url
 151+ })
 152+ )
 153+ )
128154 }
129 - // Append a player to the embedPlayer target
130 - // -- special title key sequence name bound
131 - $embedPlayer.append(
132 - $j('<video />')
133 - .attr({
134 - 'poster' : imageinfo.thumburl,
135 - 'durationHint' : duration,
136 - 'apiTitleKey' : page.title.replace('File:',''),
137 - })
138 - .addClass('kskin')
139 - .css({
140 - 'width': imageinfo.thumbwidth,
141 - 'height' : imageinfo.thumbheight
142 - })
143 - .append(
144 - // ogg source
145 - $j('<source />')
146 - .attr({
147 - 'type': 'video/ogg',
148 - 'src' : imageinfo.url
149 - })
150 - )
 155+ }
 156+ // Display embed sequence
 157+ $j( _this.target ).empty().append(
 158+ $j('<div />')
 159+ .addClass( 'sequencer-player')
 160+ .css( {
 161+ 'float' : 'left',
 162+ 'width' : imageinfo.thumbwidth
 163+ })
 164+ .append(
 165+ $embedPlayer
151166 )
152 - }
153 - }
154 - // Display embed sequence
155 - $j( _this.target ).empty().append(
156 - $j('<div />')
157 - .addClass( 'sequencer-player')
158 - .css( {
159 - 'float' : 'left',
160 - 'width' : imageinfo.thumbwidth
161 - })
162 - .append(
163 - $embedPlayer
164 - )
165 - ,
166 -
167 - // Embed player
168 - $j('<div />')
169 - .addClass( 'sequencer-embed-helper')
170 - .css({
171 - 'margin-left': '430px'
172 - })
173 -
174 - // Text embed code
175 - .append(
176 - $j('<h3 />')
177 - .text( gM('mwe-sequencer-embed-sequence') )
178167 ,
179 - $j('<span />' )
180 - .text( gM('mwe-sequencer-embed-sequence-desc') )
181 - ,
182 - $j('<br />'),
183 - $j('<textarea />')
 168+
 169+ // Embed player
 170+ $j('<div />')
 171+ .addClass( 'sequencer-embed-helper')
184172 .css({
185 - 'width' : '100%',
186 - 'height' : '200px'
187 - }).focus(function(){
188 - $j(this).select();
 173+ 'margin-left': '430px'
189174 })
 175+
 176+ // Text embed code
190177 .append(
191 - _this.getSequenceEmbedCode()
192 - )
193 - ),
194 -
195 - // Add a clear both to give content body height
196 - $j('<div />').css({'clear': 'both'})
197 - )
198 -
199 - }); // load json player data
200 -
201 - mw.load('EmbedPlayer', function(){
202 - $j( _this.target ).find('video').embedPlayer();
 178+ $j('<h3 />')
 179+ .text( gM('mwe-sequencer-embed-sequence') )
 180+ ,
 181+ $j('<span />' )
 182+ .text( gM('mwe-sequencer-embed-sequence-desc') )
 183+ ,
 184+ $j('<br />'),
 185+ $j('<textarea />')
 186+ .css({
 187+ 'width' : '100%',
 188+ 'height' : '200px'
 189+ }).focus(function(){
 190+ $j(this).select();
 191+ })
 192+ .append(
 193+ _this.getSequenceEmbedCode()
 194+ )
 195+ ),
 196+
 197+ // Add a clear both to give content body height
 198+ $j('<div />').css({'clear': 'both'})
 199+ )
 200+ // Rewrite the player
 201+ $j('#embedSequencePlayer').embedPlayer();
 202+ }); // load json player data
203203 })
204204 },
205205 getSequenceEmbedCode: function(){

Status & tagging log