Slide 1

Slide 1 text

Moriel Schottlender Software Engineer Collaboration Team Wikimedia Foundation

Slide 2

Slide 2 text

OOjs-UI

Slide 3

Slide 3 text

OOjs-UI Object Oriented JavaScript User Interface Library

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

● VisualEditor project started in 2011 ● Repository split in late 2013: ● VisualEditor standalone ('core') ● VisualEditor MediaWiki ● OOjs-UI

Slide 6

Slide 6 text

Why build something new??

Slide 7

Slide 7 text

Why not?

Slide 8

Slide 8 text

MediaWiki is Super extensible

Slide 9

Slide 9 text

Super extensibility ● Extensions (plugins) ● User scripts (Common.js / Common.css) ● Gadgets ● Projects in ~280 languages – 895 wikis

Slide 10

Slide 10 text

Constraints ● We can't trust the DOM for data storage – User scripts can mess with it – (We don't think that's a good idea in general)

Slide 11

Slide 11 text

Constraints ● We can't trust the DOM for data storage – User scripts can mess with it – (We don't think that's a good idea in general) ● Must be cross-platform / cross-browser

Slide 12

Slide 12 text

Constraints ● We can't trust the DOM for data storage – User scripts can mess with it – (We don't think that's a good idea in general) ● Must be cross-platform / cross-browser ● Must be themeable

Slide 13

Slide 13 text

Constraints ● We can't trust the DOM for data storage – User scripts can mess with it – (We don't think that's a good idea in general) ● Must be cross-platform / cross-browser ● Must be themeable ● Consistent one place for UI / Widgets – Users from many different cultures, countries, languages and platforms

Slide 14

Slide 14 text

Constraints ● We can't trust the DOM for data storage – User scripts can mess with it – (We don't think that's a good idea in general) ● Must be cross-platform / cross-browser ● Must be themeable ● Consistent one place for UI / Widgets – Users from many different cultures, countries, languages and platforms ● The basic functionality must support old browser technology

Slide 15

Slide 15 text

Existing problems

Slide 16

Slide 16 text

Data is stored in the DOM

Slide 17

Slide 17 text

Data is stored in the DOM (Bootstrap)

Slide 18

Slide 18 text

