romo-av 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/assets/js/romo-av/audio.js +0 -0
- data/assets/js/romo-av/dropdown_video.js +303 -0
- data/assets/js/romo-av/modal_video.js +312 -0
- data/assets/js/romo-av/video.js +619 -0
- data/lib/romo-av/dassets.rb +38 -0
- data/lib/romo-av/version.rb +4 -0
- data/lib/romo-av.rb +14 -0
- data/log/.gitkeep +0 -0
- data/romo-av.gemspec +24 -0
- data/test/helper.rb +10 -0
- data/test/support/factory.rb +6 -0
- data/test/system/.gitkeep +0 -0
- data/test/unit/dassets_tests.rb +41 -0
- data/test/unit/romo-av_tests.rb +21 -0
- data/tmp/.gitkeep +0 -0
- metadata +120 -0
@@ -0,0 +1,312 @@
|
|
1
|
+
$.fn.romoModalVideo = function() {
|
2
|
+
return $.map(this, function(element) {
|
3
|
+
return new RomoModalVideo(element);
|
4
|
+
});
|
5
|
+
}
|
6
|
+
|
7
|
+
var RomoModalVideo = function(element) {
|
8
|
+
this.elem = $(element);
|
9
|
+
|
10
|
+
this.modal = this.elem.romoModal()[0];
|
11
|
+
this.doBindModal();
|
12
|
+
|
13
|
+
this.video = undefined;
|
14
|
+
this.doBindVideo();
|
15
|
+
this.elem.on('modal:loadBodySuccess', $.proxy(function(e, data, modal) {
|
16
|
+
this.doBindVideo();
|
17
|
+
}, this));
|
18
|
+
|
19
|
+
this.doInit();
|
20
|
+
this.elem.trigger('modalVideo:ready', [this]);
|
21
|
+
}
|
22
|
+
|
23
|
+
RomoModalVideo.prototype.doInit = function() {
|
24
|
+
// override as needed
|
25
|
+
}
|
26
|
+
|
27
|
+
RomoModalVideo.prototype.doBindModal = function() {
|
28
|
+
if (this.elem.data('romo-modal-clear-content') === undefined) {
|
29
|
+
this.elem.attr('data-romo-modal-clear-content', 'true');
|
30
|
+
}
|
31
|
+
|
32
|
+
// modal/video interactions
|
33
|
+
|
34
|
+
this.elem.on('modalVideo:video:loadedmetadata', $.proxy(function(e, videoObj, video, modalVideo) {
|
35
|
+
this.modal.doPlacePopupElem();
|
36
|
+
}, this));
|
37
|
+
|
38
|
+
this.elem.on('modalVideo:video:enterFullscreen', $.proxy(function(e, videoObj, video, modalVideo) {
|
39
|
+
// wait 1 sec then turn off modal body elem events - since we are in fullscreen
|
40
|
+
// mode, we don't care about them
|
41
|
+
setTimeout($.proxy(function() {
|
42
|
+
this.modal.doUnBindWindowBodyClick();
|
43
|
+
this.modal.doUnBindWindowBodyKeyUp();
|
44
|
+
this.modal.doUnBindElemKeyUp();
|
45
|
+
}, this), 1000);
|
46
|
+
}, this));
|
47
|
+
this.elem.on('modalVideo:video:exitFullscreen', $.proxy(function(e, videoObj, video, modalVideo) {
|
48
|
+
// wait 1 sec then turn on modal body elem events - since we are no longer
|
49
|
+
// in fullscreen mode, we need to care about them again
|
50
|
+
setTimeout($.proxy(function() {
|
51
|
+
this.modal.doBindWindowBodyClick();
|
52
|
+
this.modal.doBindWindowBodyKeyUp();
|
53
|
+
this.modal.doBindElemKeyUp();
|
54
|
+
}, this), 1000);
|
55
|
+
}, this));
|
56
|
+
|
57
|
+
// event proxies
|
58
|
+
|
59
|
+
this.elem.on('modal:ready', $.proxy(function(e, modal) {
|
60
|
+
this.elem.trigger('modalVideo:modal:ready', [modal, this]);
|
61
|
+
}, this));
|
62
|
+
this.elem.on('modal:toggle', $.proxy(function(e, modal) {
|
63
|
+
this.elem.trigger('modalVideo:modal:toggle', [modal, this]);
|
64
|
+
}, this));
|
65
|
+
this.elem.on('modal:popupOpen', $.proxy(function(e, modal) {
|
66
|
+
this.elem.trigger('modalVideo:modal:popupOpen', [modal, this]);
|
67
|
+
}, this));
|
68
|
+
this.elem.on('modal:popupClose', $.proxy(function(e, modal) {
|
69
|
+
this.elem.trigger('modalVideo:modal:popupClose', [modal, this]);
|
70
|
+
}, this));
|
71
|
+
this.elem.on('modal:dragStart', $.proxy(function(e, modal) {
|
72
|
+
this.elem.trigger('modalVideo:modal:dragStart', [modal, this]);
|
73
|
+
}, this));
|
74
|
+
this.elem.on('modal:dragMove', $.proxy(function(e, placeX, placeY, modal) {
|
75
|
+
this.elem.trigger('modalVideo:modal:dragMove', [placeX, placeY, modal, this]);
|
76
|
+
}, this));
|
77
|
+
this.elem.on('modal:dragStop', $.proxy(function(e, modal) {
|
78
|
+
this.elem.trigger('modalVideo:modal:dragStop', [modal, this]);
|
79
|
+
}, this));
|
80
|
+
this.elem.on('modal:loadBodyStart', $.proxy(function(e, modal) {
|
81
|
+
this.elem.trigger('modalVideo:modal:loadBodyStart', [modal, this]);
|
82
|
+
}, this));
|
83
|
+
this.elem.on('modal:loadBodySuccess', $.proxy(function(e, data, modal) {
|
84
|
+
this.elem.trigger('modalVideo:modal:loadBodySuccess', [data, modal, this]);
|
85
|
+
}, this));
|
86
|
+
this.elem.on('modal:loadBodyError', $.proxy(function(e, xhr, modal) {
|
87
|
+
this.elem.trigger('modalVideo:modal:loadBodyError', [xhr, modal, this]);
|
88
|
+
}, this));
|
89
|
+
this.elem.on('modal:dismiss', $.proxy(function(e, modal) {
|
90
|
+
this.elem.trigger('modalVideo:modal:dismiss', [modal, this]);
|
91
|
+
}, this));
|
92
|
+
}
|
93
|
+
|
94
|
+
RomoModalVideo.prototype.doBindVideo = function() {
|
95
|
+
var videoElem = this.modal.popupElem.find('[data-romo-video-auto="modalVideo"]');
|
96
|
+
|
97
|
+
this._bindVideoElemEvents(videoElem);
|
98
|
+
this._bindModalVideoTriggerEvents();
|
99
|
+
|
100
|
+
this.video = videoElem.romoVideo()[0];
|
101
|
+
}
|
102
|
+
|
103
|
+
// private
|
104
|
+
|
105
|
+
RomoModalVideo.prototype._bindVideoElemEvents = function(videoElem) {
|
106
|
+
// playback events
|
107
|
+
|
108
|
+
videoElem.on('video:play', $.proxy(function(e, videoObj, video) {
|
109
|
+
this.elem.trigger('modalVideo:video:play', [videoObj, video, this]);
|
110
|
+
}, this));
|
111
|
+
videoElem.on('video:pause', $.proxy(function(e, videoObj, video) {
|
112
|
+
this.elem.trigger('modalVideo:video:pause', [videoObj, video, this]);
|
113
|
+
}, this));
|
114
|
+
|
115
|
+
// state events
|
116
|
+
|
117
|
+
videoElem.on('video:playing', $.proxy(function(e, videoObj, video) {
|
118
|
+
this.elem.trigger('modalVideo:video:playing', [videoObj, video, this]);
|
119
|
+
}, this));
|
120
|
+
videoElem.on('video:waiting', $.proxy(function(e, videoObj, video) {
|
121
|
+
this.elem.trigger('modalVideo:video:waiting', [videoObj, video, this]);
|
122
|
+
}, this));
|
123
|
+
videoElem.on('video:ended', $.proxy(function(e, videoObj, video) {
|
124
|
+
this.elem.trigger('modalVideo:video:ended', [videoObj, video, this]);
|
125
|
+
}, this));
|
126
|
+
videoElem.on('video:emptied', $.proxy(function(e, videoObj, video) {
|
127
|
+
this.elem.trigger('modalVideo:video:emptied', [videoObj, video, this]);
|
128
|
+
}, this));
|
129
|
+
videoElem.on('video:error', $.proxy(function(e, videoObj, video) {
|
130
|
+
this.elem.trigger('modalVideo:video:error', [videoObj, video, this]);
|
131
|
+
}, this));
|
132
|
+
videoElem.on('video:stalled', $.proxy(function(e, videoObj, video) {
|
133
|
+
this.elem.trigger('modalVideo:video:stalled', [videoObj, video, this]);
|
134
|
+
}, this));
|
135
|
+
videoElem.on('video:suspend', $.proxy(function(e, videoObj, video) {
|
136
|
+
this.elem.trigger('modalVideo:video:suspend', [videoObj, video, this]);
|
137
|
+
}, this));
|
138
|
+
|
139
|
+
// status events
|
140
|
+
|
141
|
+
videoElem.on('video:progress', $.proxy(function(e, videoObj, video) {
|
142
|
+
this.elem.trigger('modalVideo:video:progress', [videoObj, video, this]);
|
143
|
+
}, this));
|
144
|
+
videoElem.on('video:timeupdate', $.proxy(function(e, videoObj, video) {
|
145
|
+
this.elem.trigger('modalVideo:video:timeupdate', [videoObj, video, this]);
|
146
|
+
}, this));
|
147
|
+
|
148
|
+
// settings events
|
149
|
+
|
150
|
+
videoElem.on('video:volumechange', $.proxy(function(e, videoObj, video) {
|
151
|
+
this.elem.trigger('modalVideo:video:volumechange', [videoObj, video, this]);
|
152
|
+
}, this));
|
153
|
+
videoElem.on('video:durationchange', $.proxy(function(e, videoObj, video) {
|
154
|
+
this.elem.trigger('modalVideo:video:durationchange', [videoObj, video, this]);
|
155
|
+
}, this));
|
156
|
+
videoElem.on('video:ratechange', $.proxy(function(e, videoObj, video) {
|
157
|
+
this.elem.trigger('modalVideo:video:ratechange', [videoObj, video, this]);
|
158
|
+
}, this));
|
159
|
+
|
160
|
+
// fullscreen events
|
161
|
+
|
162
|
+
videoElem.on('video:enterFullscreen', $.proxy(function(e, videoObj, video) {
|
163
|
+
this.elem.trigger('modalVideo:video:enterFullscreen', [videoObj, video, this]);
|
164
|
+
}, this));
|
165
|
+
videoElem.on('video:exitFullscreen', $.proxy(function(e, videoObj, video) {
|
166
|
+
this.elem.trigger('modalVideo:video:exitFullscreen', [videoObj, video, this]);
|
167
|
+
}, this));
|
168
|
+
videoElem.on('video:fullscreenChange', $.proxy(function(e, videoObj, video) {
|
169
|
+
this.elem.trigger('modalVideo:video:fullscreenChange', [videoObj, video, this]);
|
170
|
+
}, this));
|
171
|
+
|
172
|
+
// load events
|
173
|
+
|
174
|
+
videoElem.on('video:loadstart', $.proxy(function(e, videoObj, video) {
|
175
|
+
this.elem.trigger('modalVideo:video:loadstart', [videoObj, video, this]);
|
176
|
+
}, this));
|
177
|
+
videoElem.on('video:loadedmetadata', $.proxy(function(e, videoObj, video) {
|
178
|
+
this.elem.trigger('modalVideo:video:loadedmetadata', [videoObj, video, this]);
|
179
|
+
}, this));
|
180
|
+
videoElem.on('video:loadeddata', $.proxy(function(e, videoObj, video) {
|
181
|
+
this.elem.trigger('modalVideo:video:loadeddata', [videoObj, video, this]);
|
182
|
+
}, this));
|
183
|
+
videoElem.on('video:canplay', $.proxy(function(e, videoObj, video) {
|
184
|
+
this.elem.trigger('modalVideo:video:canplay', [videoObj, video, this]);
|
185
|
+
}, this));
|
186
|
+
videoElem.on('video:canplaythrough', $.proxy(function(e, videoObj, video) {
|
187
|
+
this.elem.trigger('modalVideo:video:canplaythrough', [videoObj, video, this]);
|
188
|
+
}, this));
|
189
|
+
}
|
190
|
+
|
191
|
+
RomoModalVideo.prototype._bindModalVideoTriggerEvents = function() {
|
192
|
+
// playback triggers
|
193
|
+
|
194
|
+
this.elem.on('modalVideo:video:triggerPlay', $.proxy(function(e) {
|
195
|
+
if (this.video != undefined) {
|
196
|
+
this.video.elem.trigger('video:triggerPlay', []);
|
197
|
+
}
|
198
|
+
}, this));
|
199
|
+
this.elem.on('modalVideo:video:triggerPause', $.proxy(function(e) {
|
200
|
+
if (this.video != undefined) {
|
201
|
+
this.video.elem.trigger('video:triggerPause', []);
|
202
|
+
}
|
203
|
+
}, this));
|
204
|
+
this.elem.on('modalVideo:video:triggerTogglePlay', $.proxy(function(e) {
|
205
|
+
if (this.video != undefined) {
|
206
|
+
this.video.elem.trigger('video:triggerTogglePlay', []);
|
207
|
+
}
|
208
|
+
}, this));
|
209
|
+
this.elem.on('modalVideo:video:triggerSetPlaybackToTime', $.proxy(function(e, secondNum) {
|
210
|
+
if (this.video != undefined) {
|
211
|
+
this.video.elem.trigger('video:triggerSetPlaybackToTime', [secondNum]);
|
212
|
+
}
|
213
|
+
}, this));
|
214
|
+
this.elem.on('modalVideo:video:triggerSetPlaybackToFrame', $.proxy(function(e, frameNum) {
|
215
|
+
if (this.video != undefined) {
|
216
|
+
this.video.elem.trigger('video:triggerSetPlaybackToFrame', [frameNum]);
|
217
|
+
}
|
218
|
+
}, this));
|
219
|
+
this.elem.on('modalVideo:video:triggerSetPlaybackToPercent', $.proxy(function(e, percent) {
|
220
|
+
if (this.video != undefined) {
|
221
|
+
this.video.elem.trigger('video:triggerSetPlaybackToPercent', [percent]);
|
222
|
+
}
|
223
|
+
}, this));
|
224
|
+
this.elem.on('modalVideo:video:triggerModPlaybackByTime', $.proxy(function(e, secondsCount) {
|
225
|
+
if (this.video != undefined) {
|
226
|
+
this.video.elem.trigger('video:triggerModPlaybackByTime', [secondsCount]);
|
227
|
+
}
|
228
|
+
}, this));
|
229
|
+
this.elem.on('modalVideo:video:triggerModPlaybackByFrames', $.proxy(function(e, frameCount) {
|
230
|
+
if (this.video != undefined) {
|
231
|
+
this.video.elem.trigger('video:triggerModPlaybackByFrames', [frameCount]);
|
232
|
+
}
|
233
|
+
}, this));
|
234
|
+
this.elem.on('modalVideo:video:triggerModPlaybackByPercent', $.proxy(function(e, percent) {
|
235
|
+
if (this.video != undefined) {
|
236
|
+
this.video.elem.trigger('video:triggerModPlaybackByPercent', [percent]);
|
237
|
+
}
|
238
|
+
}, this));
|
239
|
+
|
240
|
+
// settings triggers
|
241
|
+
|
242
|
+
this.elem.on('modalVideo:video:triggerMute', $.proxy(function(e) {
|
243
|
+
if (this.video != undefined) {
|
244
|
+
this.video.elem.trigger('video:triggerMute', []);
|
245
|
+
}
|
246
|
+
}, this));
|
247
|
+
this.elem.on('modalVideo:video:triggerUnmute', $.proxy(function(e) {
|
248
|
+
if (this.video != undefined) {
|
249
|
+
this.video.elem.trigger('video:triggerUnmute', []);
|
250
|
+
}
|
251
|
+
}, this));
|
252
|
+
this.elem.on('modalVideo:video:triggerToggleMute', $.proxy(function(e) {
|
253
|
+
if (this.video != undefined) {
|
254
|
+
this.video.elem.trigger('video:triggerToggleMute', []);
|
255
|
+
}
|
256
|
+
}, this));
|
257
|
+
this.elem.on('modalVideo:video:triggerSetVolumeToPercent', $.proxy(function(e, percent) {
|
258
|
+
if (this.video != undefined) {
|
259
|
+
this.video.elem.trigger('video:triggerSetVolumeToPercent', [percent]);
|
260
|
+
}
|
261
|
+
}, this));
|
262
|
+
this.elem.on('modalVideo:video:triggerModVolumeByPercent', $.proxy(function(e, percent) {
|
263
|
+
if (this.video != undefined) {
|
264
|
+
this.video.elem.trigger('video:triggerModVolumeByPercent', [percent]);
|
265
|
+
}
|
266
|
+
}, this));
|
267
|
+
this.elem.on('modalVideo:video:triggerSetPlaybackRate', $.proxy(function(e, rate) {
|
268
|
+
if (this.video != undefined) {
|
269
|
+
this.video.elem.trigger('video:triggerSetPlaybackRate', [rate]);
|
270
|
+
}
|
271
|
+
}, this));
|
272
|
+
this.elem.on('modalVideo:video:triggerModPlaybackRate', $.proxy(function(e, rate) {
|
273
|
+
if (this.video != undefined) {
|
274
|
+
this.video.elem.trigger('video:triggerModPlaybackRate', [rate]);
|
275
|
+
}
|
276
|
+
}, this));
|
277
|
+
|
278
|
+
// fullscreen triggers
|
279
|
+
|
280
|
+
this.elem.on('modalVideo:video:triggerEnterFullscreen', $.proxy(function(e) {
|
281
|
+
if (this.video != undefined) {
|
282
|
+
this.video.elem.trigger('video:triggerEnterFullscreen', []);
|
283
|
+
}
|
284
|
+
}, this));
|
285
|
+
this.elem.on('modalVideo:video:triggerExitFullscreen', $.proxy(function(e) {
|
286
|
+
if (this.video != undefined) {
|
287
|
+
this.video.elem.trigger('video:triggerExitFullscreen', []);
|
288
|
+
}
|
289
|
+
}, this));
|
290
|
+
this.elem.on('modalVideo:video:triggerToggleFullscreen', $.proxy(function(e) {
|
291
|
+
if (this.video != undefined) {
|
292
|
+
this.video.elem.trigger('video:triggerToggleFullscreen', []);
|
293
|
+
}
|
294
|
+
}, this));
|
295
|
+
|
296
|
+
// load triggers
|
297
|
+
|
298
|
+
this.elem.on('modalVideo:video:triggerLoad', $.proxy(function(e) {
|
299
|
+
if (this.video != undefined) {
|
300
|
+
this.video.elem.trigger('video:triggerLoad', []);
|
301
|
+
}
|
302
|
+
}, this));
|
303
|
+
this.elem.on('modalVideo:video:triggerModSource', $.proxy(function(e, source) {
|
304
|
+
if (this.video != undefined) {
|
305
|
+
this.video.elem.trigger('video:triggerModSource', [source]);
|
306
|
+
}
|
307
|
+
}, this));
|
308
|
+
}
|
309
|
+
|
310
|
+
Romo.onInitUI(function(e) {
|
311
|
+
Romo.initUIElems(e, '[data-romo-modalVideo-auto="true"]').romoModalVideo();
|
312
|
+
});
|