From 99f4835f1e418874f45c56c8ea194d2e55262661 Mon Sep 17 00:00:00 2001 From: amandaghassaei <amandaghassaei@gmail.com> Date: Mon, 23 Mar 2015 01:22:46 -0400 Subject: [PATCH] cleaning up cam checkbox code --- js/cam/Assembler.js | 3 ++- js/menus/CamMenuView.js | 27 +++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/js/cam/Assembler.js b/js/cam/Assembler.js index e1554f81..4e5f0916 100644 --- a/js/cam/Assembler.js +++ b/js/cam/Assembler.js @@ -17,6 +17,7 @@ Assembler = Backbone.Model.extend({ editsMadeToProgram: false,//warn the user that they will override changes rapidHeight: 6, + rapidHeightRelative: true, safeHeight: 0.5,//inches above stock or assembly, when feed rate should slow origin: null, @@ -24,7 +25,7 @@ Assembler = Backbone.Model.extend({ stock: null, stockPosition: new THREE.Vector3(20,0,0),//in abs coordinates stockPositionRelative: true, - multipleStockPositions: true, + multipleStockPositions: false, stockArraySize: {x:4, y:4}, stockSeparation: 2.78388, postStockNum: 0,//which piece of stock to pick up diff --git a/js/menus/CamMenuView.js b/js/menus/CamMenuView.js index 5a48151b..6434d2e4 100644 --- a/js/menus/CamMenuView.js +++ b/js/menus/CamMenuView.js @@ -11,8 +11,7 @@ CamMenuView = Backbone.View.extend({ "click .camProcess": "_selectCamProcess", "click .units": "_changeUnits", "click #saveCam": "_save", - "change #stockPosRel": "_changeStockPositionRelative", - "change #multipleStockPositions": "_changeMultipleStockPositions", + "change input:checkbox": "_clickCheckbox", "focusout .numberInput": "render" }, @@ -86,16 +85,12 @@ CamMenuView = Backbone.View.extend({ this.assembler.trigger("change"); }, - _changeStockPositionRelative: function(e){ + _clickCheckbox: function(e){ e.preventDefault(); - $(e.target).blur(); - dmaGlobals.assembler.set("stockPositionRelative", !dmaGlobals.assembler.get("stockPositionRelative")); - }, - - _changeMultipleStockPositions: function(e){ - e.preventDefault(); - $(e.target).blur(); - dmaGlobals.assembler.set("multipleStockPositions", !dmaGlobals.assembler.get("multipleStockPositions")); + var $object = $(e.target); + $object.blur(); + var property = $object.data("property"); + dmaGlobals.assembler.set(property, !dmaGlobals.assembler.get(property)); }, _save: function(e){ @@ -144,11 +139,11 @@ CamMenuView = Backbone.View.extend({ <input data-type="y" value="<%= stockPosition.y.toFixed(4) %>" placeholder="Y" class="form-control numberInput stockPosition" type="text">\ <input data-type="z" value="<%= stockPosition.z.toFixed(4) %>" placeholder="Z" class="form-control numberInput stockPosition" type="text"><br/>\ <label class="checkbox" for="stockPosRel">\ - <input id="stockPosRel" type="checkbox" <% if (stockPositionRelative){ %> checked="checked"<% } %> value="" data-toggle="checkbox" class="custom-checkbox">\ + <input id="stockPosRel" data-property="stockPositionRelative" type="checkbox" <% if (stockPositionRelative){ %> checked="checked"<% } %> value="" data-toggle="checkbox" class="custom-checkbox">\ <span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>\ Stock position relative to Zero</label>\ <label class="checkbox" for="multipleStockPositions">\ - <input id="multipleStockPositions" type="checkbox" <% if (multipleStockPositions){ %> checked="checked"<% } %> value="" data-toggle="checkbox" class="custom-checkbox">\ + <input id="multipleStockPositions" data-property="multipleStockPositions" type="checkbox" <% if (multipleStockPositions){ %> checked="checked"<% } %> value="" data-toggle="checkbox" class="custom-checkbox">\ <span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>\ Multiple stock positions</label>\ <% if (multipleStockPositions){ %>\ @@ -156,7 +151,11 @@ CamMenuView = Backbone.View.extend({ <input data-type="y" value="<%= stockArraySize.y %>" placeholder="Y" class="form-control numberInput stockArraySize" type="text"><br/><br/>\ Stock separation: <input value="<%= stockSeparation %>" placeholder="X" class="form-control numberInput stockSeparation" type="text"><br/><br/>\ <% } %>\ - Clearance Height: <input value="<%= rapidHeight %>" placeholder="Z" class="form-control numberInput rapidHeight" type="text"><br/><br/>\ + Clearance Height: <input value="<%= rapidHeight %>" placeholder="Z" class="form-control numberInput rapidHeight" type="text"><br/>\ + <label class="checkbox" for="rapidPosRel">\ + <input id="rapidPosRel" data-property="rapidHeightRelative" type="checkbox" <% if (rapidHeightRelative){ %> checked="checked"<% } %> value="" data-toggle="checkbox" class="custom-checkbox">\ + <span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>\ + Clearance height relative to Zero</label>\ Approach Height: <input value="<%= safeHeight %>" placeholder="Z" class="form-control numberInput safeHeight" type="text"><br/><br/>\ Speeds (measured in <%= units %> per second):<br/><br/>\ Rapids (xy, z): <input data-type="xy" value="<%= rapidSpeeds.xy %>" placeholder="XY" class="form-control numberInput rapidSpeeds" type="text">\ -- GitLab