audiojs 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,10 @@
1
+ from 'git://github.com/kolber/audiojs.git' do
2
+ file 'vendor/assets/javascripts/audiojs-player-graphics.gif', 'audiojs/player-graphics.gif'
3
+ file 'vendor/assets/javascripts/audiojs.swf', 'audiojs/audiojs.swf'
4
+ file 'vendor/assets/javascripts/audiojs.js.erb', 'audiojs/audio.js' do |path|
5
+ rewrite(path) do |content|
6
+ content.gsub!("imageLocation: path + 'player-graphics.gif'", "imageLocation: <%= asset_path 'audiojs-player-graphics.gif' %>")
7
+ content.gsub!("swfLocation: path + 'audiojs.swf'", "swfLocation: <%= asset_path 'audiojs.swf' %>")
8
+ end
9
+ end
10
+ end
@@ -14,4 +14,6 @@ Gem::Specification.new do |gem|
14
14
  gem.name = "audiojs"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Audiojs::VERSION
17
+
18
+ gem.add_development_dependency('vendorer')
17
19
  end
@@ -1,3 +1,3 @@
1
1
  module Audiojs
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -3,33 +3,24 @@
3
3
  // Use the path to the audio.js file to create relative paths to the swf and player graphics
4
4
  // Remember that some systems (e.g. ruby on rails) append strings like '?1301478336' to asset paths
5
5
  var path = (function() {
6
- var re = new RegExp('([a-zA-Z0-9\-_]+)(\.min)?\.js.*'),
7
- scripts = document.getElementsByTagName('script')
8
- px = '/assets/';
9
-
6
+ var re = new RegExp('audio(\.min)?\.js.*'),
7
+ scripts = document.getElementsByTagName('script');
10
8
  for (var i = 0, ii = scripts.length; i < ii; i++) {
11
9
  var path = scripts[i].getAttribute('src');
12
- if(re.test(path)) {
13
- var _th = path.substring(0,path.lastIndexOf("/")+1);
14
- if (!(typeof _th === 'undefined') || (_th == '')) {
15
- return _th;
16
- }
17
- }
10
+ if(re.test(path)) return path.replace(re, '');
18
11
  }
19
-
20
- return px;
21
12
  })();
22
-
13
+
23
14
  // ##The audiojs interface
24
15
  // This is the global object which provides an interface for creating new `audiojs` instances.
25
16
  // It also stores all of the construction helper methods and variables.
26
17
  container[audiojs] = {
27
18
  instanceCount: 0,
28
19
  instances: {},
29
- // The markup for the swf. It is injected into the page if there is not support for the `<audio>` element. The `$n`s are placeholders.
30
- // `$1` The name of the flash movie
31
- // `$2` The path to the swf
32
- // `$3` Cache invalidation
20
+ // The markup for the swf. It is injected into the page if there is not support for the `<audio>` element. The `$n`s are placeholders.
21
+ // `$1` The name of the flash movie
22
+ // `$2` The path to the swf
23
+ // `$3` Cache invalidation
33
24
  flashSource: '\
34
25
  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="$1" width="1" height="1" name="$1" style="position: absolute; left: -1px;"> \
35
26
  <param name="movie" value="$2?playerInstance='+audiojs+'.instances[\'$1\']&datetime=$3"> \
@@ -43,8 +34,8 @@
43
34
  autoplay: false,
44
35
  loop: false,
45
36
  preload: true,
46
- imageLocation: path + 'audiojs-player-graphics.gif',
47
- swfLocation: path + 'audiojs.swf',
37
+ imageLocation: <%= asset_path 'audiojs-player-graphics.gif' %>,
38
+ swfLocation: <%= asset_path 'audiojs.swf' %>,
48
39
  useFlash: (function() {
49
40
  var a = document.createElement('audio');
50
41
  return !(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, ''));
@@ -196,10 +187,10 @@
196
187
 
197
188
  // ### Contructor functions
198
189
 
199
- // `create()`
200
- // Used to create a single `audiojs` instance.
201
- // If an array is passed then it calls back to `createAll()`.
202
- // Otherwise, it creates a single instance and returns it.
190
+ // `create()`
191
+ // Used to create a single `audiojs` instance.
192
+ // If an array is passed then it calls back to `createAll()`.
193
+ // Otherwise, it creates a single instance and returns it.
203
194
  create: function(element, options) {
204
195
  var options = options || {}
205
196
  if (element.length) {
@@ -209,8 +200,8 @@
209
200
  }
210
201
  },
211
202
 
212
- // `createAll()`
213
- // Creates multiple `audiojs` instances.
203
+ // `createAll()`
204
+ // Creates multiple `audiojs` instances.
214
205
  // If `elements` is `null`, then automatically find any `<audio>` tags on the page and create `audiojs` instances for them.
215
206
  createAll: function(options, elements) {
216
207
  var audioElements = elements || document.getElementsByTagName('audio'),
@@ -357,14 +348,14 @@
357
348
  audio.settings.updatePlayhead.apply(audio, [percent]);
358
349
  }
359
350
  audio['play'] = function() {
360
- // If the audio hasn't started preloading, then start it now.
351
+ // If the audio hasn't started preloading, then start it now.
361
352
  // Then set `preload` to `true`, so that any tracks loaded in subsequently are loaded straight away.
362
353
  if (!audio.settings.preload) {
363
354
  audio.settings.preload = true;
364
355
  audio.element.init(audio.mp3);
365
356
  }
366
357
  audio.playing = true;
367
- // IE doesn't allow a method named `play()` to be exposed through `ExternalInterface`, so lets go with `pplay()`.
358
+ // IE doesn't allow a method named `play()` to be exposed through `ExternalInterface`, so lets go with `pplay()`.
368
359
  // <http://dev.nuclearrooster.com/2008/07/27/externalinterfaceaddcallback-can-cause-ie-js-errors-with-certain-keyworkds/>
369
360
  audio.element.pplay();
370
361
  audio.settings.play.apply(audio);
@@ -403,7 +394,7 @@
403
394
 
404
395
  // ## Helper functions
405
396
  helpers: {
406
- // **Merge two objects, with `obj2` overwriting `obj1`**
397
+ // **Merge two objects, with `obj2` overwriting `obj1`**
407
398
  // The merge is shallow, but that's all that is required for our purposes.
408
399
  merge: function(obj1, obj2) {
409
400
  for (attr in obj2) {
@@ -429,7 +420,7 @@
429
420
  var re = new RegExp('(\\s|^)'+className+'(\\s|$)');
430
421
  element.className = element.className.replace(re,' ');
431
422
  },
432
- // **Dynamic CSS injection**
423
+ // **Dynamic CSS injection**
433
424
  // Takes a string of css, inserts it into a `<style>`, then injects it in at the very top of the `<head>`. This ensures any user-defined styles will take precedence.
434
425
  injectCss: function(audio, string) {
435
426
 
@@ -463,7 +454,7 @@
463
454
  if (firstchild) head.insertBefore(style, firstchild);
464
455
  else head.appendChild(styleElement);
465
456
  },
466
- // **Handle all the IE6+7 requirements for cloning `<audio>` nodes**
457
+ // **Handle all the IE6+7 requirements for cloning `<audio>` nodes**
467
458
  // Create a html5-safe document fragment by injecting an `<audio>` element into the document fragment.
468
459
  cloneHtml5Node: function(audioTag) {
469
460
  var fragment = document.createDocumentFragment(),
@@ -489,7 +480,7 @@
489
480
  // For modern browsers use the standard DOM-compliant `addEventListener`.
490
481
  if (element.addEventListener) {
491
482
  element.addEventListener(eventName, func, false);
492
- // For older versions of Internet Explorer, use `attachEvent`.
483
+ // For older versions of Internet Explorer, use `attachEvent`.
493
484
  // Also provide a fix for scoping `this` to the calling element and register each listener so the containing elements can be purged on page unload.
494
485
  } else if (element.attachEvent) {
495
486
  this.listeners.push(element);
@@ -538,8 +529,8 @@
538
529
  audio.loadTimer = loadTimer;
539
530
  },
540
531
 
541
- // **Douglas Crockford's IE6 memory leak fix**
542
- // <http://javascript.crockford.com/memory/leak.html>
532
+ // **Douglas Crockford's IE6 memory leak fix**
533
+ // <http://javascript.crockford.com/memory/leak.html>
543
534
  // This is used to release the memory leak created by the circular references created when fixing `this` scoping for IE. It is called on page unload.
544
535
  purge: function(d) {
545
536
  var a = d.attributes, i;
@@ -554,7 +545,7 @@
554
545
  }
555
546
  },
556
547
 
557
- // **DOMready function**
548
+ // **DOMready function**
558
549
  // As seen here: <https://github.com/dperini/ContentLoaded/>.
559
550
  ready: (function() { return function(fn) {
560
551
  var win = window, done = false, top = true,
@@ -660,7 +651,7 @@
660
651
  var ios = (/(ipod|iphone|ipad)/i).test(navigator.userAgent);
661
652
  // On iOS this interaction will trigger loading the mp3, so run `init()`.
662
653
  if (ios && this.element.readyState == 0) this.init.apply(this);
663
- // If the audio hasn't started preloading, then start it now.
654
+ // If the audio hasn't started preloading, then start it now.
664
655
  // Then set `preload` to `true`, so that any tracks loaded in subsequently are loaded straight away.
665
656
  if (!this.settings.preload) {
666
657
  this.settings.preload = true;
@@ -686,7 +677,7 @@
686
677
  }
687
678
  }
688
679
 
689
- // **getElementsByClassName**
680
+ // **getElementsByClassName**
690
681
  // Having to rely on `getElementsByTagName` is pretty inflexible internally, so a modified version of Dustin Diaz's `getElementsByClassName` has been included.
691
682
  // This version cleans things up and prefers the native DOM method if it's available.
692
683
  var getByClass = function(searchClass, node) {
@@ -696,7 +687,7 @@
696
687
  if (node.getElementsByClassName) {
697
688
  matches = node.getElementsByClassName(searchClass);
698
689
  } else {
699
- var i, l,
690
+ var i, l,
700
691
  els = node.getElementsByTagName("*"),
701
692
  pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
702
693
 
@@ -709,4 +700,4 @@
709
700
  return matches.length > 1 ? matches : matches[0];
710
701
  };
711
702
  // The global variable names are passed in here and can be changed if they conflict with anything else.
712
- })('audiojs', 'audiojsInstance', this);
703
+ })('audiojs', 'audiojsInstance', this);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audiojs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-12 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2012-11-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: vendorer
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  description: Audio.js on Rails Asset Pipeline
15
31
  email:
16
32
  - subosito@gmail.com
@@ -23,11 +39,12 @@ files:
23
39
  - LICENSE
24
40
  - README.md
25
41
  - Rakefile
42
+ - Vendorfile
26
43
  - audiojs.gemspec
27
44
  - lib/audiojs.rb
28
45
  - lib/audiojs/version.rb
29
46
  - vendor/assets/javascripts/audiojs-player-graphics.gif
30
- - vendor/assets/javascripts/audiojs.js
47
+ - vendor/assets/javascripts/audiojs.js.erb
31
48
  - vendor/assets/javascripts/audiojs.swf
32
49
  homepage: https://github.com/subosito/audiojs
33
50
  licenses: []
@@ -41,21 +58,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
41
58
  - - ! '>='
42
59
  - !ruby/object:Gem::Version
43
60
  version: '0'
44
- segments:
45
- - 0
46
- hash: 2509283403028303442
47
61
  required_rubygems_version: !ruby/object:Gem::Requirement
48
62
  none: false
49
63
  requirements:
50
64
  - - ! '>='
51
65
  - !ruby/object:Gem::Version
52
66
  version: '0'
53
- segments:
54
- - 0
55
- hash: 2509283403028303442
56
67
  requirements: []
57
68
  rubyforge_project:
58
- rubygems_version: 1.8.11
69
+ rubygems_version: 1.8.23
59
70
  signing_key:
60
71
  specification_version: 3
61
72
  summary: audio.js is a drop-in javascript library that allows HTML5's <audio> tag