Update OOjs UI to v0.1.0-pre (7a0e222a75)
authorJames D. Forrester <jforrester@wikimedia.org>
Wed, 18 Jun 2014 23:19:20 +0000 (16:19 -0700)
committerJames D. Forrester <jforrester@wikimedia.org>
Wed, 18 Jun 2014 23:19:20 +0000 (16:19 -0700)
New changes:
ef2f66f Element: Add unit tests for focusin/focusout hack
54b09fd Element: Remove focusin/focusout hack in onDOMEvent
91ba7d3 Accessibility: Set role=dialog on dialogs
0447150 Accessibility: Restore element focus when a window closes
715f1ef Localisation updates from https://translatewiki.net.
9f343c0 Localisation updates from https://translatewiki.net.
6be64bc Tidy up SVG sources and fix pixel snapping
7a0e222 Fix scrollIntoView() in the case where the scrollable container is the <body>

Change-Id: I9d86a238546acc867f20aeb45b102c7499108c89

14 files changed:
resources/lib/oojs-ui/i18n/ce.json
resources/lib/oojs-ui/i18n/kn.json
resources/lib/oojs-ui/images/indicators/alert.svg
resources/lib/oojs-ui/images/indicators/arrow-down.png
resources/lib/oojs-ui/images/indicators/arrow-down.svg
resources/lib/oojs-ui/images/indicators/arrow-ltr.png
resources/lib/oojs-ui/images/indicators/arrow-ltr.svg
resources/lib/oojs-ui/images/indicators/arrow-rtl.png
resources/lib/oojs-ui/images/indicators/arrow-rtl.svg
resources/lib/oojs-ui/images/indicators/arrow-up.png
resources/lib/oojs-ui/images/indicators/arrow-up.svg
resources/lib/oojs-ui/images/indicators/required.svg
resources/lib/oojs-ui/oojs-ui.js
resources/lib/oojs-ui/oojs-ui.svg.css

index 122be19..de86daf 100644 (file)
@@ -9,7 +9,7 @@
        "ooui-outline-control-move-down": "Лаха яккха элемент",
        "ooui-outline-control-move-up": "Лаккха яккха элемент",
        "ooui-outline-control-remove": "ДӀадаха меттиг",
-       "ooui-toolbar-more": "Кхин тӀе",
+       "ooui-toolbar-more": "Кхин",
        "ooui-dialog-confirm-title": "Бакъдан",
        "ooui-dialog-confirm-default-prompt": "Бакъалла лаьий хӀуна?",
        "ooui-dialog-confirm-default-ok": "ХӀаъ",
index 76b654b..85931f5 100644 (file)
@@ -6,6 +6,8 @@
                ]
        },
        "ooui-dialog-action-close": "ಮುಚ್ಚಿ",
+       "ooui-outline-control-move-down": "ವಸ್ತು ಕೆಲ್ಗೆ ಸ್ಥಲಾನ್ಥರಿಸು",
+       "ooui-outline-control-move-up": "ವಸ್ತು ಮೆಲೆ ಸ್ಥಲಾನ್ಥರಿಸು",
        "ooui-outline-control-remove": "ವಸ್ತು ತೆಗೆ",
        "ooui-toolbar-more": "ಹೆಚ್ಚು",
        "ooui-dialog-confirm-title": "ಧೃಡಪಡಿಸು",
index 8ce4b25..e549b17 100644 (file)
@@ -1,8 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="12" height="12" viewBox="0, 0, 12, 12">
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="12px"
+        height="12px" viewBox="0 0 12 12">
   <g id="deprecated" opacity="0.75">
-    <path d="M6,12 C2.686,12 -0,9.314 -0,6 C-0,2.686 2.686,-0 6,-0 C9.314,-0 12,2.686 12,6 C12,9.314 9.314,12 6,12 z M5,7 L7,7 L7,2 L5,2 z M5,10 L7,10 L7,8 L5,8 z" fill="#000000"/>
+    <path d="M6,12 C2.686,12 -0,9.314 -0,6 C-0,2.686 2.686,-0 6,-0 C9.314,-0 12,2.686 12,6 C12,9.314 9.314,12 6,12 z M5,7 L7,7 L7,2 L5,2 z M5,10 L7,10 L7,8 L5,8 z"/>
   </g>
   <defs/>
 </svg>
index 47ff54c..64e3bac 100644 (file)
Binary files a/resources/lib/oojs-ui/images/indicators/arrow-down.png and b/resources/lib/oojs-ui/images/indicators/arrow-down.png differ
index c871f60..89c21e3 100644 (file)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
 <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="12px"
-        height="12px" viewBox="0 0 12 12" style="enable-background:new 0 0 12 12;" xml:space="preserve">
+        height="12px" viewBox="0 0 12 12">
 <g id="down" style="opacity:0.75;">
-       <polygon id="arrow" style="fill-rule:evenodd;clip-rule:evenodd;" points="2.023,3 5.512,8.953 9,3"/>
+       <polygon id="arrow" points="2,3 5.5,9 9,3"/>
 </g>
 </svg>
index 7984007..4eafd0f 100644 (file)
Binary files a/resources/lib/oojs-ui/images/indicators/arrow-ltr.png and b/resources/lib/oojs-ui/images/indicators/arrow-ltr.png differ
index cbc22a4..ad87640 100644 (file)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
 <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="12px"
-        height="12px" viewBox="0 0 12 12" style="enable-background:new 0 0 12 12;" xml:space="preserve">
+        height="12px" viewBox="0 0 12 12">
 <g id="ltr" opacity="0.75">
-       <path d="M3.023,8.977 L3.023,2 L8.976,5.489 z" fill="#000000" id="arrow"/>
+       <path id="arrow" d="M3,9 L3,2 L9,5.5 z"/>
 </g>
 </svg>
index eebd509..ce13ba0 100644 (file)
Binary files a/resources/lib/oojs-ui/images/indicators/arrow-rtl.png and b/resources/lib/oojs-ui/images/indicators/arrow-rtl.png differ
index 71f73d5..010b24e 100644 (file)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
 <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="12px"
-        height="12px" viewBox="0 0 12 12" style="enable-background:new 0 0 12 12;" xml:space="preserve">
+        height="12px" viewBox="0 0 12 12">
 <g id="rtl" opacity="0.75">
-       <path d="M3.023,5.489 L8.976,8.977 L8.976,2 z" fill="#000000" id="arrow"/>
+       <path id="arrow" d="M3,5.5 L9,9 L9,2 z"/>
 </g>
 </svg>
index b827f6d..401cde6 100644 (file)
Binary files a/resources/lib/oojs-ui/images/indicators/arrow-up.png and b/resources/lib/oojs-ui/images/indicators/arrow-up.png differ
index a5d7f38..bbc2b3c 100644 (file)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
 <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="12px"
-        height="12px" viewBox="0 0 12 12" style="enable-background:new 0 0 12 12;" xml:space="preserve">
+        height="12px" viewBox="0 0 12 12">
 <g id="up" style="opacity:0.75;">
-       <polygon id="arrow" style="fill-rule:evenodd;clip-rule:evenodd;" points="5.512,2.006 2,8 9.024,8                "/>
+       <polygon id="arrow" points="5.5,2 2,8 9,8"/>
 </g>
 </svg>
index ee1baf7..d8b36b1 100644 (file)
@@ -1,10 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="12" height="12" viewBox="0, 0, 12, 12">
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="12px"
+        height="12px" viewBox="0 0 12 12">
   <g id="required" opacity="0.75">
-    <path d="M5,1 L7,1 L7,11 L5,11 z" fill="#000000"/>
-    <path d="M9.83,2.634 L10.83,4.366 L2.17,9.366 L1.17,7.634 z" fill="#000000"/>
-    <path d="M1.17,4.366 L2.17,2.634 L10.83,7.634 L9.83,9.366 z" fill="#000000"/>
+    <path d="M5,1 L7,1 L7,11 L5,11 z"/>
+    <path d="M9.83,2.634 L10.83,4.366 L2.17,9.366 L1.17,7.634 z"/>
+    <path d="M1.17,4.366 L2.17,2.634 L10.83,7.634 L9.83,9.366 z"/>
   </g>
   <defs/>
 </svg>
