X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=js%2Fkivi.Materialize.js;h=3262ffab13f5f4009e897d7ca232a488a7271662;hb=b36fb0f412d2d2b43b8d98d787743cbe1fbf2540;hp=83e4efb7fa4098ab031bca0959856e42eda2727e;hpb=291ad5ec33ddeb657c2fc7035a0177d39d73be9b;p=kivitendo-erp.git diff --git a/js/kivi.Materialize.js b/js/kivi.Materialize.js index 83e4efb7f..3262ffab1 100644 --- a/js/kivi.Materialize.js +++ b/js/kivi.Materialize.js @@ -3,9 +3,9 @@ namespace("kivi.Materialize", function(ns) { ns.init = function() { ns.reinit_widgets(); - } + }; - ns.build_i18n = function(locale) { + ns.build_i18n = function() { return { months: [ kivi.t8('January'), @@ -63,8 +63,12 @@ namespace("kivi.Materialize", function(ns) { // Accessibility labels labelMonthNext: kivi.t8('Next month'), labelMonthPrev: kivi.t8('Previous month') - } - } + }; + }; + + ns.flash = function(text) { + M.toast({html: text}); + }; ns.reinit_widgets = function() { $('.sidenav').sidenav(); @@ -75,7 +79,98 @@ namespace("kivi.Materialize", function(ns) { showClearBtn: true, i18n: ns.build_i18n() }); + $('.modal').modal(); + $('.materialboxed').materialbox(); M.updateTextFields(); - } + }; + + // alternative for kivi.popup_dialog. + // opens materialize modal instead. + // + // differences: M.modal can not load external content, so it needs to be fetched manually and inserted into the DOM. + ns.popup_dialog = function(params) { + params = params || { }; + let id = params.id || 'jqueryui_popup_dialog'; + let $div; + let custom_close = params.dialog ? params.dialog.close : undefined; + let dialog_params = $.extend( + { // kivitendo default parameters. + // unlike classic layout, there is not fixed size, and M.modal is always... modal + onCloseStart: custom_close + }, + // User supplied options: + params.dialog || { }, + { // Options that must not be changed: + // close options already work + }); + + if (params.url) { + $.ajax({ + url: params.url, + data: params.data, + success: function(data) { + params.html = data; + params.url = undefined; + params.data = undefined; + ns.popup_dialog(params); + }, + error: function(x, status, error) { console.error(error); }, + dataType: 'text', + }); + return 1; + } + + if (params.html) { + $div = $('