Rillke has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/84003


Change subject: Add checkboxShiftClick to "Copy Metadata" checkboxes
......................................................................

Add checkboxShiftClick to "Copy Metadata" checkboxes

With CheckboxShiftClick functionality, the user can change the state of
multiple checkboxes at once by pressing the shift key. This
functionality is enabled by default for all checkboxes that are present
when mw.hook('wikipage.content') is fired but not for checkboxes like
these that are dynamically generated using JavaScript.

Another way to achieve this would be firing the hook as soon as Upload
Wizard makes changes to the HTML DOM:
   mw.hooks('wikipage.content').fire( <content that was newly created> );
This would have the downside that other scripts could interfere with
UploadWizards controls in unforeseeable ways.

Also did some cleanup:

* Marking instances of jQuery with $-prefix
* Declaring variables in the beginning of the function.

Change-Id: I97f95e10bcfd03105a7907d95c10a78d944083db
---
M UploadWizardHooks.php
M resources/mw.UploadWizardDetails.js
2 files changed, 17 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard 
refs/changes/03/84003/1

diff --git a/UploadWizardHooks.php b/UploadWizardHooks.php
index 0ac2149..c3cebd9 100644
--- a/UploadWizardHooks.php
+++ b/UploadWizardHooks.php
@@ -13,6 +13,7 @@
                        'dependencies' => array(
                                'jquery.arrowSteps',
                                'jquery.autoEllipsis',
+                               'jquery.checkboxShiftClick',
                                'jquery.client',
                                'jquery.ui.core',
                                'jquery.ui.dialog',
diff --git a/resources/mw.UploadWizardDetails.js 
b/resources/mw.UploadWizardDetails.js
index 83979a7..aa05105 100644
--- a/resources/mw.UploadWizardDetails.js
+++ b/resources/mw.UploadWizardDetails.js
@@ -587,14 +587,16 @@
         * a metadata copy widget for the details view of this specific upload
         */
        buildAndShowCopyMetadata: function() {
-               var _this = this;
+               var _this = this,
+                       $copyMetadataDiv = $( '<div 
class="mwe-upwiz-metadata-copier"></div>' ),
+                       $checkboxes = $();
+
                if( mw.UploadWizard.config.copyMetadataFeature !== true ||
                        _this.copyMetadataCtrlDiv !== undefined ) {
                        return;
                }
 
                _this.copyMetadataCtrlDiv = $( '<div 
class="mwe-upwiz-details-copy-metadata"></div>' );
-               var copyMetadataDiv = $( '<div 
class="mwe-upwiz-metadata-copier"></div>' );
 
                $.each( _this.copyMetadataTypes, function addToMetadataDiv( 
metadataName, defaultStatus ) {
                        var copyMessage = 'mwe-upwiz-copy-' + metadataName,
@@ -606,15 +608,20 @@
                                copyMetadataMsg = mw.message( copyMessage 
).text();
                        }
                        $checkbox = $( '<input>' ).attr( 'type', 'checkbox' 
).attr( 'name', copyMessage ).attr( 'id', copyMessage );
+                       $checkboxes = $checkboxes.add( $checkbox );
                        if ( defaultStatus === true ) {
                                $checkbox.attr( 'checked', 'checked' );
                        }
-                       copyMetadataDiv.append( $checkbox );
-                       copyMetadataDiv.append( $( '<label for="' + copyMessage 
+ '"></label>' ).text( copyMetadataMsg ) );
-                       copyMetadataDiv.append( $( '<br />' ) );
-               } ) ;
 
-               copyMetadataDiv.append(
+                       $copyMetadataDiv
+                               .append( $checkbox )
+                               .append( $( '<label for="' + copyMessage + 
'"></label>' ).text( copyMetadataMsg ) )
+                               .append( $( '<br />' ) );
+               } ) ;
+               $checkboxes.checkboxShiftClick();
+
+
+               $copyMetadataDiv.append(
                        $( '<button type="button" 
id="mwe-upwiz-copy-metadata-button"></button>' )
                        .msg( 'mwe-upwiz-copy-metadata-button' )
                        .button()
@@ -637,11 +644,11 @@
 
                mw.UploadWizardUtil.makeToggler(
                        _this.copyMetadataCtrlDiv,
-                       copyMetadataDiv,
+                       $copyMetadataDiv,
                        'mwe-upwiz-copy-metadata'
                );
 
-               _this.$form.append( _this.copyMetadataCtrlDiv, copyMetadataDiv 
);
+               _this.$form.append( _this.copyMetadataCtrlDiv, $copyMetadataDiv 
);
                _this.copyMetadataCtrlDiv.show();
        },
 

-- 
To view, visit https://gerrit.wikimedia.org/r/84003
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I97f95e10bcfd03105a7907d95c10a78d944083db
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Rillke <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to