view 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 source
1 /**
2 * Fx.ProgressBar
3 *
4 * @version 1.1
5 *
6 * @license MIT License
7 *
8 * @author Harald Kirschner <mail [at] digitarald [dot] de>
9 * @copyright Authors
10 */
12 Fx.ProgressBar = new Class({
14 Extends: Fx,
16 options: {
17 text: null,
18 url: null,
19 transition: Fx.Transitions.Circ.easeOut,
20 fit: true,
21 link: 'cancel'
22 },
24 initialize: function(element, options) {
25 this.element = $(element);
26 this.parent(options);
28 var url = this.options.url;
29 if (url) {
30 this.element.setStyles({
31 'background-image': 'url(' + url + ')',
32 'background-repeat': 'no-repeat'
33 });
34 }
36 if (this.options.fit) {
37 url = url || this.element.getStyle('background-image').replace(/^url\(["']?|["']?\)$/g, '');
38 if (url) {
39 var fill = new Image();
40 fill.onload = function() {
41 this.fill = fill.width;
42 fill = fill.onload = null;
43 this.set(this.now || 0);
44 }.bind(this);
45 fill.src = url;
46 if (!this.fill && fill.width) fill.onload();
47 }
48 } else {
49 this.set(0);
50 }
51 },
53 start: function(to, total) {
54 return this.parent(this.now, (arguments.length == 1) ? to.limit(0, 100) : to / total * 100);
55 },
57 set: function(to) {
58 this.now = to;
59 var css = (this.fill)
60 ? (((this.fill / -2) + (to / 100) * (this.element.width || 1) || 0).round() + 'px')
61 : ((100 - to) + '%');
63 this.element.setStyle('backgroundPosition', css + ' 0px').title = Math.round(to) + '%';
65 var text = $(this.options.text);
66 if (text) text.set('text', Math.round(to) + '%');
68 return this;
69 }
71 });