summaryrefslogtreecommitdiff
path: root/public/assets/javascripts
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts')
-rw-r--r--public/assets/javascripts/mx/extensions/mx.movements.js6
-rw-r--r--public/assets/javascripts/mx/primitives/mx.image.js3
-rw-r--r--public/assets/javascripts/rectangles/engine/map/tools/ortho.js26
-rw-r--r--public/assets/javascripts/rectangles/engine/map/tools/polyline.js24
-rw-r--r--public/assets/javascripts/rectangles/engine/shapes/shapelist.js1
-rw-r--r--public/assets/javascripts/ui/lib/Toolbar.js22
-rw-r--r--public/assets/javascripts/ui/site/StaffView.js26
7 files changed, 77 insertions, 31 deletions
diff --git a/public/assets/javascripts/mx/extensions/mx.movements.js b/public/assets/javascripts/mx/extensions/mx.movements.js
index fa59908..9ed8790 100644
--- a/public/assets/javascripts/mx/extensions/mx.movements.js
+++ b/public/assets/javascripts/mx/extensions/mx.movements.js
@@ -162,13 +162,13 @@ MX.Movements = function (cam) {
case 8: // backspace
e.preventDefault()
- if (app.controller.sculptureEditor.sculpture) {
+ if (app.controller.sculptureEditor && app.controller.sculptureEditor.sculpture) {
app.controller.sculptureEditor.sculpture.remove()
}
- else if (app.controller.mediaEditor.scenery) {
+ else if (app.controller.mediaEditor && app.controller.mediaEditor.scenery) {
app.controller.mediaEditor.scenery.remove()
}
- else if (app.controller.textEditor.scenery) {
+ else if (app.controller.textEditor && app.controller.textEditor.scenery) {
app.controller.textEditor.scenery.remove()
}
}
diff --git a/public/assets/javascripts/mx/primitives/mx.image.js b/public/assets/javascripts/mx/primitives/mx.image.js
index 64de4b2..f9de141 100644
--- a/public/assets/javascripts/mx/primitives/mx.image.js
+++ b/public/assets/javascripts/mx/primitives/mx.image.js
@@ -17,7 +17,7 @@ MX.Image = MX.Object3D.extend({
this.el.style.backgroundRepeat = 'no-repeat'
- this.load(ops)
+ ops.src && this.load(ops)
},
load: function(ops){
@@ -64,7 +64,6 @@ MX.Image = MX.Object3D.extend({
if (recenter) {
ctx.restore()
}
-
},
})
diff --git a/public/assets/javascripts/rectangles/engine/map/tools/ortho.js b/public/assets/javascripts/rectangles/engine/map/tools/ortho.js
index be3d707..ef41096 100644
--- a/public/assets/javascripts/rectangles/engine/map/tools/ortho.js
+++ b/public/assets/javascripts/rectangles/engine/map/tools/ortho.js
@@ -12,11 +12,11 @@ var OrthoPolylineTool = MapTool.extend(function (base) {
if (map.ui.placing) {
// close polyline or cancel
map.ui.placing = false
- if (line.points.length > 2) {
- line.build()
+ if (shapes.workline.points.length > 2) {
+ shapes.workline.build()
}
else {
- line.reset()
+ shapes.workline.reset()
}
return
}
@@ -29,24 +29,24 @@ var OrthoPolylineTool = MapTool.extend(function (base) {
// compare to initial point
var p = last_point.clone()
if (map.ui.placing) {
- if (line.lastPoint().eq(p)) {
+ if (shapes.workline.lastPoint().eq(p)) {
return
}
- else if (line.canCloseWith(p)) {
- line.close()
- line.build()
+ else if (shapes.workline.canCloseWith(p)) {
+ shapes.workline.close()
+ shapes.workline.build()
map.ui.placing = false
}
else {
- line.add(p)
+ shapes.workline.add(p)
prev_point = p
horizontal = ! horizontal
}
}
else {
map.ui.placing = true
- line = new Polyline ()
- line.add(p)
+ shapes.workline = new Polyline ()
+ shapes.workline.add(p)
first_point = prev_point = p
horizontal = false
}
@@ -55,7 +55,7 @@ var OrthoPolylineTool = MapTool.extend(function (base) {
last_point.a = cursor.x.a
last_point.b = cursor.y.a
if (map.ui.placing) {
- if (line.points.length == 1) {
+ if (shapes.workline.points.length == 1) {
var x = abs(prev_point.a - last_point.a)
var y = abs(prev_point.b - last_point.b)
if (x > y) {
@@ -86,7 +86,7 @@ var OrthoPolylineTool = MapTool.extend(function (base) {
}
}
- if (line.canCloseWith(last_point)) {
+ if (shapes.workline.canCloseWith(last_point)) {
document.body.style.cursor = "pointer"
last_point.assign(first_point)
cursor.x.a = cursor.x.b = last_point.a
@@ -107,7 +107,7 @@ var OrthoPolylineTool = MapTool.extend(function (base) {
}
}
exports.cancel = function(){
- if (map.ui.placing) { line.reset() }
+ if (map.ui.placing) { shapes.workline.reset() }
first_point = null
map.ui.placing = false
}
diff --git a/public/assets/javascripts/rectangles/engine/map/tools/polyline.js b/public/assets/javascripts/rectangles/engine/map/tools/polyline.js
index 559aea8..1ab86f6 100644
--- a/public/assets/javascripts/rectangles/engine/map/tools/polyline.js
+++ b/public/assets/javascripts/rectangles/engine/map/tools/polyline.js
@@ -9,11 +9,11 @@ var PolylineTool = MapTool.extend(function (base) {
if (map.ui.placing) {
// close polyline or cancel
map.ui.placing = false
- if (line.points.length > 2) {
- line.build()
+ if (shapes.workline.points.length > 2) {
+ shapes.workline.build()
}
else {
- line.reset()
+ shapes.workline.reset()
}
return
}
@@ -24,27 +24,27 @@ var PolylineTool = MapTool.extend(function (base) {
// compare to initial point
var p = last_point.clone()
if (map.ui.placing) {
- if (line.canCloseWith(p)) {
- line.close()
- line.build()
+ if (shapes.workline.canCloseWith(p)) {
+ shapes.workline.close()
+ shapes.workline.build()
map.ui.placing = false
}
else {
- line.add(p)
+ shapes.workline.add(p)
}
}
else {
map.ui.placing = true
- line = new Polyline ()
- line.add(p)
+ shapes.workline = new Polyline ()
+ shapes.workline.add(p)
}
}
exports.move = function(e, cursor){
last_point.a = cursor.x.a
last_point.b = cursor.y.a
- if (map.ui.placing && line.canCloseWith(last_point)) {
+ if (map.ui.placing && shapes.workline.canCloseWith(last_point)) {
document.body.style.cursor = "pointer"
- last_point.assign(line.points[0])
+ last_point.assign(shapes.workline.points[0])
cursor.x.a = cursor.x.b = last_point.a
cursor.y.a = cursor.y.b = last_point.b
return
@@ -62,7 +62,7 @@ var PolylineTool = MapTool.extend(function (base) {
}
}
exports.cancel = function(){
- if (map.ui.placing) { line.reset() }
+ if (map.ui.placing) { shapes.workline.reset() }
map.ui.placing = false
}
return exports
diff --git a/public/assets/javascripts/rectangles/engine/shapes/shapelist.js b/public/assets/javascripts/rectangles/engine/shapes/shapelist.js
index 00e1a4e..932ce36 100644
--- a/public/assets/javascripts/rectangles/engine/shapes/shapelist.js
+++ b/public/assets/javascripts/rectangles/engine/shapes/shapelist.js
@@ -2,6 +2,7 @@ var ShapeList = Fiber.extend(function(base){
var exports = {}
exports.init = function(){
this.shapes = []
+ this.workline = null
}
exports.add = function(shape){
this.shapes.push(shape)
diff --git a/public/assets/javascripts/ui/lib/Toolbar.js b/public/assets/javascripts/ui/lib/Toolbar.js
new file mode 100644
index 0000000..a9ce51c
--- /dev/null
+++ b/public/assets/javascripts/ui/lib/Toolbar.js
@@ -0,0 +1,22 @@
+var Toolbar = Fiber.extend(function(base){
+ var exports = {}
+ exports.init = function(rapper){
+ this.rapper = (typeof rapper == "string") ? $(rapper)[0] : rapper
+ this.tools = {}
+ this.els = {}
+ }
+ exports.add = function(role, fn){
+ var self = this
+ this.tools[role] = fn
+ this.els[role] = $("[data-role=" + role + "]", self.rapper)
+ this.els[role].click(function(){
+ $(".active", self.rapper).removeClass('active')
+ $(this).addClass('active')
+ fn()
+ })
+ }
+ exports.pick = function(role){
+ this.els[role].trigger("click")
+ }
+ return exports
+}) \ No newline at end of file
diff --git a/public/assets/javascripts/ui/site/StaffView.js b/public/assets/javascripts/ui/site/StaffView.js
index 0398f71..59649e3 100644
--- a/public/assets/javascripts/ui/site/StaffView.js
+++ b/public/assets/javascripts/ui/site/StaffView.js
@@ -4,11 +4,13 @@ var StaffView = View.extend({
events: {
"click #toggle-staff": "toggleStaff",
"click #toggle-featured": "toggleFeatured",
+ "click #toggle-stock": "toggleStock",
},
initialize: function() {
this.$toggleStaff = $("#toggle-staff")
this.$toggleFeatured = $("#toggle-featured")
+ this.$toggleStock = $("#toggle-stock")
this.$mediaEmbed = $("#media-embed")
if (this.$toggleStaff.length && this.$toggleStaff.data().isstaff) {
this.$toggleStaff.html("Is Staff")
@@ -16,6 +18,9 @@ var StaffView = View.extend({
if (this.$toggleFeatured.length && this.$toggleFeatured.data().featured) {
this.$toggleFeatured.html("Featured Project")
}
+ if (this.$toggleStock.length && this.$toggleStock.data().stock) {
+ this.$toggleStock.html("Layout is Stock")
+ }
if (this.$mediaEmbed.length) {
var media = this.$mediaEmbed.data()
this.$mediaEmbed.html( Parser.tag( media ) )
@@ -67,6 +72,25 @@ var StaffView = View.extend({
$("#isFeaturedProject").html(data.state ? "yes" : "no")
}.bind(this)
})
- },
+ },
+
+ toggleStock: function(){
+ console.log("stock")
+ var state = ! this.$toggleStock.data().stock
+ $.ajax({
+ type: "put",
+ dataType: "json",
+ url: window.location.href + "/stock",
+ data: {
+ state: state,
+ _csrf: $("#_csrf").val(),
+ },
+ success: function(data){
+ this.$toggleStock.data("stock", data.state)
+ this.$toggleStock.html(data.state ? "Stock Layout" : "Make this layout Stock")
+ $("#isStockLayout").html(data.state ? "yes" : "no")
+ }.bind(this)
+ })
+ },
})