r71873 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71872‎ | r71873 | r71874 >
Date:08:38, 29 August 2010
Author:dale
Status:deferred
Tags:
Comment:
* improved addByUrl support
* refactor tool support for per tool tabs
* added callback chain for track drawing operaionts.
* audio, by default goes into audio track
Modified paths:
  • /branches/MwEmbedStandAlone/modules/AddMedia/mw.RemoteSearchDriver.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/AddMedia/mw.UploadForm.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/AddMedia/searchLibs/baseRemoteSearch.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/AddMedia/searchLibs/flickrSearch.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/AddMedia/searchLibs/mediaWikiSearch.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/Sequencer.i18n.php (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/css/mw.style.Sequencer.css (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.Sequencer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddByUrl.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddMedia.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/modules/SmilPlayer/mw.SmilLayout.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/TimedText/remotes/RemoteMwTimedText.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilLayout.js
@@ -113,7 +113,7 @@
114114 }
115115 },
116116
117 - drawElementThumb: function( $target, $node, relativeTime ){
 117+ drawElementThumb: function( $target, $node, relativeTime, callback){
118118 mw.log('SmilLayout::drawElementThumb: ' + $node.attr('id') + ' relative time:' + relativeTime );
119119 if( $target.length == 0 ){
120120 mw.log("Error drawElementThumb to empty target");
@@ -121,10 +121,12 @@
122122 }
123123 // parse the time in case it came in as human input
124124 relativeTime = this.smil.parseTime( relativeTime );
125 - switch ( this.smil.getRefType( $node )){
126 - case 'video':
127 - this.getVideoCanvasThumb($target, $node, relativeTime )
128 - break;
 125+
 126+ if( this.smil.getRefType( $node ) == 'video' ){
 127+ this.getVideoCanvasThumb($target, $node, relativeTime, callback )
 128+ return ;
 129+ }
 130+ switch ( this.smil.getRefType( $node ) ){
129131 case 'img':
130132 // xxx we could eventually use canvas as well but for now just add it at 100%
131133 $target.html(
@@ -151,14 +153,20 @@
152154 ,
153155 $j('<span />')
154156 .attr('title', titleStr)
155 - .css({'position': 'absolute', 'left':'16px'})
 157+ .css({
 158+ 'position': 'absolute',
 159+ 'left':'16px',
 160+ 'font-size' : 'x-small'
 161+ })
156162 .text( titleStr )
157163 )
158164 break;
159 - }
 165+ }
 166+ if( callback )
 167+ callback();
160168 },
161169
162 - getVideoCanvasThumb: function($target, $node, relativeTime ){
 170+ getVideoCanvasThumb: function($target, $node, relativeTime, callback ){
163171 var _this = this;
164172 var naturaSize = {};
165173 var drawElement = $j( '#' + this.smil.getPageDomId( $node ) ).get(0);
@@ -172,22 +180,28 @@
173181 naturaSize.width = drawElement.videoWidth;
174182
175183 // Draw the thumb via canvas grab
176 - // NOTE I attempted to scale down the image using canvas but failed
 184+ // NOTE canvas scale issue prevents redraw at thumb resolution
177185 // xxx should revisit thumb size issue:
178 - $target.html( $j('<canvas />')
179 - .attr({
180 - height: naturaSize.height,
181 - width : naturaSize.width
182 - }).css( {
183 - height:'100%',
184 - widht:'100%'
185 - })
186 - .addClass("ui-corner-all")
187 - )
188 - .find( 'canvas')
189 - .get(0)
190 - .getContext('2d')
191 - .drawImage( drawElement, 0, 0)
 186+ try{
 187+ $target.html( $j('<canvas />')
 188+ .attr({
 189+ height: naturaSize.height,
 190+ width : naturaSize.width
 191+ }).css( {
 192+ height:'100%',
 193+ widht:'100%'
 194+ })
 195+ .addClass("ui-corner-all")
 196+ )
 197+ .find( 'canvas')
 198+ .get(0)
 199+ .getContext('2d')
 200+ .drawImage( drawElement, 0, 0)
 201+ } catch (e){
 202+ mw.log("Error:: getVideoCanvasThumb : could not draw canvas image");
 203+ }
 204+ if( callback )
 205+ callback();
192206 }
193207
194208 // check if relativeTime transform matches current absolute time then render directly:
@@ -201,7 +215,7 @@
202216 // span new draw element
203217 var $tmpFrameNode = $node.clone();
204218 $tmpFrameNode.attr('id', $node.attr('id') + '_tmpFrameNode' );
205 - this.smil.getBuffer().bufferedSeek( $tmpFrameNode, relativeTime, function(){
 219+ this.smil.getBuffer().bufferedSeekRelativeTime( $tmpFrameNode, relativeTime, function(){
206220 // update the drawElement
207221 drawElement = $j( '#' + _this.smil.getPageDomId( $tmpFrameNode ) ).get(0);
208222 drawFrame( drawElement );
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBuffer.js
@@ -295,8 +295,8 @@
296296 /**
297297 * Clip ready for grabbing a frame such as a canvas thumb
298298 */
299 - bufferedSeek: function( smilElement, relativeTime, callback ){
300 - mw.log("SmilBuffer::bufferedSeek:" + this.smil.getPageDomId( smilElement ) + ' time:' + relativeTime );
 299+ bufferedSeekRelativeTime: function( smilElement, relativeTime, callback ){
 300+ mw.log("SmilBuffer::bufferedSeekRelativeTime:" + this.smil.getPageDomId( smilElement ) + ' time:' + relativeTime );
301301
302302 var absoluteTime = relativeTime;
303303 if( $j( smilElement ).attr('clipBegin') ){
Index: branches/MwEmbedStandAlone/modules/TimedText/remotes/RemoteMwTimedText.js
@@ -158,7 +158,7 @@
159159 _this.embedByTitle( pt[1], callback);
160160 return ;
161161 } else {
162 - mw.log( 'Error: addByTitle could not process redirect' );
 162+ mw.log( 'Error: getTitleResource could not process redirect' );
163163 callback( false );
164164 return false;
165165 }
Index: branches/MwEmbedStandAlone/modules/AddMedia/searchLibs/mediaWikiSearch.js
@@ -28,33 +28,48 @@
2929 * @param {String} title Title of the resource to be added
3030 * @param {Function} callback Function called once title resource acquired
3131 */
32 - addByTitle:function( title , callback, redirect_count ) {
 32+ getByTitle:function( title , callback ) {
3333
34 - mw.log( "AddByTitle::" + title );
 34+ mw.log( "MediaWikiSearch:: getByTitle:" + title );
3535
36 - var _this = this;
37 - if ( !redirect_count )
38 - redirect_count = 0;
39 - if ( redirect_count > 5 ) {
40 - mw.log( 'Error: addByTitle too many redirects' );
41 - callback( false );
42 - return false;
43 - }
 36+ var _this = this;
 37+
4438 var request = {
45 - 'titles':'File:' + title,
46 - 'prop':'imageinfo|revisions|categories',
47 - 'iiprop':'url|mime|size',
48 - 'iiurlwidth': parseInt( this.rsd.thumb_width ),
49 - 'rvprop':'content',
 39+ 'titles' : 'File:' + title.replace(/File:|Image:/ig, ''),
 40+ 'prop' : 'imageinfo|revisions|categories',
 41+ 'iiprop' : 'url|mime|size|metadata',
 42+ 'iiurlwidth' : parseInt( this.rsd.thumb_width ),
 43+ 'rvprop' : 'content',
5044 'redirects' : true
5145 }
52 - mw.getJSON(this.provider.apiUrl, request, function( data ) {
 46+ mw.getJSON( this.provider.apiUrl, request, function( data ) {
5347 // call addSingleResult
5448 callback( _this.addSingleResult( data ) );
5549 });
5650 },
57 -
 51+
 52+ getResourceFromUrl: function( url, callback ){
 53+ this.getByTitle( this.getTitleKeyFromMwUrl( url ), callback );
 54+ },
5855 /**
 56+ * Does best effort to get the title key from a mediawiki url
 57+ */
 58+ getTitleKeyFromMwUrl: function( url ){
 59+ // try for title key param
 60+ var titleKey = mw.parseUri( url ).queryKey['title'];
 61+ if( titleKey ){
 62+ return titleKey;
 63+ }
 64+ // else try for title url map
 65+ titleKey = url.replace( this.provider.detailsUrl.replace( '$1', ''), '' );
 66+ if( titleKey != url ){
 67+ return titleKey;
 68+ }
 69+ mw.log("Error: mediaWikiSearch:: getResourceFromUrl could not get title form url: " + url );
 70+ return false;
 71+ },
 72+
 73+ /**
5974 * Get recent upload by user and add them as results
6075 *
6176 * @param {String} user Name of the user
@@ -88,7 +103,7 @@
89104 var resourceQuery = {
90105 'titles' : titleStr,
91106 'prop' : 'imageinfo|revisions|categories',
92 - 'iiprop' : 'url|mime|size',
 107+ 'iiprop' : 'url|mime|size|metadata',
93108 'iiurlwidth': parseInt( _this.rsd.thumb_width ),
94109 'rvprop':'content'
95110 };
@@ -205,10 +220,16 @@
206221 'desc' : page.revisions[0]['*'],
207222 // add pointer to parent search obj:
208223 'pSobj' :_this,
 224+
209225 'meta': {
210226 'categories':page.categories
211227 }
212 - };
 228+ };
 229+ for( var i in page.imageinfo[0].metadata ){
 230+ if( page.imageinfo[0].metadata[i].name == 'length' ){
 231+ resource.duration = page.imageinfo[0].metadata[i].value;
 232+ }
 233+ }
213234
214235 /*
215236 //to use once we get the wiki-text parser in shape
@@ -251,8 +272,10 @@
252273 this.resultsObj[page_id] = resource;
253274
254275 // If returnFirst flag:
255 - if ( returnFirst )
 276+ // xxx this is kind of hacky .. we should have abstract getter / adder to result list
 277+ if ( returnFirst ){
256278 return this.resultsObj[page_id];
 279+ }
257280
258281
259282 this.num_results++;
Index: branches/MwEmbedStandAlone/modules/AddMedia/searchLibs/baseRemoteSearch.js
@@ -67,6 +67,10 @@
6868 return this;
6969 },
7070
 71+ getResourceFromUrl: function( url, callback ){
 72+ mw.log("Error getResourceFromUrl must be implemented by remoteSearch provider");
 73+ },
 74+
7175 /**
7276 * Base search results
7377 * Does some common initialisation for search results
Index: branches/MwEmbedStandAlone/modules/AddMedia/searchLibs/flickrSearch.js
@@ -15,8 +15,7 @@
1616 var flickrSearch = function ( options ) {
1717 this.init( options );
1818 }
19 -flickrSearch.prototype = {
20 - detailsUrl : 'http://www.flickr.com/photos/',
 19+flickrSearch.prototype = {
2120 // @@todo probably would be good to read the api-key from configuration
2221 apikey : '2867787a545cc66c0bce6f2e57aca1d1',
2322 // What license we are interested in
Index: branches/MwEmbedStandAlone/modules/AddMedia/mw.UploadForm.js
@@ -401,7 +401,7 @@
402402 remoteSearchDriver.addResourceEditLoader();
403403
404404 //Add the uploaded result
405 - searchProvider.sObj.addByTitle( wTitle, function( resource ) {
 405+ searchProvider.sObj.getByTitle( wTitle, function( resource ) {
406406 // Update the recent uploads ( background task )
407407 remoteSearchDriver.showUserRecentUploads( uploadTargetId );
408408 // Pull up resource editor:
Index: branches/MwEmbedStandAlone/modules/AddMedia/mw.RemoteSearchDriver.js
@@ -297,7 +297,8 @@
298298 'homepage': 'http://kaltura.com',
299299 'apiUrl': 'http://kaldev.kaltura.com/michael/aggregator.php',
300300
301 - 'detailsUrl' : wgServer + wgArticlePath,
 301+ 'detailsUrl' : 'http://videos.kaltura.com/$1',
 302+
302303 'lib': 'kaltura',
303304 'resource_prefix' : '',
304305 'tab_image':false
@@ -310,6 +311,8 @@
311312 'enabled': 1,
312313 'homepage': 'http://commons.wikimedia.org/wiki/Main_Page',
313314 'apiUrl': 'http://commons.wikimedia.org/w/api.php',
 315+ 'detailsUrl' : 'http://commons.wikimedia.org/wiki/$1',
 316+
314317 'lib': 'mediaWiki',
315318 'tab_img': true,
316319
@@ -335,6 +338,8 @@
336339 'homepage': 'http://www.archive.org/about/about.php',
337340
338341 'apiUrl': 'http://www.archive.org/advancedsearch.php',
 342+ 'detailsUrl' : 'http://www.archive.org/details/$1',
 343+
339344 'lib': 'archiveOrg',
340345 'local': false,
341346 'resource_prefix': 'AO_',
@@ -346,9 +351,10 @@
347352 */
348353 'flickr': {
349354 'enabled': 1,
350 - 'homepage': 'http://www.flickr.com/about/',
351 -
 355+ 'homepage': 'http://www.flickr.com/about/',
352356 'apiUrl': 'http://www.flickr.com/services/rest/',
 357+ 'detailsUrl' : 'http://www.flickr.com/photos/',
 358+
353359 'lib': 'flickr',
354360 'local': false,
355361 // Just prefix with Flickr_ for now.
@@ -363,6 +369,8 @@
364370 'enabled': 1,
365371 'homepage': 'http://metavid.org/wiki/Metavid_Overview',
366372 'apiUrl': 'http://metavid.org/w/index.php?title=Special:MvExportSearch',
 373+ 'detailsUrl' : 'http://metavid.org/wiki/Stream:$1',
 374+
367375 'lib': 'metavid',
368376 'local': false,
369377
@@ -1631,7 +1639,21 @@
16321640 callback( provider );
16331641 } );
16341642 },
 1643+ /**
 1644+ * get a resource from a url loads the provider if not already initialized
 1645+ */
 1646+ getResourceFromUrl: function ( provider, url, callback){
 1647+ if (!provider.sObj) {
 1648+ this.loadSearchLib( provider, function( provider ){
 1649+ provider.sObj.getResourceFromUrl( url, callback);
 1650+ });
 1651+ }
 1652+ else {
 1653+ provider.sObj.getResourceFromUrl( url, callback);
 1654+ }
 1655+ },
16351656
 1657+
16361658 /**
16371659 * Get a resource object from a resource id
16381660 *
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.Sequencer.js
@@ -124,12 +124,16 @@
125125 mw.log( "Sequencer::updateSmilXML" );
126126 var _this = this;
127127 // Update the embedPlayer smil:
128 - this.getSmil().updateFromString( smilXML );
 128+ this.getSmil().updateFromString( smilXML );
 129+
129130 // Get a duration ( forceRefresh to clear the cache )
130131 this.getEmbedPlayer().getDuration( true );
131132
132133 // Redraw the timeline
133 - this.getTimeline().drawTimeline();
 134+ this.getTimeline().drawTimeline();
 135+
 136+ // if a tool is displayed update the tool:
 137+ this.getTools().updateToolDisplay();
134138 },
135139
136140 /**
Index: branches/MwEmbedStandAlone/modules/Sequencer/css/mw.style.Sequencer.css
@@ -93,3 +93,12 @@
9494 padding-left: 5px;
9595 padding-right: 5px;
9696 }
 97+
 98+/* Vertical Tabs
 99+----------------------------------*/
 100+.ui-tabs-vertical { width: 55em; }
 101+.ui-tabs-vertical .ui-tabs-nav { padding: .2em .1em .2em .2em; float: left; width: 12em; }
 102+.ui-tabs-vertical .ui-tabs-nav li { clear: left; width: 100%; border-bottom-width: 1px !important; border-right-width: 0 !important; margin: 0 -1px .2em 0; }
 103+.ui-tabs-vertical .ui-tabs-nav li a { display:block; }
 104+.ui-tabs-vertical .ui-tabs-nav li.ui-tabs-selected { padding-bottom: 0; padding-right: .1em; border-right-width: 1px; border-right-width: 1px; }
 105+.ui-tabs-vertical .ui-tabs-panel { padding: 1em; float: right; width: 40em;}
Index: branches/MwEmbedStandAlone/modules/Sequencer/Sequencer.i18n.php
@@ -27,8 +27,12 @@
2828 'mwe-sequencer-audio-track' => 'Audio track',
2929 'mwe-sequencer-sequencer_credit_line' => 'Developed by [$1 Kaltura, Inc] in partnership with the [$1 Wikimedia Foundation]',
3030 'mwe-sequencer-no-sequence-create' => 'Sequence does not exists, You can [$1 start a sequence]',
31 - 'mwe-sequencer-cliptool-trim' => 'Trim clip',
32 - 'mwe-sequencer-cliptool-duration' => 'Set duration',
 31+
 32+ 'mwe-sequencer-tools-trim' => 'Trim',
 33+ 'mwe-sequencer-tools-trim-desc' => 'Set clip in and out points',
 34+ 'mwe-sequencer-tools-duration' => 'Duration',
 35+ 'mwe-sequencer-tools-duration-desc' => 'Set clip duration',
 36+
3337 'mwe-sequencer-preview' => 'Preview',
3438 'mwe-sequencer-apply-changes' => 'Apply changes',
3539 'mwe-sequencer-start-time' => 'Start time',
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddMedia.js
@@ -122,29 +122,13 @@
123123 // Check if input value can be handled by url
124124 var inputValue = _this.sequencer.getMenuTarget().find('input.searchMedia').val();
125125 if( _this.sequencer.getAddByUrl().isUrl( inputValue) ){
126 - _this.sequencer.addByUrlDialog().addByUrl( remoteSearchDriver, inputValue );
 126+ _this.sequencer.getAddByUrl().addByUrlDialog( remoteSearchDriver, inputValue );
127127 } else {
128128 // Else just use the remoteSearchDriver search interface
129129 remoteSearchDriver.createUI();
130130 }
131131 });
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 - },
 132+ },
149133
150134 /**
151135 * Get the resource object from a provided asset
@@ -204,7 +188,10 @@
205189 if( resource.mime.indexOf( 'image/' ) != -1 ){
206190 tagType = 'img';
207191 }
208 - if( resource.mime.indexOf( 'video/') != -1 ){
 192+ if( resource.mime.indexOf( 'video/') != -1
 193+ ||
 194+ resource.mime.indexOf( 'application/ogg' ) != -1 )
 195+ {
209196 tagType = 'video';
210197 }
211198 if( resource.mime.indexOf( 'audio/') != -1 ){
@@ -212,11 +199,19 @@
213200 }
214201 var $smilRef = $j( '<' + tagType + ' />')
215202
216 - // Set the default duration
 203+ // Set the default duration for images
217204 if( tagType == 'img' ){
218205 $smilRef.attr( 'dur', mw.getConfig( 'Sequencer.AddMediaImageDuration' ) );
219206 }
220207
 208+ // Set the default duration to the media duration:
 209+ if( resource.duration ){
 210+ // Set the media full duration
 211+ $smilRef.attr( 'durationHint', resource.duration );
 212+ // By default the imported resource is its entire duration
 213+ $smilRef.attr( 'dur', resource.duration );
 214+ }
 215+
221216 // Set all available params
222217 var resourceAttributeMap = {
223218 'type' : 'mime',
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTools.js
@@ -14,27 +14,37 @@
1515 init: function( sequencer ){
1616 this.sequencer = sequencer;
1717 },
 18+ // The current selected tool
 19+ currentToolId: null,
 20+
 21+ // JSON tools config
1822 tools:{
1923 'trim':{
20 - 'title': gM('mwe-sequencer-cliptool-trim'),
2124 'editWidgets' : [ 'trimTimeline' ],
2225 'editableAttributes' : ['clipBegin','dur' ],
23 - 'editActions' : ['preview', 'cancel']
 26+ 'contentTypes': ['video', 'audio']
2427 },
25 - 'duration':{
26 - 'title': gM('mwe-sequencer-cliptool-duration'),
 28+ 'duration':{
2729 'editableAttributes' : [ 'dur' ],
28 - 'editActions' : ['preview', 'cancel']
 30+ 'contentTypes': ['image']
 31+ },
 32+ 'panzoom' : {
 33+ 'editableAttributes' : [ 'panZoom' ],
 34+ 'contentTypes': ['video', 'image']
2935 }
3036 },
3137 editableAttributes:{
3238 'clipBegin':{
3339 'type': 'time',
34 - 'title' : gM('mwe-sequencer-start-time' ),
 40+ 'title' : gM('mwe-sequencer-start-time' )
3541 },
3642 'dur' :{
3743 'type': 'time',
38 - 'title' : gM('mwe-sequencer-clip-duration' ),
 44+ 'title' : gM('mwe-sequencer-clip-duration' )
 45+ },
 46+ 'panZoom' :{
 47+ 'type' : 'panzoom',
 48+ 'title' : gM('mwe-sequencer-clip-layout' )
3949 }
4050 },
4151 editableTypes: {
@@ -65,7 +75,7 @@
6676 'preview' : {
6777 'icon' : 'play',
6878 'title' : gM('mwe-sequencer-preview'),
69 - 'action': function( _this, smilClip, toolId ){
 79+ 'action': function( _this, smilClip ){
7080 _this.sequencer.getPlayer().previewClip( smilClip );
7181 // xxx todo update preview button to "pause" / "play"
7282 }
@@ -73,15 +83,22 @@
7484 'cancel':{
7585 'icon': 'close',
7686 'title' : gM('mwe-cancel'),
77 - 'action' : function( _this, smilClip, toolId ){
78 - var tool = _this.tools[toolId];
79 - for( var i=0; i < tool.editableAttributes.length ; i++ ){
80 - var attributeName = tool.editableAttributes[i];
81 - var $editToolInput = $j('#' + _this.getEditToolId( toolId, attributeName ) );
82 - // Restore all original attribute values
83 - smilClip.attr( attributeName, $editToolInput.data('initialValue') );
84 - }
85 -
 87+ 'action' : function( _this, smilClip ){
 88+ $j.each(
 89+ _this.getToolSet(
 90+ _this.sequencer.getSmil().getRefType( smilClip )
 91+ ),
 92+ function( inx, toolId ){
 93+ var tool = _this.tools[toolId];
 94+ for( var i=0; i < tool.editableAttributes.length ; i++ ){
 95+ var attributeName = tool.editableAttributes[i];
 96+ var $editToolInput = $j('#' + _this.getEditToolInputId( toolId, attributeName ) );
 97+ // Restore all original attribute values
 98+ smilClip.attr( attributeName, $editToolInput.data('initialValue') );
 99+ }
 100+ }
 101+ );
 102+
86103 // Update the clip duration :
87104 _this.sequencer.getEmbedPlayer().getDuration( true );
88105
@@ -91,17 +108,30 @@
92109 );
93110
94111 // Close / empty the toolWindow
95 - _this.sequencer.getEditToolTarget().html(
96 - _this.getDefaultText()
97 - )
 112+ _this.setDefaultText();
98113 }
99114 }
100115 },
101116 editWidgets: {
102117 'trimTimeline':{
103 - 'update': function( _this, target, smilClip ){
 118+ 'onChange': function( _this, target, smilClip ){
104119 var smil = _this.sequencer.getSmil();
105120 // Update the preview thumbs
 121+
 122+ // (local function so it can be updated after the start time is done with its draw )
 123+ var updateDurationThumb = function(){
 124+ // Check the duration:
 125+ var clipDur = $j('#editTool_trim_dur').val();
 126+ if( clipDur ){
 127+ // Render a thumbnail for the updated duration
 128+ smil.getLayout().drawElementThumb(
 129+ $j( target ).find('.trimEndThumb'),
 130+ smilClip,
 131+ clipDur
 132+ );
 133+ }
 134+ }
 135+
106136 var clipBeginTime = $j('#editTool_trim_clipBegin').val();
107137 if( !clipBeginTime ){
108138 $j(target).find('.trimStartThumb').hide();
@@ -111,22 +141,10 @@
112142 smil.getLayout().drawElementThumb(
113143 $j( target ).find('.trimStartThumb'),
114144 smilClip,
115 - 0
 145+ 0,
 146+ updateDurationThumb()
116147 )
117148 }
118 - // Check the duration:
119 - var clipDur = $j('#editTool_trim_dur').val();
120 - if( clipDur ){
121 - mw.log("Should update trimStartThumb::" + $j(smilClip).attr('clipBegin') );
122 - // Render a thumbnail for the updated duration
123 - smil.getLayout().drawElementThumb(
124 - $j( target ).find('.trimEndThumb'),
125 - smilClip,
126 - clipDur
127 - );
128 - }
129 -
130 - mw.log( "editWidgets::trimTimeline:update:: " + clipBeginTime + ' dur: ' + clipDur);
131149 },
132150 // Return the trimTimeline edit widget
133151 'draw': function( _this, target, smilClip ){
@@ -144,10 +162,10 @@
145163
146164 // Add a trim binding:
147165 $j('#editTool_trim_clipBegin,#editTool_trim_dur').change(function(){
148 - _this.editWidgets.trimTimeline.update( _this, target, smilClip);
 166+ _this.editWidgets.trimTimeline.onChange( _this, target, smilClip);
149167 })
150168 // Update the thumbnails:
151 - _this.editWidgets.trimTimeline.update( _this, target, smilClip);
 169+ _this.editWidgets.trimTimeline.onChange( _this, target, smilClip);
152170
153171 // Get the clip full duration to build out the timeline selector
154172 smil.getBody().getClipAssetDuration( smilClip, function( fullClipDuration ) {
@@ -162,13 +180,14 @@
163181 var sliderValues = [
164182 startSlider,
165183 startSlider + timeToSlider( smil.parseTime( $j('#editTool_trim_dur').val() ) )
166 - ];
 184+ ];
167185 // Return a trim tool binded to smilClip id update value events.
168186 $j(target).append(
169187 $j('<div />')
170188 .attr( 'id', _this.sequencer.id + '_trimTimeline' )
171189 .css({
172 - 'width': '100%',
 190+ 'left' : '5px',
 191+ 'right' : '15px',
173192 'margin': '5px'
174193 })
175194 .slider({
@@ -186,23 +205,16 @@
187206 },
188207 change: function( event, ui ) {
189208 var attributeValue = 0, sliderIndex = 0;
190 - if( sliderValues[0] != ui.values[0] ){
191 - var attributeChanged = 'clipBegin';
192 - sliderIndex = 0;
193 - attributeValue = sliderToTime( ui.values[ 0 ] )
194 - } else {
195 - var attributeChanged = 'dur';
196 - sliderIndex = 1;
197 - attributeValue = sliderToTime( ui.values[ 1 ]- ui.values[0] )
198 - }
199 - sliderValues[ sliderIndex ] = ui.values[ sliderIndex ];
200209
201 - // update start and end time:
202 - _this.editableTypes['time'].update( _this, smilClip, attributeChanged, attributeValue)
203 -
204 - // update the widget
205 - _this.editWidgets.trimTimeline.update( _this, target, smilClip);
 210+ // Update clipBegin
 211+ _this.editableTypes['time'].update( _this, smilClip, 'clipBegin', sliderToTime( ui.values[ 0 ] ) );
206212
 213+ // Update dur
 214+ _this.editableTypes['time'].update( _this, smilClip, 'dur', sliderToTime( ui.values[ 1 ]- ui.values[0] ) );
 215+
 216+ // update the widget display
 217+ _this.editWidgets.trimTimeline.onChange( _this, target, smilClip);
 218+
207219 // Register the edit state for undo / redo
208220 _this.sequencer.getActionsEdit().registerEdit();
209221
@@ -220,85 +232,152 @@
221233 getDefaultText: function(){
222234 return gM('mwe-sequencer-no_selected_resource');
223235 },
224 - getEditToolId: function( toolId, attributeName){
 236+ setDefaultText: function(){
 237+ this.sequencer.getEditToolTarget().html(
 238+ this.getDefaultText()
 239+ )
 240+ },
 241+ getEditToolInputId: function( toolId, attributeName){
225242 return 'editTool_' + toolId + '_' + attributeName;
226 - },
227 -
228 - drawClipEditTools: function( $target, smilClip){
229 -
 243+ },
 244+ /**
 245+ * update the current displayed tool ( when an undo, redo or history jump changes smil state )
 246+ */
 247+ updateToolDisplay: function(){
 248+ var _this = this;
 249+ // Update all tool input values:: trigger change event if changed
 250+ var smilClip = this.getCurrentSmilClip();
 251+
 252+ $j.each(
 253+ _this.getToolSet(
 254+ _this.sequencer.getSmil().getRefType( smilClip )
 255+ ),
 256+ function( inx, toolId ){
 257+ var tool = _this.tools[toolId];
 258+ for( var i=0; i < tool.editableAttributes.length ; i++ ){
 259+ var attributeName = tool.editableAttributes[i];
 260+ var $editToolInput = $j('#' + _this.getEditToolInputId( toolId, attributeName ) );
 261+ // Sync with smilClip value
 262+ if( smilClip.attr( attributeName ) != $editToolInput.val() ){
 263+ $editToolInput.val( smilClip.attr( attributeName ) );
 264+ // trigger change event:
 265+ $editToolInput.change();
 266+ }
 267+ }
 268+ }
 269+ );
 270+ },
 271+ getToolSet: function( refType ){
 272+ var toolSet = [];
 273+ for( var toolId in this.tools){
 274+ if( this.tools[toolId].contentTypes){
 275+ if( $j.inArray( refType, this.tools[toolId].contentTypes) != -1 ){
 276+ toolSet.push( toolId );
 277+ }
 278+ }
 279+ }
 280+ return toolSet;
 281+ },
 282+ drawClipEditTools: function( smilClip ){
 283+ var _this = this;
230284 var toolId = '';
231 - // get the toolId based on what "ref type" smilClip is:
232 - switch( this.sequencer.getSmil().getRefType( smilClip ) ){
233 - case 'video':
234 - case 'audio':
235 - toolId = 'trim';
236 - break;
237 - default:
238 - toolId = 'duration';
239 - break;
240 - }
 285+ var $target = this.sequencer.getEditToolTarget();
241286
 287+ // Set the current smilClip
 288+ this.currentSmilClip = smilClip;
242289
243 - // Make sure the toolid exists
244 - if( !this.tools[ toolId ] ){
245 - mw.log("Error: tool " + toolId + ' not found');
246 - return ;
247 - }
248 - var tool = this.tools[ toolId ];
249290
250 - // Append the title:
251291 $target.empty().append(
252 - $j('<div />').addClass( 'editToolsContainer' )
253 - ,
254 - $j('<h3 />' ).append(
255 - tool.title
 292+ $j('<div />')
 293+ .addClass( 'editToolsContainer' )
 294+ .append(
 295+ $j('<ul />')
256296 )
257297 );
258 -
259 - // Build out the attribute list:
260 - for( var i=0; i < tool.editableAttributes.length ; i++ ){
261 - attributeName = tool.editableAttributes[i];
262 - $target.append(
263 - this.getEditableAttribute( smilClip, toolId, attributeName )
 298+
 299+ // get the toolId based on what "ref type" smilClip is:
 300+ $j.each( this.getToolSet( this.sequencer.getSmil().getRefType( smilClip ) ), function( inx, toolId ){
 301+
 302+ var tool = _this.tools[ toolId ];
 303+
 304+ // set the currentTool if not already set
 305+ if(!_this.currentToolId){
 306+ _this.currentToolId = toolId;
 307+ }
 308+
 309+ // Append the title to the ul list
 310+ $target.find( 'ul').append(
 311+ $j('<li />').append(
 312+ $j('<a />')
 313+ .attr('href', '#tooltab_' + toolId )
 314+ .text( gM('mwe-sequencer-tools-' + toolId) )
 315+ )
264316 );
265 - }
 317+
 318+ // Append the tooltab container
 319+ $target.append(
 320+ $j('<div />')
 321+ .attr('id', 'tooltab_' + toolId )
 322+ )
 323+ var $toolContainer = $target.find( '#tooltab_' + toolId );
 324+
 325+ // Build out the attribute list for the given tool:
 326+ for( var i=0; i < tool.editableAttributes.length ; i++ ){
 327+ attributeName = tool.editableAttributes[i];
 328+ $toolContainer.append(
 329+ _this.getEditableAttribute( smilClip, toolId, attributeName )
 330+ );
 331+ }
 332+
 333+ // Output a float divider:
 334+ $toolContainer.append( $j('<div />').addClass('ui-helper-clearfix') );
 335+
 336+ // Build out tool widgets
 337+ if( tool.editWidgets ){
 338+ for( var i =0 ; i < tool.editWidgets.length ; i ++ ){
 339+ var editWidgetId = tool.editWidgets[i];
 340+ if( ! _this.editWidgets[editWidgetId] ){
 341+ mw.log("Error: not recogonized widget: " + editWidgetId);
 342+ continue;
 343+ }
 344+ // Append a target for the edit widget:
 345+ $toolContainer.append(
 346+ $j('<div />')
 347+ .attr('id', 'editWidgets_' + editWidgetId)
 348+ );
 349+ // Draw the binded widget:
 350+ _this.editWidgets[editWidgetId].draw(
 351+ _this,
 352+ $j( '#editWidgets_' + editWidgetId ),
 353+ smilClip
 354+ )
 355+ // Output a float divider:
 356+ $toolContainer.append( $j('<div />').addClass( 'ui-helper-clearfix' ) );
 357+ }
 358+ }
 359+ });
266360
267 - // output a float divider:
268 - $target.append( $j('<div />').addClass('ui-helper-clearfix') );
269 -
270 - // Build out widgets
271 - if( tool.editWidgets ){
272 - for( var i =0 ; i < tool.editWidgets.length ; i ++ ){
273 - var editWidgetId = tool.editWidgets[i];
274 - if( ! this.editWidgets[editWidgetId] ){
275 - mw.log("Error: not recogonized widget: " + editWidgetId);
276 - continue;
277 - }
278 - // Append a target for the edit widget:
279 - $target.append(
280 - $j('<div />')
281 - .attr('id', 'editWidgets_' + editWidgetId)
282 - );
283 - // Draw the binded widget:
284 - this.editWidgets[editWidgetId].draw(
285 - this,
286 - $j( '#editWidgets_' + editWidgetId ),
287 - smilClip
288 - )
289 - // Output a float divider:
290 - $target.append( $j('<div />').addClass( 'ui-helper-clearfix' ) );
291 - }
292 - }
293 -
294 - // Build out edit Actions buttons
295 - for( var i=0; i < tool.editActions.length ; i++){
296 - var editActionId = tool.editActions[i];
 361+ // Add tab bindings
 362+ $target.find('.editToolsContainer').tabs({
 363+ select: function(event, ui) {
 364+ debugger;
 365+ }
 366+ })
 367+ // Build out global edit Actions buttons ( per 'current tool' )
 368+ for( var editActionId in this.editActions ){
297369 $target.append(
298 - this.getEditAction( smilClip, toolId, editActionId )
 370+ this.getEditAction( smilClip, editActionId )
299371 )
300372 }
301373 },
302 - getEditAction: function( smilClip, toolId, editActionId ){
 374+ getCurrentSmilClip: function(){
 375+ return this.currentSmilClip;
 376+ },
 377+ getCurrentToolId: function(){
 378+ return this.currentToolId;
 379+ },
 380+
 381+ getEditAction: function( smilClip, editActionId ){
303382 if(! this.editActions[ editActionId ]){
304383 mw.log("Error: getEditAction: " + editActionId + ' not found ');
305384 return ;
@@ -314,7 +393,7 @@
315394 'margin': '5px'
316395 })
317396 .click( function(){
318 - editAction.action( _this, smilClip, toolId );
 397+ editAction.action( _this, smilClip );
319398 })
320399 return $actionButton;
321400 },
@@ -350,7 +429,7 @@
351430
352431 $j('<input />')
353432 .attr( {
354 - 'id' : _this.getEditToolId( toolId, attributeName),
 433+ 'id' : _this.getEditToolInputId( toolId, attributeName),
355434 'size': 6
356435 })
357436 .data('initialValue', initialValue )
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTimeline.js
@@ -81,24 +81,49 @@
8282 return mw.getConfig( 'Sequencer.TimelineTrackHeight' )
8383 }
8484 },
85 - // Get the selected sequence track index ( for now its always zero )
86 - getSelectedTrackIndex: function(){
87 - return 0;
 85+ /*
 86+ * Get the track index by type and then by number
 87+ * @param {string} type Type of track 'audio' or 'video'
 88+ * @param {Number=} trackNumber Optional if not set the first track index of selected type is returned
 89+ */
 90+ getTrackIndexType: function( trackType, trackNumber ){
 91+ if( !trackNumber )
 92+ trackNumber = 0;
 93+ var smilSequenceTracks = this.sequencer.getSmil().getBody().getSeqElements();
 94+ var returnTrackIndex = false;
 95+ for(var trackIndex = 0; trackIndex < smilSequenceTracks.length; trackIndex ++){
 96+ if( $j( smilSequenceTracks[ trackIndex ]).attr('tracktype') == trackType ){
 97+ if( trackNumber == 0 ){
 98+ return trackIndex;
 99+ }
 100+ trackNumber--;
 101+ }
 102+ };
 103+ mw.log("Error: SequencerTimelin:: getTrackIndexType: offset to large ( " +
 104+ trackOffset + ' or no track of type ' + type );
 105+ return false;
88106 },
89107
90108 // Draw the timeline
91 - drawTimeline: function(){
 109+ drawTimeline: function( callback ){
92110 var _this = this;
93111 // xxx TODO support multiple tracks :::
94112 var smilSequenceTracks = this.sequencer.getSmil().getBody().getSeqElements();
95113
 114+ var trackStack =0;
96115 // Draw all the tracks
97116 $j.each(smilSequenceTracks, function( trackIndex, smilSequenceTrack ){
98 - _this.drawSequenceTrack( trackIndex, smilSequenceTrack );
 117+ trackStack++;
 118+ _this.drawSequenceTrack( trackIndex, smilSequenceTrack, function(){
 119+ trackStack--;
 120+ if( trackStack == 0 && callback ){
 121+ callback();
 122+ }
 123+ });
99124 })
100125 },
101126
102 - drawSequenceTrack: function( trackIndex, smilSequenceTrack ){
 127+ drawSequenceTrack: function( trackIndex, smilSequenceTrack, callback){
103128 var _this = this;
104129 // Tracks by default are video tracks
105130 mw.log("SequenceTimeline::drawSequenceTrack: Track inx: " +
@@ -126,16 +151,16 @@
127152 $clipTrackSet = $j( '#' + this.getTrackSetId( trackIndex ));
128153 }
129154 // Draw sequence track clips ( checks for dom updates to smilSequenceTrack )
130 - this.drawTrackClipsInterface( $clipTrackSet, smilSequenceTrack );
 155+ this.drawTrackClips( $clipTrackSet, smilSequenceTrack, callback );
131156 },
132157
133158 /**
134 - * add Track Clips and Interface binding
 159+ * Add Track Clips and Interface binding
135160 */
136 - drawTrackClipsInterface: function( $clipTrackSet, smilSequenceTrack ){
 161+ drawTrackClips: function( $clipTrackSet, smilSequenceTrack, callback ){
137162 var _this = this;
138 - mw.log( 'drawTrackClipsInterface:: existing lenght: ' +
139 - $clipTrackSet.children() + ' id: ' + $clipTrackSet.attr('id') );
 163+ mw.log( 'drawTrackClips:: existing length: ' +
 164+ $clipTrackSet.children().length + ' id: ' + $clipTrackSet.attr('id') );
140165 // Setup a local pointer to the smil engine:
141166 var smil = this.sequencer.getSmil();
142167
@@ -147,12 +172,13 @@
148173 // Get all the refs that are children of the smilSequenceTrack with associated offsets and durations
149174 // for now assume all tracks start at zero time:
150175 var startOffset = 0;
 176+ var thumbRenderStack = 0;
151177 smil.getBody().getRefElementsRecurse( smilSequenceTrack, startOffset, function( $node ){
152 - var reRenderThumbFlag = false;
153 - mw.log("ADD: " + _this.getTimelineClipId( $node ) + ' to ' + $clipTrackSet.attr('id') );
 178+ var reRenderThumbFlag = false;
154179 // Draw the node onto the timeline if the clip is not already there:
155180 var $timelineClip = $clipTrackSet.find( '#' + _this.getTimelineClipId( $node ) )
156 - if( $timelineClip.length == 0 ){
 181+ if( $timelineClip.length == 0 ){
 182+ mw.log(" ADD: " + _this.getTimelineClipId( $node ) + ' to ' + $clipTrackSet.attr('id') );
157183 $timelineClip = _this.getTimelineClip( smilSequenceTrack, $node );
158184 // Set the index order on the clip
159185 $timelineClip.data( 'indexOrder', $clipTrackSet.children().length );
@@ -175,19 +201,24 @@
176202 }
177203 }
178204
179 - // xxx Check if the start time was changed to set reRenderThumbFlag
180 -
181 - if ( reRenderThumbFlag ){
182 - // issue a draw Thumb request ( since we reinserted into the dom )
183 - // Check Buffer for when the first frame of the smilNode can be grabbed:
184 - smil.getBuffer().bufferedSeek( $node, 0, function(){
185 - //mw.log("getTrackClipInterface::bufferedSeek for " + smil.getPageDomId( $node ));
186 - _this.drawClipThumb( $node , 0);
 205+ // xxx Check if the start time was changed to set reRenderThumbFlag
 206+ if ( reRenderThumbFlag ){
 207+ thumbRenderStack++;
 208+ // Issue a relative draw Thumb request for the start time
 209+ smil.getBuffer().bufferedSeekRelativeTime( $node, 0, function(){
 210+ mw.log("getTrackClipInterface::bufferedSeekRelativeTime for " + smil.getPageDomId( $node ));
 211+ _this.drawClipThumb( $node , 0, function(){
 212+ thumbRenderStack--;
 213+ if( thumbRenderStack == 0 ){
 214+ callback();
 215+ }
 216+ });
187217 });
188218 }
189219
190220 // Update the $previusClip
191221 $previusClip = $timelineClip;
 222+
192223 // Update the natural order index
193224 seqOrder ++;
194225 });
@@ -210,14 +241,14 @@
211242 ( this.timelineThumbSize.width + 12 )
212243 );
213244
214 - // Add global TrackClipInterface bindings:
 245+ // Add TrackClipInterface bindings:
215246 var keyBindings = this.sequencer.getKeyBindings();
216247 $j( keyBindings ).bind('escape', function(){
217248 // If a clips are selected deselect
218249 var selectedClips = _this.getTimelineContainer().find( '.selectedClip' )
219250 if( selectedClips.length ){
220251 selectedClips.removeClass( 'selectedClip' );
221 - return;
 252+ return false;
222253 }
223254 // Else trigger an exit request
224255 _this.sequencer.getActionsSequence().exit();
@@ -312,8 +343,7 @@
313344 var smil = this.sequencer.getSmil();
314345 // get the smil element for the edit tool:
315346 var smilClip = smil.$dom.find( '#' + $j( selectedClip ).data('smilId') );
316 - var toolTarget = this.sequencer.getEditToolTarget();
317 - this.sequencer.getTools().drawClipEditTools( toolTarget, smilClip );
 347+ this.sequencer.getTools().drawClipEditTools( smilClip );
318348 },
319349
320350 /**
@@ -366,7 +396,12 @@
367397 var _this = this;
368398 // Handle optional arguments
369399 if( typeof trackIndex == 'undefined' ){
370 - trackIndex = this.getSelectedTrackIndex();
 400+ // default audio to audio track
 401+ if( _this.sequencer.getSmil().getRefType( smilClip ) == 'audio' ){
 402+ trackIndex = this.getTrackIndexType('audio');
 403+ } else {
 404+ trackIndex = this.getTrackIndexType('video');
 405+ }
371406 }
372407 var $clipTrackSet = $j( '#' + this.getTrackSetId( trackIndex ) );
373408 if( $clipTrackSet.length == 0 ){
@@ -389,27 +424,31 @@
390425 )
391426 }
392427
393 - // Update the dom timeline
394 - this.drawTimeline();
 428+ // Update the dom timeline
 429+ _this.drawTimeline(function(){
 430+
 431+ // Invalidate / update embedPlayer duration / clip offsets
 432+ _this.sequencer.getEmbedPlayer().getDuration( true );
 433+
 434+ // Register the insert edit action
 435+ _this.sequencer.getActionsEdit().registerEdit();
 436+
 437+ // Select the current clip
 438+ var $timelineClip = $clipTrackSet.find('#' + this.getTimelineClipId( smilClip ) )
 439+ if( $timelineClip.length == 0 ){
 440+ mw.log("Error: insertSmilClipEdit: could not find clip: " + this.getTimelineClipId( smilClip ) );
 441+ }
 442+ _this.getTimelineContainer().find( '.selectedClip' ).removeClass( 'selectedClip' );
 443+ $timelineClip.addClass( 'selectedClip' );
 444+
 445+ // Seek to the added clip
 446+ // xxx should have a callback for drawTimeline
 447+ _this.seekToStartOfClip( $timelineClip );
 448+
 449+ // Display the edit interface
 450+ _this.editClip( $timelineClip );
 451+ });
395452
396 - // Invalidate / update embedPlayer duration / clip offsets
397 - this.sequencer.getEmbedPlayer().getDuration( true );
398 -
399 - // Register the insert edit action
400 - _this.sequencer.getActionsEdit().registerEdit();
401 -
402 - // Select the current clip
403 - var $timelineClip = $clipTrackSet.find('#' + this.getTimelineClipId( smilClip ) )
404 - if( $timelineClip.length == 0 ){
405 - mw.log("Error: insertSmilClipEdit: could not find clip: " + this.getTimelineClipId( smilClip ) );
406 - }
407 - this.getTimelineContainer().find( '.selectedClip' ).removeClass( 'selectedClip' );
408 - $timelineClip.addClass( 'selectedClip' );
409 - // Seek to the added clip
410 - this.seekToStartOfClip( $timelineClip );
411 -
412 - // Display the edit interface with 'special' cancel button
413 - this.editClip( $timelineClip );
414453 },
415454
416455 handleReorder: function ( movedClip ){
@@ -568,7 +607,7 @@
569608 },
570609
571610 // Draw a clip thumb into the timeline clip target
572 - drawClipThumb: function ( $node , relativeTime ){
 611+ drawClipThumb: function ( $node , relativeTime, callback ){
573612 var _this = this;
574613 var smil = this.sequencer.getSmil();
575614
@@ -655,23 +694,24 @@
656695 })
657696 .attr( 'src', smil.getAssetUrl( $node.attr('poster') ) )
658697 .load( function(){
659 - if( $thumbTarget.children().length == 0 ){
 698+ if( $thumbTarget.children().length == 0 ){
660699 $thumbTarget.html( img );
661700 }
662701 });
663702
664703 // Sometimes the load event does not fire. Force the fallback image after 5 seconds
665 - setTimeout( function(){
 704+ setTimeout( function(){
666705 if( $thumbTarget.children().length == 0 ){
667 - $thumbTarget.html( img );
 706+ mw.log( "SequencerTimeline::drawClipThumb: force image fallabck:: " + img.src);
 707+ $thumbTarget.html( img );
668708 }
669709 }, 5000);
670710 }
671711
672712 // Buffer the asset then render it into the layout target:
673 - smil.getBuffer().bufferedSeek( $node, relativeTime, function(){
674 - // Add the seek, add to canvas and draw thumb request
675 - smil.getLayout().drawElementThumb( $thumbTarget, $node, relativeTime );
 713+ smil.getBuffer().bufferedSeekRelativeTime( $node, relativeTime, function(){
 714+ // Add the seek, Add to canvas and draw thumb request
 715+ smil.getLayout().drawElementThumb( $thumbTarget, $node, relativeTime, callback );
676716
677717 })
678718 },
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerAddByUrl.js
@@ -17,7 +17,7 @@
1818 * Does a basic parseUri check to see if a string is likely a url:
1919 */
2020 isUrl: function( inputString ){
21 - return ( mw.parseUri( inputString ).authority != mw.parseUri( inputString ).host ) ;
 21+ return ( mw.parseUri( inputString ).protocol ) ;
2222 },
2323
2424 /**
@@ -27,12 +27,65 @@
2828 * Uses remoteSearchDriver to help in retrieving entry info
2929 * @param {Object} remoteSearchDriver The remote search driver
3030 */
31 - addByUrlDialog: function( remoteSearchDriver, url ){
 31+ addByUrlDialog: function( remoteSearchDriver, url ){
 32+ var _this = this;
 33+ var $dialog = mw.addLoaderDialog( gM( 'mwe-sequencer-loading-asset' ) );
 34+
 35+ // Close / empty the toolWindow
 36+ _this.sequencer.getTools().setDefaultText();
 37+
 38+ var foundImportUrl = false;
3239 // See if the asset matches the detailsUrl key type of any enabled content provider:
3340 $j.each( remoteSearchDriver.getEnabledProviders(), function(providerName, provider){
34 -
 41+ if( mw.parseUri( provider.detailsUrl ).host == mw.parseUri( url).host ){
 42+ foundImportUrl = true ;
 43+
 44+ mw.log("addByUrlDialog: matching host getResourceFromUrl::"
 45+ + mw.parseUri( provider.detailsUrl ).host
 46+ + ' == ' + mw.parseUri( url).host );
 47+
 48+ // Do special check for mediawiki templates and pages as 'special' smil types
 49+ if( provider.lib == 'mediaWiki' ){
 50+ // xxx we should do a query to the api to determine namespace instead of hard coded checks
 51+ remoteSearchDriver.loadSearchLib( provider, function( provider ){
 52+ var titleKey = provider.sObj.getTitleKeyFromMwUrl( url );
 53+ if( !titleKey ){
 54+ // continue for loop ( if we can't get a title from the mediaWiki url )
 55+ return true;
 56+ }
 57+ // Check the title type
 58+ // xxx should use wgFormattedNamespacess
 59+ if( titleKey.indexOf('File:') == 0 ){
 60+ // Asset is a file import resource as a file:
 61+ remoteSearchDriver.getResourceFromUrl( provider, url, function( resource ){
 62+ if( ! resource ){
 63+ $dialog.html( 'Error loading asset');
 64+ return ;
 65+ }
 66+ // Get convert resource to smilClip and insert into the timeline
 67+ _this
 68+ .sequencer
 69+ .getAddMedia()
 70+ .getSmilClipFromResource( resource, function( smilClip ) {
 71+ _this.sequencer.getTimeline().insertSmilClipEdit( smilClip );
 72+ mw.closeLoaderDialog();
 73+ });
 74+ });
 75+ } else {
 76+ // xxx special Template resource import goes here
 77+ }
 78+
 79+ });
 80+ } else {
 81+ mw.log(" only MediaWiki URLs supported as resources right now");
 82+ }
 83+ }
3584 });
3685
 86+ if( ! foundImportUrl ){
 87+ mw.closeLoaderDialog();
 88+ }
 89+ // xxx support direct asset include
3790 if( mw.getConfig( 'Sequencer.AddAssetByUrl' )){
3891 // try directly adding the asset
3992 }
Index: branches/MwEmbedStandAlone/modules/Sequencer/remotes/mw.MediaWikiRemoteSequencer.js
@@ -177,7 +177,7 @@
178178 gM('mwe-sequencer-not-published',
179179 $j('<a />').click( function(){
180180 _this.showEditor();
181 - })
 181+ }).css('cursor', 'pointer')
182182 )
183183 )
184184 .addClass( 'ui-state-highlight' )
@@ -197,7 +197,7 @@
198198 gM('mwe-sequencer-published-out-of-date',
199199 $j('<a />').click( function(){
200200 _this.showEditor();
201 - })
 201+ }).css('cursor', 'pointer')
202202 )
203203 ).addClass( 'ui-state-highlight' )
204204 )

Status & tagging log