Index: branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/mw.UploadWizard.js |
— | — | @@ -47,7 +47,7 @@ |
48 | 48 | "mwe-upwiz-other-prefill": "Free wikitext field", |
49 | 49 | "mwe-upwiz-showall": "show all", |
50 | 50 | "mwe-upwiz-source": "Source", |
51 | | - "mwe-upwiz-macro-edit-intro": "Please add some descriptions and other information to your uploads, and then press 'Update descriptions'", |
| 51 | + "mwe-upwiz-macro-edit-intro": "Please add some descriptions and other information to your uploads, and then press 'Update descriptions'.", |
52 | 52 | "mwe-upwiz-macro-edit": "Update descriptions", |
53 | 53 | "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.", |
54 | 54 | "mwe-upwiz-thanks-link": "This file is now available at <b><tt>$1</tt></b>.", |
— | — | @@ -1365,7 +1365,7 @@ |
1366 | 1366 | // check descriptions |
1367 | 1367 | // the filename is in a sane state |
1368 | 1368 | var desiredFilename = "File:" + $j( _this.filenameInput ).val(); |
1369 | | - shouldRename = (desiredFilename != _this.upload.title); |
| 1369 | + shouldRename = ( desiredFilename != _this.upload.title ); |
1370 | 1370 | |
1371 | 1371 | // if ok to go |
1372 | 1372 | // XXX lock down the interface, spinnerify |
— | — | @@ -1379,30 +1379,33 @@ |
1380 | 1380 | |
1381 | 1381 | var params = { |
1382 | 1382 | action: 'edit', |
1383 | | - token: mw.getConfig('token'), |
| 1383 | + token: mw.getConfig( 'token' ), |
1384 | 1384 | title: _this.upload.title, |
1385 | 1385 | // section: 0, ?? causing issues? |
1386 | 1386 | text: wikiText, |
1387 | 1387 | summary: "User edited page with " + mw.UploadWizard.userAgent, |
1388 | 1388 | // notminor: 1, |
1389 | | - // basetimestamp: _this.upload.imageinfo.timestamp, (conflicts?) |
| 1389 | + // basetimestamp: _this.upload.imageinfo.timestamp, ( conflicts? ) |
1390 | 1390 | nocreate: 1 |
1391 | 1391 | }; |
1392 | | - mw.log("editing!"); |
1393 | | - mw.log(params); |
1394 | | - var callback = function(result) { |
1395 | | - mw.log(result); |
1396 | | - mw.log("successful edit"); |
| 1392 | + |
| 1393 | + var endCallback = function() { _this.completeDetailsSubmission(); } |
| 1394 | + |
| 1395 | + mw.log( "editing!" ); |
| 1396 | + mw.log( params ); |
| 1397 | + var callback = function( result ) { |
| 1398 | + mw.log( result ); |
| 1399 | + mw.log( "successful edit" ); |
1397 | 1400 | if ( shouldRename ) { |
1398 | | - _this.rename( desiredFilename ); |
| 1401 | + _this.rename( desiredFilename, endCallback ); |
1399 | 1402 | } else { |
1400 | | - _this.completeDetailsSubmission(); |
| 1403 | + endCallback(); |
1401 | 1404 | } |
1402 | 1405 | } |
1403 | 1406 | |
1404 | 1407 | _this.upload.state = 'submitting-details'; |
1405 | 1408 | _this.showProgress(); |
1406 | | - mw.getJSON(params, callback); |
| 1409 | + mw.getJSON( params, callback ); |
1407 | 1410 | }, |
1408 | 1411 | |
1409 | 1412 | /** |
— | — | @@ -1417,7 +1420,7 @@ |
1418 | 1421 | * |
1419 | 1422 | * @param filename to rename this file to |
1420 | 1423 | */ |
1421 | | - rename: function( title ) { |
| 1424 | + rename: function( title, endCallback ) { |
1422 | 1425 | var _this = this; |
1423 | 1426 | mw.log("renaming!"); |
1424 | 1427 | params = { |
— | — | @@ -1435,30 +1438,65 @@ |
1436 | 1439 | // handle errors later |
1437 | 1440 | // possible error data: { code = 'missingtitle' } -- orig filename not there |
1438 | 1441 | // and many more |
1439 | | - |
| 1442 | + |
| 1443 | + // which should match our request. |
| 1444 | + // we should update the current upload filename |
| 1445 | + // then call the uploadwizard with our progress |
| 1446 | + |
1440 | 1447 | // success is |
1441 | 1448 | // { move = { from : ..., reason : ..., redirectcreated : ..., to : .... } |
1442 | 1449 | if (data !== undefined && data.move !== undefined && data.move.to !== undefined) { |
1443 | 1450 | _this.upload.title = data.move.to; |
| 1451 | + _this.refreshImageInfo( _this.upload, _this.upload.title, endCallback ); |
1444 | 1452 | } |
| 1453 | + } ); |
| 1454 | + }, |
1445 | 1455 | |
1446 | | - // which should match our request. |
1447 | | - // we should update the current upload filename |
1448 | | - // then call the uploadwizard with our progress |
1449 | | - _this.completeDetailsSubmission(); |
| 1456 | + /** |
| 1457 | + * Get new image info, for instance, after we renamed an image |
| 1458 | + * XXX this is very similar to getThumbnail |
| 1459 | + * XXX ought to be a method on upload instead |
| 1460 | + * |
| 1461 | + * @param upload an UploadWizardUpload object |
| 1462 | + * @param title title to look up remotely |
| 1463 | + * @param endCallback execute upon completion |
| 1464 | + */ |
| 1465 | + refreshImageInfo: function( upload, title, endCallback ) { |
| 1466 | + var params = { |
| 1467 | + 'titles': title, |
| 1468 | + 'prop': 'imageinfo', |
| 1469 | + 'iiprop': 'timestamp|url|user|size|sha1|mime|metadata' |
| 1470 | + }; |
| 1471 | + // XXX timeout callback? |
| 1472 | + mw.getJSON( params, function( data ) { |
| 1473 | + if ( data && data.query && data.query.pages ) { |
| 1474 | + if ( ! data.query.pages[-1] ) { |
| 1475 | + for ( var page_id in data.query.pages ) { |
| 1476 | + var page = data.query.pages[ page_id ]; |
| 1477 | + if ( ! page.imageinfo ) { |
| 1478 | + // not found? error |
| 1479 | + } else { |
| 1480 | + upload.imageinfo = page.imageinfo[0]; |
| 1481 | + } |
| 1482 | + } |
| 1483 | + } |
| 1484 | + } |
| 1485 | + endCallback(); |
1450 | 1486 | } ); |
1451 | 1487 | }, |
1452 | 1488 | |
1453 | 1489 | showProgress: function() { |
1454 | 1490 | var _this = this; |
1455 | | - _this.div.css( { background: 'grey' } ); |
| 1491 | + _this.div.disableInputsFade(); |
| 1492 | + // XXX spinnerize |
1456 | 1493 | _this.upload.detailsProgress = 1.0; |
1457 | 1494 | }, |
1458 | 1495 | |
1459 | 1496 | completeDetailsSubmission: function() { |
1460 | 1497 | var _this = this; |
1461 | 1498 | _this.upload.state = 'complete'; |
1462 | | - _this.div.css( { background: 'white' } ); |
| 1499 | + // XXX de-spinnerize |
| 1500 | + _this.div.enableInputsFade(); |
1463 | 1501 | }, |
1464 | 1502 | |
1465 | 1503 | /** |
— | — | @@ -1561,8 +1599,8 @@ |
1562 | 1600 | |
1563 | 1601 | |
1564 | 1602 | + '<div id="mwe-upwiz-content">' |
1565 | | - + '<div id="mwe-upwiz-tabdiv-file">' |
1566 | | - + '<div id="mwe-upwiz-intro">' + gM('mwe-upwiz-intro') + '</div>' |
| 1603 | + + '<div id="mwe-upwiz-tabdiv-file">' |
| 1604 | + + '<div id="mwe-upwiz-intro">' + gM('mwe-upwiz-intro') + '</div>' |
1567 | 1605 | + '<div id="mwe-upwiz-select-files">' + gM('mwe-upwiz-select-files') + '</div>' |
1568 | 1606 | + '<div id="mwe-upwiz-files"></div>' |
1569 | 1607 | + '<div><a id="mwe-upwiz-add-file">' + gM("mwe-upwiz-add-file-0") + '</a></div>' |
— | — | @@ -1570,48 +1608,47 @@ |
1571 | 1609 | + '<div id="mwe-upwiz-progress"></div>' |
1572 | 1610 | + '<div style="clear: left;"></div>' |
1573 | 1611 | + '</div>' |
1574 | | - + '</div>' |
1575 | | - + '<div id="mwe-upwiz-tabdiv-details">' |
1576 | | - + '<div id="mwe-upwiz-macro">' |
1577 | | - + '<div id="mwe-upwiz-macro-choice">' |
1578 | | - + '<div>' + gM( 'mwe-upwiz-intro-details' ) + '</div>' |
1579 | | - + '<div id="mwe-upwiz-macro-deeds">' |
1580 | | - + '<div id="mwe-upwiz-macro-deed-ownwork" class="deed">' |
1581 | | - + '<div class="mwe-deed-option-title">' |
1582 | | - + '<span class="deed-header closed"><a id="mwe-upwiz-source-ownwork">' + gM( 'mwe-upwiz-source-ownwork' ) + '</a></span>' |
1583 | | - + '<span class="deed-header open" style="display: none;">' |
1584 | | - + gM( 'mwe-upwiz-source-ownwork' ) |
1585 | | - + ' <a id="mwe-upwiz-source-ownwork-close">' + gM( 'mwe-upwiz-change' ) + '</a>' |
1586 | | - + '</span>' |
1587 | | - + '</div>' // more deed stuff set up below |
1588 | | - + '<div id="mwe-upwiz-macro-deed-ownwork-form" class="deed-form" style="display: none"></div>' |
1589 | | - + '</div>' |
1590 | | - + '<div id="mwe-upwiz-macro-deed-thirdparty" class="deed">' |
1591 | | - + '<div class="mwe-deed-option-title">' |
1592 | | - + '<span class="deed-header closed"><a id="mwe-upwiz-source-thirdparty">' + gM( 'mwe-upwiz-source-thirdparty' ) + '</a></span>' |
1593 | | - + '<span class="deed-header open" style="display: none;">' |
1594 | | - + gM( 'mwe-upwiz-source-thirdparty' ) |
1595 | | - + ' <a id="mwe-upwiz-source-thirdparty-close">' + gM( 'mwe-upwiz-change' ) + '</a>' |
1596 | | - + '</span>' |
1597 | | - + '</div>' // more deed stuff set up below |
1598 | | - + '<div id="mwe-upwiz-macro-deed-thirdparty-form" class="deed-form" style="display: none"></div>' |
1599 | | - + '</div>' |
1600 | | - + '</div>' |
| 1612 | + + '<div id="mwe-upwiz-tabdiv-details">' |
| 1613 | + + '<div id="mwe-upwiz-macro">' |
| 1614 | + + '<div id="mwe-upwiz-macro-choice">' |
| 1615 | + + '<div>' + gM( 'mwe-upwiz-intro-details' ) + '</div>' |
| 1616 | + + '<div id="mwe-upwiz-macro-deeds">' |
| 1617 | + + '<div id="mwe-upwiz-macro-deed-ownwork" class="deed">' |
| 1618 | + + '<div class="mwe-deed-option-title">' |
| 1619 | + + '<span class="deed-header closed"><a id="mwe-upwiz-source-ownwork">' + gM( 'mwe-upwiz-source-ownwork' ) + '</a></span>' |
| 1620 | + + '<span class="deed-header open" style="display: none;">' |
| 1621 | + + gM( 'mwe-upwiz-source-ownwork' ) |
| 1622 | + + ' <a id="mwe-upwiz-source-ownwork-close">' + gM( 'mwe-upwiz-change' ) + '</a>' |
| 1623 | + + '</span>' |
| 1624 | + + '</div>' // more deed stuff set up below |
| 1625 | + + '<div id="mwe-upwiz-macro-deed-ownwork-form" class="deed-form" style="display: none"></div>' |
| 1626 | + + '</div>' |
| 1627 | + + '<div id="mwe-upwiz-macro-deed-thirdparty" class="deed">' |
| 1628 | + + '<div class="mwe-deed-option-title">' |
| 1629 | + + '<span class="deed-header closed"><a id="mwe-upwiz-source-thirdparty">' + gM( 'mwe-upwiz-source-thirdparty' ) + '</a></span>' |
| 1630 | + + '<span class="deed-header open" style="display: none;">' |
| 1631 | + + gM( 'mwe-upwiz-source-thirdparty' ) |
| 1632 | + + ' <a id="mwe-upwiz-source-thirdparty-close">' + gM( 'mwe-upwiz-change' ) + '</a>' |
| 1633 | + + '</span>' |
| 1634 | + + '</div>' // more deed stuff set up below |
| 1635 | + + '<div id="mwe-upwiz-macro-deed-thirdparty-form" class="deed-form" style="display: none"></div>' |
| 1636 | + + '</div>' |
| 1637 | + + '</div>' |
| 1638 | + + '</div>' |
| 1639 | + + '<div id="mwe-upwiz-macro-edit" style="display: none">' |
| 1640 | + + '<div class="mwe-upwiz-macro-edit-submit">' |
| 1641 | + + '<p>' + gM( 'mwe-upwiz-macro-edit-intro' ) + '</p>' |
| 1642 | + + '</div>' // button added below |
| 1643 | + + '<div id="mwe-upwiz-macro-progress"></div>' |
| 1644 | + + '<div id="mwe-upwiz-macro-files"></div>' |
| 1645 | + + '<div class="mwe-upwiz-macro-edit-submit"></div>' // button added below |
| 1646 | + + '</div>' |
1601 | 1647 | + '</div>' |
1602 | | - + '<div id="mwe-upwiz-macro-edit" style="display: none">' |
1603 | | - + '<div class="mwe-upwiz-macro-edit-submit">' |
1604 | | - + '<p>' + gM( 'mwe-upwiz-macro-edit-intro' ) + '</p>' |
1605 | | - + '</div>' // button added below |
1606 | | - + '<div id="mwe-upwiz-macro-progress"></div>' |
1607 | | - + '<div id="mwe-upwiz-macro-files"></div>' |
1608 | | - + '<div class="mwe-upwiz-macro-edit-submit"></div>' // button added below |
1609 | | - + '</div>' |
1610 | 1648 | + '</div>' |
| 1649 | + + '<div id="mwe-upwiz-tabdiv-thanks">' |
| 1650 | + + '<div id="mwe-upwiz-thanks"></div>' |
| 1651 | + + '</div>' |
1611 | 1652 | + '</div>' |
1612 | | - + '<div id="mwe-upwiz-tabdiv-thanks">' |
1613 | | - + '<div id="mwe-upwiz-thanks"></div>' |
1614 | | - + '</div>' |
1615 | | - +'</div>' |
1616 | 1653 | |
1617 | 1654 | + '<div id="mwe-upwiz-clearing"></div>'; |
1618 | 1655 | |
— | — | @@ -1917,27 +1954,7 @@ |
1918 | 1955 | |
1919 | 1956 | }, |
1920 | 1957 | |
1921 | | - /** |
1922 | | - * in details mode, reconfigure all the uploads, for various copyright modes |
1923 | | - */ |
1924 | | - configureCopyrightDetails: function( mode ) { |
1925 | | - $j.each( _this._uploadsEditingDetails, function (i, upload) { |
1926 | | - if (mode == 'ownwork') { |
1927 | | - // disable inputs |
1928 | | - // link source to macro input |
1929 | | - } else if (mode == 'permission') { |
1930 | | - alert( 'unimplemented' ); |
1931 | 1958 | |
1932 | | - } else if (mode == 'found') { |
1933 | | - // disable inputs |
1934 | | - // link source to macro input |
1935 | | - |
1936 | | - } else { |
1937 | | - alert( 'unknown mode = ' + mode); |
1938 | | - } |
1939 | | - } ); |
1940 | | - }, |
1941 | | - |
1942 | 1959 | // might as well hardcode more of this? |
1943 | 1960 | prefillThanksPage: function() { |
1944 | 1961 | var _this = this; |
— | — | @@ -1973,6 +1990,7 @@ |
1974 | 1991 | var thumbTitle = upload.title.replace(/^File/, 'Image'); |
1975 | 1992 | var thumbWikiText = "[[" + thumbTitle + "|thumb|right]]"; |
1976 | 1993 | |
| 1994 | + // XXX this doesn't have the correct URL -- old "unique" descriptionurl |
1977 | 1995 | thanksDiv.append( |
1978 | 1996 | $j( '<div></div>' ) |
1979 | 1997 | .addClass( 'mwe-upwiz-thanks-links' ) |