Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

t/344: Refactoring of the dropdown ecosystem #361

Merged
merged 79 commits into from
Feb 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
cdbc350
Other: Initial SplitButton implementation.
jodator Nov 22, 2017
7de6eb4
Other: Update SplitButtonDropdown keystrokes behavior.
jodator Nov 22, 2017
3e62922
Other: Make createSplitButtonDropdown minimal.
jodator Nov 22, 2017
537fbe6
Other: Change how split button is bound to model.
jodator Nov 23, 2017
f4fe2e8
Other: Move some SplitButtonDropdown functionality to SplitButtonDrop…
jodator Nov 24, 2017
7804863
Other: Update SplitButton CSS.
jodator Jan 15, 2018
575b2a9
Other: Fix SplitButton CSS.
jodator Jan 15, 2018
488d050
Change: Horizontal toolbar should have nowrap set.
jodator Jan 15, 2018
4a291b9
Changed: Make split button in toolbar look like other buttons.
jodator Jan 17, 2018
08fa387
Added: Style toolbar separator in button dropdown.
jodator Jan 17, 2018
2c96b24
Fix: Split button's main button outline is not displayed correctly.
jodator Jan 17, 2018
dbc7a70
Other: SplitButton dropdown improvements.
jodator Jan 18, 2018
0394490
Remove splitbuttondropdownview.js and use 'select' button event instead.
jodator Jan 18, 2018
e1cc15c
Changed: Stub new dropdown creator methods.
jodator Jan 18, 2018
102e5c7
Changed: Extract common dropdown tasks to helper methods.
jodator Jan 19, 2018
ba2a0ee
Changed: Temporary disable 'isOn' binding in button.
jodator Jan 19, 2018
79ec879
Changed: Rename parts of SplitButton buttons to action/select.
jodator Jan 19, 2018
63642cf
Fix: typos.
jodator Jan 19, 2018
b70ffca
Changed: Remove crateButtonDropdown() and createListDropdown() helpers.
jodator Jan 22, 2018
80c7258
Tests: add tests for dropdown util: enableModelIfOneIsEnabled().
jodator Jan 22, 2018
5cf51a5
Changed: Remove createDropdown() method.
jodator Jan 22, 2018
9236088
Changed: Remove toolbar class binding from dropdown.
jodator Jan 23, 2018
16f14ed
Changed: Rename button dropdown to toolbar dropdown.
jodator Jan 23, 2018
7bf2edb
Tests: Add tests for createSplitButtonForDropdown() and createButtonF…
jodator Jan 23, 2018
53a9fdc
Changed: Removed `addDefaultBehavior()` from dropdown utils.
jodator Jan 23, 2018
a8b8f2f
Changed: Removed `createSingleButtonDropdown()` from dropdown utils.
jodator Jan 23, 2018
0d33dc2
Changed: Removed `createSplitButtonDropdown()` from dropdown utils.
jodator Jan 23, 2018
481630c
Tests: Fix test after recent changes.
jodator Jan 23, 2018
67251f9
Other: Extract `focusDropdownContentsOnArrows()` to own file.
jodator Jan 24, 2018
ba41ff8
Other: Extract `closeDropdownOnExecute()` to own file.
jodator Jan 24, 2018
7b109be
Other: Extract `closeDropdownOnBlur()` to own file.
jodator Jan 24, 2018
aee02ee
Other: Extract `createButtonForDropdown()` to own file.
jodator Jan 24, 2018
420de05
Other: Extract `createSplitButtonForDropdown()` to own file.
jodator Jan 24, 2018
b787981
Other: Extract `createDropdownView()` to own file.
jodator Jan 24, 2018
d03791a
Other: Extract `enableModelIfOneIsEnabled()` to own file.
jodator Jan 24, 2018
1b93679
Other: Extract `addListViewToDropdown()` to own file.
jodator Jan 24, 2018
88217ed
Other: Extract `addToolbarToDropdown()` to own file.
jodator Jan 24, 2018
4ee81bf
Other: Extract `getBindingTargets()` to own file and move it to ui/bi…
jodator Jan 24, 2018
b39b544
Fix: Updated toolbardropdown.css path.
jodator Jan 24, 2018
358c022
Other: Revert icon hack from ButtonView.
jodator Jan 24, 2018
335e5cb
Fixed: Toolbar dropdown's items "execute" event is not delegated to d…
jodator Jan 24, 2018
3d21766
Tests: Remove empty describe() from addtoolbartodropdown tests.
jodator Jan 24, 2018
26d94b6
Tests: Add SplitButtonView tests.
jodator Jan 24, 2018
e942460
Tests: Add `DropdownPanelView#focus()` and `DropdownPanelView#focusLa…
jodator Jan 24, 2018
f446a4a
Docs: Add dropdowns framework guide stub.
jodator Jan 24, 2018
acca5f4
Changed: Change how dropdowns with `ButtonView` and `SplitButtonView`…
jodator Jan 28, 2018
2e2815f
Changed: Remove dafult dropdown behavior helper methods from API.
jodator Jan 28, 2018
30e1e9b
Added: Introduce `bindOneToMany()` binding helper.
jodator Jan 28, 2018
bcd04c5
Changed: Move `addToolbarToDropdown()` helper to ui/dropdown/utils.
jodator Jan 29, 2018
2e7ab21
Changed: Move `addListViewToDropdown()` helper to ui/dropdown/utils.
jodator Jan 29, 2018
fec44e7
Changed: Bind dropdown behavior to `DropdownView` instead of `Model`.
jodator Jan 29, 2018
82b46f3
Docs: Updated dropdown framework guide.
jodator Jan 29, 2018
a0e8743
Fix: Wrong path to ckeditor5-utils package in tests.
jodator Jan 29, 2018
e5251ed
Code style: The dots are required at the end of the comment.
jodator Jan 29, 2018
e3139aa
Docs: Update `SplitButtonView` documentation.
jodator Jan 29, 2018
8161c10
Changed: Use `bind().toMany()` binding chain from `ObservableMixin`.
jodator Feb 1, 2018
23e0d16
Docs: Brought dropdown/utils methods to a common naming scheme.
jodator Feb 2, 2018
093e735
Changed: Review `SplitButton#actionView` bindings.
jodator Feb 2, 2018
2264fcf
Changed: Removed unnecessary private method from dropdown/utils.
jodator Feb 2, 2018
caefc2c
Docs: Document optional observable properties of the DropdownView.
jodator Feb 2, 2018
2841422
Docs: Fix links in documentation and update dropdown's properties.
jodator Feb 2, 2018
383524c
Docs: Fix code block padding in utils.js.
jodator Feb 2, 2018
39449f7
Changed: Extract DropdownButtonView from Dropdown.
jodator Feb 5, 2018
f1beae8
Changed: Move dropdown buttons to ui/dropdown/buttons.
jodator Feb 5, 2018
b071836
Changed: Make ButtonClass as a parameter of `createDropdown()`.
jodator Feb 5, 2018
f92a96b
Docs: Updated the dropdown framework guide stub.
jodator Feb 5, 2018
3e0d7a8
Code style: Fix code indentation in code examples.
jodator Feb 5, 2018
6a08edc
Changed: Remove `dropdown.buttonView` bindings to `dropdown`.
jodator Feb 5, 2018
33783eb
Docs: Move dropdowns framework guide to architecture/ui-library guide.
jodator Feb 5, 2018
a0308c3
Docs: Introduce `ButtonInterface` and `DropdownButtonInterface`.
jodator Feb 5, 2018
1413c2e
Docs: Update dropdown buttons documentation.
jodator Feb 6, 2018
41e1bbe
Docs: Update dropdown documentation.
jodator Feb 6, 2018
2b0291d
Docs: Add missing docs for DropdownPanelView.
jodator Feb 6, 2018
8344775
Changed: Rename `DropdownButtonInterface#select` event to `#open`.
jodator Feb 6, 2018
faa800b
Merge branch 'master' into t/344
Reinmar Feb 7, 2018
110f4f8
Improved ButtonInterface and how other classes implement it.
Reinmar Feb 8, 2018
a908e03
Improved docs.
Reinmar Feb 8, 2018
07925bb
Tests: Update dropdown manual tests.
jodator Feb 8, 2018
7c0e6c9
Avoid using the word Interface in interface names by simply stripping…
Reinmar Feb 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions src/button/button.jsdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md.
*/

/**
* @module ui/button/button
*/

/**
* The button interface. Implemented by, among others, {@link module:ui/button/buttonview~ButtonView},
* {@link module:ui/dropdown/button/splitbuttonview~SplitButtonView} and
* {@link module:ui/dropdown/button/dropdownbuttonview~DropdownButtonView}.
*
* @interface module:ui/button/button~Button
*/

/**
* The label of the button view visible to the user when {@link #withText} is `true`.
* It can also be used to create a {@link #tooltip}.
*
* @observable
* @member {String} #label
*/

/**
* (Optional) The keystroke associated with the button, i.e. <kbd>CTRL+B</kbd>,
* in the string format compatible with {@link module:utils/keyboard}.
*
* @observable
* @member {Boolean} #keystroke
*/

/**
* (Optional) Tooltip of the button, i.e. displayed when hovering the button with the mouse cursor.
*
* * If defined as a `Boolean` (e.g. `true`), then combination of `label` and `keystroke` will be set as a tooltip.
* * If defined as a `String`, tooltip will equal the exact text of that `String`.
* * If defined as a `Function`, `label` and `keystroke` will be passed to that function, which is to return
* a string with the tooltip text.
*
* const view = new ButtonView( locale );
* view.tooltip = ( label, keystroke ) => `A tooltip for ${ label } and ${ keystroke }.`
*
* @observable
* @default false
* @member {Boolean|String|Function} #tooltip
*/

/**
* (Optional) The position of the tooltip. See {@link module:ui/tooltip/tooltipview~TooltipView#position}
* to learn more about the available position values.
*
* **Note:** It makes sense only when the {@link #tooltip `tooltip` attribute} is defined.
*
* @observable
* @default 's'
* @member {'s'|'n'} #tooltipPosition
*/

/**
* The HTML type of the button. Default `button`.
*
* @observable
* @member {'button'|'submit'|'reset'|'menu'} #type
*/

/**
* Controls whether the button view is "on". It makes sense when a feature it represents
* is currently active, e.g. a bold button is "on" when the selection is in the bold text.
*
* To disable the button, use {@link #isEnabled} instead.
*
* @observable
* @default true
* @member {Boolean} #isOn
*/

/**
* Controls whether the button view is enabled, i.e. it can be clicked and execute an action.
*
* To change the "on" state of the button, use {@link #isOn} instead.
*
* @observable
* @default true
* @member {Boolean} #isEnabled
*/

/**
* Controls whether the button view is visible. Visible by default, buttons are hidden
* using a CSS class.
*
* @observable
* @default true
* @member {Boolean} #isVisible
*/

/**
* (Optional) Controls whether the label of the button is hidden (e.g. an icon–only button).
*
* @observable
* @default false
* @member {Boolean} #withText
*/

/**
* (Optional) An XML {@link module:ui/icon/iconview~IconView#content content} of the icon.
* When defined, an `iconView` should be added to the button.
*
* @observable
* @member {String} #icon
*/

/**
* (Optional) Controls the `tabindex` HTML attribute of the button. By default, the button is focusable
* but does not included in the <kbd>Tab</kbd> order.
*
* @observable
* @default -1
* @member {String} #tabindex
*/

