2019-06-07 21:20:01 +08:00
|
|
|
|
import { on } from "ember-addons/ember-computed-decorators";
|
|
|
|
|
|
2019-06-07 22:12:22 +08:00
|
|
|
|
const { bind } = Ember.run;
|
2017-11-21 18:53:09 +08:00
|
|
|
|
|
2019-06-07 22:12:22 +08:00
|
|
|
|
export default Ember.Mixin.create({
|
|
|
|
|
@on("init")
|
|
|
|
|
_initKeys() {
|
2017-11-21 18:53:09 +08:00
|
|
|
|
this.keys = {
|
|
|
|
|
TAB: 9,
|
|
|
|
|
ENTER: 13,
|
|
|
|
|
ESC: 27,
|
|
|
|
|
UP: 38,
|
|
|
|
|
DOWN: 40,
|
|
|
|
|
BACKSPACE: 8,
|
2018-03-22 18:29:55 +08:00
|
|
|
|
LEFT: 37,
|
|
|
|
|
RIGHT: 39,
|
|
|
|
|
A: 65
|
2017-11-21 18:53:09 +08:00
|
|
|
|
};
|
2019-06-07 22:12:22 +08:00
|
|
|
|
|
|
|
|
|
this._boundMouseDownHandler = bind(this, this._mouseDownHandler);
|
|
|
|
|
this._boundFocusHeaderHandler = bind(this, this._focusHeaderHandler);
|
|
|
|
|
this._boundKeydownHeaderHandler = bind(this, this._keydownHeaderHandler);
|
|
|
|
|
this._boundKeypressHeaderHandler = bind(this, this._keypressHeaderHandler);
|
|
|
|
|
this._boundChangeFilterInputHandler = bind(
|
|
|
|
|
this,
|
|
|
|
|
this._changeFilterInputHandler
|
|
|
|
|
);
|
|
|
|
|
this._boundKeypressFilterInputHandler = bind(
|
|
|
|
|
this,
|
|
|
|
|
this._keypressFilterInputHandler
|
|
|
|
|
);
|
|
|
|
|
this._boundFocusoutFilterInputHandler = bind(
|
|
|
|
|
this,
|
|
|
|
|
this._focusoutFilterInputHandler
|
|
|
|
|
);
|
|
|
|
|
this._boundKeydownFilterInputHandler = bind(
|
|
|
|
|
this,
|
|
|
|
|
this._keydownFilterInputHandler
|
|
|
|
|
);
|
2017-11-21 18:53:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-06-07 21:20:01 +08:00
|
|
|
|
@on("didInsertElement")
|
|
|
|
|
_setupEvents() {
|
2019-06-07 22:12:22 +08:00
|
|
|
|
$(document).on("mousedown.select-kit", this._boundMouseDownHandler);
|
2019-06-07 21:20:01 +08:00
|
|
|
|
|
|
|
|
|
this.$header()
|
2019-06-07 22:12:22 +08:00
|
|
|
|
.on("blur.select-kit", this._boundBlurHeaderHandler)
|
|
|
|
|
.on("focus.select-kit", this._boundFocusHeaderHandler)
|
|
|
|
|
.on("keydown.select-kit", this._boundKeydownHeaderHandler)
|
|
|
|
|
.on("keypress.select-kit", this._boundKeypressHeaderHandler);
|
2017-11-21 18:53:09 +08:00
|
|
|
|
|
2019-06-07 21:20:01 +08:00
|
|
|
|
this.$filterInput()
|
2019-06-07 22:12:22 +08:00
|
|
|
|
.on("change.select-kit", this._boundChangeFilterInputHandler)
|
|
|
|
|
.on("keypress.select-kit", this._boundKeypressFilterInputHandler)
|
|
|
|
|
.on("focusout.select-kit", this._boundFocusoutFilterInputHandler)
|
|
|
|
|
.on("keydown.select-kit", this._boundKeydownFilterInputHandler);
|
2019-06-07 21:20:01 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
@on("willDestroyElement")
|
|
|
|
|
_cleanUpEvents() {
|
2019-06-07 22:12:22 +08:00
|
|
|
|
$(document).off("mousedown.select-kit", this._boundMouseDownHandler);
|
2017-11-21 18:53:09 +08:00
|
|
|
|
|
2019-06-11 15:45:45 +08:00
|
|
|
|
if (this.$header()) {
|
2017-11-22 02:08:59 +08:00
|
|
|
|
this.$header()
|
2019-06-07 22:12:22 +08:00
|
|
|
|
.off("blur.select-kit", this._boundBlurHeaderHandler)
|
|
|
|
|
.off("focus.select-kit", this._boundFocusHeaderHandler)
|
|
|
|
|
.off("keydown.select-kit", this._boundKeydownHeaderHandler)
|
|
|
|
|
.off("keypress.select-kit", this._boundKeypressHeaderHandler);
|
2017-11-22 02:08:59 +08:00
|
|
|
|
}
|
2017-11-21 18:53:09 +08:00
|
|
|
|
|
2019-06-11 15:45:45 +08:00
|
|
|
|
if (this.$filterInput()) {
|
2017-11-22 02:08:59 +08:00
|
|
|
|
this.$filterInput()
|
2019-06-07 22:12:22 +08:00
|
|
|
|
.off("change.select-kit", this._boundChangeFilterInputHandler)
|
|
|
|
|
.off("keypress.select-kit", this._boundKeypressFilterInputHandler)
|
|
|
|
|
.off("focusout.select-kit", this._boundFocusoutFilterInputHandler)
|
|
|
|
|
.off("keydown.select-kit", this._boundKeydownFilterInputHandler);
|
2017-11-22 02:08:59 +08:00
|
|
|
|
}
|
2017-11-21 18:53:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
2019-05-28 18:15:12 +08:00
|
|
|
|
_mouseDownHandler(event) {
|
|
|
|
|
if (!this.element || this.isDestroying || this.isDestroyed) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2017-11-21 18:53:09 +08:00
|
|
|
|
|
2019-07-16 18:45:15 +08:00
|
|
|
|
if (this.element !== event.target && this.element.contains(event.target)) {
|
2019-05-28 18:15:12 +08:00
|
|
|
|
event.stopPropagation();
|
|
|
|
|
if (!this.renderedBodyOnce) return;
|
|
|
|
|
if (!this.isFocused) return;
|
|
|
|
|
} else {
|
|
|
|
|
this.didClickOutside(event);
|
|
|
|
|
}
|
|
|
|
|
},
|
2017-12-28 23:12:45 +08:00
|
|
|
|
|
2019-05-28 18:15:12 +08:00
|
|
|
|
_blurHeaderHandler() {
|
|
|
|
|
if (!this.isExpanded && this.isFocused) {
|
|
|
|
|
this.close();
|
|
|
|
|
}
|
|
|
|
|
},
|
2017-11-21 18:53:09 +08:00
|
|
|
|
|
2019-05-28 18:15:12 +08:00
|
|
|
|
_focusHeaderHandler(event) {
|
|
|
|
|
this.set("isFocused", true);
|
|
|
|
|
this._destroyEvent(event);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_keydownHeaderHandler(event) {
|
|
|
|
|
if (document.activeElement !== this.$header()[0]) return event;
|
|
|
|
|
|
|
|
|
|
const keyCode = event.keyCode || event.which;
|
|
|
|
|
|
|
|
|
|
if (keyCode === this.keys.TAB && event.shiftKey) {
|
|
|
|
|
this.unfocus(event);
|
|
|
|
|
}
|
|
|
|
|
if (keyCode === this.keys.TAB && !event.shiftKey) this.tabFromHeader(event);
|
|
|
|
|
if (Ember.isEmpty(this.filter) && keyCode === this.keys.BACKSPACE)
|
|
|
|
|
this.backspaceFromHeader(event);
|
|
|
|
|
if (keyCode === this.keys.ESC) this.escapeFromHeader(event);
|
|
|
|
|
if (keyCode === this.keys.ENTER) this.enterFromHeader(event);
|
|
|
|
|
if ([this.keys.UP, this.keys.DOWN].includes(keyCode))
|
|
|
|
|
this.upAndDownFromHeader(event);
|
|
|
|
|
if (
|
|
|
|
|
Ember.isEmpty(this.filter) &&
|
|
|
|
|
[this.keys.LEFT, this.keys.RIGHT].includes(keyCode)
|
|
|
|
|
) {
|
|
|
|
|
this.leftAndRightFromHeader(event);
|
|
|
|
|
}
|
|
|
|
|
return event;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_keypressHeaderHandler(event) {
|
|
|
|
|
const keyCode = event.keyCode || event.which;
|
|
|
|
|
|
|
|
|
|
if (keyCode === this.keys.ENTER) return true;
|
|
|
|
|
if (keyCode === this.keys.TAB) return true;
|
|
|
|
|
|
|
|
|
|
this.expand(event);
|
|
|
|
|
|
|
|
|
|
if (this.filterable || this.autoFilterable) {
|
|
|
|
|
this.set("renderedFilterOnce", true);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-30 05:10:47 +08:00
|
|
|
|
Ember.run.schedule("afterRender", () => {
|
2019-05-28 18:15:12 +08:00
|
|
|
|
this.$filterInput()
|
|
|
|
|
.focus()
|
|
|
|
|
.val(this.$filterInput().val() + String.fromCharCode(keyCode));
|
2017-11-21 18:53:09 +08:00
|
|
|
|
});
|
|
|
|
|
|
2019-05-28 18:15:12 +08:00
|
|
|
|
return false;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_keydownFilterInputHandler(event) {
|
|
|
|
|
const keyCode = event.keyCode || event.which;
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
Ember.isEmpty(this.filter) &&
|
|
|
|
|
keyCode === this.keys.BACKSPACE &&
|
|
|
|
|
typeof this.didPressBackspaceFromFilter === "function"
|
|
|
|
|
) {
|
|
|
|
|
this.didPressBackspaceFromFilter(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (keyCode === this.keys.TAB && event.shiftKey) {
|
|
|
|
|
this.unfocus(event);
|
|
|
|
|
}
|
|
|
|
|
if (keyCode === this.keys.TAB && !event.shiftKey) this.tabFromFilter(event);
|
|
|
|
|
if (keyCode === this.keys.ESC) this.escapeFromFilter(event);
|
|
|
|
|
if (keyCode === this.keys.ENTER) this.enterFromFilter(event);
|
|
|
|
|
if ([this.keys.UP, this.keys.DOWN].includes(keyCode))
|
|
|
|
|
this.upAndDownFromFilter(event);
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
Ember.isEmpty(this.filter) &&
|
|
|
|
|
[this.keys.LEFT, this.keys.RIGHT].includes(keyCode)
|
|
|
|
|
) {
|
|
|
|
|
this.leftAndRightFromFilter(event);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_changeFilterInputHandler(event) {
|
|
|
|
|
this.send("onFilterComputedContent", $(event.target).val());
|
|
|
|
|
},
|
|
|
|
|
_keypressFilterInputHandler(event) {
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
},
|
|
|
|
|
_focusoutFilterInputHandler(event) {
|
|
|
|
|
this.onFilterInputFocusout(event);
|
|
|
|
|
},
|
|
|
|
|
|
2017-11-21 18:53:09 +08:00
|
|
|
|
didPressTab(event) {
|
2019-05-27 16:15:39 +08:00
|
|
|
|
if (this.$highlightedRow().length && this.isExpanded) {
|
2018-03-22 18:29:55 +08:00
|
|
|
|
this.close(event);
|
|
|
|
|
this.$header().focus();
|
|
|
|
|
const guid = this.$highlightedRow().attr("data-guid");
|
|
|
|
|
this.select(this._findComputedContentItemByGuid(guid));
|
2017-11-22 06:28:48 +08:00
|
|
|
|
return true;
|
2018-03-22 18:29:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-27 16:15:39 +08:00
|
|
|
|
if (Ember.isEmpty(this.filter)) {
|
2018-03-22 18:29:55 +08:00
|
|
|
|
this.close(event);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
didPressEnter(event) {
|
2019-05-27 16:15:39 +08:00
|
|
|
|
if (!this.isExpanded) {
|
2018-03-22 18:29:55 +08:00
|
|
|
|
this.expand(event);
|
|
|
|
|
} else if (this.$highlightedRow().length) {
|
|
|
|
|
this.close(event);
|
|
|
|
|
this.$header().focus();
|
|
|
|
|
const guid = this.$highlightedRow().attr("data-guid");
|
|
|
|
|
this.select(this._findComputedContentItemByGuid(guid));
|
2017-11-21 18:53:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
|
2018-03-22 18:29:55 +08:00
|
|
|
|
didClickSelectionItem(computedContentItem) {
|
|
|
|
|
this.focus();
|
|
|
|
|
this.deselect(computedContentItem);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
didClickRow(computedContentItem) {
|
2018-03-22 23:17:23 +08:00
|
|
|
|
this.close();
|
2018-03-22 18:29:55 +08:00
|
|
|
|
this.focus();
|
|
|
|
|
this.select(computedContentItem);
|
|
|
|
|
},
|
|
|
|
|
|
2017-11-21 18:53:09 +08:00
|
|
|
|
didPressEscape(event) {
|
|
|
|
|
this._destroyEvent(event);
|
2018-03-22 18:29:55 +08:00
|
|
|
|
|
2019-05-27 16:15:39 +08:00
|
|
|
|
if (this.highlightedSelection.length && this.isExpanded) {
|
2018-03-22 18:29:55 +08:00
|
|
|
|
this.clearHighlightSelection();
|
|
|
|
|
} else {
|
|
|
|
|
this.unfocus(event);
|
|
|
|
|
}
|
2017-11-21 18:53:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
didPressUpAndDownArrows(event) {
|
|
|
|
|
this._destroyEvent(event);
|
|
|
|
|
|
2018-03-22 18:29:55 +08:00
|
|
|
|
this.clearHighlightSelection();
|
|
|
|
|
|
2017-11-21 18:53:09 +08:00
|
|
|
|
const keyCode = event.keyCode || event.which;
|
2018-03-22 18:29:55 +08:00
|
|
|
|
|
2019-05-27 16:15:39 +08:00
|
|
|
|
if (!this.isExpanded) {
|
2017-11-21 18:53:09 +08:00
|
|
|
|
this.expand(event);
|
|
|
|
|
|
|
|
|
|
if (this.$selectedRow().length === 1) {
|
|
|
|
|
this._highlightRow(this.$selectedRow());
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-03-22 18:29:55 +08:00
|
|
|
|
|
|
|
|
|
return;
|
2017-11-21 18:53:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-23 01:35:46 +08:00
|
|
|
|
const $rows = this.$rows();
|
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
|
if (!$rows.length) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-03-22 18:29:55 +08:00
|
|
|
|
|
2017-11-21 18:53:09 +08:00
|
|
|
|
if ($rows.length === 1) {
|
|
|
|
|
this._rowSelection($rows, 0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const direction = keyCode === 38 ? -1 : 1;
|
|
|
|
|
|
2019-10-30 05:10:47 +08:00
|
|
|
|
Ember.run.throttle(this, this._moveHighlight, direction, $rows, 32);
|
2017-11-21 18:53:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
|
didPressBackspaceFromFilter(event) {
|
|
|
|
|
this.didPressBackspace(event);
|
|
|
|
|
},
|
2017-11-21 18:53:09 +08:00
|
|
|
|
didPressBackspace(event) {
|
2019-05-27 16:15:39 +08:00
|
|
|
|
if (!this.isExpanded) {
|
2018-03-22 18:29:55 +08:00
|
|
|
|
this.expand();
|
|
|
|
|
if (event) event.stopImmediatePropagation();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2017-11-21 18:53:09 +08:00
|
|
|
|
|
2019-05-22 23:18:46 +08:00
|
|
|
|
if (!this.selection || !this.selection.length) return;
|
2017-11-21 18:53:09 +08:00
|
|
|
|
|
2019-05-27 16:15:39 +08:00
|
|
|
|
if (!Ember.isEmpty(this.filter)) {
|
2018-03-22 18:29:55 +08:00
|
|
|
|
this.clearHighlightSelection();
|
|
|
|
|
return;
|
2017-11-21 18:53:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-27 16:15:39 +08:00
|
|
|
|
if (!this.highlightedSelection.length) {
|
2018-03-22 18:29:55 +08:00
|
|
|
|
// try to highlight the last non locked item from the current selection
|
2019-05-27 16:15:39 +08:00
|
|
|
|
Ember.makeArray(this.selection)
|
2018-06-15 23:03:24 +08:00
|
|
|
|
.slice()
|
|
|
|
|
.reverse()
|
|
|
|
|
.some(selection => {
|
|
|
|
|
if (!Ember.get(selection, "locked")) {
|
|
|
|
|
this.highlightSelection(selection);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
});
|
2017-11-21 18:53:09 +08:00
|
|
|
|
|
2018-03-22 18:29:55 +08:00
|
|
|
|
if (event) event.stopImmediatePropagation();
|
|
|
|
|
} else {
|
2019-05-27 16:15:39 +08:00
|
|
|
|
this.deselect(this.highlightedSelection);
|
2018-03-22 18:29:55 +08:00
|
|
|
|
if (event) event.stopImmediatePropagation();
|
2017-11-21 18:53:09 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2018-03-22 18:29:55 +08:00
|
|
|
|
didPressSelectAll() {
|
2019-05-27 16:15:39 +08:00
|
|
|
|
this.highlightSelection(Ember.makeArray(this.selection));
|
2018-03-22 18:29:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
2017-11-21 18:53:09 +08:00
|
|
|
|
didClickOutside(event) {
|
2019-05-27 16:15:39 +08:00
|
|
|
|
if (this.isExpanded && $(event.target).parents(".select-kit").length) {
|
2017-11-21 18:53:09 +08:00
|
|
|
|
this.close(event);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-22 00:37:13 +08:00
|
|
|
|
this.close(event);
|
2017-11-21 18:53:09 +08:00
|
|
|
|
return;
|
|
|
|
|
},
|
|
|
|
|
|
2017-11-22 01:07:10 +08:00
|
|
|
|
// make sure we don’t propagate a click outside component
|
|
|
|
|
// to avoid closing a modal containing the component for example
|
|
|
|
|
click(event) {
|
|
|
|
|
this._destroyEvent(event);
|
|
|
|
|
},
|
|
|
|
|
|
2018-03-22 18:29:55 +08:00
|
|
|
|
didPressLeftAndRightArrows(event) {
|
2019-05-27 16:15:39 +08:00
|
|
|
|
if (!this.isExpanded) {
|
2018-03-22 18:29:55 +08:00
|
|
|
|
this.expand();
|
|
|
|
|
event.stopImmediatePropagation();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-27 16:15:39 +08:00
|
|
|
|
if (Ember.isEmpty(this.selection)) return;
|
2018-03-22 18:29:55 +08:00
|
|
|
|
|
|
|
|
|
const keyCode = event.keyCode || event.which;
|
|
|
|
|
|
|
|
|
|
if (keyCode === this.keys.LEFT) {
|
|
|
|
|
const prev = this.get("highlightedSelection.lastObject");
|
2019-05-27 16:15:39 +08:00
|
|
|
|
const indexOfPrev = this.selection.indexOf(prev);
|
2018-03-22 18:29:55 +08:00
|
|
|
|
|
2019-05-27 16:15:39 +08:00
|
|
|
|
if (this.selection[indexOfPrev - 1]) {
|
|
|
|
|
this.highlightSelection(this.selection[indexOfPrev - 1]);
|
2018-03-22 18:29:55 +08:00
|
|
|
|
} else {
|
|
|
|
|
this.highlightSelection(this.get("selection.lastObject"));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
const prev = this.get("highlightedSelection.firstObject");
|
2019-05-27 16:15:39 +08:00
|
|
|
|
const indexOfNext = this.selection.indexOf(prev);
|
2018-03-22 18:29:55 +08:00
|
|
|
|
|
2019-05-27 16:15:39 +08:00
|
|
|
|
if (this.selection[indexOfNext + 1]) {
|
|
|
|
|
this.highlightSelection(this.selection[indexOfNext + 1]);
|
2018-03-22 18:29:55 +08:00
|
|
|
|
} else {
|
|
|
|
|
this.highlightSelection(this.get("selection.firstObject"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
|
tabFromHeader(event) {
|
|
|
|
|
this.didPressTab(event);
|
|
|
|
|
},
|
|
|
|
|
tabFromFilter(event) {
|
|
|
|
|
this.didPressTab(event);
|
|
|
|
|
},
|
2017-11-21 18:53:09 +08:00
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
|
escapeFromHeader(event) {
|
|
|
|
|
this.didPressEscape(event);
|
|
|
|
|
},
|
|
|
|
|
escapeFromFilter(event) {
|
|
|
|
|
this.didPressEscape(event);
|
|
|
|
|
},
|
2017-11-21 18:53:09 +08:00
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
|
upAndDownFromHeader(event) {
|
|
|
|
|
this.didPressUpAndDownArrows(event);
|
|
|
|
|
},
|
|
|
|
|
upAndDownFromFilter(event) {
|
|
|
|
|
this.didPressUpAndDownArrows(event);
|
|
|
|
|
},
|
2017-11-21 18:53:09 +08:00
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
|
leftAndRightFromHeader(event) {
|
|
|
|
|
this.didPressLeftAndRightArrows(event);
|
|
|
|
|
},
|
|
|
|
|
leftAndRightFromFilter(event) {
|
|
|
|
|
this.didPressLeftAndRightArrows(event);
|
|
|
|
|
},
|
2018-03-22 18:29:55 +08:00
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
|
backspaceFromHeader(event) {
|
|
|
|
|
this.didPressBackspace(event);
|
|
|
|
|
},
|
2017-11-21 18:53:09 +08:00
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
|
enterFromHeader(event) {
|
|
|
|
|
this.didPressEnter(event);
|
|
|
|
|
},
|
|
|
|
|
enterFromFilter(event) {
|
|
|
|
|
this.didPressEnter(event);
|
|
|
|
|
},
|
2017-11-21 18:53:09 +08:00
|
|
|
|
|
2018-07-24 02:19:36 +08:00
|
|
|
|
onFilterInputFocusout(event) {
|
2019-07-16 18:45:15 +08:00
|
|
|
|
if (
|
|
|
|
|
!(
|
|
|
|
|
this.element !== event.relatedTarget &&
|
|
|
|
|
this.element.contains(event.relatedTarget)
|
|
|
|
|
)
|
|
|
|
|
) {
|
2018-07-24 02:19:36 +08:00
|
|
|
|
this.close(event);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2017-11-21 18:53:09 +08:00
|
|
|
|
_moveHighlight(direction, $rows) {
|
|
|
|
|
const currentIndex = $rows.index(this.$highlightedRow());
|
|
|
|
|
let nextIndex = currentIndex + direction;
|
|
|
|
|
|
|
|
|
|
if (nextIndex < 0) {
|
|
|
|
|
nextIndex = $rows.length - 1;
|
|
|
|
|
} else if (nextIndex >= $rows.length) {
|
|
|
|
|
nextIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._rowSelection($rows, nextIndex);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_rowSelection($rows, nextIndex) {
|
|
|
|
|
const highlightableValue = $rows.eq(nextIndex).attr("data-value");
|
|
|
|
|
const $highlightableRow = this.$findRowByValue(highlightableValue);
|
|
|
|
|
this._highlightRow($highlightableRow);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_highlightRow($row) {
|
2019-10-30 05:10:47 +08:00
|
|
|
|
Ember.run.schedule("afterRender", () => {
|
2017-11-21 18:53:09 +08:00
|
|
|
|
$row.trigger("mouseover").focus();
|
|
|
|
|
this.focus();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|