index 0655397..7e3aadf 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.1.0-pre (c5ae888f67)
+ * OOjs UI v0.1.0-pre (7a0e222a75)
  * 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: Wed Jun 11 2014 18:10:09 GMT-0700 (PDT)
+ * Date: Wed Jun 18 2014 16:19:15 GMT-0700 (PDT)
  */
 ( function ( OO ) {
 
@@ -486,18 +486,32 @@ OO.ui.Element.scrollIntoView = function ( el, config ) {
        // Configuration initialization
        config = config || {};
 
-       var anim = {},
+       var rel, anim = {},
                callback = typeof config.complete === 'function' && config.complete,
                sc = this.getClosestScrollableContainer( el, config.direction ),
                $sc = $( sc ),
                eld = this.getDimensions( el ),
                scd = this.getDimensions( sc ),
+               $win = $( this.getWindow( el ) );
+
+       // Compute the distances between the edges of el and the edges of the scroll viewport
+       if ( $sc.is( 'body' ) ) {
+               // If the scrollable container is the <body> this is easy
+               rel = {
+                       'top': eld.rect.top,
+                       'bottom': $win.innerHeight() - eld.rect.bottom,
+                       'left': eld.rect.left,
+                       'right': $win.innerWidth() - eld.rect.right
+               };
+       } else {
+               // Otherwise, we have to subtract el's coordinates from sc's coordinates
                rel = {
                        'top': eld.rect.top - ( scd.rect.top + scd.borders.top ),
                        'bottom': scd.rect.bottom - scd.borders.bottom - scd.scrollbar.bottom - eld.rect.bottom,
                        'left': eld.rect.left - ( scd.rect.left + scd.borders.left ),
                        'right': scd.rect.right - scd.borders.right - scd.scrollbar.right - eld.rect.right
                };
+       }
 
        if ( !config.direction || config.direction === 'y' ) {
                if ( rel.top < 0 ) {
@@ -606,6 +620,7 @@ OO.ui.Element.prototype.scrollElementIntoView = function ( config ) {
 /**
  * Bind a handler for an event on this.$element
  *
+ * @deprecated Use jQuery#on instead.
  * @param {string} event
  * @param {Function} callback
  */
@@ -616,6 +631,7 @@ OO.ui.Element.prototype.onDOMEvent = function ( event, callback ) {
 /**
  * Unbind a handler bound with #offDOMEvent
  *
+ * @deprecated Use jQuery#off instead.
  * @param {string} event
  * @param {Function} callback
  */
@@ -624,105 +640,33 @@ OO.ui.Element.prototype.offDOMEvent = function ( event, callback ) {
 };
 
 ( function () {
-       // Static
-
-       // jQuery 1.8.3 has a bug with handling focusin/focusout events inside iframes.
-       // Firefox doesn't support focusin/focusout at all, so we listen for 'focus'/'blur' on the
-       // document, and simulate a 'focusin'/'focusout' event on the target element and make
-       // it bubble from there.
-       //
-       // - http://jsfiddle.net/sw3hr/
-       // - http://bugs.jquery.com/ticket/14180
-       // - https://github.com/jquery/jquery/commit/1cecf64e5aa4153
-       function specialEvent( simulatedName, realName ) {
-               function handler( e ) {
-                       jQuery.event.simulate(
-                               simulatedName,
-                               e.target,
-                               jQuery.event.fix( e ),
-                               /* bubble = */ true
-                       );
-               }
-
-               return {
-                       setup: function () {
-                               var doc = this.ownerDocument || this,
-                                       attaches = $.data( doc, 'ooui-' + simulatedName + '-attaches' );
-                               if ( !attaches ) {
-                                       doc.addEventListener( realName, handler, true );
-                               }
-                               $.data( doc, 'ooui-' + simulatedName + '-attaches', ( attaches || 0 ) + 1 );
-                       },
-                       teardown: function () {
-                               var doc = this.ownerDocument || this,
-                                       attaches = $.data( doc, 'ooui-' + simulatedName + '-attaches' ) - 1;
-                               if ( !attaches ) {
-                                       doc.removeEventListener( realName, handler, true );
-                                       $.removeData( doc, 'ooui-' + simulatedName + '-attaches' );
-                               } else {
-                                       $.data( doc, 'ooui-' + simulatedName + '-attaches', attaches );
-                               }
-                       }
-               };
-       }
-
-       var hasOwn = Object.prototype.hasOwnProperty,
-               specialEvents = {
-                       focusin: specialEvent( 'focusin', 'focus' ),
-                       focusout: specialEvent( 'focusout', 'blur' )
-               };
-
        /**
         * Bind a handler for an event on a DOM element.
         *
-        * Uses jQuery internally for everything except for events which are
-        * known to have issues in the browser or in jQuery. This method
-        * should become obsolete eventually.
+        * Used to be for working around a jQuery bug (jqbug.com/14180),
+        * but obsolete as of jQuery 1.11.0.
         *
         * @static
+        * @deprecated Use jQuery#on instead.
         * @param {HTMLElement|jQuery} el DOM element
         * @param {string} event Event to bind
         * @param {Function} callback Callback to call when the event fires
         */
        OO.ui.Element.onDOMEvent = function ( el, event, callback ) {
-               var orig;
-
-               if ( hasOwn.call( specialEvents, event ) ) {
-                       // Replace jQuery's override with our own
-                       orig = $.event.special[event];
-                       $.event.special[event] = specialEvents[event];
-
-                       $( el ).on( event, callback );
-
-                       // Restore
-                       $.event.special[event] = orig;
-               } else {
-                       $( el ).on( event, callback );
-               }
+               $( el ).on( event, callback );
        };
 
        /**
         * Unbind a handler bound with #static-method-onDOMEvent.
         *
+        * @deprecated Use jQuery#off instead.
         * @static
         * @param {HTMLElement|jQuery} el DOM element
         * @param {string} event Event to unbind
         * @param {Function} [callback] Callback to unbind
         */
        OO.ui.Element.offDOMEvent = function ( el, event, callback ) {
-               var orig;
-               if ( hasOwn.call( specialEvents, event ) ) {
-                       // Replace jQuery's override with our own
-                       orig = $.event.special[event];
-                       $.event.special[event] = specialEvents[event];
-
-                       $( el ).off( event, callback );
-
-                       // Restore
-                       $.event.special[event] = orig;
-               } else {
-                       $( el ).off( event, callback );
-               }
+               $( el ).off( event, callback );
        };
 }() );
 /**
@@ -1341,6 +1285,10 @@ OO.ui.Window.prototype.open = function ( data ) {
 
        // Open the window
        this.opening = $.Deferred();
+
+       // So we can restore focus on closing
+       this.$prevFocus = $( document.activeElement );
+
        this.frame.load().done( OO.ui.bind( function () {
                this.$element.show();
                this.visible = true;
@@ -1404,6 +1352,11 @@ OO.ui.Window.prototype.close = function ( data ) {
                        this.opened.resolve();
                }
                this.$element.hide();
+               // Restore focus to whatever was focused before opening
+               if ( this.$prevFocus ) {
+                       this.$prevFocus.focus();
+                       this.$prevFocus = undefined;
+               }
                this.visible = false;
                this.closing.resolve();
                // Now that we are totally done closing, it's safe to allow opening
@@ -1608,7 +1561,7 @@ OO.ui.Dialog = function OoUiDialog( config ) {
        this.$element.on( 'mousedown', false );
 
        // Initialization
-       this.$element.addClass( 'oo-ui-dialog' );
+       this.$element.addClass( 'oo-ui-dialog' ).attr( 'role', 'dialog' );
        this.setSize( config.size );
 };
 
index aa4d42e..76feb5d 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * OOjs UI v0.1.0-pre (c5ae888f67)
+ * OOjs UI v0.1.0-pre (7a0e222a75)
  * 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: Wed Jun 11 2014 18:10:09 GMT-0700 (PDT)
+ * Date: Wed Jun 18 2014 16:19:15 GMT-0700 (PDT)
  */
 
 /* Textures */