| 1 |
window.vimeography = window.vimeography || {}; |
| 2 |
|
| 3 |
|
| 4 |
/** |
| 5 |
* [utilities2 description] |
| 6 |
* @return {[type]} [description] |
| 7 |
*/ |
| 8 |
window.vimeography.utilities2 = function() { |
| 9 |
this.enable_byline = 0; |
| 10 |
this.enable_title = 0; |
| 11 |
this.enable_portrait = 0; |
| 12 |
this.enable_autoplay = 0; |
| 13 |
this.enable_api = 1; |
| 14 |
|
| 15 |
this.player_id = ''; |
| 16 |
}; |
| 17 |
|
| 18 |
|
| 19 |
/** |
| 20 |
* Return the gallery wrapper for the provided ID |
| 21 |
* |
| 22 |
* @since 1.2.3 |
| 23 |
* @param {[type]} id [description] |
| 24 |
* @return {[type]} [description] |
| 25 |
*/ |
| 26 |
window.vimeography.utilities2.prototype.get_gallery = function( id ) { |
| 27 |
return jQuery('#vimeography-gallery-' + id); |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
/** |
| 32 |
* Sets a custom event to trigger when the Vimeo video |
| 33 |
* has ended |
| 34 |
* |
| 35 |
* If any videos exist, add events |
| 36 |
* |
| 37 |
* If no videos, we need to add events when they are finally retrieved |
| 38 |
* |
| 39 |
* @since 1.2.3 |
| 40 |
* @return {[type]} [description] |
| 41 |
*/ |
| 42 |
window.vimeography.utilities2.prototype.enable_playlist = function(gallery_id) { |
| 43 |
var _self = this; |
| 44 |
$gallery = _self.get_gallery(gallery_id); |
| 45 |
|
| 46 |
/* Wait for the gallery to send a signal */ |
| 47 |
$gallery.on('vimeography/video/ready', function(){ |
| 48 |
var player = jQuery('#' + _self.player_id)[0]; |
| 49 |
|
| 50 |
$f(player).addEvent('ready', function(player_id){ |
| 51 |
var froogaloop = $f(player_id); |
| 52 |
|
| 53 |
froogaloop.addEvent('finish', function(player_id){ |
| 54 |
var gallery = _self.get_gallery(gallery_id); |
| 55 |
gallery.trigger('vimeography/playlist/next'); |
| 56 |
}); |
| 57 |
}); |
| 58 |
}); |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
/** |
| 63 |
* [get_video description] |
| 64 |
* @param {[type]} link [description] |
| 65 |
* @return {[type]} [description] |
| 66 |
*/ |
| 67 |
window.vimeography.utilities2.prototype.get_video = function(link) { |
| 68 |
var endpoint = 'https://vimeo.com/api/oembed.json'; |
| 69 |
|
| 70 |
/* Put together the URL */ |
| 71 |
var url = endpoint |
| 72 |
+ '?url=' + encodeURIComponent(link) |
| 73 |
+ '&byline=' + this.enable_byline |
| 74 |
+ '&title=' + this.enable_title |
| 75 |
+ '&portrait=' + this.enable_portrait |
| 76 |
+ '&autoplay=' + this.enable_autoplay |
| 77 |
+ '&api=' + this.enable_api |
| 78 |
+ '&player_id='+ 'vimeography' + Math.floor(Math.random()*999999) |
| 79 |
+ '&callback=?'; |
| 80 |
|
| 81 |
return jQuery.getJSON(url); |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
/** |
| 86 |
* Sets the iframe DOM ID to the same string that was generated |
| 87 |
* during the oEmbed get_video call |
| 88 |
* |
| 89 |
* @param string html Unmodified iframe HTML |
| 90 |
* @return string html iframe HTML with ID added |
| 91 |
*/ |
| 92 |
window.vimeography.utilities2.prototype.set_video_id = function(html) { |
| 93 |
var regex = /player_id=(vimeography\d+)/g; |
| 94 |
var match = regex.exec(html); |
| 95 |
|
| 96 |
var iframe = jQuery(html).filter('iframe')[0]; |
| 97 |
|
| 98 |
this.player_id = match[1]; |
| 99 |
iframe.id = this.player_id; |
| 100 |
|
| 101 |
return iframe; |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
/** |
| 106 |
* [ description] |
| 107 |
* @param {[type]} html [description] |
| 108 |
* @return {[type]} [description] |
| 109 |
*/ |
| 110 |
window.vimeography.utilities2.prototype.add_fancybox_class = function(html) { |
| 111 |
var iframe = jQuery(html).filter('iframe')[0]; |
| 112 |
iframe.className = 'fancybox-iframe'; |
| 113 |
return iframe; |
| 114 |
} |
| 115 |
|
| 116 |
/** |
| 117 |
* Detect if the current browser is IE11 |
| 118 |
* @return {Boolean} [description] |
| 119 |
*/ |
| 120 |
window.vimeography.utilities2.prototype.is_ie11 = function () { |
| 121 |
return !(window.ActiveXObject) && "ActiveXObject" in window; |
| 122 |
} |