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

update hex color

parent f0ed7b21
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,11 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _ ...@@ -30,6 +30,11 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _
lattice._changeRandomColor(); lattice._changeRandomColor();
}, },
updateHex: function(hex){
//update hex without rendering
$("#compositeColor").css("border-color", hex);
},
_finishComposite: function(e){ _finishComposite: function(e){
e.preventDefault(); e.preventDefault();
this.stopListening(); this.stopListening();
...@@ -76,7 +81,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _ ...@@ -76,7 +81,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _
Name: &nbsp;&nbsp;<input id="compositeName" data-property="compositeName" value="<%= compositeName %>" placeholder="Enter Name" class="seventyFiveWidth form-control textInput lattice" type="text"><br/><br/>\ Name: &nbsp;&nbsp;<input id="compositeName" data-property="compositeName" value="<%= compositeName %>" placeholder="Enter Name" class="seventyFiveWidth form-control textInput lattice" type="text"><br/><br/>\
Bounding Box: ()<br/><br/>\ Bounding Box: ()<br/><br/>\
Display Color: &nbsp;&nbsp;\ Display Color: &nbsp;&nbsp;\
<input style="border-color: <%= compositeColor %> ;" value="<%= compositeColor %>" placeholder="Enter HEX" class="halfWidth form-control" type="text"><br/><br/>\ <input id="compositeColor" style="border-color: <%= compositeColor %> ;" data-property="compositeColor" value="<%= compositeColor %>" placeholder="Enter HEX" class="halfWidth lattice form-control hexInput" type="text"><br/><br/>\
<a id="newRandomColor" href="#" class="btn btn-block btn-lg btn-default">New Random Color</a><br/><br/>\ <a id="newRandomColor" href="#" class="btn btn-block btn-lg btn-default">New Random Color</a><br/><br/>\
<a id="finishComposite" href="#" class="btn btn-block btn-lg btn-success">Finish Composite</a><br/>\ <a id="finishComposite" href="#" class="btn btn-block btn-lg btn-success">Finish Composite</a><br/>\
<a id="cancelComposite" href="#" class="btn btn-halfWidth btn-lg btn-default">Cancel / Exit</a>\ <a id="cancelComposite" href="#" class="btn btn-halfWidth btn-lg btn-default">Cancel / Exit</a>\
......
...@@ -20,6 +20,7 @@ define(['jquery', 'underscore', 'backbone'], function($, _, Backbone){ ...@@ -20,6 +20,7 @@ define(['jquery', 'underscore', 'backbone'], function($, _, Backbone){
if (this.model.changedAttributes()["currentNav"]) return; if (this.model.changedAttributes()["currentNav"]) return;
if ($("input[type=text]").is(":focus")) return; if ($("input[type=text]").is(":focus")) return;
this.$el.html(this.template(this._makeTemplateJSON())); this.$el.html(this.template(this._makeTemplateJSON()));
this.$el.html(this.template(this._makeTemplateJSON()));
if (this._render) this._render(); if (this._render) this._render();
}, },
......
...@@ -44,7 +44,8 @@ define(['jquery', 'underscore', 'plist', 'backbone', 'lattice'], function($, _, ...@@ -44,7 +44,8 @@ define(['jquery', 'underscore', 'plist', 'backbone', 'lattice'], function($, _,
} }
if ($(".floatInput").is(":focus")) this._updateFloat(e); if ($(".floatInput").is(":focus")) this._updateFloat(e);
if ($(".intInput").is(":focus")) this._updateInt(e); if ($(".intInput").is(":focus")) this._updateInt(e);
if ($(".textInput").is(":focus")) this._updateString(e); if ($(".textInput").is(":focus")) this._updateString(e)
if ($(".hexInput").is(":focus")) this._updateHex(e);
}, },
_updateString: function(e){ _updateString: function(e){
...@@ -58,6 +59,24 @@ define(['jquery', 'underscore', 'plist', 'backbone', 'lattice'], function($, _, ...@@ -58,6 +59,24 @@ define(['jquery', 'underscore', 'plist', 'backbone', 'lattice'], function($, _,
this._getPropertyOwner($target).set(property, $target.val()); this._getPropertyOwner($target).set(property, $target.val());
}, },
_updateHex: function(e){
e.preventDefault();
var $target = $(e.target);
var hex = $target.val();
if (!this._isValidHex(hex)) return;
var property = $target.data("property");
if (!property) {
console.warn("no property associated with string input");
return;
}
this._getPropertyOwner($target).set(property, hex);
if (this.menu.updateHex) this.menu.updateHex(hex);
},
_isValidHex: function(hex){
return hex.match(/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i) !== null;
},
_updateFloat: function(e){ _updateFloat: function(e){
e.preventDefault(); e.preventDefault();
var $target = $(e.target); var $target = $(e.target);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment