8 |
8 |
9 IriSP.Widgets.Slider.prototype = new IriSP.Widgets.Widget(); |
9 IriSP.Widgets.Slider.prototype = new IriSP.Widgets.Widget(); |
10 |
10 |
11 IriSP.Widgets.Slider.prototype.defaults = { |
11 IriSP.Widgets.Slider.prototype.defaults = { |
12 minimized_height : 4, |
12 minimized_height : 4, |
13 maximized_height : 4, |
13 maximized_height : 10, |
14 minimize_timeout : 1500 /* time before minimizing slider after mouseout, |
14 minimize_timeout : 1500 /* time before minimizing slider after mouseout, |
15 set to zero for fixed slider */ |
15 set to zero for fixed slider */ |
16 }; |
16 }; |
17 |
17 |
18 IriSP.Widgets.Slider.prototype.template = |
|
19 '<div class="Ldt-Slider"></div><div class="Ldt-Slider-Time">00:00</div>'; |
|
20 |
|
21 IriSP.Widgets.Slider.prototype.draw = function() { |
18 IriSP.Widgets.Slider.prototype.draw = function() { |
22 |
19 |
23 this.renderTemplate(); |
20 this.$slider = IriSP.jQuery('<div>') |
|
21 .addClass("Ldt-Slider"); |
24 |
22 |
25 this.$time = this.$.find(".Ldt-Slider-Time"); |
23 this.$.append(this.$slider); |
26 |
|
27 this.$slider = this.$.find(".Ldt-Slider"); |
|
28 |
24 |
29 var _this = this; |
25 var _this = this; |
30 |
26 |
31 this.$slider.slider({ |
27 this.$slider.slider({ |
32 range: "min", |
28 range: "min", |
33 value: 0, |
29 value: 0, |
34 min: 0, |
30 min: 0, |
35 max: this.source.getDuration().milliseconds, |
31 max: this.source.getDuration().milliseconds, |
36 slide: function(event, ui) { |
32 slide: function(event, ui) { |
37 _this.media.setCurrentTime(ui.value); |
33 _this.player.popcorn.currentTime(ui.value / 1000); |
38 _this.player.trigger("Mediafragment.setHashToTime"); |
34 _this.player.popcorn.trigger("IriSP.Mediafragment.setHashToTime"); |
39 } |
35 } |
40 }); |
36 }); |
41 |
37 |
42 this.$handle = this.$slider.find('.ui-slider-handle'); |
38 this.$handle = this.$slider.find('.ui-slider-handle'); |
43 |
39 |
44 this.onMediaEvent("timeupdate","onTimeupdate"); |
40 this.bindPopcorn("timeupdate","onTimeupdate"); |
45 this.onMdpEvent("Player.MouseOver","onMouseover"); |
41 this.bindPopcorn("IriSP.PlayerWidget.MouseOver","onMouseover"); |
46 this.onMdpEvent("Player.MouseOut","onMouseout"); |
42 this.bindPopcorn("IriSP.PlayerWidget.MouseOut","onMouseout"); |
47 |
43 |
48 if (this.minimize_timeout) { |
44 if (this.minimize_timeout) { |
49 this.$slider.css(this.calculateSliderCss(this.minimized_height)); |
45 this.$slider.css(this.calculateSliderCss(this.minimized_height)); |
50 this.$handle.css(this.calculateHandleCss(this.minimized_height)); |
46 this.$handle.css(this.calculateHandleCss(this.minimized_height)); |
51 |
47 |
|
48 this.$ |
|
49 .mouseover(this.functionWrapper("onMouseover")) |
|
50 .mouseout(this.functionWrapper("onMouseout")); |
|
51 |
52 this.maximized = false; |
52 this.maximized = false; |
53 this.timeoutId = false; |
53 this.timeoutId = false; |
54 } |
54 } |
55 |
|
56 this.$ |
|
57 .mouseover(function() { |
|
58 _this.$time.show(); |
|
59 _this.onMouseover(); |
|
60 }) |
|
61 .mouseout(this.functionWrapper("onMouseout")) |
|
62 .mousemove(function(_e) { |
|
63 var _x = _e.pageX - _this.$.offset().left, |
|
64 _t = new IriSP.Model.Time(_this.media.duration * _x / _this.width); |
|
65 _this.$time.text(_t.toString()).css("left",_x); |
|
66 }); |
|
67 }; |
55 }; |
68 |
56 |
69 IriSP.Widgets.Slider.prototype.onTimeupdate = function(_time) { |
57 IriSP.Widgets.Slider.prototype.onTimeupdate = function() { |
|
58 var _time = 1000 * this.player.popcorn.currentTime(); |
70 this.$slider.slider("value",_time); |
59 this.$slider.slider("value",_time); |
71 this.player.trigger("Arrow.updatePosition",{widget: this.type, time: _time}); |
60 this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{widget: this.type, time: _time}); |
72 }; |
61 } |
73 |
62 |
74 IriSP.Widgets.Slider.prototype.onMouseover = function() { |
63 IriSP.Widgets.Slider.prototype.onMouseover = function() { |
75 if (this.minimize_timeout) { |
64 if (this.minimize_timeout) { |
76 if (this.timeoutId) { |
65 if (this.timeoutId) { |
77 window.clearTimeout(this.timeoutId); |
66 window.clearTimeout(this.timeoutId); |
113 this.calculateHandleCss(_height), |
101 this.calculateHandleCss(_height), |
114 500, |
102 500, |
115 function() { |
103 function() { |
116 IriSP.jQuery(this).css("overflow","visible"); |
104 IriSP.jQuery(this).css("overflow","visible"); |
117 }); |
105 }); |
118 }; |
106 } |
119 |
107 |
120 IriSP.Widgets.Slider.prototype.calculateSliderCss = function(_size) { |
108 IriSP.Widgets.Slider.prototype.calculateSliderCss = function(_size) { |
121 return { |
109 return { |
122 height: _size + "px", |
110 height: _size + "px", |
123 "margin-top": (this.minimized_height - _size) + "px" |
111 "margin-top": (this.minimized_height - _size) + "px" |
124 }; |
112 }; |
125 }; |
113 } |
126 |
114 |
127 IriSP.Widgets.Slider.prototype.calculateHandleCss = function(_size) { |
115 IriSP.Widgets.Slider.prototype.calculateHandleCss = function(_size) { |
128 return { |
116 return { |
129 height: (2 + _size) + "px", |
117 height: (2 + _size) + "px", |
130 width: (2 + _size) + "px", |
118 width: (2 + _size) + "px", |
131 "margin-left": -Math.ceil(2 + _size / 2) + "px" |
119 "margin-left": -Math.ceil(2 + _size / 2) + "px" |
132 }; |
120 } |
133 }; |
121 } |