first import
This commit is contained in:
5
sites/all/modules/media_vimeo/js/flash_detect_min.js
Normal file
5
sites/all/modules/media_vimeo/js/flash_detect_min.js
Normal file
@@ -0,0 +1,5 @@
|
||||
//http://www.featureblend.com/license.txt
|
||||
var FlashDetect=new function(){var self=this;self.installed=false;self.raw="";self.major=-1;self.minor=-1;self.revision=-1;self.revisionStr="";var activeXDetectRules=[{"name":"ShockwaveFlash.ShockwaveFlash.7","version":function(obj){return getActiveXVersion(obj);}},{"name":"ShockwaveFlash.ShockwaveFlash.6","version":function(obj){var version="6,0,21";try{obj.AllowScriptAccess="always";version=getActiveXVersion(obj);}catch(err){}
|
||||
return version;}},{"name":"ShockwaveFlash.ShockwaveFlash","version":function(obj){return getActiveXVersion(obj);}}];var getActiveXVersion=function(activeXObj){var version=-1;try{version=activeXObj.GetVariable("$version");}catch(err){}
|
||||
return version;};var getActiveXObject=function(name){var obj=-1;try{obj=new ActiveXObject(name);}catch(err){obj={activeXError:true};}
|
||||
return obj;};var parseActiveXVersion=function(str){var versionArray=str.split(",");return{"raw":str,"major":parseInt(versionArray[0].split(" ")[1],10),"minor":parseInt(versionArray[1],10),"revision":parseInt(versionArray[2],10),"revisionStr":versionArray[2]};};var parseStandardVersion=function(str){var descParts=str.split(/ +/);var majorMinor=descParts[2].split(/\./);var revisionStr=descParts[3];return{"raw":str,"major":parseInt(majorMinor[0],10),"minor":parseInt(majorMinor[1],10),"revisionStr":revisionStr,"revision":parseRevisionStrToInt(revisionStr)};};var parseRevisionStrToInt=function(str){return parseInt(str.replace(/[a-zA-Z]/g,""),10)||self.revision;};self.majorAtLeast=function(version){return self.major>=version;};self.minorAtLeast=function(version){return self.minor>=version;};self.revisionAtLeast=function(version){return self.revision>=version;};self.versionAtLeast=function(major){var properties=[self.major,self.minor,self.revision];var len=Math.min(properties.length,arguments.length);for(i=0;i<len;i++){if(properties[i]>=arguments[i]){if(i+1<len&&properties[i]==arguments[i]){continue;}else{return true;}}else{return false;}}};self.FlashDetect=function(){if(navigator.plugins&&navigator.plugins.length>0){var type='application/x-shockwave-flash';var mimeTypes=navigator.mimeTypes;if(mimeTypes&&mimeTypes[type]&&mimeTypes[type].enabledPlugin&&mimeTypes[type].enabledPlugin.description){var version=mimeTypes[type].enabledPlugin.description;var versionObj=parseStandardVersion(version);self.raw=versionObj.raw;self.major=versionObj.major;self.minor=versionObj.minor;self.revisionStr=versionObj.revisionStr;self.revision=versionObj.revision;self.installed=true;}}else if(navigator.appVersion.indexOf("Mac")==-1&&window.execScript){var version=-1;for(var i=0;i<activeXDetectRules.length&&version==-1;i++){var obj=getActiveXObject(activeXDetectRules[i].name);if(!obj.activeXError){self.installed=true;version=activeXDetectRules[i].version(obj);if(version!=-1){var versionObj=parseActiveXVersion(version);self.raw=versionObj.raw;self.major=versionObj.major;self.minor=versionObj.minor;self.revision=versionObj.revision;self.revisionStr=versionObj.revisionStr;}}}}}();};FlashDetect.JS_RELEASE="1.0.4";
|
127
sites/all/modules/media_vimeo/js/media_vimeo.fromurl.js
Normal file
127
sites/all/modules/media_vimeo/js/media_vimeo.fromurl.js
Normal file
@@ -0,0 +1,127 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Create the 'Vimeo' tab for the WYSIWYG plugins.
|
||||
*/
|
||||
|
||||
// (function ($) {
|
||||
// namespace('Drupal.media.browser.plugin');
|
||||
//
|
||||
// Drupal.media.browser.plugin.media_vimeo = function(mediaBrowser, options) {
|
||||
// return {
|
||||
// init: function() {
|
||||
// tabset = mediaBrowser.getTabset();
|
||||
// tabset.tabs('add', '#media_vimeo', 'Vimeo');
|
||||
// mediaBrowser.listen('tabs.show', function (e, id) {
|
||||
// if (id == 'media_vimeo') {
|
||||
// // We only need to set this once.
|
||||
// // We probably could set it upon load.
|
||||
// if (mediaBrowser.getActivePanel().html() == '') {
|
||||
// mediaBrowser.getActivePanel().html(options.media_vimeo);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// // For now, I guess self registration makes sense.
|
||||
// // Really though, we should be doing it via drupal_add_js and some settings
|
||||
// // from the drupal variable.
|
||||
// //@todo: needs a review.
|
||||
// Drupal.media.browser.register('media_vimeo', Drupal.media.browser.plugin.media_vimeo, {});
|
||||
// })(jQuery);
|
||||
|
||||
(function ($) {
|
||||
namespace('media.browser.plugin');
|
||||
|
||||
Drupal.media.browser.plugin.vimeo_library = function(mediaBrowser, options) {
|
||||
|
||||
return {
|
||||
mediaFiles: [],
|
||||
init: function() {
|
||||
tabset = mediaBrowser.getTabset();
|
||||
tabset.tabs('add', '#vimeo_library', 'Vimeo');
|
||||
var that = this;
|
||||
mediaBrowser.listen('tabs.show', function (e, id) {
|
||||
if (id == 'vimeo_library') {
|
||||
// This is kinda rough, I'm not sure who should delegate what here.
|
||||
mediaBrowser.getActivePanel().addClass('throbber');
|
||||
mediaBrowser.getActivePanel().html('');
|
||||
//mediaBrowser.getActivePanel().addClass('throbber');
|
||||
|
||||
// Assumes we have to refresh everytime.
|
||||
// Remove any existing content
|
||||
mediaBrowser.getActivePanel().append('<ul></ul>');
|
||||
that.browser = $('ul', mediaBrowser.getActivePanel());
|
||||
that.browser.addClass('clearfix');
|
||||
that.getMedia();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
getStreams: function () {
|
||||
return ['vimeo://'];
|
||||
},
|
||||
|
||||
getConditions: function () {
|
||||
return {};
|
||||
//return this.settings.conditions;
|
||||
},
|
||||
|
||||
getMedia: function() {
|
||||
var that = this;
|
||||
var callback = mediaBrowser.getCallbackUrl('getMedia');
|
||||
var params = {
|
||||
conditions: JSON.stringify(this.getConditions()),
|
||||
streams: JSON.stringify(this.getStreams())
|
||||
};
|
||||
jQuery.get(
|
||||
callback,
|
||||
params,
|
||||
function(data, status) {
|
||||
that.mediaFiles = data.media;
|
||||
that.emptyMessage = data.empty;
|
||||
that.pager = data.pager;
|
||||
that.render();
|
||||
},
|
||||
'json'
|
||||
);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var that = this;
|
||||
mediaBrowser.getActivePanel().removeClass('throbber');
|
||||
if (this.mediaFiles.length < 1) {
|
||||
jQuery('<div id="media-empty-message" class="media-empty-message"></div>').appendTo(this.browser)
|
||||
.html(this.emptyMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
for (var m in this.mediaFiles) {
|
||||
mediaFile = this.mediaFiles[m];
|
||||
|
||||
var listItem = jQuery('<li></li>').appendTo(this.browser)
|
||||
.attr('id', 'media-file-' + mediaFile.fid)
|
||||
.addClass('media-file');
|
||||
|
||||
var imgLink = jQuery('<a href="#"></a>').appendTo(listItem)
|
||||
.html(mediaFile.preview)
|
||||
.bind('click', mediaFile, function(e) {
|
||||
// Notify the main browser
|
||||
//this.selectedMedia = mediaFile;
|
||||
$('div.media-thumbnail img').removeClass('selected');
|
||||
$('div.media-thumbnail img', $(this)).addClass('selected');
|
||||
mediaBrowser.notify('mediaSelected', {mediaFiles: [e.data]});
|
||||
//that.settings.onSelect(mediaFile);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
jQuery('<div id="media-pager" class="media-pager"></div>').appendTo(this.browser)
|
||||
.html(this.pager);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Drupal.media.browser.register('vimeo_library', Drupal.media.browser.plugin.vimeo_library);
|
||||
})(jQuery);
|
106
sites/all/modules/media_vimeo/js/media_vimeo.js
Normal file
106
sites/all/modules/media_vimeo/js/media_vimeo.js
Normal file
@@ -0,0 +1,106 @@
|
||||
|
||||
/**
|
||||
* @file media_vimeo/js/media_vimeo.js
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
|
||||
Drupal.media_vimeo = {};
|
||||
Drupal.behaviors.media_vimeo = {
|
||||
attach: function (context, settings) {
|
||||
// Check the browser to see if it supports html5 video.
|
||||
var video = document.createElement('video');
|
||||
var html5 = video.canPlayType ? true : false;
|
||||
|
||||
// If it has video, does it support the correct codecs?
|
||||
if (html5) {
|
||||
html5 = false;
|
||||
if (video.canPlayType( 'video/webm; codecs="vp8, vorbis"' ) || video.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"')) {
|
||||
html5 = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Put a prompt in the video wrappers to let users know they need flash
|
||||
if (!FlashDetect.installed && !html5){
|
||||
$('.media-vimeo-preview-wrapper').each(Drupal.media_vimeo.needFlash);
|
||||
}
|
||||
|
||||
// Replace all object tags with iframes.
|
||||
if (Drupal.settings && Drupal.settings.media_vimeo) {
|
||||
for (video in Drupal.settings.media_vimeo) {
|
||||
Drupal.media_vimeo.insertEmbed(video);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.media_vimeo.needFlash = function () {
|
||||
var id = $(this).attr('id');
|
||||
var wrapper = $('.media-vimeo-preview-wrapper');
|
||||
var hw = Drupal.settings.media_vimeo[id].height / Drupal.settings.media_vimeo[id].width;
|
||||
wrapper.html('<div class="js-fallback">' + Drupal.t('You need Flash to watch this video. <a href="@flash">Get Flash</a>', {'@flash':'http://get.adobe.com/flashplayer'}) + '</div>');
|
||||
wrapper.height(wrapper.width() * hw);
|
||||
};
|
||||
|
||||
Drupal.media_vimeo.insertEmbed = function (embed_id) {
|
||||
var videoWrapper = $('#' + embed_id + '.media-vimeo-preview-wrapper');
|
||||
var settings = Drupal.settings.media_vimeo[embed_id];
|
||||
|
||||
// Calculate the ratio of the dimensions of the embed.
|
||||
settings.hw = settings.height / settings.width;
|
||||
|
||||
// Replace the object embed with Vimeo's iframe. This isn't done by the
|
||||
// theme function because Vimeo doesn't have a no-JS or no-Flash fallback.
|
||||
var video = $('<iframe class="vimeo-player" type="text/html" frameborder="0"></iframe>');
|
||||
var src = 'http://player.vimeo.com/video/' + settings.video_id;
|
||||
|
||||
// Allow other modules to modify the video settings.
|
||||
settings.options = settings.options || {};
|
||||
$(window).trigger('media_vimeo_load', settings);
|
||||
|
||||
// Merge Vimeo options (such as autoplay) into the source URL.
|
||||
var query = $.param(settings.options);
|
||||
if (query) {
|
||||
src += '?' + query;
|
||||
}
|
||||
|
||||
// Set up the iframe with its contents and add it to the page.
|
||||
video
|
||||
.attr('id', settings.id)
|
||||
.attr('width', settings.width)
|
||||
.attr('height', settings.height)
|
||||
.attr('src', src);
|
||||
videoWrapper.html(video);
|
||||
|
||||
// Bind a resize event to handle fluid layouts.
|
||||
$(window).bind('resize', Drupal.media_vimeo.resizeEmbeds);
|
||||
|
||||
// For some reason Chrome does not properly size the container around the
|
||||
// embed and it will just render the embed at full size unless we set this
|
||||
// timeout.
|
||||
if (!$('.lightbox-stack').length) {
|
||||
setTimeout(Drupal.media_vimeo.resizeEmbeds, 1);
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.media_vimeo.resizeEmbeds = function () {
|
||||
$('.media-vimeo-preview-wrapper').each(Drupal.media_vimeo.resizeEmbed);
|
||||
};
|
||||
|
||||
Drupal.media_vimeo.resizeEmbed = function () {
|
||||
var context = $(this).parent();
|
||||
var video = $(this).children(':first-child');
|
||||
var hw = Drupal.settings.media_vimeo[$(this).attr('id')].hw;
|
||||
// Change the height of the wrapper that was given a fixed height by the
|
||||
// Vimeo theming function.
|
||||
$(this)
|
||||
.height(context.width() * hw)
|
||||
.width(context.width());
|
||||
|
||||
// Change the attributes on the embed to match the new size.
|
||||
video
|
||||
.height(context.width() * hw)
|
||||
.width(context.width());
|
||||
};
|
||||
|
||||
})(jQuery);
|
Reference in New Issue
Block a user