r63464 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63463‎ | r63464 | r63465 >
Date:12:04, 9 March 2010
Author:dale
Status:deferred
Tags:
Comment:
* fixed firefogg progress display info
* added return to form cb for iframe hosted upload dialogs
* initial import and updates to ajaxcategories for improved mwEmbed lib integration.
* updated mwEmbed gadget enable button to "multimedia beta"
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.Firefogg.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadForm.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadHandler.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadInterface.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AjaxCategories (added) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AjaxCategories/README (added) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AjaxCategories/loader.js (added) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AjaxCategories/mw.AjaxCategories.js (added) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/mw.ApiProxy.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/kplayerEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/mwEmbed.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadHandler.js
@@ -55,7 +55,10 @@
5656 'rewriteDescriptionText' : true,
5757
5858 // Callback which is called when the source name changes
59 - 'selectFileCb': false
 59+ 'selectFileCb': null,
 60+
 61+ // Callback called when an upload completes or is canceld and we want to re-activeate the form
 62+ 'returnToFormCb' : null
6063
6164 };
6265
@@ -139,7 +142,7 @@
140143 }
141144
142145 // Setup ui uploadHandler pointer
143 - this.ui.uploadHandler = this;
 146+ this.ui.uploadHandler = this;
144147
145148 mw.log( "init mvUploadHandler:: " + this.apiUrl + ' interface: ' + this.ui );
146149 },
@@ -473,7 +476,7 @@
474477
475478 var httpUpConf = {
476479 'url' : $j( '#wpUploadFileURL' ).val(),
477 - 'filename' : $j( '#wpDestFile' ).val(),
 480+ 'filename' : _this.getFilename(),
478481 'comment' : this.getUploadDescription(),
479482 'watch' : ( $j( '#wpWatchthis' ).is( ':checked' ) ) ? 'true' : 'false',
480483 'ignorewarnings': ($j('#wpIgnoreWarning' ).is( ':checked' ) ) ? 'true' : 'false'
@@ -787,11 +790,15 @@
788791 var request = {
789792 'action': 'upload',
790793 'sessionkey': _this.warnings_sessionkey,
791 - 'ignorewarnings': 1,
792 - 'filename': $j( '#wpDestFile' ).val(),
 794+ 'ignorewarnings': 1,
793795 'token' : _this.getToken(),
 796+ 'filename' : _this.getFileName()
 797+ };
 798+ // presently we don't let the user update desc at ignoreWarningsSubmit
 799+ /*
794800 'comment' : _this.getUploadDescription()
795 - };
 801+ */
 802+
796803 //run the upload from stash request
797804 mw.getJSON(_this.apiUrl, request, function( data ) {
798805 _this.processApiResult( data );
@@ -823,6 +830,10 @@
824831 return false;
825832 }
826833 },
 834+ // get the filename from the current form
 835+ getFileName: function() {
 836+ return $j( this.form ).find( "[name='filename']" ).val();
 837+ },
827838
828839 // Get the editToken from the page.
829840 getToken : function(){
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadInterface.js
@@ -16,6 +16,7 @@
1717 mw.addMessages( {
1818 "mwe-upload-in-progress" : "Upload in progress (do not close this window)",
1919 "mwe-uploaded-status" : "Uploaded",
 20+ "mwe-transcoded-status" : "Transcoded",
2021 "mwe-uploaded-time-remaining" : "Time remaining: $1",
2122 "mwe-upload-done" : "Your upload <i>should be<\/i> accessible."
2223 } );
@@ -117,11 +118,17 @@
118119 .text( '0% -' ),
119120
120121 $j( '<span />' )
121 - .attr( 'id', 'up-status-state' )
122 - .text( gM( 'mwe-uploaded-status' ) )
 122+ .attr( 'id', 'up-status-state' )
123123 )
124124 );
125125
 126+ var $statusState = $progressContainer.find( '#up-status-state' );
 127+ if( options.statusType == 'transcode' ){
 128+ $statusState.text( gM( 'mwe-transcoded-status' ) );
 129+ } else {
 130+ $statusState.text( gM( 'mwe-uploaded-status' ) );
 131+ }
 132+
126133 // Add the estimated time remaining
127134 $progressContainer.append(
128135 $j('<span />')
@@ -252,10 +259,8 @@
253260
254261 // Generate the error button
255262 var buttons = {};
256 - buttons[ gM( 'mwe-return-to-form' ) ] = function() {
257 - $j( this ).dialog( 'close' );
258 - // Disable direct submit so that we can handle updated form data
259 - _this.sendUploadAction( 'disableDirectSubmit' );
 263+ buttons[ gM( 'mwe-return-to-form' ) ] = function() {
 264+ _this.returnToForm( this );
260265 };
261266
262267
@@ -396,8 +401,7 @@
397402 };
398403 // Create the "return to form" button
399404 buttons[ gM( 'mwe-return-to-form' ) ] = function() {
400 - $j( this ).dialog( 'close' );
401 - _this.sendUploadAction( 'disableDirectSubmit' );
 405+ _this.returnToForm( this );
402406 }
403407 // Show warning
404408 _this.setPrompt(
@@ -416,6 +420,18 @@
417421 // No error!
418422 return true;
419423 },
 424+ /**
 425+ * return to the upload form handler
 426+ */
 427+ returnToForm: function( dialogElement ){
 428+ $j( dialogElement ).dialog( 'close' );
 429+
 430+ // Dissable direct submit on the transport ( so send via sendUploadAction )
 431+ this.sendUploadAction( 'disableDirectSubmit' );
 432+
 433+ // returnToFormCb
 434+ this.sendUploadAction( 'returnToFormCb' );
 435+ },
420436
421437 /**
422438 * Send an upload action to the upload handler.
@@ -438,6 +454,7 @@
439455 // "Return" button
440456 buttons[ gM( 'mwe-return-to-form' ) ] = function() {
441457 $j( this ).dialog( 'destroy' ).remove();
 458+ _this.sendUploadAction( 'returnToForm' );
442459 _this.sendUploadAction( 'disableDirectSubmit' );
443460 }
444461 // "Go to resource" button
@@ -473,7 +490,7 @@
474491 mw.log( 'f: getCancelButton()' );
475492 var cancelBtn = [];
476493 cancelBtn[ gM( 'mwe-cancel' ) ] = function() {
477 - $j( dlElm ).dialog( 'close' );
 494+ $j( this ).dialog( 'close' );
478495 };
479496 return cancelBtn;
480497 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.Firefogg.js
@@ -388,8 +388,7 @@
389389
390390 // Otherwise show the "install Firefogg" message
391391 var firefoggUrl = _this.getFirefoggInstallUrl();
392 - if( firefoggUrl ) {
393 -
 392+ if( firefoggUrl ) {
394393 // Add the target please install in not present:
395394 if ( !this.target_please_install ) {
396395 $j( this.selector ).after(
@@ -788,10 +787,13 @@
789788 return false;
790789 }
791790 // Setup the interface progress indicator:
792 - _this.ui.setup( { 'title' : gM( 'fogg-transcoding' ) } );
 791+ _this.ui.setup( {
 792+ 'title' : gM( 'fogg-transcoding' ),
 793+ 'statusType' : 'transcode'
 794+ } );
793795
794796 // Add the preview controls if transcoding:
795 - if ( !_this.getEncoderSettings()['passthrough'] ) {
 797+ if ( !_this.getEncoderSettings()[ 'passthrough' ] ) {
796798 _this.createPreviewControls();
797799 }
798800
@@ -948,13 +950,17 @@
949951 }
950952 // We are doing a firefogg upload:
951953 mw.log( "firefogg: doUpload:: " );
952 -
953 - // Setup the firefogg dialog (if not passthrough )
954 - _this.ui.setup( { 'title' : gM( 'mwe-upload-transcode-in-progress' ) } );
955 -
 954+
956955 // Add the preview controls if transcoding:
957956 if ( !_this.getEncoderSettings()['passthrough'] ) {
958957 _this.createPreviewControls();
 958+
 959+ // Setup the firefogg transcode dialog (if not passthrough )
 960+ _this.ui.setup( {
 961+ 'title' : gM( 'mwe-upload-transcode-in-progress' ),
 962+ 'statusType' : 'transcode'
 963+ } );
 964+
959965 }
960966
961967
@@ -1013,6 +1019,12 @@
10141020 function /* onDone */ () {
10151021 var uploadRequest = _this.getUploadApiRequest();
10161022
 1023+ // Update the UI for uploading
 1024+ _this.ui.setup( {
 1025+ 'title' : gM( 'mwe-upload-in-progress' ),
 1026+ 'statusType' : 'upload'
 1027+ } );
 1028+
10171029 mw.log( 'Do POST upload to:' +_this.apiUrl + ' with data:\n' + JSON.stringify( uploadRequest ) );
10181030
10191031 _this.fogg.post( _this.apiUrl, 'file', JSON.stringify( uploadRequest ) );
@@ -1125,10 +1137,7 @@
11261138 }
11271139
11281140 mw.log( 'doEncode: with: ' + JSON.stringify( encoderSettings ) );
1129 - _this.fogg.encode( JSON.stringify( encoderSettings ) );
1130 -
1131 - // Show transcode status:
1132 - $j( '#up-status-state' ).html( gM( 'mwe-upload-transcoded-status' ) );
 1141+ _this.fogg.encode( JSON.stringify( encoderSettings ) );
11331142
11341143
11351144 // Setup a local function for timed callback:
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadForm.js
@@ -192,6 +192,16 @@
193193 'warn_target' : "#wpDestFile-warning"
194194 } );
195195 },
 196+
 197+ 'returnToFormCb' : function(){
 198+ // Enable upload button and remove loader
 199+ $j( '#wpUploadBtn' )
 200+ .attr( 'disabled', null )
 201+ .parent()
 202+ .find( '.loading_spinner' )
 203+ .remove();
 204+ },
 205+
