romo-av 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.log
3
+ *.rbc
4
+ .rbx/
5
+ .bundle
6
+ .config
7
+ .yardoc
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'rake', "~> 10.4.0"
6
+ gem 'pry', "~> 0.9.0"
7
+
8
+ gem "dassets", '~> 0.11'
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015-Present Kelly Redding and Collin Redding
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # RomoAv
2
+
3
+ Audio/Video components for the [Romo UI Toolkit](https://github.com/redding/romo).
4
+
5
+ ## Usage
6
+
7
+ TODO: Write code samples and usage instructions here
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'romo-av'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install romo-av
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
File without changes
@@ -0,0 +1,303 @@
1
+ $.fn.romoDropdownVideo = function() {
2
+ return $.map(this, function(element) {
3
+ return new RomoDropdownVideo(element);
4
+ });
5
+ }
6
+
7
+ var RomoDropdownVideo = function(element) {
8
+ this.elem = $(element);
9
+
10
+ this.dropdown = this.elem.romoDropdown()[0];
11
+ this.doBindDropdown();
12
+
13
+ this.video = undefined;
14
+ this.doBindVideo();
15
+ this.elem.on('dropdown:loadBodySuccess', $.proxy(function(e, data, dropdown) {
16
+ this.doBindVideo();
17
+ }, this));
18
+
19
+ this.doInit();
20
+ this.elem.trigger('dropdownVideo:ready', [this]);
21
+ }
22
+
23
+ RomoDropdownVideo.prototype.doInit = function() {
24
+ // override as needed
25
+ }
26
+
27
+ RomoDropdownVideo.prototype.doBindDropdown = function() {
28
+ if (this.elem.data('romo-dropdown-clear-content') === undefined) {
29
+ this.elem.attr('data-romo-dropdown-clear-content', 'true');
30
+ }
31
+
32
+ // dropdown/video interactions
33
+
34
+ this.elem.on('dropdownVideo:video:loadedmetadata', $.proxy(function(e, videoObj, video, dropdownVideo) {
35
+ this.dropdown.doPlacePopupElem();
36
+ }, this));
37
+
38
+ this.elem.on('dropdownVideo:video:enterFullscreen', $.proxy(function(e, videoObj, video, dropdownVideo) {
39
+ // wait 1 sec then turn off dropdown body elem events - since we are in fullscreen
40
+ // mode, we don't care about them
41
+ setTimeout($.proxy(function() {
42
+ this.dropdown.doUnBindWindowBodyClick();
43
+ this.dropdown.doUnBindWindowBodyKeyUp();
44
+ this.dropdown.doUnBindElemKeyUp();
45
+ }, this), 1000);
46
+ }, this));
47
+ this.elem.on('dropdownVideo:video:exitFullscreen', $.proxy(function(e, videoObj, video, dropdownVideo) {
48
+ // wait 1 sec then turn on dropdown 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.dropdown.doBindWindowBodyClick();
52
+ this.dropdown.doBindWindowBodyKeyUp();
53
+ this.dropdown.doBindElemKeyUp();
54
+ }, this), 1000);
55
+ }, this));
56
+
57
+ // event proxies
58
+
59
+ this.elem.on('dropdown:ready', $.proxy(function(e, dropdown) {
60
+ this.elem.trigger('dropdownVideo:dropdown:ready', [dropdown, this]);
61
+ }, this));
62
+ this.elem.on('dropdown:toggle', $.proxy(function(e, dropdown) {
63
+ this.elem.trigger('dropdownVideo:dropdown:toggle', [dropdown, this]);
64
+ }, this));
65
+ this.elem.on('dropdown:popupOpen', $.proxy(function(e, dropdown) {
66
+ this.elem.trigger('dropdownVideo:dropdown:popupOpen', [dropdown, this]);
67
+ }, this));
68
+ this.elem.on('dropdown:popupClose', $.proxy(function(e, dropdown) {
69
+ this.elem.trigger('dropdownVideo:dropdown:popupClose', [dropdown, this]);
70
+ }, this));
71
+ this.elem.on('dropdown:loadBodyStart', $.proxy(function(e, dropdown) {
72
+ this.elem.trigger('dropdownVideo:dropdown:loadBodyStart', [dropdown, this]);
73
+ }, this));
74
+ this.elem.on('dropdown:loadBodySuccess', $.proxy(function(e, data, dropdown) {
75
+ this.elem.trigger('dropdownVideo:dropdown:loadBodySuccess', [data, dropdown, this]);
76
+ }, this));
77
+ this.elem.on('dropdown:loadBodyError', $.proxy(function(e, xhr, dropdown) {
78
+ this.elem.trigger('dropdownVideo:dropdown:loadBodyError', [xhr, dropdown, this]);
79
+ }, this));
80
+ this.elem.on('dropdown:dismiss', $.proxy(function(e, dropdown) {
81
+ this.elem.trigger('dropdownVideo:dropdown:dismiss', [dropdown, this]);
82
+ }, this));
83
+ }
84
+
85
+ RomoDropdownVideo.prototype.doBindVideo = function() {
86
+ var videoElem = this.dropdown.popupElem.find('[data-romo-video-auto="dropdownVideo"]');
87
+
88
+ this._bindVideoElemEvents(videoElem);
89
+ this._bindDropdownVideoTriggerEvents();
90
+
91
+ this.video = videoElem.romoVideo()[0];
92
+ }
93
+
94
+ // private
95
+
96
+ RomoDropdownVideo.prototype._bindVideoElemEvents = function(videoElem) {
97
+ // playback events
98
+
99
+ videoElem.on('video:play', $.proxy(function(e, videoObj, video) {
100
+ this.elem.trigger('dropdownVideo:video:play', [videoObj, video, this]);
101
+ }, this));
102
+ videoElem.on('video:pause', $.proxy(function(e, videoObj, video) {
103
+ this.elem.trigger('dropdownVideo:video:pause', [videoObj, video, this]);
104
+ }, this));
105
+
106
+ // state events
107
+
108
+ videoElem.on('video:playing', $.proxy(function(e, videoObj, video) {
109
+ this.elem.trigger('dropdownVideo:video:playing', [videoObj, video, this]);
110
+ }, this));
111
+ videoElem.on('video:waiting', $.proxy(function(e, videoObj, video) {
112
+ this.elem.trigger('dropdownVideo:video:waiting', [videoObj, video, this]);
113
+ }, this));
114
+ videoElem.on('video:ended', $.proxy(function(e, videoObj, video) {
115
+ this.elem.trigger('dropdownVideo:video:ended', [videoObj, video, this]);
116
+ }, this));
117
+ videoElem.on('video:emptied', $.proxy(function(e, videoObj, video) {
118
+ this.elem.trigger('dropdownVideo:video:emptied', [videoObj, video, this]);
119
+ }, this));
120
+ videoElem.on('video:error', $.proxy(function(e, videoObj, video) {
121
+ this.elem.trigger('dropdownVideo:video:error', [videoObj, video, this]);
122
+ }, this));
123
+ videoElem.on('video:stalled', $.proxy(function(e, videoObj, video) {
124
+ this.elem.trigger('dropdownVideo:video:stalled', [videoObj, video, this]);
125
+ }, this));
126
+ videoElem.on('video:suspend', $.proxy(function(e, videoObj, video) {
127
+ this.elem.trigger('dropdownVideo:video:suspend', [videoObj, video, this]);
128
+ }, this));
129
+
130
+ // status events
131
+
132
+ videoElem.on('video:progress', $.proxy(function(e, videoObj, video) {
133
+ this.elem.trigger('dropdownVideo:video:progress', [videoObj, video, this]);
134
+ }, this));
135
+ videoElem.on('video:timeupdate', $.proxy(function(e, videoObj, video) {
136
+ this.elem.trigger('dropdownVideo:video:timeupdate', [videoObj, video, this]);
137
+ }, this));
138
+
139
+ // settings events
140
+
141
+ videoElem.on('video:volumechange', $.proxy(function(e, videoObj, video) {
142
+ this.elem.trigger('dropdownVideo:video:volumechange', [videoObj, video, this]);
143
+ }, this));
144
+ videoElem.on('video:durationchange', $.proxy(function(e, videoObj, video) {
145
+ this.elem.trigger('dropdownVideo:video:durationchange', [videoObj, video, this]);
146
+ }, this));
147
+ videoElem.on('video:ratechange', $.proxy(function(e, videoObj, video) {
148
+ this.elem.trigger('dropdownVideo:video:ratechange', [videoObj, video, this]);
149
+ }, this));
150
+
151
+ // fullscreen events
152
+
153
+ videoElem.on('video:enterFullscreen', $.proxy(function(e, videoObj, video) {
154
+ this.elem.trigger('dropdownVideo:video:enterFullscreen', [videoObj, video, this]);
155
+ }, this));
156
+ videoElem.on('video:exitFullscreen', $.proxy(function(e, videoObj, video) {
157
+ this.elem.trigger('dropdownVideo:video:exitFullscreen', [videoObj, video, this]);
158
+ }, this));
159
+ videoElem.on('video:fullscreenChange', $.proxy(function(e, videoObj, video) {
160
+ this.elem.trigger('dropdownVideo:video:fullscreenChange', [videoObj, video, this]);
161
+ }, this));
162
+
163
+ // load events
164
+
165
+ videoElem.on('video:loadstart', $.proxy(function(e, videoObj, video) {
166
+ this.elem.trigger('dropdownVideo:video:loadstart', [videoObj, video, this]);
167
+ }, this));
168
+ videoElem.on('video:loadedmetadata', $.proxy(function(e, videoObj, video) {
169
+ this.elem.trigger('dropdownVideo:video:loadedmetadata', [videoObj, video, this]);
170
+ }, this));
171
+ videoElem.on('video:loadeddata', $.proxy(function(e, videoObj, video) {
172
+ this.elem.trigger('dropdownVideo:video:loadeddata', [videoObj, video, this]);
173
+ }, this));
174
+ videoElem.on('video:canplay', $.proxy(function(e, videoObj, video) {
175
+ this.elem.trigger('dropdownVideo:video:canplay', [videoObj, video, this]);
176
+ }, this));
177
+ videoElem.on('video:canplaythrough', $.proxy(function(e, videoObj, video) {
178
+ this.elem.trigger('dropdownVideo:video:canplaythrough', [videoObj, video, this]);
179
+ }, this));
180
+ }
181
+
182
+ RomoDropdownVideo.prototype._bindDropdownVideoTriggerEvents = function() {
183
+ // playback triggers
184
+
185
+ this.elem.on('dropdownVideo:video:triggerPlay', $.proxy(function(e) {
186
+ if (this.video != undefined) {
187
+ this.video.elem.trigger('video:triggerPlay', []);
188
+ }
189
+ }, this));
190
+ this.elem.on('dropdownVideo:video:triggerPause', $.proxy(function(e) {
191
+ if (this.video != undefined) {
192
+ this.video.elem.trigger('video:triggerPause', []);
193
+ }
194
+ }, this));
195
+ this.elem.on('dropdownVideo:video:triggerTogglePlay', $.proxy(function(e) {
196
+ if (this.video != undefined) {
197
+ this.video.elem.trigger('video:triggerTogglePlay', []);
198
+ }
199
+ }, this));
200
+ this.elem.on('dropdownVideo:video:triggerSetPlaybackToTime', $.proxy(function(e, secondNum) {
201
+ if (this.video != undefined) {
202
+ this.video.elem.trigger('video:triggerSetPlaybackToTime', [secondNum]);
203
+ }
204
+ }, this));
205
+ this.elem.on('dropdownVideo:video:triggerSetPlaybackToFrame', $.proxy(function(e, frameNum) {
206
+ if (this.video != undefined) {
207
+ this.video.elem.trigger('video:triggerSetPlaybackToFrame', [frameNum]);
208
+ }
209
+ }, this));
210
+ this.elem.on('dropdownVideo:video:triggerSetPlaybackToPercent', $.proxy(function(e, percent) {
211
+ if (this.video != undefined) {
212
+ this.video.elem.trigger('video:triggerSetPlaybackToPercent', [percent]);
213
+ }
214
+ }, this));
215
+ this.elem.on('dropdownVideo:video:triggerModPlaybackByTime', $.proxy(function(e, secondsCount) {
216
+ if (this.video != undefined) {
217
+ this.video.elem.trigger('video:triggerModPlaybackByTime', [secondsCount]);
218
+ }
219
+ }, this));
220
+ this.elem.on('dropdownVideo:video:triggerModPlaybackByFrames', $.proxy(function(e, frameCount) {
221
+ if (this.video != undefined) {
222
+ this.video.elem.trigger('video:triggerModPlaybackByFrames', [frameCount]);
223
+ }
224
+ }, this));
225
+ this.elem.on('dropdownVideo:video:triggerModPlaybackByPercent', $.proxy(function(e, percent) {
226
+ if (this.video != undefined) {
227
+ this.video.elem.trigger('video:triggerModPlaybackByPercent', [percent]);
228
+ }
229
+ }, this));
230
+
231
+ // settings triggers
232
+
233
+ this.elem.on('dropdownVideo:video:triggerMute', $.proxy(function(e) {
234
+ if (this.video != undefined) {
235
+ this.video.elem.trigger('video:triggerMute', []);
236
+ }
237
+ }, this));
238
+ this.elem.on('dropdownVideo:video:triggerUnmute', $.proxy(function(e) {
239
+ if (this.video != undefined) {
240
+ this.video.elem.trigger('video:triggerUnmute', []);
241
+ }
242
+ }, this));
243
+ this.elem.on('dropdownVideo:video:triggerToggleMute', $.proxy(function(e) {
244
+ if (this.video != undefined) {
245
+ this.video.elem.trigger('video:triggerToggleMute', []);
246
+ }
247
+ }, this));
248
+ this.elem.on('dropdownVideo:video:triggerSetVolumeToPercent', $.proxy(function(e, percent) {
249
+ if (this.video != undefined) {
250
+ this.video.elem.trigger('video:triggerSetVolumeToPercent', [percent]);
251
+ }
252
+ }, this));
253
+ this.elem.on('dropdownVideo:video:triggerModVolumeByPercent', $.proxy(function(e, percent) {
254
+ if (this.video != undefined) {
255
+ this.video.elem.trigger('video:triggerModVolumeByPercent', [percent]);
256
+ }
257
+ }, this));
258
+ this.elem.on('dropdownVideo:video:triggerSetPlaybackRate', $.proxy(function(e, rate) {
259
+ if (this.video != undefined) {
260
+ this.video.elem.trigger('video:triggerSetPlaybackRate', [rate]);
261
+ }
262
+ }, this));
263
+ this.elem.on('dropdownVideo:video:triggerModPlaybackRate', $.proxy(function(e, rate) {
264
+ if (this.video != undefined) {
265
+ this.video.elem.trigger('video:triggerModPlaybackRate', [rate]);
266
+ }
267
+ }, this));
268
+
269
+ // fullscreen triggers
270
+
271
+ this.elem.on('dropdownVideo:video:triggerEnterFullscreen', $.proxy(function(e) {
272
+ if (this.video != undefined) {
273
+ this.video.elem.trigger('video:triggerEnterFullscreen', []);
274
+ }
275
+ }, this));
276
+ this.elem.on('dropdownVideo:video:triggerExitFullscreen', $.proxy(function(e) {
277
+ if (this.video != undefined) {
278
+ this.video.elem.trigger('video:triggerExitFullscreen', []);
279
+ }
280
+ }, this));
281
+ this.elem.on('dropdownVideo:video:triggerToggleFullscreen', $.proxy(function(e) {
282
+ if (this.video != undefined) {
283
+ this.video.elem.trigger('video:triggerToggleFullscreen', []);
284
+ }
285
+ }, this));
286
+
287
+ // load triggers
288
+
289
+ this.elem.on('dropdownVideo:video:triggerLoad', $.proxy(function(e) {
290
+ if (this.video != undefined) {
291
+ this.video.elem.trigger('video:triggerLoad', []);
292
+ }
293
+ }, this));
294
+ this.elem.on('dropdownVideo:video:triggerModSource', $.proxy(function(e, source) {
295
+ if (this.video != undefined) {
296
+ this.video.elem.trigger('video:triggerModSource', [source]);
297
+ }
298
+ }, this));
299
+ }
300
+
301
+ Romo.onInitUI(function(e) {
302
+ Romo.initUIElems(e, '[data-romo-dropdownVideo-auto="true"]').romoDropdownVideo();
303
+ });