r71932 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71931‎ | r71932 | r71933 >
Date:09:33, 30 August 2010
Author:dale
Status:deferred
Tags:
Comment:
improved panZoom edit support
stubs for transitions
Modified paths:
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mvpcf/mw.style.PlayerSkinMvpcf.css (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/Sequencer.i18n.php (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/actions/mw.SequencerActionsSequence.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTools.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilAnimate.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilLayout.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilLayout.js
@@ -5,21 +5,21 @@
66 }
77
88 mw.SmilLayout.prototype = {
9 - // Stores the number of assets we are currently loading
 9+ // Stores the number of assets we are currently loading
1010 mediaLoadingCount : 0,
1111
1212 // Stores the callback function for once assets are loaded
1313 mediaLoadedCallback : null,
1414
15 - //Stores the current top z-index for "putting things on top"
 15+ // Stores the current top z-index for "putting things on top"
1616 topZindex: 1,
1717
18 - // Constructor:
 18+ // Constructor:
1919 init: function( smilObject ){
2020 // Setup a pointer to parent smil Object
2121 this.smil = smilObject;
2222
23 - // Set the smil layout dom:
 23+ // Set the smil layout dom:
2424 this.$dom = this.smil.getDom().find( 'layout' );
2525
2626 // Reset the htmlDOM cache
@@ -36,13 +36,13 @@
3737 },
3838
3939 /*
40 - * Get layout
41 - */
 40+ * Get layout
 41+ */
4242 getRootLayout: function(){
4343 var _this = this;
4444 mw.log( "SmilLayout::getRootLayout:" );
4545 if( !this.$rootLayout ){
46 - // Setup target Size:
 46+ // Setup target Size:
4747 this.targetWidth = this.smil.embedPlayer.getWidth();
4848 this.targetHeight = this.smil.embedPlayer.getHeight();
4949
@@ -56,7 +56,7 @@
5757 'overflow': 'hidden'
5858 });
5959
60 - // Update the root layout css
 60+ // Update the root layout css
6161 this.$rootLayout.css( _this.getRootLayoutCss() );
6262
6363 // Update the root layout html
@@ -66,18 +66,19 @@
6767 },
6868
6969 /**
70 - * Get and increment the top z-index counter:
 70+ * Get and increment the top z-index counter:
7171 */
7272 getTopZIndex: function(){
7373 return this.topZindex++;
7474 },
7575
7676 /**
77 - * Draw a smilElement to the layout.
78 - *
79 - * If the element does not exist in the html dom add it.
80 - * @parma {Element} smilElement to be drawn.
81 - */
 77+ * Draw a smilElement to the layout.
 78+ *
 79+ * If the element does not exist in the html dom add it.
 80+ *
 81+ * @parma {Element} smilElement to be drawn.
 82+ */
8283 drawElement: function( smilElement ) {
8384 var _this = this;
8485 // Check for quick "show" path:
@@ -87,9 +88,10 @@
8889 return ;
8990 }
9091
91 - // Else draw the node into the regionTarget
 92+ // Else draw the node into the regionTarget
9293
93 - //mw.log( "SmilLayout::drawElement: " + nodeName + '.' + $j( smilElement ).attr('id' ) + ' into ' + regionId );
 94+ // mw.log( "SmilLayout::drawElement: " + nodeName + '.' + $j(
 95+ // smilElement ).attr('id' ) + ' into ' + regionId );
9496 var $regionTarget = this.getRegionTarget( smilElement );
9597
9698 // Make sure we have a $regionTarget
@@ -106,14 +108,16 @@
107109 _this.getSmilElementHtml( smilElement )
108110 )
109111 } else {
110 - // Make sure the element is visible ( may be faster to just call show directly)
 112+ // Make sure the element is visible ( may be faster to just call
 113+ // show directly)
111114 if( $targetElement.is(':hidden') ) {
112115 $targetElement.show();
113116 }
114117 }
115118 },
116119
117 - drawElementThumb: function( $target, $node, relativeTime, callback){
 120+ drawElementThumb: function( $target, $node, relativeTime, callback){
 121+ var _this = this;
118122 mw.log('SmilLayout::drawElementThumb: ' + $node.attr('id') + ' relative time:' + relativeTime );
119123 if( $target.length == 0 ){
120124 mw.log("Error drawElementThumb to empty target");
@@ -128,13 +132,25 @@
129133 }
130134 switch ( this.smil.getRefType( $node ) ){
131135 case 'img':
132 - // xxx we could eventually use canvas as well but for now just add it at 100%
 136+ // xxx we should use canvas here but for now just hack it up:
 137+ var $playerImage = this.getSmilImgHtml( $node );
133138 $target.html(
134 - this.getSmilImgHtml( $node, {
135 - 'width' : $target.width(),
136 - 'height' : $target.height()
 139+ $j('<img />')
 140+ .attr({
 141+ 'src' : this.smil.getAssetUrl( $node.attr( 'src' ) )
137142 })
138143 );
 144+ var img = $target.find('img').get(0)
 145+ _this.getNaturalSize( img, function( natrualSize ){
 146+ _this.fitMeetBest(
 147+ img,
 148+ natrualSize,
 149+ {
 150+ 'width' : $target.width(),
 151+ 'height' : $target.height()
 152+ }
 153+ )
 154+ });
139155 break;
140156 case 'cdata_html':
141157 // Scale down the html into the target width
@@ -180,7 +196,7 @@
181197 naturaSize.width = drawElement.videoWidth;
182198
183199 // Draw the thumb via canvas grab
184 - // NOTE canvas scale issue prevents redraw at thumb resolution
 200+ // NOTE canvas scale issue prevents redraw at thumb resolution
185201 // xxx should revisit thumb size issue:
186202 try{
187203 $target.html( $j('<canvas />')
@@ -204,7 +220,8 @@
205221 callback();
206222 }
207223
208 - // check if relativeTime transform matches current absolute time then render directly:
 224+ // check if relativeTime transform matches current absolute time then
 225+ // render directly:
209226 var drawTime = ( relativeTime + this.smil.parseTime( $j( $node ).attr('clipBegin') ) );
210227 if( this.smil.isSameFrameTime( drawElement.currentTime, drawTime ) ) {
211228 mw.log("getVideoCanvasThumb: Draw time:" + drawTime + " matches video time drawFrame:" +drawElement.currentTime );
@@ -216,7 +233,7 @@
217234 var $tmpFrameNode = $node.clone();
218235 $tmpFrameNode.attr('id', $node.attr('id') + '_tmpFrameNode' );
219236 this.smil.getBuffer().bufferedSeekRelativeTime( $tmpFrameNode, relativeTime, function(){
220 - // update the drawElement
 237+ // update the drawElement
221238 drawElement = $j( '#' + _this.smil.getPageDomId( $tmpFrameNode ) ).get(0);
222239 drawFrame( drawElement );
223240 // Remove the temporary node from dom
@@ -226,7 +243,7 @@
227244 },
228245
229246 /**
230 - * Get a region target for a given smilElement
 247+ * Get a region target for a given smilElement
231248 */
232249 getRegionTarget: function( smilElement ){
233250 var regionId = $j( smilElement ).attr( 'region');
@@ -238,15 +255,15 @@
239256 return false;
240257 }
241258 } else {
242 - // No region provided use the rootLayout:
 259+ // No region provided use the rootLayout:
243260 $regionTarget = this.$rootLayout;
244261 }
245262 return $regionTarget;
246263 },
247264
248265 /**
249 - * Hide a smilElement in the layout
250 - */
 266+ * Hide a smilElement in the layout
 267+ */
251268 hideElement: function( smilElement ){
252269 // Check that the element is already in the dom
253270 var $targetElement = this.$rootLayout.find( '#' + this.smil.getPageDomId( smilElement ) );
@@ -258,13 +275,15 @@
259276
260277 /**
261278 * Get the transformed smil element in html format
262 - * @param
 279+ *
 280+ * @param
263281 */
264282 getSmilElementHtml: function( smilElement ) {
265283 var smilType = this.smil.getRefType( smilElement )
266284
267285 switch( smilType ){
268 - // Not part of strict smil, but saves time being able have an "html" display mode
 286+ // Not part of strict smil, but saves time being able have an "html"
 287+ // display mode
269288 case 'cdata_html':
270289 return this.getSmilCDATAHtml( smilElement );
271290 break;
@@ -277,7 +296,8 @@
278297 case 'audio':
279298 return this.getSmilAudioHtml( smilElement );
280299 break;
281 - // Smil Text: http://www.w3.org/TR/SMIL/smil-text.html ( obviously we support a subset )
 300+ // Smil Text: http://www.w3.org/TR/SMIL/smil-text.html ( obviously
 301+ // we support a subset )
282302 case 'smiltext':
283303 return this.getSmilTextHtml( smilElement );
284304 break;
@@ -295,8 +315,8 @@
296316 },
297317
298318 /**
299 - * Return the video
300 - */
 319+ * Return the video
 320+ */
301321 getSmilVideoHtml: function( smilElement ){
302322 return $j('<video />')
303323 .attr( {
@@ -319,11 +339,12 @@
320340 },
321341
322342 /**
323 - * Get Smil CDATA ( passed through jQuery .clean as part of fragment creation )
324 - * XXX Security XXX
325 - * Here we are parsing in SMIL -> HTML should be careful about XSS or script elevation
326 - *
327 - * @@TODO check all sources are "local" only smil and enforce domain on all asset sources
 343+ * Get Smil CDATA ( passed through jQuery .clean as part of fragment
 344+ * creation ) XXX Security XXX Here we are parsing in SMIL -> HTML should be
 345+ * careful about XSS or script elevation
 346+ *
 347+ * @@TODO check all sources are "local" only smil and enforce domain on all
 348+ * asset sources
328349 */
329350 getSmilCDATAHtml: function( smilElement, targetWidth ){
330351 // Default target width if unset:
@@ -337,7 +358,7 @@
338359 var xmlCdata = '';
339360 for ( var i=0; i < el.childNodes.length; i++ ) {
340361 var node = el.childNodes[i];
341 - // Check for text cdata Node type:
 362+ // Check for text cdata Node type:
342363 if( node.nodeType == 4 ) {
343364 xmlCdata += node.nodeValue;
344365 }
@@ -345,16 +366,17 @@
346367
347368 var textCss = this.transformSmilCss( smilElement , targetWidth);
348369
349 - // We pass the xmlCdata via jQuery fragment creation, this runs jquery.clean()
350 - // and filters the result html.
 370+ // We pass the xmlCdata via jQuery fragment creation, this runs
 371+ // jquery.clean()
 372+ // and filters the result html.
351373 var $cdataHtml = $j( '<div />' ).append(
352374 $j( xmlCdata )
353375 )
354376
355 - //See if we need to scale
 377+ // See if we need to scale
356378 var scalePercent = ( targetWidth / this.getVirtualWidth() );
357379
358 - // Links go to a new window and are disable scale down.
 380+ // Links go to a new window and are disable scale down.
359381 $cdataHtml.find('a').each( function(inx, link ){
360382 if( scalePercent < 1 ){
361383 $j(link).attr('href', '#');
@@ -365,19 +387,20 @@
366388
367389 if( scalePercent != 1 ){
368390 $cdataHtml.find('img').each( function(inx, image ){
369 - // make sure each image is loaded before we transform,
370 - // AND via the magic of closures this updates $cdataHtml output in-place
 391+ // make sure each image is loaded before we transform,
 392+ // AND via the magic of closures this updates $cdataHtml output
 393+ // in-place
371394 $j( image ).load(function(){
372 - // if the image has an height or width scale by scalePercent
 395+ // if the image has an height or width scale by scalePercent
373396 if ( $j( image ).width() ){
374397 var imageTargetWidth = scalePercent* $j( image ).width();
375398 var imageTargetHeight = scalePercent* $j( image ).height()
376399 } else if( image.naturalWidth ){
377 - // check natural width?
 400+ // check natural width?
378401 imageTargetWidth = scalePercent * image.naturalWidth;
379402 imageTargetHeight = scalePercent * image.naturalHeight;
380403 }
381 - //scale the image:
 404+ // scale the image:
382405 $j( image ).css({
383406 'width' : imageTargetWidth,
384407 'height' :imageTargetHeight
@@ -386,7 +409,7 @@
387410 })
388411 }
389412
390 - // Return the cdata
 413+ // Return the cdata
391414 return $j('<div />')
392415 .attr( 'id' , this.smil.getPageDomId( smilElement ) )
393416 // Wrap in font-size percentage relative to virtual size
@@ -399,16 +422,17 @@
400423 },
401424
402425 /**
403 - * Get a text element html
 426+ * Get a text element html
404427 */
405428 getSmilTextHtml: function( textElement ) {
406429 var _this = this;
407430
408 - // Empty initial text value
 431+ // Empty initial text value
409432 var textValue = '';
410433
411 - // If the textElement has no child node directly set the text value
412 - // ( if has child nodes, text will be selected by time in SmilAnimate.transformTextForTime )
 434+ // If the textElement has no child node directly set the text value
 435+ // ( if has child nodes, text will be selected by time in
 436+ // SmilAnimate.transformTextForTime )
413437 if( $j( textElement ).children().length == 0 ){
414438 mw.log( 'Direct text value to: ' + textValue);
415439 textValue = $j( textElement ).text();
@@ -416,14 +440,14 @@
417441
418442 var textCss = _this.transformSmilCss( textElement );
419443
420 - // Return the htmlElement
 444+ // Return the htmlElement
421445 return $j('<span />')
422446 .attr( 'id' , this.smil.getPageDomId( textElement ) )
423447 // Wrap in font-size percentage relative to virtual size
424448 .css( 'font-size', ( ( this.targetWidth / this.getVirtualWidth() )*100 ) + '%' )
425449 .html(
426450 $j('<span />')
427 - // Transform smil css into html css:
 451+ // Transform smil css into html css:
428452 .css( textCss )
429453 // Add the text value
430454 .text( textValue )
@@ -431,54 +455,128 @@
432456 },
433457
434458 /**
435 - * Get Image html per given smil element and requested time
436 - * @param {element} imgElement The image tag element to be updated
 459+ * Get Image html per given smil element
 460+ *
 461+ * @param {element}
 462+ * imgElement The image tag element to be updated
437463 */
438 - getSmilImgHtml: function( imgElement , targetSize) {
 464+ getSmilImgHtml: function( smilImg ) {
 465+ var _this = this;
 466+ var $image = $j('<img />')
 467+ .attr( {
 468+ 'id' : this.smil.getPageDomId( smilImg ),
 469+ 'src' : this.smil.getAssetUrl( $j( smilImg ).attr( 'src' ) )
 470+ } );
439471
440 - if( ! targetSize ){
441 - targetSize = {};
442 - targetSize.width = this.targetWidth;
443 - targetSize.height = this.targetHeight;
 472+ _this.getNaturalSize( $image.get(0), function( naturalSize) {
 473+ _this.doAssetLayout( smilImg , naturalSize);
 474+ })
 475+ return $image;
 476+ },
 477+ // xxx should really use a callback instead of failing if the media is not
 478+ // loaded
 479+ getNaturalSize: function( img , callback){
 480+ // note this just works for images atm
 481+ if( !img ){
 482+ callback( false );
444483 }
445 - var adjustImageSize = function( image ){
446 - // xxx Should read smil "imgElement" fill type
447 - var imageCss = {};
 484+ if( img.naturalWidth ){
 485+ callback( {
 486+ 'width' : img.naturalWidth,
 487+ 'height' : img.naturalHeight,
 488+ } )
 489+ } else {
 490+ $j( img ).load(function(){
 491+ callback( {
 492+ 'width' : this.naturalWidth,
 493+ 'height' : this.naturalHeight,
 494+ } )
 495+ });
 496+ }
 497+ },
 498+ /**
 499+ * Layout an asset
 500+ */
 501+ doAssetLayout: function( smilElement, naturalSize ){
 502+
 503+ // We default smil layout to meetBest
 504+ var fitMode = $j( smilElement).attr('fit');
 505+ if( !fitMode ){
 506+ fitMode = 'meetBest'
 507+ }
 508+ if( fitMode == 'meetBest' ){
 509+ var targetSize = {
 510+ 'width' : this.smil.embedPlayer.getWidth(),
 511+ 'height' : this.smil.embedPlayer.getHeight()
 512+ }
 513+ this.fitMeetBest(
 514+ $j( '#' + this.smil.getPageDomId( smilElement ) ).get(0),
 515+ naturalSize,
 516+ targetSize
 517+ );
 518+ } else {
 519+ mw.log("Layout mode: " + fitMode + ' not yet supported');
 520+ }
448521
449 - // Fit the image pre the provided targetWidth closure
450 - if( image.naturalWidth > targetSize.width ){
451 - imageCss.width = targetSize.width;
452 - imageCss.height = imageCss.width *
453 - ( image.naturalHeight / image.naturalWidth )
454 - }
455 -
456 - // fit vertically
457 - if(! imageCss.height || imageCss.height > targetSize.height ){
458 - imageCss.height = targetSize.height;
459 - imageCss.width = imageCss.height *
460 - ( image.naturalWidth / image.naturalHeight )
461 - }
462 - $j( image ).css( imageCss );
 522+ // Check for panZoom attribute
 523+ if( $j( smilElement).attr('panZoom') ){
 524+ _this.panZoomLayout( smilElement );
 525+ }
 526+ },
463527
 528+ // http://www.w3.org/TR/SMIL/smil-layout.html#adef-fit
 529+ // xxx should add the other fitting modes
 530+ fitMeetBest: function( element, natrualSize, targetSize ){
 531+ var _this = this;
 532+
 533+ // xxx Should read smil "imgElement" fill type
 534+ var imageCss = {};
 535+
 536+ // Fit the image per the provided targetWidth closure
 537+ if( natrualSize.width > targetSize.width ){
 538+ imageCss.width = '100%';
 539+ imageCss.height = ( 100 * ( natrualSize.height / natrualSize.width ) ) + '%';
464540 }
465 - mw.log( "Add image:" + this.smil.getAssetUrl( $j( imgElement ).attr( 'src' ) ) );
466 - var $image = $j('<img />')
467 - .attr( {
468 - 'id' : this.smil.getPageDomId( imgElement ),
469 - 'src' : this.smil.getAssetUrl( $j( imgElement ).attr( 'src' ) )
470 - } );
471 - if( $image.get(0).naturalHeight ){
472 - adjustImageSize( $image.get(0) );
473 - }else {
474 - $image.load( function(){
475 - adjustImageSize( this );
476 - });
 541+
 542+ // Fit vertically
 543+ if(! imageCss.height || imageCss.height > targetSize.height ){
 544+ imageCss.height = '100%';
 545+ imageCss.width = ( 100 * ( natrualSize.width / natrualSize.height ) ) + '%';
477546 }
478 - return $image;
 547+ // update the layout of the element
 548+ $j( element ).css( imageCss );
479549 },
480 -
481550 /**
482 - * Parse pan zoom attribute string
 551+ * layout function
 552+ */
 553+ panZoomLayout: function( smilElement ){
 554+ var _this = this;
 555+ var panZoom = this.parsePanZoom( $j( smilElement).attr('panZoom') );
 556+ var img = $j( '#' + this.smil.getPageDomId( smilElement ) ).get(0);
 557+
 558+ _this.getNaturalSize( img, function( natrualSize ){
 559+ // Check if the transfrom is needed:
 560+ if( parseInt( panZoom.left ) == 0
 561+ &&
 562+ parseInt( panZoom.top ) == 0
 563+ &&
 564+ ( parseInt( panZoom.width ) == 100 && panZoom.width.indexOf('%') != -1 )
 565+ &&
 566+ ( parseInt( panZoom.height ) == 100 && panZoom.height.indexOf('%') != -1 )
 567+ ){
 568+ // no transform is needed
 569+ return ;
 570+ }
 571+ // Get percent values
 572+ var percentValues = _this.smil.getAnimate().getPercentFromPanZoomValues( panZoomValues, natrualSize );
 573+
 574+ // Update the layout via the animation engine updateElementLayout method
 575+ _this.smil.getAnimate().updateElementLayout( smilElement, panZoomValues );
 576+ });
 577+ },
 578+ /**
 579+ * Parse pan zoom attribute string
 580+ *
483581 * @param panZoomString
484582 */
485583 parsePanZoom: function( panZoomString ){
@@ -496,8 +594,8 @@
497595 },
498596
499597 /**
500 - * Add all the regions to the root layout
501 - */
 598+ * Add all the regions to the root layout
 599+ */
502600 getRootLayoutHtml: function(){
503601 var _this = this;
504602 var $layoutContainer = $j( '<div />' );
@@ -522,8 +620,8 @@
523621 },
524622
525623 /**
526 - * Get the root layout object with updated html properties
527 - */
 624+ * Get the root layout object with updated html properties
 625+ */
528626 getRootLayoutCss: function( ){
529627
530628 if( this.$dom.find( 'root-layout').length ) {
@@ -547,10 +645,10 @@
548646 this.virtualHeight = this.smil.getEmbedPlayer().getHeight();
549647 }
550648
551 - // Merge in transform size to target
 649+ // Merge in transform size to target
552650 $j.extend( rootLayoutCss, this.transformSizeToTarget() );
553651
554 - // Update the layout css
 652+ // Update the layout css
555653 return rootLayoutCss;
556654 }
557655 return {};
@@ -569,35 +667,40 @@
570668 },
571669
572670 /**
573 - * Translate a root layout pixel point into a percent location
574 - * using all percentages instead of pixels lets us scale internal
575 - * layout browser side transforms ( instead of a lot javascript css updates )
576 - *
577 - * @param {object} layout Css layout to be translated from virtualWidth & virtualHeight
578 - */
579 - transformVirtualPixleToPercent: function( layout ){
 671+ * Translate a root layout pixel point into a percent location using all
 672+ * percentages instead of pixels lets us scale internal layout browser side
 673+ * transforms ( instead of a lot javascript css updates )
 674+ *
 675+ * @param {object}
 676+ * layout Css layout to be translated from virtualWidth &
 677+ * virtualHeight
 678+ */
 679+ transformVirtualPixleToPercent: function( layout, virtualLayout ){
580680 var percent = { };
 681+ if( !virtualLayout){
 682+ virtualLayout = { 'width' : this.virtualWidth, 'height' : this.virtualHeight };
 683+ }
581684 if( layout['width'] ) {
582 - percent['width'] = ( layout['width'] / this.virtualWidth )*100 + '%';
 685+ percent['width'] = ( layout['width'] / virtualLayout.width )*100 + '%';
583686 }
584687 if( layout['left'] ){
585 - percent['left'] = ( layout['left'] / this.virtualWidth )*100 + '%';
 688+ percent['left'] = ( layout['left'] / virtualLayout.width )*100 + '%';
586689 }
587690 if( layout['height'] ) {
588 - percent['height'] = ( layout['height'] / this.virtualHeight )*100 + '%';
 691+ percent['height'] = ( layout['height'] / virtualLayout.height )*100 + '%';
589692 }
590693 if( layout['top'] ){
591 - percent['top'] = ( layout['top'] / this.virtualHeight )*100 + '%';
 694+ percent['top'] = ( layout['top'] / virtualLayout.height )*100 + '%';
592695 }
593696 return percent;
594697 },
595698
596699 /**
597 - * Transform virtual height width into target size
598 - */
 700+ * Transform virtual height width into target size
 701+ */
599702 transformSizeToTarget: function(){
600703
601 - // Setup target height width based on max window size
 704+ // Setup target height width based on max window size
602705 var fullWidth = this.targetWidth - 2 ;
603706 var fullHeight = this.targetHeight ;
604707
@@ -605,7 +708,7 @@
606709 var targetWidth = fullWidth;
607710 var targetHeight = targetWidth * ( this.virtualHeight / this.virtualWidth )
608711
609 - // Check if it exceeds the height constraint:
 712+ // Check if it exceeds the height constraint:
610713 if( targetHeight > fullHeight ){
611714 targetHeight = fullHeight;
612715 targetWidth = targetHeight * ( this.virtualWidth / this.virtualHeight );
@@ -614,7 +717,8 @@
615718 var offsetTop = ( targetHeight < fullHeight )? ( fullHeight- targetHeight ) / 2 : 0;
616719 var offsetLeft = ( targetWidth < fullWidth )? ( fullWidth- targetWidth ) / 2 : 0;
617720
618 - //mw.log(" targetWidth: " + targetWidth + ' fullwidth: ' + fullWidth + ' :: ' + ( fullWidth- targetWidth ) / 2 );
 721+ // mw.log(" targetWidth: " + targetWidth + ' fullwidth: ' + fullWidth +
 722+ // ' :: ' + ( fullWidth- targetWidth ) / 2 );
619723 return {
620724 'height': targetHeight,
621725 'width' : targetWidth,
@@ -625,8 +729,8 @@
626730 },
627731
628732 /**
629 - * Transform smil attributes into html attributes
630 - */
 733+ * Transform smil attributes into html attributes
 734+ */
631735 transformSmilAttributes: function ( smilElement ){
632736 $smilElement = $j( smilElement );
633737 var smilAttributes = {
@@ -640,20 +744,22 @@
641745 attributes[ smilAttributes[ attr ] ] = $smilElement.attr( attr );
642746 }
643747 }
644 - // XXX TODO Locally scope all ids into embedPlayer.id + _id
 748+ // XXX TODO Locally scope all ids into embedPlayer.id + _id
645749
646 - // Translate rootLayout properties into div
 750+ // Translate rootLayout properties into div
647751 return attributes;
648752 },
649753
650754 /**
651 - * Transform smil attributes into css attributes
652 - * @param {object} $smilElement The smil element to be transformed
653 - */
 755+ * Transform smil attributes into css attributes
 756+ *
 757+ * @param {object}
 758+ * $smilElement The smil element to be transformed
 759+ */
654760 transformSmilCss: function( smilElement, targetWidth ){
655761 $smilElement = $j( smilElement );
656762
657 - //Set target with to master targetWidth if unset.
 763+ // Set target with to master targetWidth if unset.
658764 if( ! targetWidth ){
659765 targetWidth = this.targetWidth
660766 }
@@ -682,7 +788,8 @@
683789 }
684790
685791 // Make the font size fixed so it can be scaled
686 - // based on: http://style.cleverchimp.com/font_size_intervals/altintervals.html
 792+ // based on:
 793+ // http://style.cleverchimp.com/font_size_intervals/altintervals.html
687794 var sizeMap = {
688795 'xx-small' : '.57em',
689796 'x-small' : '.69em',
@@ -696,7 +803,7 @@
697804 cssAttributes['font-size'] = sizeMap[ cssAttributes['font-size'] ];
698805 }
699806
700 - // If the font size is pixel based parent span will have no effect,
 807+ // If the font size is pixel based parent span will have no effect,
701808 // directly resize the pixels
702809 if( cssAttributes['font-size'] && cssAttributes['font-size'].indexOf('px') != -1 ){
703810 cssAttributes['font-size'] = ( parseFloat( cssAttributes['font-size'] )
@@ -704,7 +811,7 @@
705812 }
706813
707814
708 - // Translate rootLayout properties into div
 815+ // Translate rootLayout properties into div
709816 return cssAttributes;
710817 }
711818 }
\ No newline at end of file
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilAnimate.js
@@ -317,7 +317,7 @@
318318 //mw.log( "transformImageForTime:: animateTime:" + animateTime );
319319
320320 if( $j( smilImgElement ).children().length == 0 ){
321 - // No image transform children
 321+ // No animation transform children
322322 return ;
323323 }
324324
@@ -336,15 +336,10 @@
337337 // No animate elements in range, make sure we transform to previous or to initial state if time is zero
338338 if( !animateInRange ) {
339339 if( animateTime == 0 ) {
340 - // just a hack for now ( should read from previous animation or from source attribute
341 - // this.updateElementLayout( smilImgElement, { 'top':1,'left':1,'width':1, 'height':1 } );
342 - var $target = $j( '#' + this.smil.getPageDomId( smilImgElement ));
343 - $target.css( {
344 - 'top' : '0px',
345 - 'left' :'0px',
346 - 'width' : '100%',
347 - 'height' : '100%'
348 - } );
 340+ // Check if we have native resolution information
 341+ // xxx here would be a good place to check the "fit" criteria
 342+ // http://www.w3.org/TR/SMIL3/smil-layout.html#adef-fit
 343+ // for now we assume fit "attribute" value is "meet"
349344 }
350345 // xxx should check for transform to previous
351346 }
@@ -402,30 +397,35 @@
403398 // Let Top Width Height
404399 // translate values into % values
405400 // NOTE this is dependent on the media being "loaded" and having natural width and height
 401+
 402+ var percentValues = this.getPercentFromPanZoomValues( targetValue,
 403+ this.smil.getLayout().getNaturalSize( smilImgElement )
 404+ );
 405+
 406+ // Now we have "hard" layout info try and render it.
 407+ this.updateElementLayout( smilImgElement, percentValues );
 408+ },
 409+ // transforms pan zoom target value into layout percentages
 410+ getPercentFromPanZoomValues: function(targetValue, naturalSize){
406411 var namedValueOrder = ['left', 'top', 'width', 'height' ];
407 - var htmlAsset = $j( '#' + this.smil.getPageDomId( smilImgElement ) ).get(0);
408 -
409412 var percentValues = {};
410413 for( var i =0 ;i < targetValue.length ; i++ ){
411414 if( targetValue[i].indexOf('%') == -1 ) {
412415 switch( namedValueOrder[i] ){
413416 case 'left':
414417 case 'width':
415 - percentValues[ namedValueOrder[i] ] = parseFloat( targetValue[i] ) / htmlAsset.naturalWidth;
 418+ percentValues[ namedValueOrder[i] ] = parseFloat( targetValue[i] ) / naturalSize.width;
416419 break;
417420 case 'height':
418421 case 'top':
419 - percentValues[ namedValueOrder[i] ] = parseFloat( targetValue[i] ) / htmlAsset.naturalHeight
 422+ percentValues[ namedValueOrder[i] ] = parseFloat( targetValue[i] ) / naturalSize.height
420423 break;
421424 }
422425 } else {
423426 percentValues[ namedValueOrder[i] ] = parseFloat( targetValue[i] ) / 100;
424427 }
425 - }
426 -
427 - // Now we have "hard" layout info try and render it.
428 - this.updateElementLayout( smilImgElement, percentValues );
429 -
 428+ }
 429+ return percentValues;
430430 },
431431
432432 // xxx need to refactor move to "smilLayout"
@@ -445,14 +445,14 @@
446446 var fullHeight = $target.parents('.smilRegion').height() ;
447447 var targetWidth = fullWidth;
448448 var targetHeight = targetWidth * (
449 - ( percentValues['height'] * htmlAsset.naturalHeight )
 449+ ( parseInt( percentValues['height'] ) * htmlAsset.naturalHeight )
450450 /
451 - ( percentValues['width'] * htmlAsset.naturalWidth )
 451+ ( parseInt( percentValues['width'] ) * htmlAsset.naturalWidth )
452452 )
453453 // Check if it exceeds the height constraint:
454454 var sourceScale = ( targetHeight < fullHeight )
455 - ? (1 / percentValues['width'] )
456 - : (1 / percentValues['height'] )
 455+ ? (1 / parseInt( percentValues['width'] ) )
 456+ : (1 / parseInt( percentValues['height'] ) )
457457
458458
459459 // Wrap the target and absolute the image layout ( if not already )
@@ -474,8 +474,8 @@
475475 'position' : 'absolute',
476476 'width' : sourceScale *100 + '%',
477477 'height' : sourceScale *100 + '%',
478 - 'top' : (-1 * percentValues['top'])*100 + '%',
479 - 'left' : (-1 * percentValues['left'])*100 + '%',
 478+ 'top' : (-1 * parseInt( percentValues['top'] ) )*100 + '%',
 479+ 'left' : (-1 * parseInt( percentValues['left'] ) )*100 + '%',
480480 } );
481481 },
482482
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mvpcf/mw.style.PlayerSkinMvpcf.css
@@ -18,7 +18,8 @@
1919 height: 305px;
2020 }
2121 .mv-player .control-bar {
22 - height: 29px;
 22+ height: 29px;
 23+ z-index: 2;
2324 }
2425 .mv-player .controlInnerSmall {
2526 /* width: 430px;*/
Index: branches/MwEmbedStandAlone/modules/Sequencer/Sequencer.i18n.php
@@ -31,12 +31,26 @@
3232 'mwe-sequencer-tools-trim' => 'Trim',
3333 'mwe-sequencer-tools-trim-desc' => 'Set clip in and out points',
3434 'mwe-sequencer-tools-duration' => 'Duration',
 35+ 'mwe-sequencer-clip-duration' => 'Clip duration',
 36+
3537 'mwe-sequencer-tools-duration-desc' => 'Set clip duration',
3638
 39+ 'mwe-sequencer-tools-panzoom' => 'Layout',
 40+ 'mwe-sequencer-clip-panzoom' => 'Panzoom',
 41+ 'mwe-sequencer-tools-panzoom-desc' => 'Set layout position and zoom',
 42+ 'mwe-sequencer-tools-panzoomhelper' => 'Layout helper',
 43+ 'mwe-sequencer-tools-panzoomhelper-desc' => 'Resize and move the <i>layout helper</i> to update layout',
 44+ 'mwe-sequencer-tools-panzoomhelper-resetlayout' => 'Reset layout',
 45+
 46+ 'mwe-sequencer-tools-transitions' => 'Transitions',
 47+ 'mwe-sequencer-tools-transitions-desc' => 'Set in and out Transitions',
 48+ 'mwe-sequencer-clip-transin' => 'Transition in',
 49+ 'mwe-sequencer-clip-transout' => 'Transition out',
 50+
3751 'mwe-sequencer-preview' => 'Preview',
3852 'mwe-sequencer-apply-changes' => 'Apply changes',
3953 'mwe-sequencer-start-time' => 'Start time',
40 - 'mwe-sequencer-clip-duration' => 'Clip duration',
 54+
4155
4256 'mwe-sequencer-loading_user_rights' => 'Loading user rights ...',
4357 'mwe-sequencer-sequence-xml' => 'Sequence smil xml',
@@ -108,15 +122,13 @@
109123 'mwe-sequencer-publishing-success' => 'Publish success',
110124 'mwe-sequencer-publishing-success-desc' => 'Sequence has successfully been published. [$1 Published file]',
111125
112 - 'mwe-sequencer-transition_in' => 'Transition in',
113 - 'mwe-sequencer-transition_out' => 'Transition out',
 126+
114127 'mwe-sequencer-effects' => 'Effects stack',
115128 'mwe-sequencer-remove_transition' => 'Remove transition',
116129 'mwe-sequencer-edit_transin' => 'Edit transition into clip',
117130 'mwe-sequencer-edit_transout' => 'Edit transition out of clip',
118131 'mwe-sequencer-add-transition' => 'Add a transition',
119 - 'mwe-sequencer-menu_clipedit' => 'Edit media',
120 - 'mwe-sequencer-menu_transition' => 'Transitions and effects',
 132+ 'mwe-sequencer-menu_clipedit' => 'Edit media',
121133 'mwe-sequencer-menu_cliplib' => 'Add media',
122134 'mwe-sequencer-menu_resource_overview' => 'Resource overview',
123135 'mwe-sequencer-menu_options' => 'Options',
Index: branches/MwEmbedStandAlone/modules/Sequencer/actions/mw.SequencerActionsSequence.js
@@ -45,6 +45,7 @@
4646 'buttons' : buttons,
4747 'width' : 450
4848 });
 49+ $dialog.find('input').focus();
4950 // Add a special open button
5051 $dialog.parent().find( '.ui-dialog-buttonpane' ).prepend(
5152 $j.button({
@@ -110,6 +111,7 @@
111112 'buttons' : buttons,
112113 'width' : 450
113114 });
 115+ $dialog.find('input').focus();
114116 // Add a special open button
115117 $dialog.parent().find( '.ui-dialog-buttonpane' ).prepend(
116118 $j.button({
@@ -231,10 +233,12 @@
232234 'maxlength': 255
233235 })
234236 // Make sure keys press does not affect the sequencer interface
235 - .sequencerInput( _this.sequencer )
236 - )
 237+ .sequencerInput( _this.sequencer )
 238+ )
237239 .dialog( "option", "buttons", saveDialogButtons )
238240 .dialog( "option", "title", gM('mwe-sequencer-menu-sequence-save-desc') )
 241+ // give the input focus
 242+ .find('input').focus()
239243 },
240244 /**
241245 * Display the publish dialog
@@ -457,6 +461,7 @@
458462 };
459463 buttons[ gM('mwe-sequencer-menu-sequence-exit-desc') ] = function(){
460464 _this.closeSequencer();
 465+ $j(this).dialog('close');
461466 }
462467 // Confirm the user wants to exit
463468 mw.addDialog( {
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerTools.js
@@ -14,7 +14,11 @@
1515 init: function( sequencer ){
1616 this.sequencer = sequencer;
1717 },
18 - // The current selected tool
 18+
 19+ // The current smil clip ( lazy init )
 20+ currentSmilClip: null,
 21+
 22+ // The current selected tool ( lazy init )
1923 currentToolId: null,
2024
2125 // JSON tools config
@@ -26,14 +30,20 @@
2731 },
2832 'duration':{
2933 'editableAttributes' : [ 'dur' ],
30 - 'contentTypes': ['image']
 34+ 'contentTypes': ['img']
3135 },
3236 'panzoom' : {
 37+ 'editWidgets' : ['panzoom'],
3338 'editableAttributes' : [ 'panZoom' ],
34 - 'contentTypes': ['video', 'image']
 39+ 'contentTypes': ['video', 'img'],
 40+ 'animate' : 'true'
 41+ },
 42+ 'transitions' : {
 43+ 'editableAttributes' : [ 'transIn', 'transOut' ],
 44+ 'contentTypes': ['video', 'img' ]
3545 }
3646 },
37 - editableAttributes:{
 47+ editableAttributes:{
3848 'clipBegin':{
3949 'type': 'time',
4050 'title' : gM('mwe-sequencer-start-time' )
@@ -43,11 +53,37 @@
4454 'title' : gM('mwe-sequencer-clip-duration' )
4555 },
4656 'panZoom' :{
47 - 'type' : 'panzoom',
48 - 'title' : gM('mwe-sequencer-clip-layout' )
 57+ 'type' : 'display',
 58+ 'inputSize' : 15,
 59+ 'title' : gM('mwe-sequencer-clip-panzoom' ),
 60+ 'defaultValue' : '0, 0, 100%, 100%'
 61+ },
 62+ 'transIn' : {
 63+ 'type' : 'select',
 64+ 'selectValues' : [ 'fadeFromColor' ]
 65+ },
 66+ 'transOut' : {
 67+ 'type' : 'select',
 68+ 'selectValues' : [ 'fadeFromColor', 'crossfade' ]
4969 }
5070 },
5171 editableTypes: {
 72+ 'display': {
 73+ update: function( _this, smilClip, attributeName, value){
 74+ $j( smilClip ).attr( attributeName, value);
 75+ // update the display
 76+ },
 77+ getSmilVal : function( _this, smilClip, attributeName ){
 78+ if( $j( smilClip ).attr( attributeName ) ){
 79+ return $j( smilClip ).attr( attributeName )
 80+ }
 81+ // Check for a default value
 82+ if( _this.editableAttributes[ attributeName ].defaultValue ){
 83+ return _this.editableAttributes[ attributeName ].defaultValue;
 84+ }
 85+ return '';
 86+ }
 87+ },
5288 'time' : {
5389 update : function( _this, smilClip, attributeName, value){
5490 // Validate time
@@ -80,7 +116,7 @@
81117 // xxx todo update preview button to "pause" / "play"
82118 }
83119 },
84 - 'cancel':{
 120+ 'cancel' : {
85121 'icon': 'close',
86122 'title' : gM('mwe-cancel'),
87123 'action' : function( _this, smilClip ){
@@ -113,7 +149,150 @@
114150 }
115151 },
116152 editWidgets: {
117 - 'trimTimeline':{
 153+ 'panzoom' : {
 154+ 'onChange': function( _this, target, smilClip ){
 155+ var panZoomVal = $j('#' +_this.getEditToolInputId( 'panzoom', 'panZoom')).val();
 156+ mw.log("panzoom change:" + panZoomVal );
 157+ },
 158+ 'draw': function( _this, target, smilClip ){
 159+ var orginalHelperCss = {
 160+ 'position' : 'absolute',
 161+ 'width' : 100,
 162+ 'height' : 75,
 163+ 'top' : 50,
 164+ 'left' : 70,
 165+ 'font-size' : 'x-small'
 166+ };
 167+ // Add a input box binding:
 168+ $j('#' +_this.getEditToolInputId( 'panzoom', 'panZoom'))
 169+ .change(function(){
 170+ _this.editWidgets.panzoom.onChange( _this, target, smilClip);
 171+ })
 172+
 173+ $j( target ).append(
 174+ $j('<h3 />').html(
 175+ gM('mwe-sequencer-tools-panzoomhelper-desc')
 176+ )
 177+ ,
 178+ /*xxx Keep aspect button ?*/
 179+ // Rest layout button ( restores default position )
 180+ $j.button({
 181+ 'icon' : 'arrow-4',
 182+ 'text' : gM( 'mwe-sequencer-tools-panzoomhelper-resetlayout' )
 183+ })
 184+ .attr('id', 'panzoomResetLayout')
 185+ .css('float', 'left')
 186+ .hide()
 187+ .click(function(){
 188+ // Restore default SMIL setting
 189+ _this.editableTypes['display'].update(
 190+ _this,
 191+ smilClip,
 192+ 'panzoom',
 193+ _this.editableAttributes['panzoom'].defaultValue
 194+ )
 195+ })
 196+ ,
 197+ $j('<div />')
 198+ .css({
 199+ 'border' : '1px solid #DDDDDD',
 200+ 'float' : 'left',
 201+ 'position' : 'relative',
 202+ 'width': '240px',
 203+ 'height' : '180px',
 204+ 'overflow' : 'hidden'
 205+ })
 206+ .append(
 207+ $j('<div />')
 208+ .css( orginalHelperCss )
 209+ .attr({
 210+ 'id': "panzoomHelper"
 211+ })
 212+ .addClass("ui-widget-content")
 213+ .text( gM('mwe-sequencer-tools-panzoomhelper') )
 214+ )
 215+ );
 216+ var startPanZoomVal = '';
 217+ var setStartPanZoomVal = function(){
 218+ startPanZoomVal = $j( smilClip ).attr( 'panZoom');
 219+ if(! startPanZoomVal ){
 220+ startPanZoomVal = _this.editableAttributes['panZoom'].defaultValue;
 221+ }
 222+ }
 223+
 224+ var updatePanZoomFromUiValue = function( layout ){
 225+ var pz = startPanZoomVal.split(',');
 226+ // Set the new percent offset to x/2
 227+ if( layout.left )
 228+ pz[0] = ( parseInt( pz[0] ) + ( layout.left / 2 ) ) + '%';
 229+
 230+ if( layout.top )
 231+ pz[1] = ( parseInt( pz[1] ) + ( layout.top / 2 ) )+ '%';
 232+
 233+ if( layout.width )
 234+ pz[2] = ( parseInt( pz[2] ) + ( layout.width / 2 ) ) + '%'
 235+
 236+ if( layout.height )
 237+ pz[2] = ( parseInt( pz[2] ) + ( layout.width / 2 ) ) + '%'
 238+
 239+ var smilPanZoomValue = pz.join(', ');
 240+
 241+ // Update the smil DOM:
 242+ $j( smilClip ).attr( 'panZoom', smilPanZoomValue );
 243+
 244+ // Update the user input tool input value:
 245+ $j('#' +_this.getEditToolInputId( 'panzoom', 'panZoom')).val( smilPanZoomValue );
 246+
 247+ // Animate the update on the current smil clip display:
 248+ _this.sequencer.getSmil()
 249+ .getLayout()
 250+ .panZoomLayout(
 251+ smilClip
 252+ );
 253+ }
 254+ // Add bindings
 255+ $j('#panzoomHelper')
 256+ .draggable({
 257+ containment: 'parent',
 258+ start: function( event, ui){
 259+ setStartPanZoomVal();
 260+ },
 261+ drag: function( event, ui){
 262+ updatePanZoomFromUiValue({
 263+ 'top' : ( orginalHelperCss.top - ui.position.top ),
 264+ 'left' : ( orginalHelperCss.left - ui.position.left )
 265+ });
 266+ },
 267+ stop: function( event, ui){
 268+ // run the onChange ?
 269+ // Restore original css for the layout helper
 270+ $j(this).css( orginalHelperCss )
 271+ }
 272+ })
 273+ .css('cursor', 'move')
 274+ .resizable({
 275+ handles : 'all',
 276+ maxWidth : 170,
 277+ maxHeight: 130,
 278+ aspectRatio: 4/3,
 279+ start: function( event, ui){
 280+ setStartPanZoomVal();
 281+ },
 282+ resize : function(event, ui){
 283+ updatePanZoomFromUiValue({
 284+ 'width' : ( orginalHelperCss.width - ui.size.width ),
 285+ 'height' : ( orginalHelperCss.top - ui.size.height )
 286+ });
 287+ },
 288+ stop: function( event, ui){
 289+ // Restore original css
 290+ $j(this).css( orginalHelperCss )
 291+ }
 292+ })
 293+
 294+ }
 295+ },
 296+ 'trimTimeline' : {
118297 'onChange': function( _this, target, smilClip ){
119298 var smil = _this.sequencer.getSmil();
120299 // Update the preview thumbs
@@ -160,10 +339,13 @@
161340 )
162341 }
163342
164 - // Add a trim binding:
165 - $j('#editTool_trim_clipBegin,#editTool_trim_dur').change(function(){
 343+ // Add a trim binding:
 344+ $j('#' + _this.getEditToolInputId( 'trim', 'clipBegin') +
 345+ ',#' + _this.getEditToolInputId( 'trim', 'dur') )
 346+ .change( function(){
166347 _this.editWidgets.trimTimeline.onChange( _this, target, smilClip);
167348 })
 349+
168350 // Update the thumbnails:
169351 _this.editWidgets.trimTimeline.onChange( _this, target, smilClip);
170352
@@ -186,7 +368,8 @@
187369 $j('<div />')
188370 .attr( 'id', _this.sequencer.id + '_trimTimeline' )
189371 .css({
190 - 'left' : '5px',
 372+ 'position': 'absolute',
 373+ 'left' : '15px',
191374 'right' : '15px',
192375 'margin': '5px'
193376 })
@@ -195,11 +378,12 @@
196379 min: 0,
197380 max: 1000,
198381 values: sliderValues,
199 - slide: function(event, ui) {
200 - $j('#editTool_trim_clipBegin').val(
 382+ slide: function(event, ui) {
 383+
 384+ $j('#' + _this.getEditToolInputId( 'trim', 'clipBegin') ).val(
201385 mw.seconds2npt( sliderToTime( ui.values[0] ), true )
202386 );
203 - $j('#editTool_trim_dur').val(
 387+ $j('#' + _this.getEditToolInputId( 'trim', 'dur') ).val(
204388 mw.seconds2npt( sliderToTime( ui.values[1] - ui.values[0] ), true )
205389 );
206390 },
@@ -245,59 +429,57 @@
246430 */
247431 updateToolDisplay: function(){
248432 var _this = this;
249 - // Update all tool input values:: trigger change event if changed
250 - var smilClip = this.getCurrentSmilClip();
 433+
 434+ // If tools are displayed update them
 435+ if( this.sequencer.getEditToolTarget().find('.editToolsContainer').lenght ){
 436+ this.drawClipEditTools()
 437+ }
251438
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 - );
270439 },
271440 getToolSet: function( refType ){
272 - var toolSet = [];
 441+ var toolSet = [];
273442 for( var toolId in this.tools){
274 - if( this.tools[toolId].contentTypes){
275 - if( $j.inArray( refType, this.tools[toolId].contentTypes) != -1 ){
 443+ if( this.tools[ toolId ].contentTypes){
 444+ if( $j.inArray( refType, this.tools[ toolId ].contentTypes) != -1 ){
276445 toolSet.push( toolId );
277446 }
278447 }
279448 }
280449 return toolSet;
281450 },
282 - drawClipEditTools: function( smilClip ){
 451+ drawClipEditTools: function( smilClip, selectedToolId ){
283452 var _this = this;
284 - var toolId = '';
285 - var $target = this.sequencer.getEditToolTarget();
286453
287 - // Set the current smilClip
288 - this.currentSmilClip = smilClip;
 454+ // Update the current clip and tool :
 455+ if( smilClip ){
 456+ this.setCurrentSmilClip( smilClip );
 457+ }
 458+ if( selectedToolId ){
 459+ this.setCurrentToolId( selectedToolId );
 460+ }
289461
290 -
291 - $target.empty().append(
292 - $j('<div />')
293 - .addClass( 'editToolsContainer' )
294 - .append(
295 - $j('<ul />')
296 - )
 462+ $toolsContainer = $j('<div />')
 463+ .addClass( 'editToolsContainer' )
 464+ .css( {
 465+ 'height': '80%'
 466+ })
 467+ .append(
 468+ $j('<ul />')
297469 );
298470
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 -
 471+ this.sequencer.getEditToolTarget().empty().append(
 472+ $toolsContainer
 473+ );
 474+ // Get the entire tool set based on what "ref type" smilClip is:
 475+ var toolSet = this.getToolSet(
 476+ this.sequencer.getSmil().getRefType(
 477+ this.getCurrentSmilClip()
 478+ )
 479+ );
 480+ mw.log( 'Adding ' + toolSet.length + ' tools for ' + this.sequencer.getSmil().getRefType( this.getCurrentSmilClip() ) );
 481+
 482+ $j.each( toolSet, function( inx, toolId ){
 483+
302484 var tool = _this.tools[ toolId ];
303485
304486 // set the currentTool if not already set
@@ -306,7 +488,7 @@
307489 }
308490
309491 // Append the title to the ul list
310 - $target.find( 'ul').append(
 492+ $toolsContainer.find( 'ul').append(
311493 $j('<li />').append(
312494 $j('<a />')
313495 .attr('href', '#tooltab_' + toolId )
@@ -315,11 +497,15 @@
316498 );
317499
318500 // Append the tooltab container
319 - $target.append(
 501+ $toolsContainer.append(
320502 $j('<div />')
321 - .attr('id', 'tooltab_' + toolId )
 503+ .css({'height' : '100%', 'overflow': 'auto'})
 504+ .attr('id', 'tooltab_' + toolId )
 505+ .append(
 506+ $j('<h3 />').text( gM('mwe-sequencer-tools-' + toolId + '-desc') )
 507+ )
322508 )
323 - var $toolContainer = $target.find( '#tooltab_' + toolId );
 509+ var $toolContainer = $toolsContainer.find( '#tooltab_' + toolId );
324510
325511 // Build out the attribute list for the given tool:
326512 for( var i=0; i < tool.editableAttributes.length ; i++ ){
@@ -358,14 +544,14 @@
359545 });
360546
361547 // Add tab bindings
362 - $target.find('.editToolsContainer').tabs({
 548+ $toolsContainer.tabs({
363549 select: function(event, ui) {
364 - debugger;
 550+
365551 }
366552 })
367 - // Build out global edit Actions buttons ( per 'current tool' )
 553+ // Build out global edit Actions buttons after the container
368554 for( var editActionId in this.editActions ){
369 - $target.append(
 555+ $toolsContainer.after(
370556 this.getEditAction( smilClip, editActionId )
371557 )
372558 }
@@ -373,9 +559,15 @@
374560 getCurrentSmilClip: function(){
375561 return this.currentSmilClip;
376562 },
 563+ setCurrentSmilClip: function( smilClip ){
 564+ this.currentSmilClip = smilClip;
 565+ },
377566 getCurrentToolId: function(){
378567 return this.currentToolId;
379568 },
 569+ setCurrentToolId: function( toolId ){
 570+ this.currentToolId = toolId;
 571+ },
380572
381573 getEditAction: function( smilClip, editActionId ){
382574 if(! this.editActions[ editActionId ]){
@@ -397,6 +589,7 @@
398590 })
399591 return $actionButton;
400592 },
 593+ /* get the editiable attribute input html */
401594 getEditableAttribute: function( smilClip, toolId, attributeName ){
402595 if( ! this.editableAttributes[ attributeName ] ){
403596 mw.log("Error: editableAttributes : " + attributeName + ' not found');
@@ -405,17 +598,23 @@
406599 var _this = this;
407600 var editAttribute = this.editableAttributes[ attributeName ];
408601 var editType = editAttribute.type;
409 -
 602+ if( !_this.editableTypes[ editType ] ){
 603+ mw.log(" Error: No editableTypes interface for " + editType);
 604+ return ;
 605+ }
410606 var initialValue = _this.editableTypes[ editType ].getSmilVal(
411607 _this,
412608 smilClip,
413609 attributeName
414610 );
 611+ // Set the default input size
 612+ var inputSize = ( _this.editableAttributes[ attributeName ].inputSize)?
 613+ _this.editableAttributes[ attributeName ].inputSize : 6;
 614+
415615 return $j( '<div />' )
416616 .css({
417617 'float': 'left',
418 - 'font-size': '12px',
419 - 'width': '160px',
 618+ 'font-size': '12px',
420619 'border': 'solid thin #999',
421620 'background-color': '#EEE',
422621 'padding' : '2px',
@@ -430,7 +629,7 @@
431630 $j('<input />')
432631 .attr( {
433632 'id' : _this.getEditToolInputId( toolId, attributeName),
434 - 'size': 6
 633+ 'size': inputSize
435634 })
436635 .data('initialValue', initialValue )
437636 .sequencerInput( _this.sequencer )

Status & tagging log