[Midnightbsd-cvs] www: src/player: for new site revision
smultron at midnightbsd.org
smultron at midnightbsd.org
Fri Sep 5 15:09:00 EDT 2008
Log Message:
-----------
for new site revision
Added Files:
-----------
www/shadowbox/src/player:
shadowbox-flv.js (r1.1)
shadowbox-html.js (r1.1)
shadowbox-iframe.js (r1.1)
shadowbox-img.js (r1.1)
shadowbox-qt.js (r1.1)
shadowbox-swf.js (r1.1)
shadowbox-wmp.js (r1.1)
-------------- next part --------------
--- /dev/null
+++ shadowbox/src/player/shadowbox-wmp.js
@@ -0,0 +1,120 @@
+/**
+ * The Shadowbox Windows Media player class.
+ *
+ * This file is part of Shadowbox.
+ *
+ * Shadowbox is an online media viewer application that supports all of the
+ * web's most popular media publishing formats. Shadowbox is written entirely
+ * in JavaScript and CSS and is highly customizable. Using Shadowbox, website
+ * authors can showcase a wide assortment of media in all major browsers without
+ * navigating users away from the linking page.
+ *
+ * Shadowbox is released under version 3.0 of the Creative Commons Attribution-
+ * Noncommercial-Share Alike license. This means that it is absolutely free
+ * for personal, noncommercial use provided that you 1) make attribution to the
+ * author and 2) release any derivative work under the same or a similar
+ * license.
+ *
+ * If you wish to use Shadowbox for commercial purposes, licensing information
+ * can be found at http://mjijackson.com/shadowbox/.
+ *
+ * @author Michael J. I. Jackson <mjijackson at gmail.com>
+ * @copyright 2007-2008 Michael J. I. Jackson
+ * @license http://creativecommons.org/licenses/by-nc-sa/3.0/
+ * @version SVN: $Id: shadowbox-wmp.js 99 2008-05-11 16:22:43Z mjijackson $
+ */
+
+(function(){
+
+ // shorthand
+ var SB = Shadowbox;
+ var SL = SB.lib;
+ var C = SB.getClient();
+
+ /**
+ * Constructor. This class is used to display Windows Media Player movies.
+ *
+ * @param {String} id The id to use for this content
+ * @param {Object} obj The content object
+ * @public
+ */
+ Shadowbox.wmp = function(id, obj){
+ this.id = id;
+ this.obj = obj;
+
+ // height defaults to 300 pixels
+ this.height = this.obj.height ? parseInt(this.obj.height, 10) : 300;
+ if(SB.getOptions().showMovieControls){
+ // add height of WMP controller in IE or non-IE respectively
+ this.height += (C.isIE ? 70 : 45);
+ }
+
+ // width defaults to 300 pixels
+ this.width = this.obj.width ? parseInt(this.obj.width, 10) : 300;
+ };
+
+ Shadowbox.wmp.prototype = {
+
+ /**
+ * Returns an object containing the markup for this content, suitable
+ * to pass to Shadowbox.lib.createHTML().
+ *
+ * @param {Object} dims The current Shadowbox dimensions
+ * @return {Object} The markup for this content item
+ * @public
+ */
+ markup: function(dims){
+ var options = SB.getOptions();
+ var autoplay = options.autoplayMovies ? 1 : 0;
+
+ var markup = {
+ tag: 'object',
+ id: this.id,
+ name: this.id,
+ height: this.height, // height includes controller
+ width: this.width,
+ children: [
+ { tag: 'param', name: 'autostart', value: autoplay }
+ ]
+ };
+ if(C.isIE){
+ var controls = options.showMovieControls ? 'full' : 'none';
+ // markup.type = 'application/x-oleobject';
+ markup.classid = 'clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6';
+ markup.children[markup.children.length] = { tag: 'param', name: 'url', value: this.obj.content };
+ markup.children[markup.children.length] = { tag: 'param', name: 'uimode', value: controls };
+ }else{
+ var controls = options.showMovieControls ? 1 : 0;
+ markup.type = 'video/x-ms-wmv';
+ markup.data = this.obj.content;
+ markup.children[markup.children.length] = { tag: 'param', name: 'showcontrols', value: controls };
+ }
+
+ return markup;
+ },
+
+ /**
+ * Removes this movie from the document.
+ *
+ * @return void
+ * @public
+ */
+ remove: function(){
+ if(C.isIE){
+ try{
+ window[this.id].controls.stop(); // stop the movie
+ window[this.id].URL = 'non-existent.wmv'; // force player refresh
+ window[this.id] = function(){}; // remove from window object
+ }catch(e){}
+ }
+ var el = SL.get(this.id);
+ if(el){
+ setTimeout(function(){ // using setTimeout prevents browser crashes with WMP
+ SL.remove(el);
+ }, 10);
+ }
+ }
+
+ };
+
+})();
--- /dev/null
+++ shadowbox/src/player/shadowbox-swf.js
@@ -0,0 +1,94 @@
+/**
+ * The Shadowbox SWF movie player class.
+ *
+ * This file is part of Shadowbox.
+ *
+ * Shadowbox is an online media viewer application that supports all of the
+ * web's most popular media publishing formats. Shadowbox is written entirely
+ * in JavaScript and CSS and is highly customizable. Using Shadowbox, website
+ * authors can showcase a wide assortment of media in all major browsers without
+ * navigating users away from the linking page.
+ *
+ * Shadowbox is released under version 3.0 of the Creative Commons Attribution-
+ * Noncommercial-Share Alike license. This means that it is absolutely free
+ * for personal, noncommercial use provided that you 1) make attribution to the
+ * author and 2) release any derivative work under the same or a similar
+ * license.
+ *
+ * If you wish to use Shadowbox for commercial purposes, licensing information
+ * can be found at http://mjijackson.com/shadowbox/.
+ *
+ * @author Michael J. I. Jackson <mjijackson at gmail.com>
+ * @copyright 2007-2008 Michael J. I. Jackson
+ * @license http://creativecommons.org/licenses/by-nc-sa/3.0/
+ * @version SVN: $Id: shadowbox-swf.js 99 2008-05-11 16:22:43Z mjijackson $
+ */
+
+(function(){
+
+ // shorthand
+ var SB = Shadowbox;
+ var SL = SB.lib;
+
+ /**
+ * Constructor. This class is used to display SWF movies.
+ *
+ * @param {String} id The id to use for this content
+ * @param {Object} obj The content object
+ * @public
+ */
+ Shadowbox.swf = function(id, obj){
+ this.id = id;
+ this.obj = obj;
+
+ // SWF's are resizable
+ this.resizable = true;
+
+ // height defaults to 300 pixels
+ this.height = this.obj.height ? parseInt(this.obj.height, 10) : 300;
+
+ // width defaults to 300 pixels
+ this.width = this.obj.width ? parseInt(this.obj.width, 10) : 300;
+ };
+
+ Shadowbox.swf.prototype = {
+
+ /**
+ * Returns an object containing the markup for this content, suitable
+ * to pass to Shadowbox.lib.createHTML().
+ *
+ * @param {Object} dims The current Shadowbox dimensions
+ * @return {Object} The markup for this content item
+ * @public
+ */
+ markup: function(dims){
+ var bgcolor = SB.getOptions().flashBgColor;
+ return {
+ tag: 'object',
+ id: this.id,
+ name: this.id,
+ type: 'application/x-shockwave-flash',
+ data: this.obj.content,
+ children: [
+ { tag: 'param', name: 'movie', value: this.obj.content },
+ { tag: 'param', name: 'bgcolor', value: bgcolor }
+ ],
+ height: dims.resize_h, // use resized dimensions
+ width: dims.resize_w
+ };
+ },
+
+ /**
+ * Removes this SWF from the document.
+ *
+ * @return void
+ * @public
+ */
+ remove: function(){
+ var el = SL.get(this.id);
+ if(el) SL.remove(el);
+ }
+
+ };
+
+})();
--- /dev/null
+++ shadowbox/src/player/shadowbox-qt.js
@@ -0,0 +1,114 @@
+/**
+ * The Shadowbox QuickTime player class.
+ *
+ * This file is part of Shadowbox.
+ *
+ * Shadowbox is an online media viewer application that supports all of the
+ * web's most popular media publishing formats. Shadowbox is written entirely
+ * in JavaScript and CSS and is highly customizable. Using Shadowbox, website
+ * authors can showcase a wide assortment of media in all major browsers without
+ * navigating users away from the linking page.
+ *
+ * Shadowbox is released under version 3.0 of the Creative Commons Attribution-
+ * Noncommercial-Share Alike license. This means that it is absolutely free
+ * for personal, noncommercial use provided that you 1) make attribution to the
+ * author and 2) release any derivative work under the same or a similar
+ * license.
+ *
+ * If you wish to use Shadowbox for commercial purposes, licensing information
+ * can be found at http://mjijackson.com/shadowbox/.
+ *
+ * @author Michael J. I. Jackson <mjijackson at gmail.com>
+ * @copyright 2007-2008 Michael J. I. Jackson
+ * @license http://creativecommons.org/licenses/by-nc-sa/3.0/
+ * @version SVN: $Id: shadowbox-qt.js 104 2008-06-28 20:09:34Z mjijackson $
+ */
+
+(function(){
+
+ // shorthand
+ var SB = Shadowbox;
+ var SL = SB.lib;
+ var C = SB.getClient();
+
+ /**
+ * Constructor. This class is used to display QuickTime movies.
+ *
+ * @param {String} id The id to use for this content
+ * @param {Object} obj The content object
+ * @public
+ */
+ Shadowbox.qt = function(id, obj){
+ this.id = id;
+ this.obj = obj;
+
+ // height defaults to 300 pixels
+ this.height = this.obj.height ? parseInt(this.obj.height, 10) : 300;
+ if(SB.getOptions().showMovieControls == true){
+ this.height += 16; // height of QuickTime controller
+ }
+
+ // width defaults to 300 pixels
+ this.width = this.obj.width ? parseInt(this.obj.width, 10) : 300;
+ };
+
+ Shadowbox.qt.prototype = {
+
+ /**
+ * Returns an object containing the markup for this content, suitable
+ * to pass to Shadowbox.lib.createHTML().
+ *
+ * @param {Object} dims The current Shadowbox dimensions
+ * @return {Object} The markup for this content item
+ * @public
+ */
+ markup: function(dims){
+ var options = SB.getOptions();
+ var autoplay = String(options.autoplayMovies);
+ var controls = String(options.showMovieControls);
+
+ var markup = {
+ tag: 'object',
+ id: this.id,
+ name: this.id,
+ height: this.height, // height includes controller
+ width: this.width,
+ children: [
+ { tag: 'param', name: 'src', value: this.obj.content },
+ { tag: 'param', name: 'scale', value: 'aspect' },
+ { tag: 'param', name: 'controller', value: controls },
+ { tag: 'param', name: 'autoplay', value: autoplay }
+ ],
+ kioskmode: 'true'
+ };
+ if(C.isIE){
+ markup.classid = 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B';
+ markup.codebase = 'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0';
+ }else{
+ markup.type = 'video/quicktime';
+ markup.data = this.obj.content;
+ }
+
+ return markup;
+ },
+
+ /**
+ * Removes this movie from the document.
+ *
+ * @return void
+ * @public
+ */
+ remove: function(){
+ try{
+ document[this.id].Stop(); // stop QT video stream
+ }catch(e){}
+ var el = SL.get(this.id);
+ if(el){
+ //el.innerHTML = ''; // stop QT audio stream for movies that have not yet loaded
+ SL.remove(el);
+ }
+ }
+
+ };
+
+})();
--- /dev/null
+++ shadowbox/src/player/shadowbox-flv.js
@@ -0,0 +1,121 @@
+/**
+ * The Shadowbox Flash video player class.
+ *
+ * This file is part of Shadowbox.
+ *
+ * Shadowbox is an online media viewer application that supports all of the
+ * web's most popular media publishing formats. Shadowbox is written entirely
+ * in JavaScript and CSS and is highly customizable. Using Shadowbox, website
+ * authors can showcase a wide assortment of media in all major browsers without
+ * navigating users away from the linking page.
+ *
+ * Shadowbox is released under version 3.0 of the Creative Commons Attribution-
+ * Noncommercial-Share Alike license. This means that it is absolutely free
+ * for personal, noncommercial use provided that you 1) make attribution to the
+ * author and 2) release any derivative work under the same or a similar
+ * license.
+ *
+ * If you wish to use Shadowbox for commercial purposes, licensing information
+ * can be found at http://mjijackson.com/shadowbox/.
+ *
+ * @author Michael J. I. Jackson <mjijackson at gmail.com>
+ * @copyright 2007-2008 Michael J. I. Jackson
+ * @license http://creativecommons.org/licenses/by-nc-sa/3.0/
+ * @version SVN: $Id: shadowbox-flv.js 99 2008-05-11 16:22:43Z mjijackson $
+ */
+
+(function(){
+
+ // shorthand
+ var SB = Shadowbox;
+ var SL = SB.lib;
+
+ /**
+ * Constructor. This class is used to display Flash videos with the JW
+ * FLV player.
+ *
+ * @param {String} id The id to use for this content
+ * @param {Object} obj The content object
+ * @public
+ */
+ Shadowbox.flv = function(id, obj){
+ this.id = id;
+ this.obj = obj;
+
+ // FLV's are resizable
+ this.resizable = true;
+
+ // height defaults to 300 pixels
+ this.height = this.obj.height ? parseInt(this.obj.height, 10) : 300;
+ if(SB.getOptions().showMovieControls == true){
+ this.height += 20; // height of JW FLV player controller
+ }
+
+ // width defaults to 300 pixels
+ this.width = this.obj.width ? parseInt(this.obj.width, 10) : 300;
+ };
+
+ Shadowbox.flv.prototype = {
+
+ /**
+ * Returns an object containing the markup for this content, suitable
+ * to pass to Shadowbox.lib.createHTML().
+ *
+ * @param {Object} dims The current Shadowbox dimensions
+ * @return {Object} The markup for this content item
+ * @public
+ */
+ markup: function(dims){
+ var obj = this.obj;
+
+ // use resized dimensions
+ var h = dims.resize_h;
+ var w = dims.resize_w;
+
+ var options = SB.getOptions();
+ var autoplay = String(options.autoplayMovies);
+ var controls = options.showMovieControls;
+ var showicons = String(controls);
+ var displayheight = h - (controls ? 20 : 0); // subtract controller height
+ var flashvars = [
+ 'file=' + this.obj.content,
+ 'height=' + h,
+ 'width=' + w,
+ 'autostart=' + autoplay,
+ 'displayheight=' + displayheight,
+ 'showicons=' + showicons,
+ 'backcolor=0x000000',
+ 'frontcolor=0xCCCCCC',
+ 'lightcolor=0x557722'
+ ];
+
+ return {
+ tag: 'object',
+ id: this.id,
+ name: this.id,
+ type: 'application/x-shockwave-flash',
+ data: options.flvPlayer,
+ children: [
+ { tag: 'param', name: 'movie', value: options.flvPlayer },
+ { tag: 'param', name: 'flashvars', value: flashvars.join('&') },
+ { tag: 'param', name: 'allowfullscreen', value: 'true' }
+ ],
+ height: h, // new height includes controller
+ width: w
+ };
+ },
+
+ /**
+ * Removes this movie from the document.
+ *
+ * @return void
+ * @public
+ */
+ remove: function(){
+ var el = SL.get(this.id);
+ if(el) SL.remove(el);
+ }
+
+ };
+
+})();
--- /dev/null
+++ shadowbox/src/player/shadowbox-img.js
@@ -0,0 +1,269 @@
+/**
+ * The Shadowbox image player class.
+ *
+ * This file is part of Shadowbox.
+ *
+ * Shadowbox is an online media viewer application that supports all of the
+ * web's most popular media publishing formats. Shadowbox is written entirely
+ * in JavaScript and CSS and is highly customizable. Using Shadowbox, website
+ * authors can showcase a wide assortment of media in all major browsers without
+ * navigating users away from the linking page.
+ *
+ * Shadowbox is released under version 3.0 of the Creative Commons Attribution-
+ * Noncommercial-Share Alike license. This means that it is absolutely free
+ * for personal, noncommercial use provided that you 1) make attribution to the
+ * author and 2) release any derivative work under the same or a similar
+ * license.
+ *
+ * If you wish to use Shadowbox for commercial purposes, licensing information
+ * can be found at http://mjijackson.com/shadowbox/.
+ *
+ * @author Michael J. I. Jackson <mjijackson at gmail.com>
+ * @copyright 2007-2008 Michael J. I. Jackson
+ * @license http://creativecommons.org/licenses/by-nc-sa/3.0/
+ * @version SVN: $Id: shadowbox-img.js 103 2008-06-27 06:19:21Z mjijackson $
+ */
+
+(function(){
+
+ // shorthand
+ var SB = Shadowbox;
+ var SL = SB.lib;
+ var C = SB.getClient();
+
+ /**
+ * Keeps track of 4 floating values (x, y, start_x, & start_y) that are used
+ * in the drag calculations.
+ *
+ * @property {Object} drag
+ * @private
+ */
+ var drag;
+
+ /**
+ * Holds the draggable element so we don't have to fetch it every time
+ * the mouse moves.
+ *
+ * @property {HTMLElement} draggable
+ * @private
+ */
+ var draggable;
+
+ /**
+ * The id to use for the drag layer.
+ *
+ * @property {String} drag_id
+ * @private
+ */
+ var drag_id = 'shadowbox_drag_layer';
+
+ /**
+ * Resource used to preload images. It's class-level so that when a new
+ * image is requested, the same resource can be reassigned, cancelling
+ * the original's callback.
+ *
+ * @property {HTMLElement} preloader
+ * @private
+ */
+ var preloader;
+
+ /**
+ * Resets the class drag variable.
+ *
+ * @return void
+ * @private
+ */
+ var resetDrag = function(){
+ drag = {
+ x: 0,
+ y: 0,
+ start_x: null,
+ start_y: null
+ };
+ };
+
+ /**
+ * Toggles the drag function on and off.
+ *
+ * @param {Boolean} on True to toggle on, false to toggle off
+ * @param {Number} h The height of the drag layer
+ * @param {Number} w The width of the drag layer
+ * @return void
+ * @private
+ */
+ var toggleDrag = function(on, h, w){
+ if(on){
+ resetDrag();
+ // add transparent drag layer to prevent browser dragging of actual image
+ var styles = [
+ 'position:absolute',
+ 'height:' + h + 'px',
+ 'width:' + w + 'px',
+ 'cursor:' + (C.isGecko ? '-moz-grab' : 'move'),
+ 'background-color:' + (C.isIE ? '#fff;filter:alpha(opacity=0)' : 'transparent')
+ ];
+ SL.append(SL.get('shadowbox_body_inner'), '<div id="' + drag_id + '" style="' + styles.join(';') + '"></div>');
+ SL.addEvent(SL.get(drag_id), 'mousedown', listenDrag);
+ }else{
+ var d = SL.get(drag_id);
+ if(d){
+ SL.removeEvent(d, 'mousedown', listenDrag);
+ SL.remove(d);
+ }
+ }
+ };
+
+ /**
+ * Sets up a drag listener on the document. Called when the mouse button is
+ * pressed (mousedown).
+ *
+ * @param {mixed} e The mousedown event
+ * @return void
+ * @private
+ */
+ var listenDrag = function(e){
+ // prevent browser dragging
+ SL.preventDefault(e);
+
+ var coords = SL.getPageXY(e);
+ drag.start_x = coords[0];
+ drag.start_y = coords[1];
+
+ draggable = SL.get('shadowbox_content');
+ SL.addEvent(document, 'mousemove', positionDrag);
+ SL.addEvent(document, 'mouseup', unlistenDrag);
+ if(C.isGecko) SL.setStyle(SL.get(drag_id), 'cursor', '-moz-grabbing');
+ };
+
+ /**
+ * Removes the drag listener. Called when the mouse button is released
+ * (mouseup).
+ *
+ * @return void
+ * @private
+ */
+ var unlistenDrag = function(){
+ SL.removeEvent(document, 'mousemove', positionDrag);
+ SL.removeEvent(document, 'mouseup', unlistenDrag); // clean up
+ if(C.isGecko) SL.setStyle(SL.get(drag_id), 'cursor', '-moz-grab');
+ };
+
+ /**
+ * Positions an oversized image on drag.
+ *
+ * @param {mixed} e The drag event
+ * @return void
+ * @private
+ */
+ var positionDrag = function(e){
+ var content = SB.getContent();
+ var dims = SB.getDimensions();
+ var coords = SL.getPageXY(e);
+
+ var move_x = coords[0] - drag.start_x;
+ drag.start_x += move_x;
+ drag.x = Math.max(Math.min(0, drag.x + move_x), dims.inner_w - content.width); // x boundaries
+ SL.setStyle(draggable, 'left', drag.x + 'px');
+
+ var move_y = coords[1] - drag.start_y;
+ drag.start_y += move_y;
+ drag.y = Math.max(Math.min(0, drag.y + move_y), dims.inner_h - content.height); // y boundaries
+ SL.setStyle(draggable, 'top', drag.y + 'px');
+ };
+
+ /**
+ * Constructor. This class is used to display images.
+ *
+ * @param {String} id The id to use for this content
+ * @param {Object} obj The content object
+ * @public
+ */
+ Shadowbox.img = function(id, obj){
+ this.id = id;
+ this.obj = obj;
+
+ // images are resizable
+ this.resizable = true;
+
+ // preload the image
+ this.ready = false;
+ var self = this; // needed inside preloader callback
+ preloader = new Image();
+ preloader.onload = function(){
+ // height defaults to image height
+ self.height = self.obj.height ? parseInt(self.obj.height, 10) : preloader.height;
+
+ // width defaults to image width
+ self.width = self.obj.width ? parseInt(self.obj.width, 10) : preloader.width;
+
+ // ready to go
+ self.ready = true;
+
+ // clean up to prevent memory leak in IE
+ preloader.onload = '';
+ preloader = null;
+ };
+ preloader.src = obj.content;
+ };
+
+ Shadowbox.img.prototype = {
+
+ /**
+ * Returns an object containing the markup for this content, suitable
+ * to pass to Shadowbox.lib.createHTML().
+ *
+ * @param {Object} dims The current Shadowbox dimensions
+ * @return {Object} The markup for this content item
+ * @public
+ */
+ markup: function(dims){
+ return {
+ tag: 'img',
+ id: this.id,
+ height: dims.resize_h, // use resized dimensions
+ width: dims.resize_w,
+ src: this.obj.content,
+ style: 'position:absolute'
+ };
+ },
+
+ /**
+ * An optional callback function to process after this content has been
+ * loaded.
+ *
+ * @return void
+ * @public
+ */
+ onLoad: function(){
+ var dims = SB.getDimensions();
+ if(dims.drag && SB.getOptions().handleOversize == 'drag'){
+ // listen for drag
+ // in the case of oversized images, the "resized" height and
+ // width will actually be the original image height and width
+ toggleDrag(true, dims.resize_h, dims.resize_w);
+ }
+ },
+
+ /**
+ * Removes this image from the document.
+ *
+ * @return void
+ * @public
+ */
+ remove: function(){
+ var el = SL.get(this.id);
+ if(el) SL.remove(el);
+
+ // disable drag layer
+ toggleDrag(false);
+
+ // prevent old image requests from loading
+ if(preloader){
+ preloader.onload = '';
+ preloader = null;
+ }
+ }
+
+ };
+
+})();
--- /dev/null
+++ shadowbox/src/player/shadowbox-iframe.js
@@ -0,0 +1,117 @@
+/**
+ * The Shadowbox iframe player class.
+ *
+ * This file is part of Shadowbox.
+ *
+ * Shadowbox is an online media viewer application that supports all of the
+ * web's most popular media publishing formats. Shadowbox is written entirely
+ * in JavaScript and CSS and is highly customizable. Using Shadowbox, website
+ * authors can showcase a wide assortment of media in all major browsers without
+ * navigating users away from the linking page.
+ *
+ * Shadowbox is released under version 3.0 of the Creative Commons Attribution-
+ * Noncommercial-Share Alike license. This means that it is absolutely free
+ * for personal, noncommercial use provided that you 1) make attribution to the
+ * author and 2) release any derivative work under the same or a similar
+ * license.
+ *
+ * If you wish to use Shadowbox for commercial purposes, licensing information
+ * can be found at http://mjijackson.com/shadowbox/.
+ *
+ * @author Michael J. I. Jackson <mjijackson at gmail.com>
+ * @copyright 2007-2008 Michael J. I. Jackson
+ * @license http://creativecommons.org/licenses/by-nc-sa/3.0/
+ * @version SVN: $Id: shadowbox-iframe.js 108 2008-07-11 04:19:01Z mjijackson $
+ */
+
+(function(){
+
+ // shorthand
+ var SB = Shadowbox;
+ var SL = SB.lib;
+ var C = SB.getClient();
+
+ /**
+ * Constructor. This class is used to display web pages in an HTML iframe.
+ *
+ * @param {String} id The id to use for this content
+ * @param {Object} obj The content object
+ * @public
+ */
+ Shadowbox.iframe = function(id, obj){
+ this.id = id;
+ this.obj = obj;
+
+ // height defaults to full viewport height
+ this.height = this.obj.height ? parseInt(this.obj.height, 10) : SL.getViewportHeight();
+
+ // width defaults to full viewport width
+ this.width = this.obj.width ? parseInt(this.obj.width, 10) : SL.getViewportWidth();
+ };
+
+ Shadowbox.iframe.prototype = {
+
+ /**
+ * Returns an object containing the markup for this content, suitable
+ * to pass to Shadowbox.lib.createHTML().
+ *
+ * @param {Object} dims The current Shadowbox dimensions
+ * @return {Object} The markup for this content item
+ * @public
+ */
+ markup: function(dims){
+ var markup = {
+ tag: 'iframe',
+ id: this.id,
+ name: this.id,
+ height: '100%',
+ width: '100%',
+ frameborder: '0',
+ marginwidth: '0',
+ marginheight: '0',
+ scrolling: 'auto'
+ };
+
+ if(C.isIE){
+ // prevent brief whiteout while loading iframe source
+ markup.allowtransparency = 'true';
+
+ if(!C.isIE7){
+ // prevent "secure content" warning for https on IE6
+ // see http://www.zachleat.com/web/2007/04/24/adventures-in-i-frame-shims-or-how-i-learned-to-love-the-bomb/
+ markup.src = 'javascript:false;document.write("");';
+ }
+ }
+
+ return markup;
+ },
+
+ /**
+ * An optional callback function to process after this content has been
+ * loaded.
+ *
+ * @return void
+ * @public
+ */
+ onLoad: function(){
+ var win = (C.isIE) ? SL.get(this.id).contentWindow : window.frames[this.id];
+ win.location = this.obj.content; // set the iframe's location
+ },
+
+ /**
+ * Removes this iframe from the document.
+ *
+ * @return void
+ * @public
+ */
+ remove: function(){
+ var el = SL.get(this.id);
+ if(el){
+ SL.remove(el);
+ if(C.isGecko) delete window.frames[this.id]; // needed for Firefox
+ }
+ }
+
+ };
+
+})();
--- /dev/null
+++ shadowbox/src/player/shadowbox-html.js
@@ -0,0 +1,83 @@
+/**
+ * The Shadowbox HTML player class.
+ *
+ * This file is part of Shadowbox.
+ *
+ * Shadowbox is an online media viewer application that supports all of the
+ * web's most popular media publishing formats. Shadowbox is written entirely
+ * in JavaScript and CSS and is highly customizable. Using Shadowbox, website
+ * authors can showcase a wide assortment of media in all major browsers without
+ * navigating users away from the linking page.
+ *
+ * Shadowbox is released under version 3.0 of the Creative Commons Attribution-
+ * Noncommercial-Share Alike license. This means that it is absolutely free
+ * for personal, noncommercial use provided that you 1) make attribution to the
+ * author and 2) release any derivative work under the same or a similar
+ * license.
+ *
+ * If you wish to use Shadowbox for commercial purposes, licensing information
+ * can be found at http://mjijackson.com/shadowbox/.
+ *
+ * @author Michael J. I. Jackson <mjijackson at gmail.com>
+ * @copyright 2007-2008 Michael J. I. Jackson
+ * @license http://creativecommons.org/licenses/by-nc-sa/3.0/
+ * @version SVN: $Id: shadowbox-html.js 99 2008-05-11 16:22:43Z mjijackson $
+ */
+
+(function(){
+
+ // shorthand
+ var SB = Shadowbox;
+ var SL = SB.lib;
+
+ /**
+ * Constructor. This class is used to display inline HTML.
+ *
+ * @param {String} id The id to use for this content
+ * @param {Object} obj The content object
+ * @public
+ */
+ Shadowbox.html = function(id, obj){
+ this.id = id;
+ this.obj = obj;
+
+ // height defaults to 300
+ this.height = this.obj.height ? parseInt(this.obj.height, 10) : 300;
+
+ // width defaults to 500
+ this.width = this.obj.width ? parseInt(this.obj.width, 10) : 500;
+ };
+
+ Shadowbox.html.prototype = {
+
+ /**
+ * Returns an object containing the markup for this content, suitable
+ * to pass to Shadowbox.lib.createHTML().
+ *
+ * @param {Object} dims The current Shadowbox dimensions
+ * @return {Object} The markup for this content item
+ * @public
+ */
+ markup: function(dims){
+ return {
+ tag: 'div',
+ id: this.id,
+ cls: 'html', // give special class to enable scrolling
+ html: this.obj.content
+ };
+ },
+
+ /**
+ * Removes this content from the document.
+ *
+ * @return void
+ * @public
+ */
+ remove: function(){
+ var el = SL.get(this.id);
+ if(el) SL.remove(el);
+ }
+
+ };
+
+})();
More information about the Midnightbsd-cvs
mailing list