summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/ui')
-rw-r--r--public/assets/javascripts/ui/_router.js22
-rw-r--r--public/assets/javascripts/ui/builder/BuilderInfo.js83
-rw-r--r--public/assets/javascripts/ui/builder/BuilderToolbar.js21
-rw-r--r--public/assets/javascripts/ui/editor/EditorSettings.js2
-rw-r--r--public/assets/javascripts/ui/editor/EditorToolbar.js15
-rw-r--r--public/assets/javascripts/ui/editor/LightControl.js10
-rw-r--r--public/assets/javascripts/ui/editor/MediaEditor.js42
-rw-r--r--public/assets/javascripts/ui/editor/WallpaperPicker.js10
-rw-r--r--public/assets/javascripts/ui/lib/ModalView.js7
-rw-r--r--public/assets/javascripts/ui/lib/Parser.js4
-rw-r--r--public/assets/javascripts/ui/lib/Router.js21
-rw-r--r--public/assets/javascripts/ui/site/LayoutsModal.js8
12 files changed, 116 insertions, 129 deletions
diff --git a/public/assets/javascripts/ui/_router.js b/public/assets/javascripts/ui/_router.js
index 4ff3581..d07810e 100644
--- a/public/assets/javascripts/ui/_router.js
+++ b/public/assets/javascripts/ui/_router.js
@@ -36,11 +36,18 @@ var SiteRouter = Router.extend({
"/project": 'projectPicker',
"/project/new": 'newProject',
"/project/new/:layout": 'projectNewWithLayout',
- "/project/:name": 'project',
+ "/project/:name": 'projectViewer',
+ "/project/:name/edit": 'projectEditor',
"/project/:name/view": 'projectViewer',
"/test/wallpaper": 'testWallpaper',
},
+
+ mobileRoutes: {
+ "/": 'home',
+ "/profile": 'profile',
+ "/project/:name": 'projectViewer',
+ },
initialize: function(){
this.signUpModal = new SignUpModal()
@@ -56,6 +63,11 @@ var SiteRouter = Router.extend({
this.route()
+ if (is_mobile) {
+ $(".topLinks").hide()
+ $(".share").hide()
+ }
+
$("body").removeClass("loading")
},
@@ -123,14 +135,6 @@ var SiteRouter = Router.extend({
this.readerView.load(name)
},
-/*
- editProject: function(e){
- e && e.preventDefault()
- window.history.pushState(null, document.title, "/project/edit")
- this.editProjectModal.load()
- },
-*/
-
signup: function(e){
e && e.preventDefault()
window.history.pushState(null, document.title, "/signup")
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")
diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js
index 13a6f60..d6a79fb 100644
--- a/public/assets/javascripts/ui/editor/EditorSettings.js
+++ b/public/assets/javascripts/ui/editor/EditorSettings.js
@@ -130,7 +130,7 @@ var EditorSettings = FormView.extend({
this.$name.val(data.name)
this.action = this.updateAction
- window.history.pushState(null, document.title, "/project/" + data.slug)
+ window.history.pushState(null, document.title, "/project/" + data.slug + "/edit")
},
})
diff --git a/public/assets/javascripts/ui/editor/EditorToolbar.js b/public/assets/javascripts/ui/editor/EditorToolbar.js
index a3abc5a..5e0da7e 100644
--- a/public/assets/javascripts/ui/editor/EditorToolbar.js
+++ b/public/assets/javascripts/ui/editor/EditorToolbar.js
@@ -30,6 +30,7 @@ var EditorToolbar = View.extend({
this.parent.mediaViewer.show()
this.parent.mediaUpload.show()
this.resetMode()
+ this.resetControls()
},
resetMode: function(){
@@ -43,6 +44,7 @@ var EditorToolbar = View.extend({
},
resizeMedia: function(e, state){
+ this.resetControls()
if (! state && typeof e == "boolean") {
state = e
editor.permissions.assign("resize", state)
@@ -59,6 +61,7 @@ var EditorToolbar = View.extend({
},
destroyMedia: function(e, state){
+ this.resetControls()
if (! state && typeof e == "boolean") {
state = e
editor.permissions.assign("destroy", state)
@@ -73,11 +76,19 @@ var EditorToolbar = View.extend({
},
toggleWallpaper: function(){
- this.parent.wallpaperPicker.toggle()
+ var state = ! $("[data-role='toggle-wallpaper-panel']").hasClass("inuse")
+ this.resetMode()
+ $("[data-role='toggle-wallpaper-panel']").toggleClass("inuse", state)
+ this.parent.lightControl.hide()
+ this.parent.wallpaperPicker.toggle(state)
},
toggleLightControl: function(){
- this.parent.lightControl.toggle()
+ var state = ! $("[data-role='toggle-light-control']").hasClass("inuse")
+ this.resetMode()
+ $("[data-role='toggle-light-control']").toggleClass("inuse", state)
+ this.parent.wallpaperPicker.hide()
+ this.parent.lightControl.toggle(state)
},
editWallText: function(){
diff --git a/public/assets/javascripts/ui/editor/LightControl.js b/public/assets/javascripts/ui/editor/LightControl.js
index 93d97ed..c3e80c2 100644
--- a/public/assets/javascripts/ui/editor/LightControl.js
+++ b/public/assets/javascripts/ui/editor/LightControl.js
@@ -6,12 +6,18 @@ var LightControl = View.extend({
"mousedown": "stopPropagation",
},
- toggle: function(){
- this.$el.toggleClass("active");
+ toggle: function(state){
+ this.$el.toggleClass("active", state);
// toggle the class that makes the cursor a paintbucket
// $("body").removeClass("pastePaper");
},
+ show: function(){
+ this.toggle(true)
+ },
+ hide: function(){
+ this.toggle(false)
+ },
/*
$("#shadow-control").on({
diff --git a/public/assets/javascripts/ui/editor/MediaEditor.js b/public/assets/javascripts/ui/editor/MediaEditor.js
index cd8fb63..e3a8f2e 100644
--- a/public/assets/javascripts/ui/editor/MediaEditor.js
+++ b/public/assets/javascripts/ui/editor/MediaEditor.js
@@ -11,6 +11,9 @@ var MediaEditor = FormView.extend({
"change [name=autoplay]": "setAutoplay",
"change [name=loop]": "setLoop",
"change [name=mute]": "setMute",
+ "change [name=width]": 'changeWidth',
+ "change [name=height]": 'changeHeight',
+ "change [name=units]": 'changeUnits',
"click [data-role=destroy-media]": "destroy",
},
@@ -22,8 +25,8 @@ var MediaEditor = FormView.extend({
this.$description = this.$("[name=description]")
// image fields
- this.$widthDimension = this.$("[name=width]")
- this.$heightDimension = this.$("[name=height]")
+ this.$width = this.$("[name=width]")
+ this.$height = this.$("[name=height]")
this.$units = this.$("[name=units]")
// video fields
@@ -55,16 +58,14 @@ var MediaEditor = FormView.extend({
this.$name.val(media.title)
this.$description.val(media.description)
+ this.setDimensions()
+ this.$units.val( "ft" )
switch (media.type) {
case "image":
this.$(".image").show()
this.$(".video").hide()
-
- this.$widthDimension.val( Number(media.widthDimension) || "" )
- this.$heightDimension.val( Number(media.heightDimension) || "" )
- this.$units.val( media.units || "cm" )
-
+
break
case "youtube":
@@ -113,18 +114,39 @@ var MediaEditor = FormView.extend({
this.scenery.mute(checked)
},
+ setDimensions: function(){
+ this.$width.unitVal( Number(this.scenery.dimensions.a * this.scenery.scale) || "" )
+ this.$height.unitVal( Number(this.scenery.dimensions.b * this.scenery.scale) || "" )
+ },
+ changeWidth: function(e){
+ e.stopPropagation()
+ this.scenery.set_scale( this.$width.unitVal() / this.scenery.dimensions.a )
+ this.setDimensions()
+ },
+ changeHeight: function(e){
+ e.stopPropagation()
+ this.scenery.set_scale( this.$height.unitVal() / this.scenery.dimensions.b )
+ this.setDimensions()
+ },
+ changeUnits: function(){
+ app.units = this.$units.val()
+ this.$('.units').resetUnitVal()
+ },
+
bind: function(scenery){
this.scenery = scenery
this.scenery.mx.bound = true
},
unbind: function(){
- this.scenery.mx.bound = false
- this.scenery = null
+ if (this.scenery && this.scenery.mx) {
+ this.scenery.mx.bound = false
+ }
+ this.scenery = null
},
destroy: function(){
- ConfirmModal.confirm("Are you sure you want to this media?", function(){
+ ConfirmModal.confirm("Are you sure you want delete to this media?", function(){
var scenery = this.scenery
this.hide()
Scenery.remove(scenery.id)
diff --git a/public/assets/javascripts/ui/editor/WallpaperPicker.js b/public/assets/javascripts/ui/editor/WallpaperPicker.js
index cb1e361..9ee441b 100644
--- a/public/assets/javascripts/ui/editor/WallpaperPicker.js
+++ b/public/assets/javascripts/ui/editor/WallpaperPicker.js
@@ -23,11 +23,17 @@ var WallpaperPicker = View.extend({
wm.init()
},
- toggle: function(){
- this.$el.toggleClass("active");
+ toggle: function(state){
+ this.$el.toggleClass("active", state);
// toggle the class that makes the cursor a paintbucket
// $("body").removeClass("pastePaper");
},
+ show: function(){
+ this.toggle(true)
+ },
+ hide: function(){
+ this.toggle(false)
+ },
pick: function(e){
var $swatch = $(e.currentTarget)
diff --git a/public/assets/javascripts/ui/lib/ModalView.js b/public/assets/javascripts/ui/lib/ModalView.js
index 957a54d..937c1e9 100644
--- a/public/assets/javascripts/ui/lib/ModalView.js
+++ b/public/assets/javascripts/ui/lib/ModalView.js
@@ -11,9 +11,10 @@ var ModalView = View.extend({
},
show: function(){
- $(".mediaDrawer").removeClass("active");
- this.$el.addClass("active");
- $("body").addClass("noOverflow");
+ $(".mediaDrawer").removeClass("active")
+ $(".fileUpload").removeClass("active")
+ this.$el.addClass("active")
+ $("body").addClass("noOverflow")
},
hide: function(){
diff --git a/public/assets/javascripts/ui/lib/Parser.js b/public/assets/javascripts/ui/lib/Parser.js
index dfff7b2..1cf0418 100644
--- a/public/assets/javascripts/ui/lib/Parser.js
+++ b/public/assets/javascripts/ui/lib/Parser.js
@@ -86,6 +86,10 @@ var Parser = {
success: function(result){
if (result.length == 0) { return done(id, "", 640, 360) }
var res = result[0]
+ if (res.embed_privacy != "anywhere") {
+ AlertModal.alert("Sorry, the author of this video has marked it private, preventing it from being embedded.", function(){})
+ return
+ }
done({
token: id,
thumbnail: res.thumbnail_large,
diff --git a/public/assets/javascripts/ui/lib/Router.js b/public/assets/javascripts/ui/lib/Router.js
index 5877f93..0b6385c 100644
--- a/public/assets/javascripts/ui/lib/Router.js
+++ b/public/assets/javascripts/ui/lib/Router.js
@@ -4,7 +4,8 @@ var Router = View.extend({
this.originalPath = window.location.pathname
- var pathname = window.location.pathname,
+ var routes = is_mobile ? this.mobileRoutes : this.routes,
+ pathname = window.location.pathname,
path = pathname.split("/");
for (var i = 0; i < path.length; i++) {
@@ -13,7 +14,7 @@ var Router = View.extend({
}
}
- if (pathname in this.routes) {
+ if (pathname in routes) {
this[this.routes[pathname]](null)
}
@@ -21,35 +22,39 @@ var Router = View.extend({
path.pop()
}
- for (var route in this.routes) {
+ for (var route in routes) {
var routePath = route.split("/")
if (routePath[1] == path[1]) {
if (routePath[2] && routePath[2].indexOf(":") !== -1 && path[2] && (path[3] === routePath[3]) ) {
this[this.routes[route]](null, path[2])
- break;
+ return
}
else if (routePath[2] == path[2]) {
if (routePath[3] && path[3]) {
if (routePath[3].indexOf(":") !== -1) {
this[this.routes[route]](null, path[3])
- break;
+ return
}
else if (routePath[3] == path[3]) {
this[this.routes[route]](null)
- break;
+ return
}
}
else if (! routePath[3] && ! path[3]) {
this[this.routes[route]](null)
- break;
+ return
}
}
else if (! routePath[2] && (! path[2].length || ! path[2])) {
this[this.routes[route]](null)
- break;
+ return
}
}
}
+
+ if (is_mobile) {
+ window.location.href = "/"
+ }
}
})
diff --git a/public/assets/javascripts/ui/site/LayoutsModal.js b/public/assets/javascripts/ui/site/LayoutsModal.js
index 4948b0e..f109ec3 100644
--- a/public/assets/javascripts/ui/site/LayoutsModal.js
+++ b/public/assets/javascripts/ui/site/LayoutsModal.js
@@ -19,6 +19,7 @@ var LayoutsIndex = View.extend({
this.$form.hide()
this.$noTemplates.show()
}
+ this.$templates.empty()
data.forEach(function(room){
var $span = $("<span>")
// $span.html(JSON.stringify(room))
@@ -58,7 +59,7 @@ var ProjectsModal = ModalView.extend(LayoutsIndex.prototype).extend({
$layout.addClass("active")
// actually do
- window.location.pathname = "/project/" + $layout.data("slug")
+ window.location.pathname = "/project/" + $layout.data("slug") + "/edit"
},
newProject: function(e){
@@ -103,7 +104,7 @@ var NewProjectModal = ModalView.extend(LayoutsIndex.prototype).extend({
action: "/api/layout",
events: {
- "click .templates span": 'toggleActive',
+ "click .templates span": 'choose',
"submit form": 'choose',
},
@@ -115,7 +116,8 @@ var NewProjectModal = ModalView.extend(LayoutsIndex.prototype).extend({
choose: function(e){
e && e.preventDefault()
- var layout = this.$(".templates .active").data("slug")
+// var layout = this.$(".templates .active").data("slug")
+ var layout = $(e.currentTarget).data("slug")
if (! layout || ! layout.length) return
window.location.pathname = "/project/new/" + layout
}