r68596 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68595‎ | r68596 | r68597 >
Date:01:10, 26 June 2010
Author:dale
Status:deferred
Tags:
Comment:
minor smil code clean up
Modified paths:
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilAnimate.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBody.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBuffer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilLayout.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/tests/VideoTransitionSmil.xml (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBuffer.js
@@ -21,6 +21,7 @@
2222
2323 // Get active body elements
2424 //this.smil.getBody().getElementsForTime( time );
 25+
2526 // Check load status per temporal offset
2627
2728 // setTimeout to call self until buffer is ready
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilBody.js
@@ -74,7 +74,7 @@
7575
7676 // Transform the elements per animate engine
7777 _this.smil.getAnimate().animateTransform( smilElement, relativeTime, deltaTime );
78 - },
 78+ },
7979 /* SMIL Element out of range */
8080 function( smilElement ){
8181 // Hide the element in the layout
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilLayout.js
@@ -56,7 +56,8 @@
5757 });
5858
5959 // Update the root layout css
60 - this.$rootLayout.css( _this.getRootLayoutCss() )
 60+ this.$rootLayout.css( _this.getRootLayoutCss() );
 61+
6162 // Update the root layout html
6263 this.$rootLayout.html( _this.getRootLayoutHtml() );
6364 }
@@ -124,7 +125,7 @@
125126 * Get the transformed smil element in html format
126127 * @param
127128 */
128 - getSmilElementHtml: function ( smilElement ) {
 129+ getSmilElementHtml: function( smilElement ) {
129130 var smilType = this.smil.getRefType( smilElement )
130131 switch( smilType ){
131132 // Not part of strict smil, but saves time being able have an "html" display mode
@@ -159,14 +160,14 @@
160161 */
161162 getSmilVideoHtml: function( videoElement ){
162163 return $j('<video />')
163 - .attr( {
164 - 'id' : this.smil.getAssetId( videoElement ),
165 - 'src' : this.smil.getAssetUrl( $j( videoElement ).attr( 'src' ) )
166 - } )
167 - .css( {
168 - 'width': '100%',
169 - 'height' : '100%'
170 - })
 164+ .attr( {
 165+ 'id' : this.smil.getAssetId( videoElement ),
 166+ 'src' : this.smil.getAssetUrl( $j( videoElement ).attr( 'src' ) )
 167+ } )
 168+ .css( {
 169+ 'width': '100%',
 170+ 'height' : '100%'
 171+ } )
171172 },
172173
173174 /**
@@ -174,7 +175,7 @@
175176 * XXX Security XXX
176177 * Here we are parsing in SMIL -> HTML should be careful about XSS or script elevation
177178 *
178 - * @@TODO check if this is "local" only smil and enforce domain on all asset sources
 179+ * @@TODO check all sources are "local" only smil and enforce domain on all asset sources
179180 */
180181 getSmilCDATAHtml: function( smilElement ){
181182 // Get "clean" smil data
@@ -195,7 +196,7 @@
196197 .attr( 'id' , this.smil.getAssetId( smilElement ) )
197198 // Wrap in font-size percentage relative to virtual size
198199 .css( 'font-size', ( ( this.targetWidth / this.virtualWidth )*100 ) + '%' )
199 - .append(
 200+ .append(
200201 // We pass the xmlCdata via jQuery fragment creation, this runs jquery.clean()
201202 // and filters the result html.
202203 $j( xmlCdata )
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilAnimate.js
@@ -1,4 +1,3 @@
2 -
32 /**
43 * Handles the smil animate class
54 */
@@ -88,7 +87,9 @@
8988 }
9089 }
9190 }
 91+ if(
9292
 93+
9394 // Check if we need to do a smilText clear:
9495 if( nodeName.toLowerCase() == 'smiltext' ){
9596 var el = $j( smilElement ).get(0);
@@ -104,8 +105,7 @@
105106 }
106107 }
107108 }
108 - //mw.log( 'checkForTransformUpdate::' + nodeName +' ' + animateTime );
109 -
 109+ //mw.log( 'checkForTransformUpdate::' + nodeName +' ' + animateTime );
110110 return false;
111111 },
112112
@@ -119,8 +119,6 @@
120120 transformElement: function( smilElement, animateTime ) {
121121 var nodeName = $j( smilElement ).get(0).nodeName ;
122122
123 -
124 -
125123 //mw.log("transformForTime: " + nodeName + ' t:' + animateTime );
126124 switch( nodeName.toLowerCase() ){
127125 case 'smiltext':
@@ -128,10 +126,13 @@
129127 break;
130128 case 'img':
131129 return this.transformImageForTime( smilElement, animateTime);
132 - break;
 130+ break;
133131 }
134132 },
135133
 134+ /**
 135+ * transformTextForTime
 136+ */
136137 transformTextForTime: function( textElement, animateTime ) {
137138 //mw.log("transformTextForTime:: " + animateTime );
138139
@@ -193,15 +194,20 @@
194195 $j( animateElement ).attr( 'attributeName' ) );
195196 }
196197 });
197 - // No animate elements in range, make sure we transform to previus or to initial state if time is zero
 198+ // No animate elements in range, make sure we transform to previous or to initial state if time is zero
