Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to OOjs-UI

Introduction to OOjs-UI

This presentation was given in WikimediaAtWork event at Feb 24th in the Wikimedia offices.

Moriel Schottlender

February 24, 2016
Tweet

More Decks by Moriel Schottlender

Other Decks in Programming

Transcript

  1. • VisualEditor project started in 2011 • Repository split in

    late 2013: • VisualEditor standalone ('core') • VisualEditor MediaWiki • OOjs-UI
  2. Super extensibility • Extensions (plugins) • User scripts (Common.js /

    Common.css) • Gadgets • Projects in ~280 languages – 895 wikis
  3. 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)
  4. 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
  5. 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
  6. 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
  7. 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
  8. Data is stored in the DOM <div class="dropdown"> <a id="dLabel"

    data-target="#" href="http://example.com" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> Dropdown trigger <span class="caret"></span> </a> <ul class="dropdown-menu" aria-labelledby="dLabel"> ... </ul> </div> (Bootstrap)
  9. DOM events are messy :( Input field| keydown change input

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

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

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

    cut paste Arrows? Enter? Requires focus change OO.ui.TextInputWidget
  13. 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
  14. 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
  15. 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
  16. Event emitter support Object Oriented Component (building bigger widgets from

    smaller) Library of mixins everyone can use Abstracting the DOM
  17. 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
  18. 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
  19. 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
  20. 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
  21. OOjs OOjs-UI OOUI-PHP Object-Oriented (Inheritance, Mixins) Event Emitter Utilities Widgets

    DOM behavior abstraction Theming Widgets DOM structure for no-JS Theming
  22. 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
  23. 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 ); };
  24. 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