Skip to content

Commit

Permalink
Lint fix, tab intend 4 spaces in source files
Browse files Browse the repository at this point in the history
  • Loading branch information
goldim1993 committed Nov 1, 2022
1 parent f299431 commit 7e6d6b1
Show file tree
Hide file tree
Showing 11 changed files with 137 additions and 139 deletions.
205 changes: 103 additions & 102 deletions source/class/ugpa/timefield/Field.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,117 +9,118 @@
************************************************************************ */

qx.Class.define("ugpa.timefield.Field", {
extend: qx.ui.container.Composite,
include: qx.ui.form.MForm,
extend: qx.ui.container.Composite,
include: qx.ui.form.MForm,

construct(date){
super();
this.__setupLayout();
construct(date) {
// noinspection JSAnnotator
super();
this.__setupLayout();

this._createChildControl("popup");
this._createChildControl("popup");

this._createChildControl("hours");
this.__addTimeSeparator();
this._createChildControl("minutes");
this.__addTimeSeparator();
this._createChildControl("seconds");
this._createChildControl("hours");
this.__addTimeSeparator();
this._createChildControl("minutes");
this.__addTimeSeparator();
this._createChildControl("seconds");

if (date){
this.setValue(date);
}
},

events: {
"stopScrolling": "qx.event.type.Event"
},

properties: {
appearance: {
refine: true,
init: "textfield"
}
},

members: {
_createChildControlImpl(id, hash){
let control;

switch(id) {
case "popup":
control = new ugpa.timefield.SliderPopup();
control.addListener("stopScrolling", function(){
this.fireEvent("stopScrolling");
}, this);
break;
case "hours":
control = this.__addInput(23);
this._add(control);
break;
case "minutes":
case "seconds":
control = this.__addInput(59);
this._add(control);
break;
}

return control || super._createChildControlImpl(id);
},

__setupLayout(){
const layout = new qx.ui.layout.HBox();
layout.set({alignY: "middle"});
this.setLayout(layout);
},

setValue(value){
const hours = Math.floor(value / 3600);
this.__setSecondsForSubField("hours", hours);

const minutes = Math.floor(value / 60) % 60;
this.__setSecondsForSubField("minutes", minutes);

const seconds = Math.floor(value % 60);
this.__setSecondsForSubField("seconds", seconds);
},

__setSecondsForSubField(subfield, seconds){
this.getChildControl(subfield).setValue(ugpa.timefield.Input.toValidString(seconds));
},

getValue(){
return this.__getTimeInSecondsFromFields();
},

__getTimeInSecondsFromFields(){
const hours = this.getChildControl("hours").getValue();
const minutes = this.getChildControl("minutes").getValue();
const seconds = this.getChildControl("seconds").getValue();
return this.__calcTimeInSeconds(hours, minutes, seconds);
},

__calcTimeInSeconds(hours, minutes, seconds){
return Number(hours) * 3600 + Number(minutes) * 60 + Number(seconds);
if (date) {
this.setValue(date);
}
},

__addInput(maxValue){
const input = new ugpa.timefield.Input(maxValue);
input.addListener("input", function(){
this.getChildControl("popup").hide();
}, this);
input.addListener("mouseup", this._onMouseUp, this);
return input;
events: {
"stopScrolling": "qx.event.type.Event"
},

__addTimeSeparator(){
this._add(new qx.ui.basic.Label(":"));
properties: {
appearance: {
refine: true,
init: "textfield"
}
},

_onMouseUp(e){
const popup = this.getChildControl("popup");
const input = e.getTarget();
popup.setCurrentInput(input);
popup.show();
members: {
_createChildControlImpl(id, hash) {
let control;

switch (id) {
case "popup":
control = new ugpa.timefield.SliderPopup();
control.addListener("stopScrolling", function() {
this.fireEvent("stopScrolling");
}, this);
break;
case "hours":
control = this.__addInput(23);
this._add(control);
break;
case "minutes":
case "seconds":
control = this.__addInput(59);
this._add(control);
break;
}

return control || super._createChildControlImpl(id);
},

__setupLayout() {
const layout = new qx.ui.layout.HBox();
layout.set({alignY: "middle"});
this.setLayout(layout);
},

setValue(value) {
const hours = Math.floor(value / 3600);
this.__setSecondsForSubField("hours", hours);

const minutes = Math.floor(value / 60) % 60;
this.__setSecondsForSubField("minutes", minutes);

const seconds = Math.floor(value % 60);
this.__setSecondsForSubField("seconds", seconds);
},

__setSecondsForSubField(subfield, seconds) {
this.getChildControl(subfield).setValue(ugpa.timefield.Input.toValidString(seconds));
},

getValue() {
return this.__getTimeInSecondsFromFields();
},

__getTimeInSecondsFromFields() {
const hours = this.getChildControl("hours").getValue();
const minutes = this.getChildControl("minutes").getValue();
const seconds = this.getChildControl("seconds").getValue();
return this.__calcTimeInSeconds(hours, minutes, seconds);
},

__calcTimeInSeconds(hours, minutes, seconds) {
return Number(hours) * 3600 + Number(minutes) * 60 + Number(seconds);
},

__addInput(maxValue) {
const input = new ugpa.timefield.Input(maxValue);
input.addListener("input", function() {
this.getChildControl("popup").hide();
}, this);
input.addListener("mouseup", this._onMouseUp, this);
return input;
},

__addTimeSeparator() {
this._add(new qx.ui.basic.Label(":"));
},

_onMouseUp(e) {
const popup = this.getChildControl("popup");
const input = e.getTarget();
popup.setCurrentInput(input);
popup.show();
}
}
}
});


16 changes: 8 additions & 8 deletions source/class/ugpa/timefield/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
qx.Class.define("ugpa.timefield.Input", {
extend: qx.ui.form.TextField,

construct(maxValue){
construct(maxValue) {
// noinspection JSAnnotator
super("00");
this.set({
width : 25,
Expand Down Expand Up @@ -42,7 +43,7 @@ qx.Class.define("ugpa.timefield.Input", {
* @param value {Number|String} value
* @return padded value
*/
toValidString(value){
toValidString(value) {
value = String(Number(value));
const twoZeros = value.length === 2;
const lessTen = Number(value) < 10;
Expand All @@ -51,27 +52,26 @@ qx.Class.define("ugpa.timefield.Input", {
},

members: {
hasValidValue(){
hasValidValue() {
return this.isValidValue(this.getValue());
},

_onChangeValue(e){
_onChangeValue(e) {
const value = e.getData();

if (this.isValidValue(value)) {
const padded = this.constructor.toValidString(value);
this.setPrevValue(padded);
this.setValue(padded);
}
else {
} else {
const prevValue = this.getPrevValue();
this.setValue(prevValue);
}
},

isValidValue(time){
isValidValue(time) {
time = Number(time);
return time >= 0 && time <= this.getMaxValue();
}
}
});
});
8 changes: 4 additions & 4 deletions source/class/ugpa/timefield/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
qx.Class.define("ugpa.timefield.Slider", {
extend: qx.ui.form.Slider,

construct(){
construct() {
// noinspection JSAnnotator
super("horizontal");
this.getChildControl("knob").addListener("touchend", function(){
this.getChildControl("knob").addListener("touchend", function() {
this.fireEvent("scrollStop");
}, this);
this.addListener("changeValue", this._onChangeSliderValue, this);
Expand All @@ -27,9 +27,9 @@ qx.Class.define("ugpa.timefield.Slider", {
},

members: {
_onChangeSliderValue(e){
_onChangeSliderValue(e) {
const input = e.getTarget().getUserData("input");
input.setValue(String(e.getData()));
}
}
});
});
23 changes: 12 additions & 11 deletions source/class/ugpa/timefield/SliderPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
qx.Class.define("ugpa.timefield.SliderPopup", {
extend: qx.ui.popup.Popup,

construct(){
construct() {
// noinspection JSAnnotator
super(new qx.ui.layout.HBox());
this._createChildControl("slider");
},
Expand All @@ -21,28 +22,28 @@ qx.Class.define("ugpa.timefield.SliderPopup", {
},

members: {
setCurrentInput(input){
setCurrentInput(input) {
const slider = this.getChildControl("slider");
slider.setUserData("input", input);
slider.setMaximum(input.getMaxValue());
slider.setValue(Number(input.getValue()));
this.placeToWidget(input);
},

_createChildControlImpl(id, hash){
_createChildControlImpl(id, hash) {
let control;

switch(id) {
case "slider":
control = new ugpa.timefield.Slider();
control.addListener("scrollStop", function(){
this.fireEvent("stopScrolling");
}, this);
this._add(control);
switch (id) {
case "slider":
control = new ugpa.timefield.Slider();
control.addListener("scrollStop", function() {
this.fireEvent("stopScrolling");
}, this);
this._add(control);
break;
}

return control || super._createChildControlImpl(id);
}
}
});
});
8 changes: 3 additions & 5 deletions source/class/ugpa/timefield/demo/Application.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ qx.Class.define("ugpa.timefield.demo.Application",
*
* @lint ignoreDeprecated(alert)
*/
main : function()
{
main : function() {
// Call super class
this.base(arguments);

// Enable logging in debug variant
if (qx.core.Environment.get("qx.debug"))
{
if (qx.core.Environment.get("qx.debug")) {
// support native logging capabilities, e.g. Firebug for Firefox
qx.log.appender.Native;
// support additional cross-browser console. Press F7 to toggle visibility
Expand All @@ -59,4 +57,4 @@ qx.Class.define("ugpa.timefield.demo.Application",
doc.add(field, {left: 100, top: 50});
}
}
});
});
6 changes: 2 additions & 4 deletions source/class/ugpa/timefield/test/DemoTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,15 @@ qx.Class.define("ugpa.timefield.test.DemoTest",
/**
* Here are some simple tests
*/
testSimple : function()
{
testSimple : function() {
this.assertEquals(4, 3+1, "This should never fail!");
this.assertFalse(false, "Can false be true?!");
},

/**
* Here are some more advanced tests
*/
testAdvanced: function ()
{
testAdvanced: function () {
var a = 3;
var b = a;
this.assertIdentical(a, b, "A rose by any other name is still a rose");
Expand Down
Loading

0 comments on commit 7e6d6b1

Please sign in to comment.