...
|
...
|
@@ -27,7 +27,8 @@ var Modal = function(elem, config) { |
|
|
|
|
|
/* ------------------------static attribute ------------------*/
|
|
|
Modal.DEFAULT = {
|
|
|
backdrop: true
|
|
|
backdrop: true,
|
|
|
show: true
|
|
|
};
|
|
|
|
|
|
/* ------------------------public method ------------------*/
|
...
|
...
|
@@ -92,6 +93,12 @@ Modal._jqueryBridge = function(config, relatedTarget) { |
|
|
return this.each(function() {
|
|
|
var $this = $(this);
|
|
|
var data = $this.data(DATA_KEY);
|
|
|
var configs = $this.data(DATA_KEY) ? 'toggle' : $.extend(
|
|
|
{},
|
|
|
Modal.DEFAULT,
|
|
|
$this.data(),
|
|
|
toString.call(config) === '[object Object]' && config
|
|
|
);
|
|
|
|
|
|
if (!data) {
|
|
|
$this.data(DATA_KEY, data = new Modal($this, config));
|
...
|
...
|
@@ -99,7 +106,7 @@ Modal._jqueryBridge = function(config, relatedTarget) { |
|
|
|
|
|
if (typeof config === 'string') {
|
|
|
data[config](relatedTarget);
|
|
|
} else if (config.show) {
|
|
|
} else if (configs.show) {
|
|
|
data.show(relatedTarget);
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -108,9 +115,10 @@ Modal._jqueryBridge = function(config, relatedTarget) { |
|
|
/* ----------------------- DATA-API ----------------------*/
|
|
|
|
|
|
$(document).on('click.yoho.modal.data-api', Selector.DATA_TOGGLE, function(event) {
|
|
|
var $this = $(this);
|
|
|
var selector = this.getAttribute('data-target');
|
|
|
var $target = $(selector);
|
|
|
var config = $target.data(DATA_KEY) ? 'toggle' : $.extend({show: true}, $target.data());
|
|
|
var config = $target.data(DATA_KEY) ? 'toggle' : $.extend($target.data(), $this.data());
|
|
|
|
|
|
if ($target[0].tagName.toUpperCase() === 'A') {
|
|
|
event.preventDefault();
|
...
|
...
|
|