| 1 | // LiveJournal javascript standard interface routines |
|---|
| 2 | |
|---|
| 3 | // create a little animated hourglass at (x,y) with a unique-ish ID |
|---|
| 4 | // returns the element created |
|---|
| 5 | Hourglass = new Class( Object, { |
|---|
| 6 | init: function(widget, classname) { |
|---|
| 7 | this.ele = document.createElement("img"); |
|---|
| 8 | if (!this.ele) return; |
|---|
| 9 | |
|---|
| 10 | var imgprefix = Site ? Site.imgprefix : ''; |
|---|
| 11 | |
|---|
| 12 | this.ele.src = imgprefix ? imgprefix + "/hourglass.gif" : "/img/hourglass.gif"; |
|---|
| 13 | this.ele.style.position = "absolute"; |
|---|
| 14 | |
|---|
| 15 | DOM.addClassName(this.ele, classname); |
|---|
| 16 | |
|---|
| 17 | if (widget) |
|---|
| 18 | this.hourglass_at_widget(widget); |
|---|
| 19 | }, |
|---|
| 20 | |
|---|
| 21 | hourglass_at: function (x, y) { |
|---|
| 22 | this.ele.width = 17; |
|---|
| 23 | this.ele.height = 17; |
|---|
| 24 | this.ele.style.top = (y - 8) + "px"; |
|---|
| 25 | this.ele.style.left = (x - 8) + "px"; |
|---|
| 26 | |
|---|
| 27 | // unique ID |
|---|
| 28 | this.ele.id = "lj_hourglass" + x + "." + y; |
|---|
| 29 | |
|---|
| 30 | document.body.appendChild(this.ele); |
|---|
| 31 | }, |
|---|
| 32 | |
|---|
| 33 | add_class_name: function (classname) { |
|---|
| 34 | if (this.ele) |
|---|
| 35 | DOM.addClassName(this.ele, classname); |
|---|
| 36 | }, |
|---|
| 37 | |
|---|
| 38 | hourglass_at_widget: function (widget) { |
|---|
| 39 | var dim = DOM.getAbsoluteDimensions(widget); |
|---|
| 40 | var x = dim.absoluteLeft; |
|---|
| 41 | var y = dim.absoluteTop; |
|---|
| 42 | var w = dim.absoluteRight - x; |
|---|
| 43 | var h = dim.absoluteBottom - y; |
|---|
| 44 | if (w && h) { |
|---|
| 45 | x += w/2; |
|---|
| 46 | y += h/2; |
|---|
| 47 | } |
|---|
| 48 | this.hourglass_at(x, y); |
|---|
| 49 | }, |
|---|
| 50 | |
|---|
| 51 | hide: function () { |
|---|
| 52 | if (this.ele) { |
|---|
| 53 | try { |
|---|
| 54 | document.body.removeChild(this.ele); |
|---|
| 55 | } catch (e) {} |
|---|
| 56 | } |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | } ); |
|---|