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/editor/EditorToolbar.js3
-rw-r--r--public/assets/javascripts/ui/editor/EditorView.js10
-rw-r--r--public/assets/javascripts/ui/editor/MediaEditor.js5
-rw-r--r--public/assets/javascripts/ui/editor/TextEditor.js85
4 files changed, 94 insertions, 9 deletions
diff --git a/public/assets/javascripts/ui/editor/EditorToolbar.js b/public/assets/javascripts/ui/editor/EditorToolbar.js
index 513306d..49decc2 100644
--- a/public/assets/javascripts/ui/editor/EditorToolbar.js
+++ b/public/assets/javascripts/ui/editor/EditorToolbar.js
@@ -3,6 +3,7 @@ var EditorToolbar = View.extend({
el: "#editorToolbar",
events: {
+ "mousedown": 'stopPropagation',
"click [data-role='toggle-map-view']": 'toggleMap',
"click [data-role='toggle-project-settings']": 'toggleSettings',
"click [data-role='open-media-viewer']": 'openMediaViewer',
@@ -42,6 +43,7 @@ var EditorToolbar = View.extend({
// this.resizeMedia(true)
// this.destroyMedia(false)
$(".inuse").removeClass("inuse")
+ $("body").removeClass("addText")
this.parent.hideExtras()
this.resetPermissions()
},
@@ -131,6 +133,7 @@ var EditorToolbar = View.extend({
$("[data-role='toggle-text-editor']").toggleClass("inuse", state)
this.parent.mediaEditor.hide()
this.parent.wallpaperPicker.hide()
+ this.parent.lightControl.hide()
this.parent.settings.hide()
this.parent.textEditor.toggle(state)
},
diff --git a/public/assets/javascripts/ui/editor/EditorView.js b/public/assets/javascripts/ui/editor/EditorView.js
index 83db532..67687fe 100644
--- a/public/assets/javascripts/ui/editor/EditorView.js
+++ b/public/assets/javascripts/ui/editor/EditorView.js
@@ -42,11 +42,19 @@ var EditorView = View.extend({
},
pick: function(scenery){
- this.mediaEditor.pick(scenery)
+ if (scenery.type == "text") {
+ this.mediaEditor.hide()
+ this.textEditor.pick(scenery)
+ }
+ else {
+ this.textEditor.hide()
+ this.mediaEditor.pick(scenery)
+ }
},
hideExtras: function(){
this.mediaEditor.hide()
+ this.textEditor.hide()
Scenery.resize.hide()
Scenery.hovering = false
}
diff --git a/public/assets/javascripts/ui/editor/MediaEditor.js b/public/assets/javascripts/ui/editor/MediaEditor.js
index e4f93df..0a4d894 100644
--- a/public/assets/javascripts/ui/editor/MediaEditor.js
+++ b/public/assets/javascripts/ui/editor/MediaEditor.js
@@ -76,7 +76,6 @@ var MediaEditor = FormView.extend({
case "image":
this.$(".image").show()
this.$(".video").hide()
-
break
case "youtube":
@@ -90,7 +89,6 @@ var MediaEditor = FormView.extend({
this.$loop.prop('checked', !! media.loop)
this.$mute.prop('checked', !! media.mute)
this.$keyframe.val( Number(media.keyframe || 0) )
-
break
}
},
@@ -166,7 +164,6 @@ var MediaEditor = FormView.extend({
this.scenery.media.title = this.$name.val()
this.scenery.media.description = this.$description.val()
Minotaur.watch( app.router.editorView.settings )
-
if (this.scenery.mx) {
this.scenery.mx.bound = false
this.scenery.mx.el.classList.remove("picked")
@@ -177,8 +174,6 @@ var MediaEditor = FormView.extend({
},
destroy: function(){
-// ConfirmModal.confirm("Are you sure you want delete this object?", function(){
-// }.bind(this))
var scenery = this.scenery
this.hide()
Scenery.remove(scenery.id)
diff --git a/public/assets/javascripts/ui/editor/TextEditor.js b/public/assets/javascripts/ui/editor/TextEditor.js
index 0319a31..0d082ca 100644
--- a/public/assets/javascripts/ui/editor/TextEditor.js
+++ b/public/assets/javascripts/ui/editor/TextEditor.js
@@ -1,6 +1,8 @@
var TextEditor = FormView.extend({
el: "#textEditor",
+ tainted: false,
+ scenery: null,
events: {
"keydown": 'taint',
@@ -9,20 +11,87 @@ var TextEditor = FormView.extend({
"change [name=font-family]": 'changeFontFamily',
"change [name=font-size]": 'changeFontSize',
"input [name=text-body]": 'changeText',
- "click [data-role=destroy-media]": "destroy",
+ "click [data-role=destroy-text]": "destroy",
},
initialize: function(opt){
this.parent = opt.parent
this.__super__.initialize.call(this)
+ this.$settings = this.$(".setting")
+ this.$noTextMessage = this.$(".no-text")
this.$fontFamily = this.$("[name=font-family]")
this.$fontSize = this.$("[name=font-size]")
this.$textBody = this.$("[name=text-body]")
},
toggle: function(state){
- this.$el.toggleClass("active", state);
+ $("#keyhint").fadeOut(200)
+
+ this.$el.toggleClass("active", state)
+ if (state) {
+ Scenery.nextMedia = { type: 'text', width: 300, height: 150 }
+ this.createMode(true)
+ }
+ },
+
+ hide: function(scenery){
+ if (this.scenery) {
+ this.unbind()
+ }
+ this.toggle(false)
+ },
+
+ taint: function(e){
+ e.stopPropagation()
+ this.tainted = true
+ },
+
+ bind: function(scenery){
+ this.tainted = false
+ this.scenery = scenery
+ this.scenery.mx.bound = true
+ this.scenery.mx.el.classList.add("picked")
+ },
+
+ unbind: function(){
+ if (this.scenery && this.tainted) {
+ Minotaur.watch( app.router.editorView.settings )
+
+ if (this.scenery.mx) {
+ this.scenery.mx.bound = false
+ this.scenery.mx.el.classList.remove("picked")
+ }
+ }
+ this.tainted = false
+ this.scenery = null
+ },
+
+ createMode: function(state){
+ this.$settings.toggle(! state)
+ this.$noTextMessage.toggle(!! state)
+ $("body").toggleClass("addText", !! state)
+ },
+
+ pick: function(scenery){
+ if (this.scenery) {
+ this.unbind()
+ }
+
+ Scenery.resize.show(scenery)
+ Scenery.hovering = true
+
+ this.bind(scenery)
+ this.$el.toggleClass("active", true)
+ this.$textBody.val( this.scenery.media.description )
+
+ this.createMode(false)
+
+ if (! this.scenery.media.description) {
+ setTimeout(function(){
+ this.$textBody.focus()
+ }.bind(this), 100)
+ }
},
taint: function(e){
@@ -35,7 +104,17 @@ var TextEditor = FormView.extend({
changeFontSize: function(){
},
- changeText: function(){
+ changeText: function(e){
+ e.stopPropagation()
+ var text = this.$textBody.val()
+ this.scenery.setText(text)
},
+
+ destroy: function(){
+ var scenery = this.scenery
+ this.hide()
+ Scenery.remove(scenery.id)
+ Scenery.resize.hide()
+ },
})