summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-10-06 23:41:04 -0400
committerJules Laplace <jules@okfoc.us>2014-10-06 23:41:04 -0400
commit9dccd8305b57a8d19caac960aa6f8528f208baf6 (patch)
tree7a0a1aae626abcde6722d054b97388e5a3f1814e /public/assets/javascripts/ui
parentc4793f4c649425d0a4b09ce7244edd7ceb69f335 (diff)
parent20b1d2787e71cb28c55187d42805407fef63d0e4 (diff)
merge
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.js15
-rw-r--r--public/assets/javascripts/ui/editor/TextEditor.js107
4 files changed, 122 insertions, 13 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..9b81db1 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
}
},
@@ -162,11 +160,12 @@ var MediaEditor = FormView.extend({
},
unbind: function(){
- if (this.scenery && this.tainted) {
- this.scenery.media.title = this.$name.val()
- this.scenery.media.description = this.$description.val()
- Minotaur.watch( app.router.editorView.settings )
-
+ if (this.scenery) {
+ if (this.tainted) {
+ 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 +176,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..1e35c12 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',
@@ -8,21 +10,103 @@ var TextEditor = FormView.extend({
"mousedown": "stopPropagation",
"change [name=font-family]": 'changeFontFamily',
"change [name=font-size]": 'changeFontSize',
+ "change [name=text-align]": 'changeTextAlign',
"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]")
+ this.$textAlign = this.$("[name=text-align]")
},
toggle: function(state){
- this.$el.toggleClass("active", state);
+ $("#keyhint").fadeOut(200)
+
+ this.$el.toggleClass("active", state)
+ if (state) {
+ Scenery.nextMedia = {
+ type: 'text',
+ width: 600,
+ height: 450,
+ scale: 0.5,
+ font: { family: 'Lato', size: 12, align: 'left' },
+ }
+
+ 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) {
+ if (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.$fontFamily.val( this.scenery.media.font.family )
+ this.$fontSize.val( this.scenery.media.font.size )
+ this.$textAlign.val( this.scenery.media.font.align )
+
+ this.createMode(false)
+
+ if (! this.scenery.media.description) {
+ setTimeout(function(){
+ this.$textBody.focus()
+ }.bind(this), 100)
+ }
},
taint: function(e){
@@ -30,12 +114,29 @@ var TextEditor = FormView.extend({
},
changeFontFamily: function(){
+ this.scenery.setFont({ family: this.$fontFamily.val() })
+ },
+
+ changeTextAlign: function(){
+ this.scenery.setFont({ align: this.$textAlign.val() })
},
changeFontSize: function(){
+ var size = parseInt( this.$fontSize.val() )
+ size && this.scenery.setFont({ size: size })
},
- 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()
+ },
})