--- /dev/null
+/**\r
+ * QLIB 1.0 Sprite Object\r
+ * Copyright (C) 2002 2003, Quazzle.com Serge Dolgov\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ * http://qlib.quazzle.com\r
+ */\r
+\r
+function QSprite_load(src) {\r
+ if (src) {\r
+ this.face = new Image(this.cwidth, this.cheight);\r
+ this.face.src = src;\r
+ this.valid = false;\r
+ }\r
+}\r
+ \r
+function QSprite_show(show) {\r
+ if (show && !this.valid && this.face.complete) {\r
+ this._img.src = this.face.src;\r
+ this.valid = true;\r
+ }\r
+ this._show(show);\r
+}\r
+\r
+function QSprite_moveTo(x, y) {\r
+ this.stop();\r
+ this._move(x, y);\r
+}\r
+\r
+function QSprite_slideTo(x, y) {\r
+ this.stop();\r
+ if (this.visible) {\r
+ this.doSlide(++this._spro, x, y);\r
+ } else {\r
+ this.moveTo(x, y);\r
+ }\r
+}\r
+\r
+function QSprite_shake() {\r
+ this.stop();\r
+ if (this.visible) {\r
+ this.doShake(++this._spro, 0, this.x, this.y);\r
+ }\r
+}\r
+\r
+function QSprite_stop() {\r
+ this._spro++;\r
+ if (this._sprt) {\r
+ clearTimeout(this._sprt);\r
+ this._sprt = false;\r
+ }\r
+}\r
+\r
+function QSprite_doSlide(id, x, y) {\r
+ if (this._spro == id) {\r
+ this._sprt = false;\r
+ var dx = Math.round(x - this.x);\r
+ var dy = Math.round(y - this.y);\r
+ if (dx || dy) {\r
+ if (dx) dx = dx > 0 ? Math.ceil(dx/4) : Math.floor(dx/4);\r
+ if (dy) dy = dy > 0 ? Math.ceil(dy/4) : Math.floor(dy/4);\r
+ this._move(this.x + dx, this.y + dy);\r
+ this._sprt = setTimeout(this.name + ".doSlide(" + id + "," + x + "," + y + ")", 30);\r
+ } else {\r
+ this._move(x, y);\r
+ }\r
+ }\r
+}\r
+\r
+function QSprite_doShake(id, phase, x, y) {\r
+ if (this._spro == id) {\r
+ this._sprt = false;\r
+ if (phase < 20) {\r
+ var m = 3 * Math.sin(.16 * phase);\r
+ this._move(x + m * Math.sin(phase), y + m * Math.cos(phase));\r
+ this._sprt = setTimeout(this.name + ".doShake(" + id + "," + (++phase) + "," + x + "," + y + ")", 20);\r
+ } else {\r
+ this._move(x, y);\r
+ }\r
+ }\r
+}\r
+\r
+function QSprite_doClick() {\r
+ if (!this._sprt) {\r
+ this.onClick(this.tag);\r
+ }\r
+ return false;\r
+}\r
+\r
+function QSprite(parent, name, x, y, width, height, src, visible, effects, opacity, zindex) {\r
+ this.init(parent, name);\r
+ this.x = x - 0;\r
+ this.y = y - 0;\r
+ this.width = (this.cwidth = width - 0) + 8;\r
+ this.height = (this.cheight = height - 0) + 8;\r
+ var j = QSprite.arguments.length;\r
+ this.visible = (j > 7) ? visible : true;\r
+ this.effects = (j > 8) ? effects : 0;\r
+ this.opacity = (j > 9) ? opacity : 100;\r
+ this.zindex = (j > 10) ? zindex : null;\r
+ this.valid = !!src;\r
+ this.content = '<a href="#" title="" onclick="return false" onmousedown="return ' + this.name +\r
+ '.doClick()" onmouseover="window.top.status=\'\';return true" hidefocus="true" unselectable="on"><img name="' +\r
+ this.id + '" src="' + (src || '') + '" border="0" width="' + this.cwidth + '" height="' + this.cheight +\r
+ '" alt="" unselectable="on"></a>';\r
+ this.doClick = QSprite_doClick;\r
+ this.doSlide = QSprite_doSlide;\r
+ this.doShake = QSprite_doShake;\r
+ this.onClick = QControl.event;\r
+ this.create();\r
+ this.face = this._img = this.document.images[this.id] || new Image(1, 1);\r
+ this._spro = 0;\r
+ this._sprt = false;\r
+ this._show = this.show;\r
+ this._move = this.moveTo;\r
+ this.load = QSprite_load;\r
+ this.show = QSprite_show;\r
+ this.moveTo = QSprite_moveTo;\r
+ this.slideTo = QSprite_slideTo;\r
+ this.shake = QSprite_shake;\r
+ this.stop = QSprite_stop;\r
+}\r
+QSprite.prototype = new QWndCtrl();\r