Update OOjs UI to v0.1.0-pre (8986c46d35)
authorJames D. Forrester <jforrester@wikimedia.org>
Wed, 2 Apr 2014 02:33:44 +0000 (19:33 -0700)
committerJames D. Forrester <jforrester@wikimedia.org>
Wed, 2 Apr 2014 02:33:44 +0000 (19:33 -0700)
New changes:
735cebc Filter calls to selectItem and highlightItem on SelectWidget
897b30f Return null in Element#getDocument
b5ede88 Add Element#isElementAttached
68df19f Disable tool groups when all its tools are disabled
1aaa507 Grunt-watch less files
e4dd7b2 build: Update devDependencies
64d6c32 Localisation updates from https://translatewiki.net.
b5c6db5 Localisation updates from https://translatewiki.net.
b9460cb apex/button: Reset border-color of disabled button when not hovered
32c4799 Localisation updates from https://translatewiki.net.
674165e Enable jscs for OOjs UI repo
d98b338 grunt: Add messageDocumentation task to ensure each 'en' message has a 'qqq'
d421dd6 demos/tools: Indentation fix

Change-Id: Ic9b7ff01fe066eb5cba6a0fd0fc515ff3c62b66a

14 files changed:
resources/oojs-ui/i18n/bg.json
resources/oojs-ui/i18n/dsb.json
resources/oojs-ui/i18n/el.json
resources/oojs-ui/i18n/es.json
resources/oojs-ui/i18n/et.json
resources/oojs-ui/i18n/hi.json
resources/oojs-ui/i18n/kk-cyrl.json
resources/oojs-ui/i18n/ms.json
resources/oojs-ui/i18n/pl.json
resources/oojs-ui/i18n/qu.json
resources/oojs-ui/i18n/zh-hans.json
resources/oojs-ui/oojs-ui-apex.css
resources/oojs-ui/oojs-ui.js
resources/oojs-ui/oojs-ui.svg.css

index 939719b..6006244 100644 (file)
@@ -8,6 +8,6 @@
         ]
     },
     "ooui-dialog-action-close": "Затваряне",
-    "ooui-outline-control-remove": "Ð\9fÑ\80емаÑ\85ване Ð½Ð° Ð¾Ð±ÐµÐºÑ\82и",
+    "ooui-outline-control-remove": "Ð\9fÑ\80емаÑ\85ване Ð½Ð° Ð¾Ð±ÐµÐºÑ\82а",
     "ooui-toolbar-more": "Още"
-}
\ No newline at end of file
+}
index 0f47587..ef60093 100644 (file)
@@ -7,5 +7,6 @@
     "ooui-dialog-action-close": "Zacyniś",
     "ooui-outline-control-move-down": "Element dołoj pśesunuś",
     "ooui-outline-control-move-up": "Element górjej pśesunuś",
+    "ooui-outline-control-remove": "Zapisk wótpóraś",
     "ooui-toolbar-more": "Wěcej"
-}
\ No newline at end of file
+}
index 66051f1..d1ef8b2 100644 (file)
@@ -12,7 +12,8 @@
         ]
     },
     "ooui-dialog-action-close": "Κλείσιμο",
-    "ooui-outline-control-move-down": "Μετακίνηση προς τα κάτω",
-    "ooui-outline-control-move-up": "Μετακίνηση προς τα πάνω",
+    "ooui-outline-control-move-down": "Μετακίνηση στοιχείου προς τα κάτω",
+    "ooui-outline-control-move-up": "Μετακίνηση στοιχείου προς τα επάνω",
+    "ooui-outline-control-remove": "Αφαίρεση στοιχείου",
     "ooui-toolbar-more": "Περισσότερα"
-}
\ No newline at end of file
+}
index eb53138..a3be749 100644 (file)
@@ -21,4 +21,4 @@
     "ooui-outline-control-move-up": "Mover arriba",
     "ooui-outline-control-remove": "Eliminar elemento",
     "ooui-toolbar-more": "Más"
-}
\ No newline at end of file
+}
index aa780e4..f0ddc39 100644 (file)
@@ -10,4 +10,4 @@
     "ooui-outline-control-move-up": "Liiguta üksust ülespoole",
     "ooui-outline-control-remove": "Eemalda üksus",
     "ooui-toolbar-more": "Veel"
-}
\ No newline at end of file
+}
index 3c41b3e..ae895d1 100644 (file)
@@ -13,4 +13,4 @@
     "ooui-outline-control-move-up": "प्रविष्टि ऊपर ले जाएँ",
     "ooui-outline-control-remove": "आइटम हटाएँ",
     "ooui-toolbar-more": "अधिक"
-}
\ No newline at end of file
+}
index df37fe3..7213dad 100644 (file)
@@ -9,4 +9,4 @@
     "ooui-outline-control-move-up": "Элементті жоғары жылжыту",
     "ooui-outline-control-remove": "Элементті алып тастау",
     "ooui-toolbar-more": "толығырақ"
-}
\ No newline at end of file
+}
index 21aef50..4f78aaa 100644 (file)
@@ -8,5 +8,6 @@
     "ooui-dialog-action-close": "Tutup",
     "ooui-outline-control-move-down": "Alihkan perkara ke bawah",
     "ooui-outline-control-move-up": "Alihkan perkara ke atas",
-    "ooui-toolbar-more": "Lagi"
-}
\ No newline at end of file
+    "ooui-outline-control-remove": "Buang perkara",
+    "ooui-toolbar-more": "Selebihnya"
+}
index 33ff886..2cb7330 100644 (file)
@@ -21,4 +21,4 @@
     "ooui-outline-control-move-up": "Przenieś wyżej",
     "ooui-outline-control-remove": "Usuń element",
     "ooui-toolbar-more": "Więcej"
-}
\ No newline at end of file
+}
index d98b0e4..4442528 100644 (file)
@@ -10,4 +10,4 @@
     "ooui-outline-control-move-up": "Qallawata huqariy",
     "ooui-outline-control-remove": "P'anqa sutikunata qichuy",
     "ooui-toolbar-more": "Aswan"
-}
\ No newline at end of file
+}
index 58e8ebe..e8041ca 100644 (file)
@@ -23,4 +23,4 @@
     "ooui-outline-control-move-up": "上移项",
     "ooui-outline-control-remove": "移除项",
     "ooui-toolbar-more": "更多"
-}
\ No newline at end of file
+}
index 091f4fc..aa5d78f 100644 (file)
 .oo-ui-buttonedElement-framed.oo-ui-widget-disabled .oo-ui-buttonedElement-button.oo-ui-buttonedElement-pressed {
   color: #333;
   background: #eee;
+  border-color: #ccc;
   opacity: 0.5;
   box-shadow: none;
 }
index 937ff33..9a1e324 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.1.0-pre (23fb1b6144)
+ * OOjs UI v0.1.0-pre (8986c46d35)
  * https://www.mediawiki.org/wiki/OOjs_UI
  *
  * Copyright 2011–2014 OOjs Team and other contributors.
  * Released under the MIT license
  * http://oojs.mit-license.org
  *
