mirror of
https://github.com/Jermolene/TiddlyWiki5.git
synced 2025-12-27 20:33:08 -08:00
Now there is now longer a dummy DOM element corresponding to the macro itself. Instead, macros must create a single element child. This allows us to more easily fit Bootstrap's requirements for HTML layout (eg, that problem with links in navbars not being recognised). The refactoring isn't complete, there are still a few bugs to chase down
58 lines
1.2 KiB
JavaScript
58 lines
1.2 KiB
JavaScript
/*\
|
|
title: $:/core/modules/macros/video.js
|
|
type: application/javascript
|
|
module-type: macro
|
|
|
|
Video macro
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
exports.info = {
|
|
name: "video",
|
|
params: {
|
|
src: {byName: "default", type: "text"},
|
|
type: {byName: true, type: "text"},
|
|
width: {byName: true, type: "text"},
|
|
height: {byName: true, type: "text"}
|
|
}
|
|
};
|
|
|
|
exports.executeMacro = function() {
|
|
var src = this.params.src,
|
|
videoType = this.params.type || "vimeo",
|
|
videoWidth = this.params.width || 640,
|
|
videoHeight = this.params.height || 360;
|
|
switch(videoType) {
|
|
case "vimeo":
|
|
return $tw.Tree.Element("iframe",{
|
|
src: "http://player.vimeo.com/video/" + src + "?autoplay=0",
|
|
width: videoWidth,
|
|
height: videoHeight,
|
|
frameborder: 0
|
|
});
|
|
case "youtube":
|
|
return $tw.Tree.Element("iframe",{
|
|
type: "text/html",
|
|
src: "http://www.youtube.com/embed/" + src,
|
|
width: videoWidth,
|
|
height: videoHeight,
|
|
frameborder: 0
|
|
});
|
|
case "archiveorg":
|
|
return $tw.Tree.Element("iframe",{
|
|
src: "http://www.archive.org/embed/" + src,
|
|
width: videoWidth,
|
|
height: videoHeight,
|
|
frameborder: 0
|
|
});
|
|
default:
|
|
return null;
|
|
}
|
|
};
|
|
|
|
})();
|