/* not use resp fm*/ "use strict"; // Current version: 6 //toggle button configs var q4ToggleEditorText = 'Rimuovi editor'; var q4ToggleEditorIcon = 'http://localhost/sopraesottolozero.it/skins/r/img/off.png'; //inline editing configs var q4InlineAutoSave = true; //url manipulation functions, no dependency //changes a querystring parameter on an url function changeqspar(url, par, val){ if (url !== null) { //use an url object to parse the url var urlobj = new URL(url,document.baseURI); var urlqsobj = urlobj.searchParams; //set the url querystring parameter to the value urlqsobj.set(par,val); //rebuild the original url with the updated querystring var urlsplit = url.split("?"); var thisurl=urlsplit[0]+"?"+urlqsobj.toString()+urlobj.hash; return thisurl; } else return null; } //returns a querystring parameter on an url function getqspar(url, par){ if (url !== null) { //use an url object to parse the url var urlobj = new URL(url,document.baseURI); var urlqsobj = urlobj.searchParams; return urlqsobj.get(par); } else return null; } //adds a random rand parameter to an url function addrandom(url) { var newurl=url; newurl = changeqspar(newurl,'rand',Math.floor(Math.random() * 100000)); return newurl; } //function that returns an absolute url given a relative one var getAbsoluteUrl = (function() { //var a; return function(url) { var urlobj = new URL(url,document.baseURI); return urlobj.toString(); }; })(); //setup editor toggle button in tinyMCE 5+ function setupToggleEditor(ed){ ed.ui.registry.addIcon('removeeditor', ''); ed.ui.registry.addButton('removeeditor', { title : q4ToggleEditorText, icon : 'removeeditor', onAction : function() {ed.hide();} }); } //this should be revised, currently doesn't work properly function toggleEditor(myid) { myid = (typeof myid === 'string' ? myid : $(myid).attr('id')); myid = myid.replace( /(:|\.|\[|\]|,|=|@)/g, "\\$1" ); thiseditor=tinymce.get(myid); if (thiseditor.isHidden()) thiseditor.show(); else thiseditor.hide(); } //function to setup focus and blur handlers in inline mode function setupFocusBlurInlineHandlers(ed) { ed.on('focus', function(e) {dofocus(ed);} ); ed.on('blur', function(e) {doblur(ed);} ); } //function to setup blur handler in standard mode function setupBlurHandler(ed,txtareasel) { ed.on('blur',function(e){ if(ed.isDirty()) $(txtareasel).attr('data-changed','true');ed.save();}); } //setup filter for automatic adding of sandbox attribute to media embedding iframes function setupIframeSandboxFilter(ed) { ed.on('PreInit', function() { ed.parser.addNodeFilter('iframe', function(nodes) { nodes.forEach(function(node) { node.attr('sandbox', 'allow-scripts allow-same-origin'); }); }); }); } // TinyMCE inline editing session configs var ieditbaseurl="./iedit.php"; var blurconfirm="Ci sono modifiche non salvate, vuoi salvarle? Cliccando su Annulla le modifiche effettuate verranno perse."; //ajax functions for inline editing with tinymce4+ //ieditbaseurl = url to send edits to //blurconfirm = message to show when focusing out if unsaved changes //return inline editing parameters, helper for the other functions function getdebugprefix(ed) { var recid=ed.getBody().getAttribute("data-ieditid"); var fldid=ed.getBody().getAttribute("data-ieditfld"); return 'Record: '+recid+' Field: '+fldid+' '; } //return inline editing parameters, helper for the other functions function getiparms(ed) { var formid=ed.getBody().getAttribute("data-iedit"); var formv=ed.getBody().getAttribute("data-ieditv"); var listv=ed.getBody().getAttribute("data-ieditl"); var recid=ed.getBody().getAttribute("data-ieditid"); var fldid=ed.getBody().getAttribute("data-ieditfld"); var parms={form:formid,field:fldid,id:recid}; if (formv) parms['formv']=formv; if (listv) parms['listv']=listv; return parms; } //cancel edits to the content function docancel(ed) { ed.setContent(ed.startContent); ed.undoManager.clear(); ed.setDirty(false); console.log(getdebugprefix(ed)+'Edits canceled'); } //do post to try saving edits function trysaving(ed) { var parms=getiparms(ed); var csrf=ed.getBody().getAttribute("data-ieditcsrf"); var val=ed.getContent(); var url=ieditbaseurl+"?"+$.param(parms); console.log(getdebugprefix(ed)+"trying saving to url: "+url); $.ajax({ type: "POST", url: url, data: { value: val , _csrf_: csrf } }).done(function(data) {checksaving(ed,data);}); } //check saving results function checksaving(ed,data) { var dataj=JSON.parse(data); console.log(getdebugprefix(ed)+"Received data: "+data); if (dataj) { console.log(getdebugprefix(ed)+"Decoded data: "+dataj.result+" "+dataj.formv+" "+dataj.message); //if (dataj.formv!="") { if (dataj.result=='OK') { ed.save(); console.log(getdebugprefix(ed)+"Save success: "+dataj.message); if (!q4InlineAutoSave) { ed.notificationManager.open({text:dataj.message,type:'success',timeout: 5000}); ed.startContent = ed.getContent(); } refresh(ed); //this is needed to refresh the csrf } else { ed.focus(); console.log(getdebugprefix(ed)+"Save failure: "+dataj.result); //console.log(getdebugprefix(ed)+"Message: "+dataj.message); //console.log(getdebugprefix(ed)+"Error message: "+dataj.errmessage); ed.notificationManager.open({text:dataj.message+'
'+dataj.errmessage,type:'error',timeout: 4000}); // ed.setDirty(true); } if (dataj.revisedvalue!='') { ed.setContent(dataj.revisedvalue); ed.startContent = dataj.revisedvalue; } if (dataj.newrecid!='' && ed.getBody().getAttribute("data-ieditid")<0) { let items=$("*[data-ieditid='"+ed.getBody().getAttribute("data-ieditid")+"']"); if ((ed.getBody().getAttribute("data-ieditl")??"")!="") items=items.filter("*[data-ieditl='"+ed.getBody().getAttribute("data-ieditl")+"']"); items.attr("data-ieditid",dataj.newrecid); refresh(tinymce.activeEditor); //console.log(getdebugprefix(ed)+'Items to refresh',items); } //} } else { console.error(getdebugprefix(ed)+"Not a json response: "+data); } } //do get to refresh an editor configs function refresh(ed) { console.log(getdebugprefix(ed)+'Refreshing iedit attribs'); var parms=getiparms(ed); var url=ieditbaseurl+"?"+$.param(parms); $.ajax({ type: "GET", url: url }).done(function(data) { var dataj=JSON.parse(data); if (dataj) { console.log(getdebugprefix(ed)+"Refreshed iedit attribs: "+dataj.result+" formv: "+dataj.formv+" mess: "+dataj.message+" csrf: "+dataj.csrf); ed.getBody().setAttribute("data-ieditv",dataj.formv); ed.getBody().setAttribute("data-ieditcsrf",dataj.csrf); } else { console.error(getdebugprefix(ed)+"Not a json response: "+data); } }); } //do get to activate an editor instance function dofocus(ed) { console.log(getdebugprefix(ed)+'Focusing field'); //refresh(ed); } //check if dirty content, ask for confirmation and then try saving or do cancel function doblur(ed) { console.log(getdebugprefix(ed)+'Starting content: '+ed.startContent); console.log(getdebugprefix(ed)+'Current content: '+ed.getContent()); if (ed.isDirty() || ed.getContent()!==ed.startContent) { console.log(getdebugprefix(ed)+' is dirty'); //don't ask for confirmation if field was empty or if autosave is active if (ed.startContent==='' || q4InlineAutoSave || confirm(blurconfirm)) { console.log(getdebugprefix(ed)+'Dirty exit, try saving'); //trysaving(ed); //ed.execCommand('mceSave'); //return true; } else { console.log(getdebugprefix(ed)+'Dirty exit, cancel'); ed.execCommand('mceCancel'); } } else console.log(getdebugprefix(ed)+'clean exit'); } // TinyMCE basic configs var Q4TinyMCEConfig = { "width": "100%", "height": "100%", "verify_html": true, "convert_urls": true, "relative_urls": true, "browser_spellcheck": true, "toolbar_mode": "wrap", "forced_root_block": "p", "forced_root_block_attrs": { "class": "tmce_forced_root" }, "force_br_newlines": true, "invalid_styles": { "p": "display", "div": "display", "table": "width", "*": "color font-family font-size background margin margin-bottom line-height mso-ansi-font-size mso-ansi-font-style mso-ansi-font-weight mso-ansi-language mso-arabic-font-family mso-armenian-font-family mso-ascii-font-family mso-ascii-theme-font mso-background-source mso-bengali-font-family mso-baseline-position mso-bidi-flag mso-bidi-font-family mso-bidi-font-size mso-bidi-font-style mso-bidi-font-weight mso-bidi-language mso-bidi-theme-font mso-bookmark mso-bopomofo-font-family mso-border-alt mso-border-between mso-border-between-color mso-border-between-style mso-border-between-width mso-border-bottom-alt mso-border-bottom-color-alt mso-border-bottom-source mso-border-bottom-style-alt mso-border-bottom-width-alt mso-border-color-alt mso-border-effect mso-border-insideh mso-border-insidev mso-border-left-alt mso-border-left-color-alt mso-border-left-source mso-border-left-style-alt mso-border-left-width-alt mso-border-right-alt mso-border-right-color-alt mso-border-right-source mso-border-right-style-alt mso-border-right-width-alt mso-border-shadow mso-border-source mso-border-style-alt mso-border-top-alt mso-border-top-color-alt mso-border-top-source mso-border-top-style-alt mso-border-width-alt mso-border-top-width-alt mso-border-width-alt mso-break-type mso-build mso-build-after-action mso-build-after-color mso-build-auto-secs mso-build-avi mso-build-dual-id mso-build-order mso-build-sound-name mso-bullet-image mso-cellspacing mso-cell-special mso-char-indent mso-char-indent-count mso-char-indent-size mso-char-tracking mso-char-type mso-char-wrap mso-color-alt mso-color-index mso-color-source mso-column-break-before mso-columns mso-column-separator mso-column-margin mso-comment-author mso-comment-continuation mso-comment-id mso-comment-reference mso-currency-font-family mso-cyrillic-font-family mso-data-placement mso-default-font-family mso-default-height mso-default-props mso-default-width mso-diagonal-down mso-diagonal-down-color mso-diagonal-down-source mso-diagonal-down-style mso-diagonal-down-width mso-diagonal-up mso-diagonal-up-color mso-diagonal-up-source mso-diagonal-up-style mso-diagonal-up-width mso-devanagari-font-family mso-displayed-decimal-separator mso-displayed-thousand-separator mso-element mso-element-anchor-horizontal mso-element-anchor-lock mso-element-anchor-vertical mso-element-frame-height mso-element-frame-hspace mso-element-frame-vspace mso-element-frame-width mso-element-left mso-element-linespan mso-element-top mso-element-wrap mso-endnote-continuation-notice mso-endnote-continuation-notice-id mso-endnote-continuation-notice-src mso-endnote-continuation-separator mso-endnote-continuation-separator-id mso-endnote-continuation-separator-src mso-endnote-display mso-endnote-id mso-endnote-numbering mso-endnote-numbering-restart mso-endnote-numbering-start mso-endnote-numbering-style mso-endnote-separator mso-endnote-position mso-endnote-separator mso-endnote-separator-id mso-endnote-separator-src mso-eudc-font-family mso-even-footer mso-even-footer-id mso-even-footer-src mso-even-header mso-even-header-id mso-even-header-src mso-facing-pages mso-fareast-font-family mso-fareast-hint mso-fareast-language mso-fills-color mso-fareast-theme-font mso-field-change mso-field-change-author mso-field-change-time mso-field-change-value mso-field-code mso-field-lock mso-first-footer mso-first-footer-id mso-first-footer-src mso-first-header mso-first-header-id mso-first-header-src mso-font-alt mso-font-charset mso-font-format mso-font-info mso-font-info-charset mso-font-info-type mso-font-kerning mso-font-pitch mso-font-signature mso-font-signature-csb-one mso-font-signature-csb-two mso-font-signature-usb-four mso-font-signature-usb-one mso-font-signature-usb-three mso-font-signature-usb-two mso-font-src mso-font-width mso-footer mso-footer-data mso-footer-id mso-footer-margin mso-footer-src mso-footnote-continuation-notice mso-footnote-continuation-notice-id mso-footnote-continuation-notice-src mso-footnote-continuation-separator mso-footnote-continuation-separator-id mso-footnote-continuation-separator-src mso-footnote-id mso-footnote-numbering mso-footnote-numbering-restart mso-footnote-numbering-start mso-footnote-numbering-style mso-footnote-position mso-footnote-separator mso-footnote-separator-id mso-footnote-separator-src mso-foreground mso-forms-protection mso-generic-font-family mso-georgian-font-family mso-gram-e mso-greek-font-family mso-gurmukhi-font-family mso-halfwidthkana-font-family mso-han-font-family mso-hangul-font-family mso-hansi-font-family mso-hansi-theme-font mso-header mso-header-data mso-header-id mso-header-margin mso-header-src mso-hebrew-font-family mso-height-alt mso-height-rule mso-height-source mso-hide mso-highlight mso-horizontal-page-align mso-hyphenate mso-ignore mso-kinsoku-overflow mso-kana-font-family mso-kannada-font-family mso-kinsoku-overflow mso-lao-font-family mso-latin-font-family mso-latinext-font-family mso-layout-grid-align mso-layout-grid-char-alt mso-layout-grid-origin mso-level-font-family mso-level-indent mso-level-legacy mso-level-legacy-indent mso-level-legacy-space mso-level-legal-format mso-level-number-format mso-level-numbering mso-level-number-position mso-level-reset-level mso-level-size mso-level-start-at mso-level-style-link mso-level-tab-stop mso-level-suffix mso-level-text mso-line-break-override mso-line-grid mso-line-height-alt mso-line-height-rule mso-line-numbers-count-by mso-line-numbers-distance mso-line-numbers-restart mso-line-numbers-start mso-line-spacing mso-linked-frame mso-list mso-list-change-author mso-list-change-time mso-list-change-values mso-list-id mso-list-ins mso-list-ins-author mso-list-ins-time mso-list-template-ids mso-list-type mso-malayalam-font-family mso-margin-bottom-alt mso-margin-left-alt mso-margin-top-alt mso-mirror-margins mso-negative-indent-tab mso-no-proof mso-number-format mso-oriya-font-family mso-outline-level mso-outline-parent mso-outline-parent-col mso-outline-parent-row mso-outline-parent-visibility mso-outline-style mso-padding-alt mso-padding-between mso-padding-bottom-alt mso-padding-left-alt mso-padding-right-alt mso-padding-top-alt mso-page-border-aligned mso-page-border-art mso-page-border-bottom-art mso-page-border-display mso-page-border-left-art mso-page-border-offset-from mso-page-border-right-art mso-page-border-surround-footer mso-page-border-surround-header mso-page-border-top-art mso-page-border-z-order mso-page-numbers mso-page-numbers-chapter-separator mso-page-numbers-chapter-style mso-page-numbers-start mso-page-numbers-style mso-page-orientation mso-page-scale mso-pagination mso-panose-arm-style mso-panose-contrast mso-panose-family-type mso-panose-letterform mso-panose-midline mso-panose-proportion mso-panose-serif-style mso-panose-stroke-variation mso-panose-weight mso-panose-x-height mso-paper-source mso-paper-source-first-page mso-paper-source-other-pages mso-para-margin mso-para-margin-bottom mso-para-margin-left mso-para-margin-right mso-para-margin-top mso-pattern mso-pattern-color mso-pattern-style mso-position-horizontal mso-position-horizontal-relative mso-position-vertical mso-position-vertical-relative mso-print-area mso-print-color mso-print-gridlines mso-print-headings mso-print-resolution mso-print-sheet-order mso-print-title-column mso-print-title-row mso-prop-change mso-prop-change-author mso-prop-change-time mso-protection mso-rotate mso-row-margin-left mso-row-margin-right mso-ruby-merge mso-ruby-visibility mso-scheme-fill-color mso-scheme-shadow-color mso-shading mso-shadow-color mso-space-above mso-space-below mso-spacerun mso-special-character mso-special-format mso-spl-e mso-style-id mso-style-link mso-style-locked mso-style-name mso-style-next mso-style-noshow mso-style-parent mso-style-priority mso-style-type mso-style-qformat mso-style-type mso-style-unhide mso-style-update mso-subdocument mso-symbol-font-family mso-syriac-font-family mso-tab-count mso-table-anchor-horizontal mso-table-anchor-vertical mso-table-bspace mso-table-del-author mso-table-deleted mso-table-del-time mso-table-dir mso-table-ins-author mso-table-inserted mso-table-ins-time mso-table-layout-alt mso-table-left mso-table-lspace mso-table-overlap mso-table-prop-author mso-table-prop-change mso-table-prop-time mso-table-rspace mso-table-top mso-table-tspace mso-tamil-font-family mso-telugu-font-family mso-table-wrap mso-text-animation mso-text-combine-brackets mso-text-combine-id mso-text-control mso-text-fit-id mso-text-indent-alt mso-text-orientation mso-text-raise mso-thaana-font-family mso-thai-font-family mso-themecolor mso-themeshade mso-title-page mso-tny-compress mso-tstyle-colband-size mso-tstyle-rowband-size mso-unsynced mso-vertical-align-alt mso-vertical-align-special mso-vertical-page-align mso-width-alt mso-width-source mso-word-wrap mso-wrap-distance-bottom mso-wrap-distance-left mso-wrap-distance-right mso-wrap-distance-top mso-wrap-edited mso-xlrowspan mso-yfti-firstrow mso-yfti-irow mso-yfti-lastrow mso-yfti-tbllook mso-zero-height" }, "paste_auto_cleanup_on_paste": true, "paste_remove_styles": true, "paste_remove_styles_if_webkit": true, "paste_strip_class_attributes": true, "allow_html_in_named_anchor": true, "apply_source_formatting": true, "convert_newlines_to_brs": false, "theme_advanced_toolbar_location": "top", "theme_advanced_layout_manager": "SimpleLayout", "document_base_url": "http://localhost/sopraesottolozero.it/", "doctype": "", "language": "it", "content_style": "\r\n#tinymce.mce-content-body [style*=\"absolute\"]\r\n\t{\r\n\ttop:0 !important;\r\n\tleft:0 !important;\r\n\tposition:relative !important;\r\n\twidth:100% !important;\r\n\theight:auto !important;\r\n\toverflow:visible !important;\r\n\tmargin-top:10px;\r\n\tpadding-top:7px;\r\n\toutline: 1px dotted red !important;\r\n\t}\r\n#tinymce.mce-content-body [style*=\"absolute\"]:before\r\n\t{\r\n\ttop:-7px;\r\n\tleft:20px;\r\n\tcolor:red;\r\n\theight:14px;\r\n\tdisplay:block;\r\n\tfont-size:10px;\r\n\tposition:absolute;\r\n\tbackground-color:white;\r\n\tcontent:\"Errore! Questo blocco verr\u00e0 totalmente rimosso dall'output HTML, poich\u00e9 i posizionamenti absolute sono vietati\";\r\n\t}\r\n#tinymce.mce-content-body img[style*=\"float\"]\r\n\t{\r\n\tmargin:8px;\r\n\t}\r\n#tinymce.mce-content-body hr\r\n\t{\r\n\tclear:both;\r\n\tborder:1px solid #c7c7c7;\r\n\t}\r\nslot\r\n\t{\r\n\tdisplay:inline;\r\n\toutline:1px dotted rgba(0,0,100,0.7);\r\n\t}\r\n\t", "menubar": false, "branding": false, "autosave_ask_before_unload": false, "plugins": "charmap searchreplace help save code", "toolbar": "save cancel", "inline": true, "hidden_input": false, "fixed_toolbar_container": "#tmcetb", "style_formats": [ { "title": "Evidenzia 1", "inline": "span", "classes": "evid1" }, { "title": "Evidenzia 2", "inline": "span", "classes": "evid2" } ] }; // TinyMCE valid elements //valid elements for tinymce when used in text only mode var tmce_valid_elements_textonly = "" //+"@[accesskey|draggable|style|class|hidden|tabindex|contenteditable|id|title|contextmenu|lang|dir