成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

jquery插件之tip提示框

didikee / 1298人閱讀

摘要:提示框插件插件可以滿足常用的提示顯示,支持個(gè)方向,支持邊框背景色文本顏色自定義,支持位置微調(diào)層級(jí)微調(diào)寬度間距等參數(shù)調(diào)整。

Tips提示框插件

插件可以滿足常用的提示顯示,支持12個(gè)方向,支持邊框、背景色、文本顏色自定義,支持位置微調(diào)、層級(jí)微調(diào)、寬度間距等參數(shù)調(diào)整。

tips:提示信息組件

參數(shù):

msg:"asdf",內(nèi)容

dire:2,方向

w:250,寬度

_x:0,橫向偏移

_y:0,縱向偏移

zIndex:100000,層級(jí)

borderColor:#FFF,邊框顏色

bgColor:#FFF,背景顏色

useHover:true是否使用懸浮顯示

color:默認(rèn)提示文字顏色

padding:邊距

(function ($) {
    var defaults = {
        dire: 12,
        w: 250,
        _x: 0,
        _y: 0,
        borderColor: "#FFBB76",
        bgColor: "#FFFCEF",
        color: "#FF0000",
        padding: [5, 10],
        arrWidth: 10,
        useHover: true,
        zIndex: 100000
    };
    $.fn.tips = function (opt) {
        var tip, opts = $.extend({}, defaults, opt);
        if (this[0]) {
            opts.tag = this;
            if (opts.useHover) {
                opts.tag.hover(function () {
                    tip = new Tip(opts);
                    tip.show();
                }, function () {
                    tip.close();
                });
            } else {
                tip = new Tip(opts);
                tip.show();
            }
            return this;
        }
    };
    function Tip(opts) {
        this.dire = opts.dire;
        this.width = opts.w;
        this.zIndex = opts.zIndex;
        this.borderColor = opts.borderColor;
        this.bgColor = opts.bgColor;
        this.color = opts.color;
        this.padding = opts.padding;
        this.arrWidth = opts.arrWidth;
        this.offsetX = opts._x;
        this.offsetY = opts._y;
        this.tag = opts.tag;
        this.msg = opts.msg;
        this.wrap = $("
"); this.innerArr = $("
"); this.outerArr = $("
"); this.init(); }; Tip.prototype = { init: function () { var msg = this.tag.data("tipMsg"); if (!this.msg) { this.msg = msg; } this.createTemp(); }, createTemp: function () { var t = this; t.createWrap(); t.setPosition(); }, createWrap: function () { var t = this; t.wrap.html(t.msg); var wrapCSS = { width: t.width, border: "1px solid " + t.borderColor, "border-radius": "5px", background: t.bgColor, color: t.color, padding: t.getPadding() }; t.outerArr.css(t.getArrStyle(t.dire, t.arrWidth, t.borderColor)); t.innerArr.css(t.getArrStyle(t.dire, t.arrWidth, t.bgColor)); t.wrap.prepend(t.innerArr).prepend(t.outerArr).css(wrapCSS); $("body").append(t.wrap); }, setPosition: function () { var t = this; var posObj = t.getPos(t.dire, t.getPosition(t.tag), t.getPosition(t.wrap), t.arrWidth), pos = posObj.pos, innerPos = posObj.innerPos, outerPos = posObj.outerPos; t.wrap.css({top: pos.y, left: pos.x}); t.innerArr.css({top: innerPos.y, left: innerPos.x}); t.outerArr.css({top: outerPos.y, left: outerPos.x}); }, getPadding: function () { var t = this, pad = "0px", padArr = t.padding, len = padArr.length; switch (len) { case 1: pad = padArr[0] + "px"; break; case 2: pad = padArr[0] + "px " + padArr[1] + "px"; break; case 3: pad = padArr[0] + "px " + padArr[1] + "px " + padArr[2] + "px"; break; case 4: pad = padArr[0] + "px " + padArr[1] + "px " + padArr[2] + "px " + padArr[3] + "px"; break; } return pad; }, getPosition: function (tag) { return {t: tag.offset().top, l: tag.offset().left, h: tag.outerHeight(), w: tag.outerWidth()}; }, getArrStyle: function (dir, width, color) { var style; switch (dir) { case 11: case 12: case 1: style = { "border-bottom-style": "solid", "border-width": "0px " + width + "px " + width + "px", "border-bottom-color": color }; break; case 2: case 3: case 4: style = { "border-left-style": "solid", "border-width": width + "px 0px " + width + "px " + width + "px", "border-left-color": color }; break; case 5: case 6: case 7: style = { "border-top-style": "solid", "border-width": width + "px " + width + "px 0px", "border-top-color": color }; break; case 8: case 9: case 10: style = { "border-right-style": "solid", "border-width": width + "px " + width + "px " + width + "px 0px", "border-right-color": color }; break; } return style || {}; }, getPos: function (d, tagPos, pos, arrWidth) { var _pos, _innerPos, _outerPos, l = tagPos.l, t = tagPos.t, w = tagPos.w, h = tagPos.h, ww = pos.w, hh = pos.h; switch (d) { case 0: case 1: _pos = {x: l + w / 2 + arrWidth + 20 + 1 - ww, y: t + h + arrWidth}; _outerPos = {x: ww - 2 - 20 - arrWidth * 2, y: -arrWidth}; _innerPos = {x: ww - 2 - 20 - arrWidth * 2, y: -arrWidth + 1}; break; case 2: _pos = {x: l - ww - arrWidth, y: t + h / 2 - arrWidth - 20 - 1}; _outerPos = {x: ww - 2, y: 20}; _innerPos = {x: ww - 2 - 1, y: 20}; break; case 3: _pos = {x: l - ww - arrWidth, y: t + h / 2 - hh / 2}; _outerPos = {x: ww - 2, y: (hh - 2) / 2 - arrWidth}; _innerPos = {x: ww - 2 - 1, y: (hh - 2) / 2 - arrWidth}; break; case 4: _pos = {x: l - ww - arrWidth, y: t + h / 2 + arrWidth + 20 + 1 - hh}; _outerPos = {x: ww - 2, y: hh - 2 - 20 - arrWidth * 2}; _innerPos = {x: ww - 2 - 1, y: hh - 2 - 20 - arrWidth * 2}; break; case 5: _pos = {x: l + w / 2 + arrWidth + 20 + 1 - ww, y: t - arrWidth - hh}; _outerPos = {x: ww - 2 - 20 - arrWidth * 2, y: hh - 2}; _innerPos = {x: ww - 2 - 20 - arrWidth * 2, y: hh - 2 - 1}; break; case 6: _pos = {x: l + w / 2 - ww / 2, y: t - arrWidth - hh}; _outerPos = {x: (ww - 2) / 2 - arrWidth, y: hh - 2}; _innerPos = {x: (ww - 2) / 2 - arrWidth, y: hh - 2 - 1}; break; case 7: _pos = {x: l + w / 2 - 20 - arrWidth, y: t - arrWidth - hh}; _outerPos = {x: 20, y: hh - 2}; _innerPos = {x: 20, y: hh - 2 - 1}; break; case 8: _pos = {x: l + w + arrWidth, y: t + h / 2 + arrWidth + 20 + 1 - hh}; _outerPos = {x: -arrWidth, y: hh - 2 - 20 - arrWidth * 2}; _innerPos = {x: -arrWidth + 1, y: hh - 2 - 20 - arrWidth * 2}; break; case 9: _pos = {x: l + w + arrWidth, y: t + h / 2 - hh / 2}; _outerPos = {x: -arrWidth, y: (hh - 2) / 2 - arrWidth}; _innerPos = {x: -arrWidth + 1, y: (hh - 2) / 2 - arrWidth}; break; case 10: _pos = {x: l + w + arrWidth, y: t + h / 2 - arrWidth - 20 - 1}; _outerPos = {x: -arrWidth, y: 20}; _innerPos = {x: -arrWidth + 1, y: 20}; break; case 11: _pos = {x: l + w / 2 - 20 - arrWidth, y: t + h + arrWidth}; _outerPos = {x: 20, y: -arrWidth}; _innerPos = {x: 20, y: -arrWidth + 1}; break; case 12: _pos = {x: l + w / 2 - ww / 2, y: t + h + arrWidth}; _outerPos = {x: (ww - 2) / 2 - arrWidth, y: -arrWidth}; _innerPos = {x: (ww - 2) / 2 - arrWidth, y: -arrWidth + 1}; break; default: _pos = {x: 0, y: 0}; } return { pos: _pos, innerPos: _innerPos, outerPos: _outerPos }; }, show: function () { this.wrap.show(); }, close: function () { this.wrap.remove(); } }; })(jQuery);

CSS:

.tip-wrap {
    position: absolute;
    display: none;
}

.tip-arr-a, .tip-arr-b {
    position: absolute;
    width: 0;
    height: 0;
    line-height: 0;
    border-style: dashed;
    border-color: transparent;
}

page:

我是測(cè)試數(shù)據(jù)

效果:

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/78469.html

相關(guān)文章

  • 觸屏版開發(fā)總結(jié)

    摘要:概述前段時(shí)間剛剛完成公司觸屏版項(xiàng)目,我覺得很有必要寫一篇文章總結(jié)下自己的心得和踩過的坑。小結(jié)個(gè)人覺得整個(gè)開發(fā)流程就是一體的,沒有絕對(duì)的前后端分離。細(xì)數(shù)下開發(fā)過程中遇到的坑。最近在看模板,貌似很吊的樣子總結(jié)學(xué)習(xí)就是不斷踩坑的過程啊 概述 前段時(shí)間剛剛完成公司觸屏版項(xiàng)目,我覺得很有必要寫一篇文章總結(jié)下自己的心得和踩過的坑。每次回頭看看自己寫的代碼,都有不一樣的體會(huì),不過大致感覺都是驚人的...

    張利勇 評(píng)論0 收藏0
  • javascript功能插件大集合 前端常用插件 js常用插件

    摘要:轉(zhuǎn)載來源包管理器管理著庫,并提供讀取和打包它們的工具。能構(gòu)建更好應(yīng)用的客戶端包管理器。一個(gè)整合和的最佳思想,使開發(fā)者能快速方便地組織和編寫前端代碼的下一代包管理器。很棒的組件集合。隱秘地使用和用戶數(shù)據(jù)。 轉(zhuǎn)載來源:https://github.com/jobbole/aw... 包管理器管理著 javascript 庫,并提供讀取和打包它們的工具。?npm – npm 是 javasc...

    netmou 評(píng)論0 收藏0
  • javascript功能插件大集合 前端常用插件 js常用插件

    摘要:轉(zhuǎn)載來源包管理器管理著庫,并提供讀取和打包它們的工具。能構(gòu)建更好應(yīng)用的客戶端包管理器。一個(gè)整合和的最佳思想,使開發(fā)者能快速方便地組織和編寫前端代碼的下一代包管理器。很棒的組件集合。隱秘地使用和用戶數(shù)據(jù)。 轉(zhuǎn)載來源:https://github.com/jobbole/aw... 包管理器管理著 javascript 庫,并提供讀取和打包它們的工具。?npm – npm 是 javasc...

    Hydrogen 評(píng)論0 收藏0
  • 全解小程序猜數(shù)字游戲 04《 程序員變現(xiàn)指南 微信&QQ 小程序 真的零基礎(chǔ)開發(fā)寶

    摘要:此時(shí)使用設(shè)置當(dāng)前值中的猜測(cè)值為輸入框的內(nèi)容值。接著判斷猜測(cè)之是否大于或者小于,因?yàn)檫@兩者是范圍之外不再進(jìn)行判斷,所以最開始使用進(jìn)行判斷不能小于不能大于以上代碼中表示調(diào)用微信小程序接口彈出提示,傳入的參數(shù)為提示內(nèi)容。 ...

    不知名網(wǎng)友 評(píng)論0 收藏0
  • javascript功能插件大集合,寫前端的親們記得收藏

    摘要:一個(gè)專注于瀏覽器端和兼容的包管理器。一個(gè)整合和的最佳思想,使開發(fā)者能快速方便地組織和編寫前端代碼的下一代包管理器。完全插件化的工具,能在中識(shí)別和記錄模式。健壯的優(yōu)雅且功能豐富的模板引擎。完整的經(jīng)過充分測(cè)試和記錄數(shù)據(jù)結(jié)構(gòu)的庫。 【導(dǎo)讀】:GitHub 上有一個(gè) Awesome – XXX 系列的資源整理。awesome-javascript 是 sorrycc 發(fā)起維護(hù)的 JS 資源列表...

    cfanr 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<