Changeset 9098
- Timestamp:
- 10/29/2014 12:36:12 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/js/mentions.js
r8958 r9098 77 77 */ 78 78 before_reposition: function( offset ) { 79 var $view = $( '#atwho-ground-' + this.id + ' .atwho-view' ), 80 caret = this.$inputor.caret( 'offset', { iframe: $( '#content_ifr' )[0] } ).left, 81 move; 82 83 // If the caret is past horizontal half, then flip it, yo. 84 if ( caret > ( $( 'body' ).width() / 2 ) ) { 79 // get the iframe, if any, already applied with atwho 80 var caret, 81 line, 82 iframeOffset, 83 move, 84 $view = $( '#atwho-ground-' + this.id + ' .atwho-view' ), 85 $body = $( 'body' ), 86 atwhoDataValue = this.$inputor.data( 'atwho' ); 87 88 if ( 'undefined' !== atwhoDataValue && 'undefined' !== atwhoDataValue.iframe && null !== atwhoDataValue.iframe ) { 89 caret = this.$inputor.caret( 'offset', { iframe: atwhoDataValue.iframe } ); 90 // Caret.js no longer calculates iframe caret position from the window (it's now just within the iframe). 91 // We need to get the iframe offset from the window and merge that into our object. 92 iframeOffset = $( atwhoDataValue.iframe ).offset(); 93 if ( 'undefined' !== iframeOffset ) { 94 caret.left += iframeOffset.left; 95 caret.top += iframeOffset.top; 96 } 97 } else { 98 caret = this.$inputor.caret( 'offset' ); 99 } 100 101 // If the caret is past horizontal half, then flip it, yo 102 if ( caret.left > ( $body.width() / 2 ) ) { 85 103 $view.addClass( 'right' ); 86 move = caret - offset.left - this.view.$el.width();104 move = caret.left - offset.left - this.view.$el.width(); 87 105 } else { 88 106 $view.removeClass( 'right' ); 89 move = caret - offset.left + 1; 90 } 91 92 offset.top += 1; 107 move = caret.left - offset.left + 1; 108 } 109 110 // If we're on a small screen, scroll to caret 111 if ( $body.width() <= 400 ) { 112 $( document ).scrollTop( caret.top - 6 ); 113 } 114 115 // New position is under the caret (never above) and positioned to follow 116 // Dynamic sizing based on the input area (remove 'px' from end) 117 line = parseInt( this.$inputor.css( 'line-height' ).substr( 0, this.$inputor.css( 'line-height' ).length - 2 ), 10 ); 118 if ( !line || line < 5 ) { // sanity check, and catch no line-height 119 line = 19; 120 } 121 122 offset.top = caret.top + line; 93 123 offset.left += move; 94 124 }, … … 104 134 */ 105 135 inserting_wrapper: function( $inputor, content, suffix ) { 106 var new_suffix = ( suffix === '' ) ? suffix : suffix || ' '; 107 return '' + content + new_suffix; 136 return '' + content + suffix; 108 137 } 109 138 }
Note: See TracChangeset
for help on using the changeset viewer.