Harej has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/333803 )
Change subject: [WIP] Fixing bugs causing JS-based browsers to stall ...................................................................... [WIP] Fixing bugs causing JS-based browsers to stall Also specifying default hub image in the absence of input Bug: T155615 Bug: T155579 Change-Id: I0966e7c5fd6c1d0e4878187bc212fa3facf6e264 --- M includes/SpecialCreateHubFeature.php M modules/ext.CollaborationKit.colour.js M modules/ext.CollaborationKit.hubimage.js M modules/ext.CollaborationKit.icon.js 4 files changed, 46 insertions(+), 18 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CollaborationKit refs/changes/03/333803/1 diff --git a/includes/SpecialCreateHubFeature.php b/includes/SpecialCreateHubFeature.php index a1af255..b64176b 100644 --- a/includes/SpecialCreateHubFeature.php +++ b/includes/SpecialCreateHubFeature.php @@ -65,7 +65,8 @@ 'cssclass' => 'mw-ck-icon-input', 'label-message' => 'collaborationkit-createhubfeature-icon', 'help-message' => 'collaborationkit-createhubfeature-icon-help', - 'options' => $iconChoices + 'options' => $iconChoices, + 'default' => 'circlestar' ], 'contenttype' => [ 'type' => 'radio', diff --git a/modules/ext.CollaborationKit.colour.js b/modules/ext.CollaborationKit.colour.js index 9841661..18df988 100644 --- a/modules/ext.CollaborationKit.colour.js +++ b/modules/ext.CollaborationKit.colour.js @@ -59,6 +59,8 @@ classes: [ 'mw-ck-colourchoice-container' ] } ); + this.radioSelect.selectItemByData( $( '.mw-ck-colour-input select' ).val() ); + this.content.$element.append( this.radioSelect.$element ); this.$body.append( this.content.$element ); diff --git a/modules/ext.CollaborationKit.hubimage.js b/modules/ext.CollaborationKit.hubimage.js index 1c02c01..365249d 100644 --- a/modules/ext.CollaborationKit.hubimage.js +++ b/modules/ext.CollaborationKit.hubimage.js @@ -17,9 +17,28 @@ // Use the initialize() method to add content to the dialog's $body, // to initialize widgets, and to set up event handlers. ProcessDialog.prototype.initialize = function () { + var defaultSearchTerm; + ProcessDialog.super.prototype.initialize.apply( this, arguments ); - this.content = new mw.widgets.MediaSearchWidget(); + // Default image search flow: + // First work off of existing value for hub image, if it exists + // If no hub image (new hub creation), search display title or page title + // If nothing specified, fill in a filename for a generic icon + + if ( $( '.mw-ck-hub-image-input input' ).val() != '' ) { + defaultSearchTerm = $( '.mw-ck-hub-image-input input' ).val(); + } else if ( $( 'input[name=wpdisplay_name]' ).val() != '' ) { + defaultSearchTerm = $( 'input[name=wpdisplay_name]' ).val(); + } else if ( $( 'input[name=wptitle]' ).val() != '' ) { + defaultSearchTerm = $( 'input[name=wptitle]' ).val(); + } else { + defaultSearchTerm = 'OOjs UI icon puzzle-ltr.svg'; + } + + this.content = new mw.widgets.MediaSearchWidget( { + value: defaultSearchTerm + } ); this.$body.append( this.content.$element ); }; @@ -30,24 +49,27 @@ dialog = this; if ( action ) { - return new OO.ui.Process( function () { - fileObj = dialog.content.getResults().getSelectedItem().getData(); - fileUrl = fileObj.thumburl; - fileTitle = new mw.Title( fileObj.title ); - fileTitle = fileTitle.title + '.' + fileTitle.ext; + if ( $( '.mw-ck-hub-image-input input' ).val() != '' ) { + return new OO.ui.Process( function () { + fileObj = dialog.content.getResults().getSelectedItem().getData(); + fileUrl = fileObj.thumburl; + fileTitle = new mw.Title( fileObj.title ); + fileTitle = fileTitle.title + '.' + fileTitle.ext; - // Generate preview - $( 'img.hubimagePreview' ) - .attr( 'style', 'display:block' ) - .attr( 'src', fileUrl ) - .attr( 'width', '200px' ) - .css( 'margin-bottom', '10px' ); + // Generate preview + $( 'img.hubimagePreview' ) + .attr( 'style', 'display:block' ) + .attr( 'src', fileUrl ) + .attr( 'width', '200px' ) + .css( 'margin-bottom', '10px' ); - // Set form value - $( '.mw-ck-hub-image-input input' ).val( fileTitle ); - + // Set form value + $( '.mw-ck-hub-image-input input' ).val( fileTitle ); dialog.close( { action: action } ); - } ); + } ); + } else { + dialog.close(); + } } // Fallback to parent handler. return ProcessDialog.super.prototype.getActionProcess.call( this, action ); diff --git a/modules/ext.CollaborationKit.icon.js b/modules/ext.CollaborationKit.icon.js index db1ed04..700ab1b 100644 --- a/modules/ext.CollaborationKit.icon.js +++ b/modules/ext.CollaborationKit.icon.js @@ -46,6 +46,8 @@ classes: [ 'mw-ck-iconbrowser' ] } ); + this.radioSelect.selectItemByData( $( '.mw-ck-icon-input input' ).val() ); + this.content.$element.append( this.radioSelect.$element ); this.$body.append( this.content.$element ); @@ -62,6 +64,7 @@ // Generate preview $( '.iconPreview' ) + .attr('class', 'iconPreview') // Purges current icon selection .addClass( 'mw-ck-icon-' + toAppend ) .css( 'display', 'block' ); // Set form value @@ -86,7 +89,7 @@ // Create a new dialog window. processDialog = new ProcessDialog( { - size: 'medium' + size: 'large' } ); // Add windows to window manager using the addWindows() method. -- To view, visit https://gerrit.wikimedia.org/r/333803 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0966e7c5fd6c1d0e4878187bc212fa3facf6e264 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CollaborationKit Gerrit-Branch: master Gerrit-Owner: Harej <jamesmh...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits