jschr/bootstrap-modal
Composer 安装命令:
composer require jschr/bootstrap-modal
包简介
Extends the default Bootstrap Modal class. Responsive, stackable, ajax and more.
关键字:
README 文档
README
Note: Since this plugin was created to solve a lot of the issues with BS2, it still uses the BS2 markup syntax. Currently I believe the default BS3 modal addresses some of the bigger issues and is not worth maintaining two versions of this plugin.
Bootstrap Modal v2.2.6
See live demo here.
Extends Bootstrap's native modals to provide additional functionality. Introduces a ModalManager class that operates behind the scenes to handle multiple modals by listening on their events.
A single ModalManager is created by default on body and can be accessed through the jQuery plugin interface.
$('body').modalmanager('loading');
Bootstrap-Modal can be used as a replacement for Bootstrap's Modal class or as a patch to the library.
Bootstrap 3
If you're using BS3, I've provided a compatible css patch. Include bootstrap-modal-bs3patch.css before the main bootstrap-modal.css file to use this plugin with Bootstrap 3.
If you're using the loading spinner functionality you may also need to change the default template to be compatible in js:
$.fn.modal.defaults.spinner = $.fn.modalmanager.defaults.spinner =
'<div class="loading-spinner" style="width: 200px; margin-left: -100px;">' +
'<div class="progress progress-striped active">' +
'<div class="progress-bar" style="width: 100%;"></div>' +
'</div>' +
'</div>';
Overview
- Backwards compatible
- Responsive
- Stackable
- Full width
- Load content via AJAX
- Disable background scrolling
Installation
- Include
css/bootstrap-modal.cssafter the main bootstrap css files. - Include
js/bootstrap-modalmanager.jsandjs/bootstrap-modal.jsafter the main bootstrap js files.
<link href="css/bootstrap.css" rel="stylesheet" /> <link href="css/bootstrap-responsive.css" rel="stylesheet" /> <link href="css/bootstrap-modal.css" rel="stylesheet" /> <script src="js/bootstrap.js"></script> <script src="js/bootstrap-modalmanager.js"></script> <script src="js/bootstrap-modal.js"></script>
Options
In addition to the standard bootstrap options, you now have access to the following options
Modal
-
width Set the initial width of the modal.
-
height Set the initial height of the modal.
-
maxHeight Set the max-height of the modal-body.
-
loading Toggle the loading state.
-
spinner Provide a custom image or animation for the loading spinner.
-
backdropTemplate Provide a custom modal backdrop.
-
consumeTab Used to enable tabindexing for modals with
data-tabindex. This is set to true by default. -
focusOn The element or selector to set the focus to once the modal is shown.
-
replace If set to true, the modal will replace the topmost modal when opened.
-
attentionAnimation Set the animation used by the
attentionmethod. Any animation in animate.css is supported but only the shake animation is included by default. -
modalOverflow Set this property to true for modals with highly dynamic content. This will force the modal to behave as if it is larger than the viewport.
-
manager Set the modal's manager. By default this is set to the
GlobalModalManagerand will most likely not need to be overridden.
ModalManager
-
loading Toggle the loading state.
-
backdropLimit Limit the amount of backdrops that will appear on the page at the same time.
-
spinner Provide a custom image or animation for the loading spinner.
-
backdropTemplate Provide a custom modalmanager backdrop. This backdrop is used when
$element.modalmanager('loading')is called.
Getting a reference to the modal manager
If you did not created your own ModalManager, perhaps you'll need a reference to it. That can be easily accomplished using the following snippet:
var modalManager = $("body").data("modalmanager"); var openModals = modalManager.getOpenModals(); modalManager.removeLoading();
After that, you'll be able to call any methods that modal manager has, such as:
- removeLoading (remove the loading and backdrop window);
- getOpenModals (to get the modals that are already open);
- etc;
Disable Background Scrolling
If you want to prevent the background page from scrolling (see demo for example) you must wrap the page contents in a <div class="page-container">. For example:
<body> <div class="page-container"> <div class="navbar navbar-fixed-top">...</div> <div class="container">...</div> </div> </body>
The reason for doing this instead of just simply setting overflow: hidden when a modal is open is to avoid having the page shift as a result of the scrollbar appearing/disappearing. This also allows the document to be scrollable when there is a tall modal but only to the height of the modal, not the entire page.
Constrain Modal to Window Size
You can bind the height of the modal body to the window with something like this:
$.fn.modal.defaults.maxHeight = function(){ // subtract the height of the modal header and footer return $(window).height() - 165; }
Note: This will be overwritten by the responsiveness and is only set when the modal is displayed, not when the window is resized.
Tab Index for Modal Forms
You can use data-tabindex instead of the default tabindex to specify the tabindex within a modal.
<input type="text" data-tabindex="1" /> <input type="text" data-tabindex="2" />
See the stackable example on the demo page for an example.
jschr/bootstrap-modal 适用场景与选型建议
jschr/bootstrap-modal 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 39.59k 次下载、GitHub Stars 达 4.96k, 最近一次更新时间为 2013 年 01 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「javascript」 「bootstrap」 「modal」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jschr/bootstrap-modal 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jschr/bootstrap-modal 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jschr/bootstrap-modal 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Generates a Blade directive exporting all of your named Laravel routes. Also provides a nice route() helper function in JavaScript.
Caching and compression for Twig assets (JavaScript and CSS).
A pretty nice way to expose your translation messages to your JavaScript.
Fork from ghosh/Micromodal. Tiny, dependency-free javascript library for creating accessible modal dialogs.
Make Filament modals draggable.
A Filament form component that displays repeater items in a table with modal-based editing.
统计信息
- 总下载量: 39.59k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4966
- 点击次数: 21
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Apache
- 更新时间: 2013-01-26