r105257 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105256‎ | r105257 | r105258 >
Date:00:10, 6 December 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Moved the menu of a drop down tool to be inside the drop down tool itself
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/styles/es.ToolbarView.css (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/tools/es.ButtonTool.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/tools/es.DropdownTool.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/tools/es.FormatDropdownTool.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/views/es.ContextView.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/views/es.MenuView.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/tools/es.FormatDropdownTool.js
@@ -58,23 +58,6 @@
5959 'type' : 'pre'
6060 }
6161 ] );
62 -
63 - // Events
64 - var _this = this;
65 - this.$.bind( {
66 - 'mousedown': function( e ) {
67 - if ( e.button === 0 ) {
68 - e.preventDefault();
69 - return false;
70 - }
71 - },
72 - 'mouseup': function( e ) {
73 - if ( e.button === 0 ) {
74 - _this.menuView.setPosition( es.Position.newFromElementPagePosition( _this.$ ) );
75 - _this.menuView.toggle();
76 - }
77 - }
78 - } );
7962 };
8063
8164 /* Methods */
@@ -107,7 +90,7 @@
10891 }
10992
11093 if ( format === null ) {
111 - this.$.html( ' ' );
 94+ this.$label.html( ' ' );
11295 } else {
11396 var items = this.menuView.getItems();
11497 for ( i = 0; i < items.length; i++ ) {
@@ -115,7 +98,7 @@
11699 format.type === items[i].type &&
117100 es.compareObjects( format.attributes, items[i].attributes )
118101 ) {
119 - this.$.text( items[i].label );
 102+ this.$label.text( items[i].label );
120103 break;
121104 }
122105 }
Index: trunk/extensions/VisualEditor/modules/es/tools/es.ButtonTool.js
@@ -20,13 +20,13 @@
2121 var _this = this;
2222 this.$.bind( {
2323 'mousedown': function( e ) {
24 - if ( e.button === 0 ) {
 24+ if ( e.which === 1 ) {
2525 e.preventDefault();
2626 return false;
2727 }
2828 },
2929 'mouseup': function ( e ) {
30 - if ( e.button === 0 ) {
 30+ if ( e.which === 1 ) {
3131 _this.onClick( e );
3232 }
3333 }
Index: trunk/extensions/VisualEditor/modules/es/tools/es.DropdownTool.js
@@ -18,17 +18,33 @@
1919 var _this = this;
2020 this.menuView = new es.MenuView( items, function( item ) {
2121 _this.onSelect( item );
22 - _this.$.text( item.label );
23 - } );
 22+ _this.$label.text( item.label );
 23+ }, this.$ );
 24+ this.$label = $( '<div class="es-toolbarDropdownTool-label"></div>' ).appendTo( this.$ );
2425
2526 // Events
2627 $( document )
2728 .add( this.toolbar.surfaceView.$ )
2829 .mousedown( function( e ) {
29 - if ( e.button === 0 ) {
 30+ if ( e.which === 1 ) {
3031 _this.menuView.hide();
3132 }
3233 } );
 34+ this.$.bind( {
 35+ 'mousedown': function( e ) {
 36+ if ( e.which === 1 ) {
 37+ e.preventDefault();
 38+ return false;
 39+ }
 40+ },
 41+ 'mouseup': function( e ) {
 42+ // Don't respond to menu clicks
 43+ var $item = $( e.target ).closest( '.es-menuView' );
 44+ if ( e.which === 1 && $item.length === 0 ) {
 45+ _this.menuView.toggle();
 46+ }
 47+ }
 48+ } );
3349
3450 // DOM Changes
3551 this.$.addClass( 'es-toolbarDropdownTool' ).addClass( 'es-toolbarDropdownTool-' + name );
Index: trunk/extensions/VisualEditor/modules/es/styles/es.ToolbarView.css
@@ -22,7 +22,6 @@
2323 .es-toolbarButtonTool,
2424 .es-toolbarDropdownTool {
2525 display: inline-block;
26 - padding: 0.25em;
2726 border: solid 1px transparent;
2827 border-radius: 0.125em;
2928 -webkit-border-radius: 0.125em;
@@ -32,6 +31,7 @@
3332 vertical-align: top;
3433 }
3534 .es-toolbarButtonTool {
 35+ padding: 0.25em;
3636 width: 22px;
3737 height: 22px;
3838 margin-right: 0.125em;
@@ -98,11 +98,15 @@
9999 background-image: url(../images/clear.png);
100100 }
101101 .es-toolbarDropdownTool {
 102+ position: relative;
102103 border-color: #dddddd;
103104 -webkit-border-radius: 0.25em;
104105 -moz-border-radius: 0.25em;
105106 -o-border-radius: 0.25em;
106107 background-color: white;
 108+}
 109+.es-toolbarDropdownTool-label {
 110+ padding: 0.25em;
107111 font-size: 0.8em;
108112 line-height: 24px;
109113 padding-left: 0.75em;
@@ -111,6 +115,10 @@
112116 background-position: 9em center;
113117 background-repeat: no-repeat;
114118 }
 119+.es-toolbarDropdownTool .es-menuView {
 120+ left: -1px;
 121+ top: -1px;
 122+}
115123 .es-toolbarDropdownTool-format {
116124 width: 8em;
117125 }
Index: trunk/extensions/VisualEditor/modules/es/views/es.ContextView.js
@@ -58,13 +58,13 @@
5959 // Events
6060 this.$icon.bind( {
6161 'mousedown': function( e ) {
62 - if ( e.button === 0 ) {
 62+ if ( e.which === 1 ) {
6363 e.preventDefault();
6464 return false;
6565 }
6666 },
6767 'mouseup': function( e ) {
68 - if ( e.button === 0 ) {
 68+ if ( e.which === 1 ) {
6969 _this.menuView.toggle();
7070 }
7171 }
Index: trunk/extensions/VisualEditor/modules/es/views/es.MenuView.js
@@ -13,7 +13,7 @@
1414 this.items = [];
1515 this.autoNamedBreaks = 0;
1616 this.callback = callback;
17 -
 17+
1818 // Items
1919 if ( es.isArray( items ) ) {
2020 for ( var i = 0; i < items.length; i++ ) {
@@ -25,13 +25,13 @@
2626 var _this = this;
2727 this.$.bind( {
2828 'mousedown': function( e ) {
29 - if ( e.button === 0 ) {
 29+ if ( e.which === 1 ) {
3030 e.preventDefault();
3131 return false;
3232 }
3333 },
3434 'mouseup': function( e ) {
35 - if ( e.button === 0 ) {
 35+ if ( e.which === 1 ) {
3636 var $item = $( e.target ).closest( '.es-menuView-item' );
3737 if ( $item.length ) {
3838 var name = $item.attr( 'rel' );

Status & tagging log