From ffdd99bef1838e8ad79a367205a550957844ba6e Mon Sep 17 00:00:00 2001 From: "James D. Forrester" Date: Wed, 26 Nov 2014 15:41:43 -0800 Subject: [PATCH] Update OOjs UI to v0.2.3 Release notes: https://git.wikimedia.org/blob/oojs%2Fui.git/v0.2.3/History.md Change-Id: Ia3d8a5a9df0efffd2b5cb1466e600cc0b77d7ef2 --- resources/lib/oojs-ui/oojs-ui-apex.css | 6 +- resources/lib/oojs-ui/oojs-ui-apex.js | 4 +- resources/lib/oojs-ui/oojs-ui-apex.svg.css | 6 +- resources/lib/oojs-ui/oojs-ui-mediawiki.css | 6 +- resources/lib/oojs-ui/oojs-ui-mediawiki.js | 4 +- .../lib/oojs-ui/oojs-ui-mediawiki.svg.css | 6 +- resources/lib/oojs-ui/oojs-ui.js | 93 +++++++++++++++---- 7 files changed, 93 insertions(+), 32 deletions(-) diff --git a/resources/lib/oojs-ui/oojs-ui-apex.css b/resources/lib/oojs-ui/oojs-ui-apex.css index f8916e80c9..10999330c9 100644 --- a/resources/lib/oojs-ui/oojs-ui-apex.css +++ b/resources/lib/oojs-ui/oojs-ui-apex.css @@ -1,12 +1,12 @@ /*! - * OOjs UI v0.2.2 + * OOjs UI v0.2.3 * https://www.mediawiki.org/wiki/OOjs_UI * * Copyright 2011–2014 OOjs Team and other contributors. * Released under the MIT license * http://oojs.mit-license.org * - * Date: 2014-11-25T01:13:20Z + * Date: 2014-11-26T23:37:12Z */ .oo-ui-progressBarWidget-slide-frames from { margin-left: -40%; @@ -1011,7 +1011,7 @@ background-color: transparent; } .oo-ui-radioOptionWidget .oo-ui-radioInputWidget, -.oo-ui-radioOptionWidget .oo-ui-labelElement-label { +.oo-ui-radioOptionWidget.oo-ui-labelElement .oo-ui-labelElement-label { display: inline-block; vertical-align: middle; } diff --git a/resources/lib/oojs-ui/oojs-ui-apex.js b/resources/lib/oojs-ui/oojs-ui-apex.js index 2a629646f2..ad755574da 100644 --- a/resources/lib/oojs-ui/oojs-ui-apex.js +++ b/resources/lib/oojs-ui/oojs-ui-apex.js @@ -1,12 +1,12 @@ /*! - * OOjs UI v0.2.2 + * OOjs UI v0.2.3 * https://www.mediawiki.org/wiki/OOjs_UI * * Copyright 2011–2014 OOjs Team and other contributors. * Released under the MIT license * http://oojs.mit-license.org * - * Date: 2014-11-25T01:13:13Z + * Date: 2014-11-26T23:37:00Z */ /* Instantiation */ diff --git a/resources/lib/oojs-ui/oojs-ui-apex.svg.css b/resources/lib/oojs-ui/oojs-ui-apex.svg.css index 26a4c0ba3d..aa2dfb4065 100644 --- a/resources/lib/oojs-ui/oojs-ui-apex.svg.css +++ b/resources/lib/oojs-ui/oojs-ui-apex.svg.css @@ -1,12 +1,12 @@ /*! - * OOjs UI v0.2.2 + * OOjs UI v0.2.3 * https://www.mediawiki.org/wiki/OOjs_UI * * Copyright 2011–2014 OOjs Team and other contributors. * Released under the MIT license * http://oojs.mit-license.org * - * Date: 2014-11-25T01:13:20Z + * Date: 2014-11-26T23:37:12Z */ .oo-ui-progressBarWidget-slide-frames from { margin-left: -40%; @@ -1011,7 +1011,7 @@ background-color: transparent; } .oo-ui-radioOptionWidget .oo-ui-radioInputWidget, -.oo-ui-radioOptionWidget .oo-ui-labelElement-label { +.oo-ui-radioOptionWidget.oo-ui-labelElement .oo-ui-labelElement-label { display: inline-block; vertical-align: middle; } diff --git a/resources/lib/oojs-ui/oojs-ui-mediawiki.css b/resources/lib/oojs-ui/oojs-ui-mediawiki.css index a70e18a3bd..d8d365387f 100644 --- a/resources/lib/oojs-ui/oojs-ui-mediawiki.css +++ b/resources/lib/oojs-ui/oojs-ui-mediawiki.css @@ -1,12 +1,12 @@ /*! - * OOjs UI v0.2.2 + * OOjs UI v0.2.3 * https://www.mediawiki.org/wiki/OOjs_UI * * Copyright 2011–2014 OOjs Team and other contributors. * Released under the MIT license * http://oojs.mit-license.org * - * Date: 2014-11-25T01:13:20Z + * Date: 2014-11-26T23:37:12Z */ .oo-ui-progressBarWidget-slide-frames from { margin-left: -40%; @@ -918,7 +918,7 @@ background-color: transparent; } .oo-ui-radioOptionWidget .oo-ui-radioInputWidget, -.oo-ui-radioOptionWidget .oo-ui-labelElement-label { +.oo-ui-radioOptionWidget.oo-ui-labelElement .oo-ui-labelElement-label { display: inline-block; vertical-align: middle; } diff --git a/resources/lib/oojs-ui/oojs-ui-mediawiki.js b/resources/lib/oojs-ui/oojs-ui-mediawiki.js index 9a57c669f6..89338d65bc 100644 --- a/resources/lib/oojs-ui/oojs-ui-mediawiki.js +++ b/resources/lib/oojs-ui/oojs-ui-mediawiki.js @@ -1,12 +1,12 @@ /*! - * OOjs UI v0.2.2 + * OOjs UI v0.2.3 * https://www.mediawiki.org/wiki/OOjs_UI * * Copyright 2011–2014 OOjs Team and other contributors. * Released under the MIT license * http://oojs.mit-license.org * - * Date: 2014-11-25T01:13:13Z + * Date: 2014-11-26T23:37:00Z */ /** * @class diff --git a/resources/lib/oojs-ui/oojs-ui-mediawiki.svg.css b/resources/lib/oojs-ui/oojs-ui-mediawiki.svg.css index f38a637fb5..d8aedd3f14 100644 --- a/resources/lib/oojs-ui/oojs-ui-mediawiki.svg.css +++ b/resources/lib/oojs-ui/oojs-ui-mediawiki.svg.css @@ -1,12 +1,12 @@ /*! - * OOjs UI v0.2.2 + * OOjs UI v0.2.3 * https://www.mediawiki.org/wiki/OOjs_UI * * Copyright 2011–2014 OOjs Team and other contributors. * Released under the MIT license * http://oojs.mit-license.org * - * Date: 2014-11-25T01:13:20Z + * Date: 2014-11-26T23:37:12Z */ .oo-ui-progressBarWidget-slide-frames from { margin-left: -40%; @@ -918,7 +918,7 @@ background-color: transparent; } .oo-ui-radioOptionWidget .oo-ui-radioInputWidget, -.oo-ui-radioOptionWidget .oo-ui-labelElement-label { +.oo-ui-radioOptionWidget.oo-ui-labelElement .oo-ui-labelElement-label { display: inline-block; vertical-align: middle; } diff --git a/resources/lib/oojs-ui/oojs-ui.js b/resources/lib/oojs-ui/oojs-ui.js index 2e2a011edf..d42139e892 100644 --- a/resources/lib/oojs-ui/oojs-ui.js +++ b/resources/lib/oojs-ui/oojs-ui.js @@ -1,12 +1,12 @@ /*! - * OOjs UI v0.2.2 + * OOjs UI v0.2.3 * https://www.mediawiki.org/wiki/OOjs_UI * * Copyright 2011–2014 OOjs Team and other contributors. * Released under the MIT license * http://oojs.mit-license.org * - * Date: 2014-11-25T01:13:13Z + * Date: 2014-11-26T23:37:00Z */ ( function ( OO ) { @@ -1756,11 +1756,20 @@ OO.ui.Window.prototype.getSize = function () { * @return {number} Content height */ OO.ui.Window.prototype.getContentHeight = function () { - // Temporarily resize the frame so getBodyHeight() can use scrollHeight measurements - var bodyHeight, oldHeight = this.$frame[0].style.height; - this.$frame[0].style.height = '1px'; + // Temporarily resize the frame so getBodyHeight() can use scrollHeight measurements. + // Disable transitions first, otherwise we'll get values from when the window was animating. + var bodyHeight, oldHeight, oldTransition, + styleObj = this.$frame[0].style; + oldTransition = styleObj.transition || styleObj.OTransition || styleObj.MsTransition || + styleObj.MozTransition || styleObj.WebkitTransition; + styleObj.transition = styleObj.OTransition = styleObj.MsTransition = + styleObj.MozTransition = styleObj.WebkitTransition = 'none'; + oldHeight = styleObj.height; + styleObj.height = '1px'; bodyHeight = this.getBodyHeight(); - this.$frame[0].style.height = oldHeight; + styleObj.height = oldHeight; + styleObj.transition = styleObj.OTransition = styleObj.MsTransition = + styleObj.MozTransition = styleObj.WebkitTransition = oldTransition; return Math.round( // Add buffer for border @@ -2275,6 +2284,7 @@ OO.ui.Dialog = function OoUiDialog( config ) { this.actions = new OO.ui.ActionSet(); this.attachedActions = []; this.currentAction = null; + this.onDocumentKeyDownHandler = this.onDocumentKeyDown.bind( this ); // Events this.actions.connect( this, { @@ -2438,6 +2448,10 @@ OO.ui.Dialog.prototype.getSetupProcess = function ( data ) { ); } this.actions.add( items ); + + if ( this.constructor.static.escapable ) { + this.$document.on( 'keydown', this.onDocumentKeyDownHandler ); + } }, this ); }; @@ -2448,6 +2462,10 @@ OO.ui.Dialog.prototype.getTeardownProcess = function ( data ) { // Parent method return OO.ui.Dialog.super.prototype.getTeardownProcess.call( this, data ) .first( function () { + if ( this.constructor.static.escapable ) { + this.$document.off( 'keydown', this.onDocumentKeyDownHandler ); + } + this.actions.clear(); this.currentAction = null; }, this ); @@ -2463,11 +2481,6 @@ OO.ui.Dialog.prototype.initialize = function () { // Properties this.title = new OO.ui.LabelWidget( { $: this.$ } ); - // Events - if ( this.constructor.static.escapable ) { - this.$document.on( 'keydown', this.onDocumentKeyDown.bind( this ) ); - } - // Initialization this.$content.addClass( 'oo-ui-dialog-content' ); this.setPendingElement( this.$head ); @@ -3444,7 +3457,15 @@ OO.inheritClass( OO.ui.ToolFactory, OO.Factory ); /* Methods */ -/** */ +/** + * Get tools from the factory + * + * @param {Array} include Included tools + * @param {Array} exclude Excluded tools + * @param {Array} promote Promoted tools + * @param {Array} demote Demoted tools + * @return {string[]} List of tools + */ OO.ui.ToolFactory.prototype.getTools = function ( include, exclude, promote, demote ) { var i, len, included, promoted, demoted, auto = [], @@ -5975,7 +5996,45 @@ OO.ui.MessageDialog.prototype.getSetupProcess = function ( data ) { * @inheritdoc */ OO.ui.MessageDialog.prototype.getBodyHeight = function () { - return Math.round( this.text.$element.outerHeight( true ) ); + var bodyHeight, oldOverflow, + $scrollable = this.container.$element; + + oldOverflow = $scrollable[0].style.overflow; + $scrollable[0].style.overflow = 'hidden'; + + // Force… ugh… something to happen + $scrollable.contents().hide(); + $scrollable.height(); + $scrollable.contents().show(); + + bodyHeight = Math.round( this.text.$element.outerHeight( true ) ); + $scrollable[0].style.overflow = oldOverflow; + + return bodyHeight; +}; + +/** + * @inheritdoc + */ +OO.ui.MessageDialog.prototype.setDimensions = function ( dim ) { + var $scrollable = this.container.$element; + OO.ui.MessageDialog.super.prototype.setDimensions.call( this, dim ); + + // Twiddle the overflow property, otherwise an unnecessary scrollbar will be produced. + // Need to do it after transition completes (250ms), add 50ms just in case. + setTimeout( function () { + var oldOverflow = $scrollable[0].style.overflow; + $scrollable[0].style.overflow = 'hidden'; + + // Force… ugh… something to happen + $scrollable.contents().hide(); + $scrollable.height(); + $scrollable.contents().show(); + + $scrollable[0].style.overflow = oldOverflow; + }, 300 ); + + return this; }; /** @@ -6420,9 +6479,12 @@ OO.ui.BookletLayout.prototype.onStackLayoutSet = function ( page ) { */ OO.ui.BookletLayout.prototype.focus = function () { var $input, page = this.stackLayout.getCurrentItem(); - if ( !page ) { + if ( !page && this.outlined ) { this.selectFirstSelectablePage(); page = this.stackLayout.getCurrentItem(); + if ( !page ) { + return; + } } // Only change the focus if is not already in the current page if ( !page.$element.find( ':focus' ).length ) { @@ -9744,7 +9806,7 @@ OO.ui.TextInputWidget.prototype.onIndicatorMouseDown = function ( e ) { */ OO.ui.TextInputWidget.prototype.onKeyPress = function ( e ) { if ( e.which === OO.ui.Keys.ENTER && !this.multiline ) { - this.emit( 'enter' ); + this.emit( 'enter', e ); } }; @@ -10390,7 +10452,6 @@ OO.ui.ButtonOptionWidget.prototype.setSelected = function ( state ) { * * @class * @extends OO.ui.OptionWidget - * @mixins OO.ui.ButtonElement * * @constructor * @param {Object} [config] Configuration options -- 2.20.1