jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/339474 )
Change subject: demos: Extract remaining widgets from widgets.js ...................................................................... demos: Extract remaining widgets from widgets.js Just copy-paste and move into the Demo namespace. Bug: T158592 Change-Id: I76b876e6a28583cb2a282824f064de2e8a8adc7e --- A demos/classes/DraggableGroupWidget.js A demos/classes/DraggableHandledItemWidget.js A demos/classes/DraggableItemWidget.js A demos/classes/NumberLookupTextInputWidget.js A demos/classes/UnsupportedSelectFileWidget.js M demos/index.html M demos/pages/widgets.js 7 files changed, 145 insertions(+), 145 deletions(-) Approvals: jenkins-bot: Verified Jforrester: Looks good to me, approved diff --git a/demos/classes/DraggableGroupWidget.js b/demos/classes/DraggableGroupWidget.js new file mode 100644 index 0000000..aa13875 --- /dev/null +++ b/demos/classes/DraggableGroupWidget.js @@ -0,0 +1,19 @@ +/** + * Draggable group widget containing drag/drop items + * + * @param {Object} [config] Configuration options + */ +Demo.DraggableGroupWidget = function DemoDraggableGroupWidget( config ) { + // Configuration initialization + config = config || {}; + + // Parent constructor + Demo.DraggableGroupWidget.parent.call( this, config ); + + // Mixin constructors + OO.ui.mixin.DraggableGroupElement.call( this, $.extend( {}, config, { $group: this.$element } ) ); +}; + +/* Setup */ +OO.inheritClass( Demo.DraggableGroupWidget, OO.ui.Widget ); +OO.mixinClass( Demo.DraggableGroupWidget, OO.ui.mixin.DraggableGroupElement ); diff --git a/demos/classes/DraggableHandledItemWidget.js b/demos/classes/DraggableHandledItemWidget.js new file mode 100644 index 0000000..8efffc9 --- /dev/null +++ b/demos/classes/DraggableHandledItemWidget.js @@ -0,0 +1,19 @@ +/** + * Drag/drop items with custom handle + * + * @param {Object} [config] Configuration options + */ +Demo.DraggableHandledItemWidget = function DemoDraggableHandledItemWidget( config ) { + // Configuration initialization + config = config || {}; + + // Parent constructor + Demo.DraggableHandledItemWidget.parent.call( this, config ); + + // Mixin constructors + OO.ui.mixin.DraggableElement.call( this, $.extend( { $handle: this.$icon }, config ) ); +}; + +/* Setup */ +OO.inheritClass( Demo.DraggableHandledItemWidget, OO.ui.DecoratedOptionWidget ); +OO.mixinClass( Demo.DraggableHandledItemWidget, OO.ui.mixin.DraggableElement ); diff --git a/demos/classes/DraggableItemWidget.js b/demos/classes/DraggableItemWidget.js new file mode 100644 index 0000000..bc86360 --- /dev/null +++ b/demos/classes/DraggableItemWidget.js @@ -0,0 +1,19 @@ +/** + * Drag/drop items + * + * @param {Object} [config] Configuration options + */ +Demo.DraggableItemWidget = function DemoDraggableItemWidget( config ) { + // Configuration initialization + config = config || {}; + + // Parent constructor + Demo.DraggableItemWidget.parent.call( this, config ); + + // Mixin constructors + OO.ui.mixin.DraggableElement.call( this, config ); +}; + +/* Setup */ +OO.inheritClass( Demo.DraggableItemWidget, OO.ui.DecoratedOptionWidget ); +OO.mixinClass( Demo.DraggableItemWidget, OO.ui.mixin.DraggableElement ); diff --git a/demos/classes/NumberLookupTextInputWidget.js b/demos/classes/NumberLookupTextInputWidget.js new file mode 100644 index 0000000..4bca4b7 --- /dev/null +++ b/demos/classes/NumberLookupTextInputWidget.js @@ -0,0 +1,65 @@ +/** + * Demo for LookupElement. + * + * @class + * @extends OO.ui.TextInputWidget + * @mixins OO.ui.mixin.LookupElement + * + * @constructor + * @param {Object} config Configuration options + */ +Demo.NumberLookupTextInputWidget = function DemoNumberLookupTextInputWidget( config ) { + // Parent constructor + OO.ui.TextInputWidget.call( this, { validate: 'integer' } ); + // Mixin constructors + OO.ui.mixin.LookupElement.call( this, config ); +}; +OO.inheritClass( Demo.NumberLookupTextInputWidget, OO.ui.TextInputWidget ); +OO.mixinClass( Demo.NumberLookupTextInputWidget, OO.ui.mixin.LookupElement ); + +/** + * @inheritdoc + */ +Demo.NumberLookupTextInputWidget.prototype.getLookupRequest = function () { + var + value = this.getValue(), + deferred = $.Deferred(), + delay = 500 + Math.floor( Math.random() * 500 ); + + this.getValidity().then( function () { + // Resolve with results after a faked delay + setTimeout( function () { + deferred.resolve( [ value * 1, value * 2, value * 3, value * 4, value * 5 ] ); + }, delay ); + }, function () { + // No results when the input contains invalid content + deferred.resolve( [] ); + } ); + + return deferred.promise( { abort: function () {} } ); +}; + +/** + * @inheritdoc + */ +Demo.NumberLookupTextInputWidget.prototype.getLookupCacheDataFromResponse = function ( response ) { + return response || []; +}; + +/** + * @inheritdoc + */ +Demo.NumberLookupTextInputWidget.prototype.getLookupMenuOptionsFromData = function ( data ) { + var + items = [], + i, number; + for ( i = 0; i < data.length; i++ ) { + number = String( data[ i ] ); + items.push( new OO.ui.MenuOptionWidget( { + data: number, + label: number + } ) ); + } + + return items; +}; diff --git a/demos/classes/UnsupportedSelectFileWidget.js b/demos/classes/UnsupportedSelectFileWidget.js new file mode 100644 index 0000000..5da9f9b --- /dev/null +++ b/demos/classes/UnsupportedSelectFileWidget.js @@ -0,0 +1,8 @@ +Demo.UnsupportedSelectFileWidget = function DemoUnsupportedSelectFileWidget() { + // Parent constructor + Demo.UnsupportedSelectFileWidget.parent.apply( this, arguments ); +}; +OO.inheritClass( Demo.UnsupportedSelectFileWidget, OO.ui.SelectFileWidget ); +Demo.UnsupportedSelectFileWidget.static.isSupported = function () { + return false; +}; diff --git a/demos/index.html b/demos/index.html index f5bd319..b072bc1 100644 --- a/demos/index.html +++ b/demos/index.html @@ -17,6 +17,11 @@ <script src="demo.js"></script> <script src="classes/ButtonStyleShowcaseWidget.js"></script> <script src="classes/CapsuleNumberPopupMultiselectWidget.js"></script> + <script src="classes/DraggableGroupWidget.js"></script> + <script src="classes/DraggableItemWidget.js"></script> + <script src="classes/DraggableHandledItemWidget.js"></script> + <script src="classes/NumberLookupTextInputWidget.js"></script> + <script src="classes/UnsupportedSelectFileWidget.js"></script> <script src="pages/dialogs.js"></script> <script src="pages/icons.js"></script> <script src="pages/widgets.js"></script> diff --git a/demos/pages/widgets.js b/demos/pages/widgets.js index 2ecec45..8622790 100644 --- a/demos/pages/widgets.js +++ b/demos/pages/widgets.js @@ -8,69 +8,9 @@ verticalHandledDragItems = [], $demo = demo.$element; - /** - * Draggable group widget containing drag/drop items - * - * @param {Object} [config] Configuration options - */ - function DraggableGroupWidget( config ) { - // Configuration initialization - config = config || {}; - - // Parent constructor - DraggableGroupWidget.parent.call( this, config ); - - // Mixin constructors - OO.ui.mixin.DraggableGroupElement.call( this, $.extend( {}, config, { $group: this.$element } ) ); - } - - /* Setup */ - OO.inheritClass( DraggableGroupWidget, OO.ui.Widget ); - OO.mixinClass( DraggableGroupWidget, OO.ui.mixin.DraggableGroupElement ); - - /** - * Drag/drop items - * - * @param {Object} [config] Configuration options - */ - function DraggableItemWidget( config ) { - // Configuration initialization - config = config || {}; - - // Parent constructor - DraggableItemWidget.parent.call( this, config ); - - // Mixin constructors - OO.ui.mixin.DraggableElement.call( this, config ); - } - - /* Setup */ - OO.inheritClass( DraggableItemWidget, OO.ui.DecoratedOptionWidget ); - OO.mixinClass( DraggableItemWidget, OO.ui.mixin.DraggableElement ); - - /** - * Drag/drop items with custom handle - * - * @param {Object} [config] Configuration options - */ - function DraggableHandledItemWidget( config ) { - // Configuration initialization - config = config || {}; - - // Parent constructor - DraggableHandledItemWidget.parent.call( this, config ); - - // Mixin constructors - OO.ui.mixin.DraggableElement.call( this, $.extend( { $handle: this.$icon }, config ) ); - } - - /* Setup */ - OO.inheritClass( DraggableHandledItemWidget, OO.ui.DecoratedOptionWidget ); - OO.mixinClass( DraggableHandledItemWidget, OO.ui.mixin.DraggableElement ); - for ( i = 0; i <= 12; i++ ) { horizontalDragItems.push( - new DraggableItemWidget( { + new Demo.DraggableItemWidget( { data: 'item' + i, icon: 'tag', label: 'Inline item ' + i @@ -78,14 +18,14 @@ ); if ( i <= 6 ) { verticalDragItems.push( - new DraggableItemWidget( { + new Demo.DraggableItemWidget( { data: 'item' + i, icon: 'tag', label: 'Item ' + i } ) ); verticalHandledDragItems.push( - new DraggableHandledItemWidget( { + new Demo.DraggableHandledItemWidget( { data: 'item' + i, icon: 'menu', label: 'Item ' + i @@ -93,81 +33,6 @@ ); } } - - /** - * Demo for LookupElement. - * - * @class - * @extends OO.ui.TextInputWidget - * @mixins OO.ui.mixin.LookupElement - * - * @constructor - * @param {Object} config Configuration options - */ - function NumberLookupTextInputWidget( config ) { - // Parent constructor - OO.ui.TextInputWidget.call( this, { validate: 'integer' } ); - // Mixin constructors - OO.ui.mixin.LookupElement.call( this, config ); - } - OO.inheritClass( NumberLookupTextInputWidget, OO.ui.TextInputWidget ); - OO.mixinClass( NumberLookupTextInputWidget, OO.ui.mixin.LookupElement ); - - /** - * @inheritdoc - */ - NumberLookupTextInputWidget.prototype.getLookupRequest = function () { - var - value = this.getValue(), - deferred = $.Deferred(), - delay = 500 + Math.floor( Math.random() * 500 ); - - this.getValidity().then( function () { - // Resolve with results after a faked delay - setTimeout( function () { - deferred.resolve( [ value * 1, value * 2, value * 3, value * 4, value * 5 ] ); - }, delay ); - }, function () { - // No results when the input contains invalid content - deferred.resolve( [] ); - } ); - - return deferred.promise( { abort: function () {} } ); - }; - - /** - * @inheritdoc - */ - NumberLookupTextInputWidget.prototype.getLookupCacheDataFromResponse = function ( response ) { - return response || []; - }; - - /** - * @inheritdoc - */ - NumberLookupTextInputWidget.prototype.getLookupMenuOptionsFromData = function ( data ) { - var - items = [], - i, number; - for ( i = 0; i < data.length; i++ ) { - number = String( data[ i ] ); - items.push( new OO.ui.MenuOptionWidget( { - data: number, - label: number - } ) ); - } - - return items; - }; - - function UnsupportedSelectFileWidget() { - // Parent constructor - UnsupportedSelectFileWidget.parent.apply( this, arguments ); - } - OO.inheritClass( UnsupportedSelectFileWidget, OO.ui.SelectFileWidget ); - UnsupportedSelectFileWidget.static.isSupported = function () { - return false; - }; textInputForLabel = new OO.ui.TextInputWidget( { value: 'Input for label above' } ); labelForTextInput = new OO.ui.LabelWidget( { @@ -1058,7 +923,7 @@ } ), new OO.ui.FieldLayout( - new UnsupportedSelectFileWidget(), + new Demo.UnsupportedSelectFileWidget(), { label: 'SelectFileWidget (no browser support)\u200E', align: 'top' @@ -1082,7 +947,7 @@ } ), new OO.ui.FieldLayout( - new UnsupportedSelectFileWidget( { + new Demo.UnsupportedSelectFileWidget( { showDropTarget: true } ), { @@ -1670,7 +1535,7 @@ label: 'Draggable', items: [ new OO.ui.FieldLayout( - new DraggableGroupWidget( { + new Demo.DraggableGroupWidget( { orientation: 'horizontal', items: horizontalDragItems } ), @@ -1680,7 +1545,7 @@ } ), new OO.ui.FieldLayout( - new DraggableGroupWidget( { + new Demo.DraggableGroupWidget( { items: verticalDragItems } ), { @@ -1689,7 +1554,7 @@ } ), new OO.ui.FieldLayout( - new DraggableGroupWidget( { + new Demo.DraggableGroupWidget( { items: verticalHandledDragItems } ), { @@ -1899,14 +1764,14 @@ } ), new OO.ui.FieldLayout( - new NumberLookupTextInputWidget(), + new Demo.NumberLookupTextInputWidget(), { label: 'LookupElement (try inputting an integer)\u200E', align: 'top' } ), new OO.ui.FieldLayout( - new NumberLookupTextInputWidget( { + new Demo.NumberLookupTextInputWidget( { highlightFirst: false } ), { -- To view, visit https://gerrit.wikimedia.org/r/339474 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I76b876e6a28583cb2a282824f064de2e8a8adc7e Gerrit-PatchSet: 1 Gerrit-Project: oojs/ui Gerrit-Branch: master Gerrit-Owner: Bartosz DziewoĆski <matma....@gmail.com> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits