From 5a35d057453f82aad1097f1a90e9bdd341018a17 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 7 Nov 2014 13:22:36 -0500 Subject: embed modal --- public/assets/javascripts/ui/reader/EmbedView.js | 50 ++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 public/assets/javascripts/ui/reader/EmbedView.js (limited to 'public/assets/javascripts/ui/reader/EmbedView.js') diff --git a/public/assets/javascripts/ui/reader/EmbedView.js b/public/assets/javascripts/ui/reader/EmbedView.js new file mode 100644 index 0000000..a0b3c6f --- /dev/null +++ b/public/assets/javascripts/ui/reader/EmbedView.js @@ -0,0 +1,50 @@ +var EmbedView = ModalView.extend({ + el: ".embedView", + + events: { + "keydown": "stopPropagation", + "input [name=width]": "build", + "input [name=height]": "build", + "click [name=mute]": "build", + "click textarea": "selectAll", + }, + + defaultWidth: 600, + defaultHeight: 450, + + initialize: function(opt){ + this.parent = opt.parent + this.$embedCode = this.$("#embedCode") + this.$width = this.$("[name=width]") + this.$height = this.$("[name=height]") + this.$mute = this.$("[name=mute]") + + this.$width.val(this.defaultWidth) + this.$height.val(this.defaultHeight) + }, + + show: function(){ + this.build() + this.__super__.show.call(this) + }, + + build: function(){ + var mute = this.$mute.prop('checked') ? 1 : 0 + var width = clamp( this.$width.int(), 0, 2000) || this.defaultWidth + var height = clamp( this.$height.int(), 0, 2000) || this.defaultHeight + var link = this.parent.getLink() + link += "?mute=" + mute +// link += "&noui=1" + var kode = "" + + this.$embedCode.val( kode ) + }, + + selectAll: function(){ + this.$embedCode[0].select() + }, + +}) -- cgit v1.2.3-70-g09d2