r64493 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64492‎ | r64493 | r64494 >
Date:15:37, 1 April 2010
Author:dale
Status:deferred
Tags:
Comment:
* added core style sheets to mwEmbed core class loader
* removed some unused css in common.css
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/jsScriptLoader.php (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/mwEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/skins/common/common.css (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/skins/common/common.css
@@ -373,97 +373,10 @@
374374 .ui-dialog .ui-dialog-buttonpane button { float: left !important; }
375375
376376
377 -.vol_container{
378 - z-index:99;
379 - width:23px;
380 - height:75px;
381 - width:23px;
382 - background: #CCC;
383 -}
384 -.vol_container_below{
385 - top:30px;
386 -}
387 -.vol_container_top{
388 - top:-77px;
389 -}
390 -.vol_container .volume_bar{
391 - margin-top:5px;
392 - height:65px;
393 - width:10px;
394 - margin-left: auto ;
395 - margin-right: auto ;
396 -}
397 -.vol_container .ui-slider-handle{
398 - cursor : pointer;
399 - width:10px;
400 - height:10px;
401 - position:absolute;
402 - left:-1px;
403 -}
404 -
405 -/* related videos Video */
406 -.related_vids {
407 - top:10px;
408 - left:5px;
409 - right:5px;
410 - bottom:5px;
411 - position:absolute;
412 - overflow-y:auto;
413 -}
414 -.related_vids h1 {
415 - border:medium none;
416 - font-size:20px;
417 - margin:4px 0px 4px 11px;
418 - padding:0;
419 - color:#FFF;
420 - font-family:arial,sans-serif;
421 -}
422 -
423 -.related_vids ul {
424 - margin:0;
425 - padding:0;
426 - list-style-image:none;
427 - list-style-position:inside;
428 - list-style-type:none;
429 - margin:0;
430 - padding:0;
431 -}
432 -
433 -.related_vids li{
434 - -x-system-font:none;
435 - color:#FAFAFA;
436 - display:table;
437 - font-family:arial,sans-serif;
438 - font-size:11px;
439 - line-height:normal;
440 - margin:0 0 6px 35px;
441 - padding:0;
442 -}
443 -.related_vids a{
444 - color:#FAFAFA;
445 -}
446 -
447 -.related_vids li div {
448 - float:right;
449 - margin:5px 0 0 10px;
450 - width:200px;
451 -}
452 -
453 -.related_vids img {
454 - width:80px;
455 - z-index:2;
456 - border-bottom:3px solid #36393D;
457 - border-top:3px solid #36393D;
458 -}
459 -
460377 .mw-imported-resource{
461378 border: thin solid black;
462379 }
463380
464 -.interface_wrap{
465 - position:relative;
466 -}
467 -
468381 .kaltura-icon {
469382 background-image:url('images/kaltura_logo_sm_transparent.png') !important;
470383 background-repeat:no-repeat;
@@ -473,12 +386,6 @@
474387 margin-top: -6px !important;
475388 margin-left: 3px !important;
476389 }
477 -.mw-buffer{
478 - width:0px;
479 - height:100%;
480 - z-index:1;
481 - top:0px;
482 -}
483390
484391 .mw-fullscreen-overlay {
485392 background: rgb(0, 0, 0) none repeat scroll 0% 0%;
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js
@@ -2387,8 +2387,12 @@
23882388 * @param {String} cssString Css Payload to be added to head of document
23892389 */
23902390 mw.addStyleString = function( cssClassName, cssString ) {
 2391+ if( mw.style[ cssClassName ] ){
 2392+ mw.log(" Style: ( " + cssClassName + ' ) already set' );
 2393+ return true;
 2394+ }
23912395 // Set the style to true ( to not request it again )
2392 - mw.style[ cssClassName ] = true;
 2396+ mw.style[ cssClassName ] = true;
23932397 mw.log(" Style: " + cssClassName + ' has been set' );
23942398 // Wait for the DOM to be ready before adding in the css:
23952399 mw.ready( function() {
Index: branches/js2-work/phase3/js/mwEmbed/jsScriptLoader.php
@@ -107,15 +107,16 @@
108108
109109 // Build the output
110110 // Swap in the appropriate language per js_file
111 - foreach ( $this->jsFileList as $classKey => $file_name ) {
 111+ foreach ( $this->jsFileList as $classKey => $filePath ) {
112112
113113 // Get the script content
114 - $jstxt = $this->getScriptText( $classKey, $file_name );
 114+ $jstxt = $this->getScriptText( $classKey, $filePath );
115115 if( $jstxt ){
116116 $this->jsout .= $this->doProcessJs( $jstxt );
117117 }
118118
119 - // If the core mwEmbed class entry point include all the loader js
 119+ // If the core mwEmbed class entry point add some
 120+ // other "core" files:
120121 if( $classKey == 'mwEmbed' ){
121122
122123 // Output the loaders:
@@ -125,11 +126,11 @@
126127 $this->jsout .= jsClassLoader::getLanguageJs( $this->langCode );
127128
128129 // Output the "common" css file
129 - $filePath = self::getJsPathFromClass( 'mw.style.common' );
130 - if( $filePath ) {
131 - $this->jsout .= $this->getScriptText( 'mw.style.common', $filePath );
132 - }
 130+ $this->jsout .= $this->getScriptText( 'mw.style.common' );
133131
 132+ // Output the jQuery ui theme css
 133+ $this->jsout .= $this->getScriptText( 'mw.style.redmond' );
 134+
134135 // Output special IE comment tag to support special mwEmbed tags.
135136 $NotMinifiedTopJs.='/*@cc_on\'video source itext playlist\'.replace(/\w+/g,function(n){document.createElement(n)})@*/'."\n";
136137 }
@@ -256,19 +257,20 @@
257258 * Get the javascript text content from a given classKey
258259 *
259260 * @param {String} $classKey Class Key to grab text for
260 - * @param {String} [$file_name] Optional file path to get js text
 261+ * @param {String} [$filePath] Optional file path to get js text
261262 * @return unknown
262263 */
263 - function getScriptText( $classKey, $file_name = '' ){
 264+ function getScriptText( $classKey ){
264265 $jsout = '';
 266+ $filePath = self::getPathFromClass( $classKey );
265267 // Special case: title classes
266268 if ( substr( $classKey, 0, 3 ) == 'WT:' ) {
267269 global $wgUser;
268270 // Get just the title part
269 - $title_block = substr( $classKey, 3 );
270 - if ( $title_block[0] == '-' && strpos( $title_block, '|' ) !== false ) {
 271+ $titleBlock = substr( $classKey, 3 );
 272+ if ( $titleBlock[0] == '-' && strpos( $titleBlock, '|' ) !== false ) {
271273 // Special case of "-" title with skin
272 - $parts = explode( '|', $title_block );
 274+ $parts = explode( '|', $titleBlock );
273275 $title = array_shift( $parts );
274276 foreach ( $parts as $tparam ) {
275277 list( $key, $val ) = explode( '=', $tparam );
@@ -288,20 +290,20 @@
289291 return $sk->generateUserJs( $skin ) . "\n";
290292 }
291293 } else {
292 - $ext = substr($title_block, strrpos($title_block, '.') + 1);
 294+ $ext = substr($titleBlock, strrpos($titleBlock, '.') + 1);
293295 // Make sure the wiki title ends with .js or .css
294296 if ( self::validFileExtension( $ext ) ) {
295297 $this->errorMsg .= 'WikiTitle includes should end with .js or .css';
296298 return false;
297299 }
298300 // It's a wiki title, append the output of the wikitext:
299 - $t = Title::newFromText( $title_block );
 301+ $t = Title::newFromText( $titleBlock );
300302 $a = new Article( $t );
301303 // Only get the content if the page is not empty:
302304 if ( $a->getID() !== 0 ) {
303305 // If in debug mode, add a comment with wiki title and rev:
304306 if ( $this->debug )
305 - $jsout .= "\n/**\n* WikiJSPage: " . htmlspecialchars( $title_block ) . " rev: " . $a->getID() . " \n*/\n";
 307+ $jsout .= "\n/**\n* WikiJSPage: " . htmlspecialchars( $titleBlock ) . " rev: " . $a->getID() . " \n*/\n";
306308 $fileStr = $a->getContent() . "\n";
307309 $jsout.= ( $ext == 'css' ) ?
308310 $this->transformCssOutput( $classKey, $fileStr ) :
@@ -310,22 +312,22 @@
311313 }
312314 }
313315 }else{
314 - $ext = substr($file_name, strrpos($file_name, '.') + 1);
 316+ $ext = substr($filePath, strrpos($filePath, '.') + 1);
315317 // Dealing with files
316 - if ( trim( $file_name ) != '' ) {
317 - $fileStr = $this->getFileContents( $file_name ) . "\n";
 318+ if ( trim( $filePath ) != '' ) {
 319+ $fileStr = $this->getFileContents( $filePath ) . "\n";
318320 if( $fileStr ){
319321 // Add the file name if debug is enabled
320322 if ( $this->debug ){
321 - $jsout .= "\n/**\n* File: " . htmlspecialchars( $file_name ) . "\n*/\n";
 323+ $jsout .= "\n/**\n* File: " . htmlspecialchars( $filePath ) . "\n*/\n";
322324 }
323325 $jsout.= ( $ext == 'css' ) ?
324 - $this->transformCssOutput( $classKey, $fileStr, $file_name ) :
 326+ $this->transformCssOutput( $classKey, $fileStr, $filePath ) :
325327 $fileStr;
326328
327329 return $jsout;
328330 }else{
329 - $this->errorMsg .= "\nError could not read file: ". htmlspecialchars( $file_name ) ."\n";
 331+ $this->errorMsg .= "\nError could not read file: ". htmlspecialchars( $filePath ) ."\n";
330332 return false;
331333 }
332334 }
@@ -347,7 +349,7 @@
348350 $cssOptions[ 'preserveComments' ] = false;
349351 }
350352 $serverUri = $this->getScriptLoaderUri();
351 -
 353+
352354 // Check for the two jsScriptLoader entry points:
353355 if( strpos( $serverUri, 'mwScriptLoader.php') !== false ){
354356 $cssOptions[ 'prependRelativePath' ] =
@@ -515,11 +517,11 @@
516518
517519 $reqClass = preg_replace( "/[^A-Za-z0-9_\-\.]/", '', $reqClass );
518520
519 - $jsFilePath = self::getJsPathFromClass( $reqClass );
 521+ $filePath = self::getPathFromClass( $reqClass );
520522 if( !$jsFilePath ){
521523 $this->errorMsg .= 'Requested class: ' . htmlspecialchars( $reqClass ) . ' not found' . "\n";
522524 }else{
523 - $this->jsFileList[ $reqClass ] = $jsFilePath;
 525+ $this->jsFileList[ $reqClass ] = $filePath;
524526 $this->requestKey .= $reqClass;
525527 }
526528 }
@@ -638,7 +640,7 @@
639641 * @param {String} $reqClass Class key to get the path for
640642 * @return path of the class or "false"
641643 */
642 - public static function getJsPathFromClass( $reqClass ){
 644+ public static function getPathFromClass( $reqClass ){
643645 global $wgJSAutoloadClasses;
644646 // Make sure the class is loaded:
645647 jsClassLoader::loadClassPaths();
@@ -789,7 +791,7 @@
790792 * @return {Array} decoded json array of message key value pairs
791793 */
792794 function getMsgKeysFromClass( $class ){
793 - $filePath = self::getJsPathFromClass( $class );
 795+ $filePath = self::getPathFromClass( $class );
794796 $str = $this->getScriptText($class, $filePath);
795797
796798 $inx = self::getAddMessagesIndex( $str );

Status & tagging log