Skip to content
Snippets Groups Projects
Commit 405ce461 authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

numberInput

parent 8e75eb8b
No related branches found
No related tags found
No related merge requests found
......@@ -183,7 +183,7 @@ hr {
margin: 20px 0;
}
input.numberInput{
input.intInput, number.floatInput{
width:22%;
display: inline;
padding: 8px 10px;
......
......@@ -32,10 +32,7 @@ LatticeMenuView = Backbone.View.extend({
},
_updateGikLength: function(e){
e.preventDefault();
var newVal = parseInt($(e.target).val());
if (isNaN(newVal)) return;
globals.lattice.set("gikLength", newVal);
},
_clearCells: function(e){
......@@ -104,7 +101,7 @@ LatticeMenuView = Backbone.View.extend({
<br/><br/>\
<% } %>\
<% if (connectionType == "gik") { %>\
GIK Length:&nbsp;&nbsp;<input id="gikLength" value="<%= gikLength %>" placeholder="GIK length" class="form-control numberInput" type="text"><br/>\
GIK Length:&nbsp;&nbsp;<input data-property="gikLength" value="<%= gikLength %>" placeholder="GIK length" class="form-control intInput lattice" type="text"><br/>\
<br/>\
<% } %>\
<% if (allMaterialTypes[cellType][connectionType]){ %> \
......
......@@ -9,7 +9,7 @@ MenuWrapper = Backbone.View.extend({
events: {
"click .menuWrapperTab>a": "_tabWasSelected",
"click .dropdownSelector": "_makeDropdownSelection"
"click .dropdownSelector": "_makeDropdownSelection",
},
initialize: function(){
......@@ -46,7 +46,7 @@ MenuWrapper = Backbone.View.extend({
if ($("input").is(":focus") && e.keyCode == 13) {//enter key
$(e.target).blur();
// this.render();
this._renderTab();
return;
}
......@@ -55,11 +55,39 @@ MenuWrapper = Backbone.View.extend({
},
_updateFloat: function(e){
e.preventDefault();
var $target = $(e.target);
var newVal = parseFloat($target.val());
if (isNaN(newVal)) {
console.warn("value is not float");
return;
}
this._setNumber($target, newVal);
},
_updateInt: function(e){
e.preventDefault();
var $target = $(e.target);
var newVal = parseInt($target.val());
if (isNaN(newVal)) {
console.warn("value is NaN");
return;
}
this._setNumber($target, newVal);
},
_setNumber: function($target, newVal){
var property = $target.data("property");
if (!property) {
console.warn("no property associated with number input");
return;
}
var key = $target.data("key");
if (key){
if ($target.hasClass("lattice")) globals.lattice.get(property)[key] = newVal;
return;
}
if ($target.hasClass("lattice")) globals.lattice.set(property, newVal);
},
_makeDropdownSelection: function(e){
......@@ -89,6 +117,12 @@ MenuWrapper = Backbone.View.extend({
}
});
this._renderTab(tabName);
},
_renderTab: function(tabName){
if (!tabName) tabName = this.model.get("currentTab");
if (tabName == "lattice"){
if (!this.latticeMenu) this.latticeMenu = new LatticeMenuView({model:this.model});
this.latticeMenu.render();
......@@ -118,7 +152,6 @@ MenuWrapper = Backbone.View.extend({
console.warn("no tab initialized!");
$("#menuContent").html('Coming Soon.');//clear out content from menu
}
},
render: function(){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment