asp的bbs程序

源代码在线查看: tip.lib.js

软件大小: 3353 K
上传用户: happy_christina
关键词: asp bbs 程序
下载地址: 免注册下载 普通下载 VIP

相关代码

				/*
				  By Hangring
				  #2008.02.28#
				  ---
				  use list:
				  > global.lib.js
				  > node.lib.js
				  > events.lib.js
				  > node.lib.js
				  > css.lib.js
				  > function.lib.js
				  > popup.lib.js
				  ---
				  复选框
				  ---
				  包含样式:
				  
				*/
				
				function Tip () {
				    this.button = null;
				    this.tip = null;
				
				    this.isCreate = false;
				
				    // 单独拥有tip
				    this.standAlone = !false;
				
				    // display text
				    this.text = '';
				    // display
				    this.display = true;
				
				    // Offset
				    this.xOffset = 10;
				    this.yOffset = 20;
				
				    this.css = {
				        tip:'tip'
				    };
				}
				
				Tip.flow = null;
				Tip.css = {tip:'tip'};
				
				Tip.prototype.Init = function () {
				};
				
				Tip.prototype.Create = function () {
				    var self = this;
				    this.isCreate = true;
				
				    this.mouseMove = function (e) {
				        var obj = $EO(e);
				        var flow = self.standAlone ? self.tip : Tip.flow;
				        if (self._Condition(obj, e)) {
				            if (!flow) {
				                flow = PopUp.Panel('');
				                self.standAlone ? (self.tip = flow) : (Tip.flow = flow);
				                CSS.AddClass(flow, self.standAlone ? self.css.tip : Tip.css.tip);
				                PopUp.AddPopUp(flow);
				                PopUp.AddMask(flow);
				            }
				            var x = e.clientX + self.xOffset;
				            var y = e.clientY + self.yOffset;
				            var W = Global.GetClientWidth();
				            var H = Global.GetClientHeight();
				            var w = flow.offsetWidth;
				            var h = flow.offsetHeight;
				            /*
				            if (x > W / 2) {
				                x = e.clientX - w - self.xOffset;
				            }
				            if (y > H / 2) {
				                y = e.clientY - h - self.yOffset;
				            }
				            */
				            if (x + w > W) {
				                x = e.clientX - w - self.xOffset;
				            }
				            if (x < 0) x = 0;
				            if (y + h > H) {
				                y = e.clientY - h - self.yOffset;
				            }
				            if (y < 0) y = 0;
				            x += Global.GetScrollLeft();
				            y += Global.GetScrollTop();
				            PopUp.SetDisplay(flow, self.display);
				            //CSS.SetAlpha(flow, 70);
				            if (flow._innerHTML != self.text)
				                flow._innerHTML = flow.innerHTML = self.text;
				            self._Change(e, flow);
				            PopUp.SetXY(flow, x, y);
				        }
				        else if (flow) {
				            /*PopUp.SetVisible(flow, false);*/
				            self.Remove();
				        }
				    };
				    //this.mouseMove = this.mouseMove.Rebuild(['e', 'th'], 'var self = arguments.callee.self;');
				    //this.mouseMove.self = self;
				    Events.AttachEvent(document, 'mousemove', this.mouseMove);
				};
				
				Tip.prototype.Remove = function () {
				    Events.RemoveEvent(document, 'mousemove', this.mouseMove);
				    if (this.tip) {
				        PopUp.RemovePopUp(this.tip);
				        this.tip = null;
				    }
				    this.isCreate = false;
				};
				
				Tip.prototype.SetText = function (str /* :String */) {
				    var flow = this.standAlone ? this.tip : Tip.flow;
				    flow.innerHTML = str;
				};
				
				Tip.prototype.SetVisible = function (visible /* :String|Boolean */) {
				    var flow = this.standAlone ? this.tip : Tip.flow;
				    if (typeof visible == 'boolean') {
				        visible = visible ? 'visible' : 'hidden';
				    }
				    flow.style.visibility = visible;
				};
				
				Tip.prototype._Condition = function (obj /* :HTMLElement */, e) {
				    var isFocus = false;
				    while (obj) {
				        if (obj == this.button) {
				            isFocus = true;
				            break;
				        }
				        obj = obj.parentNode;
				    }
				    return isFocus || this.Condition(e);
				};
				// 外部调用
				Tip.prototype.Condition = function (e) {
				    return false;
				};
				
				Tip.prototype._Change = function (e, flow) {
				    this.Change(e, flow);
				};
				// 外部调用
				Tip.prototype.Change = function (e, flow) {
				};
				
				/*
				    var tip = new Tip();
				    tip.button = $('roll');
				    tip.text = '...Roll Tip...';
				    tip.Create();
				    // (or)
				    var tip = new Tip();
				    tip.Condition = function () {return true};
				    tip.text = '...Roll Tip...';
				    tip.Create();
				*/			

相关资源