X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=js%2Fkivi.js;h=5f9360f6661e415cce846c577de8eb7ae2bebf7c;hb=d58f0807a72e7a791cded47b057e5f20116ca13f;hp=77dfe5c63ca7f8367f76a8887c28e5aab94f1bc4;hpb=a2179ea178c2e8cdcef9fd0cab517048778383de;p=kivitendo-erp.git diff --git a/js/kivi.js b/js/kivi.js index 77dfe5c63..5f9360f66 100644 --- a/js/kivi.js +++ b/js/kivi.js @@ -337,7 +337,8 @@ namespace("kivi", function(ns) { extraPlugins: 'inline_resize', toolbar: buttons, disableAutoInline: true, - title: false + title: false, + disableNativeSpellChecker: false }; config.height = $e.height(); @@ -346,6 +347,14 @@ namespace("kivi", function(ns) { var editor = CKEDITOR.inline($e.get(0), config); $e.data('ckeditorInstance', editor); + if ($e.hasClass('texteditor-space-for-toolbar')) + editor.on('instanceReady', function() { + var editor = $e.ckeditorGet(); + var editable = editor.editable(); + $(editable.$).css("margin-top", "30px"); + }); + + if ($e.hasClass('texteditor-autofocus')) editor.on('instanceReady', function() { ns.focus_ckeditor($e); }); }; @@ -371,6 +380,7 @@ namespace("kivi", function(ns) { if (ns.Part) ns.Part.reinit_widgets(); if (ns.CustomerVendor) ns.CustomerVendor.reinit_widgets(); if (ns.Validator) ns.Validator.reinit_widgets(); + if (ns.Materialize) ns.Materialize.reinit_widgets(); if (ns.ProjectPicker) ns.run_once_for('input.project_autocomplete', 'project_picker', function(elt) { @@ -467,6 +477,9 @@ namespace("kivi", function(ns) { // - dialog: an optional object of options passed to the $.dialog() call // - load: an optional function that is called after the content has been loaded successfully (only if an AJAX call is made) ns.popup_dialog = function(params) { + if (kivi.Materialize) + return kivi.Materialize.popup_dialog(params); + var dialog; params = params || { }; @@ -671,6 +684,49 @@ namespace("kivi", function(ns) { $input.prop('selectionStart', position); $input.prop('selectionEnd', position); }; + + ns._shell_escape = function(str) { + if (str.match(/^[a-zA-Z0-9.,_=+/-]+$/)) + return str; + + return "'" + str.replace(/'/, "'\\''") + "'"; + }; + + ns.call_as_curl = function(params) { + params = params || {}; + var uri = document.documentURI.replace(/\?.*/, ''); + var command = ['curl', '--user', kivi.myconfig.login + ':SECRET', '--request', params.method || 'POST'] + + $(params.data || []).each(function(idx, elt) { + command = command.concat([ '--form-string', elt.name + '=' + (elt.value || '') ]); + }); + + command.push(uri); + + return $.map(command, function(elt, idx) { + return kivi._shell_escape(elt); + }).join(' '); + }; + + ns.serialize = function(source, target = [], prefix, in_array = false) { + let arr_prefix = first => in_array ? (first ? "[+]" : "[]") : ""; + + if (Array.isArray(source) ) { + source.forEach(( val, i ) => { + ns.serialize(val, target, prefix + arr_prefix(i == 0), true); + }); + } else if (typeof source === "object") { + let first = true; + for (let key in source) { + ns.serialize(source[key], target, (prefix !== undefined ? prefix + arr_prefix(first) + "." : "") + key); + first = false; + } + } else { + target.push({ name: prefix + arr_prefix(false), value: source }); + } + + return target; + }; }); kivi = namespace('kivi');