summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/reader/EmbedView.js
blob: a0b3c6fce5b9a1ad606ff5084794eb88bffaa06a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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()
  },

})