196206 'beforeSubmitCb' : function( ) {
197207 buildAssetDescription( options );
198208 }
@@ -266,7 +276,15 @@
267277 'warn_target': '#file-warning'
268278 } );
269279 },
270 -
 280+ 'returnToFormCb' : function(){
 281+ alert("UPLOAD form returnToFormCb ");
 282+ // Enable upload button and remove loader
 283+ $j( '#wpUploadBtn' )
 284+ .attr( 'disabled', null )
 285+ .parent()
 286+ .find( '.loading_spinner' )
 287+ .remove();
 288+ },
271289 // Timeout callback
272290 'timeoutCb' : function(){
273291 mw.log("timed out in setting up setupApiFileBrowseProxy");
@@ -291,21 +309,28 @@
292310 .attr( 'disabled', 'disabled' )
293311 .before(
294312 $j('<span />').loadingSpinner()
295 - );
 313+ );
296314
 315+ // Setup the form data:
 316+ var formData = {
 317+ 'filename' : $j( '#wpDestFile' ).val(),
 318+ 'comment' : $j( '#wpUploadDescription' ).val(),
 319+ }
297320
 321+ if( $j( '#wpWatchthis' ).is( ':checked' ) ) {
 322+ formData[ 'watch' ] = 'true';
 323+ }
 324+ if( $j('#wpIgnoreWarning' ).is( ':checked' ) ) {
 325+ formData[ 'ignorewarnings' ] = 'true';
 326+ }
 327+
298328 // Build the output and send upload request to fileProxy
299329 mw.ApiProxy.sendServerMsg( {
300330 'apiUrl' : options.apiUrl,
301331 'frameName' : fileIframeName,
302332 'frameMsg' : {
303333 'action' : 'fileSubmit',
304 - 'formData' : {
305 - 'filename' : $j('#wpDestFile').val(),
306 - 'comment' : $j('#wpUploadDescription').val(),
307 - 'watch' : ( $j( '#wpWatchthis' ).is( ':checked' ) ) ? 'true' : 'false',
308 - 'ignorewarnings': ($j('#wpIgnoreWarning' ).is( ':checked' ) ) ? 'true' : 'false'
309 - }
 334+ 'formData' : formData
310335 }
311336 } );
312337 } );
Index: branches/js2-work/phase3/js/mwEmbed/modules/AjaxCategories/loader.js
@@ -0,0 +1,5 @@
 2+
 3+// Add the class name define for AjaxCategories
 4+mw.addClassFilePaths( {
 5+ "mw.AjaxCategories" : "modules/AjaxCategories/mw.AjaxCategories.js"
 6+} );
\ No newline at end of file
Index: branches/js2-work/phase3/js/mwEmbed/modules/AjaxCategories/mw.AjaxCategories.js
@@ -0,0 +1,359 @@
 2+mw.addMessages( {
 3+ "ajax-add-category" : "[Add Category]",
 4+ "ajax-add-category-submit" : "[Add]",
 5+ "ajax-confirm-prompt" : "[Confirmation Text]",
 6+ "ajax-confirm-title" : "[Confirmation Title]",
 7+ "ajax-confirm-save" : "[Save]",
 8+ "ajax-add-category-summary" : "[Add category $1]",
 9+ "ajax-remove-category-summary" : "[Remove category $2]",
 10+ "ajax-confirm-actionsummary" : "[Summary]",
 11+ "ajax-error-title" : "Error",
 12+ "ajax-error-dismiss" : "OK",
 13+ "ajax-remove-category-error" : "[RemoveErr]"
 14+} );
 15+
 16+var defaultAjaxCategoriesOptions = {
 17+
 18+ // The edit mode can be api, or text box.
 19+ // When set to api, category changes are saved to the target article page
 20+ // when set to textbox category changes are outputed to a text box.
 21+ 'editMode' : 'api'
 22+
 23+}
 24+
 25+/**
 26+* AjaxCategories jQuery binder
 27+* lets you bind a ajaxCategories tool to a div
 28+*/
 29+( function( $ ) {
 30+ $.fn.AjaxCategories = function( options ) {
 31+ var hostElement = $j( this.selector ).get(0);
 32+ // Merge options with defaults and create new mw.AjaxCategories instance
 33+ hostElement.AjaxCategories = mw.AjaxCategories(
 34+ $j.extend( {},
 35+ defaultAjaxCategoriesOptions,
 36+ {'target' : this.selector},
 37+ options
 38+ )
 39+ );
 40+ }
 41+} )( jQuery );
 42+
 43+/**
 44+ * AjaxCategories constructor
 45+ */
 46+mw.AjaxCategories = function( options ){
 47+ this.setupAJAXCategories( options );
 48+}
 49+mw.AjaxCategories.prototype = {
 50+
 51+ setupAJAXCategories : function( options ) {
 52+
 53+ var clElement = $j( '.catlinks' );
 54+
 55+ // Unhide hidden category holders.
 56+ clElement.removeClass( 'catlinks-allhidden' );
 57+
 58+ var addLink = $j( '<a/>' );
 59+ addLink.addClass( 'mw-ajax-addcategory' );
 60+
 61+ // Create [Add Category] link
 62+ addLink.text( gM( 'ajax-add-category' ) );
 63+ addLink.attr( 'href', '#' );
 64+ addLink.click( ajaxCategories.handleAddLink );
 65+ clElement.append( addLink );
 66+
 67+ // Create add category prompt
 68+ var $promptContainer = $j( '<div />')
 69+ .attr( {
 70+ 'id' : "mw-addcategory-prompt"
 71+ } );
 72+
 73+ var $promptTextbox = $j( '<input />')
 74+ .attr( {
 75+ 'type' : "text",
 76+ 'size' : "45",
 77+ 'id' : "mw-addcategory-input"
 78+ } );
 79+
 80+ var $addButton = $j( '<input />')
 81+ .attr({
 82+ 'type' : "button",
 83+ 'id' : "mw-addcategory-button"
 84+ });
 85+ $addButton.val( gM( 'ajax-add-category-submit' ) );
 86+
 87+ $promptTextbox.keypress( ajaxCategories.handleCategoryInput );
 88+ $addButton.click( ajaxCategories.handleCategoryAdd );
 89+
 90+ $promptContainer.append( $promptTextbox );
 91+ $promptContainer.append( $addButton );
 92+ $promptContainer.hide();
 93+
 94+ // Create delete link for each category.
 95+ $j( '.catlinks div span a' ).each( function( e ) {
 96+ // Create a remove link
 97+ var deleteLink = $j( '<a class="mw-remove-category" href="#"/>' );
 98+
 99+ deleteLink.click( ajaxCategories.handleDeleteLink );
 100+
 101+ $j( this ).after( deleteLink );
 102+ } );
 103+
 104+ clElement.append( $promptContainer );
 105+ },
 106+
 107+ handleAddLink : function( e ) {
 108+
 109+ e.preventDefault();
 110+
 111+ // Make sure the suggestion plugin is loaded. Load everything else while we're at it
 112+ mw.load(
 113+ ['$j.ui', '$j.ui.dialog', '$j.fn.suggestions'],
 114+ function() {
 115+ $j( '#mw-addcategory-prompt' ).toggle();
 116+
 117+ $j( '#mw-addcategory-input' ).suggestions( {
 118+ 'fetch':ajaxCategories.fetchSuggestions,
 119+ 'cancel': function() {
 120+ // TODO support abort mechnism for mwEmbed
 121+ mw.log('Abort request');
 122+ }
 123+ } );
 124+ $j( '#mw-addcategory-input' ).suggestions();
 125+ }
 126+ );
 127+ },
 128+
 129+ fetchSuggestions : function( query ) {
 130+ var that = this;
 131+ var request = {
 132+ 'list': 'allpages',
 133+ 'apnamespace': 14,
 134+ 'apprefix': $j( this ).val()
 135+ };
 136+ mw.getJSON( request, function( data ) {
 137+ // Process data.query.allpages into an array of titles
 138+ var pages = data.query.allpages;
 139+ var titleArr = [];
 140+
 141+ $j.each( pages, function( i, page ) {
 142+ var title = page.title.split( ':', 2 )[1];
 143+ titleArr.push( title );
 144+ } );
 145+
 146+ $j( that ).suggestions( 'suggestions', titleArr );
 147+ } );
 148+
 149+ ajaxCategories.request = request;
 150+ },
 151+
 152+ reloadCategoryList : function( response ) {
 153+ var holder = $j( '<div/>' );
 154+
 155+ holder.load(
 156+ window.location.href + ' .catlinks',
 157+ function() {
 158+ $j( '.catlinks' ).replaceWith( holder.find( '.catlinks' ) );
 159+ ajaxCategories.setupAJAXCategories();
 160+ ajaxCategories.removeProgressIndicator( $j( '.catlinks' ) );
 161+ }
 162+ );
 163+ },
 164+
 165+ confirmEdit : function( page, fn, actionSummary, doneFn ) {
 166+ // Load jQuery UI
 167+ mw.load(
 168+ ['$j.ui', '$j.ui.dialog', '$j.fn.suggestions'],
 169+ function() {
 170+ // Produce a confirmation dialog
 171+
 172+ var dialog = $j( '<div/>' );
 173+
 174+ dialog.addClass( 'mw-ajax-confirm-dialog' );
 175+ dialog.attr( 'title', gM( 'ajax-confirm-title' ) );
 176+
 177+ // Intro text.
 178+ var confirmIntro = $j( '<p/>' );
 179+ confirmIntro.text( gM( 'ajax-confirm-prompt' ) );
 180+ dialog.append( confirmIntro );
 181+
 182+ // Summary of the action to be taken
 183+ var summaryHolder = $j( '<p/>' );
 184+ var summaryLabel = $j( '<strong/>' );
 185+ summaryLabel.text( gM( 'ajax-confirm-actionsummary' ) + " " );
 186+ summaryHolder.text( actionSummary );
 187+ summaryHolder.prepend( summaryLabel );
 188+ dialog.append( summaryHolder );
 189+
 190+ // Reason textbox.
 191+ var reasonBox = $j( '<input type="text" size="45" />' );
 192+ reasonBox.addClass( 'mw-ajax-confirm-reason' );
 193+ dialog.append( reasonBox );
 194+
 195+ // Submit button
 196+ var submitButton = $j( '<input type="button"/>' );
 197+ submitButton.val( gM( 'ajax-confirm-save' ) );
 198+
 199+ var submitFunction = function() {
 200+ dialog.loadingSpinner();
 201+ ajaxCategories.doEdit(
 202+ page,
 203+ fn,
 204+ reasonBox.val(),
 205+ function() {
 206+ doneFn();
 207+ dialog.dialog( 'close' );
 208+ ajaxCategories.removeProgressIndicator( dialog );
 209+ }
 210+ );
 211+ };
 212+
 213+ var buttons = { };
 214+ buttons[gM( 'ajax-confirm-save' )] = submitFunction;
 215+ var dialogOptions = {
 216+ 'AutoOpen' : true,
 217+ 'buttons' : buttons,
 218+ 'width' : 450
 219+ };
 220+
 221+ $j( '#catlinks' ).prepend( dialog );
 222+ dialog.dialog( dialogOptions );
 223+ }
 224+ );
 225+ },
 226+
 227+ doEdit : function( page, fn, summary, doneFn ) {
 228+ // Get an edit token and page revision info
 229+ var getTokenVars = {
 230+ 'prop':'info|revisions',
 231+ 'intoken':'edit',
 232+ 'titles':page,
 233+ 'rvprop':'content|timestamp'
 234+ };
 235+
 236+ mw.getJSON( getTokenVars, function( reply ) {
 237+ var infos = reply.query.pages;
 238+ $j.each(
 239+ infos,
 240+ function( pageid, data ) {
 241+ var token = data.edittoken;
 242+ var timestamp = data.revisions[0].timestamp;
 243+ var oldText = data.revisions[0]['*'];
 244+
 245+ var newText = fn( oldText );
 246+
 247+ if ( newText === false ) return;
 248+
 249+ var postEditVars = {
 250+ 'action':'edit',
 251+ 'title':page,
 252+ 'text':newText,
 253+ 'summary':summary,
 254+ 'token':token,
 255+ 'basetimestamp':timestamp,
 256+ 'format':'json'
 257+ };
 258+
 259+ $j.post( wgScriptPath + '/api.php', postEditVars, doneFn, 'json' );
 260+ }
 261+ );
 262+ } );
 263+ },
 264+
 265+ addProgressIndicator : function( elem ) {
 266+ var indicator = $j( '<div/>' );
 267+
 268+ indicator.addClass( 'mw-ajax-loader' );
 269+
 270+ elem.append( indicator );
 271+ },
 272+
 273+ removeProgressIndicator : function( elem ) {
 274+ elem.find( '.mw-ajax-loader' ).remove();
 275+ },
 276+
 277+ handleCategoryAdd : function( e ) {
 278+ // Grab category text
 279+ var category = $j( '#mw-addcategory-input' ).val();
 280+ var appendText = "\n[[" + wgFormattedNamespaces[14] + ":" + category + "]]\n";
 281+ var summary = gM( 'ajax-add-category-summary', category );
 282+
 283+ ajaxCategories.confirmEdit(
 284+ wgPageName,
 285+ function( oldText ) { return oldText + appendText },
 286+ summary,
 287+ ajaxCategories.reloadCategoryList
 288+ );
 289+ },
 290+
 291+ handleDeleteLink : function( e ) {
 292+ e.preventDefault();
 293+
 294+ var category = $j( this ).parent().find( 'a' ).text();
 295+
 296+ // Build a regex that matches legal invocations of that category.
 297+
 298+ // In theory I should escape the aliases, but there's no JS function for it
 299+ // Shouldn't have any real impact, can't be exploited or anything, so we'll
 300+ // leave it for now.
 301+ var categoryNSFragment = '';
 302+ $j.each( wgNamespaceIds, function( name, id ) {
 303+ if ( id == 14 ) {
 304+ // Allow the first character to be any case
 305+ var firstChar = name.charAt( 0 );
 306+ firstChar = '[' + firstChar.toUpperCase() + firstChar.toLowerCase() + ']';
 307+ categoryNSFragment += '|' + firstChar + name.substr( 1 );
 308+ }
 309+ } );
 310+ categoryNSFragment = categoryNSFragment.substr( 1 ); // Remove leading |
 311+
 312+ // Build the regex
 313+ var titleFragment = category;
 314+
 315+ firstChar = category.charAt( 0 );
 316+ firstChar = '[' + firstChar.toUpperCase() + firstChar.toLowerCase() + ']';
 317+ titleFragment = firstChar + category.substr( 1 );
 318+ var categoryRegex = '\\[\\[' + categoryNSFragment + ':' + titleFragment + '(\\|[^\\]]*)?\\]\\]';
 319+ categoryRegex = new RegExp( categoryRegex, 'g' );
 320+
 321+ var summary = gM( 'ajax-remove-category-summary', category );
 322+
 323+ ajaxCategories.confirmEdit(
 324+ wgPageName,
 325+ function( oldText ) {
 326+ var newText = oldText.replace( categoryRegex, '' );
 327+
 328+ if ( newText == oldText ) {
 329+ var error = gM( 'ajax-remove-category-error' );
 330+ ajaxCategories.showError( error );
 331+ ajaxCategories.removeProgressIndicator( $j( '.mw-ajax-confirm-dialog' ) );
 332+ $j( '.mw-ajax-confirm-dialog' ).dialog( 'close' );
 333+ return false;
 334+ }
 335+
 336+ return newText;
 337+ },
 338+ summary, ajaxCategories.reloadCategoryList
 339+ );
 340+ },
 341+
 342+ showError : function( str ) {
 343+ var dialog = $j( '<div/>' );
 344+ dialog.text( str );
 345+
 346+ $j( '#bodyContent' ).append( dialog );
 347+
 348+ var buttons = { };
 349+ buttons[gM( 'ajax-error-dismiss' )] = function( e ) {
 350+ dialog.dialog( 'close' );
 351+ };
 352+ var dialogOptions = {
 353+ 'buttons' : buttons,
 354+ 'AutoOpen' : true,
 355+ 'title' : gM( 'ajax-error-title' )
 356+ };
 357+
 358+ dialog.dialog( dialogOptions );
 359+ }
 360+};
Index: branches/js2-work/phase3/js/mwEmbed/modules/AjaxCategories/README
@@ -0,0 +1 @@
 2+Port of ajaxcategories to mwEmbed module
\ No newline at end of file
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/kplayerEmbed.js
@@ -82,6 +82,7 @@
8383
8484 //alert( this.playerElement );
8585 if( this.playerElement && this.playerElement.addJsListener ) {
 86+
8687 // Add KDP listeners
8788 _this.bindPlayerFunction( 'doPause', 'onPause' );
8889 _this.bindPlayerFunction( 'doPlay', 'onPlay' );
@@ -134,8 +135,9 @@
135136 * calls parent_play to update the interface
136137 */
137138 play: function() {
138 - if( this.playerElement && this.playerElement.sendNotification )
 139+ if( this.playerElement && this.playerElement.sendNotification ){
139140 this.playerElement.sendNotification( 'doPlay' );
 141+ }
140142 this.parent_play();
141143 },
142144
Index: branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/mw.ApiProxy.js
@@ -114,7 +114,18 @@
115115 var uploadDialogInterface = new mw.UploadDialogInterface( {
116116 'uploadHandlerAction' : function( action ){
117117 mw.log( 'apiProxy uploadActionHandler:: ' + action );
118 - // Send action to remote frame
 118+
 119+ // Handle actions that don't need to go to the iframe:
 120+ switch ( action ){
 121+ case 'returnToFormCb':
 122+ if( options.returnToFormCb ){
 123+ options.returnToFormCb();
 124+ }
 125+ return ;
 126+ break;
 127+ }
 128+
 129+ // Handle actions that get sent to the remote frame
119130 mw.ApiProxy.sendServerMsg( {
120131 'apiUrl' : options.apiUrl,
121132 'frameName' : iFrameName,
@@ -127,7 +138,7 @@
128139 } );
129140
130141 // Setup the context with the callback in the current closure
131 - var context = createContext({
 142+ var context = createContext( {
132143 'apiUrl' : options.apiUrl,
133144 // Setup the callback to process iframeData
134145 'callback' : function( iframeData ) {
@@ -143,14 +154,14 @@
144155 }
145156 mw.log( '~browseFile Callback~ event type: ' + iframeData['event'] );
146157
147 - // Else check for event
 158+ // Handle events:
148159 if( iframeData['event'] ) {
149160 switch( iframeData['event'] ) {
150161 case 'selectFileCb':
151162 if( options.selectFileCb ) {
152163 options.selectFileCb( iframeData[ 'fileName' ] );
153164 }
154 - break
 165+ break
155166 // Set the doneUploadCb if set in the browseFile options
156167 case 'doneUploadCb':
157168 mw.log( "should call cb: " + options.doneUploadCb );
@@ -312,11 +323,11 @@
313324 */
314325 $.handleServerMsg = function( frameMsg ){
315326 mw.log( "handleServerMsg:: " + JSON.stringify( frameMsg ) );
316 - if( ! frameMsg.action ){
 327+ if( ! frameMsg.action ) {
317328 mw.log(" missing frameMsg action " );
318329 return false;
319330 }
320 - switch( frameMsg.action ){
 331+ switch( frameMsg.action ) {
321332 case 'fileSubmit':
322333 serverSubmitFile( frameMsg.formData );
323334 break;
@@ -374,7 +385,7 @@
375386 * @return context object
376387 * false if context object can not be found
377388 */
378 - function getContext ( contextKey ){
 389+ function getContext ( contextKey ) {
379390 if( ! proxyContext [ contextKey ] ){
380391 mw.log( "Error: contextKey not found:: " + contextKey );
381392 return false;
@@ -416,8 +427,8 @@
417428 * @param {URL} apiUrl The url of the api server
418429 */
419430 // Include gadget js ( in case the user has not enabled the gadget on that domain )
420 - var gadgetWithJS = '?withJS=MediaWiki:MwEmbed.js';
421 - //var gadgetWithJS = '';
 431+ //var gadgetWithJS = '?withJS=MediaWiki:MwEmbed.js';
 432+ var gadgetWithJS = '';
422433 function getServerFrame( context ) {
423434 if( ! context || ! context.apiUrl ){
424435 mw.log( "Error no context api url " );
@@ -513,7 +524,7 @@
514525 // FIXME offer the user the ability to "approve" requested domain save to
515526 // their user preference setup )
516527
517 - // FIXME grab the users whitelist for our current domain
 528+ // FIXME grab and check domain against the users whitelist and permissions
518529 return false;
519530 }
520531
@@ -784,7 +795,12 @@
785796 'fileName' : fileName
786797 } );
787798 },
788 -
 799+ // The return to form cb:
 800+ 'returnToFormCb' : function (){
 801+ sendClientMsg( {
 802+ 'event': 'returnToFormCb'
 803+ } );
 804+ },
789805 // Api proxy does not handle descriptionText rewrite
790806 'rewriteDescriptionText' : false,
791807
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js
@@ -30,15 +30,12 @@
3131 }
3232
3333 /*
34 -* Set the mwEmbedVersion ( not set by stopgap )
 34+* Set the mwEmbedVersion
3535 */
36 -var MW_EMBED_VERSION = '1.1d';
 36+var MW_EMBED_VERSION = '1.1e';
3737
3838 /**
3939 * The global mw object:
40 -*
41 -* Any global functions/classes that are not jQuery plugins should make
42 -* there way into the mw namespace
4340 */
4441 ( function( mw ) {
4542
@@ -49,9 +46,7 @@
5047 mw.version = MW_EMBED_VERSION
5148
5249 /**
53 - * Configuration System:
54 - *
55 - * Simple system of inherit defaults, with getter setter functions:
 50+ * Configuration System:
5651 */
5752
5853 // Local scope configuration var:
@@ -577,12 +572,13 @@
578573 }
579574 node = node['p'];
580575 }
581 - if ( !node['t'] )
 576+ if ( !node['t'] ) {
582577 node['t'] = '';
 578+ }
583579 // Don't put }} closures into output:
584 - if ( txt[a] && txt[a] != '}' )
 580+ if ( txt[a] && txt[a] != '}' ) {
585581 node['t'] += txt[a];
586 -
 582+ }
587583 }
588584 return node;
589585 }
@@ -1380,6 +1376,7 @@
13811377 }
13821378 );
13831379 }
 1380+
13841381 /**
13851382 * mediaWiki JSON a wrapper for jQuery getJSON:
13861383 *
@@ -2831,8 +2828,8 @@
28322829 "mwe-load-drag-item" : "Loading dragged item",
28332830 "mwe-ok" : "OK",
28342831 "mwe-cancel" : "Cancel",
2835 - "mwe-enable-gadget" : "Enable mwEmbed gadget for all pages",
2836 - "mwe-enable-gadget-done" : "mwEmbed gadget has been enabled",
 2832+ "mwe-enable-gadget" : "Enable multimedia beta ( mwEmbed ) for all pages",
 2833+ "mwe-enable-gadget-done" : "multimedia beta gadget has been enabled",
28372834 "mwe-must-login-gadget" : "To enable gadget you must <a target=\"_new\" href=\"$1\">login</a>",
28382835 "mwe-test-plural" : "I ran {{PLURAL:$1|$1 test|$1 tests}}"
28392836 } );

Status & tagging log