From: James D. Forrester Date: Thu, 29 May 2014 01:37:16 +0000 (-0700) Subject: Update OOjs UI to v0.1.0-pre (09b223d279) X-Git-Tag: 1.31.0-rc.0~15544^2 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=c9594a047ac18e577d0d85e00ebffa43b5ef8ced;p=lhc%2Fweb%2Fwiklou.git Update OOjs UI to v0.1.0-pre (09b223d279) New changes: 09b223d StackLayout: Clean up inconsistent event firing and documentation Change-Id: I1297880400f776bcf73753ef31ae613f0fcb0ad4 --- diff --git a/resources/lib/oojs-ui/oojs-ui.js b/resources/lib/oojs-ui/oojs-ui.js index 0dcadd45c2..b75b172aa0 100644 --- a/resources/lib/oojs-ui/oojs-ui.js +++ b/resources/lib/oojs-ui/oojs-ui.js @@ -1,12 +1,12 @@ /*! - * OOjs UI v0.1.0-pre (7b283a9dcc) + * OOjs UI v0.1.0-pre (09b223d279) * 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: Tue May 27 2014 15:41:42 GMT-0700 (PDT) + * Date: Wed May 28 2014 18:37:12 GMT-0700 (PDT) */ ( function ( OO ) { @@ -4791,7 +4791,7 @@ OO.mixinClass( OO.ui.StackLayout, OO.ui.GroupElement ); /** * @event set - * @param {OO.ui.Layout|null} [item] Current item + * @param {OO.ui.Layout|null} item Current item or null if there is no longer a layout shown */ /* Methods */ @@ -4799,12 +4799,29 @@ OO.mixinClass( OO.ui.StackLayout, OO.ui.GroupElement ); /** * Get the current item. * - * @return {OO.ui.Layout|null} [description] + * @return {OO.ui.Layout|null} */ OO.ui.StackLayout.prototype.getCurrentItem = function () { return this.currentItem; }; +/** + * Unset the current item. + * + * @private + * @param {OO.ui.StackLayout} layout + * @fires set + */ +OO.ui.StackLayout.prototype.unsetCurrentItem = function () { + var prevItem = this.currentItem; + if ( prevItem === null ) { + return; + } + + this.currentItem = null; + this.emit( 'set', null ); +}; + /** * Add items. * @@ -4831,13 +4848,16 @@ OO.ui.StackLayout.prototype.addItems = function ( items, index ) { * * @param {OO.ui.Layout[]} items Items to remove * @chainable + * @fires set */ OO.ui.StackLayout.prototype.removeItems = function ( items ) { OO.ui.GroupElement.prototype.removeItems.call( this, items ); + if ( $.inArray( this.currentItem, items ) !== -1 ) { - this.currentItem = null; - if ( !this.currentItem && this.items.length ) { + if ( this.items.length ) { this.setItem( this.items[0] ); + } else { + this.unsetCurrentItem(); } } @@ -4850,9 +4870,10 @@ OO.ui.StackLayout.prototype.removeItems = function ( items ) { * Items will be detached, not removed, so they can be used later. * * @chainable + * @fires set */ OO.ui.StackLayout.prototype.clearItems = function () { - this.currentItem = null; + this.unsetCurrentItem(); OO.ui.GroupElement.prototype.clearItems.call( this ); return this; @@ -4863,8 +4884,12 @@ OO.ui.StackLayout.prototype.clearItems = function () { * * Any currently shown item will be hidden. * + * FIXME: If the passed item to show has not been added in the items list, then + * this method drops it and unsets the current item. + * * @param {OO.ui.Layout} item Item to show * @chainable + * @fires set */ OO.ui.StackLayout.prototype.setItem = function ( item ) { if ( item !== this.currentItem ) { @@ -4875,11 +4900,11 @@ OO.ui.StackLayout.prototype.setItem = function ( item ) { if ( !this.continuous ) { item.$element.css( 'display', 'block' ); } + this.currentItem = item; + this.emit( 'set', item ); } else { - item = null; + this.unsetCurrentItem(); } - this.currentItem = item; - this.emit( 'set', item ); } return this; diff --git a/resources/lib/oojs-ui/oojs-ui.svg.css b/resources/lib/oojs-ui/oojs-ui.svg.css index 34547cfd1e..74073a0f2c 100644 --- a/resources/lib/oojs-ui/oojs-ui.svg.css +++ b/resources/lib/oojs-ui/oojs-ui.svg.css @@ -1,12 +1,12 @@ /*! - * OOjs UI v0.1.0-pre (7b283a9dcc) + * OOjs UI v0.1.0-pre (09b223d279) * 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: Tue May 27 2014 15:41:42 GMT-0700 (PDT) + * Date: Wed May 28 2014 18:37:12 GMT-0700 (PDT) */ /* Textures */