|
@@ -27,7 +27,8 @@ var Modal = function(elem, config) { |
|
@@ -27,7 +27,8 @@ var Modal = function(elem, config) { |
27
|
|
27
|
|
28
|
/* ------------------------static attribute ------------------*/
|
28
|
/* ------------------------static attribute ------------------*/
|
29
|
Modal.DEFAULT = {
|
29
|
Modal.DEFAULT = {
|
30
|
- backdrop: true
|
30
|
+ backdrop: true,
|
|
|
31
|
+ show: true
|
31
|
};
|
32
|
};
|
32
|
|
33
|
|
33
|
/* ------------------------public method ------------------*/
|
34
|
/* ------------------------public method ------------------*/
|
|
@@ -92,6 +93,12 @@ Modal._jqueryBridge = function(config, relatedTarget) { |
|
@@ -92,6 +93,12 @@ Modal._jqueryBridge = function(config, relatedTarget) { |
92
|
return this.each(function() {
|
93
|
return this.each(function() {
|
93
|
var $this = $(this);
|
94
|
var $this = $(this);
|
94
|
var data = $this.data(DATA_KEY);
|
95
|
var data = $this.data(DATA_KEY);
|
|
|
96
|
+ var configs = $this.data(DATA_KEY) ? 'toggle' : $.extend(
|
|
|
97
|
+ {},
|
|
|
98
|
+ Modal.DEFAULT,
|
|
|
99
|
+ $this.data(),
|
|
|
100
|
+ toString.call(config) === '[object Object]' && config
|
|
|
101
|
+ );
|
95
|
|
102
|
|
96
|
if (!data) {
|
103
|
if (!data) {
|
97
|
$this.data(DATA_KEY, data = new Modal($this, config));
|
104
|
$this.data(DATA_KEY, data = new Modal($this, config));
|
|
@@ -99,7 +106,7 @@ Modal._jqueryBridge = function(config, relatedTarget) { |
|
@@ -99,7 +106,7 @@ Modal._jqueryBridge = function(config, relatedTarget) { |
99
|
|
106
|
|
100
|
if (typeof config === 'string') {
|
107
|
if (typeof config === 'string') {
|
101
|
data[config](relatedTarget);
|
108
|
data[config](relatedTarget);
|
102
|
- } else if (config.show) {
|
109
|
+ } else if (configs.show) {
|
103
|
data.show(relatedTarget);
|
110
|
data.show(relatedTarget);
|
104
|
}
|
111
|
}
|
105
|
});
|
112
|
});
|
|
@@ -108,9 +115,10 @@ Modal._jqueryBridge = function(config, relatedTarget) { |
|
@@ -108,9 +115,10 @@ Modal._jqueryBridge = function(config, relatedTarget) { |
108
|
/* ----------------------- DATA-API ----------------------*/
|
115
|
/* ----------------------- DATA-API ----------------------*/
|
109
|
|
116
|
|
110
|
$(document).on('click.yoho.modal.data-api', Selector.DATA_TOGGLE, function(event) {
|
117
|
$(document).on('click.yoho.modal.data-api', Selector.DATA_TOGGLE, function(event) {
|
|
|
118
|
+ var $this = $(this);
|
111
|
var selector = this.getAttribute('data-target');
|
119
|
var selector = this.getAttribute('data-target');
|
112
|
var $target = $(selector);
|
120
|
var $target = $(selector);
|
113
|
- var config = $target.data(DATA_KEY) ? 'toggle' : $.extend({show: true}, $target.data());
|
121
|
+ var config = $target.data(DATA_KEY) ? 'toggle' : $.extend($target.data(), $this.data());
|
114
|
|
122
|
|
115
|
if ($target[0].tagName.toUpperCase() === 'A') {
|
123
|
if ($target[0].tagName.toUpperCase() === 'A') {
|
116
|
event.preventDefault();
|
124
|
event.preventDefault();
|