提示对话框-大气响应式CSS3过渡动画的jQuery提示框插件

这是一款带19种炫酷CSS3过渡动画的jQuery模态窗口插件。该插件基于Codrops的ModalWindowEffects来制作,通过jQuery插件的方式来统一管理各种打开模态窗口的效果。

安装

可以通过bower来安装该模态窗口插件。

bower install foxythemes-niftymodals            

使用方法

在页面中引入jquery.niftymodals.css和jquery、jquery.niftymodals.js文件。

<link rel="stylesheet" href="dist/css/jquery.niftymodals.css">
<script src="path/to/jquery.min.js"></script>                 
<script src="dist/js/jquery.niftymodals.js"></script>                 
HTML结构

模态窗口的基本HTML结构如下:

<div class="md-dialog md-effect-1 md-show" id="your-modal-id">
    <div class="md-content">
        <!-- your content -->
    </div>
</div>
<div class="md-overlay"></div>    
初始化插件

在页面DOM元素加载完毕之后,可以通过在按钮或超链接上绑定niftyModal()方法来打开模态窗口。

$('#button-id').on('click',function(){
  $('#modal-id').niftyModal();
});                

配置参数

在对模态窗口初始化时,可以以对象的方式传入一些配置参数:

$('#modal-id').niftyModal({
    overlaySelector: '.md-overlay',//模态窗口遮罩层的class类
    closeSelector: '.md-close',//模态窗口关闭按钮元素的class类
    classAddAfterOpen: 'md-show',//Body control class
    //This object will be available in the modal events
    data: {
      some_data: ''
    },
    //This option allow to attach a callback to a button with the class 'md-close'
    buttons: [
      {
        class: 'btn-ok',
        callback: function ( btn, modal, event ) {
          //You can cancel the modal hide event by returning false
          alert("You need to check your info!");
          return false;
        }
      },
      {
        class: 'btn-cancel',
        callback: function ( btn, modal, event ) {
          //You can access to the mocal data here
          var modal_data = modal.data.some_data;
        }
      }
    ],
    beforeOpen: function( modal ){
      //You can cancel the modal show event by returning false
    },
    afterOpen: function( modal ){
      //Executed after show event
    },
    beforeClose: function( modal ){
      //You can cancel the hide event by returning false
    },
    afterClose: function( modal ){
      //Executed after hide event
    }
});                 

或者你可以通过下面的方法来设置默认的配置参数:

$.fn.niftyModal('setDefaults',{
    overlaySelector: '.modal-overlay',
    closeSelector: '.modal-close',
    classAddAfterOpen: 'modal-show',
});                 
与Bootstrap结合使用

该插件可以和Bootstrap结合使用,你只需要引入jquery.niftymodals.bootstrap.css文件。

<link rel="stylesheet" type="text/css" href="[your path]/dist/jquery.niftymodals.bootstrap.css">                 

这个css样式表包含了对原生Bootstrap模态窗口组件的一些重写样式,例如:modal-headermodal-contentmodal-footer等。

jquery-niftymodals模态窗口插件的github地址为:https://github.com/foxythemes/jquery-niftymodals。

在线预览 网盘下载

郑重声明:

1 本资源来源于互联网,资源的版权归资源原作者所持有,受《中华人民共和国著作权法》等相关法律保护。

2 由于无法和原作者取得联系,所以上传的部分资源无法先通过原作者的同意就分享给大家了,如本资源侵犯了您(原作者)的权益,请联系我们(微信号 xiaohaimei1989),我们会立马删除您的资源,并向您表达诚挚的歉意!

3 本站是一个公益型网站,分享资源的目的在于传播知识,分享知识,收取一点点打赏的辛苦费是用于网站的日常运营开支,并非用于商业用途。

4 本站资源只提供学习和参考研究使用,使用过后请在第一时间内删除。本站不承担资源被单位或个人商用带来的法律责任。

发表评论