diff options
Diffstat (limited to 'public/assets/javascripts/ui/reader/EmbedView.js')
| -rw-r--r-- | public/assets/javascripts/ui/reader/EmbedView.js | 50 |
1 files changed, 50 insertions, 0 deletions
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 = "<iframe src='" + encodeURI(link) + "' width='" + width + "' height='" + height + "'" + + " seamless scrolling='no' style='border: 0'" + + " webkitAllowFullScreen mozallowfullscreen allowfullscreen" + + "></iframe>" + + this.$embedCode.val( kode ) + }, + + selectAll: function(){ + this.$embedCode[0].select() + }, + +}) |
