Mercurial > judyates
comparison 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 |
comparison
equal
deleted
inserted
replaced
2:670229c4eb4b | 3:3f6b44aa6b35 |
---|---|
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 */ | |
11 | |
12 Fx.ProgressBar = new Class({ | |
13 | |
14 Extends: Fx, | |
15 | |
16 options: { | |
17 text: null, | |
18 url: null, | |
19 transition: Fx.Transitions.Circ.easeOut, | |
20 fit: true, | |
21 link: 'cancel' | |
22 }, | |
23 | |
24 initialize: function(element, options) { | |
25 this.element = $(element); | |
26 this.parent(options); | |
27 | |
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 } | |
35 | |
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 }, | |
52 | |
53 start: function(to, total) { | |
54 return this.parent(this.now, (arguments.length == 1) ? to.limit(0, 100) : to / total * 100); | |
55 }, | |
56 | |
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) + '%'); | |
62 | |
63 this.element.setStyle('backgroundPosition', css + ' 0px').title = Math.round(to) + '%'; | |
64 | |
65 var text = $(this.options.text); | |
66 if (text) text.set('text', Math.round(to) + '%'); | |
67 | |
68 return this; | |
69 } | |
70 | |
71 }); |