Skip to content

Commit

Permalink
Merge pull request #96 from ericktai/master
Browse files Browse the repository at this point in the history
Support for absolute left/right placement
  • Loading branch information
yuku committed Aug 6, 2014
2 parents c5a5d93 + e54dd1d commit e83de22
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ The `option` is an optional Object which MAY have `appendTo`. If `appendTo` is g

```js
var option = {
appentTo: 'body' // suports Element and jQuery object
appendTo: 'body' // supports Element and jQuery object
};
```

Expand Down
12 changes: 11 additions & 1 deletion jquery.textcomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@
var fontSize;
// If the strategy has the 'placement' option set to 'top', move the
// position above the element
if(this.strategy.placement === 'top') {
if(this.strategy.placement.indexOf('top') > -1) {
// Move it to be in line with the match character
fontSize = parseInt(this.$el.css('font-size'));
// Overwrite the position object to set the 'bottom' property instead of the top.
Expand All @@ -565,6 +565,16 @@
// strategy is shown, $el keeps the property.
position.bottom = 'auto';
}

if (this.strategy.placement.indexOf('absleft') > -1) {
position.left = 0;
}

if (this.strategy.placement.indexOf('absright') > -1) {
position.right = 0;
position.left = 'auto';
}

this.$el.css(position);
return this;
},
Expand Down

0 comments on commit e83de22

Please sign in to comment.