froogaloop 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7101bd0cf381a898dee6b22a28a7459b3f23836e
4
+ data.tar.gz: 3879e8f9c9d9f75686caa58cf5cd929f14586d10
5
+ SHA512:
6
+ metadata.gz: 4341d35fc2ea3507d60132735a163481a4eaa612c84e033a0b8f5ce556cdf2fb808ef04b2085c8f9ff6453df716d6e6147b104f8eaa64b7236a1de512addb9db
7
+ data.tar.gz: 350e7a1be3e93a99a0f376c470b996740ebd78b151928c0e5faa9b3342f6dec21a2d55ac0e971ae4e88b692f0e75a17d740e67600fdaeef5a26875a39e4e117b
@@ -0,0 +1,4 @@
1
+ .DS_Store
2
+ builds
3
+
4
+ .tags
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+ gem 'rails', group: :test
3
+
4
+ gemspec
@@ -0,0 +1,23 @@
1
+
2
+ Copyright (c) 2015 Thomas Barker
3
+
4
+ MIT License
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ "Software"), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # froogaloop
2
+
3
+ ### Installation
4
+
5
+
6
+ Add this line to your `Gemfile`:
7
+ ```
8
+ gem 'froogaloop'
9
+ ```
10
+ And then execute:
11
+ ```
12
+ $ bundle
13
+ ```
14
+
15
+ Or install it yourself as:
16
+ ```
17
+ $ gem install froogaloop
18
+ ```
19
+
20
+ ### Usage
21
+
22
+ You can add froogaloop to your `application.js` file using a require statement like this:
23
+ ```
24
+ //= require jquery.froogaloop
25
+ ```
26
+
27
+ ### License
28
+
29
+ The gem is still under active development and although it is publicly available, we won't be held responsible if you install it in your own project and something goes wrong. Use at your own risk.
30
+
31
+ [License](https://github.com/pwcshipyard/feature_it/blob/master/LICENSE) under the MIT license.
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'froogaloop/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'froogaloop'
8
+ spec.version = Froogaloop::VERSION
9
+ spec.date = '2015-09-01'
10
+ spec.authors = ['Thomas Barker']
11
+ spec.email = ['thomas.john.barker@gmail.com']
12
+ spec.summary = 'JS wrapper for Vimeo videos'
13
+ spec.description = 'JS wrapper for Vimeo videos'
14
+ spec.homepage = 'https://github.com/pwcshipyard/froogaloop'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.7'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ end
@@ -0,0 +1,8 @@
1
+ require 'froogaloop/version'
2
+
3
+ module Froogaloop
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ # Version determinate
2
+ module Froogaloop
3
+ VERSION = '0.0.3'
4
+ end
@@ -0,0 +1,260 @@
1
+ // Init style shamelessly stolen from jQuery http://jquery.com
2
+ var Froogaloop = (function(){
3
+ // Define a local copy of Froogaloop
4
+ function Froogaloop(iframe) {
5
+ // The Froogaloop object is actually just the init constructor
6
+ return new Froogaloop.fn.init(iframe);
7
+ }
8
+
9
+ var eventCallbacks = {},
10
+ hasWindowEvent = false,
11
+ isReady = false,
12
+ slice = Array.prototype.slice,
13
+ playerOrigin = '*';
14
+
15
+ Froogaloop.fn = Froogaloop.prototype = {
16
+ element: null,
17
+
18
+ init: function(iframe) {
19
+ if (typeof iframe === "string") {
20
+ iframe = document.getElementById(iframe);
21
+ }
22
+
23
+ this.element = iframe;
24
+
25
+ return this;
26
+ },
27
+
28
+ /*
29
+ * Calls a function to act upon the player.
30
+ *
31
+ * @param {string} method The name of the Javascript API method to call. Eg: 'play'.
32
+ * @param {Array|Function} valueOrCallback params Array of parameters to pass when calling an API method
33
+ * or callback function when the method returns a value.
34
+ */
35
+ api: function(method, valueOrCallback) {
36
+ if (!this.element || !method) {
37
+ return false;
38
+ }
39
+
40
+ var self = this,
41
+ element = self.element,
42
+ target_id = element.id !== '' ? element.id : null,
43
+ params = !isFunction(valueOrCallback) ? valueOrCallback : null,
44
+ callback = isFunction(valueOrCallback) ? valueOrCallback : null;
45
+
46
+ // Store the callback for get functions
47
+ if (callback) {
48
+ storeCallback(method, callback, target_id);
49
+ }
50
+
51
+ postMessage(method, params, element);
52
+ return self;
53
+ },
54
+
55
+ /*
56
+ * Registers an event listener and a callback function that gets called when the event fires.
57
+ *
58
+ * @param eventName (String): Name of the event to listen for.
59
+ * @param callback (Function): Function that should be called when the event fires.
60
+ */
61
+ addEvent: function(eventName, callback) {
62
+ if (!this.element) {
63
+ return false;
64
+ }
65
+
66
+ var self = this,
67
+ element = self.element,
68
+ target_id = element.id !== '' ? element.id : null;
69
+
70
+
71
+ storeCallback(eventName, callback, target_id);
72
+
73
+ // The ready event is not registered via postMessage. It fires regardless.
74
+ if (eventName != 'ready') {
75
+ postMessage('addEventListener', eventName, element);
76
+ }
77
+ else if (eventName == 'ready' && isReady) {
78
+ callback.call(null, target_id);
79
+ }
80
+
81
+ return self;
82
+ },
83
+
84
+ /*
85
+ * Unregisters an event listener that gets called when the event fires.
86
+ *
87
+ * @param eventName (String): Name of the event to stop listening for.
88
+ */
89
+ removeEvent: function(eventName) {
90
+ if (!this.element) {
91
+ return false;
92
+ }
93
+
94
+ var self = this,
95
+ element = self.element,
96
+ target_id = element.id !== '' ? element.id : null,
97
+ removed = removeCallback(eventName, target_id);
98
+
99
+ // The ready event is not registered
100
+ if (eventName != 'ready' && removed) {
101
+ postMessage('removeEventListener', eventName, element);
102
+ }
103
+ }
104
+ };
105
+
106
+ /**
107
+ * Handles posting a message to the parent window.
108
+ *
109
+ * @param method (String): name of the method to call inside the player. For api calls
110
+ * this is the name of the api method (api_play or api_pause) while for events this method
111
+ * is api_addEventListener.
112
+ * @param params (Object or Array): List of parameters to submit to the method. Can be either
113
+ * a single param or an array list of parameters.
114
+ * @param target (HTMLElement): Target iframe to post the message to.
115
+ */
116
+ function postMessage(method, params, target) {
117
+ if (!target.contentWindow.postMessage) {
118
+ return false;
119
+ }
120
+
121
+ var data = JSON.stringify({
122
+ method: method,
123
+ value: params
124
+ });
125
+
126
+ target.contentWindow.postMessage(data, playerOrigin);
127
+ }
128
+
129
+ /**
130
+ * Event that fires whenever the window receives a message from its parent
131
+ * via window.postMessage.
132
+ */
133
+ function onMessageReceived(event) {
134
+ var data, method;
135
+
136
+ try {
137
+ data = JSON.parse(event.data);
138
+ method = data.event || data.method;
139
+ }
140
+ catch(e) {
141
+ //fail silently... like a ninja!
142
+ }
143
+
144
+ if (method == 'ready' && !isReady) {
145
+ isReady = true;
146
+ }
147
+
148
+ // Handles messages from the vimeo player only
149
+ if (!(/^https?:\/\/player.vimeo.com/).test(event.origin)) {
150
+ return false;
151
+ }
152
+
153
+ if (playerOrigin === '*') {
154
+ playerOrigin = event.origin;
155
+ }
156
+
157
+ var value = data.value,
158
+ eventData = data.data,
159
+ target_id = target_id === '' ? null : data.player_id,
160
+
161
+ callback = getCallback(method, target_id),
162
+ params = [];
163
+
164
+ if (!callback) {
165
+ return false;
166
+ }
167
+
168
+ if (value !== undefined) {
169
+ params.push(value);
170
+ }
171
+
172
+ if (eventData) {
173
+ params.push(eventData);
174
+ }
175
+
176
+ if (target_id) {
177
+ params.push(target_id);
178
+ }
179
+
180
+ return params.length > 0 ? callback.apply(null, params) : callback.call();
181
+ }
182
+
183
+
184
+ /**
185
+ * Stores submitted callbacks for each iframe being tracked and each
186
+ * event for that iframe.
187
+ *
188
+ * @param eventName (String): Name of the event. Eg. api_onPlay
189
+ * @param callback (Function): Function that should get executed when the
190
+ * event is fired.
191
+ * @param target_id (String) [Optional]: If handling more than one iframe then
192
+ * it stores the different callbacks for different iframes based on the iframe's
193
+ * id.
194
+ */
195
+ function storeCallback(eventName, callback, target_id) {
196
+ if (target_id) {
197
+ if (!eventCallbacks[target_id]) {
198
+ eventCallbacks[target_id] = {};
199
+ }
200
+ eventCallbacks[target_id][eventName] = callback;
201
+ }
202
+ else {
203
+ eventCallbacks[eventName] = callback;
204
+ }
205
+ }
206
+
207
+ /**
208
+ * Retrieves stored callbacks.
209
+ */
210
+ function getCallback(eventName, target_id) {
211
+ if (target_id) {
212
+ return eventCallbacks[target_id][eventName];
213
+ }
214
+ else {
215
+ return eventCallbacks[eventName];
216
+ }
217
+ }
218
+
219
+ function removeCallback(eventName, target_id) {
220
+ if (target_id && eventCallbacks[target_id]) {
221
+ if (!eventCallbacks[target_id][eventName]) {
222
+ return false;
223
+ }
224
+ eventCallbacks[target_id][eventName] = null;
225
+ }
226
+ else {
227
+ if (!eventCallbacks[eventName]) {
228
+ return false;
229
+ }
230
+ eventCallbacks[eventName] = null;
231
+ }
232
+
233
+ return true;
234
+ }
235
+
236
+ function isFunction(obj) {
237
+ return !!(obj && obj.constructor && obj.call && obj.apply);
238
+ }
239
+
240
+ function isArray(obj) {
241
+ return toString.call(obj) === '[object Array]';
242
+ }
243
+
244
+ // Give the init function the Froogaloop prototype for later instantiation
245
+ Froogaloop.fn.init.prototype = Froogaloop.fn;
246
+
247
+ // Listens for the message event.
248
+ // W3C
249
+ if (window.addEventListener) {
250
+ window.addEventListener('message', onMessageReceived, false);
251
+ }
252
+ // IE
253
+ else {
254
+ window.attachEvent('onmessage', onMessageReceived);
255
+ }
256
+
257
+ // Expose froogaloop to the global object
258
+ return (window.Froogaloop = window.$f = Froogaloop);
259
+
260
+ })();
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: froogaloop
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Thomas Barker
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: JS wrapper for Vimeo videos
42
+ email:
43
+ - thomas.john.barker@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - froogaloop.gemspec
54
+ - lib/froogaloop.rb
55
+ - lib/froogaloop/version.rb
56
+ - vendor/assets/javascripts/froogaloop.js
57
+ homepage: https://github.com/pwcshipyard/froogaloop
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.4.5.1
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: JS wrapper for Vimeo videos
81
+ test_files: []
82
+ has_rdoc: