r63352 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63351‎ | r63352 | r63353 >
Date:01:42, 7 March 2010
Author:dale
Status:deferred
Tags:
Comment:
* Improved cross domain uploading support in add-media-wizard
* updated language file
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/languages/mwEmbed.i18n.php (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/loader.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/loader.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.Firefogg.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.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/ApiProxy/mw.ApiProxy.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/ClipEdit/mw.ClipEdit.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/mwEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/remotes/mediaWiki.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/tests/testApiProxy.html (modified) (history)
  • /branches/js2-work/phase3/js/uploadPage.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/loader.js
@@ -89,7 +89,7 @@
9090
9191 // Default request timeout ( for cases where we inlucde js and normal browser timeout can't be used )
9292 // stored in seconds
93 - 'defaultRequestTimeout' : 25,
 93+ 'defaultRequestTimeout' : 10,
9494
9595 // Default user language is "en" Can be overwritten by:
9696 // "uselang" url param
Index: branches/js2-work/phase3/js/mwEmbed/tests/testApiProxy.html
@@ -80,54 +80,74 @@
8181 function doFileUpload(){
8282 $j('#file-upload-container').fadeIn( 'slow' );
8383 $j('#browseTarget').loadingSpinner();
 84+ // Load firefogg lib
 85+ mw.load('AddMedia.firefogg', function( ) {
 86+ // Load proxy lib
 87+ mw.load( 'ApiProxy', function( ) {
 88+ // Get a token for the upload:
 89+ mw.getToken( remote_apiUrl, 'File:MyRandomFileTokenCheck.jpg', function( eToken ) {
 90+ mw.log(" got token :: " + eToken);
 91+ // Add the token to the dom:
 92+ $j( '#file-name' ).append(
 93+ $j('<input />')
 94+ .attr({
 95+ 'type': 'hidden',
 96+ 'id' : 'wpEditToken',
 97+ 'name' : 'token'
 98+ })
 99+ .val( eToken )
 100+ );
 101+ var fileIframeName = mw.ApiProxy.browseFile( {
 102+ //Target div to put the iframe browser button:
 103+ 'target' : '#browseTarget',
84104
85 - mw.load('AddMedia.firefogg', function( ) {
86 - mw.load( 'ApiProxy', function( ) {
87 - var fileIframeName = mw.ApiProxy.browseFile( {
88 - //Target div to put the iframe browser button:
89 - 'target' : '#browseTarget',
 105+ // Set the token
 106+ 'token' : eToken,
 107+
 108+ // Api url to upload to
 109+ 'apiUrl' : remote_apiUrl,
 110+
 111+ // File Destination Name change callback:
 112+ 'selectFileCb' : function( fname ){
 113+ // Update our local target:
 114+ $j('#file-name').val( fname );
 115+ // Run a destination file name check on the remote target
 116+ $j('#file-name').doDestCheck( {
 117+ 'apiUrl' : remote_apiUrl,
 118+ 'warn_target': '#file-warning'
 119+ } );
 120+ },
 121+ 'doneUploadCb' : function( apiResult ){
 122+ alert(' upload done' );
 123+ }
 124+ } );
90125
91 - // Api url to upload to
92 - 'apiUrl' : remote_apiUrl,
 126+ //Setup submit binding:
 127+ $j('#uploadButton').click( function( ){
 128+ // Build the output and send upload request to fileProxy
 129+ mw.ApiProxy.sendServerMsg( {
 130+ 'apiUrl' : remote_apiUrl,
 131+ 'frameName' : fileIframeName,
 132+ 'frameMsg' : {
 133+ 'action' : 'fileSubmit',
 134+ 'formData' : {
 135+ 'filename' : $j('#file-name').val(),
 136+ 'comment' : $j('#file-desc').val()
 137+ }
 138+ }
 139+ } );
 140+ // Maybe set loading to spinner
 141+ } );
93142
94 - // File Destination Name change callback:
95 - 'selectFileCb' : function( fname ){
96 - // Update our local target:
97 - $j('#file-name').val( fname );
98 - // Run a destination file name check on the remote target
 143+
 144+ // Setup doDestCheck on change
 145+ $j('#file-name').change(function(){
99146 $j('#file-name').doDestCheck( {
100147 'apiUrl' : remote_apiUrl,
101148 'warn_target': '#file-warning'
102 - } );
103 - }
104 - } );
105 -
106 - //Setup submit binding:
107 - $j('#uploadButton').click(function(){
108 - // Build the output and send upload request to fileProxy
109 - mw.ApiProxy.sendServerMsg( {
110 - 'apiUrl' : remote_apiUrl,
111 - 'frameName' : fileIframeName,
112 - 'frameMsg' : {
113 - 'action' : 'fileSubmit',
114 - 'formData' : {
115 - 'filename' : $j('#file-name').val(),
116 - 'comment' : $j('#file-desc').val()
117 - }
118 - }
119 - } );
120 - // Maybe set loading to spinner
121 - } );
122 -
123 -
124 - // Setup doDestCheck on change
125 - $j('#file-name').change(function(){
126 - $j('#file-name').doDestCheck( {
127 - 'apiUrl' : remote_apiUrl,
128 - 'warn_target': '#file-warning'
129 - } );
 149+ } );
 150+ });
130151 });
131 -
132152 })
133153 });
134154 };
Index: branches/js2-work/phase3/js/mwEmbed/languages/mwEmbed.i18n.php
@@ -12,22 +12,67 @@
1313
1414 $messages['en'] = array(
1515 /*
16 - * js file: /skins/kskin/kskinConfig.js
 16+ * js file: /modules/EmbedPlayer/mw.EmbedPlayer.js
1717 */
18 - 'mwe-credit-title' => 'Title: $1',
 18+ 'mwe-loading_plugin' => 'loading plugin ...',
 19+ 'mwe-select_playback' => 'Set playback preference',
 20+ 'mwe-link_back' => 'Link back',
 21+ 'mwe-error_swap_vid' => 'Error: mwEmbed was unable to swap the video tag for the mwEmbed interface',
 22+ 'mwe-add_to_end_of_sequence' => 'Add to end of sequence',
 23+ 'mwe-missing_video_stream' => 'The video file for this stream is missing',
 24+ 'mwe-play_clip' => 'Play clip',
 25+ 'mwe-pause_clip' => 'Pause clip',
 26+ 'mwe-volume_control' => 'Volume control',
 27+ 'mwe-player_options' => 'Player options',
 28+ 'mwe-timed_text' => 'Timed text',
 29+ 'mwe-player_fullscreen' => 'Fullscreen',
 30+ 'mwe-next_clip_msg' => 'Play next clip',
 31+ 'mwe-prev_clip_msg' => 'Play previous clip',
 32+ 'mwe-current_clip_msg' => 'Continue playing this clip',
 33+ 'mwe-seek_to' => 'Seek $1',
 34+ 'mwe-paused' => 'paused',
 35+ 'mwe-download_segment' => 'Download selection:',
 36+ 'mwe-download_full' => 'Download full video file:',
 37+ 'mwe-download_right_click' => 'To download, right click and select <i>Save link as...</i>',
 38+ 'mwe-download_clip' => 'Download video',
 39+ 'mwe-download_text' => 'Download text (<a style="color:white" title="cmml" href="http://wiki.xiph.org/index.php/CMML">CMML</a> xml):',
 40+ 'mwe-download' => 'Download',
 41+ 'mwe-share' => 'Share',
 42+ 'mwe-credits' => 'Credits',
 43+ 'mwe-clip_linkback' => 'Clip source page',
 44+ 'mwe-chose_player' => 'Choose video player',
 45+ 'mwe-no-player' => 'No player available for $1',
 46+ 'mwe-share_this_video' => 'Share this video',
 47+ 'mwe-video_credits' => 'Video credits',
 48+ 'mwe-kaltura-platform-title' => 'Kaltura open source video platform',
 49+ 'mwe-menu_btn' => 'Menu',
 50+ 'mwe-close_btn' => 'Close',
 51+ 'mwe-ogg-player-vlc-player' => 'VLC player',
 52+ 'mwe-ogg-player-oggNative' => 'HTML5 ogg player',
 53+ 'mwe-ogg-player-h264Native' => 'HTML5 h.264 player',
 54+ 'mwe-ogg-player-oggPlugin' => 'Generic Ogg plugin',
 55+ 'mwe-ogg-player-quicktime-mozilla' => 'QuickTime plugin',
 56+ 'mwe-ogg-player-quicktime-activex' => 'QuickTime ActiveX',
 57+ 'mwe-ogg-player-cortado' => 'Java Cortado',
 58+ 'mwe-ogg-player-flowplayer' => 'Flowplayer',
 59+ 'mwe-ogg-player-kplayer' => 'Kaltura player',
 60+ 'mwe-ogg-player-selected' => '(selected)',
 61+ 'mwe-ogg-player-omtkplayer' => 'OMTK Flash Vorbis',
 62+ 'mwe-generic_missing_plugin' => 'You browser does not appear to support the following playback type: <b>$1</b><br />Visit the <a href="http://commons.wikimedia.org/wiki/Commons:Media_help">Playback Methods</a> page to download a player.<br />',
 63+ 'mwe-for_best_experience' => 'For a better video playback experience we recommend the <b><a href="http://www.mozilla.com/en-US/firefox/upgrade.html?from=mwEmbed">latest firefox</a>.</b>',
 64+ 'mwe-do_not_warn_again' => 'Dismiss for now.',
 65+ 'mwe-playerSelect' => 'Players',
 66+ 'mwe-read_before_embed' => '<a href="http://mediawiki.org/wiki/Security_Notes_on_Remote_Embedding" target="_new">Read this</a> before embedding.',
 67+ 'mwe-embed_site_or_blog' => 'Embed on a page',
 68+ 'mwe-related_videos' => 'Related videos',
 69+ 'mwe-seeking' => 'seeking',
 70+ 'mwe-copy-code' => 'Copy code',
 71+ 'mwe-video-h264' => 'H.264 video',
 72+ 'mwe-video-flv' => 'Flash video',
 73+ 'mwe-video-ogg' => 'Ogg video',
 74+ 'mwe-video-audio' => 'Ogg audio',
1975
2076 /*
21 - * js file: /modules/Sequencer/mw.TimedEffectsEdit.js
22 - */
23 - 'mwe-transition_in' => 'Transition in',
24 - 'mwe-transition_out' => 'Transition out',
25 - 'mwe-effects' => 'Effects stack',
26 - 'mwe-remove_transition' => 'Remove transition',
27 - 'mwe-edit_transin' => 'Edit transition into clip',
28 - 'mwe-edit_transout' => 'Edit transition out of clip',
29 - 'mwe-add-transition' => 'Add a transition',
30 -
31 - /*
3277 * js file: /modules/Sequencer/mw.Sequencer.js
3378 */
3479 'mwe-menu_clipedit' => 'Edit media',
@@ -66,12 +111,66 @@
67112 'mwe-sequencer_credit_line' => 'Developed by <a href="http://kaltura.com">Kaltura, Inc.</a> in partnership with the <a href="http://wikimediafoundation.org/wiki/Home">Wikimedia Foundation</a> (<a href="#">more information</a>).',
68113
69114 /*
 115+ * js file: /modules/Sequencer/mw.TimedEffectsEdit.js
 116+ */
 117+ 'mwe-transition_in' => 'Transition in',
 118+ 'mwe-transition_out' => 'Transition out',
 119+ 'mwe-effects' => 'Effects stack',
 120+ 'mwe-remove_transition' => 'Remove transition',
 121+ 'mwe-edit_transin' => 'Edit transition into clip',
 122+ 'mwe-edit_transout' => 'Edit transition out of clip',
 123+ 'mwe-add-transition' => 'Add a transition',
 124+
 125+ /*
70126 * js file: /modules/Sequencer/remotes/RemoteMwSequencer.js
71127 */
72128 'mwe-no-sequence-create' => 'No sequence exists named $1, You can $2',
73129 'mwe-sequence-create-one' => 'start a sequence',
74130
75131 /*
 132+ * js file: /modules/ClipEdit/mw.ClipEdit.js
 133+ */
 134+ 'mwe-crop' => 'Crop image',
 135+ 'mwe-apply_crop' => 'Apply crop to image',
 136+ 'mwe-reset_crop' => 'Reset crop',
 137+ 'mwe-insert_image_page' => 'Insert into page',
 138+ 'mwe-insert_into_sequence' => 'Insert into sequence',
 139+ 'mwe-preview_insert' => 'Preview insert',
 140+ 'mwe-cancel_image_insert' => 'Cancel insert',
 141+ 'mwe-sc_attributes' => 'Clip detail edit',
 142+ 'mwe-sc_inoutpoints' => 'Set in-out points',
 143+ 'mwe-sc_overlays' => 'Overlays',
 144+ 'mwe-sc_audio' => 'Audio control',
 145+ 'mwe-sc_duration' => 'Duration',
 146+ 'mwe-template_properties' => 'Template properties',
 147+ 'mwe-custom_title' => 'Custom title',
 148+ 'mwe-edit_properties' => 'Edit properties',
 149+ 'mwe-other_properties' => 'Other properties',
 150+ 'mwe-resource_page' => 'Resource page:',
 151+ 'mwe-set_in_out_points' => 'Set in-out points',
 152+ 'mwe-start_time' => 'Start time',
 153+ 'mwe-end_time' => 'End time',
 154+ 'mwe-preview_inout' => 'Preview in-out points',
 155+ 'mwe-edit-tools' => 'Edit tools',
 156+ 'mwe-inline-description' => 'Caption',
 157+ 'mwe-edit-video-tools' => 'Edit video tools:',
 158+ 'mwe-duration' => 'Duration:',
 159+ 'mwe-layout' => 'Layout',
 160+ 'mwe-layout_right' => 'Right side image layout',
 161+ 'mwe-layout_left' => 'Left side image layout',
 162+
 163+ /*
 164+ * js file: /modules/ApiProxy/mw.ApiProxy.js
 165+ */
 166+ 'mwe-setting-up-proxy' => 'Setting up proxy...',
 167+ 'mwe-re-try' => 'Retry API request',
 168+ 'mwe-re-trying' => 'Retrying API request...',
 169+ 'mwe-proxy-not-ready' => 'Proxy is not configured',
 170+ 'mwe-please-login' => 'The request failed. Are you logged in on $1 ? Please $2 and try again',
 171+ 'mwe-log-in-link' => 'log in',
 172+ 'mwe-remember-loging' => 'General security reminder: Only login to web sites when your address bar displays that site\'s address.',
 173+
 174+ /*
76175 * js file: /modules/TimedText/mw.TimedTextEdit.js
77176 */
78177 'mew-timedtext-editor' => 'Timed text editor',
@@ -130,211 +229,6 @@
131230 'mwe-language-no-subtitles-for-clip' => 'No $1 subtitles where found for clip: $2',
132231
133232 /*
134 - * js file: /modules/EmbedPlayer/mw.EmbedPlayer.js
135 - */
136 - 'mwe-loading_plugin' => 'loading plugin ...',
137 - 'mwe-select_playback' => 'Set playback preference',
138 - 'mwe-link_back' => 'Link back',
139 - 'mwe-error_swap_vid' => 'Error: mwEmbed was unable to swap the video tag for the mwEmbed interface',
140 - 'mwe-add_to_end_of_sequence' => 'Add to end of sequence',
141 - 'mwe-missing_video_stream' => 'The video file for this stream is missing',
142 - 'mwe-play_clip' => 'Play clip',
143 - 'mwe-pause_clip' => 'Pause clip',
144 - 'mwe-volume_control' => 'Volume control',
145 - 'mwe-player_options' => 'Player options',
146 - 'mwe-timed_text' => 'Timed text',
147 - 'mwe-player_fullscreen' => 'Fullscreen',
148 - 'mwe-next_clip_msg' => 'Play next clip',
149 - 'mwe-prev_clip_msg' => 'Play previous clip',
150 - 'mwe-current_clip_msg' => 'Continue playing this clip',
151 - 'mwe-seek_to' => 'Seek $1',
152 - 'mwe-paused' => 'paused',
153 - 'mwe-download_segment' => 'Download selection:',
154 - 'mwe-download_full' => 'Download full video file:',
155 - 'mwe-download_right_click' => 'To download, right click and select <i>Save link as...</i>',
156 - 'mwe-download_clip' => 'Download video',
157 - 'mwe-download_text' => 'Download text (<a style="color:white" title="cmml" href="http://wiki.xiph.org/index.php/CMML">CMML</a> xml):',
158 - 'mwe-download' => 'Download',
159 - 'mwe-share' => 'Share',
160 - 'mwe-credits' => 'Credits',
161 - 'mwe-clip_linkback' => 'Clip source page',
162 - 'mwe-chose_player' => 'Choose video player',
163 - 'mwe-no-player' => 'No player available for $1',
164 - 'mwe-share_this_video' => 'Share this video',
165 - 'mwe-video_credits' => 'Video credits',
166 - 'mwe-kaltura-platform-title' => 'Kaltura open source video platform',
167 - 'mwe-menu_btn' => 'Menu',
168 - 'mwe-close_btn' => 'Close',
169 - 'mwe-ogg-player-vlc-player' => 'VLC player',
170 - 'mwe-ogg-player-oggNative' => 'HTML5 ogg player',
171 - 'mwe-ogg-player-h264Native' => 'HTML5 h.264 player',
172 - 'mwe-ogg-player-oggPlugin' => 'Generic Ogg plugin',
173 - 'mwe-ogg-player-quicktime-mozilla' => 'QuickTime plugin',
174 - 'mwe-ogg-player-quicktime-activex' => 'QuickTime ActiveX',
175 - 'mwe-ogg-player-cortado' => 'Java Cortado',
176 - 'mwe-ogg-player-flowplayer' => 'Flowplayer',
177 - 'mwe-ogg-player-kplayer' => 'Kaltura player',
178 - 'mwe-ogg-player-selected' => '(selected)',
179 - 'mwe-ogg-player-omtkplayer' => 'OMTK Flash Vorbis',
180 - 'mwe-generic_missing_plugin' => 'You browser does not appear to support the following playback type: <b>$1</b><br />Visit the <a href="http://commons.wikimedia.org/wiki/Commons:Media_help">Playback Methods</a> page to download a player.<br />',
181 - 'mwe-for_best_experience' => 'For a better video playback experience we recommend the <b><a href="http://www.mozilla.com/en-US/firefox/upgrade.html?from=mwEmbed">latest firefox</a>.</b>',
182 - 'mwe-do_not_warn_again' => 'Dismiss for now.',
183 - 'mwe-playerSelect' => 'Players',
184 - 'mwe-read_before_embed' => '<a href="http://mediawiki.org/wiki/Security_Notes_on_Remote_Embedding" target="_new">Read this</a> before embedding.',
185 - 'mwe-embed_site_or_blog' => 'Embed on a page',
186 - 'mwe-related_videos' => 'Related videos',
187 - 'mwe-seeking' => 'seeking',
188 - 'mwe-copy-code' => 'Copy code',
189 - 'mwe-video-h264' => 'H.264 video',
190 - 'mwe-video-flv' => 'Flash video',
191 - 'mwe-video-ogg' => 'Ogg video',
192 - 'mwe-video-audio' => 'Ogg audio',
193 -
194 - /*
195 - * js file: /modules/AddMedia/mw.UploadHandler.js
196 - */
197 - 'mwe-upload-transcoded-status' => 'Transcoded',
198 - 'mwe-upload-stats-fileprogress' => '$1 of $2',
199 - 'mwe-upload_completed' => 'Your upload is complete',
200 - 'mwe-upload_done' => '<a href="$1">Your upload <i>should be</i> accessible</a>.',
201 - 'mwe-upload-unknown-size' => 'Unknown size',
202 - 'mwe-cancel-confim' => 'Are you sure you want to cancel?',
203 - 'mwe-successfulupload' => 'Upload successful',
204 - 'mwe-uploaderror' => 'Upload error',
205 - 'mwe-uploadwarning' => 'Upload warning',
206 - 'mwe-unknown-error' => 'Unknown error:',
207 - 'mwe-return-to-form' => 'Return to form',
208 - 'mwe-file-exists-duplicate' => 'This file is a duplicate of the following file:',
209 - 'mwe-fileexists' => 'A file with this name exists already. Please check <b><tt>$1</tt></b> if you are not sure if you want to change it.',
210 - 'mwe-fileexists-thumb' => '<center><b>Existing file</b></center>',
211 - 'mwe-ignorewarning' => 'Ignore warning and save file anyway',
212 - 'mwe-file-thumbnail-no' => 'The filename begins with <b><tt>$1</tt></b>',
213 - 'mwe-go-to-resource' => 'Go to resource page',
214 - 'mwe-upload-misc-error' => 'Unknown upload error',
215 - 'mwe-wgfogg_warning_bad_extension' => 'You have selected a file with an unsuported extension (<a href="http://commons.wikimedia.org/wiki/Commons:Firefogg#Supported_File_Types">more information</a>).',
216 - 'thumbnail-more' => 'Enlarge',
217 - 'license-header' => 'Licensing',
218 - 'filedesc' => 'Summary',
219 - 'filesource' => 'Source:',
220 - 'filestatus' => 'Copyright status:',
221 -
222 - /*
223 - * js file: /modules/AddMedia/loader.js
224 - */
225 - 'mwe-loading-add-media-wiz' => 'Loading add media wizard',
226 -
227 - /*
228 - * js file: /modules/AddMedia/mw.FirefoggGUI.js
229 - */
230 - 'fogg-save_local_file' => 'Save Ogg',
231 - 'fogg-help-sticky' => 'Help (click to stick)',
232 - 'fogg-cg-preset' => 'Preset: <strong>$1</strong>',
233 - 'fogg-cg-quality' => 'Basic quality and resolution control',
234 - 'fogg-cg-meta' => 'Metadata for the clip',
235 - 'fogg-cg-range' => 'Encoding range',
236 - 'fogg-cg-advVideo' => 'Advanced video encoding controls',
237 - 'fogg-cg-advAudio' => 'Advanced audio encoding controls',
238 - 'fogg-preset-custom' => 'Custom settings',
239 - 'fogg-webvideo-desc' => 'Web video Theora, Vorbis 400 kbit/s and 400px maximum width',
240 - 'fogg-savebandwidth-desc' => 'Low bandwidth Theora, Vorbis 164 kbit/s and 200px maximum width',
241 - 'fogg-highquality-desc' => 'High quality Theora, Vorbis 1080px maximum width',
242 - 'fogg-videoQuality-title' => 'Video quality',
243 - 'fogg-videoQuality-help' => 'Used to set the <i>visual quality</i> of the encoded video (not used if you set bitrate in advanced controls below).',
244 - 'fogg-starttime-title' => 'Start second',
245 - 'fogg-starttime-help' => 'Only encode from time in seconds',
246 - 'fogg-endtime-title' => 'End second',
247 - 'fogg-endtime-help' => 'Only encode to time in seconds',
248 - 'fogg-audioQuality-title' => 'Audio quality',
249 - 'fogg-audioQuality-help' => 'Used to set the <i>acoustic quality</i> of the encoded audio (not used if you set bitrate in advanced controls below).',
250 - 'fogg-videoCodec-title' => 'Video codec',
251 - 'fogg-videoCodec-help' => 'Used to select the clip video codec. Presently only Theora is supported. More about the <a target="_new" href="http://en.wikipedia.org/wiki/Theora">Theora codec</a>.',
252 - 'fogg-audioCodec-title' => 'Audio codec',
253 - 'fogg-audioCodec-help' => 'Used to set the clip audio codec. Presently only Vorbis is supported. More about the <a target="_new" href="http://en.wikipedia.org/wiki/Vorbis">Vorbis codec</a>',
254 - 'fogg-width-title' => 'Video width',
255 - 'fogg-width-help' => 'Resize to given width.',
256 - 'fogg-height-title' => 'Video height',
257 - 'fogg-height-help' => 'Resize to given height.',
258 - 'fogg-videoBitrate-title' => 'Video bitrate',
259 - 'fogg-videoBitrate-help' => 'Video bitrate sets the encoding bitrate for video in (kb/s)',
260 - 'fogg-twopass-title' => 'Two pass encoding',
261 - 'fogg-twopass-help' => 'Two pass encoding enables more constant quality by making two passes over the video file',
262 - 'fogg-framerate-title' => 'Frame rate',
263 - 'fogg-framerate-help' => 'The video frame rate. More about <a target="_new" href="http://en.wikipedia.org/wiki/Frame_rate">frame rate</a>.',
264 - 'fogg-aspect-title' => 'Aspect ratio',
265 - 'fogg-aspect-help' => 'The video aspect ratio can be 4:3 or 16:9. More about <a target="_new" href="http://en.wikipedia.org/wiki/Aspect_ratio_%28image%29">aspect ratios</a>.',
266 - 'fogg-keyframeInterval-title' => 'Key frame interval',
267 - 'fogg-keyframeInterval-help' => 'The keyframe interval in frames. Note: Most codecs force keyframes if the difference between frames is greater than keyframe encode size. More about <a href="http://en.wikipedia.org/wiki/I-frame">keyframes</a>.',
268 - 'fogg-denoise-title' => 'Denoise filter',
269 - 'fogg-denoise-help' => 'Denoise input video. More about <a href="http://en.wikipedia.org/wiki/Video_denoising">denoise</a>.',
270 - 'fogg-novideo-title' => 'No video',
271 - 'fogg-novideo-help' => 'disable video in the output',
272 - 'fogg-audioBitrate-title' => 'Audio bitrate',
273 - 'fogg-samplerate-title' => 'Audio sampling rate',
274 - 'fogg-samplerate-help' => 'set output sample rate (in Hz).',
275 - 'fogg-noaudio-title' => 'No audio',
276 - 'fogg-noaudio-help' => 'disable audio in the output',
277 - 'fogg-title-title' => 'Title',
278 - 'fogg-title-help' => 'A title for your clip',
279 - 'fogg-artist-title' => 'Creator name',
280 - 'fogg-artist-help' => 'The creator of this clip',
281 - 'fogg-date-title' => 'Date',
282 - 'fogg-date-help' => 'The date the footage was created or released',
283 - 'fogg-location-title' => 'Location',
284 - 'fogg-location-help' => 'The location of the footage',
285 - 'fogg-organization-title' => 'Organization',
286 - 'fogg-organization-help' => 'Name of organization (studio)',
287 - 'fogg-copyright-title' => 'Copyright',
288 - 'fogg-copyright-help' => 'The copyright of the clip',
289 - 'fogg-license-title' => 'License',
290 - 'fogg-license-help' => 'The license of the clip (preferably a Creative Commons URL).',
291 - 'fogg-contact-title' => 'Contact',
292 - 'fogg-contact-help' => 'Contact link',
293 -
294 - /*
295 - * js file: /modules/AddMedia/searchLibs/metavidSearch.js
296 - */
297 - 'mwe-stream_title' => '$1 $2 to $3',
298 -
299 - /*
300 - * js file: /modules/AddMedia/searchLibs/kalturaSearch.js
301 - */
302 - 'rsd-media-filter-title' => 'Media',
303 - 'rsd-media-filter-videos' => 'Videos',
304 - 'rsd-media-filter-images' => 'Images',
305 - 'rsd-provider-filter-title' => 'Providers',
306 -
307 - /*
308 - * js file: /modules/AddMedia/searchLibs/baseRemoteSearch.js
309 - */
310 - 'mwe-imported_from' => '$1 imported from [$2 $3]. See the original [$4 resource page] for more information.',
311 - 'mwe-import-description' => '$1, imported from $2',
312 -
313 - /*
314 - * js file: /modules/AddMedia/mw.UploadForm.js
315 - */
316 - 'mwe-select_file' => 'Select file',
317 - 'mwe-select_ownwork' => 'I am uploading entirely my own work, and licensing it under:',
318 - 'mwe-license_cc-by-sa' => 'Creative Commons Share Alike (3.0)',
319 - 'mwe-upload' => 'Upload file',
320 - 'mwe-destfilename' => 'Destination filename:',
321 - 'mwe-summary' => 'Summary',
322 - 'mwe-error_not_loggedin' => 'You do not appear to be logged in or do not have upload privileges.',
323 - 'mwe-watch-this-file' => 'Watch this file',
324 - 'mwe-ignore-any-warnings' => 'Ignore any warnings',
325 - 'mwe-i-would-like-to' => 'I would like to',
326 - 'mwe-upload-own-file' => 'Upload my own work to $1',
327 - 'mwe-upload-not-my-file' => 'Upload media that is not my own work to $1',
328 - 'mwe-upload-once-done' => 'Please upload in the new window or tab. Once you have completed your upload, $1',
329 - 'mwe-upload-refresh' => 'refresh your upload list',
330 -
331 - /*
332 - * js file: /modules/AddMedia/mw.UploadInterface.js
333 - */
334 - 'mwe-upload-in-progress' => 'Upload in progress (do not close this window)',
335 - 'mwe-uploaded-status' => 'Uploaded',
336 - 'mwe-uploaded-time-remaining' => 'Time remaining: $1',
337 -
338 - /*
339233 * js file: /modules/AddMedia/mw.RemoteSearchDriver.js
340234 */
341235 'mwe-add_media_wizard' => 'Add media wizard',
@@ -362,14 +256,15 @@
363257 'mwe-no-import-by-url' => 'This user or wiki <b>cannot</b> import assets from remote URLs.<p>Do you need to login?</p><p>Is upload_by_url permission set for you?<br />Does the wiki have $1 enabled?</p>',
364258 'mwe-no-import-by-url-linktext' => '$wgAllowCopyUploads',
365259 'mwe-results_from' => 'Results from $1',
366 - 'mwe-missing_desc_see_source' => 'This asset is missing a description. Please see the [$1 original source] and help describe it.',
 260+ 'mwe-missing_desc_see_source' => 'This asset is missing a description. Please see the $1 and help describe it.',
367261 'rsd_config_error' => 'Add media wizard configuration error: $1',
368 - 'mwe-your_recent_uploads' => 'Your recent uploads to $1',
 262+ 'mwe-your-recent-uploads' => 'Your recent uploads to $1',
369263 'mwe-no_recent_uploads' => 'No recent uploads',
370264 'mwe-not-logged-in-uploads' => 'You may not be logged in so no recent uploads can be displayed. $1 login and $2',
371265 'mwe-loggin-link' => 'Please login',
372266 'mwe-try-again-link' => 'try again',
373 - 'mwe-upload_a_file' => 'Upload a new file',
 267+ 'mwe-upload-a-file' => 'Upload a new file',
 268+ 'mwe-upload-a-file-to' => 'Upload a new file to $1',
374269 'mwe-resource_page_desc' => 'Resource page description:',
375270 'mwe-edit_resource_desc' => 'Edit wiki text resource description:',
376271 'mwe-local_resource_title' => 'Local resource title:',
@@ -405,8 +300,34 @@
406301 'rsd-search-timeout' => 'The search request did not complete. The server may be down experiencing heavy load. You can try again later',
407302
408303 /*
 304+ * js file: /modules/AddMedia/mw.UploadHandler.js
 305+ */
 306+ 'mwe-upload-stats-fileprogress' => '$1 of $2',
 307+ 'mwe-upload-unknown-size' => 'Unknown size',
 308+ 'mwe-cancel-confim' => 'Are you sure you want to cancel?',
 309+ 'mwe-successfulupload' => 'Upload successful',
 310+ 'mwe-uploaderror' => 'Upload error',
 311+ 'mwe-uploadwarning' => 'Upload warning',
 312+ 'mwe-unknown-error' => 'Unknown error:',
 313+ 'mwe-return-to-form' => 'Return to form',
 314+ 'mwe-file-exists-duplicate' => 'This file is a duplicate of the following file:',
 315+ 'mwe-fileexists' => 'A file with this name exists already. Please check <b><tt>$1</tt></b> if you are not sure if you want to change it.',
 316+ 'mwe-fileexists-thumb' => 'Existing file',
 317+ 'mwe-ignorewarning' => 'Ignore warning and save file anyway',
 318+ 'mwe-file-thumbnail-no' => 'The filename begins with <b><tt>$1</tt></b>',
 319+ 'mwe-go-to-resource' => 'Go to resource page',
 320+ 'mwe-upload-misc-error' => 'Unknown upload error',
 321+ 'mwe-wgfogg_warning_bad_extension' => 'You have selected a file with an unsuported extension (<a href="http://commons.wikimedia.org/wiki/Commons:Firefogg#Supported_File_Types">more information</a>).',
 322+ 'thumbnail-more' => 'Enlarge',
 323+ 'license-header' => 'Licensing',
 324+ 'filedesc' => 'Summary',
 325+ 'filesource' => 'Source:',
 326+ 'filestatus' => 'Copyright status:',
 327+
 328+ /*
409329 * js file: /modules/AddMedia/mw.Firefogg.js
410330 */
 331+ 'mwe-upload-transcoded-status' => 'Transcoded',
411332 'mwe-upload-transcode-in-progress' => 'Transcode and upload in progress (do not close this window)',
412333 'fogg-transcoding' => 'Encoding video to ogg',
413334 'fogg-select_file' => 'Select file',
@@ -414,12 +335,13 @@
415336 'fogg-select_url' => 'Select URL',
416337 'fogg-check_for_firefogg' => 'Checking for Firefogg...',
417338 'fogg-installed' => 'Firefogg is installed,',
418 - 'fogg-not-installed' => 'Firefogg is not installed',
 339+ 'fogg-not-installed' => 'Firefogg is not installed or not enabled.',
419340 'fogg-for_improved_uploads' => 'For improved uploads:',
420341 'fogg-please-install' => '$1. More $2',
421342 'fogg-please-install-install-linktext' => 'Install firefogg',
422343 'fogg-please-install-about-linktext' => 'about firefogg',
423 - 'fogg-use_latest_firefox' => 'Please first install <a href="http://www.mozilla.com/en-US/firefox/upgrade.html?from=firefogg">Firefox 3.5</a> (or later). <i>Then revisit this page to install the <b>Firefogg</b> extension.</i>',
 344+ 'fogg-use_latest_firefox' => 'Please first install $1. <i>Then revisit this page to install the <b>Firefogg</b> extension.</i>',
 345+ 'fogg-latest-firefox' => 'latest firefox',
424346 'fogg-passthrough_mode' => 'Your selected file is already ogg or not a video file',
425347 'fogg-encoding-done' => 'Encoding complete',
426348 'fogg-badtoken' => 'Token is not valid',
@@ -428,55 +350,124 @@
429351 'fogg-warning-firebug' => '<b>Firebug</b> can cause conflicts with <i>Firefogg</i>. Please disable <b>Firebug</b> for this page.',
430352
431353 /*
 354+ * js file: /modules/AddMedia/searchLibs/metavidSearch.js
 355+ */
 356+ 'mwe-stream_title' => '$1 $2 to $3',
 357+
 358+ /*
 359+ * js file: /modules/AddMedia/searchLibs/kalturaSearch.js
 360+ */
 361+ 'rsd-media-filter-title' => 'Media',
 362+ 'rsd-media-filter-videos' => 'Videos',
 363+ 'rsd-media-filter-images' => 'Images',
 364+ 'rsd-provider-filter-title' => 'Providers',
 365+
 366+ /*
 367+ * js file: /modules/AddMedia/searchLibs/baseRemoteSearch.js
 368+ */
 369+ 'mwe-imported_from' => '$1 imported from [$2 $3]. See the original [$4 resource page] for more information.',
 370+ 'mwe-import-description' => '$1, imported from $2',
 371+
 372+ /*
432373 * js file: /modules/AddMedia/jquery.dragDropFile.js
433374 */
434375 'mwe-upload-multi' => 'Upload {{PLURAL:$1|file|files}}',
435376 'mwe-review-upload' => 'Review file {{PLURAL:$1|upload|uploads}}',
436377
437378 /*
438 - * js file: /modules/ClipEdit/mw.ClipEdit.js
 379+ * js file: /modules/AddMedia/mw.UploadForm.js
439380 */
440 - 'mwe-crop' => 'Crop image',
441 - 'mwe-apply_crop' => 'Apply crop to image',
442 - 'mwe-reset_crop' => 'Reset crop',
443 - 'mwe-insert_image_page' => 'Insert into page',
444 - 'mwe-insert_into_sequence' => 'Insert into sequence',
445 - 'mwe-preview_insert' => 'Preview insert',
446 - 'mwe-cancel_image_insert' => 'Cancel insert',
447 - 'mwe-sc_attributes' => 'Clip detail edit',
448 - 'mwe-sc_inoutpoints' => 'Set in-out points',
449 - 'mwe-sc_overlays' => 'Overlays',
450 - 'mwe-sc_audio' => 'Audio control',
451 - 'mwe-sc_duration' => 'Duration',
452 - 'mwe-template_properties' => 'Template properties',
453 - 'mwe-custom_title' => 'Custom title',
454 - 'mwe-edit_properties' => 'Edit properties',
455 - 'mwe-other_properties' => 'Other properties',
456 - 'mwe-resource_page' => 'Resource page:',
457 - 'mwe-set_in_out_points' => 'Set in-out points',
458 - 'mwe-start_time' => 'Start time',
459 - 'mwe-end_time' => 'End time',
460 - 'mwe-preview_inout' => 'Preview in-out points',
461 - 'mwe-edit-tools' => 'Edit tools',
462 - 'mwe-inline-description' => 'Caption',
463 - 'mwe-edit-video-tools' => 'Edit video tools:',
464 - 'mwe-duration' => 'Duration:',
465 - 'mwe-layout' => 'Layout',
466 - 'mwe-layout_right' => 'Right side image layout',
467 - 'mwe-layout_left' => 'Left side image layout',
 381+ 'mwe-select_file' => 'Select file',
 382+ 'mwe-select_ownwork' => 'I am uploading entirely my own work, and licensing it under:',
 383+ 'mwe-license_cc-by-sa' => 'Creative Commons Share Alike (3.0)',
 384+ 'mwe-upload' => 'Upload file',
 385+ 'mwe-destfilename' => 'Destination filename:',
 386+ 'mwe-summary' => 'Summary',
 387+ 'mwe-error_not_loggedin' => 'You do not appear to be logged in or do not have upload privileges.',
 388+ 'mwe-error-not-loggedin-file' => 'You do not appear to be logged in or there was an error in the software. You can $1 and try again',
 389+ 'mwe-link-login' => 'login',
 390+ 'mwe-watch-this-file' => 'Watch this file',
 391+ 'mwe-ignore-any-warnings' => 'Ignore any warnings',
 392+ 'mwe-i-would-like-to' => 'I would like to',
 393+ 'mwe-upload-own-file' => 'Upload my own work to $1',
 394+ 'mwe-upload-not-my-file' => 'Upload media that is not my own work to $1',
 395+ 'mwe-upload-once-done' => 'Please $1. Once you have completed your upload, $2',
 396+ 'mwe-upload-in-new-win-link' => 'upload in the new window or tab',
 397+ 'mwe-upload-refresh' => 'refresh your upload list',
468398
469399 /*
470 - * js file: /modules/ApiProxy/mw.ApiProxy.js
 400+ * js file: /modules/AddMedia/mw.FirefoggGUI.js
471401 */
472 - 'mwe-setting-up-proxy' => 'Setting up proxy...',
473 - 'mwe-re-try' => 'Retry API request',
474 - 'mwe-re-trying' => 'Retrying API request...',
475 - 'mwe-proxy-not-ready' => 'Proxy is not configured',
476 - 'mwe-please-login' => 'The request failed. Are you logged in on $1 ? Please $2 and try again',
477 - 'mwe-log-in-link' => 'log in',
478 - 'mwe-remember-loging' => 'General security reminder: Only login to web sites when your address bar displays that site\'s address.',
 402+ 'fogg-save_local_file' => 'Save Ogg',
 403+ 'fogg-help-sticky' => 'Help (click to stick)',
 404+ 'fogg-cg-preset' => 'Preset: <strong>$1</strong>',
 405+ 'fogg-cg-quality' => 'Basic quality and resolution control',
 406+ 'fogg-cg-meta' => 'Metadata for the clip',
 407+ 'fogg-cg-range' => 'Encoding range',
 408+ 'fogg-cg-advVideo' => 'Advanced video encoding controls',
 409+ 'fogg-cg-advAudio' => 'Advanced audio encoding controls',
 410+ 'fogg-preset-custom' => 'Custom settings',
 411+ 'fogg-webvideo-desc' => 'Web video Theora, Vorbis 400 kbit/s and 400px maximum width',
 412+ 'fogg-savebandwidth-desc' => 'Low bandwidth Theora, Vorbis 164 kbit/s and 200px maximum width',
 413+ 'fogg-highquality-desc' => 'High quality Theora, Vorbis 1080px maximum width',
 414+ 'fogg-videoQuality-title' => 'Video quality',
 415+ 'fogg-videoQuality-help' => 'Used to set the <i>visual quality</i> of the encoded video (not used if you set bitrate in advanced controls below).',
 416+ 'fogg-starttime-title' => 'Start second',
 417+ 'fogg-starttime-help' => 'Only encode from time in seconds',
 418+ 'fogg-endtime-title' => 'End second',
 419+ 'fogg-endtime-help' => 'Only encode to time in seconds',
 420+ 'fogg-audioQuality-title' => 'Audio quality',
 421+ 'fogg-audioQuality-help' => 'Used to set the <i>acoustic quality</i> of the encoded audio (not used if you set bitrate in advanced controls below).',
 422+ 'fogg-videoCodec-title' => 'Video codec',
 423+ 'fogg-videoCodec-help' => 'Used to select the clip video codec. Presently only Theora is supported. More about the <a target="_new" href="http://en.wikipedia.org/wiki/Theora">Theora codec</a>.',
 424+ 'fogg-audioCodec-title' => 'Audio codec',
 425+ 'fogg-audioCodec-help' => 'Used to set the clip audio codec. Presently only Vorbis is supported. More about the <a target="_new" href="http://en.wikipedia.org/wiki/Vorbis">Vorbis codec</a>',
 426+ 'fogg-width-title' => 'Video width',
 427+ 'fogg-width-help' => 'Resize to given width.',
 428+ 'fogg-height-title' => 'Video height',
 429+ 'fogg-height-help' => 'Resize to given height.',
 430+ 'fogg-videoBitrate-title' => 'Video bitrate',
 431+ 'fogg-videoBitrate-help' => 'Video bitrate sets the encoding bitrate for video in (kb/s)',
 432+ 'fogg-twopass-title' => 'Two pass encoding',
 433+ 'fogg-twopass-help' => 'Two pass encoding enables more constant quality by making two passes over the video file',
 434+ 'fogg-framerate-title' => 'Frame rate',
 435+ 'fogg-framerate-help' => 'The video frame rate. More about <a target="_new" href="http://en.wikipedia.org/wiki/Frame_rate">frame rate</a>.',
 436+ 'fogg-aspect-title' => 'Aspect ratio',
 437+ 'fogg-aspect-help' => 'The video aspect ratio can be 4:3 or 16:9. More about <a target="_new" href="http://en.wikipedia.org/wiki/Aspect_ratio_%28image%29">aspect ratios</a>.',
 438+ 'fogg-keyframeInterval-title' => 'Key frame interval',
 439+ 'fogg-keyframeInterval-help' => 'The keyframe interval in frames. Note: Most codecs force keyframes if the difference between frames is greater than keyframe encode size. More about <a href="http://en.wikipedia.org/wiki/I-frame">keyframes</a>.',
 440+ 'fogg-denoise-title' => 'Denoise filter',
 441+ 'fogg-denoise-help' => 'Denoise input video. More about <a href="http://en.wikipedia.org/wiki/Video_denoising">denoise</a>.',
 442+ 'fogg-novideo-title' => 'No video',
 443+ 'fogg-novideo-help' => 'disable video in the output',
 444+ 'fogg-audioBitrate-title' => 'Audio bitrate',
 445+ 'fogg-samplerate-title' => 'Audio sampling rate',
 446+ 'fogg-samplerate-help' => 'set output sample rate (in Hz).',
 447+ 'fogg-noaudio-title' => 'No audio',
 448+ 'fogg-noaudio-help' => 'disable audio in the output',
 449+ 'fogg-title-title' => 'Title',
 450+ 'fogg-title-help' => 'A title for your clip',
 451+ 'fogg-artist-title' => 'Creator name',
 452+ 'fogg-artist-help' => 'The creator of this clip',
 453+ 'fogg-date-title' => 'Date',
 454+ 'fogg-date-help' => 'The date the footage was created or released',
 455+ 'fogg-location-title' => 'Location',
 456+ 'fogg-location-help' => 'The location of the footage',
 457+ 'fogg-organization-title' => 'Organization',
 458+ 'fogg-organization-help' => 'Name of organization (studio)',
 459+ 'fogg-copyright-title' => 'Copyright',
 460+ 'fogg-copyright-help' => 'The copyright of the clip',
 461+ 'fogg-license-title' => 'License',
 462+ 'fogg-license-help' => 'The license of the clip (preferably a Creative Commons URL).',
 463+ 'fogg-contact-title' => 'Contact',
 464+ 'fogg-contact-help' => 'Contact link',
479465
480466 /*
 467+ * js file: /modules/AddMedia/loader.js
 468+ */
 469+ 'mwe-loading-add-media-wiz' => 'Loading add media wizard',
 470+
 471+ /*
481472 * js file: /mwEmbed.js
482473 */
483474 'mwe-loading_txt' => 'Loading ...',
@@ -493,6 +484,11 @@
494485 'mwe-enable-gadget-done' => 'mwEmbed gadget has been enabled',
495486 'mwe-must-login-gadget' => 'To enable gadget you must <a target="_new" href="$1">login</a>',
496487 'mwe-test-plural' => 'I ran {{PLURAL:$1|$1 test|$1 tests}}',
 488+
 489+ /*
 490+ * js file: /skins/kskin/kskinConfig.js
 491+ */
 492+ 'mwe-credit-title' => 'Title: $1',
497493 );
498494
499495 /** Afrikaans (Afrikaans)
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadHandler.js
@@ -7,11 +7,8 @@
88 * This base upload class is optionally extended by Firefogg
99 *
1010 */
11 -mw.addMessages({
12 - "mwe-upload-transcoded-status" : "Transcoded",
13 - "mwe-upload-stats-fileprogress" : "$1 of $2",
14 - "mwe-upload_completed" : "Your upload is complete",
15 - "mwe-upload_done" : "<a href=\"$1\">Your upload <i>should be<\/i> accessible<\/a>.",
 11+mw.addMessages( {
 12+ "mwe-upload-stats-fileprogress" : "$1 of $2",
1613 "mwe-upload-unknown-size" : "Unknown size",
1714 "mwe-cancel-confim" : "Are you sure you want to cancel?",
1815 "mwe-successfulupload" : "Upload successful",
@@ -21,7 +18,7 @@
2219 "mwe-return-to-form" : "Return to form",
2320 "mwe-file-exists-duplicate" : "This file is a duplicate of the following file:",
2421 "mwe-fileexists" : "A file with this name exists already. Please check <b><tt>$1<\/tt><\/b> if you are not sure if you want to change it.",
25 - "mwe-fileexists-thumb" : "<center><b>Existing file<\/b><\/center>",
 22+ "mwe-fileexists-thumb" : "Existing file",
2623 "mwe-ignorewarning" : "Ignore warning and save file anyway",
2724 "mwe-file-thumbnail-no" : "The filename begins with <b><tt>$1<\/tt><\/b>",
2825 "mwe-go-to-resource" : "Go to resource page",
@@ -102,10 +99,10 @@
103100 // If chunks uploading is supported
104101 chunks_supported: true,
105102
106 - // If the existing form should be used to post to the api
 103+ // If the form should be used to directly upload / submit to the api
107104 // Since file selection can't be "moved" we have to use the existing
108105 // form and just submit it to a different target
109 - form_post_override: false,
 106+ formDirectSubmit: false,
110107
111108 // http copy by url mode flag
112109 http_copy_upload : null,
@@ -113,9 +110,9 @@
114111 // If the upload action is done
115112 action_done: false,
116113
117 - // Edit token for upload
 114+ // Edit token for upload lazy initialized with getToken() function
118115 editToken: false,
119 -
 116+
120117 // The DOM node for the upload form
121118 form: false,
122119
@@ -168,19 +165,48 @@
169166 this.orig_onsubmit = this.form.onsubmit;
170167 }
171168
 169+ if( this.selectFileCb ){
 170+ this.bindSelectFileCb();
 171+ }
 172+
172173 // Set up the submit action:
173 - $j( this.form ).submit( function() {
 174+ $j( this.form ).unbind( 'submit' ).submit( function() {
174175 mw.log( "FORM SUBMIT::" );
175176 return _this.onSubmit();
176177 } );
177178 },
178 -
 179+
179180 /**
 181+ * Binds the onSelect file callback
 182+ */
 183+ bindSelectFileCb: function(){
 184+ var _this = this;
 185+ // Grab the select file input from the form
 186+ var $target = $j( this.form ).find( "input[type='file']" );
 187+ $target.change( function() {
 188+ var path = $j( this ).val();
 189+ // Find trailing part
 190+ var slash = path.lastIndexOf( '/' );
 191+ var backslash = path.lastIndexOf( '\\' );
 192+ var fname;
 193+ if ( slash == -1 && backslash == -1 ) {
 194+ fname = path;
 195+ } else if ( slash > backslash ) {
 196+ fname = path.substring( slash + 1, 10000 );
 197+ } else {
 198+ fname = path.substring( backslash + 1, 10000 );
 199+ }
 200+ fname = fname.charAt( 0 ).toUpperCase().concat( fname.substring( 1, 10000 ) ).replace( / /g, '_' );
 201+ _this.selectFileCb( fname );
 202+ } );
 203+ },
 204+
 205+ /**
180206 * onSubmit handler for the upload form
181207 */
182208 onSubmit: function() {
183209 var _this = this;
184 - mw.log( 'Base::onSubmit:' );
 210+ mw.log( 'Base::onSubmit: isRawFormUpload:' + this.formDirectSubmit );
185211
186212 // Run the original onsubmit (if not run yet set flag to avoid excessive chaining)
187213 if ( typeof( this.orig_onsubmit ) == 'function' ) {
@@ -189,6 +215,13 @@
190216 return false;
191217 }
192218 }
 219+ // Check for post action
 220+ // formDirectSubmit is needed to actualy do the upload via a form "submit"
 221+ if ( this.formDirectSubmit ) {
 222+ mw.log("direct submit: ");
 223+
 224+ return true;
 225+ }
193226
194227 // Call the onsubmit_cb option if set:
195228 if( this.onsubmit_cb && typeof this.onsubmit_cb == 'function' ) {
@@ -198,12 +231,9 @@
199232 // Remap the upload form to the "api" form:
200233 this.remapFormToApi();
201234
202 - // Check for post action override
203 - if ( this.form_post_override ) {
204 - mw.log( 'form_post_override is true, do ordinary form submit' );
205 - return true;
206 - }
207 - mw.log(" about to run try / catch " );
 235+
 236+
 237+ mw.log(" about to run onSubmit try / catch: detectUploadMode" );
208238 // Put into a try catch so we are sure to return false:
209239 try {
210240 // Startup interface dispatch dialog
@@ -321,13 +351,13 @@
322352 remapFormToApi: function() {
323353 var _this = this;
324354 //
325 - mw.log("remapFormToApi:: " + this.apiUrl + ' form: ' + this.form);
 355+ mw.log("remapFormToApi:: " + this.apiUrl + ' form: ' + this.form);
326356
327357 if ( !this.apiUrl ) {
328358 mw.log( 'Error: no api url target' );
329359 return false;
330360 }
331 - var $form = $j( this.form_selector );
 361+ var $form = $j( this.form );
332362
333363 // Set the form action
334364 try {
@@ -335,7 +365,7 @@
336366 } catch( e ) {
337367 mw.log( "IE sometimes errors out when you change the action" );
338368 }
339 -
 369+
340370 // Add API action
341371 if ( $form.find( "[name='action']" ).length == 0 ) {
342372 $form.append(
@@ -346,7 +376,7 @@
347377 'value' : "upload"
348378 })
349379 )
350 - }
 380+ }
351381
352382 // Add JSON response format
353383 if ( $form.find( "[name='format']" ).length == 0 ) {
@@ -358,8 +388,8 @@
359389 'value' : "jsonfm"
360390 })
361391 )
362 - }
363 -
 392+ }
 393+
364394 // Map a new hidden form
365395 $form.find( "[name='wpUploadFile']" ).attr( 'name', 'file' );
366396 $form.find( "[name='wpDestFile']" ).attr( 'name', 'filename' );
@@ -391,11 +421,7 @@
392422 doPostUpload: function() {
393423 var _this = this;
394424 var $form = $j( _this.form );
395 - mw.log( 'mvBaseUploadHandler.doPostUpload' );
396 -
397 - // Issue a normal post request
398 - // Get the token from the page
399 - _this.editToken = $j( "#wpEditToken" ).val();
 425+ mw.log( 'mvBaseUploadHandler.doPostUpload' );
400426
401427 // TODO check for sendAsBinary to support Firefox/HTML5 progress on upload
402428 this.ui.setLoading();
@@ -413,14 +439,14 @@
414440 $j( "body" ).append(
415441 $j( iframe )
416442 .attr({
417 - 'src':'javascript:false;',
418 - 'id':_this.iframeId,
419 - 'name': _this.iframeId
 443+ 'src' : 'javascript:false;',
 444+ 'id' : _this.iframeId,
 445+ 'name': _this.iframeId
420446 })
421447 .css('display', 'none')
422448 );
 449+
423450
424 -
425451 // Set the form target to the iframe
426452 $form.attr( 'target', _this.iframeId );
427453
@@ -429,9 +455,13 @@
430456 _this.processIframeResult( $j( this ).get( 0 ) );
431457 });
432458
433 - // Do post override
434 - _this.form_post_override = true;
435 -
 459+ // Do normal post upload override
 460+ _this.formDirectSubmit = true;
 461+ mw.log('About to submit:');
 462+ $form.find('input').each( function(){
 463+ mw.log( $j(this).attr( 'name' ) + ' :: ' + $j(this).val() );
 464+ })
 465+
436466 $form.submit();
437467 },
438468
@@ -448,9 +478,7 @@
449479 'comment' : this.getUploadDescription(),
450480 'watch' : ( $j( '#wpWatchthis' ).is( ':checked' ) ) ? 'true' : 'false',
451481 'ignorewarnings': ($j('#wpIgnoreWarning' ).is( ':checked' ) ) ? 'true' : 'false'
452 - }
453 - //check for editToken
454 - this.editToken = $j( "#wpEditToken" ).val();
 482+ }
455483 this.doHttpUpload( httpUpConf );
456484 },
457485
@@ -466,7 +494,8 @@
467495 //Special case of upload.js commons hack:
468496 var comment_value = $j( '#wpUploadDescription' ).val();
469497 if( comment_value == '' ) {
470 - comment_value = $j( "[name='wpUploadDescription']").val();
 498+ // Else try with the form name:
 499+ comment_value = $j( "[name='comment']").val();
471500 }
472501 mw.log( 'getUploadDescription:: base:' + comment_value + ' ucr:' + this.useCopyrightUpload );
473502 // Set license, copyStatus, source if available ( generally not available SpecialUpload needs some refactoring )
@@ -515,8 +544,8 @@
516545 * @param {Element} iframe iframe to extract result from
517546 */
518547 processIframeResult: function( iframe ) {
519 - var _this = this;
520 - var doc = iframe.contentDocument ? iframe.contentDocument : frames[iframe.id].document;
 548+ var _this = this;
 549+ var doc = iframe.contentDocument ? iframe.contentDocument : frames[ iframe.id ].document;
521550 // Fix for Opera 9.26
522551 if ( doc.readyState && doc.readyState != 'complete' ) {
523552 return;
@@ -525,13 +554,14 @@
526555 if ( doc.body && doc.body.innerHTML == "false" ) {
527556 return;
528557 }
 558+
529559 var response;
530560 if ( doc.XMLDocument ) {
531561 // The response is a document property in IE
532562 response = doc.XMLDocument;
533563 } else if ( doc.body ) {
534564 // Get the json string
535 - json = $j( doc.body ).find( 'pre' ).text();
 565+ var json = $j( doc.body ).find( 'pre' ).text();
536566 //mw.log( 'iframe:json::' + json_str + "\nbody:" + $j( doc.body ).html() );
537567 if ( json ) {
538568 response = window["eval"]( "(" + json + ")" );
@@ -560,7 +590,8 @@
561591 // Set up the request
562592 var request = {
563593 'action' : 'upload',
564 - 'asyncdownload' : true // Do async download
 594+ 'asyncdownload' : true, // Do async download
 595+ 'token' : this.getToken()
565596 };
566597
567598 // Add any parameters specified by the caller
@@ -570,13 +601,6 @@
571602 }
572603 }
573604
574 - // Add the edit token (if available)
575 - if( !_this.editToken && _this.apiUrl ) {
576 - mw.log( 'Error:doHttpUpload: missing token' );
577 - } else {
578 - request['token'] =_this.editToken;
579 - }
580 -
581605 // Reset the done with action flag
582606 _this.action_done = false;
583607
@@ -598,12 +622,9 @@
599623 this.upload_status_request = {
600624 'action' : 'upload',
601625 'httpstatus' : 'true',
602 - 'sessionkey' : _this.upload_session_key
603 - };
604 -
605 - // Add token if present
606 - if ( this.editToken )
607 - this.upload_status_request['token'] = this.editToken;
 626+ 'sessionkey' : _this.upload_session_key,
 627+ 'token' : _this.getToken()
 628+ };
608629
609630 // Trigger an initial request (subsequent ones will be done by a timer)
610631 this.onAjaxUploadStatusTimer();
@@ -720,16 +741,14 @@
721742
722743 if ( apiRes.upload && apiRes.upload.imageinfo && apiRes.upload.imageinfo.descriptionurl ) {
723744 // Call the completion callback if available.
724 - if ( _this.done_upload_cb && typeof _this.done_upload_cb == 'function' ) {
725 - mw.log( "call done_upload_cb" );
726 -
727 - // This overrides our normal completion handling so we close the
728 - // dialog immediately.
729 - _this.ui.close();
730 - _this.done_upload_cb( apiRes.upload );
731 - return true;
732 - }
733 -
 745+ if ( typeof _this.doneUploadCb == 'function' ) {
 746+ // check if the callback returns true and close up shop
 747+ if( _this.doneUploadCb( apiRes ) ){
 748+ // Close the ui
 749+ _this.ui.close();
 750+ return true;
 751+ }
 752+ }
734753 // Else pass off the api Success to interface:
735754 _this.ui.showApiSuccess( apiRes );
736755 return true;
@@ -747,8 +766,8 @@
748767 case 'ignoreWarnings':
749768 this.ignoreWarningsSubmit();
750769 break;
751 - case 'disableFormPostOverride':
752 - this.form_post_override = false;
 770+ case 'disableDirectSubmit':
 771+ this.formDirectSubmit = false;
753772 break;
754773 default:
755774 mw.log( "Error reciveUploadAction:: unkown action: " + action );
@@ -766,14 +785,14 @@
767786 // Check if we have a stashed key:
768787 if ( _this.warnings_sessionkey !== false ) {
769788 //set to "loading"
770 - $j( '#upProgressDialog' ).html( mw.loading_spinner() );
 789+ _this.ui.setLoading();
771790 //setup request:
772791 var request = {
773792 'action': 'upload',
774793 'sessionkey': _this.warnings_sessionkey,
775794 'ignorewarnings': 1,
776795 'filename': $j( '#wpDestFile' ).val(),
777 - 'token' : _this.editToken,
 796+ 'token' : _this.getToken(),
778797 'comment' : _this.getUploadDescription()
779798 };
780799 //run the upload from stash request
@@ -782,9 +801,9 @@
783802 } );
784803 } else {
785804 mw.log( 'No session key re-sending upload' )
786 - //do a stashed upload
 805+ //Do a stashed upload
787806 $j( '#wpIgnoreWarning' ).attr( 'checked', true );
788 - $j( _this.editForm ).submit();
 807+ $j( _this.form ).submit();
789808 }
790809 },
791810
@@ -799,15 +818,32 @@
800819 * Get the DOMNode of the form element we are rewriting.
801820 * Returns false if it can't be found.
802821 */
803 - getForm: function() {
804 -
 822+ getForm: function() {
805823 if ( this.form_selector && $j( this.form_selector ).length != 0 ) {
806824 return $j( this.form_selector ).get( 0 );
807825 } else {
808826 mw.log( "mvBaseUploadHandler.getForm(): no form_selector" );
809827 return false;
810828 }
811 - }
 829+ },
 830+
 831+ // Get the editToken from the page.
 832+ getToken : function(){
 833+ if( this.editToken ){
 834+ return this.editToken;
 835+ }
 836+ if( $j( '#wpEditToken').length ){
 837+ this.editToken = $j( '#wpEditToken').val();
 838+ }
 839+ if( $j("form[name='token']").length){
 840+ this.editToken = $j("form[name='token']").val();
 841+ }
 842+ if( !this.editToken ){
 843+ mw.log("Error: can not find edit token ")
 844+ return false;
 845+ }
 846+ return this.editToken;
 847+ }
812848
813849 };
814850
@@ -831,6 +867,7 @@
832868 if ( !options.warn_target ) {
833869 options.warn_target = '#wpDestFile-warning';
834870 }
 871+ mw.log( 'do doDestCheck and update: ' + options.warn_target );
835872
836873 if( ! options.apiUrl ) {
837874 options.apiUrl = mw.getLocalApiUrl();
@@ -845,8 +882,7 @@
846883 .append( '<td />' )
847884 .attr('id', 'wpDestFile-warning')
848885 );
849 - }
850 - mw.log( 'past dest');
 886+ }
851887 // Remove any existing warning
852888 $j( options.warn_target ).empty();
853889
@@ -859,72 +895,116 @@
860896 .loadingSpinner()
861897 );
862898 // Setup the request
863 - var request = {
 899+ var request = {
864900 'titles': 'File:' + $j( _this.selector ).val(),
865901 'prop': 'imageinfo',
866902 'iiprop': 'url|mime|size',
867903 'iiurlwidth': 150
868 - };
 904+ };
869905
870906 // Do the destination check ( on the local wiki )
871907 mw.getJSON( options.apiUrl, request, function( data ) {
872 - // Remove spinner
873 - $j( '#mw-spinner-wpDestFile' ).remove();
874 -
875 - if ( !data || !data.query || !data.query.pages ) {
876 - // Ignore a null result
877 - return;
 908+ mw.log(" got callback? wtf");
 909+ // Remove spinner
 910+ $j( '#mw-spinner-wpDestFile' ).remove();
 911+
 912+ if ( !data || !data.query || !data.query.pages ) {
 913+ // Ignore a null result
 914+ mw.log(" No data in DestCheck result")
 915+ return;
 916+ }
 917+
 918+ if ( data.query.pages[-1] ) {
 919+ // No conflict found
 920+ mw.log(" No pages in DestCheck result")
 921+ return;
 922+ }
 923+ for ( var page_id in data.query.pages ) {
 924+ if ( !data.query.pages[ page_id ].imageinfo ) {
 925+ continue;
878926 }
879927
880 - if ( data.query.pages[-1] ) {
881 - // No conflict found
882 - return;
 928+ // Conflict found, show warning
 929+ if ( data.query.normalized ) {
 930+ var ntitle = data.query.normalized[0].to;
 931+ } else {
 932+ var ntitle = data.query.pages[ page_id ].title
883933 }
884 - for ( var page_id in data.query.pages ) {
885 - if ( !data.query.pages[ page_id ].imageinfo ) {
886 - continue;
887 - }
888 -
889 - // Conflict found, show warning
890 - if ( data.query.normalized ) {
891 - var ntitle = data.query.normalized[0].to;
892 - } else {
893 - var ntitle = data.query.pages[ page_id ].title
894 - }
895 - var img = data.query.pages[ page_id ].imageinfo[0];
896 - $j( options.warn_target ).html(
897 - gM( 'mwe-fileexists', ntitle ) +
898 - '<div class="thumb tright">' +
899 - '<div ' +
900 - 'style="width: ' + ( parseInt( img.thumbwidth ) + 2 ) + 'px;" ' +
901 - 'class="thumbinner">' +
902 - '<a ' +
903 - 'title="' + ntitle + '" ' +
904 - 'class="image" ' +
905 - 'href="' + img.descriptionurl + '">' +
906 - '<img ' +
907 - 'width="' + img.thumbwidth + '" ' +
908 - 'height="' + img.thumbheight + '" ' +
909 - 'border="0" ' +
910 - 'class="thumbimage" ' +
911 - 'src="' + img.thumburl + '" ' +
912 - 'alt="' + ntitle + '"/>' +
913 - '</a>' +
914 - '<div class="thumbcaption">' +
915 - '<div class="magnify">' +
916 - '<a title="' + gM('thumbnail-more') + '" class="internal" ' +
917 - 'href="' + img.descriptionurl +'">' +
918 - '<img border="0" width="15" height="11" alt="" ' +
919 - 'src="' + mw.getConfig( 'images_path' ) + 'magnify-clip.png" />' +
920 - '</a>' +
921 - '</div>' +
922 - gM( 'mwe-fileexists-thumb' ) +
923 - '</div>' +
924 - '</div>' +
925 - '</div>'
 934+ var img = data.query.pages[ page_id ].imageinfo[0];
 935+
 936+ var linkAttr ={
 937+ 'title' : ntitle,
 938+ 'href' : img.descriptionurl,
 939+ 'target' : '_new'
 940+ };
 941+
 942+ var $fileAlreadyExists = $j('<div />')
 943+ .append(
 944+ gM( 'mwe-fileexists',
 945+ $j('<a />')
 946+ .attr( linkAttr )
 947+ .text( ntitle )
 948+ )
 949+ )
 950+
 951+ var $imageLink = $j('<a />')
 952+ .addClass( 'image' )
 953+ .attr( linkAttr )
 954+ .append(
 955+ $j( '<img />')
 956+ .addClass( 'thumbimage' )
 957+ .attr( {
 958+ 'width' : img.thumbwidth,
 959+ 'height' : img.thumbheight,
 960+ 'border' : 0,
 961+ 'src' : img.thumburl,
 962+ 'alt' : ntitle
 963+ } )
926964 );
927 - }
 965+
 966+ var $imageCaption = $j( '<div />' )
 967+ .addClass( 'thumbcaption' )
 968+ .append(
 969+ $j('<div />')
 970+ .addClass( "magnify" )
 971+ .append(
 972+ $j('<a />' )
 973+ .addClass( 'internal' )
 974+ .attr( {
 975+ 'title' : gM('thumbnail-more'),
 976+ 'href' : img.descriptionurl
 977+ } ),
 978+
 979+ $j( '<img />' )
 980+ .attr( {
 981+ 'border' : 0,
 982+ 'width' : 15,
 983+ 'height' : 11,
 984+ 'src' : mw.getConfig( 'images_path' ) + 'magnify-clip.png'
 985+ } ),
 986+
 987+ $j('<span />')
 988+ .html( gM( 'mwe-fileexists-thumb' ) )
 989+ )
 990+ );
 991+ $j( options.warn_target ).append(
 992+ $fileAlreadyExists,
 993+
 994+ $j( '<div />' )
 995+ .addClass( 'thumb tright' )
 996+ .append(
 997+ $j( '<div />' )
 998+ .addClass( 'thumbinner' )
 999+ .css({
 1000+ 'width' : ( parseInt( img.thumbwidth ) + 2 ) + 'px;'
 1001+ })
 1002+ .append(
 1003+ $imageLink,
 1004+ $imageCaption
 1005+ )
 1006+ )
 1007+ );
9281008 }
929 - );
 1009+ } );
9301010 }
9311011 })( jQuery );
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/loader.js
@@ -88,7 +88,7 @@
8989 * Includes both firefogg & firefogg "GUI" which share some loading logic:
9090 */
9191
92 - // Clone the baseUploadlibs array
 92+ // Clone the baseUploadlibs array and add the firefogg lib:
9393 var mwBaseFirefoggReq = baseUploadlibs.slice( 0 )
9494 mwBaseFirefoggReq[ 0 ].push( 'mw.Firefogg' );
9595
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadInterface.js
@@ -16,7 +16,8 @@
1717 mw.addMessages( {
1818 "mwe-upload-in-progress" : "Upload in progress (do not close this window)",
1919 "mwe-uploaded-status" : "Uploaded",
20 - "mwe-uploaded-time-remaining" : "Time remaining: $1"
 20+ "mwe-uploaded-time-remaining" : "Time remaining: $1",
 21+ "mwe-upload-done" : "Your upload <i>should be<\/i> accessible.",
2122 } );
2223
2324 /**
@@ -60,9 +61,11 @@
6162 $j( '<div />')
6263 .attr( 'id', "upProgressDialog" )
6364 );
 65+
6466 if( typeof options == 'undefined' || !options.title ) {
6567 options.title = gM('mwe-upload-in-progress');
6668 }
 69+
6770 $j( '#upProgressDialog' ).dialog( {
6871 title : options.title,
6972 bgiframe: true,
@@ -82,6 +85,7 @@
8386 },
8487 buttons: _this.getCancelButton()
8588 } );
 89+
8690 mw.log( 'upProgressDialog::dialog done' );
8791
8892 var $progressContainer = $j('<div />')
@@ -89,7 +93,8 @@
9094 .css({
9195 'height' : '15px'
9296 });
93 - // add the progress bar
 97+
 98+ // Add the progress bar
9499 $progressContainer.append(
95100 $j('<div />')
96101 .attr('id', 'up-progressbar')
@@ -192,7 +197,6 @@
193198
194199 /**
195200 * Set the dialog to loading
196 - * @param optional loadingText text to set dialog to.
197201 */
198202 setLoading: function( ) {
199203 this.action_done = false;
@@ -244,9 +248,10 @@
245249
246250 // Generate the error button
247251 var buttons = {};
248 - buttons[ gM( 'mwe-return-to-form' ) ] = function() {
249 - _this.form_post_override = false;
 252+ buttons[ gM( 'mwe-return-to-form' ) ] = function() {
250253 $j( this ).dialog( 'close' );
 254+ // Disable direct submit so that we can handle updated form data
 255+ _this.sendUploadAction( 'disableDirectSubmit' );
251256 };
252257
253258
@@ -388,7 +393,7 @@
389394 // Create the "return to form" button
390395 buttons[ gM( 'mwe-return-to-form' ) ] = function() {
391396 $j( this ).dialog( 'close' );
392 - _this.sendUploadAction( 'disableFormPostOverride' );
 397+ _this.sendUploadAction( 'disableDirectSubmit' );
393398 }
394399 // Show warning
395400 _this.setPrompt(
@@ -418,6 +423,7 @@
419424
420425 /**
421426 * Shows api success from a apiResult
 427+ * @param {Object} apiRes Result object
422428 */
423429 showApiSuccess: function( apiRes ){
424430 mw.log( " UI:: showApiSuccess: " );
@@ -428,7 +434,7 @@
429435 // "Return" button
430436 buttons[ gM( 'mwe-return-to-form' ) ] = function() {
431437 $j( this ).dialog( 'destroy' ).remove();
432 - _this.sendUploadAction( 'disableFormPostOverride' );
 438+ _this.sendUploadAction( 'disableDirectSubmit' );
433439 }
434440 // "Go to resource" button
435441 buttons[ gM('mwe-go-to-resource') ] = function() {
@@ -437,7 +443,11 @@
438444 _this.action_done = true;
439445 _this.setPrompt(
440446 gM( 'mwe-successfulupload' ),
441 - gM( 'mwe-upload_done', url),
 447+ $j('<a />')
 448+ .attr( 'href', url )
 449+ .html(
 450+ gM( 'mwe-upload-done')
 451+ ),
442452 buttons
443453 );
444454 mw.log( 'apiRes.upload.imageinfo::' + url );
@@ -482,12 +492,10 @@
483493 * other domain via iframe proxy or eventually html5 sendMsg
484494 */
485495 init: function( callbackProxy ){
486 - this.callbackProxy = callbackProxy;
 496+ var _this = this;
 497+ this.callbackProxy = callbackProxy;
487498 },
488 - setup: function( options ){
489 - this.callbackProxy( 'setup', options );
490 - },
491 -
 499+
492500 // Don't call update progress more than once every 3 seconds
493501 // Since it involves loading a cached iframe. Once we support html5
494502 // cross domain "sendMsg" then we can pass all updates
@@ -497,16 +505,35 @@
498506 this.callbackProxy( 'updateProgress', fraction );
499507 }
500508 },
 509+
 510+ // Pass on the setup call
 511+ setup: function( options ){
 512+ this.callbackProxy( 'setup', options );
 513+ },
 514+
 515+ // pass along the close request
 516+ close: function(){
 517+ this.callbackProxy( 'close' );
 518+ },
 519+
 520+ // Pass on the "setLoading" action
 521+ setLoading: function( ){
 522+ this.callbackProxy( 'setLoading' );
 523+ },
 524+
501525 // Pass on the show api errror:
502526 showApiError: function ( apiRes ){
503527 this.callbackProxy( 'showApiError', apiRes );
504528 },
 529+
505530 // Pass on the show api success:
506531 showApiSuccess: function ( apiRes ) {
507532 this.callbackProxy( 'showApiSuccess', apiRes );
508533 },
 534+
509535 // Pass on api action
510536 sendUploadAction: function( action ) {
511537 this.callbackProxy( 'sendUploadAction', action );
512538 }
 539+
513540 };
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.Firefogg.js
@@ -4,6 +4,7 @@
55 */
66
77 mw.addMessages({
 8+ "mwe-upload-transcoded-status" : "Transcoded",
89 "mwe-upload-transcode-in-progress" : "Transcode and upload in progress (do not close this window)",
910 "fogg-transcoding" : "Encoding video to ogg",
1011 "fogg-select_file" : "Select file",
@@ -11,12 +12,13 @@
1213 "fogg-select_url" : "Select URL",
1314 "fogg-check_for_firefogg" : "Checking for Firefogg...",
1415 "fogg-installed" : "Firefogg is installed,",
15 - "fogg-not-installed" : "Firefogg is not installed",
 16+ "fogg-not-installed" : "Firefogg is not installed or not enabled.",
1617 "fogg-for_improved_uploads" : "For improved uploads:",
1718 "fogg-please-install" : "$1. More $2",
1819 "fogg-please-install-install-linktext" : "Install firefogg",
1920 "fogg-please-install-about-linktext" : "about firefogg",
20 - "fogg-use_latest_firefox" : "Please first install <a href=\"http:\/\/www.mozilla.com\/en-US\/firefox\/upgrade.html?from=firefogg\">Firefox 3.5<\/a> (or later). <i>Then revisit this page to install the <b>Firefogg<\/b> extension.<\/i>",
 21+ "fogg-use_latest_firefox" : "Please first install $1. <i>Then revisit this page to install the <b>Firefogg<\/b> extension.<\/i>",
 22+ "fogg-latest-firefox" : "latest firefox",
2123 "fogg-passthrough_mode" : "Your selected file is already ogg or not a video file",
2224 "fogg-encoding-done" : "Encoding complete",
2325 "fogg-badtoken" : "Token is not valid",
@@ -33,7 +35,7 @@
3436
3537 var default_firefogg_options = {
3638 // Callback for upload completion
37 - 'done_upload_cb': false,
 39+ 'doneUploadCb': false,
3840
3941 // The API URL to upload to
4042 'apiUrl': null,
@@ -44,15 +46,14 @@
4547 // True if we will be showing the encoder interface
4648 'encoder_interface': false,
4749
48 - // True if we want to limit the library functionality to "only firefogg"
49 - // (no upload or progress bars)
50 - 'only_firefogg': false,
51 -
5250 // jQuery selector identifying the target control container or form (can't be left null)
5351 'selector': '',
5452
5553 // May be "upload" to if we are rewriting an upload form, or "local" if we are encoding a local file
5654 'form_type': 'local',
 55+
 56+ // Special Mode that just checks for firefogg install and puts a notice after the target
 57+ 'installCheckMode': false,
5758
5859 // CSS selector for the select file button
5960 'target_btn_select_file': false,
@@ -106,8 +107,10 @@
107108
108109 // Setup the Firefogg:
109110 var myFogg = new mw.Firefogg( options );
110 -
111 - if ( myFogg ) {
 111+
 112+ // Kind of silly installCheckMode check
 113+ // need to refactor as described in init :: installCheckMode
 114+ if ( myFogg && ! myFogg.installCheckMode ) {
112115 myFogg.doRewrite( );
113116 var selectorElement = $j( this.selector ).get( 0 );
114117 selectorElement[ 'uploadHandler' ] = myFogg;
@@ -151,12 +154,14 @@
152155 * Object initialisation
153156 */
154157 init: function( options ) {
155 - if ( !options )
 158+ if ( !options ){
156159 options = {};
 160+ }
157161
158162 // If we have no apiUrl, set upload mode to "post"
159 - if ( !options.apiUrl )
 163+ if ( !options.apiUrl ){
160164 options.upload_mode = 'post';
 165+ }
161166
162167 // Set options
163168 for ( var i in default_firefogg_options ) {
@@ -166,18 +171,34 @@
167172 this[i] = default_firefogg_options[i];
168173 }
169174 }
 175+
 176+ // Check for special installCheckMode
 177+
 178+ // NOTE we should refactor install checks into static functions / entry points
 179+ // so that they can be called without initializing the firefogg object with a special flag.
 180+ if( this.installCheckMode ){
 181+ if ( ! this.getFirefogg() ) {
 182+ this.form_type = 'upload';
 183+ // Show install firefogg msg
 184+ this.showInstallFirefog();
 185+ return ;
 186+ }
 187+ if( console.firebug ) {
 188+ this.appendFirebugWarning();
 189+ }
 190+ mw.log( "installCheckMode no firefogg init");
 191+ return ;
 192+ }
170193
171 - // Inherit from mw.BaseUploadHandler (unless we're in only_firefogg mode)
172 - if ( !this.only_firefogg ) {
173 - var myBUI = new mw.UploadHandler( options );
 194+ // Inherit from mw.BaseUploadHandler
 195+ var myBUI = new mw.UploadHandler( options );
174196
175 - // Prefix conflicting members with parent_
176 - for ( var i in myBUI ) {
177 - if ( this[ i ] ) {
178 - this[ 'parent_'+ i ] = myBUI[i];
179 - } else {
180 - this[ i ] = myBUI[i];
181 - }
 197+ // Prefix conflicting members with parent_
 198+ for ( var i in myBUI ) {
 199+ if ( this[ i ] ) {
 200+ this[ 'parent_'+ i ] = myBUI[i];
 201+ } else {
 202+ this[ i ] = myBUI[i];
182203 }
183204 }
184205
@@ -319,10 +340,10 @@
320341 /**
321342 * Show the install firefogg msg
322343 */
323 - showInstallFirefog: function() {
324 - var _this = this;
 344+ showInstallFirefog: function() {
 345+ var _this = this;
325346
326 - var upMsg = ( _this.form_type == 'upload' ) ?
 347+ var upMsg = ( _this.form_type == 'upload' ) ?
327348 gM( 'fogg-for_improved_uploads' ) + ' ' : gM( 'fogg-not-installed') + ' ';
328349
329350 // Show the "use latest Firefox" message if necessary
@@ -332,7 +353,22 @@
333354
334355 // Add the use_latest if not present:
335356 if ( !this.target_use_latest_firefox ) {
336 - $j( this.selector ).after( this.getControlHtml( 'target_use_latest_firefox' ) );
 357+ $j( this.selector ).after(
 358+ $j( '<div />' )
 359+ .addClass( 'target_use_latest_firefox' )
 360+ .html(
 361+ gM('fogg-use_latest_firefox',
 362+ $j('<a />')
 363+ .attr({
 364+ 'href' : 'http://www.mozilla.com/firefox/?from=firefogg',
 365+ 'target' : "_new"
 366+ })
 367+ .text(
 368+ gM( 'fogg-latest-firefox' )
 369+ )
 370+ )
 371+ )
 372+ );
337373 this.target_use_latest_firefox = this.selector + ' ~ .target_use_latest_firefox';
338374 }
339375
@@ -342,24 +378,31 @@
343379 .prepend( upMsg );
344380 }
345381
346 - $j( _this.target_use_latest_firefox ).show();
 382+ $j( _this.target_use_latest_firefox ).show();
347383 return ;
348384 }
349385 mw.log( 'should show install link');
350386
351 - // Otherwise show the "install Firefogg" message
 387+ // Otherwise show the "install Firefogg" message
352388 var firefoggUrl = _this.getFirefoggInstallUrl();
353389 if( firefoggUrl ) {
354390
355391 // Add the target please install in not present:
356392 if ( !this.target_please_install ) {
357 - $j( this.selector ).after( this.getControlHtml( 'target_please_install' ) );
358 - this.target_please_install = this.selector + ' ~ .target_please_install';
 393+ $j( this.selector ).after(
 394+ $j('<div />')
 395+ .addClass( 'ui-corner-all target_please_install' )
 396+ .css({
 397+ 'border' : 'thin solid black',
 398+ 'margin' : '4px'
 399+ })
 400+ );
 401+ this.target_please_install = this.selector + ' ~ .target_please_install';
359402 }
360403 // Add the install msg
361404 $j( _this.target_please_install )
362405 .html( upMsg +
363 - gM( 'fogg-please-install', [
 406+ gM( 'fogg-please-install', [
364407 // Install link
365408 $j('<a />')
366409 .text( gM( "fogg-please-install-install-linktext" ) )
@@ -368,7 +411,10 @@
369412 // About link
370413 $j('<a />')
371414 .text( gM( "fogg-please-install-about-linktext" ) )
372 - .attr( 'href', 'http://commons.wikimedia.org/wiki/Commons:Firefogg' )
 415+ .attr({
 416+ 'href' : 'http://commons.wikimedia.org/wiki/Commons:Firefogg',
 417+ 'target' : '_new'
 418+ } )
373419 ])
374420 )
375421 .css( 'padding', '10px' )
@@ -423,7 +469,7 @@
424470 }
425471
426472 // If Firefogg is not available, just show a "please install" message
427 - if ( ! _this.getFirefogg() ) {
 473+ if ( ! _this.getFirefogg() ) {
428474 // Show install firefogg msg
429475 this.showInstallFirefog();
430476 return;
@@ -433,16 +479,7 @@
434480 if ( this.form_type == 'upload'
435481 && typeof console != 'undefined'
436482 && console.firebug ) {
437 - $j( this.selector ).after(
438 - $j( '<div />' )
439 - .addClass( 'ui-state-error ui-corner-all' )
440 - .html( gM( 'fogg-warning-firebug' ) )
441 - .css({
442 - 'width' : 'auto',
443 - 'margin' : '5px',
444 - 'padding' : '5px'
445 - })
446 - );
 483+ this.appendFirebugWarning();
447484 }
448485
449486 // Change the file browser to type text. We can't simply change the attribute so
@@ -473,7 +510,18 @@
474511 this.createControls();
475512 this.bindControls();
476513 },
477 -
 514+ appendFirebugWarning : function(){
 515+ $j( this.selector ).after(
 516+ $j( '<div />' )
 517+ .addClass( 'ui-state-error ui-corner-all' )
 518+ .html( gM( 'fogg-warning-firebug' ) )
 519+ .css({
 520+ 'width' : 'auto',
 521+ 'margin' : '5px',
 522+ 'padding' : '5px'
 523+ })
 524+ );
 525+ },
478526 /**
479527 * Create controls for showing a transcode/crop/resize preview
480528 */
@@ -883,13 +931,10 @@
884932
885933 /**
886934 * Do an upload, with the mode given by this.upload_mode
887 - * XXX should probably be dispatched from BaseUploadHandler doUpload instead
 935+ * NOTE: should probably be dispatched from BaseUploadHandler doUpload instead
888936 */
889937 doUpload: function() {
890 - var _this = this;
891 - mw.log( "firefogg: doUpload:: " +
892 - ( this.getFirefogg() ? 'on' : 'off' ) +
893 - ' up mode:' + _this.upload_mode );
 938+ var _this = this;
894939
895940 _this.uploadBeginTime = (new Date()).getTime();
896941 // If Firefogg is disabled or doing an copyByUrl upload, just invoke the parent method
@@ -897,6 +942,8 @@
898943 _this.parent_doUpload();
899944 return ;
900945 }
 946+ // We are doing a firefogg upload:
 947+ mw.log( "firefogg: doUpload:: " );
901948
902949 // Setup the firefogg dialog (if not passthrough )
903950 _this.ui.setup( { 'title' : gM( 'mwe-upload-transcode-in-progress' ) } );
@@ -1151,22 +1198,6 @@
11521199 _this.processApiResult ( apiResult );
11531200 return true;
11541201 }
1155 -
1156 - /*
1157 - if( apiResult && _this.isApiSuccess( apiResult ) ) {
1158 - if( _this.processApiResult ( apiResult ) ) {
1159 - return true;
1160 - }
1161 - }
1162 -
1163 - if ( apiResult && !_this.isApiSuccess( apiResult ) ) {
1164 - // Show the error and stop the upload
1165 - _this.ui.showApiError( apiResult );
1166 - _this.action_done = true;
1167 - _this.fogg.cancel();
1168 - return false;
1169 - }
1170 - */
11711202
11721203 }
11731204 // Show the video preview if encoding and show_preview is enabled.
@@ -1191,26 +1222,21 @@
11921223 }
11931224 // Chunk upload mode:
11941225 if ( apiResult && apiResult.resultUrl ) {
1195 - var buttons = { };
1196 - buttons[ gM( 'mwe-go-to-resource' ) ] = function() {
1197 - window.location = apiResult.resultUrl;
 1226+ this.action_done = true;
 1227+ // Call the callback
 1228+ if ( typeof _this.doneUploadCb == 'function' ) {
 1229+ // check if the callback returns true and close up shop
 1230+ if( _this.doneUploadCb( apiRes ) ){
 1231+ _this.ui.close();
 1232+ return true;
 1233+ }
11981234 }
1199 - var go_to_url_txt = gM( 'mwe-go-to-resource' );
1200 - var showMessage = true;
1201 - if ( typeof _this.done_upload_cb == 'function' ) {
1202 - // Call the callback
1203 - // It will return false if it doesn't want us to show our own "done" message
1204 - showMessage = _this.done_upload_cb( _this.formData );
1205 - }
1206 - if ( showMessage ) {
1207 - _this.ui.setPrompt( gM( 'mwe-successfulupload' ),
1208 - gM( 'mwe-upload_done', apiResult.resultUrl ), buttons );
1209 - } else {
1210 - this.action_done = true;
1211 - $j( '#upProgressDialog' ).empty().dialog( 'close' );
1212 - }
 1235+ // Else pass off the api Success to interface:
 1236+ _this.ui.showApiSuccess( apiResult );
 1237+ return true;
12131238 } else {
1214 - // Done state with error? Not really possible given how firefogg works...
 1239+ // Done state with error?
 1240+ // Should not be possible because firefogg would not be "done" without resultURL
12151241 mw.log( " Upload done in chunks mode, but no resultUrl!" );
12161242 }
12171243
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadForm.js
@@ -1,9 +1,8 @@
22 /**
33 * Simple form output jquery binding
44 * enables dynamic form output to a given target
5 - *
65 */
7 -
 6+
87 mw.addMessages( {
98 "mwe-select_file" : "Select file",
109 "mwe-select_ownwork" : "I am uploading entirely my own work, and licensing it under:",
@@ -22,15 +21,16 @@
2322 "mwe-i-would-like-to" : "I would like to",
2423 "mwe-upload-own-file" : "Upload my own work to $1",
2524 "mwe-upload-not-my-file" : "Upload media that is not my own work to $1",
26 - "mwe-upload-once-done" : "Please upload in the new window or tab. Once you have completed your upload, $1",
 25+ "mwe-upload-once-done" : "Please $1. Once you have completed your upload, $2",
 26+ "mwe-upload-in-new-win-link" : "upload in the new window or tab",
2727 "mwe-upload-refresh" : "refresh your upload list"
2828 } );
2929
3030 var default_form_options = {
3131 'enable_fogg' : true,
3232 'license_options': ['cc-by-sa'],
33 - 'api_target' : false,
34 - 'ondone_callback' : null
 33+ 'apiUrl' : false,
 34+ 'doneUploadCb' : null
3535 };
3636 mw.UploadForm = { };
3737
@@ -41,6 +41,8 @@
4242 */
4343 var uploadMenuTarget = null;
4444 var remoteSearchDriver = null;
 45+ var selectUploadProviderCb = null;
 46+
4547 mw.UploadForm.getUploadMenu = function( options ){
4648 if( ! options.target ){
4749 mw.log("Error no target for upload menu" );
@@ -53,9 +55,12 @@
5456 remoteSearchDriver = options.remoteSearchDriver
5557 }
5658
 59+ if( options.selectUploadProviderCb ){
 60+ selectUploadProviderCb = options.selectUploadProviderCb;
 61+ }
 62+
5763 // Build out the menu
58 - $j( uploadMenuTarget ).empty().append(
59 -
 64+ $j( uploadMenuTarget ).empty().append(
6065 $j( '<span />' )
6166 .text(
6267 gM('mwe-i-would-like-to' )
@@ -65,6 +70,7 @@
6671 );
6772
6873 $uploadTargetsList = $j( '<ul />' );
 74+
6975 // Set provider Target
7076 for( var uploadTargetId in options.uploadTargets ){
7177 $uploadTargetsList.append(
@@ -90,13 +96,13 @@
9197 }
9298
9399 // First do a reality check on the options:
94 - if ( !options.api_target ) {
 100+ if ( !options.apiUrl ) {
95101 $j( options.target ).html( 'Error: Missing api target' );
96102 return false;
97103 }
98104
99105 // Get an edit Token for "uploading"
100 - mw.getToken( options.api_target, 'File:MyRandomFileTokenCheck.jpg', function( eToken ) {
 106+ mw.getToken( options.apiUrl, 'File:MyRandomFileTokenCheck.jpg', function( eToken ) {
101107 if ( !eToken || eToken == '+\\' ) {
102108 $j( options.target ).html( gM( 'mwe-error_not_loggedin' ) );
103109 return false;
@@ -120,23 +126,24 @@
121127 } );
122128
123129
124 - // Do local destination fill ( if we are local )
125 - // Otherwise its handled via mw.ApiProxy.browseFile selectFileCb option
126 - if( mw.isLocalDomain( options.api_target ) ) {
127 - setupLocalUploadBindings();
 130+ //Set up the bindings
 131+ if( mw.isLocalDomain( options.apiUrl ) ) {
 132+ // Setup Local upload bindings
 133+ setupLocalUploadBindings( options );
 134+ }else{
 135+ // Setup ApiFile bindings
 136+ setupApiFileBrowseProxy(
 137+ options
 138+ );
128139 }
129140
130141 // Do remote or local destination check:
131142 $j( "#wpDestFile" ).change( function( ) {
132143 $j( "#wpDestFile" ).doDestCheck( {
133 - 'apiUrl' : options.api_target,
 144+ 'apiUrl' : options.apiUrl,
134145 'warn_target':'#wpDestFile-warning'
135146 } );
136 - } );
137 -
138 - if ( typeof options.ondone_callback == 'undefined' ) {
139 - options.ondone_callback = false;
140 - }
 147+ } );
141148 }); // ( token )
142149 }
143150
@@ -145,44 +152,26 @@
146153 * ( this is different from the api file proxy bindings that
147154 * handles the interface bindings within the api file proxy setup.
148155 */
149 - function setupLocalUploadBindings( ) {
150 -
151 - $j( "#wpUploadFile" ).change( function() {
152 - var path = $j( this ).val();
153 - // Find trailing part
154 - var slash = path.lastIndexOf( '/' );
155 - var backslash = path.lastIndexOf( '\\' );
156 - var fname;
157 - if ( slash == -1 && backslash == -1 ) {
158 - fname = path;
159 - } else if ( slash > backslash ) {
160 - fname = path.substring( slash + 1, 10000 );
161 - } else {
162 - fname = path.substring( backslash + 1, 10000 );
163 - }
164 - fname = fname.charAt( 0 ).toUpperCase().concat( fname.substring( 1, 10000 ) ).replace( / /g, '_' );
165 -
166 - // Output result
167 - $j( "#wpDestFile" ).val( fname );
168 -
169 - // Do destination check
170 - $j( "#wpDestFile" ).doDestCheck( {
171 - 'warn_target':'#wpDestFile-warning'
172 - } );
173 - } );
 156+ function setupLocalUploadBindings( options ) {
174157
175 - mw.load( 'AddMedia.firefogg', function( ) {
 158+ mw.load( 'AddMedia.firefogg', function( ) {
176159 $j( "#wpUploadFile" ).firefogg( {
177160 // An api url (we won't submit directly to action of the form)
178 - 'apiUrl' : options.api_target,
 161+ 'apiUrl' : options.apiUrl,
179162
180163 // MediaWiki API supports chunk uploads:
181164 'enable_chunks' : false,
182165
183166 'form_selector' : '#suf_upload',
 167+
 168+ 'doneUploadCb' : options.doneUploadCb,
 169+
184170 'selectFileCb' : function( fileName ) {
185 - $j( "#wpDestFile" ).val( oggName ).doDestCheck( {
186 - warn_target: "#wpDestFile-warning"
 171+ // Update our local target:
 172+ $j('#wpDestFile').val( fileName );
 173+ $j( "#wpDestFile" ).doDestCheck( {
 174+ 'apiUrl' : options.apiUrl,
 175+ 'warn_target' : "#wpDestFile-warning"
187176 } );
188177 },
189178 'onsubmit_cb' : function( ) {
@@ -205,31 +194,42 @@
206195 '{{self|cc-by-sa-3.0}}' + "\n"
207196 );
208197 }
209 - },
210 - 'done_upload_cb' : options.ondone_callback
 198+ }
211199 } );
212200 });
213201 }
214202 /**
215203 * Setup a fileBrowse proxy for a given target
216204 */
217 - function setupApiFileBrowseProxy ( $targetFileBrowse, options ) {
 205+ function setupApiFileBrowseProxy ( options ) {
 206+ // Set the "firefogg warning"
 207+ // ( note AddMedia.firefogg will be loaded by the same url should be cached )
 208+ mw.load( 'AddMedia.firefogg', function( ) {
 209+ $j( options.target ).find( '.remote-browse-file' ).firefogg( {
 210+ 'installCheckMode' : true
 211+ });
 212+ } );
218213 // Load the apiProxy ( if its not already loaded )
219214 mw.load( 'ApiProxy', function( ) {
220215 var fileIframeName = mw.ApiProxy.browseFile( {
221216 //Target div to put the iframe browser button:
222 - 'target' : $targetFileBrowse,
 217+ 'target' : $j( options.target ).find( '.remote-browse-file' ),
223218
 219+ 'token' : options.eToken,
 220+
224221 // Api url to upload to
225 - 'apiUrl' : options.api_target,
226 -
 222+ 'apiUrl' : options.apiUrl,
 223+
 224+ // Setup the callback:
 225+ 'doneUploadCb' : options.doneUploadCb,
 226+
227227 // File Destination Name change callback:
228 - 'selectFileCb' : function( fname ) {
 228+ 'selectFileCb' : function( fileName ) {
229229 // Update our local target:
230 - $j('#wpDestFile').val( fname );
 230+ $j('#wpDestFile').val( fileName );
231231 // Run a destination file name check on the remote target
232232 $j('#wpDestFile').doDestCheck( {
233 - 'apiUrl' : options.api_target,
 233+ 'apiUrl' : options.apiUrl,
234234 'warn_target': '#file-warning'
235235 } );
236236 },
@@ -240,19 +240,50 @@
241241 gM( 'mwe-error-not-loggedin-file',
242242 $j( '<a />' )
243243 .text( gM('mwe-link-login') )
244 - .attr('attr', options.api_target.replace( 'api.php', 'index.php' ) + '?title=Special:UserLogin' )
 244+ .attr('attr', options.apiUrl.replace( 'api.php', 'index.php' ) + '?title=Special:UserLogin' )
245245 )
246246 );
247247
248248 }
249249 } );
250 - });
 250+
 251+ // Setup submit binding:
 252+ $j('#wpUploadBtn').click( function(){
 253+ // Build the output and send upload request to fileProxy
 254+ mw.ApiProxy.sendServerMsg( {
 255+ 'apiUrl' : options.apiUrl,
 256+ 'frameName' : fileIframeName,
 257+ 'frameMsg' : {
 258+ 'action' : 'fileSubmit',
 259+ 'formData' : {
 260+ 'filename' : $j('#wpDestFile').val(),
 261+ 'comment' : $j('#wpUploadDescription').val(),
 262+ 'watch' : ( $j( '#wpWatchthis' ).is( ':checked' ) ) ? 'true' : 'false',
 263+ 'ignorewarnings': ($j('#wpIgnoreWarning' ).is( ':checked' ) ) ? 'true' : 'false'
 264+ }
 265+ }
 266+ } );
 267+ // Maybe set loading to spinner
 268+ } );
 269+
 270+ // Overwide the form submit:
 271+ $j( '#suf_upload' ).submit( function(){
 272+ // Only support form submit via button click
 273+ return false;
 274+ });
 275+
 276+
 277+ });
251278 }
252279 /**
253280 * Get a provider upload links for local upload and remote
254281 */
255 - function getProviderUploadLinks( uploadTargetId ){
 282+ function getProviderUploadLinks( uploadTargetId ){
 283+ // Setup local pointers:
 284+ var _this = this
256285 var uploadProvider = remoteSearchDriver.getUploadTargets()[ uploadTargetId ];
 286+ var searchProvider = remoteSearchDriver.content_providers[ uploadTargetId ];
 287+
257288 var apiUrl = uploadProvider.apiUrl;
258289 $uploadLinks = $j( '<div />' );
259290
@@ -272,19 +303,31 @@
273304 gM( 'mwe-upload-own-file', uploadProvider.title )
274305 )
275306 .click( function( ) {
276 - $j( uploadMenuTarget ).empty().loadingSpinner();
 307+ $j( uploadMenuTarget ).empty().loadingSpinner();
 308+
 309+ // if selectUploadProviderCb is set run the callback
 310+ if( selectUploadProviderCb ){
 311+ selectUploadProviderCb( uploadProvider )
 312+ }
 313+
277314 // Do upload form
278315 mw.UploadForm.getForm( {
279316 "target" : uploadMenuTarget,
280 - "api_target" : apiUrl,
281 - "ondone_callback" : function( resultData ) {
282 - var wTitle = resultData['filename'];
283 - // Add a loading div
 317+ "apiUrl" : apiUrl,
 318+ "doneUploadCb" : function( resultData ) {
 319+ if( !resultData || ! resultData.upload || ! resultData.upload['filename']){
 320+ mw.log( "Error in upload form no upload data in done Upload callback ");
 321+ return false;
 322+ }
 323+ var wTitle = resultData.upload['filename'];
 324+ mw.log( 'uploadForm: doneUploadCb : '+ wTitle);
 325+ // Add the resource editor interface with loaders:
284326 remoteSearchDriver.addResourceEditLoader();
 327+
285328 //Add the uploaded result
286 - provider.sObj.addByTitle( wTitle, function( resource ) {
287 - // Redraw ( with added result if new )
288 - remoteSearchDriver.showResults();
 329+ searchProvider.sObj.addByTitle( wTitle, function( resource ) {
 330+ // Update the recent uploads ( background task )
 331+ remoteSearchDriver.showUserRecentUploads( uploadTargetId );
289332 // Pull up resource editor:
290333 remoteSearchDriver.showResourceEditor( resource );
291334 } );
@@ -302,7 +345,7 @@
303346 $j('<li />').append(
304347 $j( '<a />' )
305348 .attr( {
306 - 'href' : uploadProvider.uploadPage,
 349+ 'href' : '#',
307350 'target' : '_new'
308351 } )
309352 .text(
@@ -313,6 +356,15 @@
314357 gM( "mwe-upload-once-done",
315358 $j('<a />')
316359 .attr( {
 360+ 'href' : uploadProvider.uploadPage,
 361+ 'target' : "_new"
 362+ } )
 363+ .text(
 364+ gM("mwe-upload-in-new-win-link")
 365+ ),
 366+
 367+ $j('<a />')
 368+ .attr( {
317369 'href' : '#'
318370 } )
319371 .addClass('user-upload-refresh')
@@ -326,10 +378,8 @@
327379 $j( uploadMenuTarget ).find( '.user-upload-refresh' )
328380 .click( function( ) {
329381 remoteSearchDriver.showUserRecentUploads( uploadTargetId );
330 - } );
331 -
332 - // Follow the link to open a new tab
333 - return true;
 382+ return false;
 383+ } );
334384 } )
335385 )
336386 );
@@ -352,7 +402,7 @@
353403 'id' : "suf_upload",
354404 'name' : "suf_upload",
355405 'enctype' : "multipart/form-data",
356 - 'action' : options.api_target,
 406+ 'action' : options.apiUrl,
357407 'method' : "post"
358408 } )
359409 );
@@ -380,7 +430,7 @@
381431 .attr( {
382432 'type' : "hidden",
383433 'id' : "wpEditToken",
384 - 'name' : "wpEditToken",
 434+ 'name' : "token",
385435 'value' : options.eToken
386436 })
387437 )
@@ -396,7 +446,7 @@
397447 );
398448
399449 // Output the upload file button ( check for cross domain )
400 - if( mw.isLocalDomain( options.api_target ) ) {
 450+ if( mw.isLocalDomain( options.apiUrl ) ) {
401451 $uploadForm.append(
402452 $j( '<input />')
403453 .attr( {
@@ -405,7 +455,9 @@
406456 'name' : "wpUploadFile",
407457 'size' : "15"
408458 } )
409 - .css( 'display', 'inline' )
 459+ .css( 'display', 'inline' ),
 460+
 461+ $j( '<br />' )
410462 );
411463 } else {
412464 /**
@@ -417,16 +469,9 @@
418470 $j( '<div />' )
419471 .addClass( 'remote-browse-file' )
420472 .loadingSpinner()
421 - )
422 - setupApiFileBrowseProxy(
423 - $uploadForm.find('.remote-browse-file' ),
424 - options
425 - );
426 - }
 473+ );
 474+ }
427475
428 - // Add firefogg warning
429 -
430 -
431476 // Add destination fileName
432477 $uploadForm.append(
433478 $j( '<label />' ).attr({
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js
@@ -36,14 +36,16 @@
3737 "mwe-missing_desc_see_source" : "This asset is missing a description. Please see the $1 and help describe it.",
3838
3939 "rsd_config_error" : "Add media wizard configuration error: $1",
40 - "mwe-your_recent_uploads" : "Your recent uploads to $1",
 40+ "mwe-your-recent-uploads" : "Your recent uploads to $1",
4141 "mwe-no_recent_uploads" : "No recent uploads",
4242
4343 "mwe-not-logged-in-uploads" : "You may not be logged in so no recent uploads can be displayed. $1 login and $2",
4444 "mwe-loggin-link" : "Please login",
4545 "mwe-try-again-link" : "try again",
4646
47 - "mwe-upload_a_file" : "Upload a new file",
 47+ "mwe-upload-a-file" : "Upload a new file",
 48+ "mwe-upload-a-file-to" : "Upload a new file to $1",
 49+
4850 "mwe-resource_page_desc" : "Resource page description:",
4951 "mwe-edit_resource_desc" : "Edit wiki text resource description:",
5052 "mwe-local_resource_title" : "Local resource title:",
@@ -1038,12 +1040,16 @@
10391041 // Set the tab container to loading:
10401042 this.$resultsContainer.loadingSpinner();
10411043
1042 - //Show the upload form
1043 - mw.load( ['mw.UploadForm'], function() {
1044 - var provider = _this.content_providers[ 'this_wiki' ];
1045 - // Load this_wiki search system to grab the resource
1046 - _this.loadSearchLib( provider, function() {
1047 - _this.showUploadForm( provider );
 1044+ // Show the upload form (use the standard module AddMedia.firefogg
 1045+ // This way we get a high cache hit rate by using a general module
 1046+ // and not grouping mw.UploadForm into the upload code set
 1047+ mw.load( 'AddMedia.firefogg', function() {
 1048+ mw.load( 'mw.UploadForm', function() {
 1049+ var provider = _this.content_providers[ 'this_wiki' ];
 1050+ // Load this_wiki search system to grab the resource
 1051+ _this.loadSearchLib( provider, function() {
 1052+ _this.showUploadForm( provider );
 1053+ } );
10481054 } );
10491055 } );
10501056 },
@@ -1067,7 +1073,8 @@
10681074 })
10691075 .append(
10701076 $j('<h3 />')
1071 - .text( gM( 'mwe-upload_a_file' ) ),
 1077+ .addClass( 'upload-a-file-msg' )
 1078+ .text( gM( 'mwe-upload-a-file' ) ),
10721079
10731080 $j('<div />').attr({
10741081 'id': 'rsd_upload_form'
@@ -1093,7 +1100,12 @@
10941101 mw.UploadForm.getUploadMenu( {
10951102 'target': '#rsd_upload_form',
10961103 'uploadTargets' : _this.getUploadTargets(),
1097 - 'remoteSearchDriver' : this
 1104+ 'remoteSearchDriver' : this,
 1105+ 'selectUploadProviderCb' : function( uploadProvider ){
 1106+ _this.$resultsContainer.find( '.upload-a-file-msg' ).html(
 1107+ gM( 'mwe-upload-a-file-to', uploadProvider.title )
 1108+ );
 1109+ }
10981110 } );
10991111 },
11001112
@@ -1113,13 +1125,12 @@
11141126 $j( target ).append(
11151127 $j( '<h3 />' )
11161128 .append(
1117 - gM( 'mwe-your_recent_uploads', uploadTarget.title )
 1129+ gM( 'mwe-your-recent-uploads', uploadTarget.title )
11181130 ),
11191131
11201132 // Add the targetUpload container
11211133 $j('<div />')
1122 - .attr( 'id', 'user-results-' + uploadTargetId )
1123 - .loadingSpinner()
 1134+ .attr( 'id', 'user-results-' + uploadTargetId )
11241135 )
11251136 // Issue the call to get the recent uploads:
11261137 _this.showUserRecentUploads( uploadTargetId );
@@ -1132,32 +1143,17 @@
11331144 var provider = _this.content_providers[ uploadTargetId ];
11341145 var uploadTargets = _this.getUploadTargets();
11351146 var uploadApiUrl = uploadTargets[ uploadTargetId ].apiUrl ;
1136 -
 1147+
 1148+ // Set the target to a loadingSpinner
 1149+ $j('#user-results-' + uploadTargetId ).loadingSpinner();
 1150+
11371151 // If the target is not local or we don't have a userName
11381152 // ( try and grab the user name via api call (will be a proxy call if remote) )
1139 - if( ! mw.isLocalDomain( uploadApiUrl ) ) {
1140 - // Garb the userName via api call
1141 - var request = {
1142 - 'action':'query',
1143 - 'meta':'userinfo'
1144 - }
1145 - // Do request ( will automatically invoke proxy because its a proxy action and remote url )
1146 - mw.getJSON( uploadApiUrl, request, function( data ){
1147 - // Now we get the data back for that domain
1148 - if( !data || !data.query || !data.query.userinfo ){
1149 - // Could not get user name user is not-logge
1150 - mw.log( " No user data in resposne " );
1151 - return false;
1152 - }
1153 - var userName = data.query.userinfo.name;
1154 - _this.showUserRecentUploadsWithUser( uploadTargetId, userName );
1155 -
1156 - },
1157 - // Add a timeout function for getting the user-name
1158 - function( ) {
 1153+ mw.getUserName( uploadApiUrl, function( userName ) {
 1154+ if( userName === false ){
11591155 var logInLink = uploadApiUrl.replace( 'api.php', 'index.php' ) + '?title=Special:UserLogin';
11601156 // Timed out or proxy not setup ( for remotes )
1161 - $j( '#user-results-' + uploadTargetId ).html(
 1157+ $j( '#user-results-' + uploadTargetId ).html(
11621158 gM( "mwe-not-logged-in-uploads",
11631159 $j( '<a />' )
11641160 .attr( {
@@ -1179,19 +1175,15 @@
11801176 $j( '#user-results-' + uploadTargetId )
11811177 .find( '.try-again' )
11821178 .click(function(){
1183 - //Refresh the user uploads
 1179+ mw.log(" try again:: " + uploadTargetId);
 1180+ $j( '#user-results-' + uploadTargetId ).empty().loadingSpinner();
 1181+ // Refresh the user uploads
11841182 _this.showUserRecentUploads( uploadTargetId );
11851183 })
1186 - } );
1187 - } else {
1188 - // No user name, since every page outputs wgUserName assume the user is not logged in )
1189 - if( !wgUserName ) {
1190 - $j( '#user-results-' + uploadTargetId )
1191 - .text( gM( 'mwe-not-logged-in-uploads' ) );
1192 - }else{
1193 - _this.showUserRecentUploadsWithUser( uploadTargetId, wgUserName );
 1184+ } else {
 1185+ _this.showUserRecentUploadsWithUser( uploadTargetId, userName );
11941186 }
1195 - }
 1187+ } );
11961188 },
11971189
11981190 showUserRecentUploadsWithUser: function( uploadTargetId, userId ){
@@ -1269,7 +1261,8 @@
12701262 mw.parseUri( thisWikiProvider.apiUrl ).host,
12711263 $j( '<a />' )
12721264 .attr( {
1273 - 'href' : $uploadLink.attr('href')
 1265+ 'href' : $uploadLink.attr('href'),
 1266+ 'target' : '_new'
12741267 } )
12751268 .text( gM('mwe-local-upload-policy-link') )
12761269 ),
@@ -1286,7 +1279,7 @@
12871280 */
12881281 updateResults: function() {
12891282 if ( this.current_provider == 'upload' ) {
1290 - this.updateUploadResults();
 1283+ this.showUploadTab();
12911284 } else {
12921285 this.updateSearchResults( this.current_provider, false );
12931286 }
@@ -1509,17 +1502,18 @@
15101503 _this.currentRequest = context();
15111504 mw.log( "ProviderCallBack Generated " + context() )
15121505 provider.sObj.getSearchResults( $j( '#rsd_q' ).val() ,
1513 - function( resultStatus ) {
1514 - mw.log( "ProviderCallBack Received " + context() );
1515 - if( _this.currentRequest != context() ) {
1516 - mw.log( "Context mismatch for request " + _this.currentRequest + ' != ' + context );
1517 - // do not update the results this.currentRequest
1518 - // does not match the interface request state.
1519 - return false;
1520 - }
1521 - //else update search results
1522 - _this.showResults();
1523 - });
 1506+ function( resultStatus ) {
 1507+ mw.log( "ProviderCallBack Received " + context() );
 1508+ if( _this.currentRequest != context() ) {
 1509+ mw.log( "Context mismatch for request " + _this.currentRequest + ' != ' + context );
 1510+ // do not update the results this.currentRequest
 1511+ // does not match the interface request state.
 1512+ return false;
 1513+ }
 1514+ //else update search results
 1515+ _this.showResults();
 1516+ }
 1517+ );
15241518
15251519 // Set a timeout of 20 seconds
15261520 setTimeout( function() {
@@ -1693,9 +1687,16 @@
16941688 // Add "no search results" text
16951689 $j( '#rsd_no_search_res' ).remove();
16961690 if ( numResults == 0 ) {
1697 - $resultsContainer.append(
1698 - gM( 'rsd_no_results', $j( '#rsd_q' ).val() )
1699 - )
 1691+ // NOTE: we should handle no-results with a callback not with condition check
 1692+ if( _this.current_provider == 'upload' ) {
 1693+ $resultsContainer.append(
 1694+ gM( 'mwe-no_recent_uploads' )
 1695+ );
 1696+ } else {
 1697+ $resultsContainer.append(
 1698+ gM( 'rsd_no_results', $j( '#rsd_q' ).val() )
 1699+ ) ;
 1700+ }
17001701 }
17011702 this.addResultBindings();
17021703 },
@@ -2697,7 +2698,7 @@
26982699 // ( mvBaseUploadInterface handles upload errors )
26992700 var uploader = new mw.BaseUploadInterface( {
27002701 'apiUrl' : _this.upload_api_target,
2701 - 'done_upload_cb':function() {
 2702+ 'doneUploadCb': function() {
27022703 mw.log( 'doApiImport:: run callback::' );
27032704 // We have finished the upload:
27042705
Index: branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/mw.ApiProxy.js
@@ -69,7 +69,7 @@
7070 }
7171
7272 // Generate a new context object: (its oky that optional arguments are null )
73 - var context = getNewContext({
 73+ var context = createContext({
7474 'apiUrl' : apiUrl,// currentServerApiUrl
7575 'apiReq' : requestQuery,
7676 'callback' : callback,
@@ -97,15 +97,42 @@
9898 mw.log( "Error: no target for file browse iframe" ) ;
9999 return false;
100100 }
 101+
 102+ if( !options.token ){
 103+ mw.log( "Error: no token for file browse ");
 104+ return false;
 105+ }
 106+
 107+ mw.log( "browseFile:: " + $j(options.target).length );
 108+
 109+ mw.log( "BROWSE FILE:: cb: " + options.doneUploadCb);
 110+
101111 if( ! options.apiUrl ) {
102112 mw.log( "Error: no api url to target" );
103113 return false;
104114 }
 115+ mw.log( 'Setup uploadDialogInterface' );
105116
106 - // Setup the context with the callback
107 - var context = getNewContext({
 117+ // Make sure we have the dialog interface:
 118+ var uploadDialogInterface = new mw.UploadDialogInterface( {
 119+ 'uploadHandlerAction' : function( action ){
 120+ mw.log( 'apiProxy uploadActionHandler:: ' + action );
 121+ // Send action to remote frame
 122+ mw.ApiProxy.sendServerMsg( {
 123+ 'apiUrl' : options.apiUrl,
 124+ 'frameName' : iFrameName,
 125+ 'frameMsg' : {
 126+ 'action' : 'uploadHandlerAction',
 127+ 'uiAction' : action
 128+ }
 129+ } );
 130+ }
 131+ } );
 132+
 133+ // Setup the context with the callback in the current closure
 134+ var context = createContext({
108135 'apiUrl' : options.apiUrl,
109 - // Setup the proxy scope callback to display the upload unhide the iframe upload form
 136+ // Setup the callback to process iframeData
110137 'callback' : function( iframeData ) {
111138 // Process fileBrowse callbacks ::
112139
@@ -117,17 +144,28 @@
118145 $j( '#' + iFrameName ).fadeIn( 'fast' );
119146 return ;
120147 }
 148+ mw.log( '~browseFile Callback~ event type: ' + iframeData['event'] );
121149
122150 // Else check for event
123151 if( iframeData['event'] ) {
124152 switch( iframeData['event'] ) {
125153 case 'selectFileCb':
126154 if( options.selectFileCb ) {
127 - options.selectFileCb( iframeData['fileName'] );
 155+ options.selectFileCb( iframeData[ 'fileName' ] );
128156 }
129157 break
 158+ // Set the doneUploadCb if set in the browseFile options
 159+ case 'doneUploadCb':
 160+ mw.log( "should call cb: " + options.doneUploadCb );
 161+ if( options.doneUploadCb ) {
 162+ options.doneUploadCb( iframeData[ 'apiResult' ] );
 163+ return true;
 164+ }else{
 165+ return false;
 166+ }
 167+ break;
130168 case 'uploadUI':
131 - if( uploadDialogInterface[ iframeData['method'] ] ){
 169+ if( uploadDialogInterface[ iframeData[ 'method' ] ] ){
132170 var args = iframeData['arguments'];
133171 mw.log( "Do dialog interface: " + iframeData['method'] + ' args: ' + args[0] + ', ' + args[1] + ', ' + args[2] );
134172 uploadDialogInterface[ iframeData['method'] ](
@@ -142,10 +180,6 @@
143181 }
144182 });
145183
146 -
147 - // Update the current apiUrl:
148 - context[ 'apiUrl' ] = options.apiUrl;
149 -
150184 // Setup the default width and height:
151185 if( ! options.width ) {
152186 options.width = 270;
@@ -156,9 +190,10 @@
157191
158192 var iFrameName = ( options.iframeName ) ? options.iframeName : 'fileBrowse_' + $j('iframe').length;
159193 // Setup an object to be packaged into the frame
160 - var iFrameRequest ={
 194+ var iFrameRequest = {
161195 'clientFrame' : getClientFrame( context ),
162 - 'action' : 'browseFile'
 196+ 'action' : 'browseFile',
 197+ 'token' : options.token
163198 };
164199
165200 var frameStyle = 'display:none;border:none;overflow:hidden;'
@@ -168,7 +203,13 @@
169204 // Empty the target ( so that the iframe can be put there )
170205 $j( options.target ).empty();
171206
172 - // Append the browseFile iframe to the target:
 207+ mw.log( 'append spinner');
 208+ // Add a loading spinner to the target
 209+ $j( options.target ).append(
 210+ $j( '<div />' ).loadingSpinner()
 211+ );
 212+
 213+ // Append the browseFile iframe to the target:
173214 appendIframe( {
174215 'context' : context,
175216 'persist' : true,
@@ -176,29 +217,6 @@
177218 'name' : iFrameName,
178219 'request' : iFrameRequest,
179220 'target' : options.target
180 - } );
181 -
182 - // Add a loading spinner to the target
183 - $j( options.target ).append(
184 - $j( '<div />' ).loadingSpinner()
185 - );
186 -
187 - // Make sure we have the dialog interface:
188 - mw.load( 'mw.UploadInterface', function(){
189 - var uploadDialogInterface = new mw.UploadDialogInterface( {
190 - 'uploadHandlerAction' : function( action ){
191 - mw.log( 'apiProxy uploadActionHandler:: ' + action );
192 - // Send action to remote frame
193 - mw.ApiProxy.sendServerMsg( {
194 - 'apiUrl' : options.apiUrl,
195 - 'frameName' : iFrameName,
196 - 'frameMsg' : {
197 - 'action' : 'uploadHandlerAction',
198 - 'uiAction' : action
199 - }
200 - } );
201 - }
202 - } );
203221 } );
204222
205223 // Return the name of the browseFile frame
@@ -221,7 +239,7 @@
222240 }
223241
224242 //Setup a new context
225 - var context = getNewContext({
 243+ var context = createContext({
226244 'apiUrl' : options.apiUrl
227245 });
228246
@@ -271,20 +289,21 @@
272290 }
273291
274292 // Get the context via contextKey
275 - var context = getContext( resultObject.contextKey );
 293+ var context = getContext( resultObject.contextKey );
276294
277295 // Set the loaded flag to true. ( avoids timeout calls )
278296 context[ 'proxyLoaded' ] = true;
279297
280 - // Special callback to frameProxyOk flag
281 - // (only used to quickly test the proxy connection)
 298+ // Special callback to quickly establish a valid proxy connection.
 299+ // If the proxyed "request" takes more time it does not
 300+ // count against the proxy connection being established.
282301 if ( resultObject.state == 'ok' ) {
283302 return ;
284303 }
285304
286305 // Check for the context callback:
287 - if( context ['callback'] ){
288 - context ['callback']( resultObject );
 306+ if( context.callback ){
 307+ context.callback( resultObject );
289308 }
290309 }
291310
@@ -332,35 +351,35 @@
333352 */
334353
335354 /**
336 - * Get new context (creates a new context and stores it in the proxyContext local global
 355+ * Creates a new context stored in the proxyContext local global
337356 * @param {Object} contextVars Initial contextVars
338357 */
339 - function getNewContext ( contextVars ) {
 358+ function createContext ( contextVars ) {
340359 // Create a ~ sufficently ~ unique context key
341360 var contextKey = new Date().getTime() * Math.random();
342361 proxyContext [ contextKey ] = contextVars;
343362
344363 // Setup the proxy loaded flag for this context:
345 - proxyContext[ contextKey ][ 'proxyLoaded' ] = false; // frameProxyOk
 364+ proxyContext[ contextKey ][ 'proxyLoaded' ] = false;
346365
347366 // Set a local pointer to the contextKey
348367 proxyContext[ contextKey ]['contextKey' ] = contextKey;
349368
 369+ mw.log( "created context with key:" + contextKey );
 370+
350371 // Return the proxy context
351372 return proxyContext [ contextKey ];
352373 }
353374
354375 /**
355376 * Get a context from a contextKey
356 - * @param {String} contextKey Key of the context object to be returned
 377+ * @param {String} [optional] contextKey Key of the context object to be returned
357378 * @return context object
358379 * false if context object can not be found
359380 */
360 - function getContext ( contextKey ){
 381+ function getContext ( contextKey ){
361382 if( ! proxyContext [ contextKey ] ){
362383 mw.log( "Error: contextKey not found:: " + contextKey );
363 - var cat = proxyContext;
364 - debugger;
365384 return false;
366385 }
367386 return proxyContext [ contextKey ];;
@@ -396,7 +415,7 @@
397416 //var gadgetWithJS = '?withJS=MediaWiki:Gadget-mwEmbed.js';
398417 var gadgetWithJS = '';
399418 function getServerFrame( context ) {
400 - if( ! context.apiUrl ){
 419+ if( ! context || ! context.apiUrl ){
401420 mw.log( "Error no context api url " );
402421 return false;
403422 }
@@ -408,7 +427,7 @@
409428
410429 /**
411430 * Do the frame proxy
412 - * Writes an iframe with a hashed value of the requestQuery
 431+ * Sets up a frame proxy request
413432 *
414433 * @param {Object} context ( the context of the current doFrameProxy call )
415434 * @param {Object} requestQuery The api request object
@@ -512,6 +531,7 @@
513532 * @param {Object} context
514533 */
515534 function proxyNotReadyTimeout( context ) {
 535+ mw.log( 'proxyNotReadyTimeout::' + context[ 'timeoutCb' ]);
516536
517537 // See if we have a callback function to call ( do not display the dialog )
518538 if( context[ 'timeoutCb' ] && typeof context[ 'timeoutCb' ] == 'function' ) {
@@ -521,16 +541,16 @@
522542
523543 var buttons = { };
524544 buttons[ gM( 'mwe-re-try' ) ] = function() {
525 - mw.addLoaderDialog( gM( 'mwe-re-trying' ) );
 545+ mw.addLoaderDialog( gM( 'mwe-re-trying' ) );
526546 // Re try the same context request:
527 - doFrameProxy( context );
 547+ doFrameProxy( context );
528548 }
529549 buttons[ gM( 'mwe-cancel' ) ] = function() {
530550 mw.closeLoaderDialog();
531551 }
532552
533553 // Setup the login link:
534 - var pUri = mw.parseUri( getServerFrame() );
 554+ var pUri = mw.parseUri( getServerFrame( context ) );
535555 var login_url = pUri.protocol + '://' + pUri.host;
536556 login_url += pUri.path.replace( 'MediaWiki:ApiProxy', 'Special:UserLogin' );
537557
@@ -604,10 +624,11 @@
605625 clientRequest.request[ 'format' ] = 'json';
606626
607627 mw.log(" do post request to: " + wgScriptPath + '/api' + wgScriptExtension );
608 -
 628+ /*
609629 for( var i in clientRequest.request ) {
610630 mw.log("req: " + i + " = " + clientRequest.request[i] );
611631 }
 632+ */
612633
613634 // Process the API request. We don't use mw.getJSON since we need to "post"
614635 $j.post( wgScriptPath + '/api' + wgScriptExtension,
@@ -683,12 +704,19 @@
684705 * @return browse file config
685706 */
686707 function serverBrowseFileSetup( ){
687 - // Get the proxy config
688 - var proxyConfig = mw.getConfig( 'apiProxyConfig' );
689 - //check for fw ( file width )
690 - if( ! proxyConfig.fileWidth ) {
691 - proxyConfig.fileWidth = 130;
 708+ // Get the client request config
 709+ var clientRequest = getClientRequest();
 710+
 711+ // Check for fw ( file width )
 712+ if( ! clientRequest.fileWidth ) {
 713+ clientRequest.fileWidth = 130;
692714 }
 715+ // Check for the token
 716+ if( ! clientRequest.token ){
 717+ mw.log("Error server browse file setup without token")
 718+ return false;
 719+ }
 720+
693721 //Build a form with bindings similar to uploadPage.js ( but only the browse button )
694722 $j('body').html(
695723 $j('<form />')
@@ -701,7 +729,7 @@
702730 'action' : mw.getLocalApiUrl()
703731 } )
704732 .append(
705 - //Add a single "browse for file" button
 733+ //Add the "browse for file" button
706734 $j('<input />')
707735 .attr({
708736 'type' : "file",
@@ -709,8 +737,17 @@
710738 'id' : "wpUploadFile"
711739 })
712740 .css({
713 - 'width' : proxyConfig.fileWidth
 741+ 'width' : clientRequest.fileWidth
 742+ }),
 743+
 744+ // Append the token
 745+ $j('<input />')
 746+ .attr({
 747+ 'type' : 'hidden',
 748+ 'id' : "wpEditToken",
 749+ 'name' : 'token',
714750 })
 751+ .val( clientRequest.token )
715752 )
716753 );
717754 }
@@ -718,7 +755,9 @@
719756 /**
720757 * Browse file upload config generator
721758 */
722 - function getUploadFileConfig(){
 759+ function getUploadFileConfig(){
 760+
 761+ // Setup the upload iframeUI
723762 var uploadIframeUI = new mw.UploadIframeUI( function( method ){
724763 // Get all the arguments after the "method"
725764 var args = $j.makeArray( arguments ).splice( 1 );
@@ -741,8 +780,16 @@
742781 'event': 'selectFileCb',
743782 'fileName' : fileName
744783 } );
745 - }
746 - }
 784+ },
 785+ // Set the doneUploadCb if set in the browseFile options
 786+ 'doneUploadCb' : function ( apiResult ){
 787+ sendClientMsg( {
 788+ 'event': 'doneUploadCb',
 789+ 'apiResult' : apiResult
 790+ } );
 791+ }
 792+ }
 793+
747794 return uploadConfig;
748795 }
749796
@@ -751,7 +798,7 @@
752799 */
753800 function serverSendUploadHandlerAction( action ) {
754801 // Get a refrence to the uploadHandler:
755 - // NOTE: this should not be hard-coded
 802+ // NOTE: both firefogg and upload form should save upload target in a similar way
756803 var selector = ( wgEnableFirefogg ) ? '#wpUploadFile' : '#mw-upload-form';
757804 var uploadHandler = $j( selector ).get(0).uploadHandler;
758805 if( uploadHandler ){
@@ -766,38 +813,28 @@
767814 * @param {Object} options Options for submiting file
768815 */
769816 function serverSubmitFile( formData ){
 817+ mw.log("Submit form with fname:" + formData.filename + "\n :: " + formData.comment)
770818 // Add the FileName and and the description to the form
771819 var $form = $j('#mw-upload-form');
772 - // Add the filename and description if missing
773 - if( ! $form.find("[name='filename']").length ){
774 - $form.append(
775 - $j( '<input />' )
776 - .attr( {
777 - 'id' : 'wpDestFile',
778 - 'name' : 'filename',
779 - 'type' : 'hidden'
780 - } )
781 - );
782 - }
783 - if( ! $form.find("[name='description']").length ){
784 - $form.append(
785 - $j( '<input />' )
786 - .attr( {
787 - 'id' : 'wpUploadDescription',
788 - 'name' : 'comment',
789 - 'type' : 'hidden'
790 - } )
791 - );
792 - }
793 -
794 - // Update filename and description ( if set )
795 - if( formData.filename ) {
796 - $form.find( "[name='filename']" ).val( formData.filename )
797 - }
798 - if( formData.description ) {
799 - $form.find( "[name='description']" ).val( formData.description )
800 - }
 820+ var formApiFields = [ 'filename', 'comment', 'watch', 'ignorewarnings', 'token' ];
801821
 822+ for( var i=0; i < formApiFields.length ; i++ ){
 823+ var fieldName = formApiFields[ i ];
 824+ if( typeof formData[ fieldName ] == 'string' ) {
 825+ // Add the input field if not already there:
 826+ if( ! $form.find("[name='" + fieldName + "']" ).length ){
 827+ $form.append(
 828+ $j( '<input />' )
 829+ .attr( {
 830+ 'name' : fieldName,
 831+ 'type' : 'hidden'
 832+ } )
 833+ )
 834+ }
 835+ // Add the value if set:
 836+ $form.find("[name='" + fieldName + "']" ).val( formData[ fieldName ] );
 837+ }
 838+ }
802839 // Do submit the form
803840 $form.submit();
804841 };
@@ -854,9 +891,10 @@
855892 * persist - set to true if the iframe should not
856893 * be removed from the dom after its done loading
857894 */
858 - function appendIframe( options ){
859 - var s = '<iframe ';
860 -
 895+ function appendIframe( options ){
 896+
 897+
 898+ var s = '<iframe ';
861899 // check for context
862900 if( ! options[ 'context' ] ) {
863901 mw.log("Error missing context");
@@ -873,7 +911,8 @@
874912 if( ! options[ 'name' ] ) {
875913 options[ 'name' ] = 'mwApiProxyFrame_' + $j('iframe').length;
876914 }
877 -
 915+
 916+
878917 // Add the frame name / id:
879918 s += 'name="' + mw.escapeQuotes( options[ 'name' ] ) + '" ';
880919 s += 'id="' + mw.escapeQuotes( options[ 'name' ] ) + '" ';
@@ -906,14 +945,14 @@
907946 if( ! options[ 'target' ] ){
908947 options[ 'target' ] = 'body';
909948 }
910 -
 949+ var nameTarget = ( typeof options[ 'target' ] == 'string') ? options[ 'target' ] : $j( options[ 'target' ]).length ;
 950+ mw.log( "Append iframe:" + options[ 'name' ] + ' to: ' + nameTarget);
911951 // Append to target
912952 $j( options['target'] ).append( s );
913953
914954 // Setup the onload callback
915 - $j( '#' + options['name'] ).get( 0 ).onload = function() {
 955+ $j( '#' + options['name'] ).get( 0 ).onload = function() {
916956 if( ! options.persist ){
917 -
918957 // Schedule the removal of the iframe
919958 // We don't call it directly since some browsers seem to call "ready"
920959 // before blocking code is done running
@@ -921,15 +960,15 @@
922961 $j('#' + options[ 'name' ] ).remove();
923962 }, 10 );
924963 }
925 - // Setupt the timeout check:
926 - setTimeout( function() {
927 - if ( context[ 'frameProxyOk'] ) {
928 - // We timed out no api proxy (should make sure the user is "logged in")
929 - mw.log( "Error:: api proxy timeout are we logged in? mwEmbed is on?" );
930 - proxyNotReadyTimeout( context );
931 - }
932 - }, mw.getConfig( 'defaultRequestTimeout') * 1000 );
933 - };
 964+ };
 965+ // Setupt the timeout check:
 966+ setTimeout( function() {
 967+ if ( context[ 'proxyLoaded'] === false ) {
 968+ // We timed out no api proxy (should make sure the user is "logged in")
 969+ mw.log( "Error:: api proxy timeout" + context.contextKey );
 970+ proxyNotReadyTimeout( context );
 971+ }
 972+ }, mw.getConfig( 'defaultRequestTimeout') * 1000 );
934973 }
935974
936975 } )( window.mw.ApiProxy );
Index: branches/js2-work/phase3/js/mwEmbed/modules/ClipEdit/mw.ClipEdit.js
@@ -772,6 +772,7 @@
773773 $j( '#mw_layout_right' )[0].checked = false;
774774 $j( '#mw_layout_left' )[0].checked = true;
775775 _this.resource.layout = 'left';
 776+ return true;
776777 } );
777778
778779 // Right radio click
@@ -779,6 +780,7 @@
780781 $j( '#mw_layout_left' )[0].checked = false;
781782 $j( '#mw_layout_right' )[0].checked = true;
782783 _this.resource.layout = 'right';
 784+ return true;
783785 } );
784786 break;
785787 case 'crop':
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js
@@ -1380,8 +1380,7 @@
13811381 * @param {Mixed} data or callback
13821382 * @param {Function} callbcak function called on success
13831383 * @param {Function} callbackTimeout - optional function called on timeout
1384 - * Setting timeout callback also avoids dialog display for timed out proxy calls.
1385 - *
 1384+ * Setting timeout callback also avoids default dialog display for timed-out proxy calls.
13861385 */
13871386 mw.getJSON = function() {
13881387 // Set up the url
@@ -1425,10 +1424,15 @@
14261425 data['format'] = 'json';
14271426 }
14281427
1429 - // Setup callback wrapper for timeout
 1428+ // Setup callback wrapper for timeout
14301429 var requestTimeOutFlag = false;
14311430 var ranCallback = false;
1432 - var myCallback = function( data ){
 1431+
 1432+ /**
 1433+ * local callback function to control timeout
 1434+ * @param {Object} data Result data
 1435+ */
 1436+ var myCallback = function( data ){
14331437 if( ! requestTimeOutFlag ){
14341438 ranCallback = true;
14351439 callback( data );
@@ -1436,25 +1440,33 @@
14371441 }
14381442 // Set the local timeout call based on defaultRequestTimeout
14391443 setTimeout( function( ) {
1440 - if( ! ranCallback ){
 1444+ if( ! ranCallback ) {
14411445 requestTimeOutFlag = true;
1442 - mw.log( "Error:: request timed out: " + url ) ;
1443 - if( timeoutCallback ) {
 1446+ mw.log( "Error:: request timed out: " + url ) ;
 1447+ if( timeoutCallback ){
14441448 timeoutCallback();
14451449 }
14461450 }
14471451 }, mw.getConfig( 'defaultRequestTimeout' ) * 1000 );
14481452
1449 - mw.log("run getJSON: " + mw.replaceUrlParams( url, data ) );
 1453+ mw.log("run getJSON: " + mw.replaceUrlParams( url, data ) );
 1454+
14501455 // Check if the request requires a "post"
14511456 if( mw.checkRequestPost( data ) ) {
 1457+
14521458 // Check if we need to setup a proxy
14531459 if( ! mw.isLocalDomain( url ) ) {
 1460+
 1461+ //Set local scope ranCallback to true
 1462+ // ( ApiProxy handles timeouts internnaly )
 1463+ ranCallback = true;
 1464+
14541465 // Load the proxy and issue the request
1455 - mw.load( 'ApiProxy', function() {
1456 - mw.ApiProxy.doRequest( url, data, myCallback, timeoutCallback);
 1466+ mw.load( 'ApiProxy', function() {
 1467+ mw.ApiProxy.doRequest( url, data, callback, timeoutCallback);
14571468 });
1458 - }else{
 1469+
 1470+ } else {
14591471 // Do the request an ajax post
14601472 $j.post( url, data, myCallback, 'json');
14611473 }
@@ -1509,11 +1521,11 @@
15101522 }
15111523
15121524 /**
1513 - * Simple api helper to grab an edit token
 1525+ * Api helper to grab an edit token
15141526 *
15151527 * @param {String} [apiUrl] Optional target API URL (uses default local api if unset)
15161528 * @param {String} title The wiki page title you want to edit
1517 - * @param {callback} callback Function to pass the token to
 1529+ * @param {callback} callback Function to pass the token to returns false if token not retrived
15181530 */
15191531 mw.getToken = function( apiUrl, title, callback ) {
15201532 // Make the apiUrl be optional:
@@ -1533,23 +1545,69 @@
15341546 mw.getJSON( apiUrl, request, function( data ) {
15351547 for ( var i in data.query.pages ) {
15361548 if ( data.query.pages[i]['edittoken'] ) {
1537 - if ( typeof callback == 'function' )
1538 - callback ( data.query.pages[i]['edittoken'] );
 1549+ callback ( data.query.pages[i]['edittoken'] );
 1550+ return ;
15391551 }
15401552 }
15411553 // No token found:
1542 - return false;
 1554+ callback ( false );
15431555 } );
15441556 }
15451557
15461558 /**
 1559+ * Api helper to grab the username
 1560+ * @param {String} [apiUrl] Optional target API url (uses default local api if unset)
 1561+ * @param {Function} callback Function to callback with username or false if not found
 1562+ */
 1563+ mw.getUserName = function( apiUrl, callback ){
 1564+ if( typeof apiUrl == 'function' ){
 1565+ var callback = apiUrl;
 1566+ var apiUrl = mw.getLocalApiUrl();
 1567+ }
 1568+
 1569+ // If apiUrl is local check wgUserName global
 1570+ // before issuing the api request.
 1571+ if( mw.isLocalDomain( apiUrl ) ){
 1572+ if( typeof wgUserName != 'undefined' && wgUserName !== null ) {
 1573+ callback( wgUserName )
 1574+ return ;
 1575+ }
 1576+ }
 1577+
 1578+ // Setup the api request
 1579+ var request = {
 1580+ 'action':'query',
 1581+ 'meta':'userinfo'
 1582+ }
 1583+
 1584+ // Do request
 1585+ mw.getJSON( apiUrl, request, function( data ) {
 1586+ if( !data || !data.query || !data.query.userinfo || !data.query.userinfo.name ){
 1587+ // Could not get user name user is not-logged in
 1588+ mw.log( " No userName in response " );
 1589+ callback( false );
 1590+ return ;
 1591+ }
 1592+ // Check for "not logged in" id == 0
 1593+ if( data.query.userinfo.id == 0 ){
 1594+ callback( false );
 1595+ return ;
 1596+ }
 1597+ // Else return the username:
 1598+ callback( data.query.userinfo.name );
 1599+ }, function(){
 1600+ //Timeout also results in callback( false );
 1601+ callback( false );
 1602+ } );
 1603+ }
 1604+
 1605+ /**
15471606 * Utility Functions
15481607 */
15491608
15501609 /**
15511610 * addLoaderDialog
1552 - * small helper for putting a loading dialog box on top of everything
1553 - * (helps block for request that
 1611+ * small helper for displaying a loading dialog
15541612 *
15551613 * @param msg text text of the loader msg
15561614 */
@@ -1567,7 +1625,7 @@
15681626 /**
15691627 * Add a (temporary) dialog window:
15701628 * @param {String} title Title string for the dialog
1571 - * @param {String} msg_txt String to be inserted in msg box
 1629+ * @param {String} msg_html String to be inserted in msg box
15721630 * @param {Mixed} buttons A button object for the dialog
15731631 * Can be 'ok' for oky button.
15741632 */
Index: branches/js2-work/phase3/js/mwEmbed/remotes/mediaWiki.js
@@ -4,8 +4,8 @@
55 */
66 var urlparts = getRemoteEmbedPath();
77 var mwEmbedHostPath = urlparts[0];
8 -var mwRemoteVersion = 'r102';
9 -var mwUseScriptLoader = true;
 8+var mwRemoteVersion = 'r103';
 9+var mwUseScriptLoader = false;
1010
1111 // Log the mwRemote version ( will determine what version of js we get )
1212 if( window.console ){
@@ -32,10 +32,10 @@
3333 */
3434 function doPageSpecificRewrite() {
3535 // Deal with multiple doPageSpecificRewrite
36 - if( typeof window.ranRewrites != 'undefined'){
 36+ if( typeof window.ranMwRewrites != 'undefined'){
3737 return ;
3838 }
39 - window.ranRewrites = 'done';
 39+ window.ranMwRewrites = 'done';
4040
4141 // Add media wizard
4242 if ( wgAction == 'edit' || wgAction == 'submit' ) {
@@ -100,7 +100,7 @@
101101 if ( location.search.indexOf('uploadWizard=1') != -1 ) {
102102 scriptName = 'uploadWizard.js';
103103 }
104 - loadMwEmbed([
 104+ loadMwEmbed( [
105105 'mw.UploadHandler',
106106 'mw.UploadInterface',
107107 'mw.Firefogg',
Index: branches/js2-work/phase3/js/uploadPage.js
@@ -13,6 +13,8 @@
1414 if ( typeof wgEnableFirefogg == 'undefined' ){
1515 wgEnableFirefogg = true;
1616 }
 17+ // NOTE: we should unify upload handler call so we don't have to call firefogg and
 18+ // UploadHandler separately.
1719 if ( wgEnableFirefogg ) {
1820 mw.load( 'AddMedia.firefogg', function(){
1921 // Set up the upload handler to Firefogg. Should work with the HTTP uploads too.
@@ -32,9 +34,6 @@
3335 // Set the select file callback:
3436 'selectFileCb': function( fileName ) {
3537 $j( '#wpDestFile' ).val( fileName );
36 - $j( '#wpDestFile' ).doDestCheck( {
37 - 'warn_target': '#wpDestFile-warning'
38 - } );
3938 }
4039 } );
4140 } )
@@ -42,7 +41,14 @@
4342 // Add basic upload profile support ( http status monitoring, progress box for
4443 // browsers that support it, etc.)
4544 mw.load( 'AddMedia.UploadHandler', function(){
46 - $j( mwUploadFormSelector ).uploadHandler( );
 45+ $j( mwUploadFormSelector ).uploadHandler( {
 46+ 'selectFileCb': function( fileName ) {
 47+ $j( '#wpDestFile' ).val( fileName );
 48+ $j( '#wpDestFile' ).doDestCheck( {
 49+ 'warn_target': '#wpDestFile-warning'
 50+ } );
 51+ }
 52+ });
4753 });
4854 }
4955
@@ -64,6 +70,7 @@
6571 _this.toggleUpType( this.id == 'wpSourceTypeFile' );
6672 } );
6773 }
 74+
6875 $j( '#wpUploadFile,#wpUploadFileURL' )
6976 .focus( function() {
7077 _this.toggleUpType( this.id == 'wpUploadFile' );

Status & tagging log