diff options
Diffstat (limited to 'public/assets/javascripts/ui/editor/MediaEditor.js')
| -rw-r--r-- | public/assets/javascripts/ui/editor/MediaEditor.js | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/public/assets/javascripts/ui/editor/MediaEditor.js b/public/assets/javascripts/ui/editor/MediaEditor.js index 29ec9e5..aea78aa 100644 --- a/public/assets/javascripts/ui/editor/MediaEditor.js +++ b/public/assets/javascripts/ui/editor/MediaEditor.js @@ -4,9 +4,13 @@ var MediaEditor = FormView.extend({ events: { "click .playButton": "togglePlaying", + "mousedown [name=keyframe]": "stopPropagation", "change [name=keyframe]": "seek", + "change [name=autoplay]": "setAutoplay", + "change [name=loop]": "setLoop", + "change [name=mute]": "setMute", }, - + initialize: function(opt){ this.parent = opt.parent this.__super__.initialize.call(this) @@ -22,6 +26,7 @@ var MediaEditor = FormView.extend({ // video fields this.$playButton = this.$(".playButton") + this.$autoplay = this.$("[name=autoplay]") this.$loop = this.$("[name=loop]") this.$mute = this.$("[name=mute]") this.$keyframe = this.$("[name=keyframe]") @@ -53,11 +58,10 @@ var MediaEditor = FormView.extend({ case "image": this.$(".image").show() this.$(".video").hide() - /* - this.$widthDimension - this.$heightDimension - this.$units - */ + + this.$widthDimension.val( Number(media.widthDimension) || "" ) + this.$heightDimension.val( Number(media.heightDimension) || "" ) + this.$units.val( media.units || "cm" ) break @@ -67,11 +71,12 @@ var MediaEditor = FormView.extend({ this.$(".video").show() this.$(".image").hide() - /* - this.$loop - this.$mute - this.$keyframe - */ + this.$playButton.toggleClass("playing", ! this.scenery.paused()) + this.$autoplay.prop('checked', !! media.autoplay) + this.$loop.prop('checked', !! media.loop) + this.$mute.prop('checked', !! media.mute) + this.$keyframe.val( Number(media.keyframe || 0) ) + break } @@ -80,15 +85,31 @@ var MediaEditor = FormView.extend({ seek: function(){ var n = parseFloat( this.$keyframe.val() ) this.scenery.seek(n) + + this.scenery.media.keyframe = n }, - + + setAutoplay: function(){ + var checked = this.$autoplay.prop('checked') + this.scenery.media.autoplay = checked + }, + setLoop: function(){ + var checked = this.$loop.prop('checked') + this.scenery.media.loop = checked + }, + setMute: function(){ + var checked = this.$mute.prop('checked') + this.scenery.media.mute = checked + this.scenery.mute(checked) + }, + bind: function(scenery){ this.scenery = scenery - this.scenery.media.bound = true + this.scenery.mx.bound = true }, unbind: function(){ - this.scenery.media.bound = false + this.scenery.mx.bound = false this.scenery = null }, |
