Skip to content

Commit

Permalink
Lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
goldim1993 committed Mar 31, 2023
1 parent 3f3cc5f commit 735b271
Show file tree
Hide file tree
Showing 15 changed files with 130 additions and 134 deletions.
2 changes: 1 addition & 1 deletion Manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
},

"requires": {
"@qooxdoo/framework": "^7.5.1"
"@qooxdoo/framework": "^7.0.0"
}
}
46 changes: 23 additions & 23 deletions source/class/ugpa/completer/Completer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ qx.Class.define("ugpa.completer.Completer", {
this.__delayTimer = null;
},

destruct(){
destruct() {
this.__delayTimer = null;
},

Expand Down Expand Up @@ -107,96 +107,96 @@ qx.Class.define("ugpa.completer.Completer", {
},

members: {
_applyWidget(widget){
_applyWidget(widget) {
widget.addListener("input", this._onInput, this);
widget.addListener("click", this._onFocus, this);
widget.addListener("tap", this._onFocus, this);

this.__updatePopupWidth(this.getPopup());
},

__updatePopupWidth(popup){
if (popup){
__updatePopupWidth(popup) {
if (popup) {
const widget = this.getWidget();
if (widget){
if (widget) {
popup.setWidth(widget.getWidth());
}
}
},

_applyPopup(popup){
_applyPopup(popup) {
this.__updatePopupWidth(popup);
},

_onFocus(){
if (!this.getEnabled()){
_onFocus() {
if (!this.getEnabled()) {
this.getPopup().hide();
return;
}
const value = this.getWidget().getValue();
if (!value && this.getMinLength() > 0){
if (!value && this.getMinLength() > 0) {
return;
}
this.__showPopup();
this.__applyInput(value === null ? "" : value);
},

_onInput(e){
if (!this.getEnabled()){
_onInput(e) {
if (!this.getEnabled()) {
return;
}
const input = e.getData();
if (input.length < this.getMinLength()) {
if (this.getPopup().isVisible()){
if (this.getPopup().isVisible()) {
this.getPopup().hide();
}
return;
}
this.__searchWithTimer(input);
},

__searchWithTimer(input){
__searchWithTimer(input) {
this.__stopDelayTimer();

this.__delayTimer = qx.event.Timer.once(function(){
this.__delayTimer = qx.event.Timer.once(function() {
this.__showPopup();
this.__applyInput(input);
}, this, this.getDelay());
},

__stopDelayTimer(){
if (this.__delayTimer){
__stopDelayTimer() {
if (this.__delayTimer) {
this.__delayTimer.stop();
this.__delayTimer = null;
}
},

__showPopup(){
__showPopup() {
const popup = this.getPopup();
popup.show();
popup.placeToWidget(this.getWidget());
},

__applyAutofocus(){
if (this.getAutoFocus()){
__applyAutofocus() {
if (this.getAutoFocus()) {
const popup = this.getPopup();
this._setupAutoFocus(popup);
}
},

search(value){
search(value) {
this.__searchWithTimer(value);
},

__applyInput(input){
__applyInput(input) {
this._clearPopup();
const values = this.filterByInput(input, this.__source);
if (values.length){
if (values.length) {
values.slice(0, this.getMaxVisibleItems()).forEach(this._addItemOnPopup, this);
this.__applyAutofocus();
} else {
this.getPopup().hide();
}
}
}
});
});
12 changes: 6 additions & 6 deletions source/class/ugpa/completer/IPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

qx.Interface.define("ugpa.completer.IPopup", {
members: {
show(){},
hide(){},
isVisible(){},
setWidth(width){
show() {},
hide() {},
isVisible() {},
setWidth(width) {
qx.core.Assert.assertNumber(width);
},
placeToWidget(){}
placeToWidget() {}
}
});
});
8 changes: 4 additions & 4 deletions source/class/ugpa/completer/IWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

qx.Interface.define("ugpa.completer.IWidget", {
members: {
getWidth(){},
getValue(){},
setValue(value){
getWidth() {},
getValue() {},
setValue(value) {
qx.core.Assert.assertString(value);
}
}
});
});
70 changes: 36 additions & 34 deletions source/class/ugpa/completer/ListCompleter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ qx.Class.define("ugpa.completer.ListCompleter", {
this.setPopup(this.__createPopup(this.__list));
},

destruct(){
destruct() {
this.__list.dispose();
this.__list = null;
},

members: {
__getListModel(){
__getListModel() {
return this.__list.getModel();
},

_applyPopup(popup){
_applyPopup(popup) {
super._applyPopup(popup);
popup.add(this.__list);
},

__createList(){
__createList() {
const model = new qx.data.Array();
const list = new qx.ui.list.List(model);
list.getPane().addListener("update", this._onUpdatePane, this);
Expand All @@ -33,122 +33,124 @@ qx.Class.define("ugpa.completer.ListCompleter", {
return list;
},

__createPopup(list){
__createPopup(list) {
const popup = new ugpa.completer.ListPopup();
popup.add(list);
return popup;
},

_onUpdatePane(){
_onUpdatePane() {
const height = this.__list.getPane().getRowConfig().getTotalSize() + 6;
this.__list.setHeight(height);
},

_onPointerDown(e){
_onPointerDown(e) {
const target = e.getTarget();
if (target instanceof qx.ui.form.ListItem){
if (this.__oldItem){
if (target instanceof qx.ui.form.ListItem) {
if (this.__oldItem) {
this.__oldItem.removeState("selected");
}
target.addState("selected");
this.__oldItem = target;
}
},

setDelegate(delegate){
setDelegate(delegate) {
this.__list.setDelegate(delegate);
},

_onKeyPress(e){
if (!this.getEnabled()){
_onKeyPress(e) {
if (!this.getEnabled()) {
return;
}
const model = this.__getListModel();
if (model.getLength() === 0){
if (model.getLength() === 0) {
return;
}
const key = e.getKeyIdentifier();
if (key === "Backspace"){
if (key === "Backspace") {
return;
}
if (key === "Down" || key === "Up"){
if (key === "Down" || key === "Up") {
e.preventDefault();
}
let index;
const list = this.__list;
const selection = list.getSelection();
if (!this.getPopup().isVisible()){
if (!this.getPopup().isVisible()) {
this.getPopup().show();
}

if (selection.getLength()){
if (selection.getLength()) {
const selected = selection.getItem(0);
if (key === "Enter"){
if (key === "Enter") {
this.__applyValue(selected);
this.getPopup().hide();
}

index = model.indexOf(selected);

if (key === "Down"){
if (index === model.getLength() - 1){
if (key === "Down") {
if (index === model.getLength() - 1) {
index = 0;
} else {
index++;
}
}

if (key === "Up"){
if (index === 0){
if (key === "Up") {
if (index === 0) {
index = model.getLength() - 1;
} else {
index--;
}
}
} else {
if (key === "Down"){
if (key === "Down") {
index = 0;
}

if (key === "Up"){
if (key === "Up") {
index = model.getLength() - 1;
}
}
if (qx.lang.Type.isNumber(index)){
if (qx.lang.Type.isNumber(index)) {
const value = model.getItem(index);
list.setSelection([value]);
this.__applyValue(value);
}
},

_setupAutoFocus(){
_setupAutoFocus() {
const firstItem = this.__getListModel().getItem(0);
if (firstItem){
if (firstItem) {
this.__list.setSelection([firstItem]);
}
},

_addItemOnPopup(value){
_addItemOnPopup(value) {
this.__getListModel().push(value);
},

__applyValue(value){
if (this.getCompletionColumn()){
__applyValue(value) {
if (this.getCompletionColumn()) {
value = value.get(this.getCompletionColumn());
}
this.getWidget().setValue(value);
},

_onItemPressed(e){
_onItemPressed(e) {
const index = e.getData()[0];
const value = this.__getListModel().getItem(index);
this.__applyValue(value);
qx.event.Timer.once(function(){this.getPopup().hide();}, this, 100);
qx.event.Timer.once(function() {
this.getPopup().hide();
}, this, 100);
},

_clearPopup(){
_clearPopup() {
const model = this.__getListModel();
model.removeAll();
}
}
});
});
4 changes: 2 additions & 2 deletions source/class/ugpa/completer/ListPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ qx.Class.define("ugpa.completer.ListPopup", {
extend: qx.ui.popup.Popup,
implement: ugpa.completer.IPopup,

construct(){
construct() {
// noinspection JSAnnotator
super();
this.setLayout(new qx.ui.layout.Grow());
}
});
});
Loading

0 comments on commit 735b271

Please sign in to comment.