Skip to content

Commit

Permalink
cleanup indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
oetiker committed Aug 29, 2023
1 parent f840731 commit 5503309
Show file tree
Hide file tree
Showing 3 changed files with 325 additions and 323 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@
* widget and next to the individual form widgets.
*/
qx.Class.define("callbackery.ui.form.renderer.NoteForm", {
extend : qx.ui.form.renderer.Single,
extend: qx.ui.form.renderer.Single,
/**
* create a page for the View Tab with the given title
*
* @param vizWidget {Widget} visualization widget to embed
*/
construct: function(form) {
construct: function (form) {
this._gotNote = false;
this._mobileMode;
this._reflowQueue = [];
this.base(arguments,form);
this.base(arguments, form);
var fl = this._getLayout();
// have plenty of space for input, not for the labels
fl.setColumnFlex(0, 0);
fl.setColumnAlign(0, "left", "top");
fl.setColumnFlex(1, 4);
fl.setColumnMinWidth(1, 130);
fl.setColumnFlex(2, this._gotNote ? 1 : 0);
fl.setColumnMaxWidth(2,250);
fl.setColumnMaxWidth(2, 250);
fl.setSpacingY(0);
this.addListener('resize', (e) => {
this._updateForm(e.getData().width);
Expand All @@ -40,9 +40,9 @@ qx.Class.define("callbackery.ui.form.renderer.NoteForm", {
members: {
_gotNote: null,
_reflowQueue: null,
_updateForm: function(width){
_updateForm(width) {
let update = true;
if (width < 400 ) {
if (width < 400) {
if (this._mobileMode === true) {
update = false;
}
Expand All @@ -58,22 +58,22 @@ qx.Class.define("callbackery.ui.form.renderer.NoteForm", {
}
}
if (update) {
this._reflowQueue.forEach( (element) => {
this._reflowQueue.forEach((element) => {
element();
});
}
},
addItems: function(items,names,title,itemOptions,headerOptions){
addItems(items, names, title, itemOptions, headerOptions) {
// add the header
let rfq = this._reflowQueue;
if (title != null) {
let widget = null;
if (headerOptions && headerOptions.widget){
if (headerOptions && headerOptions.widget) {
widget = headerOptions.widget.set({
value: title,
paddingTop: this._row == 0 ? 0 :10
paddingTop: this._row == 0 ? 0 : 10
});

}
else {
widget = this._createHeader(title);
Expand All @@ -82,155 +82,157 @@ qx.Class.define("callbackery.ui.form.renderer.NoteForm", {
rfq.push(() => {
if (this._mobileMode) {
this._add(
widget, {
row: row,
column: 1,
widget, {
row: row,
column: 1,
colSpan: 2
});
}
else {
this._add(
widget, {
row: row,
column: 0,
colSpan: 3
});
row: row,
column: 0,
colSpan: 3
});
}
});
this._row++;
if (headerOptions
&& headerOptions.note){
if (headerOptions
&& headerOptions.note) {
let note = new qx.ui.basic.Label(
headerOptions.note).set({
rich: true,
alignX: 'left',
paddingBottom: 12,
paddingRight: 10
});
rich: true,
alignX: 'left',
paddingBottom: 12,
paddingRight: 10
});
let row = this._row;
rfq.push( () => {
rfq.push(() => {
if (this._mobileMode) {
this._add(
note, {
row: row,
column: 1,
colSpan: 2
}
);
row: row,
column: 1,
colSpan: 2
}
);
}
else {
this._add(
note, {
row: row,
column: 0,
colSpan: 3
}
);
row: row,
column: 0,
colSpan: 3
}
);
}
});
this._row++;
if (headerOptions.widget) {
this._connectVisibility(
headerOptions.widget,note);
headerOptions.widget, note);
}
}
}

// add the items
var msg = callbackery.ui.MsgBox.getInstance();
var that = this;
for (var i = 0; i < items.length; i++) { (function(){ // context
let label = that._createLabel(names[i], items[i]);
let item = items[i];
item.set({
marginTop: 2,
marginBottom: 2
});
var labelName = names[i];
// allow form items without label
if (label) {

label.setBuddy(item);
let row = that._row;
rfq.push( () => {
let newLabel = label.getValue().replace(/\s*:\s*$/,'');
if (that._mobileMode) {
label.set({
value: newLabel,
marginTop: 2,
marginBottom: 0,
paddingBottom: 0,
font: 'small',
});
that._add(label, {
row: row,
column: 1,
});
}
else {
label.set({
value: newLabel + ':',
marginTop: 2,
marginBottom: 2,
font: 'default',
});
that._add(label, {
row: row+1,
column: 0,
});
}
for (var i = 0; i < items.length; i++) {
(function () { // context
let label = that._createLabel(names[i], items[i]);
let item = items[i];
item.set({
marginTop: 2,
marginBottom: 2
});
}
that._add(item, {row: that._row+1, column: 1});
if (itemOptions != null && itemOptions[i] != null) {
if ( itemOptions[i].note ){
that._gotNote = true;
var note = new qx.ui.basic.Label(
itemOptions[i].note).set({
rich: true,
paddingLeft: 20,
paddingRight: 20
var labelName = names[i];
// allow form items without label
if (label) {

label.setBuddy(item);
let row = that._row;
rfq.push(() => {
let newLabel = label.getValue().replace(/\s*:\s*$/, '');
if (that._mobileMode) {
label.set({
value: newLabel,
marginTop: 2,
marginBottom: 0,
paddingBottom: 0,
font: 'small',
});
that._add(label, {
row: row,
column: 1,
});
}
else {
label.set({
value: newLabel + ':',
marginTop: 2,
marginBottom: 2,
font: 'default',
});
that._add(label, {
row: row + 1,
column: 0,
});
}
});
that._add(note,{
row: that._row+1,
column: 2
}
that._add(item, { row: that._row + 1, column: 1 });
if (itemOptions != null && itemOptions[i] != null) {
if (itemOptions[i].note) {
that._gotNote = true;
var note = new qx.ui.basic.Label(
itemOptions[i].note).set({
rich: true,
paddingLeft: 20,
paddingRight: 20
});
that._add(note, {
row: that._row + 1,
column: 2
});
that._connectVisibility(item, note);
}
}
if (itemOptions[i].copyOnTap
&& item.getReadOnly()) {
var copyFailMsg = itemOptions[i].copyFailMsg
? that.xtr(itemOptions[i].copyFailMsg)
: that.tr("Select %1 and press [ctrl]+[c]", labelName);
var copySuccessMsg = itemOptions[i].copySuccessMsg
? that.xtr(itemOptions[i].copySuccessMsg)
: that.tr("%1 copied", labelName);

item.addListener('tap', function (e) {
try {
navigator.clipboard.writeText(item.getValue())
.then(function (ret) {
msg.info(that.tr("Success"), copySuccessMsg);
})
.catch(function (err) {
msg.info(that.tr("Copy failed"), copyFailMsg);
})
} catch (err) {
msg.info(that.tr("Copy failed"), copyFailMsg);
}
});
that._connectVisibility(item, note);
}
}
if ( itemOptions[i].copyOnTap
&& item.getReadOnly()){
var copyFailMsg = itemOptions[i].copyFailMsg
? that.xtr(itemOptions[i].copyFailMsg)
: that.tr("Select %1 and press [ctrl]+[c]",labelName);
var copySuccessMsg = itemOptions[i].copySuccessMsg
? that.xtr(itemOptions[i].copySuccessMsg)
: that.tr("%1 copied",labelName);
that._row += 2;
that._connectVisibility(item, label);

item.addListener('tap',function(e){
try {
navigator.clipboard.writeText(item.getValue())
.then(function(ret){
msg.info(that.tr("Success"),copySuccessMsg);
})
.catch(function(err){
msg.info(that.tr("Copy failed"),copyFailMsg);
})
} catch (err) {
msg.info(that.tr("Copy failed"),copyFailMsg);
}
});
}
that._row += 2;
that._connectVisibility(item, label);

// store the names for translation
if (qx.core.Environment.get("qx.dynlocale")) {
that._names.push({
name: names[i], label: label, item: items[i]
});
}
})(); } // end context
// store the names for translation
if (qx.core.Environment.get("qx.dynlocale")) {
that._names.push({
name: names[i], label: label, item: items[i]
});
}
})();
} // end context
let bounds = this.getBounds();
if (bounds) {
this._updateForm(bounds.width);
Expand Down
Loading

0 comments on commit 5503309

Please sign in to comment.