VolkerE has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/347790 )
Change subject: Update OOjs UI to v0.21.0 ...................................................................... Update OOjs UI to v0.21.0 Release notes: https://phabricator.wikimedia.org/diffusion/GOJU/browse/master/History.md;v0.21.0 Change-Id: I94d5b7a89551e7d34d53223872ad3005f0ac4a04 --- M composer.json M composer.lock M composer/installed.json M oojs/oojs-ui/History.md M oojs/oojs-ui/bin/doccomparer.rb M oojs/oojs-ui/bin/docparser.rb M oojs/oojs-ui/bin/generate-JSPHP-for-karma.php M oojs/oojs-ui/bin/testsuitegenerator.rb M oojs/oojs-ui/demos/demos.php M oojs/oojs-ui/demos/index.html M oojs/oojs-ui/demos/pages/dialogs.js M oojs/oojs-ui/demos/pages/toolbars.js M oojs/oojs-ui/demos/pages/widgets.js M oojs/oojs-ui/package.json M oojs/oojs-ui/php/Element.php M oojs/oojs-ui/php/widgets/CheckboxMultiselectInputWidget.php M oojs/oojs-ui/php/widgets/ComboBoxInputWidget.php M oojs/oojs-ui/php/widgets/DropdownInputWidget.php M oojs/oojs-ui/php/widgets/RadioSelectInputWidget.php 19 files changed, 335 insertions(+), 138 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vendor refs/changes/90/347790/1 diff --git a/composer.json b/composer.json index 8350f4e..060cea0 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ "mediawiki/at-ease": "1.1.0", "monolog/monolog": "1.22.1", "nmred/kafka-php": "0.1.5", - "oojs/oojs-ui": "0.20.2", + "oojs/oojs-ui": "0.21.0", "oyejorge/less.php": "1.7.0.14", "pear/console_getopt": "1.4.1", "pear/mail": "1.3.0", diff --git a/composer.lock b/composer.lock index 13bf2cf..afa7167 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "c1bede778afbc1b61ef8739e204be406", + "content-hash": "cef3fe39dce79bd5ec5b2b4d83e63289", "packages": [ { "name": "composer/semver", @@ -466,16 +466,16 @@ }, { "name": "oojs/oojs-ui", - "version": "v0.20.2", + "version": "v0.21.0", "source": { "type": "git", "url": "https://github.com/wikimedia/oojs-ui.git", - "reference": "82ad6d14629d0cc57dfe6dba183b21b7e0598db5" + "reference": "f8c175f7c3934573715fb97d3c1a64f8f0d365f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wikimedia/oojs-ui/zipball/82ad6d14629d0cc57dfe6dba183b21b7e0598db5", - "reference": "82ad6d14629d0cc57dfe6dba183b21b7e0598db5", + "url": "https://api.github.com/repos/wikimedia/oojs-ui/zipball/f8c175f7c3934573715fb97d3c1a64f8f0d365f0", + "reference": "f8c175f7c3934573715fb97d3c1a64f8f0d365f0", "shasum": "" }, "require": { @@ -541,7 +541,7 @@ ], "description": "Provides library of common widgets, layouts, and windows.", "homepage": "https://www.mediawiki.org/wiki/OOjs_UI", - "time": "2017-03-30T20:15:35+00:00" + "time": "2017-04-11T22:11:33+00:00" }, { "name": "oyejorge/less.php", diff --git a/composer/installed.json b/composer/installed.json index dda430f..9a82fa9 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -1721,87 +1721,6 @@ "description": "More info available on: http://pear.php.net/package/Net_Socket" }, { - "name": "oojs/oojs-ui", - "version": "v0.20.2", - "version_normalized": "0.20.2.0", - "source": { - "type": "git", - "url": "https://github.com/wikimedia/oojs-ui.git", - "reference": "82ad6d14629d0cc57dfe6dba183b21b7e0598db5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/wikimedia/oojs-ui/zipball/82ad6d14629d0cc57dfe6dba183b21b7e0598db5", - "reference": "82ad6d14629d0cc57dfe6dba183b21b7e0598db5", - "shasum": "" - }, - "require": { - "mediawiki/at-ease": "1.1.0", - "php": ">=5.5.9" - }, - "require-dev": { - "jakub-onderka/php-parallel-lint": "0.9.2", - "mediawiki/mediawiki-codesniffer": "0.6.0", - "phpunit/phpunit": "4.8.21" - }, - "time": "2017-03-30T20:15:35+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "classmap": [ - "php/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Timo Tijhof", - "email": "krinklem...@gmail.com" - }, - { - "name": "Bartosz Dziewoński", - "email": "matma....@gmail.com" - }, - { - "name": "Ed Sanders", - "email": "esand...@wikimedia.org" - }, - { - "name": "James D. Forrester", - "email": "jforres...@wikimedia.org" - }, - { - "name": "Kirsten Menger-Anderson", - "email": "kmen...@wikimedia.org" - }, - { - "name": "Rob Moen", - "email": "rm...@wikimedia.org" - }, - { - "name": "Roan Kattouw", - "email": "r...@wikimedia.org" - }, - { - "name": "Trevor Parscal", - "email": "tre...@wikimedia.org" - }, - { - "name": "Kunal Mehta", - "email": "lego...@gmail.com" - }, - { - "name": "Prateek Saxena", - "email": "prtks...@gmail.com" - } - ], - "description": "Provides library of common widgets, layouts, and windows.", - "homepage": "https://www.mediawiki.org/wiki/OOjs_UI" - }, - { "name": "monolog/monolog", "version": "1.22.1", "version_normalized": "1.22.1.0", @@ -2190,5 +2109,86 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com" + }, + { + "name": "oojs/oojs-ui", + "version": "v0.21.0", + "version_normalized": "0.21.0.0", + "source": { + "type": "git", + "url": "https://github.com/wikimedia/oojs-ui.git", + "reference": "f8c175f7c3934573715fb97d3c1a64f8f0d365f0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wikimedia/oojs-ui/zipball/f8c175f7c3934573715fb97d3c1a64f8f0d365f0", + "reference": "f8c175f7c3934573715fb97d3c1a64f8f0d365f0", + "shasum": "" + }, + "require": { + "mediawiki/at-ease": "1.1.0", + "php": ">=5.5.9" + }, + "require-dev": { + "jakub-onderka/php-parallel-lint": "0.9.2", + "mediawiki/mediawiki-codesniffer": "0.6.0", + "phpunit/phpunit": "4.8.21" + }, + "time": "2017-04-11T22:11:33+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "classmap": [ + "php/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Timo Tijhof", + "email": "krinklem...@gmail.com" + }, + { + "name": "Bartosz Dziewoński", + "email": "matma....@gmail.com" + }, + { + "name": "Ed Sanders", + "email": "esand...@wikimedia.org" + }, + { + "name": "James D. Forrester", + "email": "jforres...@wikimedia.org" + }, + { + "name": "Kirsten Menger-Anderson", + "email": "kmen...@wikimedia.org" + }, + { + "name": "Rob Moen", + "email": "rm...@wikimedia.org" + }, + { + "name": "Roan Kattouw", + "email": "r...@wikimedia.org" + }, + { + "name": "Trevor Parscal", + "email": "tre...@wikimedia.org" + }, + { + "name": "Kunal Mehta", + "email": "lego...@gmail.com" + }, + { + "name": "Prateek Saxena", + "email": "prtks...@gmail.com" + } + ], + "description": "Provides library of common widgets, layouts, and windows.", + "homepage": "https://www.mediawiki.org/wiki/OOjs_UI" } ] diff --git a/oojs/oojs-ui/History.md b/oojs/oojs-ui/History.md index d83c3dd..58e3bd0 100644 --- a/oojs/oojs-ui/History.md +++ b/oojs/oojs-ui/History.md @@ -1,4 +1,49 @@ # OOjs UI Release History +## v0.21.0 / 2017-04-11 +### Breaking changes +* [BREAKING CHANGE] ActionWidget: Remove resize event (IvanFon) +* [BREAKING CHANGE] dependencies: Drop support for ES3 browsers via es5-shim (James D. Forrester) + +### Features +* Create a TagMultiselectWidget (Moriel Schottlender) +* FloatingMenuSelectWidget: Add `width` config option (Moriel Schottlender) +* MenuSelectWidget: Add `config.$autoCloseIgnore` (Roan Kattouw) + +### Styles +* PopupWidget: Center the anchor for vertical (above/below) popups too (Bartosz Dziewoński) +* MediaWiki theme: Add separator when toolbar items break on narrow (Volker E) +* MediaWiki theme: Fix IE < 11 icon/indicator position in SelectFileWidget (Volker E) +* MediaWiki theme: Fix overflow ellipsis on small DropdownWidget sizes (Volker E) +* MediaWiki theme: Fix selector regression on DraggableElement (Volker E) +* MediaWiki theme: Fix Toolbars containing ButtonGroups (David Lynch) +* MediaWiki theme: Replace arrows with chevrons and increase contrast (Volker E) +* MediaWiki theme: Unify `padding` across widgets and variablize (Volker E) +* MediaWiki theme: Unify `padding` on ButtonElement (Volker E) +* MediaWiki theme: Unify `padding` on DecoratedOptionWidget and descendants (Volker E) +* Follow-up eceb6f20: MediaWiki theme: Remove unused indicator flags (Volker E) + +### Code +* Remove remnants of PHP-5.3-style `array()` literals (Bartosz Dziewoński) +* ClippableElement: Fix progressive width loss bug (Roan Kattouw) +* ComboBoxInputWidget: Fix minor JS/PHP differences (Bartosz Dziewoński) +* ComboBoxInputWidget: Redo the 'down' indicator in PHP (Bartosz Dziewoński) +* DraggableElement: Only apply focus when widget is not disabled (Moriel Schottlender) +* DraggableElement: Toggle style on `$handle`, not `$element` (Andrew Green) +* DropdownInputWidget: Only allow setting values actually in the dropdown (Bartosz Dziewoński) +* MenuSelectWidget: Highlight the first result when searching (Moriel Schottlender) +* MessageDialog: Accept proposed size dialog on `getSetupProcess` (Ebrahim Byagowi) +* TextInputWidget: Reduce unnecessary duplicated CSS output (Volker E) +* TextInputWidget: Use `.prop()` rather than `.attr()` for 'required' (Bartosz Dziewoński) +* Apex theme: Align coding style to conventions (Volker E) +* Apex theme: Simplify color usage through Less variables (Volker E) +* demos: Remove scaling restrictions (Volker E) +* docparser: Improve trait/mixin handling (Bartosz Dziewoński) +* docparser: Properly handle default values in PHP (Bartosz Dziewoński) +* docs: Add detail to documentation of core.js utilities (Ed Sanders) +* docs: Minor documentation tweaks (Bartosz Dziewoński) +* tests: Comparison tests for infusing previously untestable classes (Bartosz Dziewoński) + + ## v0.20.2 / 2017-03-30 ### Styles * DraggableElement: Fix regression on selectors (Volker E) diff --git a/oojs/oojs-ui/bin/doccomparer.rb b/oojs/oojs-ui/bin/doccomparer.rb index 7772548..0dcb66a 100644 --- a/oojs/oojs-ui/bin/doccomparer.rb +++ b/oojs/oojs-ui/bin/doccomparer.rb @@ -33,7 +33,6 @@ cleanup_class_name(text) .gsub('null and undefined', 'null') .gsub('undefined and null', 'null') - .gsub('array()', '[]') .gsub('jQuery|string|Function', 'string') .gsub('jQuery', 'Tag') .gsub('string|Function', 'string') @@ -59,14 +58,10 @@ val[:params].delete 'element' # PHP only end val[:config].each_pair{|_k, v| - default = v.delete :default - v[:description] << " (default: #{default})" if default v[:description] = sanitize_description v[:description] v[:type] = sanitize_description v[:type] } val[:params].each_pair{|_k, v| - default = v.delete :default - v[:description] << " (default: #{default})" if default v[:description] = sanitize_description v[:description] v[:type] = sanitize_description v[:type] } diff --git a/oojs/oojs-ui/bin/docparser.rb b/oojs/oojs-ui/bin/docparser.rb index 47a010a..7bdff9c 100644 --- a/oojs/oojs-ui/bin/docparser.rb +++ b/oojs/oojs-ui/bin/docparser.rb @@ -18,7 +18,15 @@ end def cleanup_class_name class_name - class_name.sub(/OO\.ui\./, '') + class_name.sub(/OO\.ui\./, '').sub(/mixin\./, '') +end + +def extract_default_from_description item + m = item[:description].match(/\(default: (.+?)\)\s*?$/) + return if !m + # modify `item` in-place + item[:default] = m[1] + item[:description] = m.pre_match end def parse_file filename @@ -57,7 +65,7 @@ } valid_for_all = %w[name description].map(&:to_sym) valid_per_kind = { - class: valid_for_all + %w[parent mixins methods properties events abstract trait].map(&:to_sym), + class: valid_for_all + %w[parent mixins methods properties events abstract mixin].map(&:to_sym), method: valid_for_all + %w[params config return visibility static].map(&:to_sym), property: valid_for_all + %w[type static].map(&:to_sym), event: valid_for_all + %w[params].map(&:to_sym), @@ -74,7 +82,11 @@ m = comment_line.match(/^@(\w+)[ \t]*(.*)/) if !m + # this is a continuation of previous item's description previous_item[:description] << comment_line + "\n" + if filetype == :php + extract_default_from_description(previous_item) + end next end @@ -130,6 +142,9 @@ data[:params] << {name: name, type: cleanup_class_name(type), description: description || ''} previous_item = data[:params][-1] end + if filetype == :php + extract_default_from_description(previous_item) + end end when 'cfg' # JS only m = content.match(/^\{(.+?)\} \[?([\w.$]+?)(?:=(.+?))?\]?( .+)?$/) @@ -162,10 +177,10 @@ data[:static] = true when 'abstract' data[:abstract] = true - when 'ignore' + when 'ignore', 'inheritdoc' ignore = true when 'inheritable', 'deprecated', 'singleton', 'throws', - 'chainable', 'fires', 'localdoc', 'inheritdoc', 'member', + 'chainable', 'fires', 'localdoc', 'member', 'see', 'uses' # skip else @@ -179,7 +194,7 @@ if code_line && code_line.strip != '' case filetype when :js - m = code_line.match(/(?:(static|prototype)\.)?(\w+) =/) + m = code_line.match(/(?:(static|prototype|mixin)\.)?(\w+) =/) if !m bad_input filename, code_line.strip next @@ -187,6 +202,7 @@ kind_, name = m.captures data[:static] = true if kind_ == 'static' kind = {'static' => :property, 'prototype' => :method}[ kind_.strip ] if kind_ && !kind + data[:mixin] = true if kind_ == 'mixin' data[:name] ||= cleanup_class_name(name) when :php m = code_line.match(/ @@ -203,7 +219,7 @@ visibility, static, kind_, name, parent = m.captures kind = {'$' => :property, 'function' => :method, 'class' => :class, 'trait' => :class}[ kind_.strip ] data[:visibility] = {'private' => :private, 'protected' => :protected, 'public' => :public}[ visibility ] || :public - data[:trait] = true if kind_.strip == 'trait' + data[:mixin] = true if kind_.strip == 'trait' data[:static] = true if static data[:parent] = cleanup_class_name(parent) if parent data[:name] ||= cleanup_class_name(name) diff --git a/oojs/oojs-ui/bin/generate-JSPHP-for-karma.php b/oojs/oojs-ui/bin/generate-JSPHP-for-karma.php index 8f71595..faadd70 100644 --- a/oojs/oojs-ui/bin/generate-JSPHP-for-karma.php +++ b/oojs/oojs-ui/bin/generate-JSPHP-for-karma.php @@ -7,7 +7,7 @@ $testSuiteOutput = []; // @codingStandardsIgnoreStart -function new_OOUI( $class, $config = array() ) { +function new_OOUI( $class, $config = [] ) { // @codingStandardsIgnoreEnd $class = "OOUI\\" . $class; return new $class( $config ); @@ -28,7 +28,7 @@ foreach ( $themes as $theme ) { OOUI\Theme::setSingleton( new_OOUI( $theme ) ); foreach ( $testSuite as $className => $tests ) { - foreach ( $tests as $test ) { + foreach ( $tests['tests'] as $test ) { // Unstub placeholders $config = $test['config']; array_walk_recursive( $config, 'unstub' ); diff --git a/oojs/oojs-ui/bin/testsuitegenerator.rb b/oojs/oojs-ui/bin/testsuitegenerator.rb index e46a4a0..f0da93e 100644 --- a/oojs/oojs-ui/bin/testsuitegenerator.rb +++ b/oojs/oojs-ui/bin/testsuitegenerator.rb @@ -11,16 +11,17 @@ class_names = (js + php).map{|c| c[:name] }.sort.uniq - tests = [] + tests = {} classes = php.select{|c| class_names.include? c[:name] } - untestable_classes = %w[DropdownInputWidget ComboBoxInputWidget + # classes with different PHP and JS implementations. + # we can still compare the PHP-infuse result to JS result, though. + infuse_only_classes = %w[DropdownInputWidget ComboBoxInputWidget RadioSelectInputWidget CheckboxMultiselectInputWidget] testable_classes = classes .reject{|c| c[:abstract] } # can't test abstract classes .reject{|c| !c[:parent] || c[:trait] || c[:parent] == 'Theme' } # can't test abstract .reject{|c| %w[Element Widget Layout Theme].include? c[:name] } # no toplevel - .reject{|c| untestable_classes.include? c[:name] } # different PHP and JS implementations make_class_instance_placeholder = lambda do |klass, config| '_placeholder_' + { @@ -61,6 +62,12 @@ 'indicator' => ['down'], 'flags' => %w[constructive primary], 'progress' => [0, 50, 100, false], + 'options' => [ + [], + [ { 'data' => 'a', 'label' => 'A' } ], + [ { 'data' => 'a' }, { 'data' => 'b' } ], + [ { 'data' => 'a', 'label' => 'A' }, { 'data' => 'b', 'label' => 'B' } ], + ], # usually makes no sense in JS 'autofocus' => [], # too simple to test? @@ -131,7 +138,13 @@ end testable_classes.each do |klass| - config_sources = find_config_sources.call(klass[:name]) + class_name = klass[:name] + tests[class_name] = { + infuseonly: !infuse_only_classes.index(class_name).nil?, + tests: [], + } + + config_sources = find_config_sources.call(class_name) .map{|c| find_class.call(c)[:methods][0] } config = config_sources.map{|c| c[:config] }.compact.inject(:+) required_config = klass[:methods][0][:params] || [] @@ -145,7 +158,7 @@ expanded = config_comb.map{|config_option| types = config_option[:type].split '|' values = - sensible_values[ [ klass[:name], config_option[:name] ] ] || + sensible_values[ [ class_name, config_option[:name] ] ] || sensible_values[ config_option[:name] ] || expand_types_to_values.call(types) values.map{|v| config_option.dup.merge(value: v) } @@ -154,16 +167,15 @@ }.inject(:concat).uniq config_combinations.each do |config_comb| - tests << { - class: klass[:name], + tests[class_name][:tests] << { + class: class_name, config: Hash[ config_comb.map{|c| [ c[:name], c[:value] ] } ] } end end - $stderr.puts "Generated #{tests.length} test cases." - tests = tests.group_by{|t| t[:class] } + $stderr.puts "Generated #{tests.values.map{|a| a[:tests].length}.inject(:+)} test cases." - $stderr.puts tests.map{|class_name, class_tests| "* #{class_name}: #{class_tests.length}" } + $stderr.puts tests.map{|class_name, class_tests| "* #{class_name}: #{class_tests[:tests].length}" } puts JSON.pretty_generate tests end diff --git a/oojs/oojs-ui/demos/demos.php b/oojs/oojs-ui/demos/demos.php index a727a39..d3ba067 100644 --- a/oojs/oojs-ui/demos/demos.php +++ b/oojs/oojs-ui/demos/demos.php @@ -112,7 +112,6 @@ <!-- Demonstrate JavaScript "infusion" of PHP widgets --> <script src="node_modules/jquery/dist/jquery.js"></script> - <script src="node_modules/es5-shim/es5-shim.js"></script> <script src="node_modules/oojs/dist/oojs.jquery.js"></script> <script src="dist/oojs-ui-core.js"></script> <script src="dist/oojs-ui-<?php echo $theme; ?>.js"></script> diff --git a/oojs/oojs-ui/demos/index.html b/oojs/oojs-ui/demos/index.html index b0e9929..4571afe 100644 --- a/oojs/oojs-ui/demos/index.html +++ b/oojs/oojs-ui/demos/index.html @@ -3,15 +3,13 @@ <head> <meta charset="UTF-8"> <title>OOjs UI Demos</title> - <!-- Prevent scaling on mobile devices which cause problems with dialog sizing --> - <meta name="viewport" content="width=device-width, user-scalable=no"> + <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="classes/ButtonStyleShowcaseWidget.css"> <link rel="stylesheet" href="classes/FloatableTest.css"> <link rel="stylesheet" href="classes/PositionSelectWidget.css"> </head> <body> <script src="node_modules/jquery/dist/jquery.js"></script> - <script src="node_modules/es5-shim/es5-shim.js"></script> <script src="node_modules/oojs/dist/oojs.jquery.js"></script> <script src="dist/oojs-ui.js"></script> <script src="dist/oojs-ui-mediawiki.js"></script> <!-- Do not change this line or you'll break `grunt add-theme` --> diff --git a/oojs/oojs-ui/demos/pages/dialogs.js b/oojs/oojs-ui/demos/pages/dialogs.js index ad1cc53..dc34cf3 100644 --- a/oojs/oojs-ui/demos/pages/dialogs.js +++ b/oojs/oojs-ui/demos/pages/dialogs.js @@ -15,6 +15,12 @@ param: 'Alert message.' }, { + name: 'Larger alert', + method: 'alert', + param: 'Alert message.', + data: { size: 'larger' } + }, + { name: 'Quick confirm', method: 'confirm', param: 'Confirmation message?' @@ -288,7 +294,12 @@ if ( examples[ i ].method ) { openButton.on( - 'click', OO.ui.bind( OO.ui, examples[ i ].method, examples[ i ].param ) + 'click', OO.ui.bind( + OO.ui, + examples[ i ].method, + examples[ i ].param, + examples[ i ].data + ) ); } else { name = 'window_' + j + '_' + i; diff --git a/oojs/oojs-ui/demos/pages/toolbars.js b/oojs/oojs-ui/demos/pages/toolbars.js index 9cf90f6..ff29152 100644 --- a/oojs/oojs-ui/demos/pages/toolbars.js +++ b/oojs/oojs-ui/demos/pages/toolbars.js @@ -1,5 +1,5 @@ Demo.static.pages.toolbars = function ( demo ) { - var i, toolGroups, saveButton, deleteButton, actionButton, actionButtonDisabled, PopupTool, ToolGroupTool, + var i, toolGroups, saveButton, deleteButton, actionButton, actionGroup, actionButtonDisabled, PopupTool, ToolGroupTool, setDisabled = function () { this.setDisabled( true ); }, $demo = demo.$element, $containers = $(), @@ -12,7 +12,9 @@ {}, { actions: true }, { position: 'bottom' }, - { actions: true, position: 'bottom' } + { actions: true, position: 'bottom' }, + {}, + { actions: true } ]; // Show some random accelerator keys that don't actually work @@ -26,7 +28,7 @@ }[ name ]; } - for ( i = 0; i <= 5; i++ ) { + for ( i = 0; i <= 7; i++ ) { toolFactories.push( new OO.ui.ToolFactory() ); toolGroupFactories.push( new OO.ui.ToolGroupFactory() ); toolbars.push( new OO.ui.Toolbar( toolFactories[ i ], toolGroupFactories[ i ], configs[ i ] ) ); @@ -268,6 +270,27 @@ include: [ { group: 'autoDisableListTools' }, { group: 'unusedStuff' } ] } ] ); + // Action toolbar for toolbars[7] + toolbars[ 6 ].setup( [ + { + type: 'list', + indicator: 'down', + include: [ { group: 'listTools' } ] + } + ] ); + // Toolbar with action buttons, in a buttongroup + toolbars[ 7 ].setup( [ + { + type: 'menu', + icon: 'image', + include: [ { group: 'menuTools' } ] + }, + { + type: 'disabledMenu', + icon: 'image', + include: [ { group: 'disabledMenuTools' } ] + } + ] ); actionButton = new OO.ui.ButtonWidget( { label: 'Action' } ); actionButtonDisabled = new OO.ui.ButtonWidget( { label: 'Disabled', disabled: true } ); @@ -278,6 +301,12 @@ saveButton = new OO.ui.ButtonWidget( { label: 'Save', flags: [ 'progressive', 'primary' ] } ); toolbars[ i ].$actions.append( toolbars[ i - 1 ].$element, deleteButton.$element, saveButton.$element ); } + + saveButton = new OO.ui.ButtonWidget( { label: 'Save', flags: [ 'progressive', 'primary' ] } ); + actionGroup = new OO.ui.ButtonGroupWidget( { + items: [ saveButton, toolbars[ 6 ].items[ 0 ] ] + } ); + toolbars[ 7 ].$actions.append( actionGroup.$element ); for ( i = 0; i < toolbars.length; i++ ) { toolbars[ i ].emit( 'updateState' ); @@ -360,6 +389,9 @@ createToolGroup( 0, 'autoDisableListTools' ); createToolGroup( 1, 'menuTools' ); createToolGroup( 1, 'disabledMenuTools' ); + createToolGroup( 6, 'listTools' ); + createToolGroup( 7, 'menuTools' ); + createToolGroup( 7, 'disabledMenuTools' ); for ( i = 3; i <= 5; i += 2 ) { createToolGroup( i - 1, 'listTools' ); createToolGroup( i, 'history' ); @@ -374,7 +406,7 @@ } for ( i = 0; i < toolbars.length; i++ ) { - if ( i === 2 || i === 4 ) { + if ( i === 2 || i === 4 || i === 6 ) { // Action toolbars continue; } @@ -393,7 +425,8 @@ $containers.eq( 0 ).append( '<div class="demo-toolbars-contents">Toolbar</div>' ), $containers.eq( 1 ).append( '<div class="demo-toolbars-contents">Toolbar with action buttons</div>' ), $containers.eq( 2 ).append( '<div class="demo-toolbars-contents">Word processor toolbar</div>' ), - $containers.eq( 3 ).prepend( '<div class="demo-toolbars-contents">Position bottom</div>' ) + $containers.eq( 3 ).prepend( '<div class="demo-toolbars-contents">Position bottom</div>' ), + $containers.eq( 4 ).append( '<div class="demo-toolbars-contents">Toolbar with action buttons in a group</div>' ) ); for ( i = 0; i < toolbars.length; i++ ) { toolbars[ i ].initialize(); diff --git a/oojs/oojs-ui/demos/pages/widgets.js b/oojs/oojs-ui/demos/pages/widgets.js index d859bbf..3081ec4 100644 --- a/oojs/oojs-ui/demos/pages/widgets.js +++ b/oojs/oojs-ui/demos/pages/widgets.js @@ -1330,6 +1330,89 @@ } ), new OO.ui.FieldLayout( + new OO.ui.TagMultiselectWidget( { + placeholder: 'Add tags', + allowArbitrary: true + } ), + { + label: 'TagMultiselectWidget (allowArbitrary, inline input, placeholder)', + align: 'top' + } + ), + new OO.ui.FieldLayout( + new OO.ui.TagMultiselectWidget( { + placeholder: 'Add tags', + allowArbitrary: true, + disabled: true + } ), + { + label: 'TagMultiselectWidget (disabled, inline input, placeholder)', + align: 'top' + } + ), + new OO.ui.FieldLayout( + new OO.ui.TagMultiselectWidget( { + allowArbitrary: false, + allowDisplayInvalidTags: true, + allowedValues: [ 'foo', 'bar', 'baz' ] + } ), + { + label: 'TagMultiselectWidget (inline input, allowed values: [ \'foo\', \'bar\', \'baz\' ], allowDisplayInvalidTags)', + align: 'top' + } + ), + new OO.ui.FieldLayout( + new OO.ui.TagMultiselectWidget( { + placeholder: 'Add tags', + allowArbitrary: true, + inputPosition: 'outline' + } ), + { + label: 'TagMultiselectWidget (allowArbitrary, outline input, placeholder)', + align: 'top' + } + ), + new OO.ui.FieldLayout( + new OO.ui.PopupTagMultiselectWidget( { + allowArbitrary: true, + icon: 'tag', + indicator: 'alert' + } ), + { + label: 'PopupTagMultiselectWidget (icon, indicator, allowArbitrary)', + align: 'top' + } + ), + new OO.ui.FieldLayout( + new OO.ui.MenuTagMultiselectWidget( { + allowArbitrary: false, + options: [ + { data: 'abc', label: 'Label for abc' }, + { data: 'asd', label: 'Label for asd' }, + { data: 'jkl', label: 'Label for jkl' } + ] + } ), + { + label: 'MenuTagMultiselectWidget (allowArbitrary:false)', + align: 'top' + } + ), + new OO.ui.FieldLayout( + new OO.ui.MenuTagMultiselectWidget( { + inputPosition: 'outline', + allowArbitrary: false, + options: [ + { data: 'abc', label: 'Label for abc' }, + { data: 'asd', label: 'Label for asd' }, + { data: 'jkl', label: 'Label for jkl' } + ] + } ), + { + label: 'MenuTagMultiselectWidget (inputPosition:outline, allowArbitrary:false)', + align: 'top' + } + ), + new OO.ui.FieldLayout( new OO.ui.CapsuleMultiselectWidget( { menu: { items: [ diff --git a/oojs/oojs-ui/package.json b/oojs/oojs-ui/package.json index 28fa48c..381572d 100644 --- a/oojs/oojs-ui/package.json +++ b/oojs/oojs-ui/package.json @@ -1,6 +1,6 @@ { "name": "oojs-ui", - "version": "0.20.2", + "version": "0.21.0", "description": "User interface classes built on the OOjs framework.", "keywords": [ "oojs-plugin", @@ -22,9 +22,8 @@ "jenkins": "npm test && jsduck && npm run postdoc" }, "dependencies": { - "es5-shim": "4.5.8", "jquery": "1.11.3", - "oojs": "1.1.10" + "oojs": "2.0.0" }, "devDependencies": { "eslint-config-wikimedia": "0.3.0", diff --git a/oojs/oojs-ui/php/Element.php b/oojs/oojs-ui/php/Element.php index 9441c7f..8bab42d 100644 --- a/oojs/oojs-ui/php/Element.php +++ b/oojs/oojs-ui/php/Element.php @@ -154,7 +154,7 @@ * @param array &$config * An array which will be mutated to add the necessary configuration * properties. Unless you are implementing a subclass, you should - * always pass a new empty `array()`. + * always pass a new empty array `[]`. * @return array * A configuration array which can be passed to this object's * constructor to recreate it. This is a return value to allow diff --git a/oojs/oojs-ui/php/widgets/CheckboxMultiselectInputWidget.php b/oojs/oojs-ui/php/widgets/CheckboxMultiselectInputWidget.php index e311b29..054e099 100644 --- a/oojs/oojs-ui/php/widgets/CheckboxMultiselectInputWidget.php +++ b/oojs/oojs-ui/php/widgets/CheckboxMultiselectInputWidget.php @@ -35,7 +35,7 @@ /** * @param array $config Configuration options * @param array[] $config['options'] Array of menu options in the format - * `array( 'data' => …, 'label' => …, 'disabled' => … )` + * `[ 'data' => …, 'label' => …, 'disabled' => … ]` */ public function __construct( array $config = [] ) { // Parent constructor @@ -102,7 +102,7 @@ * Set the options available for this input. * * @param array[] $options Array of menu options in the format - * `array( 'data' => …, 'label' => …, 'disabled' => … )` + * `[ 'data' => …, 'label' => …, 'disabled' => … ]` * @return $this */ public function setOptions( $options ) { diff --git a/oojs/oojs-ui/php/widgets/ComboBoxInputWidget.php b/oojs/oojs-ui/php/widgets/ComboBoxInputWidget.php index 05ebbec..c2f8d34 100644 --- a/oojs/oojs-ui/php/widgets/ComboBoxInputWidget.php +++ b/oojs/oojs-ui/php/widgets/ComboBoxInputWidget.php @@ -16,32 +16,32 @@ /** * @param array $config Configuration options * @param array[] $config['options'] Array of menu options in the format - * `array( 'data' => …, 'label' => … )` + * `[ 'data' => …, 'label' => … ]` */ public function __construct( array $config = [] ) { - // Config initialization - $config = array_merge( [ - 'indicator' => 'down', - ], $config ); + // ComboBoxInputWidget shouldn't support `multiline` + $config['multiline'] = false; // Parent constructor parent::__construct( $config ); // Initialization + $this->forceAutocomplete = isset( $config['autocomplete'] ) ? $config['autocomplete'] : false; + $this->downIndicator = new IndicatorWidget( [ 'indicator' => 'down' ] ); $this->datalist = new Tag( 'datalist' ); $this->datalist->setAttributes( [ 'id' => Tag::generateElementId() ] ); $this->input->setAttributes( [ 'list' => $this->datalist->getAttribute( 'id' ) ] ); $this->setOptions( isset( $config['options'] ) ? $config['options'] : [] ); $this->addClasses( [ 'oo-ui-comboBoxInputWidget', 'oo-ui-comboBoxInputWidget-php' ] ); - $this->appendContent( $this->datalist ); + $this->appendContent( $this->downIndicator, $this->datalist ); } /** * Set the options available for this input. * * @param array[] $options Array of menu options in the format - * `array( 'data' => …, 'label' => … )` + * `[ 'data' => …, 'label' => … ]` * @return $this */ public function setOptions( $options ) { @@ -68,6 +68,12 @@ $o[] = [ 'data' => $data, 'label' => $label ]; } $config['options'] = $o; + // JS ComboBoxInputWidget has `autocomplete: false` in the defaults. Make sure + // explicitly passing `autocomplete: true` overrides that. Doing so doesn't make + // much sense, this is just to make the tests happy. + if ( $this->forceAutocomplete ) { + $config['autocomplete'] = true; + } return parent::getConfig( $config ); } } diff --git a/oojs/oojs-ui/php/widgets/DropdownInputWidget.php b/oojs/oojs-ui/php/widgets/DropdownInputWidget.php index 359858c..83430f5 100644 --- a/oojs/oojs-ui/php/widgets/DropdownInputWidget.php +++ b/oojs/oojs-ui/php/widgets/DropdownInputWidget.php @@ -16,7 +16,7 @@ /** * @param array $config Configuration options * @param array[] $config['options'] Array of menu options in the format - * `array( 'data' => …, 'label' => … )` + * `[ 'data' => …, 'label' => … ]` */ public function __construct( array $config = [] ) { // Parent constructor @@ -48,7 +48,7 @@ * Set the options available for this input. * * @param array[] $options Array of menu options in the format - * `array( 'data' => …, 'label' => … )` + * `[ 'data' => …, 'label' => … ]` * @return $this */ public function setOptions( $options ) { diff --git a/oojs/oojs-ui/php/widgets/RadioSelectInputWidget.php b/oojs/oojs-ui/php/widgets/RadioSelectInputWidget.php index 379b408..d9f1c98 100644 --- a/oojs/oojs-ui/php/widgets/RadioSelectInputWidget.php +++ b/oojs/oojs-ui/php/widgets/RadioSelectInputWidget.php @@ -28,7 +28,7 @@ /** * @param array $config Configuration options * @param array[] $config['options'] Array of menu options in the format - * `array( 'data' => …, 'label' => … )` + * `[ 'data' => …, 'label' => … ]` */ public function __construct( array $config = [] ) { // Parent constructor @@ -60,7 +60,7 @@ * Set the options available for this input. * * @param array[] $options Array of menu options in the format - * `array( 'data' => …, 'label' => … )` + * `[ 'data' => …, 'label' => … ]` * @return $this */ public function setOptions( $options ) { -- To view, visit https://gerrit.wikimedia.org/r/347790 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I94d5b7a89551e7d34d53223872ad3005f0ac4a04 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/vendor Gerrit-Branch: master Gerrit-Owner: VolkerE <volke...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits