/*
* qTip2 - Pretty powerful tooltips
* http://craigsworks.com/projects/qtip2/
*
* Version: nightly
* Copyright 2009-2010 Craig Michael Thompson - http://craigsworks.com
*
* Dual licensed under MIT or GPLv2 licenses
* http://en.wikipedia.org/wiki/MIT_License
* http://en.wikipedia.org/wiki/GNU_General_Public_License
*
* Date: Thu Dec 15 11:17:28.0000000000 2011
*/
/*jslint browser: true, onevar: true, undef: true, nomen: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: true */
/*global window: false, jQuery: false, console: false */
(function($, window, undefined) {
"use strict"; // Enable ECMAScript "strict" operation for this function. See more: http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
// Munge the primitives - Paul Irish tip
var TRUE = true,
FALSE = false,
NULL = null,
// Shortcut vars
QTIP, PLUGINS, MOUSE,
usedIDs = {},
uitooltip = 'ui-tooltip',
widget = 'ui-widget',
disabled = 'ui-state-disabled',
selector = 'div.qtip.'+uitooltip,
defaultClass = uitooltip + '-default',
focusClass = uitooltip + '-focus',
hoverClass = uitooltip + '-hover',
fluidClass = uitooltip + '-fluid',
hideOffset = '-31000px',
replaceSuffix = '_replacedByqTip',
oldtitle = 'oldtitle',
trackingBound;
/* Thanks to Paul Irish for this one: http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/ */
function log() {
log.history = log.history || [];
log.history.push(arguments);
// Make sure console is present
if('object' === typeof console) {
// Setup console and arguments
var c = console[ console.warn ? 'warn' : 'log' ],
args = Array.prototype.slice.call(arguments), a;
// Add qTip2 marker to first argument if it's a string
if(typeof arguments[0] === 'string') { args[0] = 'qTip2: ' + args[0]; }
// Apply console.warn or .log if not supported
a = c.apply ? c.apply(console, args) : c(args);
}
}
// Option object sanitizer
function sanitizeOptions(opts)
{
var content;
if(!opts || 'object' !== typeof opts) { return FALSE; }
if(opts.metadata === NULL || 'object' !== typeof opts.metadata) {
opts.metadata = {
type: opts.metadata
};
}
if('content' in opts) {
if(opts.content === NULL || 'object' !== typeof opts.content || opts.content.jquery) {
opts.content = {
text: opts.content
};
}
content = opts.content.text || FALSE;
if(!$.isFunction(content) && ((!content && !content.attr) || content.length < 1 || ('object' === typeof content && !content.jquery))) {
opts.content.text = FALSE;
}
if('title' in opts.content) {
if(opts.content.title === NULL || 'object' !== typeof opts.content.title) {
opts.content.title = {
text: opts.content.title
};
}
content = opts.content.title.text || FALSE;
if(!$.isFunction(content) && ((!content && !content.attr) || content.length < 1 || ('object' === typeof content && !content.jquery))) {
opts.content.title.text = FALSE;
}
}
}
if('position' in opts) {
if(opts.position === NULL || 'object' !== typeof opts.position) {
opts.position = {
my: opts.position,
at: opts.position
};
}
}
if('show' in opts) {
if(opts.show === NULL || 'object' !== typeof opts.show) {
if(opts.show.jquery) {
opts.show = { target: opts.show };
}
else {
opts.show = { event: opts.show };
}
}
}
if('hide' in opts) {
if(opts.hide === NULL || 'object' !== typeof opts.hide) {
if(opts.hide.jquery) {
opts.hide = { target: opts.hide };
}
else {
opts.hide = { event: opts.hide };
}
}
}
if('style' in opts) {
if(opts.style === NULL || 'object' !== typeof opts.style) {
opts.style = {
classes: opts.style
};
}
}
// Sanitize plugin options
$.each(PLUGINS, function() {
if(this.sanitize) { this.sanitize(opts); }
});
return opts;
}
/*
* Core plugin implementation
*/
function QTip(target, options, id, attr)
{
// Declare this reference
var self = this,
docBody = document.body,
tooltipID = uitooltip + '-' + id,
isPositioning = 0,
isDrawing = 0,
tooltip = $(),
namespace = '.qtip-' + id,
elements, cache;
// Setup class attributes
self.id = id;
self.rendered = FALSE;
self.elements = elements = { target: target };
self.timers = { img: {} };
self.options = options;
self.checks = {};
self.plugins = {};
self.cache = cache = {
event: {},
target: $(),
disabled: FALSE,
attr: attr
};
/*
* Private core functions
*/
function convertNotation(notation)
{
var i = 0, obj, option = options,
// Split notation into array
levels = notation.split('.');
// Loop through
while( option = option[ levels[i++] ] ) {
if(i < levels.length) { obj = option; }
}
return [obj || options, levels.pop()];
}
function setWidget() {
var on = options.style.widget;
tooltip.toggleClass(widget, on).toggleClass(defaultClass, options.style.default && !on);
elements.content.toggleClass(widget+'-content', on);
if(elements.titlebar){
elements.titlebar.toggleClass(widget+'-header', on);
}
if(elements.button){
elements.button.toggleClass(uitooltip+'-icon', !on);
}
}
function removeTitle(reposition)
{
if(elements.title) {
elements.titlebar.remove();
elements.titlebar = elements.title = elements.button = NULL;
// Reposition if enabled
if(reposition !== FALSE) { self.reposition(); }
}
}
function createButton()
{
var button = options.content.title.button,
isString = typeof button === 'string',
close = isString ? button : 'Close tooltip';
if(elements.button) { elements.button.remove(); }
// Use custom button if one was supplied by user, else use default
if(button.jquery) {
elements.button = button;
}
else {
elements.button = $('<a />', {
'class': 'ui-state-default ui-tooltip-close ' + (options.style.widget ? '' : uitooltip+'-icon'),
'title': close,
'aria-label': close
})
.prepend(
$('<span />', {
'class': 'ui-icon ui-icon-close',
'html': '×'
})
);
}
// Create button and setup attributes
elements.button.appendTo(elements.titlebar)
.attr('role', 'button')
.click(function(event) {
if(!tooltip.hasClass(disabled)) { self.hide(event); }
return FALSE;
});
// Redraw the tooltip when we're done
self.redraw();
}
function createTitle()
{
var id = tooltipID+'-title';
// Destroy previous title element, if present
if(elements.titlebar) { removeTitle(); }
// Create title bar and title elements
elements.titlebar = $('<div />', {
'class': uitooltip + '-titlebar ' + (options.style.widget ? 'ui-widget-header' : '')
})
.append(
elements.title = $('<div />', {
'id': id,
'class': uitooltip + '-title',
'aria-atomic': TRUE
})
)
.insertBefore(elements.content)
// Button-specific events
.delegate('.ui-tooltip-close', 'mousedown keydown mouseup keyup mouseout', function(event) {
$(this).toggleClass('ui-state-active ui-state-focus', event.type.substr(-4) === 'down');
})
.delegate('.ui-tooltip-close', 'mouseover mouseout', function(event){
$(this).toggleClass('ui-state-hover', event.type === 'mouseover');
});
// Create button if enabled
if(options.content.title.button) { createButton(); }
// Redraw the tooltip dimensions if it's rendered
else if(self.rendered){ self.redraw(); }
}
function updateButton(button)
{
var elem = elements.button,
title = elements.title;
// Make sure tooltip is rendered and if not, return
if(!self.rendered) { return FALSE; }
if(!button) {
elem.remove();
}
else {
if(!title) {
createTitle();
}
createButton();
}
}
function updateTitle(content, reposition)
{
var elem = elements.title;
// Make sure tooltip is rendered and if not, return
if(!self.rendered || !content) { return FALSE; }
// Use function to parse content
if($.isFunction(content)) {
content = content.call(target, cache.event, self);
}
// Remove title if callbac
没有合适的资源?快使用搜索试试~ 我知道了~
基于JQUERY 很灵活的TIP 工具 qTip2
共4个文件
js:2个
css:2个
4星 · 超过85%的资源 需积分: 9 15 下载量 86 浏览量
2011-12-16
09:33:26
上传
评论
收藏 47KB ZIP 举报
温馨提示
提示未功能,包括样式 位置 事件都可以 由自己定义 。。。很强很方便。。
资源推荐
资源详情
资源评论
收起资源包目录
jquery.qtip-nightly.custom.zip (4个子文件)
nightly-615c02b35fdd4941ca4c974cec2e6f9a1323976685
jquery.qtip.min.css 10KB
jquery.qtip.css 12KB
jquery.qtip.min.js 39KB
jquery.qtip.js 94KB
共 4 条
- 1
资源评论
- zhongyongbo2013-03-10其实,,你这玩意和官网上面的一样的。。。
- zhang__sheng2012-12-21刚好就只有那几个基本的源文件,到处都有,还敢要5分,sb
- mdj1632013-02-06挺实用的,就是暂时项目里还没用上。
- hsllee2013-01-30资源挺实用的
- cugxgxy1122012-12-24资料挺好,不过有些不是很实用。
生菜
- 粉丝: 4
- 资源: 19
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 实验项目一:线性表(模板 ).docx
- 基于LM317A设计交流220V输入可调5V-12V直流输出稳压电源电路multisim10仿真源文件.zip
- Screenshot_2024-04-25-17-04-18-55_2332cb9b27b851b548ba47a91682926c.jpg
- -基于AVR单片机的LNG加液机控制器设计.pdf
- ThePowerOfNow-EckhartTolle.mobi
- BLOCK_TYPE_HEARTBEAT_D70A3465D4EE4E9_046141_dump_1st.dmp
- 项目方法测试调用接口工具
- studyupdate
- 基于西瓜数据集的决策树实现.zip
- 60套HTML网站源码-响应式-涵盖(简历&作品展示&商业&科技&培训&商城&课设等)-适配移动设备-解压即用.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功