r69942 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69941‎ | r69942 | r69943 >
Date:14:20, 26 July 2010
Author:dale
Status:deferred
Tags:
Comment:
* refactor of mw.addDialog to be a more transparent jquery ui helper. ( takes a single options argument that matches $target.dialog( options )
* added a function to check if message key exists ( used for optional title attribute menu helper descriptions )
Modified paths:
  • /branches/MwEmbedStandAlone/components/mw.Language.js (modified) (history)
  • /branches/MwEmbedStandAlone/libraries/jquery/plugins/jquery.menu/jquery.menu.js (modified) (history)
  • /branches/MwEmbedStandAlone/loader.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/AddMedia/jquery.dragDropFile.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/ApiProxy/mw.ApiProxy.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/TimedText/mw.TimedTextEdit.js (modified) (history)
  • /branches/MwEmbedStandAlone/mwEmbed.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/loader.js
@@ -50,7 +50,7 @@
5151 'ClipEdit',
5252 'EmbedPlayer',
5353 'ApiProxy',
54 - 'SequenceEdit',
 54+ 'Sequencer',
5555 'TimedText',
5656 'SmilPlayer',
5757 'Playlist',
Index: branches/MwEmbedStandAlone/components/mw.Language.js
@@ -277,6 +277,16 @@
278278 // Missing key placeholder
279279 return '<' + key + '>';
280280 }
 281+ /**
 282+ * Check if a message key is defined
 283+ * @return {Boolean} true if msg is defined, false if msg is not set
 284+ */
 285+ mw.Language.isMsgKeyDefined = function( msgKey ){
 286+ if( messageCache[ msgKey ] ){
 287+ return true
 288+ }
 289+ return false;
 290+ }
281291
282292 /**
283293 * Add Supported Magic Words to parser
@@ -425,7 +435,7 @@
426436 }
427437 return ( typeInt )? parseInt( convertedNumber) : convertedNumber;
428438 }
429 -
 439+
430440 /**
431441 * Checks if a language key is valid ( is part of languageCodeList )
432442 * @param {String} langKey Language key to be checked
Index: branches/MwEmbedStandAlone/mwEmbed.js
@@ -1002,11 +1002,13 @@
10031003 * dialogHtml text Html of the loader msg
10041004 */
10051005 mw.addLoaderDialog = function( dialogHtml ) {
1006 - $dialog = mw.addDialog( dialogHtml, dialogHtml + '<br>' +
 1006+ $dialog = mw.addDialog( {
 1007+ 'title' : dialogHtml,
 1008+ 'content' : dialogHtml + '<br>' +
10071009 $j('<div />')
10081010 .loadingSpinner()
10091011 .html()
1010 - );
 1012+ });
10111013 return $dialog;
10121014 }
10131015
@@ -1031,62 +1033,73 @@
10321034 /**
10331035 * Add a (temporary) dialog window:
10341036 *
1035 - * @param {String}
1036 - * title Title string for the dialog
1037 - * @param {String}
1038 - * dialogHtml String to be inserted in msg box
1039 - * @param {Mixed}
1040 - * buttonOption A button object for the dialog Can be a string
1041 - * for the close button
 1037+ * @param {Object} with following keys:
 1038+ * title: {String} Title string for the dialog
 1039+ * content: {String} to be inserted in msg box
 1040+ * buttons: {Object} A button object for the dialog Can be a string
 1041+ * for the close button
 1042+ * any jquery.ui.dialog option
10421043 */
1043 - mw.addDialog = function ( title, dialogHtml, buttons ) {
1044 - $j( '#mwTempLoaderDialog' ).remove();
 1044+ mw.addDialog = function ( options ) {
 1045+ // Remove any other dialog
 1046+ $j( '#mwTempLoaderDialog' ).remove();
10451047
1046 - // Append the style free loader ontop:
 1048+ if( !options){
 1049+ options = {};
 1050+ }
 1051+
 1052+ // Extend the default options with provided options
 1053+ var options = $j.extend({
 1054+ 'bgiframe': true,
 1055+ 'draggable': true,
 1056+ 'resizable': false,
 1057+ 'modal': true
 1058+ }, options );
 1059+
 1060+ if( ! options.title || ! options.content ){
 1061+ mw.log("Error: mwEmbed addDialog missing required options ( title, content ) ")
 1062+ return ;
 1063+ }
 1064+
 1065+ // Append the dialog div on top:
10471066 $j( 'body' ).append(
10481067 $j('<div />')
10491068 .attr( {
10501069 'id' : "mwTempLoaderDialog",
1051 - 'title' : title
 1070+ 'title' : options.title
10521071 })
10531072 .css({
10541073 'display': 'none'
10551074 })
1056 - .html( dialogHtml )
 1075+ .append( options.content )
10571076 );
 1077+
 1078+ // Build the uiRequest
 1079+ var uiRequest = [ '$j.ui.dialog' ];
 1080+ if( options.draggable ){
 1081+ uiRequest.push( '$j.ui.draggable' )
 1082+ }
 1083+ if( options.resizable ){
 1084+ uiRequest.push( '$j.ui.resizable' );
 1085+ }
10581086
10591087 // Special button string
1060 - if ( typeof buttons == 'string' ) {
1061 - var buttonMsg = buttons;
 1088+ if ( typeof options.buttons == 'string' ) {
 1089+ var buttonMsg = options.buttons;
10621090 buttons = { };
1063 - buttons[ buttonMsg ] = function() {
 1091+ options.buttons[ buttonMsg ] = function() {
10641092 $j( '#mwTempLoaderDialog' ).dialog( 'close' );
10651093 }
1066 - }
 1094+ }
10671095
10681096 // Load the dialog resources
10691097 mw.load([
10701098 [
10711099 '$j.ui'
10721100 ],
1073 - [
1074 - '$j.ui.dialog',
1075 - '$j.ui.draggable'
1076 - ]
 1101+ uiRequest
10771102 ], function() {
1078 - // Set width to default 400 if mwTempLoaderDialog does not have an
1079 - // inherit width
1080 - var width = ( $j( '#mwTempLoaderDialog' ).width() ) ?
1081 - $j( '#mwTempLoaderDialog' ).width() + 12 :
1082 - 400;
1083 - $j( '#mwTempLoaderDialog' ).dialog( {
1084 - 'bgiframe': true,
1085 - 'draggable': true,
1086 - 'resizable': false,
1087 - 'modal': true,
1088 - 'width': width,
1089 - 'buttons': buttons
1090 - } );
 1103+ $j( '#mwTempLoaderDialog' ).dialog( options );
10911104 } );
10921105 return $j( '#mwTempLoaderDialog' );
10931106 }
Index: branches/MwEmbedStandAlone/modules/TimedText/mw.TimedTextEdit.js
@@ -346,17 +346,17 @@
347347 window.location.reload();
348348 }
349349 //Edit success
350 - mw.addDialog(
351 - gM( "mwe-timedtext-upload-text-done"),
352 - gM("mwe-timedtext-upload-text-success"),
353 - buttons
354 - )
 350+ mw.addDialog( {
 351+ 'title' : gM( "mwe-timedtext-upload-text-done"),
 352+ 'content' : gM("mwe-timedtext-upload-text-success"),
 353+ 'buttons' : buttons
 354+ })
355355 }else{
356 - mw.addDialog(
357 - gM( "mwe-timedtext-upload-text-fail-title"),
358 - gM( "mwe-timedtext-upload-text-fail-desc"),
359 - 'ok'
360 - )
 356+ mw.addDialog({
 357+ 'title' : gM( "mwe-timedtext-upload-text-fail-title"),
 358+ 'content' :gM( "mwe-timedtext-upload-text-fail-desc"),
 359+ 'buttons' : gM( 'mwe-ok' )
 360+ })
361361 }
362362 });
363363 })
Index: branches/MwEmbedStandAlone/modules/AddMedia/jquery.dragDropFile.js
@@ -117,11 +117,6 @@
118118 )
119119 )
120120 )
121 - /*mw.addDialog( "upload this image", '<img width="300" src="' + files[i].getAsDataURL() + '">' +
122 - '<br>name: ' + files[i].name + '</br>' +
123 - '<br>size: ' + files[i].fileSize + '</br>' +
124 - '<br>mime: ' + files[i].mediaType + '</br>');
125 - */
126121 // do the add-media-wizard with the upload tab
127122 } else {
128123 alert( "file is too big, needs to be below 64mb" );
Index: branches/MwEmbedStandAlone/modules/ApiProxy/mw.ApiProxy.js
@@ -582,11 +582,11 @@
583583 gM( 'mwe-remember-loging' )
584584 )
585585
586 - mw.addDialog(
587 - gM( 'mwe-proxy-not-ready' ),
588 - $dialogMsg,
589 - buttons
590 - )
 586+ mw.addDialog( {
 587+ 'title' : gM( 'mwe-proxy-not-ready' ),
 588+ 'content' : $dialogMsg,
 589+ 'buttons' : buttons
 590+ })
591591 }
592592
593593 /**
Index: branches/MwEmbedStandAlone/libraries/jquery/plugins/jquery.menu/jquery.menu.js
@@ -5,11 +5,17 @@
66 By: Maggie Costello Wachs (maggie@filamentgroup.com) and Scott Jehl (scott@filamentgroup.com)
77 http://www.filamentgroup.com
88 * reference articles: http://www.filamentgroup.com/lab/jquery_ipod_style_drilldown_menu/
 9+
 10+* modified by Michael Dale, ( michael.dale@kaltura.com )
911
1012 Copyright (c) 2009 Filament Group
1113 Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses.
1214
13 -NOTE: mvEmbed will switch to jquery ui menu once that is released
 15+NOTE: mwEmbed will switch to jquery ui menu once that is released
 16+NOTE: This menu contains several customizations for use in mwEmbed modules::
 17+
 18+* added getLineItem helper function
 19+* added special class "divider" that is non selectable menu item horizontal hr
1420 --------------------------------------------------------------------*/
1521
1622
@@ -173,11 +179,11 @@
174180 this.showMenu = function() {
175181 mw.log('$j.menu:: show menu' );
176182 killAllMenus();
177 - mw.log('done:: killAllMenus' );
 183+ mw.log('jquery.menu:: killAllMenus' );
178184 if ( ! menu.menuExists) {
179185 menu.create()
180186 };
181 - mw.log('done:: menu.create' );
 187+ mw.log('jquery.menu:: menu.create' );
182188 caller
183189 .addClass('fg-menu-open')
184190 .addClass(options.callerOnState);
@@ -185,7 +191,7 @@
186192 menu.kill();
187193 return false;
188194 });
189 - mw.log('done:: menu. binding container' );
 195+ mw.log('jquery.menu:: menu. binding container' );
190196
191197 container.hide().slideDown(options.showSpeed).find('.fg-menu:eq(0)');
192198 menu.menuOpen = true;
@@ -289,7 +295,7 @@
290296
291297 // aria roles & attributes
292298 container.find( 'ul' ).attr('role', 'menu').eq(0).attr('aria-activedescendant','active-menuitem').attr('aria-labelledby', caller.attr('id'));
293 - container.find( 'li' ).attr('role', 'menuitem');
 299+ container.find( 'li:not(.divider)' ).attr('role', 'menuitem');
294300 container.find( 'li:has(ul)' ).attr('aria-haspopup', 'true').find('ul').attr('aria-expanded', 'false');
295301 container.find( 'a' ).attr('tabindex', '-1');
296302

Status & tagging log