[Midnightbsd-cvs] www: src/adapter: for new site revision
smultron at midnightbsd.org
smultron at midnightbsd.org
Fri Sep 5 14:59:39 EDT 2008
Log Message:
-----------
for new site revision
Added Files:
-----------
www/shadowbox/src/adapter:
shadowbox-base.js (r1.1)
shadowbox-dojo.js (r1.1)
shadowbox-ext.js (r1.1)
shadowbox-jquery.js (r1.1)
shadowbox-mootools.js (r1.1)
shadowbox-prototype.js (r1.1)
shadowbox-yui.js (r1.1)
-------------- next part --------------
--- /dev/null
+++ shadowbox/src/adapter/shadowbox-jquery.js
@@ -0,0 +1,214 @@
+/**
+ * An adapter for Shadowbox and the jQuery JavaScript library.
+ *
+ * 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-jquery.js 103 2008-06-27 06:19:21Z mjijackson $
+ */
+
+if(typeof jQuery == 'undefined'){
+ throw 'Unable to load Shadowbox, jQuery library not found';
+}
+
+// create the Shadowbox object first
+var Shadowbox = {};
+
+Shadowbox.lib = {
+
+ adapter: 'jquery',
+
+ /**
+ * Gets the value of the style on the given element.
+ *
+ * @param {HTMLElement} el The DOM element
+ * @param {String} style The name of the style (e.g. margin-top)
+ * @return {mixed} The value of the given style
+ * @public
+ */
+ getStyle: function(el, style){
+ return jQuery(el).css(style);
+ },
+
+ /**
+ * Sets the style on the given element to the given value. May be an
+ * object to specify multiple values.
+ *
+ * @param {HTMLElement} el The DOM element
+ * @param {String/Object} style The name of the style to set if a
+ * string, or an object of name =>
+ * value pairs
+ * @param {String} value The value to set the given style to
+ * @return void
+ * @public
+ */
+ setStyle: function(el, style, value){
+ if(typeof style != 'object'){
+ var temp = {};
+ temp[style] = value;
+ style = temp;
+ }
+ jQuery(el).css(style);
+ },
+
+ /**
+ * Gets a reference to the given element.
+ *
+ * @param {String/HTMLElement} el The element to fetch
+ * @return {HTMLElement} A reference to the element
+ * @public
+ */
+ get: function(el){
+ return (typeof el == 'string') ? document.getElementById(el) : el;
+ },
+
+ /**
+ * Removes an element from the DOM.
+ *
+ * @param {HTMLElement} el The element to remove
+ * @return void
+ * @public
+ */
+ remove: function(el){
+ jQuery(el).remove();
+ },
+
+ /**
+ * Gets the target of the given event. The event object passed will be
+ * the same object that is passed to listeners registered with
+ * addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return {HTMLElement} The event's target element
+ * @public
+ */
+ getTarget: function(e){
+ return e.target;
+ },
+
+ /**
+ * Gets the page X/Y coordinates of the mouse event in an [x, y] array.
+ * The page coordinates should be relative to the document, and not the
+ * viewport. The event object provided here will be the same object that
+ * is passed to listeners registered with addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return {Array} The page X/Y coordinates
+ * @public
+ * @static
+ */
+ getPageXY: function(e){
+ return [e.pageX, e.pageY];
+ },
+
+ /**
+ * Prevents the event's default behavior. The event object passed will
+ * be the same object that is passed to listeners registered with
+ * addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return void
+ * @public
+ */
+ preventDefault: function(e){
+ e.preventDefault();
+ },
+
+ /**
+ * Gets the key code of the given event object (keydown). The event
+ * object here will be the same object that is passed to listeners
+ * registered with addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return {Number} The key code of the event
+ * @public
+ * @static
+ */
+ keyCode: function(e){
+ return e.keyCode;
+ },
+
+ /**
+ * Adds an event listener to the given element. It is expected that this
+ * function will be passed the event as its first argument.
+ *
+ * @param {HTMLElement} el The DOM element to listen to
+ * @param {String} name The name of the event to register
+ * (i.e. 'click', 'scroll', etc.)
+ * @param {Function} handler The event handler function
+ * @return void
+ * @public
+ */
+ addEvent: function(el, name, handler){
+ jQuery(el).bind(name, handler);
+ },
+
+ /**
+ * Removes an event listener from the given element.
+ *
+ * @param {HTMLElement} el The DOM element to stop listening to
+ * @param {String} name The name of the event to stop
+ * listening for (i.e. 'click')
+ * @param {Function} handler The event handler function
+ * @return void
+ * @public
+ */
+ removeEvent: function(el, name, handler){
+ jQuery(el).unbind(name, handler);
+ },
+
+ /**
+ * Appends an HTML fragment to the given element.
+ *
+ * @param {HTMLElement} el The element to append to
+ * @param {String} html The HTML fragment to use
+ * @return void
+ * @public
+ */
+ append: function(el, html){
+ jQuery(el).append(html);
+ }
+
+};
+
+/**
+ * Passes the selected elements to the Shadowbox.setup() function. Supports
+ * embedded height and width attributes within the class attribute.
+ *
+ * @param {Object} options The options to pass to setup() for all
+ * selected elements
+ * @public
+ * @author Mike Alsup
+ * @author Roger Barrett
+ */
+(function($){
+$.fn.shadowbox = function(options){
+ return this.each(function(){
+ var $this = $(this);
+ // support jQuery metadata plugin
+ var opts = $.extend({}, options || {}, $.metadata ? $this.metadata() : $.meta ? $this.data() : {});
+ // support embedded opts (for w/h) within the class attr
+ var cls = this.className || '';
+ opts.width = parseInt((cls.match(/w:(\d+)/)||[])[1]) || opts.width;
+ opts.height = parseInt((cls.match(/h:(\d+)/)||[])[1]) || opts.height;
+ Shadowbox.setup($this, opts);
+ });
+};
+})(jQuery);
--- /dev/null
+++ shadowbox/src/adapter/shadowbox-prototype.js
@@ -0,0 +1,208 @@
+/**
+ * An adapter for Shadowbox and the Prototpe JavaScript library.
+ *
+ * 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-prototype.js 103 2008-06-27 06:19:21Z mjijackson $
+ */
+
+if(typeof Prototype == 'undefined'){
+ throw 'Unable to load Shadowbox, Prototype framework not found';
+}
+
+// create the Shadowbox object first
+var Shadowbox = {};
+
+Shadowbox.lib = function(){
+
+ // local style camelizing for speed
+ var styleCache = {};
+ var camelRe = /(-[a-z])/gi;
+ var camelFn = function(m, a){
+ return a.charAt(1).toUpperCase();
+ };
+ var toCamel = function(style){
+ var camel;
+ if(!(camel = styleCache[style])){
+ camel = styleCache[style] = style.replace(camelRe, camelFn);
+ }
+ return camel;
+ };
+
+ return {
+
+ adapter: 'prototype',
+
+ /**
+ * Gets the value of the style on the given element.
+ *
+ * @param {HTMLElement} el The DOM element
+ * @param {String} style The name of the style (e.g. margin-top)
+ * @return {mixed} The value of the given style
+ * @public
+ */
+ getStyle: function(el, style){
+ return Element.getStyle(el, style);
+ },
+
+ /**
+ * Sets the style on the given element to the given value. May be an
+ * object to specify multiple values.
+ *
+ * @param {HTMLElement} el The DOM element
+ * @param {String/Object} style The name of the style to set if a
+ * string, or an object of name =>
+ * value pairs
+ * @param {String} value The value to set the given style to
+ * @return void
+ * @public
+ */
+ setStyle: function(el, style, value){
+ if(typeof style == 'string'){
+ var temp = {};
+ temp[toCamel(style)] = value;
+ style = temp;
+ }
+ Element.setStyle(el, style);
+ },
+
+ /**
+ * Gets a reference to the given element.
+ *
+ * @param {String/HTMLElement} el The element to fetch
+ * @return {HTMLElement} A reference to the element
+ * @public
+ */
+ get: function(el){
+ return $(el);
+ },
+
+ /**
+ * Removes an element from the DOM.
+ *
+ * @param {HTMLElement} el The element to remove
+ * @return void
+ * @public
+ */
+ remove: function(el){
+ Element.remove(el);
+ },
+
+ /**
+ * Gets the target of the given event. The event object passed will be
+ * the same object that is passed to listeners registered with
+ * addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return {HTMLElement} The event's target element
+ * @public
+ */
+ getTarget: function(e){
+ return Event.element(e);
+ },
+
+ /**
+ * Prevents the event's default behavior. The event object passed will
+ * be the same object that is passed to listeners registered with
+ * addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return void
+ * @public
+ */
+ preventDefault: function(e){
+ Event.stop(e);
+ },
+
+ /**
+ * Gets the page X/Y coordinates of the mouse event in an [x, y] array.
+ * The page coordinates should be relative to the document, and not the
+ * viewport. The event object provided here will be the same object that
+ * is passed to listeners registered with addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return {Array} The page X/Y coordinates
+ * @public
+ * @static
+ */
+ getPageXY: function(e){
+ var p = Event.pointer(e);
+ return [p.x, p.y];
+ },
+
+ /**
+ * Gets the key code of the given event object (keydown). The event
+ * object here will be the same object that is passed to listeners
+ * registered with addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return {Number} The key code of the event
+ * @public
+ * @static
+ */
+ keyCode: function(e){
+ return e.keyCode;
+ },
+
+ /**
+ * Adds an event listener to the given element. It is expected that this
+ * function will be passed the event as its first argument.
+ *
+ * @param {HTMLElement} el The DOM element to listen to
+ * @param {String} name The name of the event to register
+ * (i.e. 'click', 'scroll', etc.)
+ * @param {Function} handler The event handler function
+ * @return void
+ * @public
+ */
+ addEvent: function(el, name, handler){
+ Event.observe(el, name, handler);
+ },
+
+ /**
+ * Removes an event listener from the given element.
+ *
+ * @param {HTMLElement} el The DOM element to stop listening to
+ * @param {String} name The name of the event to stop
+ * listening for (i.e. 'click')
+ * @param {Function} handler The event handler function
+ * @return void
+ * @public
+ */
+ removeEvent: function(el, name, handler){
+ Event.stopObserving(el, name, handler);
+ },
+
+ /**
+ * Appends an HTML fragment to the given element.
+ *
+ * @param {HTMLElement} el The element to append to
+ * @param {String} html The HTML fragment to use
+ * @return void
+ * @public
+ */
+ append: function(el, html){
+ Element.insert(el, html);
+ }
+
+ };
+
+}();
--- /dev/null
+++ shadowbox/src/adapter/shadowbox-ext.js
@@ -0,0 +1,192 @@
+/**
+ * An adapter for Shadowbox and the Ext JavaScript framework.
+ *
+ * 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-ext.js 103 2008-06-27 06:19:21Z mjijackson $
+ */
+
+if(typeof Ext == 'undefined'){
+ // Note: requires ext-core.js
+ throw 'Unable to load Shadowbox, core Ext framework not found';
+}
+
+// create the Shadowbox object first
+var Shadowbox = {};
+
+Shadowbox.lib = function(){
+
+ // shorthand
+ var E = Ext.lib.Event;
+
+ return {
+
+ adapter: 'ext',
+
+ /**
+ * Gets the value of the style on the given element.
+ *
+ * @param {HTMLElement} el The DOM element
+ * @param {String} style The name of the style (e.g. margin-top)
+ * @return {mixed} The value of the given style
+ * @public
+ */
+ getStyle: function(el, style){
+ return Ext.get(el).getStyle(style);
+ },
+
+ /**
+ * Sets the style on the given element to the given value. May be an
+ * object to specify multiple values.
+ *
+ * @param {HTMLElement} el The DOM element
+ * @param {String/Object} style The name of the style to set if a
+ * string, or an object of name =>
+ * value pairs
+ * @param {String} value The value to set the given style to
+ * @return void
+ * @public
+ */
+ setStyle: function(el, style, value){
+ Ext.get(el).setStyle(style, value);
+ },
+
+ /**
+ * Gets a reference to the given element.
+ *
+ * @param {String/HTMLElement} el The element to fetch
+ * @return {HTMLElement} A reference to the element
+ * @public
+ */
+ get: function(el){
+ return Ext.getDom(el);
+ },
+
+ /**
+ * Removes an element from the DOM.
+ *
+ * @param {HTMLElement} el The element to remove
+ * @return void
+ * @public
+ */
+ remove: function(el){
+ Ext.get(el).remove();
+ },
+
+ /**
+ * Gets the target of the given event. The event object passed will be
+ * the same object that is passed to listeners registered with
+ * addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return {HTMLElement} The event's target element
+ * @public
+ */
+ getTarget: function(e){
+ return E.getTarget(e);
+ },
+
+ /**
+ * Gets the page X/Y coordinates of the mouse event in an [x, y] array.
+ * The page coordinates should be relative to the document, and not the
+ * viewport. The event object provided here will be the same object that
+ * is passed to listeners registered with addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return {Array} The page X/Y coordinates
+ * @public
+ * @static
+ */
+ getPageXY: function(e){
+ return [E.getPageX(e), E.getPageY(e)];
+ },
+
+ /**
+ * Prevents the event's default behavior. The event object passed will
+ * be the same object that is passed to listeners registered with
+ * addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return void
+ * @public
+ */
+ preventDefault: function(e){
+ E.preventDefault(e);
+ },
+
+ /**
+ * Gets the key code of the given event object (keydown). The event
+ * object here will be the same object that is passed to listeners
+ * registered with addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return {Number} The key code of the event
+ * @public
+ * @static
+ */
+ keyCode: function(e){
+ return E.getCharCode(e);
+ },
+
+ /**
+ * Adds an event listener to the given element. It is expected that this
+ * function will be passed the event as its first argument.
+ *
+ * @param {HTMLElement} el The DOM element to listen to
+ * @param {String} name The name of the event to register
+ * (i.e. 'click', 'scroll', etc.)
+ * @param {Function} handler The event handler function
+ * @return void
+ * @public
+ */
+ addEvent: function(el, name, handler){
+ E.addListener(el, name, handler);
+ },
+
+ /**
+ * Removes an event listener from the given element.
+ *
+ * @param {HTMLElement} el The DOM element to stop listening to
+ * @param {String} name The name of the event to stop
+ * listening for (i.e. 'click')
+ * @param {Function} handler The event handler function
+ * @return void
+ * @public
+ */
+ removeEvent: function(el, name, handler){
+ E.removeListener(el, name, handler);
+ },
+
+ /**
+ * Appends an HTML fragment to the given element.
+ *
+ * @param {HTMLElement} el The element to append to
+ * @param {String} html The HTML fragment to use
+ * @return void
+ * @public
+ */
+ append: function(el, html){
+ Ext.DomHelper.append(el, html);
+ }
+
+ };
+
+}();
--- /dev/null
+++ shadowbox/src/adapter/shadowbox-mootools.js
@@ -0,0 +1,243 @@
+/**
+ * An adapter for Shadowbox and the MooTools JavaScript framework.
+ *
+ * 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-mootools.js 110 2008-07-11 04:42:10Z mjijackson $
+ */
+
+if(typeof MooTools == 'undefined'){
+ // Note: requires MooTools 1.2 Core
+ throw 'Unable to load Shadowbox, MooTools library not found';
+}
+
+// create the Shadowbox object first
+var Shadowbox = {};
+
+Shadowbox.lib = function(){
+
+ var alphaRe = /alpha\([^\)]*\)/gi;
+
+ /**
+ * Sets the opacity of the given element to the specified level. Necessary
+ * in the MooTools adapter to prevent MooTools from messing with the
+ * element's visibility.
+ *
+ * @param {HTMLElement} el The element
+ * @param {Number} opacity The opacity to use
+ * @return void
+ * @private
+ * @static
+ */
+ var setOpacity = function(el, opacity){
+ var s = el.style;
+ if(window.ActiveXObject){ // IE
+ s.zoom = 1;
+ s.filter = (s.filter || '').replace(alphaRe, '') +
+ (opacity == 1 ? '' : ' alpha(opacity=' + opacity * 100 + ')');
+ }else{
+ s.opacity = opacity;
+ }
+ };
+
+ return {
+
+ adapter: 'mootools',
+
+ /**
+ * Gets the value of the style on the given element.
+ *
+ * @param {HTMLElement} el The DOM element
+ * @param {String} style The name of the style (e.g. margin-top)
+ * @return {mixed} The value of the given style
+ * @public
+ * @static
+ */
+ getStyle: function(el, style){
+ return $(el).getStyle(style);
+ },
+
+ /**
+ * Sets the style on the given element to the given value. May be an
+ * object to specify multiple values.
+ *
+ * @param {HTMLElement} el The DOM element
+ * @param {String/Object} style The name of the style to set if a
+ * string, or an object of name =>
+ * value pairs
+ * @param {String} value The value to set the given style to
+ * @return void
+ * @public
+ * @static
+ */
+ setStyle: function(el, style, value){
+ el = $(el);
+ if(typeof style != 'object'){
+ var o = {};
+ o[style] = value;
+ style = o;
+ }
+ for(var s in style){
+ if(s == 'opacity'){
+ setOpacity(el, style[s]);
+ }else{
+ el.setStyle(s, style[s]);
+ }
+ }
+ },
+
+ /**
+ * Gets a reference to the given element.
+ *
+ * @param {String/HTMLElement} el The element to fetch
+ * @return {HTMLElement} A reference to the element
+ * @public
+ * @static
+ */
+ get: function(el){
+ return $(el);
+ },
+
+ /**
+ * Removes an element from the DOM.
+ *
+ * @param {HTMLElement} el The element to remove
+ * @return void
+ * @public
+ * @static
+ */
+ remove: function(el){
+ el.parentNode.removeChild(el);
+ },
+
+ /**
+ * Gets the target of the given event. The event object passed will be
+ * the same object that is passed to listeners registered with
+ * addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return {HTMLElement} The event's target element
+ * @public
+ * @static
+ */
+ getTarget: function(e){
+ return e.target;
+ },
+
+ /**
+ * Gets the page X/Y coordinates of the mouse event in an [x, y] array.
+ * The page coordinates should be relative to the document, and not the
+ * viewport. The event object provided here will be the same object that
+ * is passed to listeners registered with addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return {Array} The page X/Y coordinates
+ * @public
+ * @static
+ */
+ getPageXY: function(e){
+ return [e.page.x, e.page.y];
+ },
+
+ /**
+ * Prevents the event's default behavior. The event object passed will
+ * be the same object that is passed to listeners registered with
+ * addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return void
+ * @public
+ * @static
+ */
+ preventDefault: function(e){
+ e.preventDefault();
+ },
+
+ /**
+ * Gets the key code of the given event object (keydown). The event
+ * object here will be the same object that is passed to listeners
+ * registered with addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return {Number} The key code of the event
+ * @public
+ * @static
+ */
+ keyCode: function(e){
+ return e.code;
+ },
+
+ /**
+ * Adds an event listener to the given element. It is expected that this
+ * function will be passed the event as its first argument.
+ *
+ * @param {HTMLElement} el The DOM element to listen to
+ * @param {String} name The name of the event to register
+ * (i.e. 'click', 'scroll', etc.)
+ * @param {Function} handler The event handler function
+ * @return void
+ * @public
+ * @static
+ */
+ addEvent: function(el, name, handler){
+ $(el).addEvent(name, handler);
+ },
+
+ /**
+ * Removes an event listener from the given element.
+ *
+ * @param {HTMLElement} el The DOM element to stop listening to
+ * @param {String} name The name of the event to stop
+ * listening for (i.e. 'click')
+ * @param {Function} handler The event handler function
+ * @return void
+ * @public
+ * @static
+ */
+ removeEvent: function(el, name, handler){
+ $(el).removeEvent(name, handler);
+ },
+
+ /**
+ * Appends an HTML fragment to the given element.
+ *
+ * @param {HTMLElement} el The element to append to
+ * @param {String} html The HTML fragment to use
+ * @return void
+ * @public
+ * @static
+ */
+ append: function(el, html){
+ if(el.insertAdjacentHTML){
+ el.insertAdjacentHTML('BeforeEnd', html);
+ }else if(el.lastChild){
+ var range = el.ownerDocument.createRange();
+ range.setStartAfter(el.lastChild);
+ var frag = range.createContextualFragment(html);
+ el.appendChild(frag);
+ }else{
+ el.innerHTML = html;
+ }
+ }
+
+ };
+
+}();
--- /dev/null
+++ shadowbox/src/adapter/shadowbox-yui.js
@@ -0,0 +1,218 @@
+/**
+ * An adapter for Shadowbox and the Yahoo! User Interface (YUI) library.
+ *
+ * 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-yui.js 103 2008-06-27 06:19:21Z mjijackson $
+ */
+
+if(typeof YAHOO == 'undefined'){
+ // Note: requires yahoo-dom-event.js
+ throw 'Unable to load Shadowbox, core YUI utilities (yahoo, dom, event) not found';
+}
+
+// create the Shadowbox object first
+var Shadowbox = {};
+
+Shadowbox.lib = function(){
+
+ // shorthand
+ var E = YAHOO.util.Event;
+ var D = YAHOO.util.Dom;
+
+ return {
+
+ adapter: 'yui',
+
+ /**
+ * Gets the value of the style on the given element.
+ *
+ * @param {HTMLElement} el The DOM element
+ * @param {String} style The name of the style (e.g. margin-top)
+ * @return {mixed} The value of the given style
+ * @public
+ * @static
+ */
+ getStyle: function(el, style){
+ return D.getStyle(el, style);
+ },
+
+ /**
+ * Sets the style on the given element to the given value. May be an
+ * object to specify multiple values.
+ *
+ * @param {HTMLElement} el The DOM element
+ * @param {String/Object} style The name of the style to set if a
+ * string, or an object of name =>
+ * value pairs
+ * @param {String} value The value to set the given style to
+ * @return void
+ * @public
+ * @static
+ */
+ setStyle: function(el, style, value){
+ if(typeof style != 'object'){
+ var temp = {};
+ temp[style] = value;
+ style = temp;
+ }
+ for(var s in style){
+ D.setStyle(el, s, style[s]);
+ }
+ },
+
+ /**
+ * Gets a reference to the given element.
+ *
+ * @param {String/HTMLElement} el The element to fetch
+ * @return {HTMLElement} A reference to the element
+ * @public
+ * @static
+ */
+ get: function(el){
+ return D.get(el);
+ },
+
+ /**
+ * Removes an element from the DOM.
+ *
+ * @param {HTMLElement} el The element to remove
+ * @return void
+ * @public
+ * @static
+ */
+ remove: function(el){
+ el.parentNode.removeChild(el);
+ },
+
+ /**
+ * Gets the target of the given event. The event object passed will be
+ * the same object that is passed to listeners registered with
+ * addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return {HTMLElement} The event's target element
+ * @public
+ * @static
+ */
+ getTarget: function(e){
+ return E.getTarget(e);
+ },
+
+ /**
+ * Gets the page X/Y coordinates of the mouse event in an [x, y] array.
+ * The page coordinates should be relative to the document, and not the
+ * viewport. The event object provided here will be the same object that
+ * is passed to listeners registered with addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return {Array} The page X/Y coordinates
+ * @public
+ * @static
+ */
+ getPageXY: function(e){
+ return [E.getPageX(e), E.getPageY(e)];
+ },
+
+ /**
+ * Prevents the event's default behavior. The event object passed will
+ * be the same object that is passed to listeners registered with
+ * addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return void
+ * @public
+ * @static
+ */
+ preventDefault: function(e){
+ E.preventDefault(e);
+ },
+
+ /**
+ * Gets the key code of the given event object (keydown). The event
+ * object here will be the same object that is passed to listeners
+ * registered with addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return {Number} The key code of the event
+ * @public
+ * @static
+ */
+ keyCode: function(e){
+ return e.keyCode;
+ },
+
+ /**
+ * Adds an event listener to the given element. It is expected that this
+ * function will be passed the event as its first argument.
+ *
+ * @param {HTMLElement} el The DOM element to listen to
+ * @param {String} name The name of the event to register
+ * (i.e. 'click', 'scroll', etc.)
+ * @param {Function} handler The event handler function
+ * @return void
+ * @public
+ * @static
+ */
+ addEvent: function(el, name, handler){
+ E.addListener(el, name, handler);
+ },
+
+ /**
+ * Removes an event listener from the given element.
+ *
+ * @param {HTMLElement} el The DOM element to stop listening to
+ * @param {String} name The name of the event to stop
+ * listening for (i.e. 'click')
+ * @param {Function} handler The event handler function
+ * @return void
+ * @public
+ * @static
+ */
+ removeEvent: function(el, name, handler){
+ E.removeListener(el, name, handler);
+ },
+
+ /**
+ * Appends an HTML fragment to the given element.
+ *
+ * @param {HTMLElement} el The element to append to
+ * @param {String} html The HTML fragment to use
+ * @return void
+ * @public
+ * @static
+ */
+ append: function(el, html){
+ if(el.insertAdjacentHTML){
+ el.insertAdjacentHTML('BeforeEnd', html);
+ }else if(el.lastChild){
+ var range = el.ownerDocument.createRange();
+ range.setStartAfter(el.lastChild);
+ var frag = range.createContextualFragment(html);
+ el.appendChild(frag);
+ }else{
+ el.innerHTML = html;
+ }
+ }
+
+ };
+
+}();
--- /dev/null
+++ shadowbox/src/adapter/shadowbox-dojo.js
@@ -0,0 +1,246 @@
+/**
+ * An adapter for Shadowbox and the Dojo Toolkit.
+ *
+ * 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 Peter Higgins <dante at dojotoolkit.org>
+ * @copyright 2008 Peter Higgins
+ * @license AFL/BSD
+ * @version SVN: $Id: shadowbox-dojo.js 103 2008-06-27 06:19:21Z mjijackson $
+ */
+
+if(typeof dojo == 'undefined'){
+ throw 'Unable to load Shadowbox, Dojo Toolkit not found';
+}
+
+// create the Shadowbox object first
+var Shadowbox = {};
+
+Shadowbox.lib = function(){
+
+ /**
+ * Holds all registered event handlers.
+ *
+ * @property {Array} events
+ * @private
+ */
+ var events = [];
+
+ // local style camelizing for speed
+ var styleCache = {};
+ var camelRe = /(-[a-z])/gi;
+ var camelFn = function(m, a){
+ return a.charAt(1).toUpperCase();
+ };
+ var toCamel = function(style){
+ var camel;
+ if(!(camel = styleCache[style])){
+ camel = styleCache[style] = style.replace(camelRe, camelFn);
+ }
+ return camel;
+ };
+
+ return {
+
+ adapter: 'dojo',
+
+ /**
+ * Gets the value of the style on the given element.
+ *
+ * @param {HTMLElement} el The DOM element
+ * @param {String} style The name of the style (e.g. margin-top)
+ * @return {mixed} The value of the given style
+ * @public
+ * @static
+ */
+ getStyle: function(el, style){
+ return dojo.style(el, toCamel(style));
+ },
+
+ /**
+ * Sets the style on the given element to the given value. May be an
+ * object to specify multiple values.
+ *
+ * @param {HTMLElement} el The DOM element
+ * @param {String/Object} style The name of the style to set if a
+ * string, or an object of name =>
+ * value pairs
+ * @param {String} value The value to set the given style to
+ * @return void
+ * @public
+ * @static
+ */
+ setStyle: function(el, style, value){
+ if(typeof style == 'string'){
+ dojo.style(el, toCamel(style), value);
+ }else{
+ for(var i in style){
+ dojo.style(el, i, style[i]);
+ }
+ }
+ },
+
+ /**
+ * Gets a reference to the given element.
+ *
+ * @param {String/HTMLElement} el The element to fetch
+ * @return {HTMLElement} A reference to the element
+ * @public
+ * @static
+ */
+ get: function(el){
+ return dojo.byId(el);
+ },
+
+ /**
+ * Removes an element from the DOM.
+ *
+ * @param {HTMLElement} el The element to remove
+ * @return void
+ * @public
+ * @static
+ */
+ remove: function(el){
+ dojo._destroyElement(el);
+ },
+
+ /**
+ * Gets the target of the given event. The event object passed will be
+ * the same object that is passed to listeners registered with
+ * addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return {HTMLElement} The event's target element
+ * @public
+ * @static
+ */
+ getTarget: function(e){
+ return e.target;
+ },
+
+ /**
+ * Gets the client X/Y coordinates of the mouse event. The event object
+ * provided here will be the same object that is passed to listeners
+ * registered with addEvent(). The return array will contain the [x, y]
+ * coordinates.
+ *
+ * @param {mixed} e The event object
+ * @return {Array} The client X/Y coordinates
+ * @public
+ * @static
+ */
+ getPageXY: function(e){
+ return [e.pageX, e.pageY];
+ },
+
+ /**
+ * Prevents the event's default behavior. The event object passed will
+ * be the same object that is passed to listeners registered with
+ * addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return void
+ * @public
+ * @static
+ */
+ preventDefault: function(e){
+ e.preventDefault();
+ },
+
+ /**
+ * Gets the key code of the given event object (keydown). The event
+ * object here will be the same object that is passed to listeners
+ * registered with addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return {Number} The key code of the event
+ * @public
+ * @static
+ */
+ keyCode: function(e){
+ return e.keyCode;
+ },
+
+ /**
+ * Adds an event listener to the given element. It is expected that this
+ * function will be passed the event as its first argument.
+ *
+ * @param {HTMLElement} el The DOM element to listen to
+ * @param {String} name The name of the event to register
+ * (i.e. 'click', 'scroll', etc.)
+ * @param {Function} handler The event handler function
+ * @return void
+ * @public
+ * @static
+ */
+ addEvent: function(el, name, handler){
+ var t = dojo.connect(el, name, handler);
+ // we need to store a handle to later disconnect
+ events.push({
+ el: el,
+ name: name,
+ handle: t
+ });
+ },
+
+ /**
+ * Removes an event listener from the given element.
+ *
+ * @param {HTMLElement} el The DOM element to stop listening to
+ * @param {String} name The name of the event to stop
+ * listening for (i.e. 'click')
+ * @param {Function} handler The event handler function
+ * @return void
+ * @public
+ * @static
+ */
+ removeEvent: function(el, name, handler){
+ // probably a quicker way to match this
+ dojo.forEach(events, function(ev, idx){
+ if(ev && ev.el == el && ev.name == name){
+ dojo.disconnect(ev.handle);
+ events[idx] = null;
+ }
+ });
+ },
+
+ /**
+ * Appends an HTML fragment to the given element.
+ *
+ * @param {HTMLElement} el The element to append to
+ * @param {String} html The HTML fragment to use
+ * @return void
+ * @public
+ * @static
+ */
+ append: function(el, html){
+ if(el.insertAdjacentHTML){
+ el.insertAdjacentHTML('BeforeEnd', html);
+ }else if(el.lastChild){
+ var range = el.ownerDocument.createRange();
+ range.setStartAfter(el.lastChild);
+ var frag = range.createContextualFragment(html);
+ el.appendChild(frag);
+ }else{
+ el.innerHTML = html;
+ }
+ }
+
+ };
+
+}();
--- /dev/null
+++ shadowbox/src/adapter/shadowbox-base.js
@@ -0,0 +1,298 @@
+/**
+ * A base library for Shadowbox used as a standalone (without another base
+ * library/adapter combination).
+ *
+ * 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-base.js 103 2008-06-27 06:19:21Z mjijackson $
+ */
+
+// create the Shadowbox object first
+var Shadowbox = {};
+
+Shadowbox.lib = function(){
+
+ // local style camelizing for speed
+ var styleCache = {};
+ var camelRe = /(-[a-z])/gi;
+ var camelFn = function(m, a){
+ return a.charAt(1).toUpperCase();
+ };
+ var toCamel = function(style){
+ var camel;
+ if(!(camel = styleCache[style])){
+ camel = styleCache[style] = style.replace(camelRe, camelFn);
+ }
+ return camel;
+ };
+
+ var view = document.defaultView;
+ var alphaRe = /alpha\([^\)]*\)/gi;
+
+ /**
+ * Sets the opacity of the given element to the specified level.
+ *
+ * @param {HTMLElement} el The element
+ * @param {Number} opacity The opacity to use
+ * @return void
+ * @private
+ * @static
+ */
+ var setOpacity = function(el, opacity){
+ var s = el.style;
+ if(window.ActiveXObject){ // IE
+ s.zoom = 1; // give "layout"
+ s.filter = (s.filter || '').replace(alphaRe, '') +
+ (opacity == 1 ? '' : ' alpha(opacity=' + (opacity * 100) + ')');
+ }else{
+ s.opacity = opacity;
+ }
+ };
+
+ return {
+
+ adapter: 'standalone',
+
+ /**
+ * Gets the value of the style on the given element. This function
+ * adapted from Ext.Element.getStyle().
+ *
+ * @param {HTMLElement} el The DOM element
+ * @param {String} style The name of the style (e.g. margin-top)
+ * @return {mixed} The value of the given style
+ * @public
+ * @static
+ */
+ getStyle: function(){
+ return view && view.getComputedStyle
+ ? function(el, style){
+ var v, cs, camel;
+ if(style == 'float') style = 'cssFloat';
+ if(v = el.style[style]) return v;
+ if(cs = view.getComputedStyle(el, '')){
+ return cs[toCamel(style)];
+ }
+ return null;
+ }
+ : function(el, style){
+ var v, cs, camel;
+ if(style == 'opacity'){
+ if(typeof el.style.filter == 'string'){
+ var m = el.style.filter.match(/alpha\(opacity=(.+)\)/i);
+ if(m){
+ var fv = parseFloat(m[1]);
+ if(!isNaN(fv)) return (fv ? fv / 100 : 0);
+ }
+ }
+ return 1;
+ }else if(style == 'float'){
+ style = 'styleFloat';
+ }
+ var camel = toCamel(style);
+ if(v = el.style[camel]) return v;
+ if(cs = el.currentStyle) return cs[camel];
+ return null;
+ };
+ }(),
+
+ /**
+ * Sets the style on the given element to the given value. May be an
+ * object to specify multiple values. This function adapted from
+ * Ext.Element.setStyle().
+ *
+ * @param {HTMLElement} el The DOM element
+ * @param {String/Object} style The name of the style to set if a
+ * string, or an object of name =>
+ * value pairs
+ * @param {String} value The value to set the given style to
+ * @return void
+ * @public
+ * @static
+ */
+ setStyle: function(el, style, value){
+ if(typeof style == 'string'){
+ var camel = toCamel(style);
+ if(camel == 'opacity'){
+ setOpacity(el, value);
+ }else{
+ el.style[camel] = value;
+ }
+ }else{
+ for(var s in style){
+ this.setStyle(el, s, style[s]);
+ }
+ }
+ },
+
+ /**
+ * Gets a reference to the given element.
+ *
+ * @param {String/HTMLElement} el The element to fetch
+ * @return {HTMLElement} A reference to the element
+ * @public
+ * @static
+ */
+ get: function(el){
+ return typeof el == 'string' ? document.getElementById(el) : el;
+ },
+
+ /**
+ * Removes an element from the DOM.
+ *
+ * @param {HTMLElement} el The element to remove
+ * @return void
+ * @public
+ * @static
+ */
+ remove: function(el){
+ el.parentNode.removeChild(el);
+ },
+
+ /**
+ * Gets the target of the given event. The event object passed will be
+ * the same object that is passed to listeners registered with
+ * addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return {HTMLElement} The event's target element
+ * @public
+ * @static
+ */
+ getTarget: function(e){
+ var t = e.target ? e.target : e.srcElement;
+ return t.nodeType == 3 ? t.parentNode : t;
+ },
+
+ /**
+ * Gets the page X/Y coordinates of the mouse event in an [x, y] array.
+ * The page coordinates should be relative to the document, and not the
+ * viewport. The event object provided here will be the same object that
+ * is passed to listeners registered with addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return {Array} The page X/Y coordinates
+ * @public
+ * @static
+ */
+ getPageXY: function(e){
+ var x = e.pageX || (e.clientX +
+ (document.documentElement.scrollLeft || document.body.scrollLeft));
+ var y = e.pageY || (e.clientY +
+ (document.documentElement.scrollTop || document.body.scrollTop));
+ return [x, y];
+ },
+
+ /**
+ * Prevents the event's default behavior. The event object here will
+ * be the same object that is passed to listeners registered with
+ * addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return void
+ * @public
+ * @static
+ */
+ preventDefault: function(e){
+ if(e.preventDefault){
+ e.preventDefault();
+ }else{
+ e.returnValue = false;
+ }
+ },
+
+ /**
+ * Gets the key code of the given event object (keydown). The event
+ * object here will be the same object that is passed to listeners
+ * registered with addEvent().
+ *
+ * @param {mixed} e The event object
+ * @return {Number} The key code of the event
+ * @public
+ * @static
+ */
+ keyCode: function(e){
+ return e.which ? e.which : e.keyCode;
+ },
+
+ /**
+ * Adds an event listener to the given element. It is expected that this
+ * function will be passed the event as its first argument.
+ *
+ * @param {HTMLElement} el The DOM element to listen to
+ * @param {String} name The name of the event to register
+ * (i.e. 'click', 'scroll', etc.)
+ * @param {Function} handler The event handler function
+ * @return void
+ * @public
+ * @static
+ */
+ addEvent: function(el, name, handler){
+ if(el.addEventListener){
+ el.addEventListener(name, handler, false);
+ }else if(el.attachEvent){
+ el.attachEvent('on' + name, handler);
+ }
+ },
+
+ /**
+ * Removes an event listener from the given element.
+ *
+ * @param {HTMLElement} el The DOM element to stop listening to
+ * @param {String} name The name of the event to stop
+ * listening for (i.e. 'click')
+ * @param {Function} handler The event handler function
+ * @return void
+ * @public
+ * @static
+ */
+ removeEvent: function(el, name, handler){
+ if(el.removeEventListener){
+ el.removeEventListener(name, handler, false);
+ }else if(el.detachEvent){
+ el.detachEvent('on' + name, handler);
+ }
+ },
+
+ /**
+ * Appends an HTML fragment to the given element.
+ *
+ * @param {HTMLElement} el The element to append to
+ * @param {String} html The HTML fragment to use
+ * @return void
+ * @public
+ * @static
+ */
+ append: function(el, html){
+ if(el.insertAdjacentHTML){
+ el.insertAdjacentHTML('BeforeEnd', html);
+ }else if(el.lastChild){
+ var range = el.ownerDocument.createRange();
+ range.setStartAfter(el.lastChild);
+ var frag = range.createContextualFragment(html);
+ el.appendChild(frag);
+ }else{
+ el.innerHTML = html;
+ }
+ }
+
+ };
+
+}();
More information about the Midnightbsd-cvs
mailing list