summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/builder
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-08-13 17:56:31 -0400
committerJules Laplace <jules@okfoc.us>2014-08-13 17:56:31 -0400
commitc4c45b64c2c0fc109f4c21effe7f73f5c46a1ae9 (patch)
treef6e5e703af41a53fe3a9daa3de23e671a1c6ab74 /public/assets/javascripts/ui/builder
parent466ccfdccd2d761f31ba78a74a40544b77b358e5 (diff)
parentb7b881a00a9b73ba54cc3a62edc402a903ec9142 (diff)
merge
Diffstat (limited to 'public/assets/javascripts/ui/builder')
-rw-r--r--public/assets/javascripts/ui/builder/BuilderInfo.js83
-rw-r--r--public/assets/javascripts/ui/builder/BuilderToolbar.js21
2 files changed, 15 insertions, 89 deletions
diff --git a/public/assets/javascripts/ui/builder/BuilderInfo.js b/public/assets/javascripts/ui/builder/BuilderInfo.js
index 56f1338..2fffdba 100644
--- a/public/assets/javascripts/ui/builder/BuilderInfo.js
+++ b/public/assets/javascripts/ui/builder/BuilderInfo.js
@@ -96,86 +96,3 @@ var BuilderInfo = View.extend({
},
})
-
-$.fn.resetUnitVal = function(){
- this.each(function(){
- var n = $(this).data("px")
- $(this).unitVal(n)
- });
-}
-
-$.fn.unitVal = function(n){
- var s
- if (typeof n === "undefined") {
- s = $(this).val()
- n = stringToMeasurement( s )
- if (! n || isNaN(n)) {
- n = $(this).data("px")
- }
- }
- s = measurementToString( n )
- $(this).val( s ).data("px", n)
- return n
-}
-
-function measurementToString( n ) {
- var s, ft, inch
- switch (app.units) {
- case 'm':
- s = round(n/36 * 0.3048 * 100) / 100 + " m"
- break
- case 'ft':
- ft = floor(n / 36)
- inch = abs(round((n % 36) / 3))
- s = ft + "'"
- if (inch > 0) {
- s += " " + inch + '"'
- }
- break
- case 'px':
- default:
- s = round(n) + " px"
- break
- }
- return s
-}
-function stringToMeasurement( s ) {
- var ft, inch, ft_in, type
- if (! s.match(/[0-9]/)) {
- return NaN
- }
- if (s.indexOf("'") !== -1 || s.indexOf('"') !== -1 || s.indexOf('ft') !== -1) {
- ft_in = s.match(/[0-9.]+/g)
- if (ft_in.length >= 2) {
- ft = parseFloat( ft_in[0] )
- inch = parseFloat( ft_in[1] )
- }
- else if (ft_in.length == 1) {
- if (s.indexOf('"') !== -1) {
- ft = 0
- inch = parseFloat( ft_in[0] )
- }
- else {
- ft = parseFloat( ft_in[0] )
- inch = 0
- }
- }
- else {
- ft = inch = 0
- }
- n = ft * 36 + inch * 3
- }
- else if (s.indexOf("m") !== -1) {
- n = parseFloat(s.match(/[0-9.]+/)) * 36 / 0.3048
- }
- else if (s.indexOf("px") !== -1) {
- n = parseFloat(s.match(/[0-9.]+/))
- }
- else {
- n = abs( stringToMeasurement( s + app.units ) )
- }
- if (s.indexOf('-') !== -1) {
- n *= -1
- }
- return n
-} \ No newline at end of file
diff --git a/public/assets/javascripts/ui/builder/BuilderToolbar.js b/public/assets/javascripts/ui/builder/BuilderToolbar.js
index df98ab0..2eb7590 100644
--- a/public/assets/javascripts/ui/builder/BuilderToolbar.js
+++ b/public/assets/javascripts/ui/builder/BuilderToolbar.js
@@ -6,15 +6,22 @@ var BuilderToolbar = View.extend({
"click [data-role='toggle-map-view']": 'toggleMap',
"click [data-role='toggle-layout-settings']": 'toggleSettings',
"click [data-role='undo']": 'undo',
- "click [data-role='create-mode']": 'create',
- "click [data-role='resize-mode']": 'resize',
- "click [data-role='move-mode']": 'move',
+// "click [data-role='create-mode']": 'create',
+// "click [data-role='resize-mode']": 'resize',
+// "click [data-role='move-mode']": 'move',
"click [data-role='destroy-mode']": 'destroy',
},
initialize: function(opt){
this.parent = opt.parent
- map.ui.permissions.toggle()
+ this.resetPermissions()
+ },
+
+ resetPermissions: function(){
+ map.ui.permissions.clear()
+ map.ui.permissions.add("create")
+ map.ui.permissions.add("move")
+ map.ui.permissions.add("resize")
},
toggleMap: function(){
@@ -27,7 +34,8 @@ var BuilderToolbar = View.extend({
undo: function(){
},
-
+
+/*
create: function(e){
var state = map.ui.permissions.toggle("create")
$(".inuse").removeClass("inuse")
@@ -45,7 +53,8 @@ var BuilderToolbar = View.extend({
$(".inuse").removeClass("inuse")
$(e.currentTarget).toggleClass("inuse", state)
},
-
+*/
+
destroy: function(e){
var state = map.ui.permissions.toggle("destroy")
$(".inuse").removeClass("inuse")