Skip to content

Instantly share code, notes, and snippets.

@a-ignatov-parc
Created April 18, 2013 15:49
Show Gist options
  • Save a-ignatov-parc/5413810 to your computer and use it in GitHub Desktop.
Save a-ignatov-parc/5413810 to your computer and use it in GitHub Desktop.
$.extend(typeahead, {
show: function() {
var targetOffset = this.$element.offset(),
targetHeight = this.$element.outerHeight(),
containerOffset = container.offset();
// Корректируем позиционирование
targetOffset.top -= containerOffset.top;
targetOffset.top += targetHeight;
targetOffset.left -= containerOffset.left;
targetOffset.left -= 15;
// Если мы еще не создавали контейнер, то делаем это и апендим внутрь блок $menu
if (!this.$popup) {
this.$popup = $('<div class="b-popup"></div>').append(this.$menu);
}
// Апендим контейнер в нужное место, позиционируем и делаем видимым
this.$popup
.appendTo(container)
.css(targetOffset)
.show();
this.shown = true;
return this;
},
hide: function() {
this.$popup.hide();
this.shown = false;
return this;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment