From: Michael M Slusarz Date: Mon, 3 Aug 2009 05:43:46 +0000 (-0600) Subject: Get rid of js/src directories. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=342c9c84bd64728e7bb89092616407f773ba688a;p=horde.git Get rid of js/src directories. --- diff --git a/ansel/js/builder.js b/ansel/js/builder.js new file mode 100755 index 000000000..f25e996cf --- /dev/null +++ b/ansel/js/builder.js @@ -0,0 +1,20 @@ + +var Builder={NODEMAP:{AREA:'map',CAPTION:'table',COL:'table',COLGROUP:'table',LEGEND:'fieldset',OPTGROUP:'select',OPTION:'select',PARAM:'object',TBODY:'table',TD:'table',TFOOT:'table',TH:'table',THEAD:'table',TR:'table'},node:function(elementName){elementName=elementName.toUpperCase();var parentTag=this.NODEMAP[elementName]||'div';var parentElement=document.createElement(parentTag);try{parentElement.innerHTML="<"+elementName+">";}catch(e){} +var element=parentElement.firstChild||null;if(element&&(element.tagName.toUpperCase()!=elementName)) +element=element.getElementsByTagName(elementName)[0];if(!element)element=document.createElement(elementName);if(!element)return;if(arguments[1]) +if(this._isStringOrNumber(arguments[1])||(arguments[1]instanceof Array)||arguments[1].tagName){this._children(element,arguments[1]);}else{var attrs=this._attributes(arguments[1]);if(attrs.length){try{parentElement.innerHTML="<"+elementName+" "+ +attrs+">";}catch(e){} +element=parentElement.firstChild||null;if(!element){element=document.createElement(elementName);for(attr in arguments[1]) +element[attr=='class'?'className':attr]=arguments[1][attr];} +if(element.tagName.toUpperCase()!=elementName) +element=parentElement.getElementsByTagName(elementName)[0];}} +if(arguments[2]) +this._children(element,arguments[2]);return element;},_text:function(text){return document.createTextNode(text);},ATTR_MAP:{'className':'class','htmlFor':'for'},_attributes:function(attributes){var attrs=[];for(attribute in attributes) +attrs.push((attribute in this.ATTR_MAP?this.ATTR_MAP[attribute]:attribute)+'="'+attributes[attribute].toString().escapeHTML().gsub(/"/,'"')+'"');return attrs.join(" ");},_children:function(element,children){if(children.tagName){element.appendChild(children);return;} +if(typeof children=='object'){children.flatten().each(function(e){if(typeof e=='object') +element.appendChild(e) +else +if(Builder._isStringOrNumber(e)) +element.appendChild(Builder._text(e));});}else +if(Builder._isStringOrNumber(children)) +element.appendChild(Builder._text(children));},_isStringOrNumber:function(param){return(typeof param=='string'||typeof param=='number');},build:function(html){var element=this.node('div');$(element).update(html.strip());return element.down();},dump:function(scope){if(typeof scope!='object'&&typeof scope!='function')scope=window;var tags=("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY "+"BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET "+"FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+"KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+"PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+"TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/);tags.each(function(tag){scope[tag]=function(){return Builder.node.apply(Builder,[tag].concat($A(arguments)));}});}} \ No newline at end of file diff --git a/ansel/js/carousel.js b/ansel/js/carousel.js new file mode 100644 index 000000000..b966dbbdf --- /dev/null +++ b/ansel/js/carousel.js @@ -0,0 +1,1076 @@ +/* Prototype-UI, version trunk + * + * Prototype-UI is freely distributable under the terms of an MIT-style license. + * For details, see the PrototypeUI web site: http://www.prototype-ui.com/ + * + *--------------------------------------------------------------------------*/ + +if(typeof Prototype == 'undefined' || !Prototype.Version.match("1.6")) + throw("Prototype-UI library require Prototype library >= 1.6.0"); + +if (Prototype.Browser.WebKit) { + Prototype.Browser.WebKitVersion = parseFloat(navigator.userAgent.match(/AppleWebKit\/([\d\.\+]*)/)[1]); + Prototype.Browser.Safari2 = (Prototype.Browser.WebKitVersion < 420); +} + +if (Prototype.Browser.IE) { + Prototype.Browser.IEVersion = parseFloat(navigator.appVersion.split(';')[1].strip().split(' ')[1]); + Prototype.Browser.IE6 = Prototype.Browser.IEVersion == 6; + Prototype.Browser.IE7 = Prototype.Browser.IEVersion == 7; +} + +Prototype.falseFunction = function() { return false }; +Prototype.trueFunction = function() { return true }; + +/* +Namespace: UI + + Introduction: + Prototype-UI is a library of user interface components based on the Prototype framework. + Its aim is to easilly improve user experience in web applications. + + It also provides utilities to help developers. + + Guideline: + - Prototype conventions are followed + - Everything should be unobstrusive + - All components are themable with CSS stylesheets, various themes are provided + + Warning: + Prototype-UI is still under deep development, this release is targeted to developers only. + All interfaces are subjects to changes, suggestions are welcome. + + DO NOT use it in production for now. + + Authors: + - Sébastien Gruhier, + - Samuel Lebeau, +*/ + +var UI = { + Abstract: { }, + Ajax: { } +}; +Object.extend(Class.Methods, { + extend: Object.extend.methodize(), + + addMethods: Class.Methods.addMethods.wrap(function(proceed, source) { + // ensure we are not trying to add null or undefined + if (!source) return this; + + // no callback, vanilla way + if (!source.hasOwnProperty('methodsAdded')) + return proceed(source); + + var callback = source.methodsAdded; + delete source.methodsAdded; + proceed(source); + callback.call(source, this); + source.methodsAdded = callback; + + return this; + }), + + addMethod: function(name, lambda) { + var methods = {}; + methods[name] = lambda; + return this.addMethods(methods); + }, + + method: function(name) { + return this.prototype[name].valueOf(); + }, + + classMethod: function() { + $A(arguments).flatten().each(function(method) { + this[method] = (function() { + return this[method].apply(this, arguments); + }).bind(this.prototype); + }, this); + return this; + }, + + // prevent any call to this method + undefMethod: function(name) { + this.prototype[name] = undefined; + return this; + }, + + // remove the class' own implementation of this method + removeMethod: function(name) { + delete this.prototype[name]; + return this; + }, + + aliasMethod: function(newName, name) { + this.prototype[newName] = this.prototype[name]; + return this; + }, + + aliasMethodChain: function(target, feature) { + feature = feature.camelcase(); + + this.aliasMethod(target+"Without"+feature, target); + this.aliasMethod(target, target+"With"+feature); + + return this; + } +}); +Object.extend(Number.prototype, { + // Snap a number to a grid + snap: function(round) { + return parseInt(round == 1 ? this : (this / round).floor() * round); + } +}); +/* +Interface: String + +*/ + +Object.extend(String.prototype, { + camelcase: function() { + var string = this.dasherize().camelize(); + return string.charAt(0).toUpperCase() + string.slice(1); + }, + + /* + Method: makeElement + toElement is unfortunately already taken :/ + + Transforms html string into an extended element or null (when failed) + + > '
  • some text
  • '.makeElement(); // => LI href# + > ''.makeElement(); // => IMG#foo (first one) + + Returns: + Extended element + + */ + makeElement: function() { + var wrapper = new Element('div'); wrapper.innerHTML = this; + return wrapper.down(); + } +}); +Object.extend(Array.prototype, { + empty: function() { + return !this.length; + }, + + extractOptions: function() { + return this.last().constructor === Object ? this.pop() : { }; + }, + + removeAt: function(index) { + var object = this[index]; + this.splice(index, 1); + return object; + }, + + remove: function(object) { + var index; + while ((index = this.indexOf(object)) != -1) + this.removeAt(index); + return object; + }, + + insert: function(index) { + var args = $A(arguments); + args.shift(); + this.splice.apply(this, [ index, 0 ].concat(args)); + return this; + } +}); +Element.addMethods({ + getScrollDimensions: function(element) { + return { + width: element.scrollWidth, + height: element.scrollHeight + } + }, + + getScrollOffset: function(element) { + return Element._returnOffset(element.scrollLeft, element.scrollTop); + }, + + setScrollOffset: function(element, offset) { + element = $(element); + if (arguments.length == 3) + offset = { left: offset, top: arguments[2] }; + element.scrollLeft = offset.left; + element.scrollTop = offset.top; + return element; + }, + + // returns "clean" numerical style (without "px") or null if style can not be resolved + // or is not numeric + getNumStyle: function(element, style) { + var value = parseFloat($(element).getStyle(style)); + return isNaN(value) ? null : value; + }, + + // by Tobie Langel (http://tobielangel.com/2007/5/22/prototype-quick-tip) + appendText: function(element, text) { + element = $(element); + text = String.interpret(text); + element.appendChild(document.createTextNode(text)); + return element; + } +}); + +document.whenReady = function(callback) { + if (document.loaded) + callback.call(document); + else + document.observe('dom:loaded', callback); +}; + +Object.extend(document.viewport, { + // Alias this method for consistency + getScrollOffset: document.viewport.getScrollOffsets, + + setScrollOffset: function(offset) { + Element.setScrollOffset(Prototype.Browser.WebKit ? document.body : document.documentElement, offset); + }, + + getScrollDimensions: function() { + return Element.getScrollDimensions(Prototype.Browser.WebKit ? document.body : document.documentElement); + } +}); +/* +Interface: UI.Options + Mixin to handle *options* argument in initializer pattern. + + TODO: find a better example than Circle that use an imaginary Point function, + this example should be used in tests too. + + It assumes class defines a property called *options*, containing + default options values. + + Instances hold their own *options* property after a first call to . + + Example: + > var Circle = Class.create(UI.Options, { + > + > // default options + > options: { + > radius: 1, + > origin: Point(0, 0) + > }, + > + > // common usage is to call setOptions in initializer + > initialize: function(options) { + > this.setOptions(options); + > } + > }); + > + > var circle = new Circle({ origin: Point(1, 4) }); + > + > circle.options + > // => { radius: 1, origin: Point(1,4) } + + Accessors: + There are builtin methods to automatically write options accessors. All those + methods can take either an array of option names nor option names as arguments. + Notice that those methods won't override an accessor method if already present. + + * creates getters + * creates setters + * creates both getters and setters + + Common usage is to invoke them on a class to create accessors for all instances + of this class. + Invoking those methods on a class has the same effect as invoking them on the class prototype. + See for more details. + + Example: + > // Creates getter and setter for the "radius" options of circles + > Circle.optionsAccessor('radius'); + > + > circle.setRadius(4); + > // 4 + > + > circle.getRadius(); + > // => 4 (circle.options.radius) + + Inheritance support: + Subclasses can refine default *options* values, after a first instance call on setOptions, + *options* attribute will hold all default options values coming from the inheritance hierarchy. +*/ + +(function() { + UI.Options = { + methodsAdded: function(klass) { + klass.classMethod($w(' setOptions allOptions optionsGetter optionsSetter optionsAccessor ')); + }, + + // Group: Methods + + /* + Method: setOptions + Extends object's *options* property with the given object + */ + setOptions: function(options) { + if (!this.hasOwnProperty('options')) + this.options = this.allOptions(); + + this.options = Object.extend(this.options, options || {}); + }, + + /* + Method: allOptions + Computes the complete default options hash made by reverse extending all superclasses + default options. + + > Widget.prototype.allOptions(); + */ + allOptions: function() { + var superclass = this.constructor.superclass, ancestor = superclass && superclass.prototype; + return (ancestor && ancestor.allOptions) ? + Object.extend(ancestor.allOptions(), this.options) : + Object.clone(this.options); + }, + + /* + Method: optionsGetter + Creates default getters for option names given as arguments. + With no argument, creates getters for all option names. + */ + optionsGetter: function() { + addOptionsAccessors(this, arguments, false); + }, + + /* + Method: optionsSetter + Creates default setters for option names given as arguments. + With no argument, creates setters for all option names. + */ + optionsSetter: function() { + addOptionsAccessors(this, arguments, true); + }, + + /* + Method: optionsAccessor + Creates default getters/setters for option names given as arguments. + With no argument, creates accessors for all option names. + */ + optionsAccessor: function() { + this.optionsGetter.apply(this, arguments); + this.optionsSetter.apply(this, arguments); + } + }; + + // Internal + function addOptionsAccessors(receiver, names, areSetters) { + names = $A(names).flatten(); + + if (names.empty()) + names = Object.keys(receiver.allOptions()); + + names.each(function(name) { + var accessorName = (areSetters ? 'set' : 'get') + name.camelcase(); + + receiver[accessorName] = receiver[accessorName] || (areSetters ? + // Setter + function(value) { return this.options[name] = value } : + // Getter + function() { return this.options[name] }); + }); + } +})(); +/* + Class: UI.Carousel + + Main class to handle a carousel of elements in a page. A carousel : + * could be vertical or horizontal + * works with liquid layout + * is designed by CSS + + Assumptions: + * Elements should be from the same size + + Example: + > ... + > + > + > ... +*/ +UI.Carousel = Class.create(UI.Options, { + // Group: Options + options: { + // Property: direction + // Can be horizontal or vertical, horizontal by default + direction : "horizontal", + + // Property: previousButton + // Selector of previous button inside carousel element, ".previous_button" by default, + // set it to false to ignore previous button + previousButton : ".previous_button", + + // Property: nextButton + // Selector of next button inside carousel element, ".next_button" by default, + // set it to false to ignore next button + nextButton : ".next_button", + + // Property: container + // Selector of carousel container inside carousel element, ".container" by default, + container : ".container", + + // Property: scrollInc + // Define the maximum number of elements that gonna scroll each time, auto by default + scrollInc : "auto", + + // Property: disabledButtonSuffix + // Define the suffix classanme used when a button get disabled, to '_disabled' by default + // Previous button classname will be previous_button_disabled + disabledButtonSuffix : '_disabled', + + // Property: overButtonSuffix + // Define the suffix classanme used when a button has a rollover status, '_over' by default + // Previous button classname will be previous_button_over + overButtonSuffix : '_over' + }, + + /* + Group: Attributes + + Property: element + DOM element containing the carousel + + Property: id + DOM id of the carousel's element + + Property: container + DOM element containing the carousel's elements + + Property: elements + Array containing the carousel's elements as DOM elements + + Property: previousButton + DOM id of the previous button + + Property: nextButton + DOM id of the next button + + Property: posAttribute + Define if the positions are from left or top + + Property: dimAttribute + Define if the dimensions are horizontal or vertical + + Property: elementSize + Size of each element, it's an integer + + Property: nbVisible + Number of visible elements, it's a float + + Property: animating + Define whether the carousel is in animation or not + */ + + /* + Group: Events + List of events fired by a carousel + + Notice: Carousel custom events are automatically namespaced in "carousel:" (see Prototype custom events). + + Examples: + This example will observe all carousels + > document.observe('carousel:scroll:ended', function(event) { + > alert("Carousel with id " + event.memo.carousel.id + " has just been scrolled"); + > }); + + This example will observe only this carousel + > new UI.Carousel('horizontal_carousel').observe('scroll:ended', function(event) { + > alert("Carousel with id " + event.memo.carousel.id + " has just been scrolled"); + > }); + + Property: previousButton:enabled + Fired when the previous button has just been enabled + + Property: previousButton:disabled + Fired when the previous button has just been disabled + + Property: nextButton:enabled + Fired when the next button has just been enabled + + Property: nextButton:disabled + Fired when the next button has just been disabled + + Property: scroll:started + Fired when a scroll has just started + + Property: scroll:ended + Fired when a scroll has been done, + memo.shift = number of elements scrolled, it's a float + + Property: sizeUpdated + Fired when the carousel size has just been updated. + Tips: memo.carousel.currentSize() = the new carousel size + */ + + // Group: Constructor + + /* + Method: initialize + Constructor function, should not be called directly + + Parameters: + element - DOM element + options - (Hash) list of optional parameters + + Returns: + this + */ + initialize: function(element, options) { + this.setOptions(options); + this.element = $(element); + this.id = this.element.id; + this.container = this.element.down(this.options.container).firstDescendant(); + this.elements = this.container.childElements(); + this.previousButton = this.options.previousButton == false ? null : this.element.down(this.options.previousButton); + this.nextButton = this.options.nextButton == false ? null : this.element.down(this.options.nextButton); + + this.posAttribute = (this.options.direction == "horizontal" ? "left" : "top"); + this.dimAttribute = (this.options.direction == "horizontal" ? "width" : "height"); + + this.elementSize = this.computeElementSize(); + this.nbVisible = this.currentSize() / this.elementSize; + + var scrollInc = this.options.scrollInc; + if (scrollInc == "auto") + scrollInc = Math.floor(this.nbVisible); + [ this.previousButton, this.nextButton ].each(function(button) { + if (!button) return; + var className = (button == this.nextButton ? "next_button" : "previous_button") + this.options.overButtonSuffix; + button.clickHandler = this.scroll.bind(this, (button == this.nextButton ? -1 : 1) * scrollInc * this.elementSize); + button.observe("click", button.clickHandler) + .observe("mouseover", function() {button.addClassName(className)}.bind(this)) + .observe("mouseout", function() {button.removeClassName(className)}.bind(this)); + }, this); + this.updateButtons(); + }, + + // Group: Destructor + + /* + Method: destroy + Cleans up DOM and memory + */ + destroy: function($super) { + [ this.previousButton, this.nextButton ].each(function(button) { + if (!button) return; + button.stopObserving("click", button.clickHandler); + }, this); + this.element.remove(); + this.fire('destroyed'); + }, + + // Group: Event handling + + /* + Method: fire + Fires a carousel custom event automatically namespaced in "carousel:" (see Prototype custom events). + The memo object contains a "carousel" property referring to the carousel. + + Example: + > document.observe('carousel:scroll:ended', function(event) { + > alert("Carousel with id " + event.memo.carousel.id + " has just been scrolled"); + > }); + + Parameters: + eventName - an event name + memo - a memo object + + Returns: + fired event + */ + fire: function(eventName, memo) { + memo = memo || { }; + memo.carousel = this; + return this.element.fire('carousel:' + eventName, memo); + }, + + /* + Method: observe + Observe a carousel event with a handler function automatically bound to the carousel + + Parameters: + eventName - an event name + handler - a handler function + + Returns: + this + */ + observe: function(eventName, handler) { + this.element.observe('carousel:' + eventName, handler.bind(this)); + return this; + }, + + /* + Method: stopObserving + Unregisters a carousel event, it must take the same parameters as this.observe (see Prototype stopObserving). + + Parameters: + eventName - an event name + handler - a handler function + + Returns: + this + */ + stopObserving: function(eventName, handler) { + this.element.stopObserving('carousel:' + eventName, handler); + return this; + }, + + // Group: Actions + + /* + Method: checkScroll + Check scroll position to avoid unused space at right or bottom + + Parameters: + position - position to check + updatePosition - should the container position be updated ? true/false + + Returns: + position + */ + checkScroll: function(position, updatePosition) { + if (position > 0) + position = 0; + else { + var limit = this.elements.last().positionedOffset()[this.posAttribute] + this.elementSize; + var carouselSize = this.currentSize(); + + if (position + limit < carouselSize) + position += carouselSize - (position + limit); + position = Math.min(position, 0); + } + if (updatePosition) + this.container.style[this.posAttribute] = position + "px"; + + return position; + }, + + /* + Method: scroll + Scrolls carousel from maximum deltaPixel + + Parameters: + deltaPixel - a float + + Returns: + this + */ + scroll: function(deltaPixel) { + if (this.animating) + return this; + + // Compute new position + var position = this.currentPosition() + deltaPixel; + + // Check bounds + position = this.checkScroll(position, false); + + // Compute shift to apply + deltaPixel = position - this.currentPosition(); + if (deltaPixel != 0) { + this.animating = true; + this.fire("scroll:started"); + + var that = this; + // Move effects + this.container.morph("opacity:0.5", {duration: 0.2, afterFinish: function() { + that.container.morph(that.posAttribute + ": " + position + "px", { + duration: 0.4, + delay: 0.2, + afterFinish: function() { + that.container.morph("opacity:1", { + duration: 0.2, + afterFinish: function() { + that.animating = false; + that.updateButtons() + .fire("scroll:ended", { shift: deltaPixel / that.currentSize() }); + } + }); + } + }); + }}); + } + return this; + }, + + /* + Method: scrollTo + Scrolls carousel, so that element with specified index is the left-most. + This method is convenient when using carousel in a tabbed navigation. + Clicking on first tab should scroll first container into view, clicking on a fifth - fifth one, etc. + Indexing starts with 0. + + Parameters: + Index of an element which will be a left-most visible in the carousel + + Returns: + this + */ + scrollTo: function(index) { + if (this.animating || index < 0 || index > this.elements.length || index == this.currentIndex() || isNaN(parseInt(index))) + return this; + return this.scroll((this.currentIndex() - index) * this.elementSize); + }, + + /* + Method: updateButtons + Update buttons status to enabled or disabled + Them status is defined by classNames and fired as carousel's custom events + + Returns: + this + */ + updateButtons: function() { + this.updatePreviousButton(); + this.updateNextButton(); + return this; + }, + + updatePreviousButton: function() { + var position = this.currentPosition(); + var previousClassName = "previous_button" + this.options.disabledButtonSuffix; + + if (this.previousButton.hasClassName(previousClassName) && position != 0) { + this.previousButton.removeClassName(previousClassName); + this.fire('previousButton:enabled'); + } + if (!this.previousButton.hasClassName(previousClassName) && position == 0) { + this.previousButton.addClassName(previousClassName); + this.fire('previousButton:disabled'); + } + }, + + updateNextButton: function() { + var lastPosition = this.currentLastPosition(); + var size = this.currentSize(); + var nextClassName = "next_button" + this.options.disabledButtonSuffix; + + if (this.nextButton.hasClassName(nextClassName) && lastPosition != size) { + this.nextButton.removeClassName(nextClassName); + this.fire('nextButton:enabled'); + } + if (!this.nextButton.hasClassName(nextClassName) && lastPosition == size) { + this.nextButton.addClassName(nextClassName); + this.fire('nextButton:disabled'); + } + }, + + // Group: Size and Position + + /* + Method: computeElementSize + Return elements size in pixel, height or width depends on carousel orientation. + + Returns: + an integer value + */ + computeElementSize: function() { + return this.elements.first().getDimensions()[this.dimAttribute]; + }, + + /* + Method: currentIndex + Returns current visible index of a carousel. + For example, a horizontal carousel with image #3 on left will return 3 and with half of image #3 will return 3.5 + Don't forget that the first image have an index 0 + + Returns: + a float value + */ + currentIndex: function() { + return - this.currentPosition() / this.elementSize; + }, + + /* + Method: currentLastPosition + Returns the current position from the end of the last element. This value is in pixel. + + Returns: + an integer value, if no images a present it will return 0 + */ + currentLastPosition: function() { + if (this.container.childElements().empty()) + return 0; + return this.currentPosition() + + this.elements.last().positionedOffset()[this.posAttribute] + + this.elementSize; + }, + + /* + Method: currentPosition + Returns the current position in pixel. + Tips: To get the position in elements use currentIndex() + + Returns: + an integer value + */ + currentPosition: function() { + return this.container.getNumStyle(this.posAttribute); + }, + + /* + Method: currentSize + Returns the current size of the carousel in pixel + + Returns: + Carousel's size in pixel + */ + currentSize: function() { + return this.container.parentNode.getDimensions()[this.dimAttribute]; + }, + + /* + Method: updateSize + Should be called if carousel size has been changed (usually called with a liquid layout) + + Returns: + this + */ + updateSize: function() { + this.nbVisible = this.currentSize() / this.elementSize; + var scrollInc = this.options.scrollInc; + if (scrollInc == "auto") + scrollInc = Math.floor(this.nbVisible); + + [ this.previousButton, this.nextButton ].each(function(button) { + if (!button) return; + button.stopObserving("click", button.clickHandler); + button.clickHandler = this.scroll.bind(this, (button == this.nextButton ? -1 : 1) * scrollInc * this.elementSize); + button.observe("click", button.clickHandler); + }, this); + + this.checkScroll(this.currentPosition(), true); + this.updateButtons().fire('sizeUpdated'); + return this; + } +}); +/* + Class: UI.Ajax.Carousel + + Gives the AJAX power to carousels. An AJAX carousel : + * Use AJAX to add new elements on the fly + + Example: + > new UI.Ajax.Carousel("horizontal_carousel", + > {url: "get-more-elements", elementSize: 250}); +*/ +UI.Ajax.Carousel = Class.create(UI.Carousel, { + // Group: Options + // + // Notice: + // It also include of all carousel's options + options: { + // Property: elementSize + // Required, it define the size of all elements + elementSize : -1, + + // Property: url + // Required, it define the URL used by AJAX carousel to request new elements details + url : null + }, + + /* + Group: Attributes + + Notice: + It also include of all carousel's attributes + + Property: elementSize + Size of each elements, it's an integer + + Property: endIndex + Index of the last loaded element + + Property: hasMore + Flag to define if there's still more elements to load + + Property: requestRunning + Define whether a request is processing or not + + Property: updateHandler + Callback to update carousel, usually used after request success + + Property: url + URL used to request additional elements + */ + + /* + Group: Events + List of events fired by an AJAX carousel, it also include of all carousel's custom events + + Property: request:started + Fired when the request has just started + + Property: request:ended + Fired when the request has succeed + */ + + // Group: Constructor + + /* + Method: initialize + Constructor function, should not be called directly + + Parameters: + element - DOM element + options - (Hash) list of optional parameters + + Returns: + this + */ + initialize: function($super, element, options) { + if (!options.url) + throw("url option is required for UI.Ajax.Carousel"); + if (!options.elementSize) + throw("elementSize option is required for UI.Ajax.Carousel"); + + $super(element, options); + + this.endIndex = 0; + this.hasMore = true; + + // Cache handlers + this.updateHandler = this.update.bind(this); + this.updateAndScrollHandler = function(nbElements, transport, json) { + this.update(transport, json); + this.scroll(nbElements); + }.bind(this); + + // Run first ajax request to fill the carousel + this.runRequest.bind(this).defer({parameters: {from: 0, to: Math.floor(this.nbVisible)}, onSuccess: this.updateHandler}); + }, + + // Group: Actions + + /* + Method: runRequest + Request the new elements details + + Parameters: + options - (Hash) list of optional parameters + + Returns: + this + */ + runRequest: function(options) { + this.requestRunning = true; + //alert("Asking for: " + options.parameters.from + " - " + options.parameters.to); + new Ajax.Request(this.options.url, Object.extend({method: "GET"}, options)); + this.fire("request:started"); + return this; + }, + + /* + Method: scroll + Scrolls carousel from maximum deltaPixel + + Parameters: + deltaPixel - a float + + Returns: + this + */ + scroll: function($super, deltaPixel) { + if (this.animating || this.requestRunning) + return this; + + var nbElements = (-deltaPixel) / this.elementSize; + // Check if there is not enough + if (this.hasMore && nbElements > 0 && this.currentIndex() + this.nbVisible + nbElements - 1 > this.endIndex) { + var from = this.endIndex + 1; + var to = Math.floor(from + this.nbVisible - 1); + this.runRequest({parameters: {from: from, to: to}, onSuccess: this.updateAndScrollHandler.curry(deltaPixel).bind(this)}); + return this; + } + else + $super(deltaPixel); + }, + + /* + Method: update + Update the carousel + + Parameters: + transport - XMLHttpRequest object + json - JSON object + + Returns: + this + */ + update: function(transport, json) { + this.requestRunning = false; + this.fire("request:ended"); + if (!json) + json = transport.responseJSON; + this.hasMore = json.more; + + this.endIndex = Math.max(this.endIndex, json.to); + this.elements = this.container.insert({bottom: json.html}).childElements(); + return this.updateButtons(); + }, + + // Group: Size and Position + + /* + Method: computeElementSize + Return elements size in pixel + + Returns: + an integer value + */ + computeElementSize: function() { + return this.options.elementSize; + }, + + /* + Method: updateSize + Should be called if carousel size has been changed (usually called with a liquid layout) + + Returns: + this + */ + updateSize: function($super) { + var nbVisible = this.nbVisible; + $super(); + // If we have enough space for at least a new element + if (Math.floor(this.nbVisible) - Math.floor(nbVisible) >= 1 && this.hasMore) { + if (this.currentIndex() + Math.floor(this.nbVisible) >= this.endIndex) { + var nbNew = Math.floor(this.currentIndex() + Math.floor(this.nbVisible) - this.endIndex); + this.runRequest({parameters: {from: this.endIndex + 1, to: this.endIndex + nbNew}, onSuccess: this.updateHandler}); + } + } + return this; + }, + + updateNextButton: function($super) { + var lastPosition = this.currentLastPosition(); + var size = this.currentSize(); + var nextClassName = "next_button" + this.options.disabledButtonSuffix; + + if (this.nextButton.hasClassName(nextClassName) && lastPosition != size) { + this.nextButton.removeClassName(nextClassName); + this.fire('nextButton:enabled'); + } + if (!this.nextButton.hasClassName(nextClassName) && lastPosition == size && !this.hasMore) { + this.nextButton.addClassName(nextClassName); + this.fire('nextButton:disabled'); + } + } +}); diff --git a/ansel/js/cropper.js b/ansel/js/cropper.js new file mode 100644 index 000000000..08519bb5c --- /dev/null +++ b/ansel/js/cropper.js @@ -0,0 +1,555 @@ +/** + * Copyright 2006, David Spurr (http://www.defusion.org.uk/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * * Neither the name of the David Spurr nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://www.opensource.org/licenses/bsd-license.php + * + * See scriptaculous.js for full scriptaculous licence + */ + +var CropDraggable=Class.create(); +Object.extend(Object.extend(CropDraggable.prototype,Draggable.prototype),{initialize:function(_1){ +this.options=Object.extend({drawMethod:function(){ +}},arguments[1]||{}); +this.element=$(_1); +this.handle=this.element; +this.delta=this.currentDelta(); +this.dragging=false; +this.eventMouseDown=this.initDrag.bindAsEventListener(this); +Event.observe(this.handle,"mousedown",this.eventMouseDown); +Draggables.register(this); +},draw:function(_2){ +var _3=Position.cumulativeOffset(this.element); +var d=this.currentDelta(); +_3[0]-=d[0]; +_3[1]-=d[1]; +var p=[0,1].map(function(i){ +return (_2[i]-_3[i]-this.offset[i]); +}.bind(this)); +this.options.drawMethod(p); +}}); +var Cropper={}; +Cropper.Img=Class.create(); +Cropper.Img.prototype={initialize:function(_7,_8){ +this.options=Object.extend({ratioDim:{x:0,y:0},minWidth:0,minHeight:0,displayOnInit:false,onEndCrop:Prototype.emptyFunction,captureKeys:true,onloadCoords:null,maxWidth:0,maxHeight:0},_8||{}); +this.img=$(_7); +this.clickCoords={x:0,y:0}; +this.dragging=false; +this.resizing=false; +this.isWebKit=/Konqueror|Safari|KHTML/.test(navigator.userAgent); +this.isIE=/MSIE/.test(navigator.userAgent); +this.isOpera8=/Opera\s[1-8]/.test(navigator.userAgent); +this.ratioX=0; +this.ratioY=0; +this.attached=false; +this.fixedWidth=(this.options.maxWidth>0&&(this.options.minWidth>=this.options.maxWidth)); +this.fixedHeight=(this.options.maxHeight>0&&(this.options.minHeight>=this.options.maxHeight)); +if(typeof this.img=="undefined"){ +return; +} +if(this.options.ratioDim.x>0&&this.options.ratioDim.y>0){ +var _c=this.getGCD(this.options.ratioDim.x,this.options.ratioDim.y); +this.ratioX=this.options.ratioDim.x/_c; +this.ratioY=this.options.ratioDim.y/_c; +} +this.subInitialize(); +if(this.img.complete||this.isWebKit){ +this.onLoad(); +}else{ +Event.observe(this.img,"load",this.onLoad.bindAsEventListener(this)); +} +},getGCD:function(a,b){ +if(b==0){ +return a; +} +return this.getGCD(b,a%b); +},onLoad:function(){ +var _f="imgCrop_"; +var _10=this.img.parentNode; +var _11=""; +if(this.isOpera8){ +_11=" opera8"; +} +this.imgWrap=Builder.node("div",{"class":_f+"wrap"+_11}); +this.north=Builder.node("div",{"class":_f+"overlay "+_f+"north"},[Builder.node("span")]); +this.east=Builder.node("div",{"class":_f+"overlay "+_f+"east"},[Builder.node("span")]); +this.south=Builder.node("div",{"class":_f+"overlay "+_f+"south"},[Builder.node("span")]); +this.west=Builder.node("div",{"class":_f+"overlay "+_f+"west"},[Builder.node("span")]); +var _12=[this.north,this.east,this.south,this.west]; +this.dragArea=Builder.node("div",{"class":_f+"dragArea"},_12); +this.handleN=Builder.node("div",{"class":_f+"handle "+_f+"handleN"}); +this.handleNE=Builder.node("div",{"class":_f+"handle "+_f+"handleNE"}); +this.handleE=Builder.node("div",{"class":_f+"handle "+_f+"handleE"}); +this.handleSE=Builder.node("div",{"class":_f+"handle "+_f+"handleSE"}); +this.handleS=Builder.node("div",{"class":_f+"handle "+_f+"handleS"}); +this.handleSW=Builder.node("div",{"class":_f+"handle "+_f+"handleSW"}); +this.handleW=Builder.node("div",{"class":_f+"handle "+_f+"handleW"}); +this.handleNW=Builder.node("div",{"class":_f+"handle "+_f+"handleNW"}); +this.selArea=Builder.node("div",{"class":_f+"selArea"},[Builder.node("div",{"class":_f+"marqueeHoriz "+_f+"marqueeNorth"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeVert "+_f+"marqueeEast"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeHoriz "+_f+"marqueeSouth"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeVert "+_f+"marqueeWest"},[Builder.node("span")]),this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW,Builder.node("div",{"class":_f+"clickArea"})]); +this.imgWrap.appendChild(this.img); +this.imgWrap.appendChild(this.dragArea); +this.dragArea.appendChild(this.selArea); +this.dragArea.appendChild(Builder.node("div",{"class":_f+"clickArea"})); +_10.appendChild(this.imgWrap); +this.startDragBind=this.startDrag.bindAsEventListener(this); +Event.observe(this.dragArea,"mousedown",this.startDragBind); +this.onDragBind=this.onDrag.bindAsEventListener(this); +Event.observe(document,"mousemove",this.onDragBind); +this.endCropBind=this.endCrop.bindAsEventListener(this); +Event.observe(document,"mouseup",this.endCropBind); +this.resizeBind=this.startResize.bindAsEventListener(this); +this.handles=[this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW]; +this.registerHandles(true); +if(this.options.captureKeys){ +this.keysBind=this.handleKeys.bindAsEventListener(this); +Event.observe(document,"keypress",this.keysBind); +} +new CropDraggable(this.selArea,{drawMethod:this.moveArea.bindAsEventListener(this)}); +this.setParams(); +},registerHandles:function(_13){ +for(var i=0;i0&&this.options.ratioDim.y>0){ +_1a.x1=Math.ceil((this.imgW-this.options.ratioDim.x)/2); +_1a.y1=Math.ceil((this.imgH-this.options.ratioDim.y)/2); +_1a.x2=_1a.x1+this.options.ratioDim.x; +_1a.y2=_1a.y1+this.options.ratioDim.y; +_1b=true; +} +} +this.setAreaCoords(_1a,false,false,1); +if(this.options.displayOnInit&&_1b){ +this.selArea.show(); +this.drawArea(); +this.endCrop(); +} +this.attached=true; +},remove:function(){ +if(this.attached){ +this.attached=false; +this.imgWrap.parentNode.insertBefore(this.img,this.imgWrap); +this.imgWrap.parentNode.removeChild(this.imgWrap); +Event.stopObserving(this.dragArea,"mousedown",this.startDragBind); +Event.stopObserving(document,"mousemove",this.onDragBind); +Event.stopObserving(document,"mouseup",this.endCropBind); +this.registerHandles(false); +if(this.options.captureKeys){ +Event.stopObserving(document,"keypress",this.keysBind); +} +} +},reset:function(){ +if(!this.attached){ +this.onLoad(); +}else{ +this.setParams(); +} +this.endCrop(); +},handleKeys:function(e){ +var dir={x:0,y:0}; +if(!this.dragging){ +switch(e.keyCode){ +case (37): +dir.x=-1; +break; +case (38): +dir.y=-1; +break; +case (39): +dir.x=1; +break; +case (40): +dir.y=1; +break; +} +if(dir.x!=0||dir.y!=0){ +if(e.shiftKey){ +dir.x*=10; +dir.y*=10; +} +this.moveArea([this.areaCoords.x1+dir.x,this.areaCoords.y1+dir.y]); +Event.stop(e); +} +} +},calcW:function(){ +return (this.areaCoords.x2-this.areaCoords.x1); +},calcH:function(){ +return (this.areaCoords.y2-this.areaCoords.y1); +},moveArea:function(_1e){ +this.setAreaCoords({x1:_1e[0],y1:_1e[1],x2:_1e[0]+this.calcW(),y2:_1e[1]+this.calcH()},true,false); +this.drawArea(); +},cloneCoords:function(_1f){ +return {x1:_1f.x1,y1:_1f.y1,x2:_1f.x2,y2:_1f.y2}; +},setAreaCoords:function(_20,_21,_22,_23,_24){ +if(_21){ +var _25=_20.x2-_20.x1; +var _26=_20.y2-_20.y1; +if(_20.x1<0){ +_20.x1=0; +_20.x2=_25; +} +if(_20.y1<0){ +_20.y1=0; +_20.y2=_26; +} +if(_20.x2>this.imgW){ +_20.x2=this.imgW; +_20.x1=this.imgW-_25; +} +if(_20.y2>this.imgH){ +_20.y2=this.imgH; +_20.y1=this.imgH-_26; +} +}else{ +if(_20.x1<0){ +_20.x1=0; +} +if(_20.y1<0){ +_20.y1=0; +} +if(_20.x2>this.imgW){ +_20.x2=this.imgW; +} +if(_20.y2>this.imgH){ +_20.y2=this.imgH; +} +if(_23!=null){ +if(this.ratioX>0){ +this.applyRatio(_20,{x:this.ratioX,y:this.ratioY},_23,_24); +}else{ +if(_22){ +this.applyRatio(_20,{x:1,y:1},_23,_24); +} +} +var _27=[this.options.minWidth,this.options.minHeight]; +var _28=[this.options.maxWidth,this.options.maxHeight]; +if(_27[0]>0||_27[1]>0||_28[0]>0||_28[1]>0){ +var _29={a1:_20.x1,a2:_20.x2}; +var _2a={a1:_20.y1,a2:_20.y2}; +var _2b={min:0,max:this.imgW}; +var _2c={min:0,max:this.imgH}; +if((_27[0]!=0||_27[1]!=0)&&_22){ +if(_27[0]>0){ +_27[1]=_27[0]; +}else{ +if(_27[1]>0){ +_27[0]=_27[1]; +} +} +} +if((_28[0]!=0||_28[0]!=0)&&_22){ +if(_28[0]>0&&_28[0]<=_28[1]){ +_28[1]=_28[0]; +}else{ +if(_28[1]>0&&_28[1]<=_28[0]){ +_28[0]=_28[1]; +} +} +} +if(_27[0]>0){ +this.applyDimRestriction(_29,_27[0],_23.x,_2b,"min"); +} +if(_27[1]>1){ +this.applyDimRestriction(_2a,_27[1],_23.y,_2c,"min"); +} +if(_28[0]>0){ +this.applyDimRestriction(_29,_28[0],_23.x,_2b,"max"); +} +if(_28[1]>1){ +this.applyDimRestriction(_2a,_28[1],_23.y,_2c,"max"); +} +_20={x1:_29.a1,y1:_2a.a1,x2:_29.a2,y2:_2a.a2}; +} +} +} +this.areaCoords=_20; +},applyDimRestriction:function(_2d,val,_2f,_30,_31){ +var _32; +if(_31=="min"){ +_32=((_2d.a2-_2d.a1)val); +} +if(_32){ +if(_2f==1){ +_2d.a2=_2d.a1+val; +}else{ +_2d.a1=_2d.a2-val; +} +if(_2d.a1<_30.min){ +_2d.a1=_30.min; +_2d.a2=val; +}else{ +if(_2d.a2>_30.max){ +_2d.a1=_30.max-val; +_2d.a2=_30.max; +} +} +} +},applyRatio:function(_33,_34,_35,_36){ +var _37; +if(_36=="N"||_36=="S"){ +_37=this.applyRatioToAxis({a1:_33.y1,b1:_33.x1,a2:_33.y2,b2:_33.x2},{a:_34.y,b:_34.x},{a:_35.y,b:_35.x},{min:0,max:this.imgW}); +_33.x1=_37.b1; +_33.y1=_37.a1; +_33.x2=_37.b2; +_33.y2=_37.a2; +}else{ +_37=this.applyRatioToAxis({a1:_33.x1,b1:_33.y1,a2:_33.x2,b2:_33.y2},{a:_34.x,b:_34.y},{a:_35.x,b:_35.y},{min:0,max:this.imgH}); +_33.x1=_37.a1; +_33.y1=_37.b1; +_33.x2=_37.a2; +_33.y2=_37.b2; +} +},applyRatioToAxis:function(_38,_39,_3a,_3b){ +var _3c=Object.extend(_38,{}); +var _3d=_3c.a2-_3c.a1; +var _3e=Math.floor(_3d*_39.b/_39.a); +var _3f; +var _40; +var _41=null; +if(_3a.b==1){ +_3f=_3c.b1+_3e; +if(_3f>_3b.max){ +_3f=_3b.max; +_41=_3f-_3c.b1; +} +_3c.b2=_3f; +}else{ +_3f=_3c.b2-_3e; +if(_3f<_3b.min){ +_3f=_3b.min; +_41=_3f+_3c.b2; +} +_3c.b1=_3f; +} +if(_41!=null){ +_40=Math.floor(_41*_39.a/_39.b); +if(_3a.a==1){ +_3c.a2=_3c.a1+_40; +}else{ +_3c.a1=_3c.a1=_3c.a2-_40; +} +} +return _3c; +},drawArea:function(){ +var _42=this.calcW(); +var _43=this.calcH(); +var px="px"; +var _45=[this.areaCoords.x1+px,this.areaCoords.y1+px,_42+px,_43+px,this.areaCoords.x2+px,this.areaCoords.y2+px,(this.img.width-this.areaCoords.x2)+px,(this.img.height-this.areaCoords.y2)+px]; +var _46=this.selArea.style; +_46.left=_45[0]; +_46.top=_45[1]; +_46.width=_45[2]; +_46.height=_45[3]; +var _47=Math.ceil((_42-6)/2)+px; +var _48=Math.ceil((_43-6)/2)+px; +this.handleN.style.left=_47; +this.handleE.style.top=_48; +this.handleS.style.left=_47; +this.handleW.style.top=_48; +this.north.style.height=_45[1]; +var _49=this.east.style; +_49.top=_45[1]; +_49.height=_45[3]; +_49.left=_45[4]; +_49.width=_45[6]; +var _4a=this.south.style; +_4a.top=_45[5]; +_4a.height=_45[7]; +var _4b=this.west.style; +_4b.top=_45[1]; +_4b.height=_45[3]; +_4b.width=_45[0]; +this.subDrawArea(); +this.forceReRender(); +},forceReRender:function(){ +if(this.isIE||this.isWebKit){ +var n=document.createTextNode(" "); +var d,el,fixEL,i; +if(this.isIE){ +fixEl=this.selArea; +}else{ +if(this.isWebKit){ +fixEl=document.getElementsByClassName("imgCrop_marqueeSouth",this.imgWrap)[0]; +d=Builder.node("div",""); +d.style.visibility="hidden"; +var _4e=["SE","S","SW"]; +for(i=0;i<_4e.length;i++){ +el=document.getElementsByClassName("imgCrop_handle"+_4e[i],this.selArea)[0]; +if(el.childNodes.length){ +el.removeChild(el.childNodes[0]); +} +el.appendChild(d); +} +} +} +fixEl.appendChild(n); +fixEl.removeChild(n); +} +},startResize:function(e){ +this.startCoords=this.cloneCoords(this.areaCoords); +this.resizing=true; +this.resizeHandle=Event.element(e).classNames().toString().replace(/([^N|NE|E|SE|S|SW|W|NW])+/,""); +Event.stop(e); +},startDrag:function(e){ +this.selArea.show(); +this.clickCoords=this.getCurPos(e); +this.setAreaCoords({x1:this.clickCoords.x,y1:this.clickCoords.y,x2:this.clickCoords.x,y2:this.clickCoords.y},false,false,null); +this.dragging=true; +this.onDrag(e); +Event.stop(e); +},getCurPos:function(e){ +var el=this.imgWrap,wrapOffsets=Position.cumulativeOffset(el); +while(el.nodeName!="BODY"){ +wrapOffsets[1]-=el.scrollTop||0; +wrapOffsets[0]-=el.scrollLeft||0; +el=el.parentNode; +} +return curPos={x:Event.pointerX(e)-wrapOffsets[0],y:Event.pointerY(e)-wrapOffsets[1]}; +},onDrag:function(e){ +if(this.dragging||this.resizing){ +var _54=null; +var _55=this.getCurPos(e); +var _56=this.cloneCoords(this.areaCoords); +var _57={x:1,y:1}; +if(this.dragging){ +if(_55.x_59){ +_5c.reverse(); +} +_5a[_5b+"1"]=_5c[0]; +_5a[_5b+"2"]=_5c[1]; +},endCrop:function(){ +this.dragging=false; +this.resizing=false; +this.options.onEndCrop(this.areaCoords,{width:this.calcW(),height:this.calcH()}); +},subInitialize:function(){ +},subDrawArea:function(){ +}}; +Cropper.ImgWithPreview=Class.create(); +Object.extend(Object.extend(Cropper.ImgWithPreview.prototype,Cropper.Img.prototype),{subInitialize:function(){ +this.hasPreviewImg=false; +if(typeof (this.options.previewWrap)!="undefined"&&this.options.minWidth>0&&this.options.minHeight>0){ +this.previewWrap=$(this.options.previewWrap); +this.previewImg=this.img.cloneNode(false); +this.previewImg.id="imgCrop_"+this.previewImg.id; +this.options.displayOnInit=true; +this.hasPreviewImg=true; +this.previewWrap.addClassName("imgCrop_previewWrap"); +this.previewWrap.setStyle({width:this.options.minWidth+"px",height:this.options.minHeight+"px"}); +this.previewWrap.appendChild(this.previewImg); +} +},subDrawArea:function(){ +if(this.hasPreviewImg){ +var _5d=this.calcW(); +var _5e=this.calcH(); +var _5f={x:this.imgW/_5d,y:this.imgH/_5e}; +var _60={x:_5d/this.options.minWidth,y:_5e/this.options.minHeight}; +var _61={w:Math.ceil(this.options.minWidth*_5f.x)+"px",h:Math.ceil(this.options.minHeight*_5f.y)+"px",x:"-"+Math.ceil(this.areaCoords.x1/_60.x)+"px",y:"-"+Math.ceil(this.areaCoords.y1/_60.y)+"px"}; +var _62=this.previewImg.style; +_62.width=_61.w; +_62.height=_61.h; +_62.left=_61.x; +_62.top=_61.y; +} +}}); + diff --git a/ansel/js/editcaption.js b/ansel/js/editcaption.js new file mode 100644 index 000000000..3b49ac2d4 --- /dev/null +++ b/ansel/js/editcaption.js @@ -0,0 +1,38 @@ +// InPlaceEditor extension based somewhat on an example given in the +// scriptaculous wiki +Ajax.InPlaceEditor.prototype.__initialize = Ajax.InPlaceEditor.prototype.initialize; +Ajax.InPlaceEditor.prototype.__getText = Ajax.InPlaceEditor.prototype.getText; +Object.extend(Ajax.InPlaceEditor.prototype, { + initialize: function(element, url, options) { + this.__initialize(element, url, options); + this.setOptions(options); + // Remove this line to stop from auto-showing the + // empty caption text on page load. + this.checkEmpty(); + }, + + setOptions: function(options) { + this.options = Object.extend(Object.extend(this.options, { + emptyClassName: 'inplaceeditor-empty' + }),options||{}); + }, + + checkEmpty: function() { + if (this.element.innerHTML.length == 0) { + emptyNode = new Element('span', {className: this.options.emptyClassName}).update(this.options.emptyText); + this.element.appendChild(emptyNode); + } + }, + + getText: function() { + $(this.element).select('.' + this.options.emptyClassName).each(function(child) { + this.element.removeChild(child); + }.bind(this)); + return this.__getText(); + } +}); + +function tileExit(ipe, e) +{ + ipe.checkEmpty(); +} diff --git a/ansel/js/editfaces.js b/ansel/js/editfaces.js new file mode 100644 index 000000000..4657ac155 --- /dev/null +++ b/ansel/js/editfaces.js @@ -0,0 +1,56 @@ +document.observe('dom:loaded', function() { + Ansel.deleteFace = function(image_id, face_id) + { + new Ajax.Request(Ansel.ajax.editFaces.url, + { + method: 'post', + parameters: { + action: 'delete', + image: image_id, + face: face_id + } + }); + $('face' + face_id).remove(); + }; + + Ansel.setFaceName = function(image_id, face_id) + { + new Ajax.Request(Ansel.ajax.editFaces.url, + { + method: 'post', + parameters: + { + action: 'setname', + face: face_id, + image: image_id, + facename: encodeURIComponent($F('facename' + face_id)) + }, + onComplete: function(r) { + if (r.responseJSON.response == 1) { + $('faces_widget_content').update(r.responseJSON.message); + } + } + } + ); + }; + + Ansel.doFaceEdit = function(image_id) + { + $('faces_widget_content').update(Ansel.ajax.editFaces.text.loading); + new Ajax.Request(Ansel.ajax.editFaces.url, + { + method: 'post', + parameters: + { + action: 'process', + image: image_id + }, + onComplete: function(r) { + if (r.responseJSON.response == 1) { + $('faces_widget_content').update(r.responseJSON.message); + } + } + } + ); + }; +}); \ No newline at end of file diff --git a/ansel/js/embed.js b/ansel/js/embed.js new file mode 100755 index 000000000..f7f49e6f8 --- /dev/null +++ b/ansel/js/embed.js @@ -0,0 +1,158 @@ +// 0) { + (function() { + var jx = j; + + var nextLink = new Element('a',{href: '#', title: 'Next Image', className: 'anselNext', style: 'text-decoration:none;width:40%;float:right;'}); + nextLink.update('>>'); + var arg1 = {node: jx, page: 1}; + nextLink.observe('click', function(e) {displayPage(e, arg1)}); + + var prevLink = new Element('a',{href: '#', title: 'Previous Image', className: 'anselPrev', style: 'text-decoration:none;width:40%;float:right;'}); + prevLink.update('<<'); + var arg2 = {node: jx, page: -1}; + prevLink.observe('click', function(e) {displayPage(e, arg2)}); + $(jx).appendChild(nextLink); + $(jx).appendChild(prevLink); + Horde_ToolTips.attachBehavior(jx); + Event.observe(window, 'unload', Horde_ToolTips.out.bind(Horde_ToolTips)); + + })(); + } else { + (function () { + var jx = j; + Horde_ToolTips.attachBehavior(jx); + })(); + } + } + if (lightboxData.length) { + lbOptions['gallery_json'] = lightboxData; + ansel_lb = new Lightbox(lbOptions); + } + + Event.observe(window, 'unload', Horde_ToolTips.out.bind(Horde_ToolTips)); + }); + +/** + * Display the images from the requested page for the requested node. + * + * @param string $node The DOM id of the embedded widget. + * @param integer $page The requested page number. + */ +function displayPage(event, args) { + var node = args.node; + var page = args.page; + var perpage = anseljson[node]['perpage']; + var imgcount = anseljson[node]['data'].size(); + var pages = Math.ceil(imgcount / perpage) - 1; + var oldPage = anseljson[node]['page']; + + page = oldPage + page; + + /* Rollover? */ + if (page > pages) { + page = 0; + } + if (page < 0) { + page = pages; + } + + var mainNode = $(node); + mainNode.update(); + var start = page * perpage; + var end = Math.min(imgcount - 1, start + perpage - 1); + for (var i = start; i <= end; i++) { + var imgContainer = mainNode.appendChild(new Element('span', {className: 'anselGalleryWidget'})); + var imgLink = imgContainer.appendChild(new Element('a', + { + href: anseljson[node]['data'][i][5], + alt: anseljson[node]['data'][i][2], + title: anseljson[node]['data'][i][2] + })); + imgLink.appendChild(new Element('img', {src: anseljson[node]['data'][i][0]})); + } + + var nextLink = new Element('a',{href: '', title: 'Next Image', style: 'text-decoration:none;width:40%;float:right;'}); + nextLink.update('>>'); + + var args = {node: node, page: ++oldPage}; + nextLink.observe('click', function(e) {displayPage(e, args);}.bind()); + + var prevLink = new Element('a',{href: '', title: 'Previous Image', style: 'text-decoration:none;width:40%;float:right;'}); + prevLink.update('<<'); + + var args = {node: node, page: --oldPage}; + prevLink.observe('click', function(e) {displayPage(e, args);}.bind()); + + mainNode.appendChild(nextLink); + mainNode.appendChild(prevLink); + + Horde_ToolTips.attachBehavior(node); + anseljson[node]['page'] = page; + event.stop(); +} +//] diff --git a/ansel/js/googlemap.js b/ansel/js/googlemap.js new file mode 100644 index 000000000..c0992e072 --- /dev/null +++ b/ansel/js/googlemap.js @@ -0,0 +1,502 @@ +/** + * Google maps implementation for Ansel + * + * Copyright 2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (GPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. + * + * @author Michael J. Rubinsky + */ +var Ansel_GMap = Class.create(); + +Ansel_GMap.prototype = { + // Main google map handle + mainMap: undefined, + + // Smaller overview map handle + smallMap: undefined, + + // Tinymarker icons... + tI: undefined, + tIO: undefined, + + // GLatLngBounds obejct for calculating proper center and zoom + bounds: undefined, + + // Geocoder + geocoder: undefined, + + // MarkerManager, if we are browsing the map. + // Note we need - > ... -*/ -UI.Carousel = Class.create(UI.Options, { - // Group: Options - options: { - // Property: direction - // Can be horizontal or vertical, horizontal by default - direction : "horizontal", - - // Property: previousButton - // Selector of previous button inside carousel element, ".previous_button" by default, - // set it to false to ignore previous button - previousButton : ".previous_button", - - // Property: nextButton - // Selector of next button inside carousel element, ".next_button" by default, - // set it to false to ignore next button - nextButton : ".next_button", - - // Property: container - // Selector of carousel container inside carousel element, ".container" by default, - container : ".container", - - // Property: scrollInc - // Define the maximum number of elements that gonna scroll each time, auto by default - scrollInc : "auto", - - // Property: disabledButtonSuffix - // Define the suffix classanme used when a button get disabled, to '_disabled' by default - // Previous button classname will be previous_button_disabled - disabledButtonSuffix : '_disabled', - - // Property: overButtonSuffix - // Define the suffix classanme used when a button has a rollover status, '_over' by default - // Previous button classname will be previous_button_over - overButtonSuffix : '_over' - }, - - /* - Group: Attributes - - Property: element - DOM element containing the carousel - - Property: id - DOM id of the carousel's element - - Property: container - DOM element containing the carousel's elements - - Property: elements - Array containing the carousel's elements as DOM elements - - Property: previousButton - DOM id of the previous button - - Property: nextButton - DOM id of the next button - - Property: posAttribute - Define if the positions are from left or top - - Property: dimAttribute - Define if the dimensions are horizontal or vertical - - Property: elementSize - Size of each element, it's an integer - - Property: nbVisible - Number of visible elements, it's a float - - Property: animating - Define whether the carousel is in animation or not - */ - - /* - Group: Events - List of events fired by a carousel - - Notice: Carousel custom events are automatically namespaced in "carousel:" (see Prototype custom events). - - Examples: - This example will observe all carousels - > document.observe('carousel:scroll:ended', function(event) { - > alert("Carousel with id " + event.memo.carousel.id + " has just been scrolled"); - > }); - - This example will observe only this carousel - > new UI.Carousel('horizontal_carousel').observe('scroll:ended', function(event) { - > alert("Carousel with id " + event.memo.carousel.id + " has just been scrolled"); - > }); - - Property: previousButton:enabled - Fired when the previous button has just been enabled - - Property: previousButton:disabled - Fired when the previous button has just been disabled - - Property: nextButton:enabled - Fired when the next button has just been enabled - - Property: nextButton:disabled - Fired when the next button has just been disabled - - Property: scroll:started - Fired when a scroll has just started - - Property: scroll:ended - Fired when a scroll has been done, - memo.shift = number of elements scrolled, it's a float - - Property: sizeUpdated - Fired when the carousel size has just been updated. - Tips: memo.carousel.currentSize() = the new carousel size - */ - - // Group: Constructor - - /* - Method: initialize - Constructor function, should not be called directly - - Parameters: - element - DOM element - options - (Hash) list of optional parameters - - Returns: - this - */ - initialize: function(element, options) { - this.setOptions(options); - this.element = $(element); - this.id = this.element.id; - this.container = this.element.down(this.options.container).firstDescendant(); - this.elements = this.container.childElements(); - this.previousButton = this.options.previousButton == false ? null : this.element.down(this.options.previousButton); - this.nextButton = this.options.nextButton == false ? null : this.element.down(this.options.nextButton); - - this.posAttribute = (this.options.direction == "horizontal" ? "left" : "top"); - this.dimAttribute = (this.options.direction == "horizontal" ? "width" : "height"); - - this.elementSize = this.computeElementSize(); - this.nbVisible = this.currentSize() / this.elementSize; - - var scrollInc = this.options.scrollInc; - if (scrollInc == "auto") - scrollInc = Math.floor(this.nbVisible); - [ this.previousButton, this.nextButton ].each(function(button) { - if (!button) return; - var className = (button == this.nextButton ? "next_button" : "previous_button") + this.options.overButtonSuffix; - button.clickHandler = this.scroll.bind(this, (button == this.nextButton ? -1 : 1) * scrollInc * this.elementSize); - button.observe("click", button.clickHandler) - .observe("mouseover", function() {button.addClassName(className)}.bind(this)) - .observe("mouseout", function() {button.removeClassName(className)}.bind(this)); - }, this); - this.updateButtons(); - }, - - // Group: Destructor - - /* - Method: destroy - Cleans up DOM and memory - */ - destroy: function($super) { - [ this.previousButton, this.nextButton ].each(function(button) { - if (!button) return; - button.stopObserving("click", button.clickHandler); - }, this); - this.element.remove(); - this.fire('destroyed'); - }, - - // Group: Event handling - - /* - Method: fire - Fires a carousel custom event automatically namespaced in "carousel:" (see Prototype custom events). - The memo object contains a "carousel" property referring to the carousel. - - Example: - > document.observe('carousel:scroll:ended', function(event) { - > alert("Carousel with id " + event.memo.carousel.id + " has just been scrolled"); - > }); - - Parameters: - eventName - an event name - memo - a memo object - - Returns: - fired event - */ - fire: function(eventName, memo) { - memo = memo || { }; - memo.carousel = this; - return this.element.fire('carousel:' + eventName, memo); - }, - - /* - Method: observe - Observe a carousel event with a handler function automatically bound to the carousel - - Parameters: - eventName - an event name - handler - a handler function - - Returns: - this - */ - observe: function(eventName, handler) { - this.element.observe('carousel:' + eventName, handler.bind(this)); - return this; - }, - - /* - Method: stopObserving - Unregisters a carousel event, it must take the same parameters as this.observe (see Prototype stopObserving). - - Parameters: - eventName - an event name - handler - a handler function - - Returns: - this - */ - stopObserving: function(eventName, handler) { - this.element.stopObserving('carousel:' + eventName, handler); - return this; - }, - - // Group: Actions - - /* - Method: checkScroll - Check scroll position to avoid unused space at right or bottom - - Parameters: - position - position to check - updatePosition - should the container position be updated ? true/false - - Returns: - position - */ - checkScroll: function(position, updatePosition) { - if (position > 0) - position = 0; - else { - var limit = this.elements.last().positionedOffset()[this.posAttribute] + this.elementSize; - var carouselSize = this.currentSize(); - - if (position + limit < carouselSize) - position += carouselSize - (position + limit); - position = Math.min(position, 0); - } - if (updatePosition) - this.container.style[this.posAttribute] = position + "px"; - - return position; - }, - - /* - Method: scroll - Scrolls carousel from maximum deltaPixel - - Parameters: - deltaPixel - a float - - Returns: - this - */ - scroll: function(deltaPixel) { - if (this.animating) - return this; - - // Compute new position - var position = this.currentPosition() + deltaPixel; - - // Check bounds - position = this.checkScroll(position, false); - - // Compute shift to apply - deltaPixel = position - this.currentPosition(); - if (deltaPixel != 0) { - this.animating = true; - this.fire("scroll:started"); - - var that = this; - // Move effects - this.container.morph("opacity:0.5", {duration: 0.2, afterFinish: function() { - that.container.morph(that.posAttribute + ": " + position + "px", { - duration: 0.4, - delay: 0.2, - afterFinish: function() { - that.container.morph("opacity:1", { - duration: 0.2, - afterFinish: function() { - that.animating = false; - that.updateButtons() - .fire("scroll:ended", { shift: deltaPixel / that.currentSize() }); - } - }); - } - }); - }}); - } - return this; - }, - - /* - Method: scrollTo - Scrolls carousel, so that element with specified index is the left-most. - This method is convenient when using carousel in a tabbed navigation. - Clicking on first tab should scroll first container into view, clicking on a fifth - fifth one, etc. - Indexing starts with 0. - - Parameters: - Index of an element which will be a left-most visible in the carousel - - Returns: - this - */ - scrollTo: function(index) { - if (this.animating || index < 0 || index > this.elements.length || index == this.currentIndex() || isNaN(parseInt(index))) - return this; - return this.scroll((this.currentIndex() - index) * this.elementSize); - }, - - /* - Method: updateButtons - Update buttons status to enabled or disabled - Them status is defined by classNames and fired as carousel's custom events - - Returns: - this - */ - updateButtons: function() { - this.updatePreviousButton(); - this.updateNextButton(); - return this; - }, - - updatePreviousButton: function() { - var position = this.currentPosition(); - var previousClassName = "previous_button" + this.options.disabledButtonSuffix; - - if (this.previousButton.hasClassName(previousClassName) && position != 0) { - this.previousButton.removeClassName(previousClassName); - this.fire('previousButton:enabled'); - } - if (!this.previousButton.hasClassName(previousClassName) && position == 0) { - this.previousButton.addClassName(previousClassName); - this.fire('previousButton:disabled'); - } - }, - - updateNextButton: function() { - var lastPosition = this.currentLastPosition(); - var size = this.currentSize(); - var nextClassName = "next_button" + this.options.disabledButtonSuffix; - - if (this.nextButton.hasClassName(nextClassName) && lastPosition != size) { - this.nextButton.removeClassName(nextClassName); - this.fire('nextButton:enabled'); - } - if (!this.nextButton.hasClassName(nextClassName) && lastPosition == size) { - this.nextButton.addClassName(nextClassName); - this.fire('nextButton:disabled'); - } - }, - - // Group: Size and Position - - /* - Method: computeElementSize - Return elements size in pixel, height or width depends on carousel orientation. - - Returns: - an integer value - */ - computeElementSize: function() { - return this.elements.first().getDimensions()[this.dimAttribute]; - }, - - /* - Method: currentIndex - Returns current visible index of a carousel. - For example, a horizontal carousel with image #3 on left will return 3 and with half of image #3 will return 3.5 - Don't forget that the first image have an index 0 - - Returns: - a float value - */ - currentIndex: function() { - return - this.currentPosition() / this.elementSize; - }, - - /* - Method: currentLastPosition - Returns the current position from the end of the last element. This value is in pixel. - - Returns: - an integer value, if no images a present it will return 0 - */ - currentLastPosition: function() { - if (this.container.childElements().empty()) - return 0; - return this.currentPosition() + - this.elements.last().positionedOffset()[this.posAttribute] + - this.elementSize; - }, - - /* - Method: currentPosition - Returns the current position in pixel. - Tips: To get the position in elements use currentIndex() - - Returns: - an integer value - */ - currentPosition: function() { - return this.container.getNumStyle(this.posAttribute); - }, - - /* - Method: currentSize - Returns the current size of the carousel in pixel - - Returns: - Carousel's size in pixel - */ - currentSize: function() { - return this.container.parentNode.getDimensions()[this.dimAttribute]; - }, - - /* - Method: updateSize - Should be called if carousel size has been changed (usually called with a liquid layout) - - Returns: - this - */ - updateSize: function() { - this.nbVisible = this.currentSize() / this.elementSize; - var scrollInc = this.options.scrollInc; - if (scrollInc == "auto") - scrollInc = Math.floor(this.nbVisible); - - [ this.previousButton, this.nextButton ].each(function(button) { - if (!button) return; - button.stopObserving("click", button.clickHandler); - button.clickHandler = this.scroll.bind(this, (button == this.nextButton ? -1 : 1) * scrollInc * this.elementSize); - button.observe("click", button.clickHandler); - }, this); - - this.checkScroll(this.currentPosition(), true); - this.updateButtons().fire('sizeUpdated'); - return this; - } -}); -/* - Class: UI.Ajax.Carousel - - Gives the AJAX power to carousels. An AJAX carousel : - * Use AJAX to add new elements on the fly - - Example: - > new UI.Ajax.Carousel("horizontal_carousel", - > {url: "get-more-elements", elementSize: 250}); -*/ -UI.Ajax.Carousel = Class.create(UI.Carousel, { - // Group: Options - // - // Notice: - // It also include of all carousel's options - options: { - // Property: elementSize - // Required, it define the size of all elements - elementSize : -1, - - // Property: url - // Required, it define the URL used by AJAX carousel to request new elements details - url : null - }, - - /* - Group: Attributes - - Notice: - It also include of all carousel's attributes - - Property: elementSize - Size of each elements, it's an integer - - Property: endIndex - Index of the last loaded element - - Property: hasMore - Flag to define if there's still more elements to load - - Property: requestRunning - Define whether a request is processing or not - - Property: updateHandler - Callback to update carousel, usually used after request success - - Property: url - URL used to request additional elements - */ - - /* - Group: Events - List of events fired by an AJAX carousel, it also include of all carousel's custom events - - Property: request:started - Fired when the request has just started - - Property: request:ended - Fired when the request has succeed - */ - - // Group: Constructor - - /* - Method: initialize - Constructor function, should not be called directly - - Parameters: - element - DOM element - options - (Hash) list of optional parameters - - Returns: - this - */ - initialize: function($super, element, options) { - if (!options.url) - throw("url option is required for UI.Ajax.Carousel"); - if (!options.elementSize) - throw("elementSize option is required for UI.Ajax.Carousel"); - - $super(element, options); - - this.endIndex = 0; - this.hasMore = true; - - // Cache handlers - this.updateHandler = this.update.bind(this); - this.updateAndScrollHandler = function(nbElements, transport, json) { - this.update(transport, json); - this.scroll(nbElements); - }.bind(this); - - // Run first ajax request to fill the carousel - this.runRequest.bind(this).defer({parameters: {from: 0, to: Math.floor(this.nbVisible)}, onSuccess: this.updateHandler}); - }, - - // Group: Actions - - /* - Method: runRequest - Request the new elements details - - Parameters: - options - (Hash) list of optional parameters - - Returns: - this - */ - runRequest: function(options) { - this.requestRunning = true; - //alert("Asking for: " + options.parameters.from + " - " + options.parameters.to); - new Ajax.Request(this.options.url, Object.extend({method: "GET"}, options)); - this.fire("request:started"); - return this; - }, - - /* - Method: scroll - Scrolls carousel from maximum deltaPixel - - Parameters: - deltaPixel - a float - - Returns: - this - */ - scroll: function($super, deltaPixel) { - if (this.animating || this.requestRunning) - return this; - - var nbElements = (-deltaPixel) / this.elementSize; - // Check if there is not enough - if (this.hasMore && nbElements > 0 && this.currentIndex() + this.nbVisible + nbElements - 1 > this.endIndex) { - var from = this.endIndex + 1; - var to = Math.floor(from + this.nbVisible - 1); - this.runRequest({parameters: {from: from, to: to}, onSuccess: this.updateAndScrollHandler.curry(deltaPixel).bind(this)}); - return this; - } - else - $super(deltaPixel); - }, - - /* - Method: update - Update the carousel - - Parameters: - transport - XMLHttpRequest object - json - JSON object - - Returns: - this - */ - update: function(transport, json) { - this.requestRunning = false; - this.fire("request:ended"); - if (!json) - json = transport.responseJSON; - this.hasMore = json.more; - - this.endIndex = Math.max(this.endIndex, json.to); - this.elements = this.container.insert({bottom: json.html}).childElements(); - return this.updateButtons(); - }, - - // Group: Size and Position - - /* - Method: computeElementSize - Return elements size in pixel - - Returns: - an integer value - */ - computeElementSize: function() { - return this.options.elementSize; - }, - - /* - Method: updateSize - Should be called if carousel size has been changed (usually called with a liquid layout) - - Returns: - this - */ - updateSize: function($super) { - var nbVisible = this.nbVisible; - $super(); - // If we have enough space for at least a new element - if (Math.floor(this.nbVisible) - Math.floor(nbVisible) >= 1 && this.hasMore) { - if (this.currentIndex() + Math.floor(this.nbVisible) >= this.endIndex) { - var nbNew = Math.floor(this.currentIndex() + Math.floor(this.nbVisible) - this.endIndex); - this.runRequest({parameters: {from: this.endIndex + 1, to: this.endIndex + nbNew}, onSuccess: this.updateHandler}); - } - } - return this; - }, - - updateNextButton: function($super) { - var lastPosition = this.currentLastPosition(); - var size = this.currentSize(); - var nextClassName = "next_button" + this.options.disabledButtonSuffix; - - if (this.nextButton.hasClassName(nextClassName) && lastPosition != size) { - this.nextButton.removeClassName(nextClassName); - this.fire('nextButton:enabled'); - } - if (!this.nextButton.hasClassName(nextClassName) && lastPosition == size && !this.hasMore) { - this.nextButton.addClassName(nextClassName); - this.fire('nextButton:disabled'); - } - } -}); diff --git a/ansel/js/src/cropper.js b/ansel/js/src/cropper.js deleted file mode 100644 index 08519bb5c..000000000 --- a/ansel/js/src/cropper.js +++ /dev/null @@ -1,555 +0,0 @@ -/** - * Copyright 2006, David Spurr (http://www.defusion.org.uk/) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * * Neither the name of the David Spurr nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * http://www.opensource.org/licenses/bsd-license.php - * - * See scriptaculous.js for full scriptaculous licence - */ - -var CropDraggable=Class.create(); -Object.extend(Object.extend(CropDraggable.prototype,Draggable.prototype),{initialize:function(_1){ -this.options=Object.extend({drawMethod:function(){ -}},arguments[1]||{}); -this.element=$(_1); -this.handle=this.element; -this.delta=this.currentDelta(); -this.dragging=false; -this.eventMouseDown=this.initDrag.bindAsEventListener(this); -Event.observe(this.handle,"mousedown",this.eventMouseDown); -Draggables.register(this); -},draw:function(_2){ -var _3=Position.cumulativeOffset(this.element); -var d=this.currentDelta(); -_3[0]-=d[0]; -_3[1]-=d[1]; -var p=[0,1].map(function(i){ -return (_2[i]-_3[i]-this.offset[i]); -}.bind(this)); -this.options.drawMethod(p); -}}); -var Cropper={}; -Cropper.Img=Class.create(); -Cropper.Img.prototype={initialize:function(_7,_8){ -this.options=Object.extend({ratioDim:{x:0,y:0},minWidth:0,minHeight:0,displayOnInit:false,onEndCrop:Prototype.emptyFunction,captureKeys:true,onloadCoords:null,maxWidth:0,maxHeight:0},_8||{}); -this.img=$(_7); -this.clickCoords={x:0,y:0}; -this.dragging=false; -this.resizing=false; -this.isWebKit=/Konqueror|Safari|KHTML/.test(navigator.userAgent); -this.isIE=/MSIE/.test(navigator.userAgent); -this.isOpera8=/Opera\s[1-8]/.test(navigator.userAgent); -this.ratioX=0; -this.ratioY=0; -this.attached=false; -this.fixedWidth=(this.options.maxWidth>0&&(this.options.minWidth>=this.options.maxWidth)); -this.fixedHeight=(this.options.maxHeight>0&&(this.options.minHeight>=this.options.maxHeight)); -if(typeof this.img=="undefined"){ -return; -} -if(this.options.ratioDim.x>0&&this.options.ratioDim.y>0){ -var _c=this.getGCD(this.options.ratioDim.x,this.options.ratioDim.y); -this.ratioX=this.options.ratioDim.x/_c; -this.ratioY=this.options.ratioDim.y/_c; -} -this.subInitialize(); -if(this.img.complete||this.isWebKit){ -this.onLoad(); -}else{ -Event.observe(this.img,"load",this.onLoad.bindAsEventListener(this)); -} -},getGCD:function(a,b){ -if(b==0){ -return a; -} -return this.getGCD(b,a%b); -},onLoad:function(){ -var _f="imgCrop_"; -var _10=this.img.parentNode; -var _11=""; -if(this.isOpera8){ -_11=" opera8"; -} -this.imgWrap=Builder.node("div",{"class":_f+"wrap"+_11}); -this.north=Builder.node("div",{"class":_f+"overlay "+_f+"north"},[Builder.node("span")]); -this.east=Builder.node("div",{"class":_f+"overlay "+_f+"east"},[Builder.node("span")]); -this.south=Builder.node("div",{"class":_f+"overlay "+_f+"south"},[Builder.node("span")]); -this.west=Builder.node("div",{"class":_f+"overlay "+_f+"west"},[Builder.node("span")]); -var _12=[this.north,this.east,this.south,this.west]; -this.dragArea=Builder.node("div",{"class":_f+"dragArea"},_12); -this.handleN=Builder.node("div",{"class":_f+"handle "+_f+"handleN"}); -this.handleNE=Builder.node("div",{"class":_f+"handle "+_f+"handleNE"}); -this.handleE=Builder.node("div",{"class":_f+"handle "+_f+"handleE"}); -this.handleSE=Builder.node("div",{"class":_f+"handle "+_f+"handleSE"}); -this.handleS=Builder.node("div",{"class":_f+"handle "+_f+"handleS"}); -this.handleSW=Builder.node("div",{"class":_f+"handle "+_f+"handleSW"}); -this.handleW=Builder.node("div",{"class":_f+"handle "+_f+"handleW"}); -this.handleNW=Builder.node("div",{"class":_f+"handle "+_f+"handleNW"}); -this.selArea=Builder.node("div",{"class":_f+"selArea"},[Builder.node("div",{"class":_f+"marqueeHoriz "+_f+"marqueeNorth"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeVert "+_f+"marqueeEast"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeHoriz "+_f+"marqueeSouth"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeVert "+_f+"marqueeWest"},[Builder.node("span")]),this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW,Builder.node("div",{"class":_f+"clickArea"})]); -this.imgWrap.appendChild(this.img); -this.imgWrap.appendChild(this.dragArea); -this.dragArea.appendChild(this.selArea); -this.dragArea.appendChild(Builder.node("div",{"class":_f+"clickArea"})); -_10.appendChild(this.imgWrap); -this.startDragBind=this.startDrag.bindAsEventListener(this); -Event.observe(this.dragArea,"mousedown",this.startDragBind); -this.onDragBind=this.onDrag.bindAsEventListener(this); -Event.observe(document,"mousemove",this.onDragBind); -this.endCropBind=this.endCrop.bindAsEventListener(this); -Event.observe(document,"mouseup",this.endCropBind); -this.resizeBind=this.startResize.bindAsEventListener(this); -this.handles=[this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW]; -this.registerHandles(true); -if(this.options.captureKeys){ -this.keysBind=this.handleKeys.bindAsEventListener(this); -Event.observe(document,"keypress",this.keysBind); -} -new CropDraggable(this.selArea,{drawMethod:this.moveArea.bindAsEventListener(this)}); -this.setParams(); -},registerHandles:function(_13){ -for(var i=0;i0&&this.options.ratioDim.y>0){ -_1a.x1=Math.ceil((this.imgW-this.options.ratioDim.x)/2); -_1a.y1=Math.ceil((this.imgH-this.options.ratioDim.y)/2); -_1a.x2=_1a.x1+this.options.ratioDim.x; -_1a.y2=_1a.y1+this.options.ratioDim.y; -_1b=true; -} -} -this.setAreaCoords(_1a,false,false,1); -if(this.options.displayOnInit&&_1b){ -this.selArea.show(); -this.drawArea(); -this.endCrop(); -} -this.attached=true; -},remove:function(){ -if(this.attached){ -this.attached=false; -this.imgWrap.parentNode.insertBefore(this.img,this.imgWrap); -this.imgWrap.parentNode.removeChild(this.imgWrap); -Event.stopObserving(this.dragArea,"mousedown",this.startDragBind); -Event.stopObserving(document,"mousemove",this.onDragBind); -Event.stopObserving(document,"mouseup",this.endCropBind); -this.registerHandles(false); -if(this.options.captureKeys){ -Event.stopObserving(document,"keypress",this.keysBind); -} -} -},reset:function(){ -if(!this.attached){ -this.onLoad(); -}else{ -this.setParams(); -} -this.endCrop(); -},handleKeys:function(e){ -var dir={x:0,y:0}; -if(!this.dragging){ -switch(e.keyCode){ -case (37): -dir.x=-1; -break; -case (38): -dir.y=-1; -break; -case (39): -dir.x=1; -break; -case (40): -dir.y=1; -break; -} -if(dir.x!=0||dir.y!=0){ -if(e.shiftKey){ -dir.x*=10; -dir.y*=10; -} -this.moveArea([this.areaCoords.x1+dir.x,this.areaCoords.y1+dir.y]); -Event.stop(e); -} -} -},calcW:function(){ -return (this.areaCoords.x2-this.areaCoords.x1); -},calcH:function(){ -return (this.areaCoords.y2-this.areaCoords.y1); -},moveArea:function(_1e){ -this.setAreaCoords({x1:_1e[0],y1:_1e[1],x2:_1e[0]+this.calcW(),y2:_1e[1]+this.calcH()},true,false); -this.drawArea(); -},cloneCoords:function(_1f){ -return {x1:_1f.x1,y1:_1f.y1,x2:_1f.x2,y2:_1f.y2}; -},setAreaCoords:function(_20,_21,_22,_23,_24){ -if(_21){ -var _25=_20.x2-_20.x1; -var _26=_20.y2-_20.y1; -if(_20.x1<0){ -_20.x1=0; -_20.x2=_25; -} -if(_20.y1<0){ -_20.y1=0; -_20.y2=_26; -} -if(_20.x2>this.imgW){ -_20.x2=this.imgW; -_20.x1=this.imgW-_25; -} -if(_20.y2>this.imgH){ -_20.y2=this.imgH; -_20.y1=this.imgH-_26; -} -}else{ -if(_20.x1<0){ -_20.x1=0; -} -if(_20.y1<0){ -_20.y1=0; -} -if(_20.x2>this.imgW){ -_20.x2=this.imgW; -} -if(_20.y2>this.imgH){ -_20.y2=this.imgH; -} -if(_23!=null){ -if(this.ratioX>0){ -this.applyRatio(_20,{x:this.ratioX,y:this.ratioY},_23,_24); -}else{ -if(_22){ -this.applyRatio(_20,{x:1,y:1},_23,_24); -} -} -var _27=[this.options.minWidth,this.options.minHeight]; -var _28=[this.options.maxWidth,this.options.maxHeight]; -if(_27[0]>0||_27[1]>0||_28[0]>0||_28[1]>0){ -var _29={a1:_20.x1,a2:_20.x2}; -var _2a={a1:_20.y1,a2:_20.y2}; -var _2b={min:0,max:this.imgW}; -var _2c={min:0,max:this.imgH}; -if((_27[0]!=0||_27[1]!=0)&&_22){ -if(_27[0]>0){ -_27[1]=_27[0]; -}else{ -if(_27[1]>0){ -_27[0]=_27[1]; -} -} -} -if((_28[0]!=0||_28[0]!=0)&&_22){ -if(_28[0]>0&&_28[0]<=_28[1]){ -_28[1]=_28[0]; -}else{ -if(_28[1]>0&&_28[1]<=_28[0]){ -_28[0]=_28[1]; -} -} -} -if(_27[0]>0){ -this.applyDimRestriction(_29,_27[0],_23.x,_2b,"min"); -} -if(_27[1]>1){ -this.applyDimRestriction(_2a,_27[1],_23.y,_2c,"min"); -} -if(_28[0]>0){ -this.applyDimRestriction(_29,_28[0],_23.x,_2b,"max"); -} -if(_28[1]>1){ -this.applyDimRestriction(_2a,_28[1],_23.y,_2c,"max"); -} -_20={x1:_29.a1,y1:_2a.a1,x2:_29.a2,y2:_2a.a2}; -} -} -} -this.areaCoords=_20; -},applyDimRestriction:function(_2d,val,_2f,_30,_31){ -var _32; -if(_31=="min"){ -_32=((_2d.a2-_2d.a1)val); -} -if(_32){ -if(_2f==1){ -_2d.a2=_2d.a1+val; -}else{ -_2d.a1=_2d.a2-val; -} -if(_2d.a1<_30.min){ -_2d.a1=_30.min; -_2d.a2=val; -}else{ -if(_2d.a2>_30.max){ -_2d.a1=_30.max-val; -_2d.a2=_30.max; -} -} -} -},applyRatio:function(_33,_34,_35,_36){ -var _37; -if(_36=="N"||_36=="S"){ -_37=this.applyRatioToAxis({a1:_33.y1,b1:_33.x1,a2:_33.y2,b2:_33.x2},{a:_34.y,b:_34.x},{a:_35.y,b:_35.x},{min:0,max:this.imgW}); -_33.x1=_37.b1; -_33.y1=_37.a1; -_33.x2=_37.b2; -_33.y2=_37.a2; -}else{ -_37=this.applyRatioToAxis({a1:_33.x1,b1:_33.y1,a2:_33.x2,b2:_33.y2},{a:_34.x,b:_34.y},{a:_35.x,b:_35.y},{min:0,max:this.imgH}); -_33.x1=_37.a1; -_33.y1=_37.b1; -_33.x2=_37.a2; -_33.y2=_37.b2; -} -},applyRatioToAxis:function(_38,_39,_3a,_3b){ -var _3c=Object.extend(_38,{}); -var _3d=_3c.a2-_3c.a1; -var _3e=Math.floor(_3d*_39.b/_39.a); -var _3f; -var _40; -var _41=null; -if(_3a.b==1){ -_3f=_3c.b1+_3e; -if(_3f>_3b.max){ -_3f=_3b.max; -_41=_3f-_3c.b1; -} -_3c.b2=_3f; -}else{ -_3f=_3c.b2-_3e; -if(_3f<_3b.min){ -_3f=_3b.min; -_41=_3f+_3c.b2; -} -_3c.b1=_3f; -} -if(_41!=null){ -_40=Math.floor(_41*_39.a/_39.b); -if(_3a.a==1){ -_3c.a2=_3c.a1+_40; -}else{ -_3c.a1=_3c.a1=_3c.a2-_40; -} -} -return _3c; -},drawArea:function(){ -var _42=this.calcW(); -var _43=this.calcH(); -var px="px"; -var _45=[this.areaCoords.x1+px,this.areaCoords.y1+px,_42+px,_43+px,this.areaCoords.x2+px,this.areaCoords.y2+px,(this.img.width-this.areaCoords.x2)+px,(this.img.height-this.areaCoords.y2)+px]; -var _46=this.selArea.style; -_46.left=_45[0]; -_46.top=_45[1]; -_46.width=_45[2]; -_46.height=_45[3]; -var _47=Math.ceil((_42-6)/2)+px; -var _48=Math.ceil((_43-6)/2)+px; -this.handleN.style.left=_47; -this.handleE.style.top=_48; -this.handleS.style.left=_47; -this.handleW.style.top=_48; -this.north.style.height=_45[1]; -var _49=this.east.style; -_49.top=_45[1]; -_49.height=_45[3]; -_49.left=_45[4]; -_49.width=_45[6]; -var _4a=this.south.style; -_4a.top=_45[5]; -_4a.height=_45[7]; -var _4b=this.west.style; -_4b.top=_45[1]; -_4b.height=_45[3]; -_4b.width=_45[0]; -this.subDrawArea(); -this.forceReRender(); -},forceReRender:function(){ -if(this.isIE||this.isWebKit){ -var n=document.createTextNode(" "); -var d,el,fixEL,i; -if(this.isIE){ -fixEl=this.selArea; -}else{ -if(this.isWebKit){ -fixEl=document.getElementsByClassName("imgCrop_marqueeSouth",this.imgWrap)[0]; -d=Builder.node("div",""); -d.style.visibility="hidden"; -var _4e=["SE","S","SW"]; -for(i=0;i<_4e.length;i++){ -el=document.getElementsByClassName("imgCrop_handle"+_4e[i],this.selArea)[0]; -if(el.childNodes.length){ -el.removeChild(el.childNodes[0]); -} -el.appendChild(d); -} -} -} -fixEl.appendChild(n); -fixEl.removeChild(n); -} -},startResize:function(e){ -this.startCoords=this.cloneCoords(this.areaCoords); -this.resizing=true; -this.resizeHandle=Event.element(e).classNames().toString().replace(/([^N|NE|E|SE|S|SW|W|NW])+/,""); -Event.stop(e); -},startDrag:function(e){ -this.selArea.show(); -this.clickCoords=this.getCurPos(e); -this.setAreaCoords({x1:this.clickCoords.x,y1:this.clickCoords.y,x2:this.clickCoords.x,y2:this.clickCoords.y},false,false,null); -this.dragging=true; -this.onDrag(e); -Event.stop(e); -},getCurPos:function(e){ -var el=this.imgWrap,wrapOffsets=Position.cumulativeOffset(el); -while(el.nodeName!="BODY"){ -wrapOffsets[1]-=el.scrollTop||0; -wrapOffsets[0]-=el.scrollLeft||0; -el=el.parentNode; -} -return curPos={x:Event.pointerX(e)-wrapOffsets[0],y:Event.pointerY(e)-wrapOffsets[1]}; -},onDrag:function(e){ -if(this.dragging||this.resizing){ -var _54=null; -var _55=this.getCurPos(e); -var _56=this.cloneCoords(this.areaCoords); -var _57={x:1,y:1}; -if(this.dragging){ -if(_55.x_59){ -_5c.reverse(); -} -_5a[_5b+"1"]=_5c[0]; -_5a[_5b+"2"]=_5c[1]; -},endCrop:function(){ -this.dragging=false; -this.resizing=false; -this.options.onEndCrop(this.areaCoords,{width:this.calcW(),height:this.calcH()}); -},subInitialize:function(){ -},subDrawArea:function(){ -}}; -Cropper.ImgWithPreview=Class.create(); -Object.extend(Object.extend(Cropper.ImgWithPreview.prototype,Cropper.Img.prototype),{subInitialize:function(){ -this.hasPreviewImg=false; -if(typeof (this.options.previewWrap)!="undefined"&&this.options.minWidth>0&&this.options.minHeight>0){ -this.previewWrap=$(this.options.previewWrap); -this.previewImg=this.img.cloneNode(false); -this.previewImg.id="imgCrop_"+this.previewImg.id; -this.options.displayOnInit=true; -this.hasPreviewImg=true; -this.previewWrap.addClassName("imgCrop_previewWrap"); -this.previewWrap.setStyle({width:this.options.minWidth+"px",height:this.options.minHeight+"px"}); -this.previewWrap.appendChild(this.previewImg); -} -},subDrawArea:function(){ -if(this.hasPreviewImg){ -var _5d=this.calcW(); -var _5e=this.calcH(); -var _5f={x:this.imgW/_5d,y:this.imgH/_5e}; -var _60={x:_5d/this.options.minWidth,y:_5e/this.options.minHeight}; -var _61={w:Math.ceil(this.options.minWidth*_5f.x)+"px",h:Math.ceil(this.options.minHeight*_5f.y)+"px",x:"-"+Math.ceil(this.areaCoords.x1/_60.x)+"px",y:"-"+Math.ceil(this.areaCoords.y1/_60.y)+"px"}; -var _62=this.previewImg.style; -_62.width=_61.w; -_62.height=_61.h; -_62.left=_61.x; -_62.top=_61.y; -} -}}); - diff --git a/ansel/js/src/editcaption.js b/ansel/js/src/editcaption.js deleted file mode 100644 index 3b49ac2d4..000000000 --- a/ansel/js/src/editcaption.js +++ /dev/null @@ -1,38 +0,0 @@ -// InPlaceEditor extension based somewhat on an example given in the -// scriptaculous wiki -Ajax.InPlaceEditor.prototype.__initialize = Ajax.InPlaceEditor.prototype.initialize; -Ajax.InPlaceEditor.prototype.__getText = Ajax.InPlaceEditor.prototype.getText; -Object.extend(Ajax.InPlaceEditor.prototype, { - initialize: function(element, url, options) { - this.__initialize(element, url, options); - this.setOptions(options); - // Remove this line to stop from auto-showing the - // empty caption text on page load. - this.checkEmpty(); - }, - - setOptions: function(options) { - this.options = Object.extend(Object.extend(this.options, { - emptyClassName: 'inplaceeditor-empty' - }),options||{}); - }, - - checkEmpty: function() { - if (this.element.innerHTML.length == 0) { - emptyNode = new Element('span', {className: this.options.emptyClassName}).update(this.options.emptyText); - this.element.appendChild(emptyNode); - } - }, - - getText: function() { - $(this.element).select('.' + this.options.emptyClassName).each(function(child) { - this.element.removeChild(child); - }.bind(this)); - return this.__getText(); - } -}); - -function tileExit(ipe, e) -{ - ipe.checkEmpty(); -} diff --git a/ansel/js/src/editfaces.js b/ansel/js/src/editfaces.js deleted file mode 100644 index 4657ac155..000000000 --- a/ansel/js/src/editfaces.js +++ /dev/null @@ -1,56 +0,0 @@ -document.observe('dom:loaded', function() { - Ansel.deleteFace = function(image_id, face_id) - { - new Ajax.Request(Ansel.ajax.editFaces.url, - { - method: 'post', - parameters: { - action: 'delete', - image: image_id, - face: face_id - } - }); - $('face' + face_id).remove(); - }; - - Ansel.setFaceName = function(image_id, face_id) - { - new Ajax.Request(Ansel.ajax.editFaces.url, - { - method: 'post', - parameters: - { - action: 'setname', - face: face_id, - image: image_id, - facename: encodeURIComponent($F('facename' + face_id)) - }, - onComplete: function(r) { - if (r.responseJSON.response == 1) { - $('faces_widget_content').update(r.responseJSON.message); - } - } - } - ); - }; - - Ansel.doFaceEdit = function(image_id) - { - $('faces_widget_content').update(Ansel.ajax.editFaces.text.loading); - new Ajax.Request(Ansel.ajax.editFaces.url, - { - method: 'post', - parameters: - { - action: 'process', - image: image_id - }, - onComplete: function(r) { - if (r.responseJSON.response == 1) { - $('faces_widget_content').update(r.responseJSON.message); - } - } - } - ); - }; -}); \ No newline at end of file diff --git a/ansel/js/src/embed.js b/ansel/js/src/embed.js deleted file mode 100755 index f7f49e6f8..000000000 --- a/ansel/js/src/embed.js +++ /dev/null @@ -1,158 +0,0 @@ -// 0) { - (function() { - var jx = j; - - var nextLink = new Element('a',{href: '#', title: 'Next Image', className: 'anselNext', style: 'text-decoration:none;width:40%;float:right;'}); - nextLink.update('>>'); - var arg1 = {node: jx, page: 1}; - nextLink.observe('click', function(e) {displayPage(e, arg1)}); - - var prevLink = new Element('a',{href: '#', title: 'Previous Image', className: 'anselPrev', style: 'text-decoration:none;width:40%;float:right;'}); - prevLink.update('<<'); - var arg2 = {node: jx, page: -1}; - prevLink.observe('click', function(e) {displayPage(e, arg2)}); - $(jx).appendChild(nextLink); - $(jx).appendChild(prevLink); - Horde_ToolTips.attachBehavior(jx); - Event.observe(window, 'unload', Horde_ToolTips.out.bind(Horde_ToolTips)); - - })(); - } else { - (function () { - var jx = j; - Horde_ToolTips.attachBehavior(jx); - })(); - } - } - if (lightboxData.length) { - lbOptions['gallery_json'] = lightboxData; - ansel_lb = new Lightbox(lbOptions); - } - - Event.observe(window, 'unload', Horde_ToolTips.out.bind(Horde_ToolTips)); - }); - -/** - * Display the images from the requested page for the requested node. - * - * @param string $node The DOM id of the embedded widget. - * @param integer $page The requested page number. - */ -function displayPage(event, args) { - var node = args.node; - var page = args.page; - var perpage = anseljson[node]['perpage']; - var imgcount = anseljson[node]['data'].size(); - var pages = Math.ceil(imgcount / perpage) - 1; - var oldPage = anseljson[node]['page']; - - page = oldPage + page; - - /* Rollover? */ - if (page > pages) { - page = 0; - } - if (page < 0) { - page = pages; - } - - var mainNode = $(node); - mainNode.update(); - var start = page * perpage; - var end = Math.min(imgcount - 1, start + perpage - 1); - for (var i = start; i <= end; i++) { - var imgContainer = mainNode.appendChild(new Element('span', {className: 'anselGalleryWidget'})); - var imgLink = imgContainer.appendChild(new Element('a', - { - href: anseljson[node]['data'][i][5], - alt: anseljson[node]['data'][i][2], - title: anseljson[node]['data'][i][2] - })); - imgLink.appendChild(new Element('img', {src: anseljson[node]['data'][i][0]})); - } - - var nextLink = new Element('a',{href: '', title: 'Next Image', style: 'text-decoration:none;width:40%;float:right;'}); - nextLink.update('>>'); - - var args = {node: node, page: ++oldPage}; - nextLink.observe('click', function(e) {displayPage(e, args);}.bind()); - - var prevLink = new Element('a',{href: '', title: 'Previous Image', style: 'text-decoration:none;width:40%;float:right;'}); - prevLink.update('<<'); - - var args = {node: node, page: --oldPage}; - prevLink.observe('click', function(e) {displayPage(e, args);}.bind()); - - mainNode.appendChild(nextLink); - mainNode.appendChild(prevLink); - - Horde_ToolTips.attachBehavior(node); - anseljson[node]['page'] = page; - event.stop(); -} -//] diff --git a/ansel/js/src/googlemap.js b/ansel/js/src/googlemap.js deleted file mode 100644 index c0992e072..000000000 --- a/ansel/js/src/googlemap.js +++ /dev/null @@ -1,502 +0,0 @@ -/** - * Google maps implementation for Ansel - * - * Copyright 2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (GPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. - * - * @author Michael J. Rubinsky - */ -var Ansel_GMap = Class.create(); - -Ansel_GMap.prototype = { - // Main google map handle - mainMap: undefined, - - // Smaller overview map handle - smallMap: undefined, - - // Tinymarker icons... - tI: undefined, - tIO: undefined, - - // GLatLngBounds obejct for calculating proper center and zoom - bounds: undefined, - - // Geocoder - geocoder: undefined, - - // MarkerManager, if we are browsing the map. - // Note we need