diff --git a/modules/es/es.Surface.css b/modules/es/es.Surface.css index 198b62799b..9eacc4aa26 100644 --- a/modules/es/es.Surface.css +++ b/modules/es/es.Surface.css @@ -85,6 +85,22 @@ padding: 0.33em 0; } +.es-contextView-position-above .es-contextView-menu { + bottom: 7px; +} + +.es-contextView-position-below .es-contextView-menu { + top: 8px; +} + +.es-contextView-position-left .es-contextView-menu { + left: 0; +} + +.es-contextView-position-right .es-contextView-menu { + right: 0; +} + .es-contextView-menuItem { padding: 0.33em 1em; cursor: pointer; @@ -137,14 +153,6 @@ background-color: #b3d6f6; } -.es-contextView-position-above .es-contextView-menu { - bottom: 7px; -} - -.es-contextView-position-below .es-contextView-menu { - top: 8px; -} - .es-contentView { position: relative; z-index: 1; diff --git a/modules/es/views/es.ContentView.js b/modules/es/views/es.ContentView.js index 384cfd81a8..8363f4b081 100644 --- a/modules/es/views/es.ContentView.js +++ b/modules/es/views/es.ContentView.js @@ -246,12 +246,14 @@ es.ContentView.prototype.drawSelection = function( range ) { 'width': contentWidth - fromPosition.left, 'height': fromPosition.bottom - fromPosition.top } ).show(); - this.$rangeEnd.css( { - 'top': toPosition.top, - 'left': 0, - 'width': toPosition.left, - 'height': toPosition.bottom - toPosition.top - } ).show(); + if ( toPosition.left ) { + this.$rangeEnd.css( { + 'top': toPosition.top, + 'left': 0, + 'width': toPosition.left, + 'height': toPosition.bottom - toPosition.top + } ).show(); + } if ( fromLineIndex + 1 < toLineIndex ) { this.$rangeFill.css( { 'top': fromPosition.bottom, diff --git a/modules/es/views/es.ContextView.js b/modules/es/views/es.ContextView.js index 2679bb8b07..20fd2d4211 100644 --- a/modules/es/views/es.ContextView.js +++ b/modules/es/views/es.ContextView.js @@ -37,7 +37,10 @@ es.ContextView = function( surfaceView, $overlay ) { /* Methods */ es.ContextView.prototype.set = function() { - this.$.removeClass( 'es-contextView-position-below es-contextView-position-above' ); + this.$.removeClass( + 'es-contextView-position-below es-contextView-position-above ' + + 'es-contextView-position-left es-contextView-position-right' + ); var selection = this.surfaceView.getModel().getSelection(), position, offset, @@ -60,6 +63,11 @@ es.ContextView.prototype.set = function() { } } if ( position ) { + if ( position.left + this.$menu.width() < $( 'body' ).width() ) { + this.$.addClass( 'es-contextView-position-left' ); + } else { + this.$.addClass( 'es-contextView-position-right' ); + } this.$.css( { 'left': position.left, 'top': position.top } ); this.$icon.fadeIn( 'fast' ); }