Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code refactoring and added code comments line ⚒️ #1809

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 10 additions & 22 deletions src/typeahead/default_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,61 +9,49 @@ var DefaultMenu = (function() {

var s = Menu.prototype;

// constructor
function DefaultMenu() {
Menu.apply(this, [].slice.call(arguments, 0));
}

// instance methods
_.mixin(DefaultMenu.prototype, Menu.prototype, {
// overrides
// ---------

open: function open() {
// only display the menu when there's something to be shown
!this._allDatasetsEmpty() && this._show();
if (!this._allDatasetsEmpty()) {
this._show();
}
return s.open.apply(this, [].slice.call(arguments, 0));
},

close: function close() {
this._hide();
return s.close.apply(this, [].slice.call(arguments, 0));
},

_onRendered: function onRendered() {
if (this._allDatasetsEmpty()) {
this._hide();
} else if (this.isOpen()) {
this._show();
}

else {
this.isOpen() && this._show();
}

return s._onRendered.apply(this, [].slice.call(arguments, 0));
},

_onCleared: function onCleared() {
if (this._allDatasetsEmpty()) {
this._hide();
} else if (this.isOpen()) {
this._show();
}

else {
this.isOpen() && this._show();
}

return s._onCleared.apply(this, [].slice.call(arguments, 0));
},

setLanguageDirection: function setLanguageDirection(dir) {
this.$node.css(dir === 'ltr' ? this.css.ltr : this.css.rtl);
return s.setLanguageDirection.apply(this, [].slice.call(arguments, 0));
},

// private
// ---------

// private methods
_hide: function hide() {
this.$node.hide();
},

_show: function show() {
// can't use jQuery#show because $node is a span element we want
// display: block; not dislay: inline;
Expand Down