Index: trunk/extensions/VisualEditor/SpecialVisualEditorSandbox.php |
— | — | @@ -33,17 +33,19 @@ |
34 | 34 | <ul id="es-docs-list" ></ul> |
35 | 35 | </div> |
36 | 36 | <div id="es-base"> |
37 | | - <div id="es-toolbar" class="es-toolbar"> |
38 | | - <div id="es-modes" class="es-modes"> |
39 | | - <div id="es-mode-wikitext" class="es-modes-button" title="$modeWikitext"></div> |
40 | | - <div id="es-mode-json" class="es-modes-button" title="$modeJson"></div> |
41 | | - <div id="es-mode-html" class="es-modes-button" title="$modeHtml"></div> |
42 | | - <div id="es-mode-render" class="es-modes-button" title="$modeRender"></div> |
43 | | - <div id="es-mode-history" class="es-modes-button" title="$modeHistory"></div> |
44 | | - <div id="es-mode-help" class="es-modes-button" title="$modeHelp"></div> |
| 37 | + <div id="es-toolbar-wrapper"> |
| 38 | + <div id="es-toolbar" class="es-toolbar"> |
| 39 | + <div id="es-modes" class="es-modes"> |
| 40 | + <div id="es-mode-wikitext" class="es-modes-button" title="$modeWikitext"></div> |
| 41 | + <div id="es-mode-json" class="es-modes-button" title="$modeJson"></div> |
| 42 | + <div id="es-mode-html" class="es-modes-button" title="$modeHtml"></div> |
| 43 | + <div id="es-mode-render" class="es-modes-button" title="$modeRender"></div> |
| 44 | + <div id="es-mode-history" class="es-modes-button" title="$modeHistory"></div> |
| 45 | + <div id="es-mode-help" class="es-modes-button" title="$modeHelp"></div> |
| 46 | + </div> |
| 47 | + <div style="clear:both"></div> |
| 48 | + <div id="es-toolbar-shadow"></div> |
45 | 49 | </div> |
46 | | - <div style="clear:both"></div> |
47 | | - <div id="es-toolbar-shadow"></div> |
48 | 50 | </div> |
49 | 51 | <div id="es-panes"> |
50 | 52 | <div id="es-visual"> |
Index: trunk/extensions/VisualEditor/demo/index.html |
— | — | @@ -70,17 +70,19 @@ |
71 | 71 | <ul id="es-docs-list" ></ul> |
72 | 72 | </div> |
73 | 73 | <div id="es-base"> |
74 | | - <div id="es-toolbar" class="es-toolbar"> |
75 | | - <div id="es-modes" class="es-modes"> |
76 | | - <div id="es-mode-wikitext" class="es-modes-button" title="Toggle wikitext view"></div> |
77 | | - <div id="es-mode-json" class="es-modes-button" title="Toggle JSON view"></div> |
78 | | - <div id="es-mode-html" class="es-modes-button" title="Toggle HTML view"></div> |
79 | | - <div id="es-mode-render" class="es-modes-button" title="Toggle preview"></div> |
80 | | - <div id="es-mode-history" class="es-modes-button" title="Toggle transaction history view"></div> |
81 | | - <div id="es-mode-help" class="es-modes-button" title="Toggle help view"></div> |
| 74 | + <div id="es-toolbar-wrapper"> |
| 75 | + <div id="es-toolbar" class="es-toolbar"> |
| 76 | + <div id="es-modes" class="es-modes"> |
| 77 | + <div id="es-mode-wikitext" class="es-modes-button" title="Toggle wikitext view"></div> |
| 78 | + <div id="es-mode-json" class="es-modes-button" title="Toggle JSON view"></div> |
| 79 | + <div id="es-mode-html" class="es-modes-button" title="Toggle HTML view"></div> |
| 80 | + <div id="es-mode-render" class="es-modes-button" title="Toggle preview"></div> |
| 81 | + <div id="es-mode-history" class="es-modes-button" title="Toggle transaction history view"></div> |
| 82 | + <div id="es-mode-help" class="es-modes-button" title="Toggle help view"></div> |
| 83 | + </div> |
| 84 | + <div style="clear:both"></div> |
| 85 | + <div id="es-toolbar-shadow"></div> |
82 | 86 | </div> |
83 | | - <div style="clear:both"></div> |
84 | | - <div id="es-toolbar-shadow"></div> |
85 | 87 | </div> |
86 | 88 | <div id="es-panes"> |
87 | 89 | <div id="es-visual"> |
Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js |
— | — | @@ -63,7 +63,6 @@ |
64 | 64 | height: $window.height(), |
65 | 65 | scrollTop: $window.scrollTop(), |
66 | 66 | // XXX: This is a dirty hack! |
67 | | - toolbarTop: $( '#es-toolbar' ).offset().top, |
68 | 67 | toolbarHeight: $( '#es-toolbar' ).height() |
69 | 68 | }; |
70 | 69 | |
— | — | @@ -139,6 +138,8 @@ |
140 | 139 | // resizing - can be implemented with setTimeout |
141 | 140 | _this.hideCursor(); |
142 | 141 | _this.dimensions.height = $window.height(); |
| 142 | + // XXX: This is a dirty hack! |
| 143 | + _this.dimensions.toolbarHeight = $( '#es-toolbar' ).height(); |
143 | 144 | var width = _this.$.width(); |
144 | 145 | if ( _this.dimensions.width !== width ) { |
145 | 146 | _this.dimensions.width = width; |
Index: trunk/extensions/VisualEditor/modules/es/views/es.ToolbarView.js |
— | — | @@ -14,35 +14,8 @@ |
15 | 15 | this.surfaceView = surfaceView; |
16 | 16 | this.$ = $container; |
17 | 17 | this.$groups = $( '<div class="es-toolbarGroups"></div>' ).prependTo( this.$ ); |
18 | | - this.$spacer = $('<div></div>'); |
19 | | - this.$.after( this.$spacer ); |
20 | 18 | this.tools = []; |
21 | 19 | |
22 | | - // Events |
23 | | - /* |
24 | | - * This code is responsible for switching toolbar into floating mode when scrolling (with |
25 | | - * keyboard or mouse). |
26 | | - */ |
27 | | - $window.scroll( function() { |
28 | | - if ( _this.surfaceView.dimensions.scrollTop > _this.surfaceView.dimensions.toolbarTop ) { |
29 | | - if ( !_this.$.hasClass( 'float' ) ) { |
30 | | - var left = _this.$.offset().left, |
31 | | - right = $window.width() - _this.$.outerWidth() - left; |
32 | | - _this.$.css( 'right', right ); |
33 | | - _this.$.css( 'left', left ); |
34 | | - _this.$spacer.height( _this.$.height() ); |
35 | | - _this.$.addClass( 'float' ); |
36 | | - } |
37 | | - } else { |
38 | | - if ( _this.$.hasClass( 'float' ) ) { |
39 | | - _this.$.css( 'right', 0 ); |
40 | | - _this.$.css( 'left', 0 ); |
41 | | - _this.$spacer.height(0); |
42 | | - _this.$.removeClass( 'float' ); |
43 | | - } |
44 | | - } |
45 | | - } ); |
46 | | - |
47 | 20 | this.surfaceView.on( 'cursor', function( annotations, nodes ) { |
48 | 21 | for( var i = 0; i < _this.tools.length; i++ ) { |
49 | 22 | _this.tools[i].updateState( annotations, nodes ); |
Index: trunk/extensions/VisualEditor/modules/sandbox/sandbox.css |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | -o-user-select; |
16 | 16 | user-select: none; |
17 | 17 | } |
18 | | -#es-toolbar.float { |
| 18 | +#es-toolbar-wrapper.float #es-toolbar { |
19 | 19 | top: 0; |
20 | 20 | position: fixed; |
21 | 21 | -webkit-border-radius: 0; |
Index: trunk/extensions/VisualEditor/modules/sandbox/sandbox.js |
— | — | @@ -566,10 +566,33 @@ |
567 | 567 | window.contextView = new es.ContextView( window.surfaceView ); |
568 | 568 | window.surfaceModel.select( new es.Range( 1, 1 ) ); |
569 | 569 | |
| 570 | + /* |
| 571 | + * This code is responsible for switching toolbar into floating mode when scrolling (with |
| 572 | + * keyboard or mouse). |
| 573 | + */ |
| 574 | + var $toolbarWrapper = $( '#es-toolbar-wrapper' ), |
| 575 | + $toolbar = $( '#es-toolbar' ), |
| 576 | + $window = $( window ); |
| 577 | + $window.scroll( function() { |
| 578 | + var toolbarWrapperOffset = $toolbarWrapper.offset(); |
| 579 | + if ( $window.scrollTop() > toolbarWrapperOffset.top ) { |
| 580 | + if ( !$toolbarWrapper.hasClass( 'float' ) ) { |
| 581 | + var left = toolbarWrapperOffset.left, |
| 582 | + right = $window.width() - $toolbarWrapper.outerWidth() - left; |
| 583 | + $toolbarWrapper.css( 'height', $toolbarWrapper.height() ).addClass( 'float' ); |
| 584 | + $toolbar.css( { 'left': left, 'right': right } ); |
| 585 | + } |
| 586 | + } else { |
| 587 | + if ( $toolbarWrapper.hasClass( 'float' ) ) { |
| 588 | + $toolbarWrapper.css( 'height', 'auto' ).removeClass( 'float' ); |
| 589 | + $toolbar.css( { 'left': 0, 'right': 0 } ); |
| 590 | + } |
| 591 | + } |
| 592 | + } ); |
| 593 | + |
570 | 594 | var $modeButtons = $( '.es-modes-button' ), |
571 | 595 | $panels = $( '.es-panel' ), |
572 | 596 | $base = $( '#es-base' ), |
573 | | - $window = $(window), |
574 | 597 | currentMode = null, |
575 | 598 | modes = { |
576 | 599 | 'wikitext': { |