diff e2gallerypro/e2upload/Source/Additions.js @ 3:3f6b44aa6b35 judyates

[svn r4] added ability to buy stuff, from a Prints page, but it doesn't work well with the css, and it also has not been fitted into the perl make system.
author rlm
date Mon, 22 Feb 2010 08:02:39 -0500
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/e2gallerypro/e2upload/Source/Additions.js	Mon Feb 22 08:02:39 2010 -0500
     1.3 @@ -0,0 +1,247 @@
     1.4 +/*
     1.5 +Script: Additions.js
     1.6 +	MooTools Additions - Various Helpers, Overlay-Class, Dialog-Class
     1.7 +
     1.8 +License:
     1.9 +	MIT-style license.
    1.10 +
    1.11 +Copyright:
    1.12 +	Copyright (c) 2009 [Christoph Pojer](http://og5.net/christoph).
    1.13 +
    1.14 +Dependencies:
    1.15 +	- MooTools Core 1.2.2
    1.16 +	- MooTools More 1.2.2.1 or newer: Tips.js
    1.17 +
    1.18 +Contains:
    1.19 +	- FileManager.Tips: Augmented version of Tips for use within the FileManager
    1.20 +	- FileManager.Request: Simple extension to request to always use the loader-icon specified by the FileManager instance
    1.21 +	- Element.appearOn: Can be used to show an element when another is hovered: $(myElement).appearOn(myWrapper)
    1.22 +	- Element.center: Centers an element
    1.23 +	- Dialog, Overlay: Nice Classes used by the FileManager
    1.24 +*/
    1.25 +
    1.26 +if(!window.FileManager) var FileManager = {};
    1.27 +
    1.28 +FileManager.Tips = new Class({
    1.29 +	
    1.30 +	Extends: Tips,
    1.31 +	
    1.32 +	options: {
    1.33 +		offsets: {x: 15, y: 0},
    1.34 +		text: null,
    1.35 +		onShow: function(tip, el){
    1.36 +			if(tip.get('opacity')==0.8 && tip.getStyle('visibility')=='visible') return;
    1.37 +			
    1.38 +			tip.get('tween').pause();
    1.39 +			tip.set({
    1.40 +				opacity: 0,
    1.41 +				tween: {
    1.42 +					duration: 200,
    1.43 +					link: 'cancel'
    1.44 +				}
    1.45 +			}).fade(0.8);
    1.46 +		},
    1.47 +		
    1.48 +		onHide: function(tip, el){
    1.49 +			tip.get('tween').pause().start('opacity', 0).chain(function(){
    1.50 +				tip.setStyle('left', 0);
    1.51 +			});
    1.52 +		}
    1.53 +	},
    1.54 +	
    1.55 +	initialize: function(el, options){
    1.56 +		this.parent(el, options);
    1.57 +		this.tip.addClass('tip-filebrowser');
    1.58 +	}
    1.59 +	
    1.60 +});
    1.61 +
    1.62 +FileManager.Request = new Class({
    1.63 +	
    1.64 +	Extends: Request.JSON,
    1.65 +	
    1.66 +	initialize: function(options, filebrowser){
    1.67 +		this.parent(options);
    1.68 +		
    1.69 +		if(filebrowser)	this.addEvents({
    1.70 +			request: filebrowser.onRequest.bind(filebrowser),
    1.71 +			complete: filebrowser.onComplete.bind(filebrowser)
    1.72 +		});
    1.73 +	}
    1.74 +	
    1.75 +});
    1.76 +
    1.77 +Element.implement({
    1.78 +	
    1.79 +	appearOn: function(el, opacity, options){
    1.80 +		opacity = $type(opacity) == 'array' ? [opacity[0] || 1, opacity[1] || 0] : [opacity || 1, 0];
    1.81 +		
    1.82 +		this.set({
    1.83 +			opacity: opacity[1],
    1.84 +			tween: options || {duration: 200}
    1.85 +		});
    1.86 +		
    1.87 +		$(el).addEvents({
    1.88 +			mouseenter: this.fade.bind(this, opacity[0]),
    1.89 +			mouseleave: this.fade.bind(this, opacity[1])
    1.90 +		});
    1.91 +		
    1.92 +		return this;
    1.93 +	},
    1.94 +	
    1.95 +	center: function(offsets){
    1.96 +		var scroll = document.getScroll(),
    1.97 +			offset = document.getSize(),
    1.98 +			size = this.getSize(),
    1.99 +			values = {x: 'left', y: 'top'};
   1.100 +		
   1.101 +		if(!offsets) offsets = {};
   1.102 +		
   1.103 +		for(var z in values){
   1.104 +			var style = scroll[z]+(offset[z]-size[z])/2+(offsets[z] || 0);
   1.105 +			this.setStyle(values[z], style < 10 ? 10 : style);
   1.106 +		}
   1.107 +		
   1.108 +		return this;
   1.109 +	}
   1.110 +	
   1.111 +});
   1.112 +
   1.113 +var Dialog = new Class({
   1.114 +	
   1.115 +	Implements: [Options, Events],
   1.116 +	
   1.117 +	options: {
   1.118 +		/*onShow: $empty,
   1.119 +		onOpen: $empty,
   1.120 +		onConfirm: $empty,
   1.121 +		onDecline: $empty,
   1.122 +		onClose: $empty,*/
   1.123 +		request: null,
   1.124 +		buttons: ['confirm', 'decline'],
   1.125 +		language: {}
   1.126 +	},
   1.127 +	
   1.128 +	initialize: function(text, options){
   1.129 +		this.setOptions(options);
   1.130 +		
   1.131 +		this.el = new Element('div', {
   1.132 +			'class': 'dialog dialog-engine-'+Browser.Engine.name+(Browser.Engine.trident ? Browser.Engine.version : ''),
   1.133 +			opacity: 0,
   1.134 +			tween: {duration: 250}
   1.135 +		}).adopt([
   1.136 +			$type(text)=='string' ? new Element('div', {text: text}) : text
   1.137 +		]);
   1.138 +		
   1.139 +		if(this.options.content) this.el.getElement('div').adopt(this.options.content);
   1.140 +		
   1.141 +		Array.each(this.options.buttons, function(v){
   1.142 +			new Element('button', {'class': 'dialog-'+v, text: this.options.language[v]}).addEvent('click', (function(e){
   1.143 +				if(e) e.stop();
   1.144 +				this.fireEvent(v).fireEvent('close');
   1.145 +				this.overlay.hide();
   1.146 +				this.destroy();
   1.147 +			}).bind(this)).inject(this.el);
   1.148 +		}, this);
   1.149 +		
   1.150 +		this.overlay = new Overlay({
   1.151 +			'class': 'overlay overlay-dialog',
   1.152 +			events: {click: this.fireEvent.bind(this, ['close'])},
   1.153 +			tween: {duration: 250}
   1.154 +		});
   1.155 +		
   1.156 +		this.bound = {
   1.157 +			scroll: (function(){
   1.158 +				if(!this.el) this.destroy();
   1.159 +				else this.el.center();
   1.160 +			}).bind(this),
   1.161 +			keyesc: (function(e){
   1.162 +				if(e.key=='esc') this.fireEvent('close').destroy();
   1.163 +			}).bind(this)
   1.164 +		};
   1.165 +		
   1.166 +		this.show();
   1.167 +	},
   1.168 +	
   1.169 +	show: function(){
   1.170 +		this.overlay.show();
   1.171 +		var self = this.fireEvent('open');
   1.172 +		this.el.setStyle('display', 'block').inject(document.body).center().fade(1).get('tween').chain(function(){
   1.173 +			self.fireEvent('show');
   1.174 +		});
   1.175 +		
   1.176 +		window.addEvents({
   1.177 +			scroll: this.bound.scroll,
   1.178 +			resize: this.bound.scroll,
   1.179 +			keyup: this.bound.keyesc
   1.180 +		});
   1.181 +	},
   1.182 +	
   1.183 +	destroy: function(){
   1.184 +		if(this.el) this.el.fade(0).get('tween').chain((function(){
   1.185 +			this.overlay.destroy();
   1.186 +			this.el.destroy();
   1.187 +		}).bind(this));
   1.188 +		
   1.189 +		window.removeEvent('scroll', this.bound.scroll).removeEvent('resize', this.bound.scroll).removeEvent('keyup', this.bound.keyesc);
   1.190 +	}
   1.191 +	
   1.192 +}),
   1.193 +Overlay = new Class({
   1.194 +	
   1.195 +	initialize: function(options){
   1.196 +		this.el = new Element('div', $extend({
   1.197 +			'class': 'overlay'
   1.198 +		}, options)).inject(document.body);
   1.199 +	},
   1.200 +	
   1.201 +	show: function(){
   1.202 +		this.objects = $$('object, select, embed').filter(function(el){
   1.203 +			return el.id=='SwiffFileManagerUpload' || el.style.visibility=='hidden' ? false : !!(el.style.visibility = 'hidden');
   1.204 +		});
   1.205 +		
   1.206 +		this.resize = (function(){
   1.207 +			if(!this.el) this.destroy();
   1.208 +			else this.el.setStyles({
   1.209 +				width: document.getScrollWidth(),
   1.210 +				height: document.getScrollHeight()
   1.211 +			});
   1.212 +		}).bind(this);
   1.213 +		
   1.214 +		this.resize();
   1.215 +		
   1.216 +		this.el.setStyles({
   1.217 +			opacity: 0,
   1.218 +			display: 'block'
   1.219 +		}).get('tween').pause().start('opacity', 0.5);
   1.220 +		
   1.221 +		window.addEvent('resize', this.resize);
   1.222 +		
   1.223 +		return this;
   1.224 +	},
   1.225 +	
   1.226 +	hide: function(){
   1.227 +		this.el.fade(0).get('tween').chain((function(){
   1.228 +			this.revertObjects();
   1.229 +			this.el.setStyle('display', 'none');
   1.230 +		}).bind(this));
   1.231 +		
   1.232 +		window.removeEvent('resize', this.resize);
   1.233 +		
   1.234 +		return this;
   1.235 +	},
   1.236 +	
   1.237 +	destroy: function(){
   1.238 +		this.revertObjects().el.destroy();
   1.239 +	},
   1.240 +	
   1.241 +	revertObjects: function(){
   1.242 +		if(this.objects && this.objects.length)
   1.243 +			this.objects.each(function(el){
   1.244 +				el.style.visibility = 'visible';	
   1.245 +			});
   1.246 +		
   1.247 +		return this;
   1.248 +	}
   1.249 +	
   1.250 +});
   1.251 \ No newline at end of file