Login   Register  
PHP Classes
elePHPant
Icontem

File: js/1mix.tooltip.js

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Alex Lau  >  Mix2ool  >  js/1mix.tooltip.js  >  Download  
File: js/1mix.tooltip.js
Role: Auxiliary data
Content type: text/plain
Description: The tooltip component
Class: Mix2ool
Web development framework integrated with jQuery
Author: By
Last change:
Date: 4 years ago
Size: 2,240 bytes
 

Contents

Class file image Download
mixElements.append("tooltip");
document.createElement("tooltip");
mix.tooltip = function (elements){
	var tooltip;
	if (type(elements) == "undefined"){
		tooltip = $(document.createElement("tooltip"));
	}else{
		tooltip = $(elements).filter(function (){
			var el = this.parentNode;
			while (el.nodeType == 1 && el.nodeName.toLowerCase() != "html" && el.nodeName.toLowerCase() != "template")
				el = el.parentNode;
			return (("" + this.nodeName).toLowerCase() == "tooltip" 
					&& this._mixInit !== true
					&& el.nodeName.toLowerCase() != "template");
		});
	}	
		
	tooltip.each(function (){
		this._mixInit = true;
	}).bind("mouseout", function (){
		mix.tooltip.hide(this);
	});
	return tooltip;
};
mix.tooltip.show = function (el){
	$(el).show().get(0)._shown = true;
};
mix.tooltip.hide = function (el){
	$(el).hide().get(0)._shown = false;
};
mix.tooltip.mouseOver = function (e){
	var id = $(this).attr("usetip");
	if (type(id) != "string" || id.length == 0) return;
	var tip = $("#" + id);
	var fixed = tip.attr("fixed");
	if (! (type(fixed) == "string" || type(fixed) == "number"))
		fixed = 0;
	(function (){
		mix.tooltip.show($("#" + id));
	}).once(fixed.toInteger());
};
mix.tooltip.offset = 5;
mix.tooltip.mouseMove = function (e){
	var id = $(this).attr("usetip");
	if (type(id) != "string" || id.length == 0) return;
	var tip = $("#" + id);
	var tf = type(tip.attr("fixed"));
	if (tf == "string" || tf == "number"){
		if (tip.get(0)._shown !== true)
			tip.css("left", (e.pageX + mix.tooltip.offset) + "px").css("top", (e.pageY + mix.tooltip.offset) + "px");
	}else{
		tip.css("left", (e.pageX + mix.tooltip.offset) + "px").css("top", (e.pageY + mix.tooltip.offset) + "px");
	}
};
mix.tooltip.mouseOut = function (e){
	var id = $(this).attr("usetip");
	if (type(id) != "string" || id.length == 0) return;
	mix.tooltip.hide($("#" + id));
};
mix.tooltip.attr = function (el, name, value){
	if (type(value) == "undefined"){ //getter
		if (name == "fixed")
			return el.getAttribute("fixed");
		return;
	}
	
	el.setAttribute(name, value);
	$(el).trigger("attrChange", [name, value]);
	
	return value;
};
mix.tooltip.customAttrList = "fixed".split(",");