/**
* Fired when the button view is clicked. It won't be fired when the button {@link #isEnabled}
* is `false`.
*
* @event execute
*/
135 changes: 15 additions & 120 deletions src/button/buttonview.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import '../../theme/components/button/button.css';
* document.body.append( view.element );
*
* @extends module:ui/view~View
* @implements module:ui/button/button~Button
*/
export default class ButtonView extends View {
/**
Expand All @@ -42,118 +43,19 @@ export default class ButtonView extends View {

const bind = this.bindTemplate;

/**
* The label of the button view visible to the user when {@link #withText} is `true`.
* It can also be used to create a {@link #tooltip}.
*
* @observable
* @member {String} #label
*/
this.set( 'label' );

/**
* (Optional) The keystroke associated with the button, i.e. <kbd>CTRL+B</kbd>,
* in the string format compatible with {@link module:utils/keyboard}.
*
* @observable
* @member {Boolean} #keystroke
*/
// Implement the Button interface.
this.set( 'icon' );
this.set( 'isEnabled', true );
this.set( 'isOn', false );
this.set( 'isVisible', true );
this.set( 'keystroke' );

/**
* (Optional) Tooltip of the button, i.e. displayed when hovering the button with the mouse cursor.
*
* * If defined as a `Boolean` (e.g. `true`), then combination of `label` and `keystroke` will be set as a tooltip.
* * If defined as a `String`, tooltip will equal the exact text of that `String`.
* * If defined as a `Function`, `label` and `keystroke` will be passed to that function, which is to return
* a string with the tooltip text.
*
* const view = new ButtonView( locale );
* view.tooltip = ( label, keystroke ) => `A tooltip for ${ label } and ${ keystroke }.`
*
* @observable
* @default false
* @member {Boolean|String|Function} #tooltip
*/
this.set( 'label' );
this.set( 'tabindex', -1 );
this.set( 'tooltip' );

/**
* (Optional) The position of the tooltip. See {@link module:ui/tooltip/tooltipview~TooltipView#position}
* to learn more about the available position values.
*
* **Note:** It makes sense only when the {@link #tooltip `tooltip` attribute} is defined.
*
* @observable
* @default 's'
* @member {'s'|'n'} #position
*/
this.set( 'tooltipPosition', 's' );

/**
* The HTML type of the button. Default `button`.
*
* @observable
* @member {'button'|'submit'|'reset'|'menu'} #type
*/
this.set( 'type', 'button' );

/**
* Controls whether the button view is "on". It makes sense when a feature it represents
* is currently active, e.g. a bold button is "on" when the selection is in the bold text.
*
* To disable the button, use {@link #isEnabled} instead.
*
* @observable
* @member {Boolean} #isOn
*/
this.set( 'isOn', false );

/**
* Controls whether the button view is enabled, i.e. it can be clicked and execute an action.
*
* To change the "on" state of the button, use {@link #isOn} instead.
*
* @observable
* @member {Boolean} #isEnabled
*/
this.set( 'isEnabled', true );

/**
* Controls whether the button view is visible. Visible by default, buttons are hidden
* using a CSS class.
*
* @observable
* @member {Boolean} #isVisible
*/
this.set( 'isVisible', true );

/**
* (Optional) Controls whether the label of the button is hidden (e.g. an icon–only button).
*
* @observable
* @member {Boolean} #withText
*/
this.set( 'withText', false );

/**
* (Optional) An XML {@link module:ui/icon/iconview~IconView#content content} of the icon.
* When defined, an {@link #iconView} will be added to the button.
*
* @observable
* @member {String} #icon
*/
this.set( 'icon' );

/**
* (Optional) Controls the `tabindex` HTML attribute of the button. By default, the button is focusable
* but does not included in the <kbd>Tab</kbd> order.
*
* @observable
* @default -1
* @member {String} #tabindex
*/
this.set( 'tabindex', -1 );

/**
* Collection of the child views inside of the button {@link #element}.
*
Expand All @@ -178,6 +80,13 @@ export default class ButtonView extends View {
*/
this.labelView = this._createLabelView();

/**
* (Optional) The icon view of the button. Only present when the {@link #icon icon attribute} is defined.
*
* @readonly
* @member {module:ui/icon/iconview~IconView} #iconView
*/

/**
* Tooltip of the button bound to the template.
*
Expand All @@ -194,13 +103,6 @@ export default class ButtonView extends View {
this._getTooltipString.bind( this )
);

/**
* (Optional) The icon view of the button. Only present when the {@link #icon icon attribute} is defined.
*
* @readonly
* @member {module:ui/icon/iconview~IconView} #iconView
*/

this.setTemplate( {
tag: 'button',

Expand Down Expand Up @@ -236,13 +138,6 @@ export default class ButtonView extends View {
} )
}
} );

/**
* Fired when the button view is clicked. It won't be fired when the button {@link #isEnabled}
* is `false`.
*
* @event execute
*/
}

/**
Expand Down
71 changes: 0 additions & 71 deletions src/dropdown/button/buttondropdownmodel.jsdoc

This file was deleted.

Loading