Index: branches/js2-work/phase3/includes/specials/SpecialUploadWizard.php |
— | — | @@ -99,6 +99,7 @@ |
100 | 100 | global $wgUser, $wgOut; |
101 | 101 | global $wgUseAjax, $wgAjaxLicensePreview, $wgEnableAPI; |
102 | 102 | global $wgEnableFirefogg, $wgFileExtensions; |
| 103 | + global $wgCanonicalNamespaceNames; |
103 | 104 | |
104 | 105 | $wgOut->addScript( Skin::makeVariablesScript( array( |
105 | 106 | // uncertain if this is relevant. Can we do license preview with API? |
— | — | @@ -110,8 +111,10 @@ |
111 | 112 | 'wgFileExtensions' => $wgFileExtensions, |
112 | 113 | |
113 | 114 | // our edit token |
114 | | - 'wgEditToken' => $wgUser->editToken() |
| 115 | + 'wgEditToken' => $wgUser->editToken(), |
115 | 116 | |
| 117 | + 'wgCanonicalNamespaceNames' => $wgCanonicalNamespaceNames |
| 118 | + |
116 | 119 | // in the future, we ought to be telling JS land other things, |
117 | 120 | // like: requirements for publication, acceptable licenses, etc. |
118 | 121 | |
Index: branches/js2-work/phase3/js/mwEmbed/loader.js |
— | — | @@ -152,6 +152,7 @@ |
153 | 153 | "$j.fn.suggestions" : "jquery/plugins/jquery.suggestions.js", |
154 | 154 | "$j.fn.textSelection" : "jquery/plugins/jquery.textSelection.js", |
155 | 155 | "$j.browserTest" : "jquery/plugins/jquery.browserTest.js", |
| 156 | + "$j.fn.jWizard" : "jquery/plugins/jquery.jWizard.js", |
156 | 157 | |
157 | 158 | "$j.effects.blind" : "jquery/jquery.ui/ui/effects.blind.js", |
158 | 159 | "$j.effects.drop" : "jquery/jquery.ui/ui/effects.drop.js", |
Index: branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/mw.UploadWizard.js |
— | — | @@ -81,7 +81,7 @@ |
82 | 82 | "mwe-copyright-custom": "Custom", |
83 | 83 | |
84 | 84 | "mwe-upwiz-next": "Next", |
85 | | - "mwe-upwiz-home": "Wikimedia Commons", |
| 85 | + "mwe-upwiz-home": "Go to Wiki home page", |
86 | 86 | "mwe-upwiz-upload-another": "Upload more files", |
87 | 87 | |
88 | 88 | "mwe-prevent-close": "Your files are still uploading. Are you sure you want to navigate away from this page?", |
— | — | @@ -474,7 +474,7 @@ |
475 | 475 | var _this = this; |
476 | 476 | |
477 | 477 | _this.filename = result.upload.filename; |
478 | | - _this.title = "File:" + _this.filename; |
| 478 | + _this.title = mw.getConfig( 'fileNamespace' ) + ':' + _this.filename; |
479 | 479 | |
480 | 480 | _this.extractImageInfo( result.upload.imageinfo ); |
481 | 481 | |
— | — | @@ -1160,8 +1160,7 @@ |
1161 | 1161 | */ |
1162 | 1162 | setFilenameFromTitle: function() { |
1163 | 1163 | var _this = this; |
1164 | | - // "File:" is the constant NS_FILE, defined in Namespaces.php. Usually unchangeable? |
1165 | | - _this.filename = "File:" + _this.getFilenameFromTitle(); |
| 1164 | + _this.filename = mw.getConfig( 'fileNamespace' ) + ':' + _this.getFilenameFromTitle(); |
1166 | 1165 | $j( '#mwe-upwiz-details-filename' ).text( _this.filename ); |
1167 | 1166 | |
1168 | 1167 | }, |
— | — | @@ -1815,6 +1814,15 @@ |
1816 | 1815 | return null; |
1817 | 1816 | }, |
1818 | 1817 | */ |
| 1818 | + |
| 1819 | + reset: function() { |
| 1820 | + var _this = this; |
| 1821 | + $j.each( _this.uploads, function( i, upload ) { |
| 1822 | + _this.removeUpload( upload ); |
| 1823 | + } ); |
| 1824 | + _this.uploads = []; |
| 1825 | + }, |
| 1826 | + |
1819 | 1827 | |
1820 | 1828 | /** |
1821 | 1829 | * create the basic interface to make an upload in this div |
— | — | @@ -1881,8 +1889,8 @@ |
1882 | 1890 | + '<div class="mwe-upwiz-stepdiv" id="mwe-upwiz-stepdiv-thanks">' |
1883 | 1891 | + '<div id="mwe-upwiz-thanks"></div>' |
1884 | 1892 | + '<div class="mwe-upwiz-buttons"/>' |
1885 | | - + '<button class="mwe-upwiz-button-begin" />' |
1886 | | - + '<br/><button class="mwe-upwiz-button-home" />' |
| 1893 | + + '<button class="mwe-upwiz-button-begin"></button>' |
| 1894 | + + '<br/><button class="mwe-upwiz-button-home"></button>' |
1887 | 1895 | + '</div>' |
1888 | 1896 | + '</div>' |
1889 | 1897 | |
— | — | @@ -1891,9 +1899,14 @@ |
1892 | 1900 | + '<div class="mwe-upwiz-clearing"></div>'; |
1893 | 1901 | |
1894 | 1902 | |
1895 | | - $j( '.mwe-upwiz-button-home' ).append( gM( 'mwe-upwiz-home' ) ); |
1896 | | - $j( '.mwe-upwiz-button-begin' ).append( gM( 'mwe-upwiz-upload-another' ) ); |
| 1903 | + $j( '.mwe-upwiz-button-home' ) |
| 1904 | + .append( gM( 'mwe-upwiz-home' ) ) |
| 1905 | + .click( function() { window.location.href = '/' } ); |
1897 | 1906 | |
| 1907 | + $j( '.mwe-upwiz-button-begin' ) |
| 1908 | + .append( gM( 'mwe-upwiz-upload-another' ) ) |
| 1909 | + .click( _this.reset() ); |
| 1910 | + |
1898 | 1911 | $j( '.mwe-upwiz-button-next' ) |
1899 | 1912 | .append( gM( 'mwe-upwiz-next' ) ) |
1900 | 1913 | |
— | — | @@ -2121,6 +2134,9 @@ |
2122 | 2135 | if ( upload.deedChooser ) { |
2123 | 2136 | upload.deedChooser.detach( upload ); |
2124 | 2137 | } |
| 2138 | + upload.details.div.remove(); |
| 2139 | + upload.thanksDiv.remove(); |
| 2140 | + |
2125 | 2141 | mw.UploadWizardUtil.removeItem( _this.uploads, upload ); |
2126 | 2142 | _this.updateFileCounts(); |
2127 | 2143 | }, |
— | — | @@ -2345,13 +2361,14 @@ |
2346 | 2362 | |
2347 | 2363 | $j.each( _this.uploads, function(i, upload) { |
2348 | 2364 | var thanksDiv = $j( '<div class="mwe-upwiz-thanks ui-helper-clearfix" />' ); |
| 2365 | + _this.thanksDiv = thanksDiv; |
2349 | 2366 | |
2350 | 2367 | var thumbnailDiv = $j( '<div></div>' ).addClass( 'mwe-upwiz-thumbnail' ); |
2351 | 2368 | thanksDiv.append( thumbnailDiv ); |
2352 | 2369 | upload.setThumbnail( thumbnailDiv ); |
2353 | 2370 | |
2354 | | - var thumbTitle = upload.title.replace(/^File/, 'Image'); // XXX is this really necessary? |
2355 | | - var thumbWikiText = "[[" + thumbTitle + "|thumb]]"; |
| 2371 | + //var thumbTitle = upload.title.replace(/^File/, 'Image'); // XXX is this really necessary? |
| 2372 | + var thumbWikiText = "[[" + upload.title + "|thumb]]"; |
2356 | 2373 | |
2357 | 2374 | thanksDiv.append( |
2358 | 2375 | $j( '<div class="mwe-upwiz-data"></div>' ) |
— | — | @@ -2370,7 +2387,7 @@ |
2371 | 2388 | $j( '<textarea class="mwe-long-textarea" rows="1"/>' ) |
2372 | 2389 | .growTextArea() |
2373 | 2390 | .append( thumbWikiText ) |
2374 | | - .trigger( 'change' ) // to make it grow to fit |
| 2391 | + .resizeIfNeeded() |
2375 | 2392 | ), |
2376 | 2393 | $j('<p/>').append( |
2377 | 2394 | gM( 'mwe-upwiz-thanks-url' ), |
— | — | @@ -2378,7 +2395,7 @@ |
2379 | 2396 | $j( '<textarea class="mwe-long-textarea" rows="1"/>' ) |
2380 | 2397 | .growTextArea() |
2381 | 2398 | .append( upload.imageinfo.descriptionurl ) |
2382 | | - .trigger( 'change' ) // to make it grow to fit |
| 2399 | + .resizeIfNeeded() |
2383 | 2400 | ) |
2384 | 2401 | ) |
2385 | 2402 | ); |
— | — | @@ -2969,14 +2986,16 @@ |
2970 | 2987 | } ); |
2971 | 2988 | } |
2972 | 2989 | |
2973 | | - var resizeIfNeeded = function() { |
| 2990 | + this.resizeIfNeeded = function() { |
2974 | 2991 | // this is the dom element |
2975 | 2992 | while (this.scrollHeight > this.offsetHeight) { |
2976 | 2993 | this.rows++; |
2977 | 2994 | } |
| 2995 | + return this; |
2978 | 2996 | }; |
2979 | 2997 | |
2980 | | - this.change(resizeIfNeeded).keyup(resizeIfNeeded); |
| 2998 | + this.change(this.resizeIfNeeded); |
| 2999 | + this.keyup(this.resizeIfNeeded); |
2981 | 3000 | |
2982 | 3001 | return this; |
2983 | 3002 | }; |
Index: branches/js2-work/phase3/js/specialUploadWizardPage.js |
— | — | @@ -4,6 +4,8 @@ |
5 | 5 | */ |
6 | 6 | |
7 | 7 | mw.ready( function() { |
| 8 | + var NS_FILE = 6; // Defines.php |
| 9 | + |
8 | 10 | mw.load( 'UploadWizard.UploadWizard', function () { |
9 | 11 | |
10 | 12 | mw.setConfig( 'debug', true ); |
— | — | @@ -23,6 +25,9 @@ |
24 | 26 | // so, this workaround will cause tagalog descriptions to be saved with this template instead. |
25 | 27 | mw.setConfig( 'languageTemplateFixups', { tl: 'tgl' } ); |
26 | 28 | mw.setConfig( 'defaultLicenses', [ 'cc_by_sa_30' ] ); |
| 29 | + |
| 30 | + // usually, but not always, File: |
| 31 | + mw.setConfig( 'fileNamespace', wgCanonicalNamespaceNames[NS_FILE] ); |
27 | 32 | |
28 | 33 | var uploadWizard = new mw.UploadWizard(); |
29 | 34 | uploadWizard.createInterface( '#upload-wizard' ); |