DOM events are messy :(

Slide 19

Slide 19 text

DOM events are messy :( Input field|

Slide 20

Slide 20 text

DOM events are messy :( Input field| keydown change input cut paste

Slide 21

Slide 21 text

DOM events are messy :( Input field| keydown change input cut paste Arrows? Enter?

Slide 22

Slide 22 text

DOM events are messy :( Input field| keydown change input cut paste Arrows? Enter? Requires focus change

Slide 23

Slide 23 text

DOM events are messy :( Input field| keydown change input cut paste Arrows? Enter? Requires focus change

Slide 24

Slide 24 text

DOM events are messy :( Input field| keydown change input cut paste Arrows? Enter? Requires focus change

Slide 25

Slide 25 text

DOM events are messy :( Input field| keydown change input cut paste Arrows? Enter? Requires focus change OO.ui.TextInputWidget

Slide 26

Slide 26 text

DOM events are messy :( Input field| keydown change input cut paste Arrows? Enter? Requires focus change Intercept Wait for stack to clear Check if content changed OO.ui.TextInputWidget

Slide 27

Slide 27 text

DOM events are messy :( Input field| keydown change input cut paste Arrows? Enter? Requires focus change Intercept Wait for stack to clear Check if content changed ignore N OO.ui.TextInputWidget

Slide 28

Slide 28 text

DOM events are messy :( Input field| keydown change input cut paste Arrows? Enter? Requires focus change Emit "change" Intercept Wait for stack to clear Check if content changed ignore Y N OO.ui.TextInputWidget

Slide 29

Slide 29 text

What we want

Slide 30

Slide 30 text

Object Oriented

Slide 31

Slide 31 text

Event emitter support Object Oriented

Slide 32

Slide 32 text

Event emitter support Object Oriented Component (building bigger widgets from smaller)

Slide 33

Slide 33 text

Event emitter support Object Oriented Component (building bigger widgets from smaller) Abstracting the DOM

Slide 34

Slide 34 text

Event emitter support Object Oriented Component (building bigger widgets from smaller) Library of mixins everyone can use Abstracting the DOM

Slide 35

Slide 35 text

Event emitter support Object Oriented Separation of data and UI Component (building bigger widgets from smaller) Library of mixins everyone can use Abstracting the DOM

Slide 36

Slide 36 text

Event emitter support Object Oriented Separation of data and UI Component (building bigger widgets from smaller) No-JS support Library of mixins everyone can use Abstracting the DOM

Slide 37

Slide 37 text

OOUI Event emitter support Object Oriented Separation of data and UI Component (building bigger widgets from smaller) No-JS support Library of mixins everyone can use Abstracting the DOM

Slide 38

Slide 38 text

OOUI OOUI-JS OOUI-PHP Event emitter support Object Oriented Separation of data and UI Component (building bigger widgets from smaller) No-JS support Library of mixins everyone can use Abstracting the DOM

Slide 39

Slide 39 text

Structure

Slide 40

Slide 40 text

OOjs OOjs-UI Object-Oriented (Inheritance, Mixins) Event Emitter Utilities Widgets DOM behavior abstraction Theming

Slide 41

Slide 41 text

OOjs OOjs-UI OOUI-PHP Object-Oriented (Inheritance, Mixins) Event Emitter Utilities Widgets DOM behavior abstraction Theming Widgets DOM structure for no-JS Theming

Slide 42

Slide 42 text

OOjs OOjs-UI OOUI-PHP infuse Object-Oriented (Inheritance, Mixins) Event Emitter Utilities Widgets DOM behavior abstraction Theming Widgets DOM structure for no-JS Theming

Slide 43

Slide 43 text

Example

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

OO.ui.SelectWidget

Slide 46

Slide 46 text

mw.echo.ui.NotificationItemWidget

Slide 47

Slide 47 text

mw.echo.ui.NotificationItemWidget Extends: OO.ui.OptionWidget

Slide 48

Slide 48 text

mw.echo.ui.NotificationItemWidget Extends: OO.ui.OptionWidget Contains: OO.ui.LabelWidget OO.ui.ButtonWidget OO.ui.IconWidget ...

Slide 49

Slide 49 text

mw.echo.ui.NotificationItemWidget mw.echo.dm.NotificationItem Extends: OO.ui.OptionWidget Contains: OO.ui.LabelWidget OO.ui.ButtonWidget OO.ui.IconWidget ...

Slide 50

Slide 50 text

mw.echo.ui.NotificationItemWidget mw.echo.dm.NotificationItem Extends: OO.ui.OptionWidget Contains: OO.ui.LabelWidget OO.ui.ButtonWidget OO.ui.IconWidget ... DATA / View model UI

Slide 51

Slide 51 text

mw.echo.ui.NotificationItemWidget = function( model, config ) { this.model = model; this.markAsReadButton = new OO.ui.ButtonWidget( { icon: 'close', framed: false, classes: [ 'mw-echo-ui-notificationItemWidget-markAsReadButton' ] } ); // Events this.markAsReadButton.connect( this, { click: 'onMarkAsReadButtonClick' } ); this.model.connect( this, { seen: 'onModelSeen', read: 'onModelRead' } ); /* … */ } mw.echo.ui.NotificationItemWidget.prototype.onMarkAsReadButtonClick = function () { this.model.toggleRead( true ); };

Slide 52

Slide 52 text

Widgets Widgets Everywhere

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

Resources

Slide 55

Slide 55 text

Official documentation: https://www.mediawiki.org/wiki/OOjs_UI Code documentation: ● Javascript: https://doc.wikimedia.org/oojs-ui/master/js/ ● PHP: https://doc.wikimedia.org/oojs-ui/master/php/ Demos: https://doc.wikimedia.org/oojs-ui/master/demos/#widgets-mediawiki-ltr npm package: ● OOjs-UI: https://www.npmjs.com/package/oojs-ui ● OOjs: https://www.npmjs.com/package/oojs Git repository: ● OOjs-UI: http://git.wikimedia.org/tree/oojs%2Fui.git ● OOjs: http://git.wikimedia.org/tree/oojs%2Fcore.git MIT LICENSE

Slide 56

Slide 56 text

Thanks!