ns.init = function() {
ns.reinit_widgets();
- }
+ };
- ns.build_i18n = function(locale) {
+ ns.build_i18n = function() {
return {
months: [
kivi.t8('January'),
// 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();
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) {
- console.log(params);
params = params || { };
let id = params.id || 'jqueryui_popup_dialog';
let $div;
// unlike classic layout, there is not fixed size, and M.modal is always... modal
onCloseStart: custom_close
},
- // User supplied options:
+ // User supplied options:
params.dialog || { },
{ // Options that must not be changed:
// close options already work
params.data = undefined;
ns.popup_dialog(params);
},
- error: function(x, status, error) { console.log(error); },
+ error: function(x, status, error) { console.error(error); },
dataType: 'text',
});
return 1;
if (params.html) {
$div = $('<div>');
- $div.attr('id', id)
+ $div.attr('id', id);
$div.addClass("modal");
let $modal_content = $('<div>');
$modal_content.addClass('modal-content');
$div.append($modal_content);
$('body').append($div);
kivi.reinit_widgets();
- dialog_params.onCloseEnd = function() { $div.remove(); }
+ dialog_params.onCloseEnd = function() { $div.remove(); };
$div.modal(dialog_params);
-
} else if(params.id) {
$div = $('#' + params.id);
} else {
$div.modal('open');
return true;
+ };
+
+ /**
+ * upload file to local storage for later sync
+ *
+ * should be used with P.M.file_upload(..., local=>1)
+ */
+ ns.LocalFileUpload = function(options) {
+ this.storage_token = options.storage_token; // used in localstorage to retrieve the file
+ this.dom_selector = options.dom_selector; // file inputs to listen on
+
+ this.init();
+ };
+
+ ns.LocalFileUpload.prototype = {
+ init: function() {
+ $(this.dom_selector).change(this.handle_file_upload);
+ },
+ handle_file_upload: function() {
+
+ },
+ load_files: function() {
+ return JSON.parse(localStorage.getImte(this.storage_token));
+ },
+ save_files: function() {
+ return JSON.parse(localStorage.getImte(this.storage_token));
+ },
+
+ };
- }
});