- * Date: Thu Mar 27 2014 14:49:30 GMT-0700 (PDT)
+ * Date: Tue Apr 01 2014 19:33:39 GMT-0700 (PDT)
  */
 ( function ( OO ) {
 
@@ -237,13 +237,11 @@ OO.ui.Element.getJQuery = function ( context, frame ) {
  *
  * @static
  * @param {jQuery|HTMLElement|HTMLDocument|Window} obj Object to get the document for
- * @return {HTMLDocument} Document object
- * @throws {Error} If context is invalid
+ * @return {HTMLDocument|null} Document object
  */
 OO.ui.Element.getDocument = function ( obj ) {
-       var doc =
-               // jQuery - selections created "offscreen" won't have a context, so .context isn't reliable
-               ( obj[0] && obj[0].ownerDocument ) ||
+       // jQuery - selections created "offscreen" won't have a context, so .context isn't reliable
+       return ( obj[0] && obj[0].ownerDocument ) ||
                // Empty jQuery selections might have a context
                obj.context ||
                // HTMLElement
@@ -251,13 +249,8 @@ OO.ui.Element.getDocument = function ( obj ) {
                // Window
                obj.document ||
                // HTMLDocument
-               ( obj.nodeType === 9 && obj );
-
-       if ( doc ) {
-               return doc;
-       }
-
-       throw new Error( 'Invalid context' );
+               ( obj.nodeType === 9 && obj ) ||
+               null;
 };
 
 /**
@@ -533,6 +526,14 @@ OO.ui.Element.prototype.getTagName = function () {
        return this.constructor.static.tagName;
 };
 
+/**
+ * Check if the element is attached to the DOM
+ * @return {boolean} The element is attached to the DOM
+ */
+OO.ui.Element.prototype.isElementAttached = function () {
+       return $.contains( this.getElementDocument(), this.$element[0] );
+};
+
 /**
  * Get the DOM document.
  *
@@ -1787,7 +1788,7 @@ OO.ui.Widget.prototype.updateDisabled = function () {
 /**
  * Set the disabled state of the widget.
  *
- * This should probably change the widgets's appearance and prevent it from being used.
+ * This should probably change the widgets' appearance and prevent it from being used.
  *
  * @param {boolean} disabled Disable widget
  * @chainable
@@ -3231,9 +3232,8 @@ OO.ui.ToolFactory.prototype.extract = function ( collection, used ) {
                                                        }
                                                }
                                        }
-                               }
                                // Include tools with matching name and exclude already used tools
-                               else if ( item.name && ( !used || !used[item.name] ) ) {
+                               else if ( item.name && ( !used || !used[item.name] ) ) {
                                        names.push( item.name );
                                        if ( used ) {
                                                used[item.name] = true;
@@ -3268,7 +3268,9 @@ OO.ui.ToolFactory.prototype.extract = function ( collection, used ) {
  */
 OO.ui.ToolGroup = function OoUiToolGroup( toolbar, config ) {
        // Configuration initialization
-       config = config || {};
+       config = $.extend( true, {
+               'aggregations': { 'disable': 'itemDisable' }
+       }, config );
 
        // Parent constructor
        OO.ui.ToolGroup.super.call( this, config );
@@ -3280,6 +3282,7 @@ OO.ui.ToolGroup = function OoUiToolGroup( toolbar, config ) {
        this.toolbar = toolbar;
        this.tools = {};
        this.pressed = null;
+       this.autoDisabled = false;
        this.include = config.include || [];
        this.exclude = config.exclude || [];
        this.promote = config.promote || [];
@@ -3294,6 +3297,7 @@ OO.ui.ToolGroup = function OoUiToolGroup( toolbar, config ) {
                'mouseout': OO.ui.bind( this.onMouseOut, this )
        } );
        this.toolbar.getToolFactory().connect( this, { 'register': 'onToolFactoryRegister' } );
+       this.connect( this, { 'itemDisable': 'updateDisabled' } );
 
        // Initialization
        this.$group.addClass( 'oo-ui-toolGroup-tools' );
@@ -3335,8 +3339,43 @@ OO.ui.ToolGroup.static.titleTooltips = false;
  */
 OO.ui.ToolGroup.static.accelTooltips = false;
 
+/**
+ * Automatically disable the toolgroup when all tools are disabled
+ *
+ * @static
+ * @property {boolean}
+ * @inheritable
+ */
+OO.ui.ToolGroup.static.autoDisable = true;
+
 /* Methods */
 
+/**
+ * @inheritdoc
+ */
+OO.ui.ToolGroup.prototype.isDisabled = function () {
+       return this.autoDisabled || OO.ui.ToolGroup.super.prototype.isDisabled.apply( this, arguments );
+};
+
+/**
+ * @inheritdoc
+ */
+OO.ui.ToolGroup.prototype.updateDisabled = function () {
+       var i, item, allDisabled = true;
+
+       if ( this.constructor.static.autoDisable ) {
+               for ( i = this.items.length - 1; i >= 0; i-- ) {
+                       item = this.items[i];
+                       if ( !item.isDisabled() ) {
+                               allDisabled = false;
+                               break;
+                       }
+               }
+               this.autoDisabled = allDisabled;
+       }
+       OO.ui.ToolGroup.super.prototype.updateDisabled.apply( this, arguments );
+};
+
 /**
  * Handle mouse down events.
  *
@@ -3506,6 +3545,8 @@ OO.ui.ToolGroup.prototype.populate = function () {
        }
        // Re-add tools (moving existing ones to new locations)
        this.addItems( add );
+       // Disabled state may depend on items
+       this.updateDisabled();
 };
 
 /**
@@ -4668,6 +4709,18 @@ OO.mixinClass( OO.ui.PopupToolGroup, OO.ui.ClippableElement );
 
 /* Methods */
 
+/**
+ * @inheritdoc
+ */
+OO.ui.PopupToolGroup.prototype.setDisabled = function () {
+       // Parent method
+       OO.ui.PopupToolGroup.super.prototype.setDisabled.apply( this, arguments );
+
+       if ( this.isDisabled() && this.isElementAttached() ) {
+               this.setActive( false );
+       }
+};
+
 /**
  * Handle focus being lost.
  *
@@ -6167,12 +6220,19 @@ OO.ui.SelectWidget.prototype.getItemFromData = function ( data ) {
  * @chainable
  */
 OO.ui.SelectWidget.prototype.highlightItem = function ( item ) {
-       var i, len;
+       var i, len, highlighted,
+               changed = false;
 
        for ( i = 0, len = this.items.length; i < len; i++ ) {
-               this.items[i].setHighlighted( this.items[i] === item );
+               highlighted = this.items[i] === item;
+               if ( this.items[i].isHighlighted() !== highlighted ) {
+                       this.items[i].setHighlighted( highlighted );
+                       changed = true;
+               }
+       }
+       if ( changed ) {
+               this.emit( 'highlight', item );
        }
-       this.emit( 'highlight', item );
 
        return this;
 };
@@ -6186,12 +6246,19 @@ OO.ui.SelectWidget.prototype.highlightItem = function ( item ) {
  * @chainable
  */
 OO.ui.SelectWidget.prototype.selectItem = function ( item ) {
-       var i, len;
+       var i, len, selected,
+               changed = false;
 
        for ( i = 0, len = this.items.length; i < len; i++ ) {
-               this.items[i].setSelected( this.items[i] === item );
+               selected = this.items[i] === item;
+               if ( this.items[i].isSelected() !== selected ) {
+                       this.items[i].setSelected( selected );
+                       changed = true;
+               }
+       }
+       if ( changed ) {
+               this.emit( 'select', item );
        }
-       this.emit( 'select', item );
 
        return this;
 };
@@ -6205,7 +6272,7 @@ OO.ui.SelectWidget.prototype.selectItem = function ( item ) {
  * @param {OO.ui.OptionWidget} [item] Item to select
  * @chainable
  */
-OO.ui.SelectWidget.prototype.intializeSelection = function( item ) {
+OO.ui.SelectWidget.prototype.intializeSelection = function ( item ) {
        var i, len, selected;
 
        for ( i = 0, len = this.items.length; i < len; i++ ) {
@@ -7659,7 +7726,7 @@ OO.ui.TextInputWidget.prototype.onEdit = function () {
  *
  * @chainable
  */
-OO.ui.TextInputWidget.prototype.adjustSize = function() {
+OO.ui.TextInputWidget.prototype.adjustSize = function () {
        var $clone, scrollHeight, innerHeight, outerHeight, maxInnerHeight, idealHeight;
 
        if ( this.multiline && this.autosize ) {
index 887da4d..58bbad0 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.1.0-pre (23fb1b6144)
+ * OOjs UI v0.1.0-pre (8986c46d35)
  * https://www.mediawiki.org/wiki/OOjs_UI
  *
  * Copyright 2011–2014 OOjs Team and other contributors.
  * Released under the MIT license
  * http://oojs.mit-license.org
  *
- * Date: Thu Mar 27 2014 14:49:30 GMT-0700 (PDT)
+ * Date: Tue Apr 01 2014 19:33:39 GMT-0700 (PDT)
  */
 
 /* Textures */