首页 > 其他 > 详细

jBox学习记录

时间:2015-03-27 12:40:35      阅读:187      评论:0      收藏:0      [点我收藏+]

一、文件引用

主页位置:http://stephanwagner.me/jBox

<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jboxcdn.com/0.3.2/jBox.min.js"></script>
<link href="http://code.jboxcdn.com/0.3.2/jBox.css" rel="stylesheet">

二、基本使用

1.1提示框

$(‘.tooltip‘).jBox(‘Tooltip‘);

1.2模态对话框

new jBox(‘Modal‘, {
    width: 300,
    height: 200,
    attach: $(‘#myModal‘),
    title: ‘My Modal Window‘,
    content: ‘<i>Hello there!</i>‘
});
 
<div id="myModal">Click me to open a modal window!</div>

1.3确定对话框

给元素添加一个data-confirm属性来绑定设置。

new jBox(‘Confirm‘, {
    confirmButton: ‘Do it!‘,
    cancelButton: ‘Nope‘
});
 
<div onclick="doit()" data-confirm="Do you really want to do this?">Click me!</div>
<a href="http://stephanwagner.me" data-confirm="Do you really want to leave this page?">Click me!</a>

1.4提示框(Notices)

var colorsN2 = [‘red‘, ‘green‘, ‘blue‘, ‘yellow‘];
            var currentColorN2 = 0;
            jQuery(‘#notice‘).click(function() {
                new jBox(‘Notice‘, {
                    animation: ‘flip‘,
                    position: {
                        x: 15,
                        y: 65
                    },
                    content: ‘Oooh! They also come in colors!‘,
                    onInit: function() {
                        this.options.color = colorsN2[currentColorN2];
                        currentColorN2++;
                        (currentColorN2 >= colorsN2.length) && (currentColorN2 = 0);
                    },
                    zIndex: 12000
            });
 });

 三、高级使用

3.1自定义主题、点击声音

var colorsN3 = [‘red‘, ‘green‘, ‘blue‘, ‘yellow‘];
    var titlesN3 = [‘Oops‘, ‘Well done‘, ‘Reminder‘, ‘Attention‘];
    var contentsN3 = [‘Sorry, something went wrong‘, ‘You perfectly clicked a button‘, ‘Don\‘t forget to click the button one more time‘, ‘Take care out there‘];
    var currentColorN3 = 0;
    jQuery(‘#demoN3‘).click(function() {
        new jBox(‘Notice‘, {
            attributes: {
                x: ‘left‘,
                y: ‘bottom‘
            },
            theme: ‘NoticeBorder‘,
            color: ‘black‘,
            audio: ‘/libraries/jBox/Source/audio/bling2‘,
            volume: noticeN3Volume,
            animation: {
                open: ‘slide:bottom‘,
                close: ‘slide:left‘
            },
            onInit: function() {
                this.options.color = colorsN3[currentColorN3];
                this.options.title = titlesN3[currentColorN3];
                this.options.content = contentsN3[currentColorN3];
                currentColorN3++;
                (currentColorN3 >= colorsN3.length) && (currentColorN3 = 0);
            },
        });
    });

3.2动画效果

var colorsN4 = [‘black‘, ‘red‘, ‘green‘, ‘blue‘, ‘yellow‘];
    var currentColorN4 = 0;
    jQuery(‘#demoN4‘).click(function() {
        new jBox(‘Notice‘, {
            autoClose: 10000,
            attributes: {
                x: ‘right‘,
                y: ‘bottom‘
            },
            stack: false,
            animation: {
                open: ‘tada‘,
                close: ‘zoomIn‘
            },
            title: ‘Tadaaa! I\‘m single!‘,
            content: ‘Open another notice to close me!‘,
            onInit: function() {
                this.options.color = colorsN4[currentColorN4];
                currentColorN4++;
                (currentColorN4 >= colorsN4.length) && (currentColorN4 = 0);
            },
        });
    });

 

jBox学习记录

原文:http://www.cnblogs.com/Leman/p/4371156.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!