[Fixed Position] Incorporate new numberfield inputs

Changed inputs from textfields to numberfields, and removed internal
type checking for these inputs
This commit is contained in:
Aaron Doubek-Kraft
2017-06-26 10:52:04 -07:00
parent 515ea7caf8
commit 2a8c3977a4
5 changed files with 31 additions and 45 deletions

View File

@ -152,57 +152,65 @@ define([
"text": "X", "text": "X",
"name": "X", "name": "X",
"cssClass": "l-input-sm", "cssClass": "l-input-sm",
"control": "textfield" "control": "numberfield",
"min": "0"
}, },
{ {
"property": "editY", "property": "editY",
"text": "Y", "text": "Y",
"name": "Y", "name": "Y",
"cssClass": "l-input-sm", "cssClass": "l-input-sm",
"control": "textfield" "control": "numberfield",
"min": "0"
}, },
{ {
"property": "editX1", "property": "editX1",
"text": "X1", "text": "X1",
"name": "X1", "name": "X1",
"cssClass": "l-input-sm", "cssClass": "l-input-sm",
"control" : "textfield" "control" : "numberfield",
"min": "0"
}, },
{ {
"property": "editY1", "property": "editY1",
"text": "Y1", "text": "Y1",
"name": "Y1", "name": "Y1",
"cssClass": "l-input-sm", "cssClass": "l-input-sm",
"control" : "textfield" "control" : "numberfield",
"min": 0
}, },
{ {
"property": "editX2", "property": "editX2",
"text": "X2", "text": "X2",
"name": "X2", "name": "X2",
"cssClass": "l-input-sm", "cssClass": "l-input-sm",
"control" : "textfield" "control" : "numberfield",
"min": "0"
}, },
{ {
"property": "editY2", "property": "editY2",
"text": "Y2", "text": "Y2",
"name": "Y2", "name": "Y2",
"cssClass": "l-input-sm", "cssClass": "l-input-sm",
"control" : "textfield" "control" : "numberfield",
"min": "0"
}, },
{ {
"property": "editHeight", "property": "editHeight",
"text": "H", "text": "H",
"name": "H", "name": "H",
"cssClass": "l-input-sm numerical", "cssClass": "l-input-sm",
"control": "textfield", "control": "numberfield",
"description": "Resize change object height" "description": "Resize change object height",
"min": "1"
}, },
{ {
"property": "editWidth", "property": "editWidth",
"text": "W", "text": "W",
"name": "W", "name": "W",
"cssClass": "l-input-sm numerical", "cssClass": "l-input-sm",
"control": "textfield" "control": "numberfield",
"min": "1"
} }
] ]
}, },

View File

@ -53,10 +53,10 @@ define(
proxy.fill = new AccessorMutator(element, 'fill'); proxy.fill = new AccessorMutator(element, 'fill');
//Expose x,y, width and height for editing //Expose x,y, width and height for editing
proxy.editWidth = new AccessorMutator(element, 'width', proxy.checkNumeric); proxy.editWidth = new AccessorMutator(element, 'width');
proxy.editHeight = new AccessorMutator(element, 'height', proxy.checkNumeric); proxy.editHeight = new AccessorMutator(element, 'height');
proxy.editX = new AccessorMutator(element, 'x', proxy.checkNumeric); proxy.editX = new AccessorMutator(element, 'x');
proxy.editY = new AccessorMutator(element, 'y', proxy.checkNumeric); proxy.editY = new AccessorMutator(element, 'y');
return proxy; return proxy;
} }

View File

@ -156,28 +156,6 @@ define(
return this.resizeHandles; return this.resizeHandles;
}; };
/**
* Ensure and input type is numeric: intended to be passed as the
* updater argument to an AccessorMutator object in order to restrict
* input to integer values only.
* @return Either the string '' (for no input), the new value passed in,
* or the current value of the new value is invalid.
*/
ElementProxy.prototype.checkNumeric = function (value, current) {
var intValue = parseInt(value);
// Handle case of empty field by swapping in 0
if (value === '') {
return 0;
}
// Else, check if the input is integral, and not, return current value
// of the field
if (isNaN(intValue)) {
return current;
} else {
return intValue;
}
};
return ElementProxy; return ElementProxy;
} }
); );

View File

@ -50,10 +50,10 @@ define(
proxy.url = new AccessorMutator(element, 'url'); proxy.url = new AccessorMutator(element, 'url');
//Expose width and height properties for editing //Expose width and height properties for editing
proxy.editWidth = new AccessorMutator(element, 'width', proxy.checkNumeric); proxy.editWidth = new AccessorMutator(element, 'width');
proxy.editHeight = new AccessorMutator(element, 'height', proxy.checkNumeric); proxy.editHeight = new AccessorMutator(element, 'height');
proxy.editX = new AccessorMutator(element, 'x', proxy.checkNumeric); proxy.editX = new AccessorMutator(element, 'x');
proxy.editY = new AccessorMutator(element, 'y', proxy.checkNumeric); proxy.editY = new AccessorMutator(element, 'y');
return proxy; return proxy;
} }

View File

@ -149,10 +149,10 @@ define(
}; };
// Expose endpoint coordinates for editing // Expose endpoint coordinates for editing
proxy.editX1 = new AccessorMutator(element, 'x', proxy.checkNumeric); proxy.editX1 = new AccessorMutator(element, 'x');
proxy.editY1 = new AccessorMutator(element, 'y', proxy.checkNumeric); proxy.editY1 = new AccessorMutator(element, 'y');
proxy.editX2 = new AccessorMutator(element, 'x2', proxy.checkNumeric); proxy.editX2 = new AccessorMutator(element, 'x2');
proxy.editY2 = new AccessorMutator(element, 'y2', proxy.checkNumeric); proxy.editY2 = new AccessorMutator(element, 'y2');
return proxy; return proxy;
} }