r104907 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104906‎ | r104907 | r104908 >
Date:22:43, 1 December 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Added example dialog (still hacking here)
Added link tool to toolbar
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/styles/es.ContextView.css (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/styles/es.ToolbarView.css (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/tools/es.AnnotationButtonTool.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/views/es.ContentView.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/views/es.ContextView.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/views/es.ToolbarView.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/tools/es.AnnotationButtonTool.js
@@ -43,5 +43,11 @@
4444 data: { 'type': 'textStyle/italic' }
4545 };
4646
 47+es.Tool.tools.link = {
 48+ constructor: es.AnnotationButtonTool,
 49+ name: 'link',
 50+ data: { 'type': 'link/internal', 'data': { 'title': '' } }
 51+};
4752
 53+
4854 es.extendClass( es.AnnotationButtonTool, es.ButtonTool );
\ No newline at end of file
Index: trunk/extensions/VisualEditor/modules/es/styles/es.ToolbarView.css
@@ -67,6 +67,9 @@
6868 .es-toolbarButtonTool-italic:before {
6969 background-image: url(../images/italic.png);
7070 }
 71+.es-toolbarButtonTool-link:before {
 72+ background-image: url(../images/link.png);
 73+}
7174 .es-toolbarButtonTool-clear:before {
7275 background-image: url(../images/clear.png);
7376 }
@@ -74,6 +77,8 @@
7578 -moz-opacity: 0.25;
7679 filter:alpha(opacity=25);
7780 opacity: 0.25;
 81+.es-toolbarButtonTool-clear:before {
 82+ background-image: url(../images/clear.png);
7883 }
7984 .es-toolbarDropdownTool {
8085 }
Index: trunk/extensions/VisualEditor/modules/es/styles/es.ContextView.css
@@ -45,8 +45,7 @@
4646 border-color: #b3d6f6;
4747 }
4848
49 -.es-contextView-menu {
50 - display: none;
 49+.es-contextView-container {
5150 position: absolute;
5251 border: solid 1px #cccccc;
5352 -webkit-border-radius: 0.25em;
@@ -60,19 +59,23 @@
6160 padding: 0.33em 0;
6261 }
6362
64 -.es-contextView-position-above .es-contextView-menu {
 63+.es-contextView-container {
 64+ display: none;
 65+}
 66+
 67+.es-contextView-position-above .es-contextView-container {
6568 bottom: -4px;
6669 }
6770
68 -.es-contextView-position-below .es-contextView-menu {
 71+.es-contextView-position-below .es-contextView-container {
6972 top: 3px;
7073 }
7174
72 -.es-contextView-position-left .es-contextView-menu {
 75+.es-contextView-position-left .es-contextView-container {
7376 left: -1px;
7477 }
7578
76 -.es-contextView-position-right .es-contextView-menu {
 79+.es-contextView-position-right .es-contextView-container {
7780 right: -1px;
7881 }
7982
@@ -95,3 +98,11 @@
9699 .es-contextView-menuItem:hover {
97100 background-color: #b3d6f6;
98101 }
 102+
 103+.es-contextView-panels {
 104+}
 105+
 106+.es-contextView-panel {
 107+ display: none;
 108+ padding: 1em;
 109+}
Index: trunk/extensions/VisualEditor/modules/es/views/es.ContextView.js
@@ -9,9 +9,13 @@
1010 this.surfaceView = surfaceView;
1111 this.$ = $( '<div class="es-contextView"></div>' ).appendTo( $overlay || $( 'body' ) );
1212 this.$toolbar = $( '<div class="es-contextView-menuSection"></div>' );
 13+ this.$container = $( '<div class="es-contextView-container"></div>' )
 14+ .appendTo( this.$ );
1315 this.$menu = $( '<div class="es-contextView-menu"></div>' )
1416 .append( this.$toolbar )
15 - .appendTo( this.$ );
 17+ .appendTo( this.$container );
 18+ this.$panels = $( '<div class="es-contextView-panels"></div>' )
 19+ .appendTo( this.$container );
1620 this.$icon = $( '<div class="es-contextView-icon"></div>' )
1721 .appendTo( this.$ );
1822 this.toolbarView = new es.ToolbarView(
@@ -23,16 +27,38 @@
2428 // Example menu items
2529 this.$menu.append(
2630 '<div class="es-contextView-menuItem-break"></div>' +
 31+ '<div class="es-contextView-menuItem" rel="link">Link to...</div>' +
 32+ '<div class="es-contextView-menuItem-break"></div>' +
2733 '<div class="es-contextView-menuItem">Copy</div>' +
2834 '<div class="es-contextView-menuItem">Cut</div>' +
2935 '<div class="es-contextView-menuItem">Paste</div>'
3036 );
3137
 38+ this.$panels.append(
 39+ '<div class="es-contextView-panel" rel="link">' +
 40+ '<div><label>Page title or URL <input type="text"></label></div>' +
 41+ '<div><a href="#cancel">Cancel</a> <button>Change</button></div>' +
 42+ '</div>'
 43+ );
 44+
3245 // Events
3346 var _this = this;
3447 this.$icon.click( function() {
35 - _this.$menu.toggle();
 48+ _this.$container.toggle();
3649 } );
 50+
 51+ this.$menu.find( '[rel="link"]' ).click( function() {
 52+ _this.$menu.hide();
 53+ _this.$panels.find( '[rel="link"]' ).show();
 54+ _this.$panels.find( '[rel="link"] input:first' ).focus();
 55+ } );
 56+ this.$panels.find( 'button, [href="#cancel"]' ).click( function() {
 57+ _this.$menu.show();
 58+ _this.$panels.children().hide();
 59+ _this.$container.toggle();
 60+ _this.surfaceView.$input.focus();
 61+ return false;
 62+ } );
3763 };
3864
3965 /* Methods */
@@ -44,6 +70,7 @@
4571 };
4672
4773 es.ContextView.prototype.set = function() {
 74+
4875 this.$.removeClass(
4976 'es-contextView-position-below es-contextView-position-above ' +
5077 'es-contextView-position-left es-contextView-position-right ' +
@@ -70,12 +97,12 @@
7198 }
7299 }
73100 if ( position ) {
74 - if ( position.left + this.$menu.width() < $( 'body' ).width() ) {
 101+ if ( position.left + this.$container.width() < $( 'body' ).width() ) {
75102 this.$.addClass( 'es-contextView-position-left' );
76103 } else {
77104 this.$.addClass( 'es-contextView-position-right' );
78105 }
79 - if ( position.top + this.$menu.height() < $( window ).height() + $( window ).scrollTop() ) {
 106+ if ( position.top + this.$container.height() < $( window ).height() + $( window ).scrollTop() ) {
80107 this.$.addClass( 'es-contextView-position-below' );
81108 } else {
82109 this.$.addClass( 'es-contextView-position-above' );
@@ -87,5 +114,5 @@
88115
89116 es.ContextView.prototype.clear = function() {
90117 this.$icon.hide();
91 - this.$menu.hide();
 118+ this.$container.hide();
92119 };
Index: trunk/extensions/VisualEditor/modules/es/views/es.ContentView.js
@@ -229,23 +229,29 @@
230230
231231 if ( fromLineIndex === toLineIndex ) {
232232 // Single line selection
233 - this.$rangeStart.css( {
234 - 'top': fromPosition.top,
235 - 'left': fromPosition.left,
236 - 'width': toPosition.left - fromPosition.left,
237 - 'height': fromPosition.bottom - fromPosition.top
238 - } ).show();
 233+ if ( toPosition.left - fromPosition.left ) {
 234+ this.$rangeStart.css( {
 235+ 'top': fromPosition.top,
 236+ 'left': fromPosition.left,
 237+ 'width': toPosition.left - fromPosition.left,
 238+ 'height': fromPosition.bottom - fromPosition.top
 239+ } ).show();
 240+ }
239241 this.$rangeFill.hide();
240242 this.$rangeEnd.hide();
241243 } else {
242244 // Multiple line selection
243245 var contentWidth = this.$.width();
244 - this.$rangeStart.css( {
245 - 'top': fromPosition.top,
246 - 'left': fromPosition.left,
247 - 'width': contentWidth - fromPosition.left,
248 - 'height': fromPosition.bottom - fromPosition.top
249 - } ).show();
 246+ if ( contentWidth - fromPosition.left ) {
 247+ this.$rangeStart.css( {
 248+ 'top': fromPosition.top,
 249+ 'left': fromPosition.left,
 250+ 'width': contentWidth - fromPosition.left,
 251+ 'height': fromPosition.bottom - fromPosition.top
 252+ } ).show();
 253+ } else {
 254+ this.$rangeStart.hide();
 255+ }
250256 if ( toPosition.left ) {
251257 this.$rangeEnd.css( {
252258 'top': toPosition.top,
Index: trunk/extensions/VisualEditor/modules/es/views/es.ToolbarView.js
@@ -48,7 +48,7 @@
4949 } );
5050
5151 this.config = config || [
52 - { 'name': 'textStyle', 'items' : [ 'bold', 'italic', 'formatting', 'clear' ] },
 52+ { 'name': 'textStyle', 'items' : [ 'bold', 'italic', 'link', 'clear' ] },
5353 { 'name': 'history', 'items' : [ 'undo', 'redo' ] }
5454 ];
5555 this.setup();

Status & tagging log