diff e2gallerypro/e2upload/Source/Uploader/Fx.ProgressBar.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/Uploader/Fx.ProgressBar.js	Mon Feb 22 08:02:39 2010 -0500
     1.3 @@ -0,0 +1,71 @@
     1.4 +/**
     1.5 + * Fx.ProgressBar
     1.6 + *
     1.7 + * @version		1.1
     1.8 + *
     1.9 + * @license		MIT License
    1.10 + *
    1.11 + * @author		Harald Kirschner <mail [at] digitarald [dot] de>
    1.12 + * @copyright	Authors
    1.13 + */
    1.14 +
    1.15 +Fx.ProgressBar = new Class({
    1.16 +
    1.17 +	Extends: Fx,
    1.18 +
    1.19 +	options: {
    1.20 +		text: null,
    1.21 +		url: null,
    1.22 +		transition: Fx.Transitions.Circ.easeOut,
    1.23 +		fit: true,
    1.24 +		link: 'cancel'
    1.25 +	},
    1.26 +
    1.27 +	initialize: function(element, options) {
    1.28 +		this.element = $(element);
    1.29 +		this.parent(options);
    1.30 +				
    1.31 +		var url = this.options.url;
    1.32 +		if (url) {
    1.33 +			this.element.setStyles({
    1.34 +				'background-image': 'url(' + url + ')',
    1.35 +				'background-repeat': 'no-repeat'
    1.36 +			});
    1.37 +		}
    1.38 +		
    1.39 +		if (this.options.fit) {
    1.40 +			url = url || this.element.getStyle('background-image').replace(/^url\(["']?|["']?\)$/g, '');
    1.41 +			if (url) {
    1.42 +				var fill = new Image();
    1.43 +				fill.onload = function() {
    1.44 +					this.fill = fill.width;
    1.45 +					fill = fill.onload = null;
    1.46 +					this.set(this.now || 0);
    1.47 +				}.bind(this);
    1.48 +				fill.src = url;
    1.49 +				if (!this.fill && fill.width) fill.onload();
    1.50 +			}
    1.51 +		} else {
    1.52 +			this.set(0);
    1.53 +		}
    1.54 +	},
    1.55 +
    1.56 +	start: function(to, total) {
    1.57 +		return this.parent(this.now, (arguments.length == 1) ? to.limit(0, 100) : to / total * 100);
    1.58 +	},
    1.59 +
    1.60 +	set: function(to) {
    1.61 +		this.now = to;
    1.62 +		var css = (this.fill)
    1.63 +			? (((this.fill / -2) + (to / 100) * (this.element.width || 1) || 0).round() + 'px')
    1.64 +			: ((100 - to) + '%');
    1.65 +		
    1.66 +		this.element.setStyle('backgroundPosition', css + ' 0px').title = Math.round(to) + '%';
    1.67 +		
    1.68 +		var text = $(this.options.text);
    1.69 +		if (text) text.set('text', Math.round(to) + '%');
    1.70 +		
    1.71 +		return this;
    1.72 +	}
    1.73 +
    1.74 +});
    1.75 \ No newline at end of file