Revision 478847c9
Von Sven Schöling vor mehr als 3 Jahren hinzugefügt
js/kivi.Materialize.js | ||
---|---|---|
75 | 75 |
showClearBtn: true, |
76 | 76 |
i18n: ns.build_i18n() |
77 | 77 |
}); |
78 |
$('.modal').modal(); |
|
78 | 79 |
M.updateTextFields(); |
79 | 80 |
} |
80 | 81 |
|
82 |
// alternative for kivi.popup_dialog. |
|
83 |
// opens materialize modal instead. |
|
84 |
// |
|
85 |
// differences: M.modal can not load external content, so it needs to be fetched manually and inserted into the DOM. |
|
86 |
ns.popup_dialog = function(params) { |
|
87 |
console.log(params); |
|
88 |
params = params || { }; |
|
89 |
let id = params.id || 'jqueryui_popup_dialog'; |
|
90 |
let $div; |
|
91 |
let custom_close = params.dialog ? params.dialog.close : undefined; |
|
92 |
let dialog_params = $.extend( |
|
93 |
{ // kivitendo default parameters. |
|
94 |
// unlike classic layout, there is not fixed size, and M.modal is always... modal |
|
95 |
onCloseStart: custom_close |
|
96 |
}, |
|
97 |
// User supplied options: |
|
98 |
params.dialog || { }, |
|
99 |
{ // Options that must not be changed: |
|
100 |
// close options already work |
|
101 |
}); |
|
102 |
|
|
103 |
if (params.url) { |
|
104 |
$.ajax({ |
|
105 |
url: params.url, |
|
106 |
data: params.data, |
|
107 |
success: function(data) { |
|
108 |
params.html = data; |
|
109 |
params.url = undefined; |
|
110 |
params.data = undefined; |
|
111 |
ns.popup_dialog(params); |
|
112 |
}, |
|
113 |
error: function(x, status, error) { console.log(error); }, |
|
114 |
dataType: 'text', |
|
115 |
}); |
|
116 |
return 1; |
|
117 |
} |
|
118 |
|
|
119 |
if (params.html) { |
|
120 |
$div = $('<div>'); |
|
121 |
$div.attr('id', id) |
|
122 |
$div.addClass("modal"); |
|
123 |
let $modal_content = $('<div>'); |
|
124 |
$modal_content.addClass('modal-content'); |
|
125 |
$modal_content.html(params.html); |
|
126 |
$div.append($modal_content); |
|
127 |
$('body').append($div); |
|
128 |
kivi.reinit_widgets(); |
|
129 |
dialog_params.onCloseEnd = function() { $div.remove(); } |
|
130 |
|
|
131 |
$div.modal(dialog_params); |
|
132 |
|
|
133 |
} else if(params.id) { |
|
134 |
$div = $('#' + params.id); |
|
135 |
} else { |
|
136 |
console.error("insufficient parameters to open dialog"); |
|
137 |
return 0; |
|
138 |
} |
|
139 |
|
|
140 |
$div.modal('open'); |
|
141 |
|
|
142 |
return true; |
|
143 |
|
|
144 |
} |
|
81 | 145 |
}); |
js/kivi.js | ||
---|---|---|
468 | 468 |
// - dialog: an optional object of options passed to the $.dialog() call |
469 | 469 |
// - load: an optional function that is called after the content has been loaded successfully (only if an AJAX call is made) |
470 | 470 |
ns.popup_dialog = function(params) { |
471 |
if (kivi.Materialize) |
|
472 |
return kivi.Materialize.popup_dialog(params); |
|
473 |
|
|
471 | 474 |
var dialog; |
472 | 475 |
|
473 | 476 |
params = params || { }; |
Auch abrufbar als: Unified diff
mobile: Materialize modals für kivi.popup_dialog