Index: branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/loader.js |
— | — | @@ -80,7 +80,6 @@ |
81 | 81 | |
82 | 82 | //Add uploadwizard classes to a new "request" var: |
83 | 83 | //request.push( libraries ); |
84 | | - |
85 | 84 | mw.load( libraries, function() { |
86 | 85 | callback( 'UploadWizard.UploadWizard' ); |
87 | 86 | } ); |
— | — | @@ -94,7 +93,6 @@ |
95 | 94 | //Add uploadwizard classes to a new "request" var: |
96 | 95 | //request.push( testLibraries ); |
97 | 96 | //debugger; |
98 | | - |
99 | 97 | mw.load( testLibraries, function() { |
100 | 98 | callback( 'UploadWizard.UploadWizardTest' ); |
101 | 99 | } ); |
Index: branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/mw.UploadWizard.js |
— | — | @@ -52,7 +52,7 @@ |
53 | 53 | "mwe-upwiz-other-prefill": "Free wikitext field", |
54 | 54 | "mwe-upwiz-showall": "show all", |
55 | 55 | "mwe-upwiz-source": "Source", |
56 | | - "mwe-upwiz-macro-edit-intro": "Please add some descriptions and other information to your uploads.", |
| 56 | + "mwe-upwiz-macro-edit-intro": "Choose a license first above, then you can add some descriptions and other information to your uploads.", |
57 | 57 | "mwe-upwiz-macro-edit": "Update descriptions", |
58 | 58 | "mwe-upwiz-thanks-intro": "Thanks for uploading your works! You can now use your files on a Wikipedia article or link to them from elsewhere on the web.", |
59 | 59 | "mwe-upwiz-thanks-link": "This file is now available at <b><tt>$1</tt></b>.", |
— | — | @@ -74,96 +74,42 @@ |
75 | 75 | |
76 | 76 | /** |
77 | 77 | * |
78 | | - * @param inputs - obj with one or more of three keys, 'source' and 'author' (html inputs) and 'license' (mw.UploadWizardLicense object) |
79 | 78 | */ |
80 | | -mw.UploadWizardDeed = function ( inputs ) { |
| 79 | +mw.UploadWizardDeed = function() { |
81 | 80 | var _this = this; |
82 | | - _this.sourceInput = inputs['source']; |
83 | | - _this.authorInput = inputs['author']; |
84 | | - _this.licenseInput = inputs['license']; |
85 | | - _this.customizable = { 'source': true, 'author': true, 'license': true }; |
86 | | - _this.readyCheck = undefined; |
87 | | - _this.isOwn = false; |
| 81 | + // prevent from instantiating directly? |
88 | 82 | }; |
89 | 83 | |
| 84 | +/* sort of an abstract class */ |
90 | 85 | mw.UploadWizardDeed.prototype = { |
91 | | - setCustomizable: function( obj ) { |
92 | | - var _this = this; |
93 | | - $j.each( obj, function( key, val ) { |
94 | | - if (_this.customizable.hasOwnProperty( key ) ) { |
95 | | - _this.customizable[key] = !!val; |
96 | | - } |
97 | | - } ); |
| 86 | + isReady: function() { |
| 87 | + return false; |
98 | 88 | }, |
99 | 89 | |
100 | | - setReadyCheck: function( callback ) { |
101 | | - var _this = this; |
102 | | - _this.readyCheck = callback; |
| 90 | + getSourceWikiText: function() { |
| 91 | + return $j( _this.sourceInput ).val(); |
103 | 92 | }, |
104 | 93 | |
105 | | - isReady: function() { |
106 | | - var _this = this; |
107 | | - if ( _this.readyCheck === undefined ) { |
108 | | - return true; |
109 | | - } else { |
110 | | - return _this.readyCheck(); |
111 | | - } |
| 94 | + getAuthorWikiText: function() { |
| 95 | + return $j( _this.authorInput ).val(); |
112 | 96 | }, |
113 | 97 | |
114 | | - applyDeed: function( uploads ) { |
| 98 | + /** |
| 99 | + * Get wikitext representing the licenses selected in the license object |
| 100 | + * @return wikitext of all applicable license templates. |
| 101 | + */ |
| 102 | + getLicenseWikiText: function() { |
115 | 103 | var _this = this; |
116 | | - if ( ! _this.isReady() ) { |
117 | | - return; |
118 | | - } |
119 | | - |
120 | | - var source; |
121 | | - var author; |
122 | | - if ( _this.isOwn ) { |
123 | | - source = '{{own}}'; |
124 | | - author = "[[User:" + mw.getConfig('userName') + '|' + $j( _this.authorInput ).val() + ']]'; |
125 | | - } else { |
126 | | - source = $j( _this.sourceInput ).val(); |
127 | | - author = $j( _this.authorInput ).val(); |
128 | | - } |
129 | | - var licenses = _this.licenseInput.getValues(); |
130 | | - |
131 | | - var licenseTxt = ''; |
132 | | - for (key in licenses) { |
133 | | - licenseTxt += '[' + key + ']=' + licenses[key] + ' '; |
134 | | - } |
135 | | - mw.log( "source:" + source + " author:" + author + " licenses:" + licenseTxt ); |
136 | | - |
137 | | - |
138 | | - $j.each( uploads, function( i, upload ) { |
139 | | - |
140 | | - $j( upload.details.sourceInput ).val( source ); |
141 | | - if ( _this.customizable['source'] ) { |
142 | | - upload.details.unlockSource(); |
143 | | - } else { |
144 | | - upload.details.lockSource(); |
145 | | - } |
146 | | - |
147 | | - $j( upload.details.authorInput ).val( author ); |
148 | | - if ( _this.customizable['author'] ) { |
149 | | - upload.details.unlockAuthor(); |
150 | | - } else { |
151 | | - upload.details.lockAuthor(); |
152 | | - } |
153 | | - |
154 | | - upload.details.licenseInput.setValues( licenses ); |
155 | | - if ( _this.isOwn ) { |
156 | | - upload.details.licenseInput.setOwn( true ); |
157 | | - } |
158 | | - if ( _this.customizable['license'] ) { |
159 | | - upload.details.unlockLicense(); |
160 | | - } else { |
161 | | - upload.details.lockLicense(); |
162 | | - } |
163 | | - |
| 104 | + var wikiText = ''; |
| 105 | + $j.each ( _this.licenses, function( key, data ) { |
| 106 | + if (data.input.checked) { |
| 107 | + wikiText += "{{" + data.template + "}}\n"; |
| 108 | + } |
164 | 109 | } ); |
| 110 | + |
| 111 | + return wikiText; |
165 | 112 | } |
166 | 113 | |
167 | | - |
168 | 114 | }; |
169 | 115 | |
170 | 116 | mw.ProgressBar = function( selector, text ) { |
— | — | @@ -286,7 +232,6 @@ |
287 | 233 | mw.UploadWizardLicenseInput = function( div, values ) { |
288 | 234 | var _this = this; |
289 | 235 | |
290 | | - _this.isOwn = false; |
291 | 236 | _this.change = function() {}; |
292 | 237 | |
293 | 238 | var c = mw.UploadWizardLicenseInput.prototype.count++; |
— | — | @@ -325,47 +270,6 @@ |
326 | 271 | count: 0, |
327 | 272 | |
328 | 273 | /** |
329 | | - * set callback for onchange of any value |
330 | | - */ |
331 | | - setChange: function( callback ) { |
332 | | - var _this = this; |
333 | | - _this.change = callback; |
334 | | - }, |
335 | | - |
336 | | - /** |
337 | | - * Get wikitext representing the licenses selected in the license object |
338 | | - * @return wikitext of all applicable license templates. |
339 | | - */ |
340 | | - getWikiText: function() { |
341 | | - var _this = this; |
342 | | - var wikiText = ''; |
343 | | - if ( _this.isOwn ) { |
344 | | - wikiText = '{{self'; |
345 | | - $j.each ( _this.licenses, function( key, data ) { |
346 | | - if ( data.input.checked ) { |
347 | | - wikiText += '|' + data.template; |
348 | | - } |
349 | | - } ); |
350 | | - wikiText += '}}'; |
351 | | - } else { |
352 | | - $j.each ( _this.licenses, function( key, data ) { |
353 | | - if (data.input.checked) { |
354 | | - wikiText += "{{" + data.template + "}}\n"; |
355 | | - } |
356 | | - } ); |
357 | | - } |
358 | | - return wikiText; |
359 | | - }, |
360 | | - |
361 | | - /** |
362 | | - * Modifies how this license will output wikiText. The templates will tack on an "I, the copyright owner blah blah". |
363 | | - */ |
364 | | - setOwn: function( bool ) { |
365 | | - var _this = this; |
366 | | - _this.isOwn = !!bool; |
367 | | - }, |
368 | | - |
369 | | - /** |
370 | 274 | * Sets the value(s) of a license input. |
371 | 275 | * @param object of license-key to boolean values, e.g. { cc_by_sa_30: true, gfdl: true } |
372 | 276 | */ |
— | — | @@ -438,6 +342,11 @@ |
439 | 343 | |
440 | 344 | mw.UploadWizardUpload.prototype = { |
441 | 345 | |
| 346 | + acceptDeed: function( deed ) { |
| 347 | + var _this = this; |
| 348 | + _this.deed.applyDeed( _this ); |
| 349 | + }, |
| 350 | + |
442 | 351 | /** |
443 | 352 | * start |
444 | 353 | */ |
— | — | @@ -778,10 +687,13 @@ |
779 | 688 | * @param selector jquery-compatible selector, for a single element |
780 | 689 | */ |
781 | 690 | moveFileInputToCover: function( selector ) { |
| 691 | + //mw.log( "moving to cover " + selector ); |
782 | 692 | var _this = this; |
783 | | - //debugger; |
784 | 693 | var $covered = $j( selector ); |
785 | 694 | |
| 695 | + //mw.log( "position: " ); |
| 696 | + //mw.log( $covered.position() ); |
| 697 | + |
786 | 698 | _this.fileCtrlContainer |
787 | 699 | .css( $covered.position() ) |
788 | 700 | .width( $covered.outerWidth() ) |
— | — | @@ -1059,14 +971,14 @@ |
1060 | 972 | |
1061 | 973 | _this.titleErrorDiv = $j('<div></div>'); |
1062 | 974 | |
1063 | | - _this.titleContainerDiv = $j('<div class="mwe-details-label-input></div>') |
| 975 | + _this.titleContainerDiv = $j('<div class="mwe-upwiz-details-label-input></div>') |
1064 | 976 | .append( $j( '<div class="mwe-upwiz-details-label"></div>' ).append( gM( 'mwe-upwiz-title' ) ) ) |
1065 | 977 | .append( $j( '<div class="mwe-upwiz-details-input"></div>' ).append( _this.titleInput ) ) |
1066 | 978 | .append( _this.titleErrorDiv ); |
1067 | 979 | |
1068 | | - _this.moreDetailsDiv = $j('<div class="mwe-more-details"></div>').hide(); |
| 980 | + _this.moreDetailsDiv = $j('<div class="mwe-more-details"></div>').maskSafeHide(); |
1069 | 981 | |
1070 | | - _this.moreDetailsCtrlDiv = $j( '<div class="mwe-details-more-options"></div>' ); |
| 982 | + _this.moreDetailsCtrlDiv = $j( '<div class="mwe-upwiz-details-more-options"></div>' ); |
1071 | 983 | |
1072 | 984 | |
1073 | 985 | |
— | — | @@ -1081,56 +993,57 @@ |
1082 | 994 | |
1083 | 995 | _this.locationInput = $j( '<input type="text" class="mwe-location" size="20"/>' ); |
1084 | 996 | |
1085 | | - var aboutThisWorkDiv = $j('<fieldset class="mwe-fieldset"></div>') |
| 997 | + var aboutThisWorkDiv = $j('<fieldset class="mwe-fieldset"></fieldset>') |
1086 | 998 | .append( $j( '<legend class="mwe-legend">' ).append( gM( 'mwe-upwiz-about-this-work' ) ) ) |
1087 | | - .append( $j( '<div class="mwe-details-more-subdiv">' ) |
| 999 | + .append( $j( '<div class="mwe-upwiz-details-more-subdiv">' ) |
1088 | 1000 | .append( $j( '<div class="mwe-upwiz-details-label-input"></div>' ) |
1089 | | - .append( $j( '<div class="mwe-details-more-label"></div>' ).append( gM( 'mwe-upwiz-date-created' ) ) ) |
1090 | | - .append( $j( '<div class="mwe-details-more-input"></div>' ).append( _this.dateInput ) ) |
| 1001 | + .append( $j( '<div class="mwe-upwiz-details-more-label"></div>' ).append( gM( 'mwe-upwiz-date-created' ) ) ) |
| 1002 | + .append( $j( '<div class="mwe-upwiz-details-more-input"></div>' ).append( _this.dateInput ) ) |
1091 | 1003 | ) |
1092 | 1004 | .append( $j ( '<div style="display: none;"></div>' ) // see prefillLocation |
1093 | | - .append( $j( '<div class="mwe-details-more-label"></div>' ).append( gM( 'mwe-upwiz-location' ) ) ) |
1094 | | - .append( $j( '<div class="mwe-details-more-input"></div>' ).append( _this.locationInput ) ) |
| 1005 | + .append( $j( '<div class="mwe-upwiz-details-more-label"></div>' ).append( gM( 'mwe-upwiz-location' ) ) ) |
| 1006 | + .append( $j( '<div class="mwe-upwiz-details-more-input"></div>' ).append( _this.locationInput ) ) |
1095 | 1007 | ) |
1096 | 1008 | ); |
1097 | 1009 | |
| 1010 | +/* |
1098 | 1011 | // XXX why is rows=1 giving me two rows. Is this growTextArea's fault? |
1099 | 1012 | _this.sourceInput = $j('<textarea class="mwe-source" rows="1" cols="40"></textarea>' ).growTextArea(); |
1100 | 1013 | _this.sourceDiv = $j( '<div></div>' ) |
1101 | | - .append( $j( '<div class="mwe-details-more-label"></div>' ).append( gM( 'mwe-upwiz-source' ) ) ) |
1102 | | - .append( $j( '<div class="mwe-details-more-input"></div>' ).append( _this.sourceInput ) ); |
| 1014 | + .append( $j( '<div class="mwe-upwiz-details-more-label"></div>' ).append( gM( 'mwe-upwiz-source' ) ) ) |
| 1015 | + .append( $j( '<div class="mwe-upwiz-details-more-input"></div>' ).append( _this.sourceInput ) ); |
1103 | 1016 | |
1104 | 1017 | |
1105 | 1018 | _this.authorInput = $j('<textarea class="mwe-author" rows="1" cols="40"></textarea>' ).growTextArea(); |
1106 | 1019 | _this.authorDiv = $j( '<div></div>' ) |
1107 | | - .append( $j( '<div class="mwe-details-more-label"></div>' ).append( gM( 'mwe-upwiz-author' ) ) ) |
1108 | | - .append( $j( '<div class="mwe-details-more-input"></div>' ).append( _this.authorInput ) ); |
| 1020 | + .append( $j( '<div class="mwe-upwiz-details-more-label"></div>' ).append( gM( 'mwe-upwiz-author' ) ) ) |
| 1021 | + .append( $j( '<div class="mwe-upwiz-details-more-input"></div>' ).append( _this.authorInput ) ); |
1109 | 1022 | |
1110 | 1023 | |
1111 | 1024 | var licenseInputDiv = $j('<div></div>'); |
1112 | 1025 | _this.licenseInput = new mw.UploadWizardLicenseInput( licenseInputDiv ); |
1113 | 1026 | _this.licenseDiv = $j( '<div></div>' ) |
1114 | | - .append( $j( '<div class="mwe-details-more-label"></div>' ).append( gM( 'mwe-upwiz-license' ) ) ) |
1115 | | - .append( $j( '<div class="mwe-details-more-input"></div>' ).append( licenseInputDiv ) ); |
| 1027 | + .append( $j( '<div class="mwe-upwiz-details-more-label"></div>' ).append( gM( 'mwe-upwiz-license' ) ) ) |
| 1028 | + .append( $j( '<div class="mwe-upwiz-details-more-input"></div>' ).append( licenseInputDiv ) ); |
| 1029 | +*/ |
1116 | 1030 | |
1117 | | - var copyrightInfoDiv = $j('<div></div>') |
1118 | | - .append( $j( '<h5 class="mwe-details-more-subhead">' ).append( gM( 'mwe-upwiz-copyright-info' ) ) ) |
1119 | | - .append( $j( '<div class="mwe-details-more-subdiv">' ) |
1120 | | - .append( _this.sourceDiv, |
1121 | | - _this.authorDiv, |
1122 | | - _this.licenseDiv ) ); |
| 1031 | + // XXX create a toggler that will switch between a custom deed chooser and the upload's chooser |
| 1032 | + var copyrightInfoDiv = $j('<fieldset class="mwe-fieldset"></fieldset>') |
| 1033 | + .append( $j( '<legend class="mwe-legend">' ).append( gM( 'mwe-upwiz-copyright-info' ) ) ) |
| 1034 | + .append( $j( '<div class="mwe-upwiz-details-more-subdiv">' ) |
| 1035 | + .html( "As above" ) ); // XXX |
1123 | 1036 | |
1124 | 1037 | |
1125 | | - var aboutTheFileDiv = $j('<div></div>') |
1126 | | - .append( $j( '<h5 class="mwe-details-more-subhead">' ).append( gM( 'mwe-upwiz-about-format' ) ) ) |
1127 | | - .append( $j( '<div class="mwe-details-more-subdiv">' ) |
| 1038 | + var aboutTheFileDiv = $j('<fieldset class="mwe-fieldset"></fieldset>') |
| 1039 | + .append( $j( '<legend class="mwe-legend">' ).append( gM( 'mwe-upwiz-about-format' ) ) ) |
| 1040 | + .append( $j( '<div class="mwe-upwiz-details-more-subdiv">' ) |
1128 | 1041 | .append( $j( '<div></div>' ) |
1129 | | - .append( $j( '<div class="mwe-details-more-label"></div>' ).append( gM( 'mwe-upwiz-filename-tag' ) ) ) |
1130 | | - .append( $j( '<div id="mwe-upwiz-details-filename" class="mwe-details-more-input"></div>' ) ) ) ); |
| 1042 | + .append( $j( '<div class="mwe-upwiz-details-more-label"></div>' ).append( gM( 'mwe-upwiz-filename-tag' ) ) ) |
| 1043 | + .append( $j( '<div class="mwe-upwiz-details-filename mwe-upwiz-details-more-input"></div>' ) ) ) ); |
1131 | 1044 | |
1132 | | - _this.otherInformationInput = $j( '<textarea class="mwe-upwiz-other-textarea" rows="3" cols="40"></textarea>' ); |
| 1045 | + _this.otherInformationInput = $j( '<textarea class="mwe-upwiz-other-textarea"></textarea>' ); |
1133 | 1046 | var otherInformationDiv = $j('<div></div>') |
1134 | | - .append( $j( '<h5 class="mwe-details-more-subhead">' ).append( gM( 'mwe-upwiz-other' ) ) ) |
| 1047 | + .append( $j( '<div class="mwe-upwiz-details-more-label">' ).append( gM( 'mwe-upwiz-other' ) ) ) |
1135 | 1048 | .append( _this.otherInformationInput ); |
1136 | 1049 | |
1137 | 1050 | |
— | — | @@ -1566,6 +1479,15 @@ |
1567 | 1480 | */ |
1568 | 1481 | getWikiText: function() { |
1569 | 1482 | var _this = this; |
| 1483 | + |
| 1484 | + // XXX validate! |
| 1485 | + if ( ! _this.isReady() ) { |
| 1486 | + alert( "ZOMG THIS DEED IS NOT READY" ); |
| 1487 | + return null; |
| 1488 | + } |
| 1489 | + |
| 1490 | + |
| 1491 | + |
1570 | 1492 | wikiText = ''; |
1571 | 1493 | |
1572 | 1494 | |
— | — | @@ -1590,17 +1512,14 @@ |
1591 | 1513 | } |
1592 | 1514 | $j.each( _this.descriptions, function( i, desc ) { |
1593 | 1515 | information['description'] += desc.getWikiText(); |
1594 | | - } ); |
1595 | | - |
| 1516 | + } ); |
1596 | 1517 | |
1597 | 1518 | // XXX add a sanity check here for good date |
1598 | 1519 | information['date'] = $j( _this.dateInput ).val().trim(); |
1599 | 1520 | |
1600 | | - // we must have all of: source, author, license |
1601 | | - information['source'] = $j( _this.sourceInput ).val().trim(); |
| 1521 | + information['source'] = _this.deedChooser.deed.getSourceWikiText(); |
1602 | 1522 | |
1603 | | - information['author'] = $j( _this.authorInput ).val().trim(); |
1604 | | - // we could try just auto looking up User and Creator, and asking them every time |
| 1523 | + information['author'] = _this.deedChooser.deed.getAuthorWikiText(); |
1605 | 1524 | |
1606 | 1525 | var info = ''; |
1607 | 1526 | for ( var key in information ) { |
— | — | @@ -1614,7 +1533,7 @@ |
1615 | 1534 | |
1616 | 1535 | wikiText += "=={{int:license-header}}==\n"; |
1617 | 1536 | |
1618 | | - wikiText += _this.licenseInput.getWikiText(); |
| 1537 | + wikiText += _this.deedChooser.deed.getLicenseWikiText(); |
1619 | 1538 | |
1620 | 1539 | // add a location template |
1621 | 1540 | |
— | — | @@ -1632,6 +1551,9 @@ |
1633 | 1552 | * Check if we are ready to post wikitext |
1634 | 1553 | */ |
1635 | 1554 | isReady: function() { |
| 1555 | + var _this = this; |
| 1556 | + return _this.deedChooser.deed.isReady(); |
| 1557 | + |
1636 | 1558 | // somehow, all the various issues discovered with this upload should be present in a single place |
1637 | 1559 | // where we can then check on |
1638 | 1560 | // perhaps as simple as _this.issues or _this.agenda |
— | — | @@ -1771,7 +1693,7 @@ |
1772 | 1694 | |
1773 | 1695 | showProgress: function() { |
1774 | 1696 | var _this = this; |
1775 | | - _this.div.disableInputsFade(); |
| 1697 | + _this.div.mask(); |
1776 | 1698 | // XXX spinnerize |
1777 | 1699 | _this.upload.detailsProgress = 1.0; |
1778 | 1700 | }, |
— | — | @@ -1780,58 +1702,8 @@ |
1781 | 1703 | var _this = this; |
1782 | 1704 | _this.upload.state = 'complete'; |
1783 | 1705 | // XXX de-spinnerize |
1784 | | - _this.div.enableInputsFade(); |
1785 | | - }, |
1786 | | - |
1787 | | - /** |
1788 | | - * Sometimes we wish to lock certain copyright or license info from being changed |
1789 | | - */ |
1790 | | - lockSource: function() { |
1791 | | - var _this = this; |
1792 | | - _this.sourceDiv.hide(); |
1793 | | - }, |
1794 | | - |
1795 | | - /** |
1796 | | - * If we hopped between deeds, and now this is visible again |
1797 | | - */ |
1798 | | - unlockSource: function() { |
1799 | | - var _this = this; |
1800 | | - _this.sourceDiv.show(); |
1801 | | - }, |
1802 | | - |
1803 | | - /** |
1804 | | - * Sometimes we wish to lock certain copyright or license info from being changed |
1805 | | - */ |
1806 | | - lockAuthor: function() { |
1807 | | - var _this = this; |
1808 | | - _this.authorDiv.hide(); |
1809 | | - }, |
1810 | | - |
1811 | | - /** |
1812 | | - * If we hopped between deeds, and now this is visible again |
1813 | | - */ |
1814 | | - unlockAuthor: function() { |
1815 | | - var _this = this; |
1816 | | - _this.authorDiv.show(); |
1817 | | - }, |
1818 | | - |
1819 | | - |
1820 | | - /** |
1821 | | - * Sometimes we wish to lock certain copyright or license info from being changed |
1822 | | - */ |
1823 | | - lockLicense: function() { |
1824 | | - var _this = this; |
1825 | | - _this.licenseDiv.hide(); |
1826 | | - }, |
1827 | | - |
1828 | | - /** |
1829 | | - * Sometimes we wish to lock certain copyright or license info from being changed |
1830 | | - */ |
1831 | | - unlockLicense: function() { |
1832 | | - var _this = this; |
1833 | | - _this.licenseDiv.show(); |
| 1706 | + _this.div.unmask(); |
1834 | 1707 | } |
1835 | | - |
1836 | 1708 | |
1837 | 1709 | }; |
1838 | 1710 | |
— | — | @@ -1907,7 +1779,7 @@ |
1908 | 1780 | |
1909 | 1781 | |
1910 | 1782 | + '<div id="mwe-upwiz-content">' |
1911 | | - + '<div id="mwe-upwiz-tabdiv-file">' |
| 1783 | + + '<div class="mwe-upwiz-tabdiv" id="mwe-upwiz-tabdiv-file">' |
1912 | 1784 | + '<div id="mwe-upwiz-intro">' + gM('mwe-upwiz-intro') + '</div>' |
1913 | 1785 | + '<div id="mwe-upwiz-files">' |
1914 | 1786 | + '<div class="shim" style="height: 120px"></div>' |
— | — | @@ -1924,44 +1796,22 @@ |
1925 | 1797 | + '</div>' |
1926 | 1798 | + '<div style="clear: left;"></div>' |
1927 | 1799 | + '</div>' |
1928 | | - + '<div id="mwe-upwiz-tabdiv-details">' |
| 1800 | + + '<div class="mwe-upwiz-tabdiv" id="mwe-upwiz-tabdiv-details">' |
1929 | 1801 | + '<div id="mwe-upwiz-macro">' |
1930 | 1802 | + '<div id="mwe-upwiz-macro-choice">' |
1931 | | - + '<div>' + gM( 'mwe-upwiz-intro-details' ) + '</div>' |
1932 | | - + '<div id="mwe-upwiz-macro-deeds">' |
1933 | | - + '<div id="mwe-upwiz-macro-deed-ownwork" class="mwe-upwiz-deed">' |
1934 | | - + '<div class="mwe-upwiz-deed-option-title">' |
1935 | | - + '<span class="mwe-upwiz-deed-header mwe-closed"><a class="mwe-upwiz-deed-header-link mwe-upwiz-deed-name">' + gM( 'mwe-upwiz-source-ownwork' ) + '</a></span>' |
1936 | | - + '<span class="mwe-upwiz-deed-header mwe-open" style="display: none;">' |
1937 | | - + '<span class="mwe-upwiz-deed-name">' + gM( 'mwe-upwiz-source-ownwork' ) + '</span>' |
1938 | | - + ' <a class="mwe-upwiz-macro-deeds-return">' + gM( 'mwe-upwiz-change' ) + '</a>' |
1939 | | - + '</span>' |
1940 | | - + '</div>' // more deed stuff set up below |
1941 | | - + '<div class="mwe-upwiz-deed-form" style="display: none"></div>' |
1942 | | - + '</div>' |
1943 | | - + '<div id="mwe-upwiz-macro-deed-thirdparty" class="mwe-upwiz-deed">' |
1944 | | - + '<div class="mwe-upwiz-deed-option-title">' |
1945 | | - + '<span class="mwe-upwiz-deed-header mwe-closed"><a class="mwe-upwiz-deed-header-link mwe-upwiz-deed-name">' + gM( 'mwe-upwiz-source-thirdparty' ) + '</a></span>' |
1946 | | - + '<span class="mwe-upwiz-deed-header mwe-open" style="display: none;">' |
1947 | | - + '<span class="mwe-upwiz-deed-name">' + gM( 'mwe-upwiz-source-thirdparty' ) + '</span>' |
1948 | | - + ' <a class="mwe-upwiz-macro-deeds-return">' + gM( 'mwe-upwiz-change' ) + '</a>' |
1949 | | - + '</span>' |
1950 | | - + '</div>' // more deed stuff set up below |
1951 | | - + '<div class="mwe-upwiz-deed-form" style="display: none"></div>' |
1952 | | - + '</div>' |
1953 | | - + '</div>' |
| 1803 | + + '<div>' + gM( 'mwe-upwiz-intro-details' ) + '</div>' |
| 1804 | + + '<div id="mwe-upwiz-macro-deeds" />' |
1954 | 1805 | + '</div>' |
1955 | 1806 | + '<div id="mwe-upwiz-macro-edit">' |
1956 | | - + '<div>' |
1957 | | - + '<p>' + gM( 'mwe-upwiz-macro-edit-intro' ) + '</p>' |
1958 | | - + '</div>' // button added below |
1959 | | - + '<div id="mwe-upwiz-macro-progress"></div>' |
1960 | | - + '<div id="mwe-upwiz-macro-files"></div>' |
1961 | | - + '<div class="mwe-upwiz-macro-edit-submit"></div>' // button added below |
| 1807 | + + '<div>' |
| 1808 | + //+ '<p>' + gM( 'mwe-upwiz-macro-edit-intro' ) + '</p>' |
1962 | 1809 | + '</div>' |
| 1810 | + + '<div id="mwe-upwiz-macro-progress"></div>' |
| 1811 | + + '<div id="mwe-upwiz-macro-files"></div>' |
| 1812 | + + '<div class="mwe-upwiz-macro-edit-submit"></div>' // button added below |
1963 | 1813 | + '</div>' |
1964 | 1814 | + '</div>' |
1965 | | - + '<div id="mwe-upwiz-tabdiv-thanks">' |
| 1815 | + + '<div class="mwe-upwiz-tabdiv" id="mwe-upwiz-tabdiv-thanks">' |
1966 | 1816 | + '<div id="mwe-upwiz-thanks"></div>' |
1967 | 1817 | + '</div>' |
1968 | 1818 | + '</div>' |
— | — | @@ -1971,20 +1821,14 @@ |
1972 | 1822 | // within FILE tab div |
1973 | 1823 | $j('#mwe-upwiz-upload-ctrl').click( function() { _this.startUploads(); } ); |
1974 | 1824 | |
1975 | | - _this.setupDeedOwnWork(); |
1976 | | - _this.setupDeedThirdParty(); |
1977 | | - _this.setupNullDeed(); |
| 1825 | + // DETAILS div |
| 1826 | + $j( '.mwe-upwiz-deed-form' ).maskSafeHide(); |
1978 | 1827 | |
1979 | | - // open and close the various deeds |
1980 | | - //$j( '.mwe-upwiz-deed-header-link' ).click( function() { |
1981 | | - // _this.showDeed( $j( this ).parents( '.mwe-upwiz-deed' ) ); |
1982 | | - //} ); |
1983 | | - $j( '.mwe-upwiz-macro-deeds-return' ).click( function() { _this.showDeedChoice(); } ); |
1984 | 1828 | |
1985 | 1829 | // buttons to submit all details and go on to the thanks page, at the top and bottom of the page. |
1986 | 1830 | $j( '.mwe-upwiz-macro-edit-submit' ).each( function() { |
1987 | 1831 | $j( this ).append( $j( '<input />' ) |
1988 | | - .addClass( 'mwe-details-submit' ) |
| 1832 | + .addClass( 'mwe-upwiz-details-submit' ) |
1989 | 1833 | .attr( { type: 'submit', value: gM( 'mwe-upwiz-macro-edit' ) } ) |
1990 | 1834 | .click( function() { |
1991 | 1835 | // move to the top of the page to see the progress bar |
— | — | @@ -1996,20 +1840,32 @@ |
1997 | 1841 | } ) ); |
1998 | 1842 | } ); |
1999 | 1843 | |
| 1844 | + _this.deedChooser = new mw.UploadWizardDeedChooser( '#mwe-upwiz-macro-deeds' ); |
2000 | 1845 | |
2001 | 1846 | // add one to start |
2002 | | - _this.newUpload( '#mwe-upwiz-add-file' ); |
| 1847 | + var upload = _this.newUpload( '#mwe-upwiz-add-file' ); |
2003 | 1848 | |
2004 | 1849 | // "select" the first tab - highlight, make it visible, hide all others |
2005 | | - _this.moveToTab('file'); |
| 1850 | + _this.moveToTab('file', function() { |
| 1851 | + // XXX moving the file input doesn't seem to work at this point |
| 1852 | + // we are catching up to the application of CSS or something |
| 1853 | + // XXX using a timeout is lame, are there other options? |
| 1854 | + setTimeout( function() { |
| 1855 | + upload.ui.moveFileInputToCover( '#mwe-upwiz-add-file' ); |
| 1856 | + }, 300 ); |
| 1857 | + } ); |
| 1858 | + |
2006 | 1859 | }, |
2007 | 1860 | |
2008 | 1861 | /** |
2009 | 1862 | * Advance one "step" in the wizard interface. |
2010 | 1863 | * It is assumed that the previous tab to the current one was selected. |
| 1864 | + * We do not hide the tabs because this messes up certain calculations we'd like to make about dimensions, while elements are not |
| 1865 | + * on screen. So instead we make the tabs zero height and, in CSS, they are already overflow hidden |
2011 | 1866 | * @param selectedTabName |
| 1867 | + * @param callback to do after layout is ready? |
2012 | 1868 | */ |
2013 | | - moveToTab: function( selectedTabName ) { |
| 1869 | + moveToTab: function( selectedTabName, callback ) { |
2014 | 1870 | var _this = this; |
2015 | 1871 | $j.each( _this.tabNames, function(i, tabName) { |
2016 | 1872 | |
— | — | @@ -2020,15 +1876,20 @@ |
2021 | 1877 | var tabDiv = $j( '#mwe-upwiz-tabdiv-' + tabName ); |
2022 | 1878 | |
2023 | 1879 | if ( _this.currentTabName == tabName ) { |
2024 | | - tabDiv.hide(); |
2025 | | - $j( tab ).hide( 1000 ); |
| 1880 | + // we hide the old tabDivs because we are afraid of some z-index elements that may interfere with later tabs |
| 1881 | + // this will break if we ever allow people to page back and forth. |
| 1882 | + tab.hide( 1000 ); |
| 1883 | + tabDiv.hide(); |
2026 | 1884 | } else if ( selectedTabName == tabName ) { |
2027 | | - tabDiv.show(); |
| 1885 | + tabDiv.maskSafeShow(); |
2028 | 1886 | tab.addClass( 'mwe-upwiz-tab-highlight' ); |
| 1887 | + if ( callback ) { |
| 1888 | + callback(); |
| 1889 | + } |
2029 | 1890 | } else { |
2030 | | - // it's neither the formerly active nor the newly active one, so hide it. |
2031 | | - // (all are visible at init..) |
2032 | | - tabDiv.hide(); |
| 1891 | + // it's neither the formerly active nor the newly active one, so don't show it |
| 1892 | + // we don't use hide() because we want to manipulate elements within future tabs, and calculate their dimensions. |
| 1893 | + tabDiv.maskSafeHide(); |
2033 | 1894 | } |
2034 | 1895 | } ); |
2035 | 1896 | |
— | — | @@ -2064,7 +1925,7 @@ |
2065 | 1926 | // XXX bind to some error state |
2066 | 1927 | |
2067 | 1928 | |
2068 | | - return true; |
| 1929 | + return upload; |
2069 | 1930 | }, |
2070 | 1931 | |
2071 | 1932 | /** |
— | — | @@ -2079,6 +1940,22 @@ |
2080 | 1941 | _this.updateFileCounts(); |
2081 | 1942 | // maybe it would be better to defer details to later? |
2082 | 1943 | upload.details = new mw.UploadWizardDetails( upload, $j( '#mwe-upwiz-macro-files' )); |
| 1944 | + |
| 1945 | + // by default, new uploads use the wizard's deed selector. |
| 1946 | + upload.deedChooser = _this.deedChooser; |
| 1947 | + $j( _this.deedChooser ).bind( 'chooseNullDeed', function(e) { |
| 1948 | + mw.log("upload received chooseNullDeed"); |
| 1949 | + upload.details.div.mask(); |
| 1950 | + e.stopPropagation(); |
| 1951 | + } ); |
| 1952 | + $j( _this.deedChooser ).bind( 'chooseDeed', function(e) { |
| 1953 | + mw.log("upload received choose"); |
| 1954 | + upload.details.div.unmask(); |
| 1955 | + e.stopPropagation(); |
| 1956 | + } ); |
| 1957 | + |
| 1958 | + |
| 1959 | + upload.details.div.mask(); |
2083 | 1960 | }, |
2084 | 1961 | |
2085 | 1962 | |
— | — | @@ -2092,6 +1969,7 @@ |
2093 | 1970 | */ |
2094 | 1971 | removeUpload: function( upload ) { |
2095 | 1972 | var _this = this; |
| 1973 | + upload.unbind(); // everything |
2096 | 1974 | mw.UploadWizardUtil.removeItem( _this.uploads, upload ); |
2097 | 1975 | _this.updateFileCounts(); |
2098 | 1976 | }, |
— | — | @@ -2220,7 +2098,7 @@ |
2221 | 2099 | $j.each( _this.uploads, function(i, upload) { |
2222 | 2100 | upload.state = 'details'; |
2223 | 2101 | } ); |
2224 | | - _this.moveToTab('details'); |
| 2102 | + _this.moveToTab( 'details' ); |
2225 | 2103 | } |
2226 | 2104 | ); |
2227 | 2105 | }, |
— | — | @@ -2375,87 +2253,163 @@ |
2376 | 2254 | */ |
2377 | 2255 | stop: function() { |
2378 | 2256 | |
2379 | | - }, |
| 2257 | + } |
| 2258 | +}; |
2380 | 2259 | |
| 2260 | +mw.UploadWizardNullDeed = $j.extend( new mw.UploadWizardDeed(), { |
| 2261 | + isReady: function() { |
| 2262 | + return false; |
| 2263 | + } |
| 2264 | +} ); |
2381 | 2265 | |
| 2266 | + |
| 2267 | + |
| 2268 | +mw.UploadWizardDeedChooser = function( selector ) { |
| 2269 | + var _this = this; |
| 2270 | + _this.selector = selector; |
| 2271 | + _this.deed = mw.UploadWizardNullDeed; |
| 2272 | + |
| 2273 | + $j( selector ).html( |
| 2274 | + '<div class="mwe-upwiz-macro-deed-ownwork mwe-upwiz-deed">' |
| 2275 | + + '<div class="mwe-upwiz-deed-option-title">' |
| 2276 | + + '<span class="mwe-upwiz-deed-header mwe-closed">' |
| 2277 | + + '<a class="mwe-upwiz-deed-header-link mwe-upwiz-deed-name">' |
| 2278 | + + gM( 'mwe-upwiz-source-ownwork' ) |
| 2279 | + + '</a>' |
| 2280 | + + '</span>' |
| 2281 | + + '<span class="mwe-upwiz-deed-header mwe-open" style="display: none;">' |
| 2282 | + + '<span class="mwe-upwiz-deed-name">' + gM( 'mwe-upwiz-source-ownwork' ) + '</span>' |
| 2283 | + + ' <a class="mwe-upwiz-macro-deeds-return">' + gM( 'mwe-upwiz-change' ) + '</a>' |
| 2284 | + + '</span>' |
| 2285 | + + '</div>' // more deed stuff set up below |
| 2286 | + + '<div class="mwe-upwiz-deed-form"></div>' |
| 2287 | + + '</div>' |
| 2288 | + |
| 2289 | + + '<div class="mwe-upwiz-macro-deed-thirdparty mwe-upwiz-deed">' |
| 2290 | + + '<div class="mwe-upwiz-deed-option-title">' |
| 2291 | + + '<span class="mwe-upwiz-deed-header mwe-closed">' |
| 2292 | + + '<a class="mwe-upwiz-deed-header-link mwe-upwiz-deed-name">' |
| 2293 | + + gM( 'mwe-upwiz-source-thirdparty' ) |
| 2294 | + + '</a>' |
| 2295 | + + '</span>' |
| 2296 | + + '<span class="mwe-upwiz-deed-header mwe-open" style="display: none;">' |
| 2297 | + + '<span class="mwe-upwiz-deed-name">' + gM( 'mwe-upwiz-source-thirdparty' ) + '</span>' |
| 2298 | + + ' <a class="mwe-upwiz-macro-deeds-return">' + gM( 'mwe-upwiz-change' ) + '</a>' |
| 2299 | + + '</span>' |
| 2300 | + + '</div>' // more deed stuff set up below |
| 2301 | + + '<div class="mwe-upwiz-deed-form"></div>' |
| 2302 | + + '</div>' |
| 2303 | + ); |
| 2304 | + |
| 2305 | + $j( '.mwe-upwiz-macro-deeds-return' ).click( function() { _this.showDeedChoice(); } ); |
| 2306 | + |
| 2307 | + _this.setupDeedOwnWork(); |
| 2308 | + _this.setupDeedThirdParty(); |
| 2309 | + _this.showDeedChoice(); |
| 2310 | +}; |
| 2311 | + |
| 2312 | +mw.UploadWizardDeedChooser.prototype = { |
| 2313 | + choose: function( deed ) { |
| 2314 | + var _this = this; |
| 2315 | + _this.deed = deed; |
| 2316 | + mw.log( "choosing deed!" ); |
| 2317 | + mw.log( deed ); |
| 2318 | + if ( deed === mw.UploadWizardNullDeed ) { |
| 2319 | + $j( _this ).trigger( 'chooseNullDeed' ); |
| 2320 | + mw.log("choose null deed"); |
| 2321 | + } else { |
| 2322 | + $j( _this ).trigger( 'chooseDeed' ); |
| 2323 | + } |
| 2324 | + }, |
| 2325 | + |
2382 | 2326 | /** |
2383 | 2327 | * Go back to original source choice. |
2384 | 2328 | * Assumed that we are in details mode. |
2385 | 2329 | */ |
2386 | 2330 | showDeedChoice: function() { |
2387 | 2331 | var _this = this; |
2388 | | - $j( '#mwe-upwiz-macro-deeds' ).find( '.mwe-upwiz-deed-header.mwe-open' ).hide(); |
2389 | | - $j( '#mwe-upwiz-macro-deeds' ).find( '.mwe-upwiz-deed-header.mwe-closed' ).show(); |
2390 | | - $j( '#mwe-upwiz-macro-deeds' ).find( '.mwe-upwiz-deed' ).fadeIn( 'fast' ); |
2391 | | - $j( '#mwe-upwiz-macro-deeds' ).find( '.mwe-upwiz-deed-form' ).fadeOut('fast'); |
| 2332 | + $j( _this.selector ).find( '.mwe-upwiz-deed-header.mwe-open' ).hide(); |
| 2333 | + $j( _this.selector ).find( '.mwe-upwiz-deed-header.mwe-closed' ).show(); |
| 2334 | + $j( _this.selector ).find( '.mwe-upwiz-deed' ).maskSafeShow(); |
| 2335 | + $j( _this.selector ).find( '.mwe-upwiz-deed-form' ).maskSafeHide(); |
2392 | 2336 | // reset deed |
2393 | | - _this.nullDeed.applyDeed( _this.uploads ); |
2394 | | - }, |
| 2337 | + _this.choose( mw.UploadWizardNullDeed ); |
| 2338 | + }, |
2395 | 2339 | |
2396 | | - |
2397 | 2340 | /** |
2398 | | - * From the deed choice page, show the 'own work' deed |
| 2341 | + * From the deed choice page, show a deed |
2399 | 2342 | */ |
2400 | 2343 | showDeed: function( selector ) { |
2401 | 2344 | $j( selector ).find( '.mwe-upwiz-deed-header.mwe-open' ).show(); |
2402 | 2345 | $j( selector ).find( '.mwe-upwiz-deed-header.mwe-closed' ).hide(); |
2403 | | - $j( selector ).siblings().fadeOut( 'fast' ); |
2404 | | - $j( selector ).find( '.mwe-upwiz-deed-form' ).fadeIn( 'fast' ); |
| 2346 | + $j( selector ).siblings().maskSafeHide(); |
| 2347 | + $j( selector ).find( '.mwe-upwiz-deed-form' ).maskSafeShow(); |
2405 | 2348 | }, |
2406 | | - |
2407 | | - /** |
2408 | | - * Deed to copy values from when no deed is selected |
2409 | | - */ |
2410 | | - setupNullDeed: function() { |
2411 | | - var _this = this; |
2412 | | - var sourceInput = $j( '<input />').attr( { name: "source", value: "" } ); |
2413 | | - var authorInput = $j( '<input />').attr( { name: "author", value: "" } ); |
2414 | | - var licenseInput = new mw.UploadWizardLicenseInput( $j('<div/>'), [] ); |
2415 | | - _this.nullDeed = new mw.UploadWizardDeed( { 'source': sourceInput, 'author': authorInput, 'license': licenseInput } ); |
2416 | | - }, |
2417 | 2349 | |
2418 | 2350 | /** |
2419 | | - * Set up the form for the deed option that says these uploads are all the user's own work. |
| 2351 | + * Set up the form and deed object for the deed option that says these uploads are all the user's own work. |
2420 | 2352 | */ |
2421 | 2353 | setupDeedOwnWork: function() { |
2422 | 2354 | mw.log("setupdeed own work"); |
2423 | 2355 | var _this = this; |
2424 | 2356 | |
2425 | | - var authorInput = $j( '<input />').attr( { name: "author" } ); |
| 2357 | + var authorInput = $j( '<input />') |
| 2358 | + .attr( { name: "author" } ) |
| 2359 | + .addClass( 'mwe-upwiz-sign' ); |
2426 | 2360 | |
2427 | 2361 | var licenseInputDiv = $j( '<div class="mwe-upwiz-deed-license"></div>' ); |
2428 | 2362 | var licenseInput = new mw.UploadWizardLicenseInput( licenseInputDiv ); |
2429 | 2363 | licenseInput.setDefaultValues(); |
2430 | 2364 | |
2431 | | - ownWorkDeed = new mw.UploadWizardDeed( { 'author': authorInput, 'license': licenseInput } ); |
2432 | | - ownWorkDeed.isOwn = true; |
2433 | | - ownWorkDeed.setCustomizable( { 'source': false, 'author': true, 'license' : true } ); |
| 2365 | + var ownWorkDeed = $j.extend( new mw.UploadWizardDeed(), { |
| 2366 | + |
| 2367 | + licenseInput: licenseInput, |
2434 | 2368 | |
2435 | | - // one or the other of these inputs must be checked to apply the deed. |
2436 | | - ownWorkDeed.setReadyCheck( function() { |
2437 | | - return $j( '#mwe-upwiz-deed-accept-ownwork-default' ).is( ':checked' ) |
2438 | | - || $j( '#mwe-upwiz-deed-accept-ownwork-custom' ).is( ':checked' ) |
2439 | | - } ); |
| 2369 | + isReady: function() { |
| 2370 | + $j( _this.selector ).find( '.mwe-upwiz-deed-accept-ownwork-default' ).is( ':checked' ) |
| 2371 | + || $j( _this.selector ).find( '.mwe-upwiz-deed-accept-ownwork-custom' ).is( ':checked' ) |
| 2372 | + }, |
2440 | 2373 | |
2441 | | - licenseInput.setChange( function() { ownWorkDeed.applyDeed( _this.uploads ) } ); |
| 2374 | + getSourceWikiText: function() { |
| 2375 | + return '{{own}}'; |
| 2376 | + }, |
2442 | 2377 | |
| 2378 | + getAuthorWikiText: function() { |
| 2379 | + return "[[User:" + mw.getConfig('userName') + '|' + $j( authorInput ).val() + ']]'; |
| 2380 | + }, |
2443 | 2381 | |
| 2382 | + |
| 2383 | + getLicenseWikiText: function() { |
| 2384 | + var wikiText = '{{self'; |
| 2385 | + $j.each ( _this.licenseInput.licenses, function( key, data ) { |
| 2386 | + if ( data.input.checked ) { |
| 2387 | + wikiText += '|' + data.template; |
| 2388 | + } |
| 2389 | + } ); |
| 2390 | + wikiText += '}}'; |
| 2391 | + return wikiText; |
| 2392 | + } |
| 2393 | + } ); |
| 2394 | + |
2444 | 2395 | var standardDiv = $j( '<div />' ) |
2445 | 2396 | .append( |
2446 | 2397 | $j( '<input />') |
2447 | | - .attr( { id: 'mwe-upwiz-deed-accept-ownwork-default', type: 'checkbox' } ) |
| 2398 | + .attr( { type: 'checkbox' } ) |
2448 | 2399 | .click( function() { |
2449 | | - ownWorkDeed.licenseInput.setDefaultValues(); |
2450 | | - ownWorkDeed.applyDeed( _this.uploads ); |
| 2400 | + if ( $j( this ).is( ':checked' ) ) { |
| 2401 | + ownWorkDeed.licenseInput.setDefaultValues(); |
| 2402 | + _this.choose( ownWorkDeed ); |
| 2403 | + } else { |
| 2404 | + _this.choose( mw.UploadWizardNullDeed ); |
| 2405 | + } |
2451 | 2406 | } ) |
2452 | | - .addClass( 'mwe-checkbox-hang-indent' ), |
| 2407 | + .addClass( 'mwe-upwiz-deed-accept-ownwork-default mwe-checkbox-hang-indent' ), |
2453 | 2408 | $j( '<p />' ) |
2454 | 2409 | .addClass( 'mwe-checkbox-hang-indent-text' ) |
2455 | 2410 | .html( gM( 'mwe-upwiz-source-ownwork-assert', |
2456 | 2411 | $j( '<input />' ) |
2457 | 2412 | .attr( { name: 'author' } ) |
2458 | | - .addClass( 'mwe-upwiz-sign' ) |
2459 | | - .blur( function() { ownWorkDeed.applyDeed( _this.uploads ); } ) ) ), |
| 2413 | + .addClass( 'mwe-upwiz-sign' ) ) ), |
2460 | 2414 | $j( '<p />' ) |
2461 | 2415 | .addClass( 'mwe-checkbox-hang-indent-text' ) |
2462 | 2416 | .addClass( 'mwe-small-print' ) |
— | — | @@ -2467,34 +2421,36 @@ |
2468 | 2422 | var customDiv = $j('<div/>') |
2469 | 2423 | .append( |
2470 | 2424 | $j( '<input />') |
2471 | | - .attr( { id: 'mwe-upwiz-deed-accept-ownwork-custom', type: 'checkbox' } ) |
2472 | | - .click( function() { ownWorkDeed.applyDeed( _this.uploads ); } ) |
2473 | | - .addClass( 'mwe-checkbox-hang-indent' ), |
| 2425 | + .attr( { type: 'checkbox' } ) |
| 2426 | + .click( function() { |
| 2427 | + if ( $j( this ).is( ':checked' ) ) { |
| 2428 | + _this.choose( ownWorkDeed ); |
| 2429 | + } else { |
| 2430 | + _this.choose( mw.UploadWizardNullDeed ); |
| 2431 | + } |
| 2432 | + } ) |
| 2433 | + .addClass( 'mwe-upwiz-deed-accept-ownwork-custom mwe-checkbox-hang-indent' ), |
2474 | 2434 | $j( '<p />' ) |
2475 | 2435 | .addClass( 'mwe-checkbox-hang-indent-text' ) |
2476 | 2436 | .append( gM( 'mwe-upwiz-source-ownwork-assert-custom', |
2477 | 2437 | '<span id="mwe-custom-author-input"></span>' ) ), |
2478 | 2438 | licenseInputDiv ) |
2479 | | - .hide(); |
| 2439 | + .maskSafeHide(); |
2480 | 2440 | |
2481 | | - hiddenInputsDiv = $j( '<span />' ).hide().append( _this.sourceInput ); |
2482 | | - |
2483 | | - $j( '#mwe-upwiz-macro-deed-ownwork .mwe-upwiz-deed-form' ). |
2484 | | - append( standardDiv, |
2485 | | - toggleDiv, |
2486 | | - customDiv, |
2487 | | - hiddenInputsDiv ); |
| 2441 | + $j( _this.selector ).find( '.mwe-upwiz-macro-deed-ownwork .mwe-upwiz-deed-form' ) |
| 2442 | + .append( standardDiv, |
| 2443 | + toggleDiv, |
| 2444 | + customDiv ); |
2488 | 2445 | |
2489 | 2446 | mw.UploadWizardUtil.makeFadingToggler( standardDiv, toggleDiv, customDiv ); |
2490 | 2447 | |
2491 | 2448 | // have to add the author input this way -- gM() will flatten it to a string and we'll lose it as a dom object |
2492 | | - authorInput.blur( function() { ownWorkDeed.applyDeed( _this.uploads ) } ).addClass( 'mwe-upwiz-sign' ); |
2493 | | - $j( '#mwe-custom-author-input' ).append( authorInput ); |
| 2449 | + $j( _this.selector ).find( '.mwe-custom-author-input' ).append( authorInput ); |
2494 | 2450 | |
2495 | 2451 | // synchronize both username signatures |
2496 | 2452 | // set initial value to configured username |
2497 | 2453 | // if one changes all the others change |
2498 | | - $j( '.mwe-upwiz-sign' ) |
| 2454 | + $j( _this.selector ).find( '.mwe-upwiz-sign' ) |
2499 | 2455 | .attr( { value: mw.getConfig( 'userName' ) } ) |
2500 | 2456 | .keyup( function() { |
2501 | 2457 | var thisInput = this; |
— | — | @@ -2507,90 +2463,75 @@ |
2508 | 2464 | } ); |
2509 | 2465 | |
2510 | 2466 | |
2511 | | - $j( '#mwe-upwiz-macro-deed-ownwork .mwe-upwiz-deed-header-link').click( |
| 2467 | + $j( _this.selector ).find( '.mwe-upwiz-macro-deed-ownwork .mwe-upwiz-deed-header-link').click( |
2512 | 2468 | function() { |
2513 | | - _this.showDeed( $j( '#mwe-upwiz-macro-deed-ownwork' ) ); |
2514 | | - ownWorkDeed.applyDeed( _this.uploads ); |
| 2469 | + _this.showDeed( $j( '.mwe-upwiz-macro-deed-ownwork' ) ); |
2515 | 2470 | } |
2516 | 2471 | ); |
2517 | 2472 | }, |
2518 | 2473 | |
2519 | | - /** |
2520 | | - * Set up the deed for when you "found pics on a website", i.e. there's a third party |
2521 | | - */ |
2522 | 2474 | setupDeedThirdParty: function() { |
2523 | | - mw.log("setupdeed third party"); |
2524 | 2475 | var _this = this; |
2525 | | - |
2526 | | - var sourceInput = $j('<textarea class="mwe-source" name="source" rows="1" cols="40"></textarea>' ) |
| 2476 | + var sourceInput = $j('<textarea class="mwe-source mwe-long-textarea" name="source" rows="1" cols="40"></textarea>' ) |
2527 | 2477 | .growTextArea() |
2528 | | - .blur( function() { thirdPartyDeed.applyDeed( _this.uploads ); } ); |
2529 | | - var authorInput = $j('<textarea class="mwe-author" name="author" rows="1" cols="40"></textarea>' ) |
| 2478 | + var authorInput = $j('<textarea class="mwe-author mwe-long-textarea" name="author" rows="1" cols="40"></textarea>' ) |
2530 | 2479 | .growTextArea() |
2531 | | - .blur( function() { thirdPartyDeed.applyDeed( _this.uploads ); } ); |
2532 | | - var licenseInputDiv = $j( '<div class="mwe-upwiz-deed-license"></div>' ); |
2533 | | - var licenseInput = new mw.UploadWizardLicenseInput( licenseInputDiv ); |
| 2480 | + licenseInputDiv = $j( '<div class="mwe-upwiz-deed-license"></div>' ); |
| 2481 | + licenseInput = new mw.UploadWizardLicenseInput( licenseInputDiv ); |
2534 | 2482 | licenseInput.setDefaultValues(); |
2535 | 2483 | |
2536 | | - thirdPartyDeed = new mw.UploadWizardDeed( { 'source': sourceInput, 'author' : authorInput, 'license' : licenseInput } ); |
2537 | | - |
2538 | | - licenseInput.setChange( function() { thirdPartyDeed.applyDeed( _this.uploads ); } ); |
| 2484 | + var thirdPartyDeed = $j.extend( new mw.UploadWizardDeed(), { |
| 2485 | + sourceInput: sourceInput, |
| 2486 | + authorInput: authorInput, |
| 2487 | + licenseInput: licenseInput, |
2539 | 2488 | |
2540 | | - var standardDiv = $j( '<div />' ); |
2541 | | - /* .append( |
2542 | | - $j( '<p />' ).html( gM( 'mwe-upwiz-source-thirdparty-intro' ) ) |
2543 | | - ); |
2544 | | - */ |
2545 | | - |
2546 | | - var toggleDiv = $j( '<div />' ); |
| 2489 | + isReady: function() { |
| 2490 | + return (! mw.isEmpty( $j( _this.sourceInput ).val() ) ) |
| 2491 | + && (! mw.isEmpty( $j( _this.authorInput ).val() ) ) |
| 2492 | + && (! mw.isEmpty( $j( _this.licenseInput ).val() ) ) |
| 2493 | + } |
| 2494 | + |
| 2495 | + } ); |
2547 | 2496 | |
2548 | 2497 | var customDiv = $j( '<div />' ) |
2549 | | - .append( |
2550 | | - $j( '<div />' ).append( gM( 'mwe-upwiz-source-thirdparty-custom-intro' ) ), |
2551 | | - $j( '<div />' ) |
2552 | | - .addClass( "mwe-upwiz-thirdparty-fields" ) |
2553 | | - .append( $j( '<label />' ) |
2554 | | - .attr( { 'for' : 'source' } ) |
2555 | | - .text( gM( 'mwe-upwiz-source' ) ) ) |
2556 | | - .append( sourceInput ), |
2557 | | - $j( '<div />' ) |
2558 | | - .addClass( "mwe-upwiz-thirdparty-fields" ) |
2559 | | - .append( $j( '<label />' ) |
2560 | | - .attr( { 'for' : 'author' } ) |
2561 | | - .text( gM( 'mwe-upwiz-author' ) ) ) |
2562 | | - .append( authorInput ), |
2563 | | - $j( '<div />' ).text( gM( 'mwe-upwiz-source-thirdparty-license' ) ), |
2564 | | - licenseInputDiv |
2565 | | - ).hide(); |
| 2498 | + .append( |
| 2499 | + $j( '<div />' ).append( gM( 'mwe-upwiz-source-thirdparty-custom-intro' ) ), |
| 2500 | + $j( '<div />' ) |
| 2501 | + .addClass( "mwe-upwiz-thirdparty-fields" ) |
| 2502 | + .append( $j( '<label />' ) |
| 2503 | + .attr( { 'for' : 'source' } ) |
| 2504 | + .text( gM( 'mwe-upwiz-source' ) ) ) |
| 2505 | + .append( sourceInput ), |
| 2506 | + $j( '<div />' ) |
| 2507 | + .addClass( "mwe-upwiz-thirdparty-fields" ) |
| 2508 | + .append( $j( '<label />' ) |
| 2509 | + .attr( { 'for' : 'author' } ) |
| 2510 | + .text( gM( 'mwe-upwiz-author' ) ) ) |
| 2511 | + .append( authorInput ), |
| 2512 | + $j( '<div />' ).text( gM( 'mwe-upwiz-source-thirdparty-license' ) ), |
| 2513 | + licenseInputDiv |
| 2514 | + ); |
2566 | 2515 | |
| 2516 | + $j( _this.selector ).find( '.mwe-upwiz-macro-deed-thirdparty .mwe-upwiz-deed-form' ).append( customDiv ); |
2567 | 2517 | |
2568 | | - $j( '#mwe-upwiz-macro-deed-thirdparty .mwe-upwiz-deed-form' ). |
2569 | | - append( standardDiv, toggleDiv, customDiv ); |
2570 | | - |
2571 | | - mw.UploadWizardUtil.makeFadingToggler( standardDiv, toggleDiv, customDiv ); |
2572 | | - |
2573 | | - $j( '.mwe-upwiz-deed-thirdparty-accept' ) |
| 2518 | + $j( _this.selector ).find( '.mwe-upwiz-deed-thirdparty-accept' ) |
2574 | 2519 | .attr( { value: gM( 'mwe-upwiz-source-thirdparty-accept' ) } ) |
2575 | 2520 | .click( function() { |
2576 | | - thirdPartyDeed.applyDeed( _this.uploads ); |
| 2521 | + _this.choose( thirdPartyDeed ); |
2577 | 2522 | } ); |
2578 | 2523 | |
2579 | | - $j( '#mwe-upwiz-macro-deed-thirdparty .mwe-upwiz-deed-header-link').click( |
| 2524 | + $j( _this.selector ).find( '.mwe-upwiz-macro-deed-thirdparty .mwe-upwiz-deed-header-link').click( |
2580 | 2525 | function() { |
2581 | | - _this.showDeed( $j( '#mwe-upwiz-macro-deed-thirdparty' ) ); |
2582 | | - thirdPartyDeed.applyDeed( _this.uploads ); |
| 2526 | + _this.showDeed( $j( '.mwe-upwiz-macro-deed-thirdparty' ) ); |
| 2527 | + _this.choose( thirdPartyDeed ); |
2583 | 2528 | } |
2584 | 2529 | ); |
2585 | 2530 | |
| 2531 | + } |
| 2532 | +}; |
2586 | 2533 | |
2587 | | - }, |
2588 | 2534 | |
2589 | 2535 | |
2590 | | - |
2591 | | - |
2592 | | - |
2593 | | -}; |
2594 | | - |
2595 | 2536 | /** |
2596 | 2537 | * Miscellaneous utilities |
2597 | 2538 | */ |
— | — | @@ -2646,17 +2587,17 @@ |
2647 | 2588 | text.text( gM( 'mwe-upwiz-fewer-options' ) ); |
2648 | 2589 | icon.removeClass( "ui-icon-triangle-1-e" ) |
2649 | 2590 | .addClass( "ui-icon-triangle-1-s" ); |
2650 | | - moreDiv.show(); |
| 2591 | + moreDiv.maskSafeShow(); |
2651 | 2592 | if (fade) { |
2652 | | - standardDiv.disableInputsFade(); |
| 2593 | + standardDiv.mask(); |
2653 | 2594 | } |
2654 | 2595 | } else { |
2655 | 2596 | text.text( gM( 'mwe-upwiz-more-options' ) ); |
2656 | 2597 | icon.removeClass( "ui-icon-triangle-1-s" ) |
2657 | 2598 | .addClass( "ui-icon-triangle-1-e" ) |
2658 | | - moreDiv.hide(); |
| 2599 | + moreDiv.maskSafeHide(); |
2659 | 2600 | if (fade) { |
2660 | | - standardDiv.enableInputsFade(); |
| 2601 | + standardDiv.unmask(); |
2661 | 2602 | } |
2662 | 2603 | } |
2663 | 2604 | }; |
— | — | @@ -2771,23 +2712,81 @@ |
2772 | 2713 | return this; |
2773 | 2714 | }; |
2774 | 2715 | |
2775 | | -jQuery.fn.disableInputsFade = function( options ) { |
2776 | | - this.fadeTo( 'fast', 0.5 ); |
2777 | | - $j.each( this.find( 'input' ), function( i, input ) { |
2778 | | - if ( input.disabled ) { |
2779 | | - $j( input ).data( { wasDisabled: true } ); |
2780 | | - } |
2781 | | - input.disabled = true; |
| 2716 | +jQuery.fn.mask = function( options ) { |
| 2717 | + |
| 2718 | + // intercept clicks... |
| 2719 | + // Note: the size of the div must be obtainable. Hence, this cannot be a div without layout (e.g. display:none). |
| 2720 | + // some of this is borrowed from http://code.google.com/p/jquery-loadmask/ , but simplified |
| 2721 | + $j.each( this, function( i, el ) { |
| 2722 | + |
| 2723 | + if ( ! $j( el ).data( 'mask' ) ) { |
| 2724 | + |
| 2725 | + |
| 2726 | + //fix for z-index bug with selects in IE6 |
| 2727 | + if ( $j.browser.msie && $j.browser.version.substring(0,1) === '6' ){ |
| 2728 | + el.find( "select" ).addClass( "masked-hidden" ); |
| 2729 | + } |
| 2730 | + |
| 2731 | + var mask = $j( '<div />' ) |
| 2732 | + .css( { 'position' : 'absolute', |
| 2733 | + 'top' : '0px', // el.offsetTop + 'px', |
| 2734 | + 'left' : '0px', // el.offsetLeft + 'px', |
| 2735 | + 'width' : el.offsetWidth + 'px', |
| 2736 | + 'height' : el.offsetHeight + 'px', |
| 2737 | + 'z-index' : 100 } ) |
| 2738 | + .click( function( e ) { e.stopPropagation(); } ); |
| 2739 | + |
| 2740 | + $j( el ).css( { 'position' : 'relative' } ) |
| 2741 | + .fadeTo( 'fast', 0.5 ) |
| 2742 | + .append( mask ) |
| 2743 | + .data( 'mask', mask ); |
| 2744 | + |
| 2745 | + //auto height fix for IE -- not sure about this, i think offsetWidth + Height is a better solution. Test! |
| 2746 | + /* |
| 2747 | + if( $j.browser.msie ) { |
| 2748 | + mask.height(el.height() + parseInt(el.css("padding-top")) + parseInt(el.css("padding-bottom"))); |
| 2749 | + mask.width(el.width() + parseInt(el.css("padding-left")) + parseInt(el.css("padding-right"))); |
| 2750 | + } |
| 2751 | + */ |
| 2752 | + |
| 2753 | + } |
| 2754 | + |
| 2755 | + // XXX bind to a custom event in case the div size changes : ? |
| 2756 | + |
2782 | 2757 | } ); |
| 2758 | + |
2783 | 2759 | return this; |
| 2760 | + |
2784 | 2761 | }; |
2785 | 2762 | |
2786 | | -jQuery.fn.enableInputsFade = function( options ) { |
2787 | | - $j.each( this.find( 'input' ), function( i, input ) { |
2788 | | - if ( ! $j( input ).data( 'wasDisabled' ) ) { |
2789 | | - input.disabled = false; |
| 2763 | +jQuery.fn.unmask = function( options ) { |
| 2764 | + |
| 2765 | + $j.each( this, function( i, el ) { |
| 2766 | + if ( $j( el ).data( 'mask' ) ) { |
| 2767 | + var mask = $j( el ).data( 'mask' ); |
| 2768 | + $j( el ).removeData( 'mask' ); // from the data |
| 2769 | + mask.remove(); // from the DOM |
| 2770 | + $j( el ).fadeTo( 'fast', 1.0 ); |
2790 | 2771 | } |
2791 | 2772 | } ); |
2792 | | - this.fadeTo( 'fast', 1.0 ); |
| 2773 | + |
| 2774 | + |
2793 | 2775 | return this; |
2794 | 2776 | }; |
| 2777 | + |
| 2778 | + |
| 2779 | +/** |
| 2780 | + * Safe hide and show |
| 2781 | + * Rather than use display: none, this collapses the divs to zero height |
| 2782 | + * This is good because then the elements in the divs still have layout and we can do things like mask and unmask (above) |
| 2783 | + */ |
| 2784 | + |
| 2785 | +jQuery.fn.maskSafeHide = function( options ) { |
| 2786 | + return this.css( { 'height' : '0px', 'overflow' : 'hidden' } ); |
| 2787 | +}; |
| 2788 | + |
| 2789 | +// XXX check overflow properties, is auto/auto not the right thing? |
| 2790 | +// may be causing scrollbar to appear when div changes size |
| 2791 | +jQuery.fn.maskSafeShow = function( options ) { |
| 2792 | + return this.css( { 'height' : 'auto', 'overflow' : 'visible' } ); |
| 2793 | +}; |
Index: branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/css/uploadWizard.css |
— | — | @@ -113,7 +113,7 @@ |
114 | 114 | |
115 | 115 | /* file inputs are freakishly large to overflow the containing div -- we get a div |
116 | 116 | that can act as a more styleable single-click file input */ |
117 | | -.mwe-upwiz-file-input { |
| 117 | +.mwe-upwiz-file-input, .disabler { |
118 | 118 | font-size: 100px; |
119 | 119 | -moz-opacity: 0.3; |
120 | 120 | filter:alpha(opacity: 0); |
— | — | @@ -278,6 +278,11 @@ |
279 | 279 | background: yellow; |
280 | 280 | } |
281 | 281 | |
| 282 | +.mwe-upwiz-tabdiv { |
| 283 | + height: 0px; |
| 284 | + overflow: hidden; |
| 285 | +} |
| 286 | + |
282 | 287 | #mwe-upwiz-tabdiv-file { |
283 | 288 | width: 550px; |
284 | 289 | } |
— | — | @@ -345,10 +350,14 @@ |
346 | 351 | margin-bottom: 12px; |
347 | 352 | } |
348 | 353 | |
| 354 | +#mwe-upwiz-macro-files { |
| 355 | + margin-top: 12px; |
| 356 | +} |
349 | 357 | .mwe-upwiz-details-file { |
350 | 358 | border-bottom: 1px solid #e0e0e0; |
351 | 359 | margin-bottom: 12px; |
352 | 360 | padding-bottom: 12px; |
| 361 | + width: 660px; |
353 | 362 | } |
354 | 363 | |
355 | 364 | |
— | — | @@ -395,4 +404,27 @@ |
396 | 405 | |
397 | 406 | } |
398 | 407 | |
399 | | -. |
| 408 | +#mwe-upwiz-details-filename. { |
| 409 | + overflow: hidden; |
| 410 | + width: 350px; |
| 411 | +} |
| 412 | + |
| 413 | +#mwe-upwiz-other-textarea, fieldset.mwe-fieldset { |
| 414 | + width: 450px; |
| 415 | +} |
| 416 | + |
| 417 | +fieldset.mwe-fieldset { |
| 418 | + border: 1px solid #cccccc; |
| 419 | + padding-left: 12px; |
| 420 | + padding-right: 12px; |
| 421 | +} |
| 422 | + |
| 423 | +legend.mwe-legend { |
| 424 | + padding: 0.5em 0.5em 0.5em 0.33em; |
| 425 | + color: #666666; |
| 426 | +} |
| 427 | + |
| 428 | +.masked-hidden { |
| 429 | + visibility: hidden !important; |
| 430 | +} |
| 431 | + |
Index: branches/js2-work/phase3/js/specialUploadWizardPage.js |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | // Commons already had a template called 'tl', though. |
23 | 23 | // so, this workaround will cause tagalog descriptions to be saved with this template instead. |
24 | 24 | mw.setConfig( 'languageTemplateFixups', { tl: 'tgl' } ); |
25 | | - mw.setConfig( 'defaultLicenses', [ 'cc_by_sa_30', 'gfdl' ] ); |
| 25 | + mw.setConfig( 'defaultLicenses', [ 'cc_by_sa_30' ] ); |
26 | 26 | |
27 | 27 | var uploadWizard = new mw.UploadWizard(); |
28 | 28 | uploadWizard.createInterface( '#upload-wizard' ); |