198199 if( !animateInRange ) {
199200 if( animateTime == 0 ) {
200 - // just a hack for now ( should read from previus animation or from source attribute
 201+ // just a hack for now ( should read from previous animation or from source attribute
201202 //this.updateElementLayout( smilImgElement, { 'top':1,'left':1,'width':1, 'height':1 } );
202203 var $target = $j( '#' + this.smil.getAssetId( smilImgElement ));
203 - $target.css({ 'top':'0px','left':'0px','width':'100%', 'height':'100%' } );
 204+ $target.css( {
 205+ 'top' : '0px',
 206+ 'left' :'0px',
 207+ 'width' : '100%',
 208+ 'height' : '100%'
 209+ } );
204210 }
205 - // xxx should check for transform to previus
 211+ // xxx should check for transform to previous
206212 }
207213 },
208214
@@ -238,8 +244,6 @@
239245 * Get the css layout transforms for a panzoom transform type
240246 *
241247 * http://www.w3.org/TR/SMIL/smil-extended-media-object.html#q32
242 - *
243 - *
244248 */
245249 transformPanZoom: function( smilImgElement, animateElement, animateTime ){
246250 var begin = this.smil.parseTime( $j( animateElement ).attr( 'begin') );
@@ -295,7 +299,7 @@
296300
297301 var htmlAsset = $j( '#' + this.smil.getAssetId( smilElement ) ).get(0);
298302
299 - // xxx best way may be to use canvaus and fitting system.
 303+ // xxx best way may be to use canvaus and a fitting system.
300304
301305 // Setup target height width based target region size
302306 var fullWidth = $target.parents('.smilRegion').width() ;
@@ -367,6 +371,5 @@
368372 targetValue[ i ] += ( startPointSet[i].indexOf('%') != -1 ) ? '%' : '';
369373 }
370374 return targetValue;
371 - }
372 -
 375+ }
373376 }
\ No newline at end of file
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/tests/VideoTransitionSmil.xml
@@ -23,7 +23,7 @@
2424 </head>
2525 <body>
2626 <seq>
27 - <ref type="text/html" dur="8" uri="Template:My_Video_Intro_Text"><![CDATA[
 27+ <ref type="text/html" dur="4" uri="Template:My_Video_Intro_Text"><![CDATA[
2828 <h3> <span class="mw-headline" id="cat">cat</span></h3>
2929 <div class="thumb tright"><div class="thumbinner" style="width:102px;"><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/d/dc/Nos_kota.jpg/120px-Nos_kota.jpg"></div></div>
3030 <div style="color:gray"> MY Date: 21 January, 2010 00:45</div>

Status & tagging log