commit 49393850cde3736cc60b5ff8e76cb9b7069fa26e
parent 0e480c9e491f8997de51b88d45a1b82d5f4973af
Author: Jan Dankert <develop@jandankert.de>
Date: Wed, 17 Mar 2021 22:27:33 +0100
Refactoring: Using ES6-Modules (experimental)
Diffstat:
14 files changed, 29 insertions(+), 1877 deletions(-)
diff --git a/modules/cms/ui/action/index/IndexShowAction.class.php b/modules/cms/ui/action/index/IndexShowAction.class.php
@@ -53,6 +53,7 @@ class IndexShowAction extends IndexAction implements Method {
$this->setTemplateVar('style',$style );
$this->setTemplateVar('scriptLink', $this->getScriptLink() );
+ $this->setTemplateVar('scriptModuleLink',Startup::THEMES_DIR . 'default/script/openrat/init.js');
$this->setTemplateVar('styleLink' , $this->getStyleLink() );
$this->setTemplateVar('themeStyleLink', Html::url('index','themestyle') );
diff --git a/modules/cms/ui/themes/ThemeCompiler.class.php b/modules/cms/ui/themes/ThemeCompiler.class.php
@@ -262,6 +262,7 @@ class ThemeCompiler
// OpenRat internal JS - als letztes, damit die vorigen bereits geladen sind.
+ /*
$js[] = __DIR__.'/default/script/openrat/callback';
$js[] = __DIR__.'/default/script/openrat/notice';
$js[] = __DIR__.'/default/script/openrat/dialog';
@@ -271,6 +272,7 @@ class ThemeCompiler
$js[] = __DIR__.'/default/script/openrat/navigator';
$js[] = __DIR__.'/default/script/openrat/common';
$js[] = __DIR__.'/default/script/openrat/init';
+ */
// Komponentenbasiertes Javascript
foreach ( TemplateEngineInfo::getComponentList() as $c)
diff --git a/modules/cms/ui/themes/default/html/views/index/show.php b/modules/cms/ui/themes/default/html/views/index/show.php
@@ -7,6 +7,7 @@
<meta charset="<?php echo O::escapeHtml(''.@$charset.'') ?>" /><?php echo O::escapeHtml('') ?>
<meta name="<?php echo O::escapeHtml('robots') ?>" content="<?php echo O::escapeHtml('noindex,nofollow') ?>" /><?php echo O::escapeHtml('') ?>
<script src="<?php echo O::escapeHtml(''.@$scriptLink.'') ?>" defer="<?php echo O::escapeHtml('defer') ?>"><?php echo O::escapeHtml('') ?></script>
+ <script type="<?php echo O::escapeHtml('module') ?>" src="<?php echo O::escapeHtml(''.@$scriptModuleLink.'') ?>" defer="<?php echo O::escapeHtml('defer') ?>"><?php echo O::escapeHtml('') ?></script>
<link rel="<?php echo O::escapeHtml('stylesheet') ?>" type="<?php echo O::escapeHtml('text/css') ?>" href="<?php echo O::escapeHtml(''.@$styleLink.'') ?>" /><?php echo O::escapeHtml('') ?>
<link rel="<?php echo O::escapeHtml('stylesheet') ?>" type="<?php echo O::escapeHtml('text/css') ?>" href="<?php echo O::escapeHtml(''.@$themeStyleLink.'') ?>" /><?php echo O::escapeHtml('') ?>
<meta id="<?php echo O::escapeHtml('theme-color') ?>" name="<?php echo O::escapeHtml('theme-color') ?>" content="<?php echo O::escapeHtml(''.@$themeColor.'') ?>" /><?php echo O::escapeHtml('') ?>
diff --git a/modules/cms/ui/themes/default/html/views/index/show.tpl.src.xml b/modules/cms/ui/themes/default/html/views/index/show.tpl.src.xml
@@ -14,6 +14,7 @@
<meta charset="${charset}"/>
<meta name="robots" content="noindex,nofollow"/>
<script src="${scriptLink}" defer="defer"/>
+ <script type="module" src="${scriptModuleLink}" defer="defer"/>
<link rel="stylesheet" type="text/css" href="${styleLink}"/>
<link rel="stylesheet" type="text/css" href="${themeStyleLink}"/>
<meta id="theme-color" name="theme-color" content="${themeColor}"/>
diff --git a/modules/cms/ui/themes/default/script/openrat.js b/modules/cms/ui/themes/default/script/openrat.js
@@ -1664,1857 +1664,6 @@ header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\
/* Include script: trumbowyg.min.js */
/** Trumbowyg v2.10.0 - A lightweight WYSIWYG editor - alex-d.github.io/Trumbowyg - License MIT - Author : Alexandre Demode (Alex-D) / alex-d.fr */
jQuery.trumbowyg={langs:{en:{viewHTML:"View HTML",undo:"Undo",redo:"Redo",formatting:"Formatting",p:"Paragraph",blockquote:"Quote",code:"Code",header:"Header",bold:"Bold",italic:"Italic",strikethrough:"Stroke",underline:"Underline",strong:"Strong",em:"Emphasis",del:"Deleted",superscript:"Superscript",subscript:"Subscript",unorderedList:"Unordered list",orderedList:"Ordered list",insertImage:"Insert Image",link:"Link",createLink:"Insert link",unlink:"Remove link",justifyLeft:"Align Left",justifyCenter:"Align Center",justifyRight:"Align Right",justifyFull:"Align Justify",horizontalRule:"Insert horizontal rule",removeformat:"Remove format",fullscreen:"Fullscreen",close:"Close",submit:"Confirm",reset:"Cancel",required:"Required",description:"Description",title:"Title",text:"Text",target:"Target",width:"Width"}},plugins:{},svgPath:null,hideButtonTexts:null},Object.defineProperty(jQuery.trumbowyg,"defaultOptions",{value:{lang:"en",fixedBtnPane:!1,fixedFullWidth:!1,autogrow:!1,autogrowOnEnter:!1,imageWidthModalEdit:!1,prefix:"trumbowyg-",semantic:!0,resetCss:!1,removeformatPasted:!1,tagsToRemove:[],btns:[["viewHTML"],["undo","redo"],["formatting"],["strong","em","del"],["superscript","subscript"],["link"],["insertImage"],["justifyLeft","justifyCenter","justifyRight","justifyFull"],["unorderedList","orderedList"],["horizontalRule"],["removeformat"],["fullscreen"]],btnsDef:{},inlineElementsSelector:"a,abbr,acronym,b,caption,cite,code,col,dfn,dir,dt,dd,em,font,hr,i,kbd,li,q,span,strikeout,strong,sub,sup,u",pasteHandlers:[],plugins:{},urlProtocol:!1,minimalLinks:!1},writable:!1,enumerable:!0,configurable:!1}),function(e,t,n,a){"use strict";var o="tbwconfirm",r="tbwcancel";a.fn.trumbowyg=function(e,t){var n="trumbowyg";if(e===Object(e)||!e)return this.each(function(){a(this).data(n)||a(this).data(n,new i(this,e))});if(1===this.length)try{var o=a(this).data(n);switch(e){case"execCmd":return o.execCmd(t.cmd,t.param,t.forceCss);case"openModal":return o.openModal(t.title,t.content);case"closeModal":return o.closeModal();case"openModalInsert":return o.openModalInsert(t.title,t.fields,t.callback);case"saveRange":return o.saveRange();case"getRange":return o.range;case"getRangeText":return o.getRangeText();case"restoreRange":return o.restoreRange();case"enable":return o.setDisabled(!1);case"disable":return o.setDisabled(!0);case"toggle":return o.toggle();case"destroy":return o.destroy();case"empty":return o.empty();case"html":return o.html(t)}}catch(r){}return!1};var i=function(o,r){var i=this,s="trumbowyg-icons",l=a.trumbowyg;i.doc=o.ownerDocument||n,i.$ta=a(o),i.$c=a(o),r=r||{},null!=r.lang||null!=l.langs[r.lang]?i.lang=a.extend(!0,{},l.langs.en,l.langs[r.lang]):i.lang=l.langs.en,i.hideButtonTexts=null!=l.hideButtonTexts?l.hideButtonTexts:r.hideButtonTexts;var d=null!=l.svgPath?l.svgPath:r.svgPath;if(i.hasSvg=d!==!1,i.svgPath=i.doc.querySelector("base")?t.location.href.split("#")[0]:"",0===a("#"+s,i.doc).length&&d!==!1){if(null==d){for(var c=n.getElementsByTagName("script"),u=0;u<c.length;u+=1){var g=c[u].src,f=g.match("trumbowyg(.min)?.js");null!=f&&(d=g.substring(0,g.indexOf(f[0]))+"ui/icons.svg")}null==d&&console.warn("You must define svgPath: https://goo.gl/CfTY9U")}var h=i.doc.createElement("div");h.id=s,i.doc.body.insertBefore(h,i.doc.body.childNodes[0]),a.ajax({async:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",dataType:"xml",crossDomain:!0,url:d,data:null,beforeSend:null,complete:null,success:function(e){h.innerHTML=(new XMLSerializer).serializeToString(e.documentElement)}})}var p=i.lang.header,m=function(){return(t.chrome||t.Intl&&Intl.v8BreakIterator)&&"CSS"in t};i.btnsDef={viewHTML:{fn:"toggle"},undo:{isSupported:m,key:"Z"},redo:{isSupported:m,key:"Y"},p:{fn:"formatBlock"},blockquote:{fn:"formatBlock"},h1:{fn:"formatBlock",title:p+" 1"},h2:{fn:"formatBlock",title:p+" 2"},h3:{fn:"formatBlock",title:p+" 3"},h4:{fn:"formatBlock",title:p+" 4"},subscript:{tag:"sub"},superscript:{tag:"sup"},bold:{key:"B",tag:"b"},italic:{key:"I",tag:"i"},underline:{tag:"u"},strikethrough:{tag:"strike"},strong:{fn:"bold",key:"B"},em:{fn:"italic",key:"I"},del:{fn:"strikethrough"},createLink:{key:"K",tag:"a"},unlink:{},insertImage:{},justifyLeft:{tag:"left",forceCss:!0},justifyCenter:{tag:"center",forceCss:!0},justifyRight:{tag:"right",forceCss:!0},justifyFull:{tag:"justify",forceCss:!0},unorderedList:{fn:"insertUnorderedList",tag:"ul"},orderedList:{fn:"insertOrderedList",tag:"ol"},horizontalRule:{fn:"insertHorizontalRule"},removeformat:{},fullscreen:{"class":"trumbowyg-not-disable"},close:{fn:"destroy","class":"trumbowyg-not-disable"},formatting:{dropdown:["p","blockquote","h1","h2","h3","h4"],ico:"p"},link:{dropdown:["createLink","unlink"]}},i.o=a.extend(!0,{},l.defaultOptions,r),i.o.hasOwnProperty("imgDblClickHandler")||(i.o.imgDblClickHandler=i.getDefaultImgDblClickHandler()),i.urlPrefix=i.setupUrlPrefix(),i.disabled=i.o.disabled||"TEXTAREA"===o.nodeName&&o.disabled,r.btns?i.o.btns=r.btns:i.o.semantic||(i.o.btns[3]=["bold","italic","underline","strikethrough"]),a.each(i.o.btnsDef,function(e,t){i.addBtnDef(e,t)}),i.eventNamespace="trumbowyg-event",i.keys=[],i.tagToButton={},i.tagHandlers=[],i.pasteHandlers=[].concat(i.o.pasteHandlers),i.isIE=e.userAgent.indexOf("MSIE")!==-1||e.appVersion.indexOf("Trident/")!==-1,i.init()};i.prototype={DEFAULT_SEMANTIC_MAP:{b:"strong",i:"em",s:"del",strike:"del",div:"p"},init:function(){var e=this;e.height=e.$ta.height(),e.initPlugins();try{e.doc.execCommand("enableObjectResizing",!1,!1),e.doc.execCommand("defaultParagraphSeparator",!1,"p")}catch(t){}e.buildEditor(),e.buildBtnPane(),e.fixedBtnPaneEvents(),e.buildOverlay(),setTimeout(function(){e.disabled&&e.setDisabled(!0),e.$c.trigger("tbwinit")})},addBtnDef:function(e,t){this.btnsDef[e]=t},setupUrlPrefix:function(){var e=this.o.urlProtocol;if(e)return"string"!=typeof e?"https://":/:\/\/$/.test(e)?e:e+"://"},buildEditor:function(){var e=this,n=e.o.prefix,o="";e.$box=a("<div/>",{"class":n+"box "+n+"editor-visible "+n+e.o.lang+" trumbowyg"}),e.isTextarea=e.$ta.is("textarea"),e.isTextarea?(o=e.$ta.val(),e.$ed=a("<div/>"),e.$box.insertAfter(e.$ta).append(e.$ed,e.$ta)):(e.$ed=e.$ta,o=e.$ed.html(),e.$ta=a("<textarea/>",{name:e.$ta.attr("id"),height:e.height}).val(o),e.$box.insertAfter(e.$ed).append(e.$ta,e.$ed),e.syncCode()),e.$ta.addClass(n+"textarea").attr("tabindex",-1),e.$ed.addClass(n+"editor").attr({contenteditable:!0,dir:e.lang._dir||"ltr"}).html(o),e.o.tabindex&&e.$ed.attr("tabindex",e.o.tabindex),e.$c.is("[placeholder]")&&e.$ed.attr("placeholder",e.$c.attr("placeholder")),e.$c.is("[spellcheck]")&&e.$ed.attr("spellcheck",e.$c.attr("spellcheck")),e.o.resetCss&&e.$ed.addClass(n+"reset-css"),e.o.autogrow||e.$ta.add(e.$ed).css({height:e.height}),e.semanticCode(),e.o.autogrowOnEnter&&e.$ed.addClass(n+"autogrow-on-enter");var r,i=!1,s=!1,l="keyup";e.$ed.on("dblclick","img",e.o.imgDblClickHandler).on("keydown",function(t){if((t.ctrlKey||t.metaKey)&&!t.altKey){i=!0;var n=e.keys[String.fromCharCode(t.which).toUpperCase()];try{return e.execCmd(n.fn,n.param),!1}catch(a){}}}).on("compositionstart compositionupdate",function(){s=!0}).on(l+" compositionend",function(t){if("compositionend"===t.type)s=!1;else if(s)return;var n=t.which;if(!(n>=37&&n<=40)){if(!t.ctrlKey&&!t.metaKey||89!==n&&90!==n)if(i||17===n)"undefined"==typeof t.which&&e.semanticCode(!1,!1,!0);else{var a=!e.isIE||"compositionend"===t.type;e.semanticCode(!1,a&&13===n),e.$c.trigger("tbwchange")}else e.$c.trigger("tbwchange");setTimeout(function(){i=!1},50)}}).on("mouseup keydown keyup",function(t){(!t.ctrlKey&&!t.metaKey||t.altKey)&&setTimeout(function(){i=!1},50),clearTimeout(r),r=setTimeout(function(){e.updateButtonPaneStatus()},50)}).on("focus blur",function(t){if(e.$c.trigger("tbw"+t.type),"blur"===t.type&&a("."+n+"active-button",e.$btnPane).removeClass(n+"active-button "+n+"active"),e.o.autogrowOnEnter){if(e.autogrowOnEnterDontClose)return;"focus"===t.type?(e.autogrowOnEnterWasFocused=!0,e.autogrowEditorOnEnter()):e.o.autogrow||(e.$ed.css({height:e.$ed.css("min-height")}),e.$c.trigger("tbwresize"))}}).on("cut",function(){setTimeout(function(){e.semanticCode(!1,!0),e.$c.trigger("tbwchange")},0)}).on("paste",function(n){if(e.o.removeformatPasted){n.preventDefault(),t.getSelection&&t.getSelection().deleteFromDocument&&t.getSelection().deleteFromDocument();try{var o=t.clipboardData.getData("Text");try{e.doc.selection.createRange().pasteHTML(o)}catch(r){e.doc.getSelection().getRangeAt(0).insertNode(e.doc.createTextNode(o))}e.$c.trigger("tbwchange",n)}catch(i){e.execCmd("insertText",(n.originalEvent||n).clipboardData.getData("text/plain"))}}a.each(e.pasteHandlers,function(e,t){t(n)}),setTimeout(function(){e.semanticCode(!1,!0),e.$c.trigger("tbwpaste",n)},0)}),e.$ta.on("keyup",function(){e.$c.trigger("tbwchange")}).on("paste",function(){setTimeout(function(){e.$c.trigger("tbwchange")},0)}),e.$box.on("keydown",function(t){if(27===t.which&&1===a("."+n+"modal-box",e.$box).length)return e.closeModal(),!1})},autogrowEditorOnEnter:function(){var e=this;e.$ed.removeClass("autogrow-on-enter");var t=e.$ed[0].clientHeight;e.$ed.height("auto");var n=e.$ed[0].scrollHeight;e.$ed.addClass("autogrow-on-enter"),t!==n&&(e.$ed.height(t),setTimeout(function(){e.$ed.css({height:n}),e.$c.trigger("tbwresize")},0))},buildBtnPane:function(){var e=this,t=e.o.prefix,n=e.$btnPane=a("<div/>",{"class":t+"button-pane"});a.each(e.o.btns,function(o,r){a.isArray(r)||(r=[r]);var i=a("<div/>",{"class":t+"button-group "+(r.indexOf("fullscreen")>=0?t+"right":"")});a.each(r,function(t,n){try{e.isSupportedBtn(n)&&i.append(e.buildBtn(n))}catch(a){}}),i.html().trim().length>0&&n.append(i)}),e.$box.prepend(n)},buildBtn:function(e){var t=this,n=t.o.prefix,o=t.btnsDef[e],r=o.dropdown,i=null==o.hasIcon||o.hasIcon,s=t.lang[e]||e,l=a("<button/>",{type:"button","class":n+e+"-button "+(o["class"]||"")+(i?"":" "+n+"textual-button"),html:t.hasSvg&&i?'<svg><use xlink:href="'+t.svgPath+"#"+n+(o.ico||e).replace(/([A-Z]+)/g,"-$1").toLowerCase()+'"/></svg>':t.hideButtonTexts?"":o.text||o.title||t.lang[e]||e,title:(o.title||o.text||s)+(o.key?" (Ctrl + "+o.key+")":""),tabindex:-1,mousedown:function(){return r&&!a("."+e+"-"+n+"dropdown",t.$box).is(":hidden")||a("body",t.doc).trigger("mousedown"),!((t.$btnPane.hasClass(n+"disable")||t.$box.hasClass(n+"disabled"))&&!a(this).hasClass(n+"active")&&!a(this).hasClass(n+"not-disable"))&&(t.execCmd(!!r&&"dropdown"||o.fn||e,o.param||e,o.forceCss),!1)}});if(r){l.addClass(n+"open-dropdown");var d=n+"dropdown",c={"class":d+"-"+e+" "+d+" "+n+"fixed-top"};c["data-"+d]=e;var u=a("<div/>",c);a.each(r,function(e,n){t.btnsDef[n]&&t.isSupportedBtn(n)&&u.append(t.buildSubBtn(n))}),t.$box.append(u.hide())}else o.key&&(t.keys[o.key]={fn:o.fn||e,param:o.param||e});return r||(t.tagToButton[(o.tag||e).toLowerCase()]=e),l},buildSubBtn:function(e){var t=this,n=t.o.prefix,o=t.btnsDef[e],r=null==o.hasIcon||o.hasIcon;return o.key&&(t.keys[o.key]={fn:o.fn||e,param:o.param||e}),t.tagToButton[(o.tag||e).toLowerCase()]=e,a("<button/>",{type:"button","class":n+e+"-dropdown-button"+(o.ico?" "+n+o.ico+"-button":""),html:t.hasSvg&&r?'<svg><use xlink:href="'+t.svgPath+"#"+n+(o.ico||e).replace(/([A-Z]+)/g,"-$1").toLowerCase()+'"/></svg>'+(o.text||o.title||t.lang[e]||e):o.text||o.title||t.lang[e]||e,title:o.key?" (Ctrl + "+o.key+")":null,style:o.style||null,mousedown:function(){return a("body",t.doc).trigger("mousedown"),t.execCmd(o.fn||e,o.param||e,o.forceCss),!1}})},isSupportedBtn:function(e){try{return this.btnsDef[e].isSupported()}catch(t){}return!0},buildOverlay:function(){var e=this;return e.$overlay=a("<div/>",{"class":e.o.prefix+"overlay"}).appendTo(e.$box),e.$overlay},showOverlay:function(){var e=this;a(t).trigger("scroll"),e.$overlay.fadeIn(200),e.$box.addClass(e.o.prefix+"box-blur")},hideOverlay:function(){var e=this;e.$overlay.fadeOut(50),e.$box.removeClass(e.o.prefix+"box-blur")},fixedBtnPaneEvents:function(){var e=this,n=e.o.fixedFullWidth,o=e.$box;e.o.fixedBtnPane&&(e.isFixed=!1,a(t).on("scroll."+e.eventNamespace+" resize."+e.eventNamespace,function(){if(o){e.syncCode();var r=a(t).scrollTop(),i=o.offset().top+1,s=e.$btnPane,l=s.outerHeight()-2;r-i>0&&r-i-e.height<0?(e.isFixed||(e.isFixed=!0,s.css({position:"fixed",top:0,left:n?"0":"auto",zIndex:7}),a([e.$ta,e.$ed]).css({marginTop:s.height()})),s.css({width:n?"100%":o.width()-1+"px"}),a("."+e.o.prefix+"fixed-top",o).css({position:n?"fixed":"absolute",top:n?l:l+(r-i)+"px",zIndex:15})):e.isFixed&&(e.isFixed=!1,s.removeAttr("style"),a([e.$ta,e.$ed]).css({marginTop:0}),a("."+e.o.prefix+"fixed-top",o).css({position:"absolute",top:l}))}}))},setDisabled:function(e){var t=this,n=t.o.prefix;t.disabled=e,e?t.$ta.attr("disabled",!0):t.$ta.removeAttr("disabled"),t.$box.toggleClass(n+"disabled",e),t.$ed.attr("contenteditable",!e)},destroy:function(){var e=this,n=e.o.prefix;e.isTextarea?e.$box.after(e.$ta.css({height:""}).val(e.html()).removeClass(n+"textarea").show()):e.$box.after(e.$ed.css({height:""}).removeClass(n+"editor").removeAttr("contenteditable").removeAttr("dir").html(e.html()).show()),e.$ed.off("dblclick","img"),e.destroyPlugins(),e.$box.remove(),e.$c.removeData("trumbowyg"),a("body").removeClass(n+"body-fullscreen"),e.$c.trigger("tbwclose"),a(t).off("scroll."+e.eventNamespace+" resize."+e.eventNamespace)},empty:function(){this.$ta.val(""),this.syncCode(!0)},toggle:function(){var e=this,t=e.o.prefix;e.o.autogrowOnEnter&&(e.autogrowOnEnterDontClose=!e.$box.hasClass(t+"editor-hidden")),e.semanticCode(!1,!0),setTimeout(function(){e.doc.activeElement.blur(),e.$box.toggleClass(t+"editor-hidden "+t+"editor-visible"),e.$btnPane.toggleClass(t+"disable"),a("."+t+"viewHTML-button",e.$btnPane).toggleClass(t+"active"),e.$box.hasClass(t+"editor-visible")?e.$ta.attr("tabindex",-1):e.$ta.removeAttr("tabindex"),e.o.autogrowOnEnter&&!e.autogrowOnEnterDontClose&&e.autogrowEditorOnEnter()},0)},dropdown:function(e){var n=this,o=n.doc,r=n.o.prefix,i=a("[data-"+r+"dropdown="+e+"]",n.$box),s=a("."+r+e+"-button",n.$btnPane),l=i.is(":hidden");if(a("body",o).trigger("mousedown"),l){var d=s.offset().left;s.addClass(r+"active"),i.css({position:"absolute",top:s.offset().top-n.$btnPane.offset().top+s.outerHeight(),left:n.o.fixedFullWidth&&n.isFixed?d+"px":d-n.$btnPane.offset().left+"px"}).show(),a(t).trigger("scroll"),a("body",o).on("mousedown."+n.eventNamespace,function(e){i.is(e.target)||(a("."+r+"dropdown",n.$box).hide(),a("."+r+"active",n.$btnPane).removeClass(r+"active"),a("body",o).off("mousedown."+n.eventNamespace))})}},html:function(e){var t=this;return null!=e?(t.$ta.val(e),t.syncCode(!0),t.$c.trigger("tbwchange"),t):t.$ta.val()},syncTextarea:function(){var e=this;e.$ta.val(e.$ed.text().trim().length>0||e.$ed.find("hr,img,embed,iframe,input").length>0?e.$ed.html():"")},syncCode:function(e){var t=this;if(!e&&t.$ed.is(":visible"))t.syncTextarea();else{var n=a("<div>").html(t.$ta.val()),o=a("<div>").append(n);a(t.o.tagsToRemove.join(","),o).remove(),t.$ed.html(o.contents().html())}if(t.o.autogrow&&(t.height=t.$ed.height(),t.height!==t.$ta.css("height")&&(t.$ta.css({height:t.height}),t.$c.trigger("tbwresize"))),t.o.autogrowOnEnter){t.$ed.height("auto");var r=t.autogrowOnEnterWasFocused?t.$ed[0].scrollHeight:t.$ed.css("min-height");r!==t.$ta.css("height")&&(t.$ed.css({height:r}),t.$c.trigger("tbwresize"))}},semanticCode:function(e,t,n){var o=this;if(o.saveRange(),o.syncCode(e),o.o.semantic){if(o.semanticTag("b"),o.semanticTag("i"),o.semanticTag("s"),o.semanticTag("strike"),t){var r=o.o.inlineElementsSelector,i=":not("+r+")";o.$ed.contents().filter(function(){return 3===this.nodeType&&this.nodeValue.trim().length>0}).wrap("<span data-tbw/>");var s=function(e){if(0!==e.length){var t=e.nextUntil(i).addBack().wrapAll("<p/>").parent(),n=t.nextAll(r).first();t.next("br").remove(),s(n)}};s(o.$ed.children(r).first()),o.semanticTag("div",!0),o.$ed.find("p").filter(function(){return(!o.range||this!==o.range.startContainer)&&(0===a(this).text().trim().length&&0===a(this).children().not("br,span").length)}).contents().unwrap(),a("[data-tbw]",o.$ed).contents().unwrap(),o.$ed.find("p:empty").remove()}n||o.restoreRange(),o.syncTextarea()}},semanticTag:function(e,t){var n;if(null!=this.o.semantic&&"object"==typeof this.o.semantic&&this.o.semantic.hasOwnProperty(e))n=this.o.semantic[e];else{if(this.o.semantic!==!0||!this.DEFAULT_SEMANTIC_MAP.hasOwnProperty(e))return;n=this.DEFAULT_SEMANTIC_MAP[e]}a(e,this.$ed).each(function(){var e=a(this);e.wrap("<"+n+"/>"),t&&a.each(e.prop("attributes"),function(){e.parent().attr(this.name,this.value)}),e.contents().unwrap()})},createLink:function(){for(var e,t,n,o=this,r=o.doc.getSelection(),i=r.focusNode,s=(new XMLSerializer).serializeToString(r.getRangeAt(0).cloneContents());["A","DIV"].indexOf(i.nodeName)<0;)i=i.parentNode;if(i&&"A"===i.nodeName){var l=a(i);s=l.text(),e=l.attr("href"),o.o.minimalLinks||(t=l.attr("title"),n=l.attr("target"));var d=o.doc.createRange();d.selectNode(i),r.removeAllRanges(),r.addRange(d)}o.saveRange();var c={url:{label:"URL",required:!0,value:e},text:{label:o.lang.text,value:s}};o.o.minimalLinks||Object.assign(c,{title:{label:o.lang.title,value:t},target:{label:o.lang.target,value:n}}),o.openModalInsert(o.lang.createLink,c,function(e){var t=o.prependUrlPrefix(e.url);if(!t.length)return!1;var n=a(['<a href="',e.url,'">',e.text||e.url,"</a>"].join(""));return o.o.minimalLinks||(e.title.length>0&&n.attr("title",e.title),e.target.length>0&&n.attr("target",e.target)),o.range.deleteContents(),o.range.insertNode(n[0]),o.syncCode(),o.$c.trigger("tbwchange"),!0})},prependUrlPrefix:function(e){var t=this;if(!t.urlPrefix)return e;const n=/^([a-z][-+.a-z0-9]*:|\/|#)/i;if(n.test(e))return e;const a=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return a.test(e)?"mailto:"+e:t.urlPrefix+e},unlink:function(){var e=this,t=e.doc.getSelection(),n=t.focusNode;if(t.isCollapsed){for(;["A","DIV"].indexOf(n.nodeName)<0;)n=n.parentNode;if(n&&"A"===n.nodeName){var a=e.doc.createRange();a.selectNode(n),t.removeAllRanges(),t.addRange(a)}}e.execCmd("unlink",void 0,void 0,!0)},insertImage:function(){var e=this;e.saveRange();var t={url:{label:"URL",required:!0},alt:{label:e.lang.description,value:e.getRangeText()}};e.o.imageWidthModalEdit&&(t.width={}),e.openModalInsert(e.lang.insertImage,t,function(t){e.execCmd("insertImage",t.url);var n=a('img[src="'+t.url+'"]:not([alt])',e.$box);return n.attr("alt",t.alt),e.o.imageWidthModalEdit&&n.attr({width:t.width}),e.syncCode(),e.$c.trigger("tbwchange"),!0})},fullscreen:function(){var e,n=this,o=n.o.prefix,r=o+"fullscreen";n.$box.toggleClass(r),e=n.$box.hasClass(r),a("body").toggleClass(o+"body-fullscreen",e),a(t).trigger("scroll"),n.$c.trigger("tbw"+(e?"open":"close")+"fullscreen")},execCmd:function(e,t,n,a){var o=this;a=!!a||"","dropdown"!==e&&o.$ed.focus();try{o.doc.execCommand("styleWithCSS",!1,n||!1)}catch(r){}try{o[e+a](t)}catch(r){try{e(t)}catch(i){"insertHorizontalRule"===e?t=void 0:"formatBlock"===e&&o.isIE&&(t="<"+t+">"),o.doc.execCommand(e,!1,t),o.syncCode(),o.semanticCode(!1,!0)}"dropdown"!==e&&(o.updateButtonPaneStatus(),o.$c.trigger("tbwchange"))}},openModal:function(e,n){var i=this,s=i.o.prefix;if(a("."+s+"modal-box",i.$box).length>0)return!1;i.o.autogrowOnEnter&&(i.autogrowOnEnterDontClose=!0),i.saveRange(),i.showOverlay(),i.$btnPane.addClass(s+"disable");var l=a("<div/>",{"class":s+"modal "+s+"fixed-top"}).css({top:i.$btnPane.height()}).appendTo(i.$box);i.$overlay.one("click",function(){return l.trigger(r),!1});var d=a("<form/>",{action:"",html:n}).on("submit",function(){return l.trigger(o),!1}).on("reset",function(){return l.trigger(r),!1}).on("submit reset",function(){i.o.autogrowOnEnter&&(i.autogrowOnEnterDontClose=!1)}),c=a("<div/>",{"class":s+"modal-box",html:d}).css({top:"-"+i.$btnPane.outerHeight()+"px",opacity:0}).appendTo(l).animate({top:0,opacity:1},100);return a("<span/>",{text:e,"class":s+"modal-title"}).prependTo(c),l.height(c.outerHeight()+10),a("input:first",c).focus(),i.buildModalBtn("submit",c),i.buildModalBtn("reset",c),a(t).trigger("scroll"),l},buildModalBtn:function(e,t){var n=this,o=n.o.prefix;return a("<button/>",{"class":o+"modal-button "+o+"modal-"+e,type:e,text:n.lang[e]||e}).appendTo(a("form",t))},closeModal:function(){var e=this,t=e.o.prefix;e.$btnPane.removeClass(t+"disable"),e.$overlay.off();var n=a("."+t+"modal-box",e.$box);n.animate({top:"-"+n.height()},100,function(){n.parent().remove(),e.hideOverlay()}),e.restoreRange()},openModalInsert:function(e,t,n){var i=this,s=i.o.prefix,l=i.lang,d="";return a.each(t,function(e,t){var n=t.label||e,a=t.name||e,o=t.attributes||{},r=Object.keys(o).map(function(e){return e+'="'+o[e]+'"'}).join(" ");d+='<label><input type="'+(t.type||"text")+'" name="'+a+'"'+("checkbox"===t.type&&t.value?' checked="checked"':' value="'+(t.value||"").replace(/"/g,"""))+'"'+r+'><span class="'+s+'input-infos"><span>'+(l[n]?l[n]:n)+"</span></span></label>"}),i.openModal(e,d).on(o,function(){var e=a("form",a(this)),r=!0,s={};a.each(t,function(t,n){var o=n.name||t,l=a('input[name="'+o+'"]',e),d=l.attr("type");switch(d.toLowerCase()){case"checkbox":s[o]=l.is(":checked");break;case"radio":s[o]=l.filter(":checked").val();break;default:s[o]=a.trim(l.val())}n.required&&""===s[o]?(r=!1,i.addErrorOnModalField(l,i.lang.required)):n.pattern&&!n.pattern.test(s[o])&&(r=!1,i.addErrorOnModalField(l,n.patternError))}),r&&(i.restoreRange(),n(s,t)&&(i.syncCode(),i.$c.trigger("tbwchange"),i.closeModal(),a(this).off(o)))}).one(r,function(){a(this).off(o),i.closeModal()})},addErrorOnModalField:function(e,t){var n=this.o.prefix,o=e.parent();e.on("change keyup",function(){o.removeClass(n+"input-error")}),o.addClass(n+"input-error").find("input+span").append(a("<span/>",{"class":n+"msg-error",text:t}))},getDefaultImgDblClickHandler:function(){var e=this;return function(){var t=a(this),n=t.attr("src"),o="(Base64)";0===n.indexOf("data:image")&&(n=o);var r={url:{label:"URL",value:n,required:!0},alt:{label:e.lang.description,value:t.attr("alt")}};return e.o.imageWidthModalEdit&&(r.width={value:t.attr("width")?t.attr("width"):""}),e.openModalInsert(e.lang.insertImage,r,function(n){return n.src!==o&&t.attr({src:n.url}),t.attr({alt:n.alt}),e.o.imageWidthModalEdit&&(parseInt(n.width)>0?t.attr({width:n.width}):t.removeAttr("width")),!0}),!1}},saveRange:function(){var e=this,t=e.doc.getSelection();if(e.range=null,t.rangeCount){var n,a=e.range=t.getRangeAt(0),o=e.doc.createRange();o.selectNodeContents(e.$ed[0]),o.setEnd(a.startContainer,a.startOffset),n=(o+"").length,e.metaRange={start:n,end:n+(a+"").length}}},restoreRange:function(){var e,t=this,n=t.metaRange,a=t.range,o=t.doc.getSelection();if(a){if(n&&n.start!==n.end){var r,i=0,s=[t.$ed[0]],l=!1,d=!1;for(e=t.doc.createRange();!d&&(r=s.pop());)if(3===r.nodeType){var c=i+r.length;!l&&n.start>=i&&n.start<=c&&(e.setStart(r,n.start-i),l=!0),l&&n.end>=i&&n.end<=c&&(e.setEnd(r,n.end-i),d=!0),i=c}else for(var u=r.childNodes,g=u.length;g>0;)g-=1,s.push(u[g])}o.removeAllRanges(),o.addRange(e||a)}},getRangeText:function(){return this.range+""},updateButtonPaneStatus:function(){var e=this,t=e.o.prefix,n=e.getTagsRecursive(e.doc.getSelection().focusNode),o=t+"active-button "+t+"active";a("."+t+"active-button",e.$btnPane).removeClass(o),a.each(n,function(n,r){var i=e.tagToButton[r.toLowerCase()],s=a("."+t+i+"-button",e.$btnPane);if(s.length>0)s.addClass(o);else try{s=a("."+t+"dropdown ."+t+i+"-dropdown-button",e.$box);var l=s.parent().data("dropdown");a("."+t+l+"-button",e.$box).addClass(o)}catch(d){}})},getTagsRecursive:function(e,t){var n=this;if(t=t||(e&&e.tagName?[e.tagName]:[]),!e||!e.parentNode)return t;e=e.parentNode;var o=e.tagName;return"DIV"===o?t:("P"===o&&""!==e.style.textAlign&&t.push(e.style.textAlign),a.each(n.tagHandlers,function(a,o){t=t.concat(o(e,n))}),t.push(o),n.getTagsRecursive(e,t).filter(function(e){return null!=e}))},initPlugins:function(){var e=this;e.loadedPlugins=[],a.each(a.trumbowyg.plugins,function(t,n){n.shouldInit&&!n.shouldInit(e)||(n.init(e),n.tagHandler&&e.tagHandlers.push(n.tagHandler),e.loadedPlugins.push(n))})},destroyPlugins:function(){a.each(this.loadedPlugins,function(e,t){t.destroy&&t.destroy()})}}}(navigator,window,document,jQuery);
-/* Include script: callback.js */
-class Callback {
-
- constructor() {
- this.list = [];
- }
-
- // Add a callback or a collection of callbacks to the list
- add( callable ) {
- this.list.push( callable );
- }
-
- fire() {
- for( let c of this.list)
- c.apply(null,arguments);
- }
-
-}
-/* Include script: notice.js */
-
-/**
- * Notice.
- */
-class Notice {
-
- 'use strict';
-
- static type = Object.freeze({
- warning: 0,
- validation: 1,
- info: 2,
- success: 3,
- error: 3,
- loading: 3,
- inactive: 4
- });
-
- constructor() {
- this.typ = '';
- this.id = 0;
- this.name = '';
- this.status = 'inactive';
- this.msg = '';
- this.log = '';
- this.timeout = 0;
-
- this.element = $('<div />')
- .addClass('notice' )
- .addClass('notice--is-inactive' )
- .addClass('collapsible' )
- .addClass('collapsible--is-closed');
-
- this.onClick = new Callback();
-
- }
-
-
- before() {
- };
-
-
- // Close the notice.
- close() {
- /* no effects in jquery slim
- this.element.fadeOut('fast', () => {
- this.element.remove();
- } );*/
- this.element.remove();
- }
-
-
- setStatus( status ) {
-
- this.element.removeClass('notice--' + this.status );
- this.status = status;
- this.element.addClass('notice--' + this.status );
- }
-
-
- inProgress() {
- this.element.addClass('loader');
- }
-
- stopProgress() {
- this.element.removeClass('loader');
- }
-
- show() {
-
- console.debug('user notice: '+this.msg);
- let notice = this;
- this.element.removeClass('notice--is-inactive');
-
- this.element.appendTo('.or-notice-container'); // Notice anhängen.
-
- let toolbar = $('<div class="or-notice-toolbar"></div>');
- toolbar.appendTo(this.element);
- toolbar.append('<i class="or-image-icon or-image-icon--menu-close or-act-notice-close"></i>');
-
- this.element.append( $('<i />').addClass('image-icon').addClass('image-icon--node-open' ).addClass('collapsible--on-open' ) );
- this.element.append( $('<i />').addClass('image-icon').addClass('image-icon--node-closed').addClass('collapsible--on-closed') );
- this.element.append('<span class="or-notice-text or-collapsible-act-switch">' + Notice.htmlEntities(this.msg) + '</span>');
-
- if (this.name) {
- this.element.append( $('<div class="or-notice-name or-collapsible-value"><a class="or-act-clickable" href="' + WorkbenchNavigator.createShortUrl(this.typ, this.id) + '" data-type="open" data-action="' + this.typ + '" data-id="' + this.id + '"><i class="or-notice-action-full or-image-icon or-image-icon--action-' + this.typ + '"></i><span class="">' + this.name + '</span></a></div>').orLinkify() );
- }
-
- if (this.log)
- this.element.append('<div class="or-notice-log or-collapsible-value"><pre>' + Notice.htmlEntities(this.log) + '</pre></div>');
-
- this.element.append('<div class="or-notice-date or-collapsible-value">' + new Date().toLocaleTimeString() + '</div>');
-
-
- // Fire onclick-handler
- this.element.find('.or-notice-text').click( function () {
- notice.onClick.fire();
- } );
-
- Workbench.registerOpenClose( this.element );
-
- // Close the notice on click
- this.element.find('.or-act-notice-close').click(function () {
- notice.close();
- });
-
- // Fadeout the notice after a while.
- if ( !this.timeout ) {
- switch( this.status ) {
- case 'ok' : this.timeout = 3; break;
- case 'info' : this.timeout = 30; break;
- case 'warning': this.timeout = 40; break;
- case 'error' : this.timeout = 50; break;
- default: this.timeout = 10; console.error('unknown notice status: '+this.status);
- }
- }
-
- if (this.timeout) {
-
- // Sets a timer to close the notice after the timeout
- let timer = setTimeout(function () {
- notice.close();
- }, this.timeout * 1000);
-
- // Click anywhere in the notice should clear the auto-close timer.
- // Because if the user interacts with the notice it should not magically disappear.
- this.element.click( function () {
- console.debug('kicked timer of notice');
- console.debug( timer );
- window.clearTimeout( timer );
- } );
- }
- }
-
- setContext(type,id,name) {
- this.typ = type;
- this.id = id;
- this.name = name;
- }
-
-
- /**
- * Show a notice bubble in the UI.
- * @param type
- * @param id
- * @param name
- * @param status
- * @param msg
- * @param log
- * @param notifyTheBrowser
- */
- start(type, id, name, status, msg, log = null, notifyTheBrowser = false) {
- // Notice-Bar mit dieser Meldung erweitern.
-
- this.setContext(type,id,name);
- this.msg = msg;
- this.log = log;
-
- if (notifyTheBrowser)
- this.notifyBrowser(msg); // Notify browser if wanted.
-
- this.setStatus(status);
-
- }
-
-
-
- /**
- * Show a notification in the browser.
- * Source: https://developer.mozilla.org/en-US/docs/Web/API/notification
- * @param text text of message
- */
- notifyBrowser()
- {
- let text = this.msg;
-
- // Let's check if the browser supports notifications
- if (!("Notification" in window)) {
- return;
- }
-
- // Let's check if the user is okay to get some notification
- else if (Notification.permission === "granted") {
- // If it's okay let's create a notification
- let notification = new Notification(text);
- }
-
- // Otherwise, we need to ask the user for permission
- else if (Notification.permission !== 'denied') {
- Notification.requestPermission(function (permission) {
- // If the user is okay, let's create a notification
- if (permission === "granted") {
- let notification = new Notification(text);
- }
- });
- }
-
- // At last, if the user already denied any notification, and you
- // want to be respectful there is no need to bother them any more.
- }
-
-
-
- /**
- * Escape HTML entities.
- *
- * @param str
- * @returns {string}
- */
- static htmlEntities( str ) {
- return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
- }
-
-
- static removeNoticesWithStatus( status) {
- $('.or-notice-container').find('.or-notice--'+status).remove();
- }
-
- static removeAllNotices( status) {
-
- $('.or-notice-container').find('.or-notice').remove();
- }
-
-}
-
-/* Include script: dialog.js */
-/**
- * The encapsulated view.
- */
-class Dialog {
-
- /**
- * A dialog is a special area in the workbench for displaying and inputting data.
- * A dialog contains a view.
- */
- constructor() {
-
- this.view;
-
- /**
- * Dirty-marker (if unsaved changes exist).
- *
- * @type {boolean}
- */
- this.isDirty = false;
-
- /**
- * the DOM element which contains the dialog.
- * @type {*|jQuery|HTMLElement}
- */
- this.element = $('.or-dialog-content .or-view');
- }
-
- /**
- * Creating a new dialog.
- *
- * @param name
- * @param action Action
- * @param method
- * @param id Id
- * @param params
- *
- * @return Promise of underlying view
- */
- start( name,action,method,id,params )
- {
- // Attribute aus dem aktuellen Editor holen, falls die Daten beim Aufrufer nicht angegeben sind.
- if (!action)
- action = Workbench.state.action;
-
- if (!id)
- id = Workbench.state.id;
-
- let dialog = this;
-
- let view = new View( action,method,id,params );
-
- Notice.removeAllNotices();
-
- $('.or-dialog-content .or-view').html(''); // Clear old content
-
- $('.or-dialog-content .or-act-dialog-name').html( name );
- this.show();
-
- view.onCloseHandler.add( function() {
- dialog.close();
- } );
-
- view.onChangeHandler.add( function() {
- // data has changed
- console.debug("Changes detected");
- dialog.isDirty = true;
- // Remove dirty-flag from view
- dialog.element.addClass('view--is-dirty');
- });
-
- view.onSaveHandler.add( function() {
- // data was saved
- dialog.isDirty = false;
- // Remove dirty-flag from view
- dialog.element.removeClass('view--is-dirty');
- });
-
- this.view = view;
-
- return this.view.start( this.element );
- }
-
-
-
- show() {
-
- $('.or-dialog').removeClass('dialog--is-closed').addClass('dialog--is-open');
-
- if ( this.isDirty ) {
- this.element.addClass('view--is-dirty');
- }
-
- let dialog = this;
-
- this.escapeKeyClosingHandler = function (e) {
- if (e.keyCode == 27) { // ESC keycode
- dialog.close();
-
- $(document).off('keyup'); // de-register.
- }
- };
-
- $(document).keyup(this.escapeKeyClosingHandler);
-
- // close dialog on click onto the blurred area.
- $('.or-dialog-filler,.or-act-dialog-close').off('click').click( function(e)
- {
- e.preventDefault();
- dialog.close();
- });
- }
-
-
- hide() {
- $('.or-dialog').removeClass('dialog--is-open').addClass('dialog--is-closed'); // Dialog schließen
- }
-
-
- /**
- * Closing the dialog.
- */
- close() {
-
- let dialog = this;
-
- if ( this.isDirty ) {
- // ask the user if we should close this dialog
- let exit = window.confirm( Workbench.language.UNSAVED_CHANGES_CONFIRM );
-
- if ( ! exit )
- return; // do not close the dialog
-
- let notice = new Notice();
- notice.msg = Workbench.language.REOPEN_CLOSED_DIALOG;
- notice.setStatus( 'warning' );
- notice.timeout = 120;
- notice.onClick.add( function() {
- dialog.show();
- notice.close();
- });
- notice.show();
- }
-
- // Remove dirty-flag from view
- $('.or-dialog-content .or-view.or-view--is-dirty').removeClass('view--is-dirty');
- this.hide();
- $(document).unbind('keyup',this.escapeKeyClosingHandler); // Cleanup ESC-Key-Listener
- }
-}
-/* Include script: view.js */
-/**
- * View.
- * A view is a part of the page. An Action is loaded into this view.
- *
- * @param action
- * @param method
- * @param id
- * @param params
- * @constructor
- */
-class View {
-
- constructor( action,method,id,params ) {
- this.action = action;
- this.method = method;
- this.id = id;
- this.params = params;
-
- this.onCloseHandler = new Callback();
-
- this.onChangeHandler = new Callback();
- this.onSaveHandler = new Callback();
- }
-
- before() {
-
- };
-
- /**
- * @param element
- * @returns {Promise}
- */
- start( element ) {
-
- this.before();
- this.element = element;
- return this.loadView();
- }
-
- afterLoad() {
-
- }
-
- close() {
-
- this.onCloseHandler.fire();
- }
-
-
- fireViewLoadedEvents(element) {
-
- Workbench.afterViewLoadedHandler.fire( element );
- }
-
-
- /**
- * Loads the content of this view
- * @returns Promise
- */
- loadView() {
-
- let url = View.createUrl( this.action,this.method,this.id,this.params,false); // URL für das Laden erzeugen.
- let element = this.element;
- let view = this;
-
- let loadViewHtmlPromise = fetch( url,{} );
-
- $(this.element).addClass('loader');
- console.debug( view);
-
- loadViewHtmlPromise.then( response => {
- if ( ! response.ok )
- throw "failed to load the view";
- return response.text();
- } ).then( data => {
-
- if ( ! data )
- data = '';
-
- $(element).html(data);
-
- $(element).find('form').each( function() {
-
- let form = new Form();
-
- form.onChangeHandler.add( () => { view.onChangeHandler.fire() } );
- form.onSaveHandler .add( () => { view.onSaveHandler .fire() } );
- form.onCloseHandler .add( () => { view.close() } );
-
- form.forwardTo = function (action, subaction, id, data) {
- view.action = action;
- view.method = subaction;
- view.id = id;
- view.params = data;
- view.loadView();
- }
-
- form.initOnElement(this);
- });
-
- view.fireViewLoadedEvents( element );
- } ).catch( cause => {
- $(element).html("");
-
- console.error( {view:view, url:url, cause: cause} );
-
- let notice = new Notice();
- notice.setStatus('error');
- notice.msg = Workbench.language.ERROR;
- notice.log = cause;
- notice.show();
- });
-
- loadViewHtmlPromise.finally( () => {
- $(element).removeClass("loader");
- });
-
- return loadViewHtmlPromise;
- }
-
-
-
-
- /**
- * Erzeugt eine URL, um die gewünschte Action vom Server zu laden.
- *
- * @param action
- * @param subaction
- * @param id
- * @param extraid
- * @param api
- * @returns URL
- */
- static createUrl(action,subaction,id,extraid={},api=false )
- {
- let url = './';
-
- if ( api )
- url += 'api/';
-
- url += '?';
-
- if(action)
- url += '&action='+action;
- if(subaction)
- url += '&subaction='+subaction;
- if(id)
- url += '&id='+id;
-
- if ( extraid instanceof FormData ) {
- for (let pair of extraid.entries()) {
- // value is already encoded.
- // this does not support multiple values.
- url += '&' + pair[0] + '=' + pair[1];
- }
- }
- else if ( extraid instanceof Object ) {
-
- Object.keys(extraid).forEach( (key) => {
- url += '&' + key + '=' + extraid[key];
- });
- }
- else
- throw "Illegal argument";
-
- if ( api )
- url += '&output=json';
-
- return url;
- }
-
-
-}
-
-/* Include script: form.js */
-/**
- * Form.
- *
- * @constructor
- */
-class Form {
-
- static modes = {
- showBrowserNotice : 1,
- keepOpen : 2,
- closeAfterSubmit : 4,
- closeAfterSuccess : 8,
- };
-
- constructor() {
-
-
- /**
- * Fires on input.
- */
- this.onChangeHandler = new Callback();
- this.onSaveHandler = new Callback();
- this.onCloseHandler = new Callback();
- }
-
- setLoadStatus( isLoading ) {
- $(this.element).closest('div.content').toggleClass('loader',isLoading);
- }
-
- initOnElement( element ) {
- this.element = element;
-
- let form = this;
-
- // Autosave in Formularen.
- // Bei Veränderungen von Checkboxen wird das Formular sofort abgeschickt.
- if ( $(this.element).data('autosave') ) {
-
- $(this.element).find('input[type="checkbox"]').click( function() {
- form.submit(Form.modes.keepOpen);
- });
- $(this.element).find('select').change( function() {
- form.submit(Form.modes.keepOpen);
- });
- }
-
- // After click to "OK" the form is submitted.
- // Why this?? input type=submit will submit!
- /*
- $(event.target).find('input.submit.ok').click( function() {
- $(this).closest('form').submit();
- });
- */
-
- $(element).find('.or-act-form-cancel').click( function() {
- form.cancel();
-
- });
- $(element).find('.or-act-form-reset').click( function() {
- form.rollback();
-
- });
- $(element).find('.or-act-form-apply').click( function() {
- form.submit(Form.modes.keepOpen);
- });
- $(element).find('.or-act-form-save').click( function() {
- form.submit();
- });
-
- // Bei Änderungen in der View das Tab als 'dirty' markieren
- $(element).find('.or-input').change( function() {
- form.onChangeHandler.fire();
- });
-
-
- // Submithandler for the whole form.
- $(element).submit( function( event ) {
-
- //
- if ($(this).data('target')=='view')
- {
- form.submit();
- event.preventDefault();
- }
- // target=top will load the native way without javascript.
- });
- }
-
- cancel() {
- //$(this.element).html('').parent().removeClass('is-open');
- Notice.removeAllNotices();
-
- this.onCloseHandler.fire();
- }
-
-
- rollback() {
- this.element.trigger('reset');
- }
-
- forwardTo(action, subaction, id, data) {
- }
-
- submit( mode ) {
-
- if ( mode === undefined )
- if ( $(this.element).data('async') )
- mode = Form.modes.closeAfterSubmit;
- else
- mode = Form.modes.closeAfterSuccess;
-
- Notice.removeAllNotices();
-
- // Show progress
- let status = new Notice();
- status.setStatus('info');
- status.inProgress();
- status.msg = Workbench.language.PROGRESS;
- status.show();
-
- // Alle vorhandenen Error-Marker entfernen.
- // Falls wieder ein Fehler auftritt, werden diese erneut gesetzt.
- $(this.element).find('.or-input--error').removeClass('input--error');
-
- let formData = new FormData( $(this.element).get(0) );
-
- // If form does not contain action/id, get it from the workbench.
- if (!formData.has('id') )
- formData.append('id',Workbench.state.id);
- if (!formData.has('action') )
- formData.append('action',Workbench.state.action);
-
- let formMethod = $(this.element).attr('method').toUpperCase();
-
- if ( formMethod == 'GET' )
- {
- // Mehrseitiges Formular
- // Die eingegebenen Formulardaten werden zur nächsten Action geschickt.
- this.forwardTo( formData.get('action'), formData.get('subaction'),formData.get('id,'),formData );
- $(status).remove();
- }
- else
- {
- let url = './api/'; // Alle Parameter befinden sich im Formular
-
- // POST-Request
- this.setLoadStatus(true);
- //url += '?output=json';
- url += '';
- //params['output'] = 'json';// Irgendwie geht das nicht.
- formData.append('output','json');
-
- if ( mode == Form.modes.closeAfterSubmit )
- this.onCloseHandler.fire();
- // Async: Window is closed, but the action will be startet now.
-
- let form = this;
- console.debug( form );
-
- let load = fetch( url, { 'method':'POST', body:formData } );
-
- load.then( response => {
- if ( ! response.ok )
- throw "Failed to post";
-
- return response.json();
- }).then( data => {
- form.setLoadStatus(false);
- status.close();
-
- form.doResponse(data, "", form.element, () => {
-
- form.onSaveHandler.fire();
-
- let afterSuccess = $(form.element).data('afterSuccess');
- let forwardTo = $(form.element).data('forwardTo');
- let async = $(form.element).data('async');
-
- if (afterSuccess == 'forward')
- mode = Form.modes.keepOpen;
-
- // The data was successful saved.
- // Now we can close the form.
- if (mode == Form.modes.closeAfterSuccess) {
- form.onCloseHandler.fire();
-
- // clear the dirty flag.
- $(form.element).closest('div.panel').find('div.header ul.views li.action.active').removeClass('dirty');
- }
-
- if (afterSuccess) {
- if (afterSuccess == 'reloadAll') {
- Openrat.workbench.reloadAll();
- } else if (afterSuccess == 'forward') {
- // Forwarding to next subaction.
- if (forwardTo)
- form.forwardTo(formData.get('action'), forwardTo, formData.get('id'), []);
- }
- } else {
- if (async)
- ; // do not reload
- else
- Openrat.workbench.reloadViews();
- }
-
- })
- } ).catch( cause => {
-
- console.warn( {
- message:'could not post form',
- cause: cause,
- form:form,
- } );
-
- form.setLoadStatus(false);
- status.close();
-
- let msg = '';
- try {
- msg = JSON.parse( cause ).message;
- }
- catch( e ) {
- msg = cause;
- }
-
- let notice = new Notice();
- notice.setStatus('error');
- notice.msg = msg;
- notice.log = cause; //JSON.stringify( $.parseJSON(jqXHR.responseText),null,2);
- notice.show();
- } );
-
- $(form.element).fadeIn();
- }
-
- }
-
-
-
- /**
- * HTTP-Antwort auf einen POST-Request auswerten.
- *
- * @param data Formulardaten
- * @param status Status
- * @param element
- */
- doResponse = function(data,status,element, onSuccess = $.noop )
- {
- let form = this;
- // Hinweismeldungen in Statuszeile anzeigen
- for( let value of data['notices'] ) {
-
- // Bei asynchronen Requests wird zusätzlich eine Browser-Notice erzeugt, da der
- // Benutzer bei länger laufenden Aktionen vielleicht das Tab oder Fenster
- // gewechselt hat.
- let notifyBrowser = $(element).data('async');
-
- let notice = new Notice();
- notice.setContext( value.type, value.id, value.name );
- notice.log = value.log;
- notice.setStatus( value.status );
- notice.msg = value.text;
- notice.show();
-
- if ( notifyBrowser )
- notice.notifyBrowser()
- };
-
- if ( data.success ) { // Kein Fehler?
- onSuccess();
- Workbench.dataChangedHandler.fire();
- }
- else
- ; // Server liefert Fehler zurück.
-
- // Validation error should mark the input field.
- for( name of data['errors'] )
- $('.or-input[name='+name+']').addClass('input--error').parent().addClass('input--error').parents('.or-group').removeClass('closed').addClass('show').addClass('open');
-
- // Jetzt das erhaltene Dokument auswerten.
- }
-
-
-
-}
-
-
-/* Include script: workbench.js */
-
-
-class Workbench {
- 'use strict'; // Strict mode
-
- static state = {
- action: '',
- id: 0,
- extra: {}
- };
-
- constructor() {
-
- this.popupWindow = null;
- Workbench.dataChangedHandler.add( function() {
- if ( Workbench.popupWindow )
- Workbench.popupWindow.location.reload();
- } );
- }
-
-
- /**
- * Initializes the Workbench.
- */
- initialize() {
-
- // Initialze Ping timer.
- this.initializePingTimer();
- this.initializeDirtyWarning();
- this.initializeState();
- this.openModalDialog();
-
- Workbench.registerOpenClose( $('.or-collapsible') );
- console.info('Application started');
- }
-
-
- initializeDirtyWarning() {
-
- // If the application should be closed, inform the user about unsaved changes.
- window.addEventListener('beforeunload', function (e) {
-
- // Are there views in the dirty state?
- if ( $('.or-view--is-dirty').length > 0 ) {
-
- e.preventDefault(); // Cancel the event
-
- // This text is replaced by modern browsers with a common message.
- return 'Unsaved content will be lost.';
- }
- else {
- // Let the browser quitting the page.
- // Do NOT logout here, because there could be other windows/tabs with the same session.
- return undefined; // nothing to do.
- }
- });
- }
-
- /**
- * Starts a dialog, if necessary.
- */
- openModalDialog() {
-
- if ( $('#dialog').data('action') ) {
- let dialog = new Dialog();
- dialog.start('',$('#dialog').data('action'),$('#dialog').data('action'),0,{} )
- }
- }
-
-
- /**
- * Sets the workbench state with action/id.
- *
- * Example: #/name/1 is translated to the state {action:name,id:1}
- */
- initializeState() {
-
- let parts = window.location.hash.split('/');
- let state = { action:'index',id:0 };
-
- if ( parts.length >= 2 )
- state.action = parts[1].toLowerCase();
-
- if ( parts.length >= 3 )
- // Only numbers and '_' allowed in the id.
- state.id = parts[2].replace(/[^0-9_]/gim,"");
-
- Workbench.state = state;
-
- Openrat.navigator.toActualHistory( state );
-
- }
-
- /**
- * Registriert den Ping-Timer für den Sitzungserhalt.
- */
- initializePingTimer() {
-
- /**
- * Ping den Server. Führt keine Aktion aus, aber sorgt dafür, dass die Sitzung erhalten bleibt.
- *
- * "Geben Sie mir ein Ping, Vasily. Und bitte nur ein einziges Ping!" (aus: Jagd auf Roter Oktober)
- */
- let ping = () => {
- let url = View.createUrl('profile','ping',0, {}, true);
- let pingPromise = fetch( url );
- console.debug('ping');
-
- pingPromise
- .then( response => {
- if ( !response.ok )
- throw "ping failed" } )
- .catch( cause => {
- // oO, what has happened? There is no session with a logged in user, or the server has gone.
- console.warn( {message: 'The server ping has failed.',cause:cause });
-
- // Is there any user input? Ok, we should warn the user that the data could not be saved.
- if ($('.or-view--is-dirty').length > 0) {
- window.alert("The server session is lost, please save your data.");
- }
- else {
- // no input data, so lets reload all views?
- // no, maybe an anonymous user is looking around.
- //Openrat.reloadAll();
- }
- } );
- }
-
- // Alle 5 Minuten pingen.
- let timeoutMinutes = 5;
-
- window.setInterval( ping, timeoutMinutes*60*1000 );
- }
-
-
-
- loadNewActionState(state) {
-
- Workbench.state = state;
- this.loadNewAction(state.action,state.id,state.data);
-
- Workbench.afterNewActionHandler.fire();
- }
-
-
- static afterNewActionHandler = new Callback();
- static afterAllViewsLoaded = new Callback();
-
-
- /**
- *
- */
-
- loadNewAction = function(action, id, params ) {
-
- this.reloadViews();
- }
-
-
-
- /**
- *
- */
-
- reloadViews() {
-
- // View in geschlossenen Sektionen löschen, damit diese nicht stehen bleiben.
- $('.or-workbench-section--is-closed .or-act-view-loader').empty();
-
- let promise = this.loadViews( $('.or-workbench .or-act-view-loader') );
- promise.done( function() {
- Workbench.afterAllViewsLoaded.fire();
- }
- );
-
- return promise;
- }
-
-
- reloadAll() {
-
- // View in geschlossenen Sektionen löschen, damit diese nicht stehen bleiben.
- let promise = this.loadViews( $('.or-act-view-loader,.or-act-view-static').empty() );
- console.debug('reloading all views');
-
- promise.done( function() {
- Workbench.afterAllViewsLoaded.fire();
- }
- );
-
- this.loadUserStyle();
- this.loadLanguage();
- this.loadUISettings();
-
- return promise;
- }
-
-
- loadUserStyle() {
-
- let url = View.createUrl('profile','userinfo',0, {},true );
-
- let load = fetch( url );
- load
- .then( response => response.json() )
- .then( response => {
-
- let style = response.output['style'];
- this.setUserStyle(style);
-
- let color = response.output['theme-color'];
- this.setThemeColor(color);
- });
- }
-
-
-
- static settings = {};
- static language = {};
-
- loadLanguage() {
-
- let url = View.createUrl('profile','language',0, {},true );
-
- let load = fetch( url );
- load
- .then( response => response.json() )
- .then( response => {
- Workbench.language = response.output.language;
- });
- }
-
- /**
- * load UI settings from the server.
- */
- loadUISettings() {
-
- let url = View.createUrl('profile','uisettings',0, {},true );
-
- let load = fetch( url );
- load
- .then( response => response.json() )
- .then( response => {
- Workbench.settings = response.output.settings.settings;
- });
- }
-
-
- /**
- *
- * @param $views
- * @returns Promise for all views
- */
- loadViews( $views )
- {
- let wb = this;
- let promises = [];
- $views.each(function (idx) {
-
- let $targetDOMElement = $(this);
-
- promises.push( wb.loadNewActionIntoElement( $targetDOMElement ) );
- });
-
- return $.when.apply( $, promises );
- }
-
-
- /**
- * @param $viewElement
- * @returns {Promise}
- */
- loadNewActionIntoElement( $viewElement )
- {
- let action;
- if ( $viewElement.is('.or-act-view-static') )
- // Static views have always the same action.
- action = $viewElement.attr('data-action');
- else
- action = Workbench.state.action;
-
- let id = Workbench.state.id;
- let params = Workbench.state.extra;
-
- let method = $viewElement.data('method');
-
- let view = new View( action,method,id,params );
- return view.start( $viewElement );
- }
-
-
-
-
- /**
- * Sets a new theme.
- * @param styleName
- */
- setUserStyle( styleName )
- {
- var html = $('html');
- var classList = html.attr('class').split(/\s+/);
- $.each(classList, function(index, item) {
- if (item.startsWith('or-theme-')) {
- html.removeClass(item.substring(3));
- }
- });
- html.addClass( 'theme-' + styleName.toLowerCase() );
- }
-
-
- /**
- * Sets a new theme color.
- * @param color Theme-color
- */
- setThemeColor( color )
- {
- document.getElementById('theme-color').setAttribute('content',color);
- }
-
-
-
- static dataChangedHandler = new Callback();
- static afterViewLoadedHandler = new Callback();
-
-
-
- /**
- * Sets the application title.
- */
- static setApplicationTitle( newTitle ) {
-
- let title = document.querySelector('head > title');
- let defaultTitle = title.dataset.default;
-
- title.textContent = (newTitle ? newTitle + ' - ' : '') + defaultTitle;
- }
-
-
-
-
- /**
- * open and close groups.
- *
- * @param $el
- */
- static registerOpenClose = function( $el )
- {
- $($el).children('.or-collapsible-act-switch').click( function() {
- $(this).closest('.or-collapsible').toggleClass('collapsible--is-open').toggleClass('collapsible--is-closed');
- });
- }
-
-
-
- /**
- * Setzt neue Action und aktualisiert alle Fenster.
- *
- * @param action Action
- * @param id Id
- */
- openNewAction( name,action,id )
- {
- // Im Mobilmodus soll das Menü verschwinden, wenn eine neue Action geoeffnet wird.
- $('.or-workbench-navigation').removeClass('workbench-navigation--is-open');
-
- Workbench.setApplicationTitle( name ); // Sets the title.
-
- Openrat.navigator.navigateToNew( {'action':action, 'id':id } );
- }
-
-
-
-
-
-
-
-
- registerDraggable(viewEl) {
-
-// Drag n Drop: Inhaltselemente (Dateien,Seiten,Ordner,Verknuepfungen) koennen auf Ordner gezogen werden.
-
- $(viewEl).find('.or-draggable').draggable(
- {
- helper: 'clone',
- opacity: 0.7,
- zIndex: 3,
- distance: 10,
- cursor: 'move',
- revert: 'false'
- }
- );
-
- }
-
-
- registerDroppable(viewEl) {
-
-
- $(viewEl).find('.or-droppable-selector').droppable({
- accept: '.or-draggable',
- hoverClass: 'droppable--hover',
- activeClass: 'droppable--active',
-
- drop: function (event, ui) {
-
- let dropped = ui.draggable;
- console.info('dropped:');
- console.info(dropped);
- let id = $(dropped).find('.or-link').data('id');
- let name = $(dropped).find('.or-navtree-text').text();
-
- if (!name)
- name = id;
-
- $(this).find('.or-selector-link-value').val( id );
- $(this).find('.or-selector-link-name' ).val( name ).attr('placeholder',name );
- }
- });
-
-/*
- $(viewEl).find('.or-droppable-navigation').droppable({
- accept: '.or-draggable',
- hoverClass: 'droppable--hover',
- activeClass: 'droppable--active',
-
- drop: function (event, ui) {
-
- let dropped = ui.draggable;
-
- let id = dropped.data('id' );
- let name = dropped.data('name');
- if (!name)
- name = id;
-
- alert('dropped');
- }
- });
-*/
- }
-
-
- static htmlDecode(input) {
- let doc = new DOMParser().parseFromString(input, "text/html");
- return doc.documentElement.textContent;
- }
-}
-
-
-/* Include script: navigator.js */
-/**
- * Navigation.
- */
-class WorkbenchNavigator {
- 'use strict';
-
- constructor( workbench ) {
- this.workbench = workbench;
- }
- /**
- * Navigiert zu einer Action.
- */
- navigateTo(state) {
-
- console.debug('Navigating to ',state);
- this.workbench.loadNewActionState(state);
- }
-
-
- /**
- *
- * Navigiert zu einer neue Action und fügt einen neuen History-Eintrag hinzu.
- */
- navigateToNew(obj) {
-
- this.navigateTo(obj);
-
- window.history.pushState(obj,obj.name,WorkbenchNavigator.createShortUrl(obj.action,obj.id) );
- }
-
- /**
- * Setzt den State für den aktuellen History-Eintrag.
- * @param obj
- */
- toActualHistory(obj) {
- window.history.replaceState(obj,obj.name,WorkbenchNavigator.createShortUrl(obj.action,obj.id) );
- }
-
-
-
- static createShortUrl(action,id) {
- return './#/'+action+(id?'/'+id:'');
- }
-}
-
-/* Include script: common.js */
-
-// Execute after DOM ready:
-document.addEventListener("DOMContentLoaded", event => {
- // JS is available.
- $('html').removeClass('nojs');
-
- /* Fade in all elements. */
- $('.or--initial-hidden').removeClass('-initial-hidden');
-
-
- /**
- * Registriert alle Events, die in der Workbench laufen sollen.
- */
- function registerWorkbenchEvents()
- {
-
- }
-
-
- registerWorkbenchEvents();
-
-
- // Listening to the "popstate" event:
- window.onpopstate = function (ev) {
- Openrat.navigator.navigateTo(ev.state);
- };
-
- Openrat.workbench.initialize();
- Openrat.workbench.reloadAll();
-
- let registerWorkbenchGlobalEvents = function() {
-
- // Binding aller Sondertasten.
- $('.keystroke').each( function() {
- let keystrokeElement = $(this);
- let keystroke = keystrokeElement.text();
- if (keystroke.length == 0)
- return; // No Keybinding.
- let keyaction = function() {
- keystrokeElement.click();
- };
- // Keybinding ausfuehren.
- $(document).bind('keydown', keystroke, keyaction );
- } );
-
- }
-
- // Initial Notices
- $('.or-act-initial-notice').each( function() {
-
- let notice = new Notice();
- notice.setStatus('info');
- notice.msg = $(this).text();
- notice.show();
-
- $(this).remove();
- });
-
- registerWorkbenchGlobalEvents();
-
-
- let closeMenu = function() {
- // Mit der Maus irgendwo hin geklickt, das Menü muss schließen.
- $('body').click( function() {
- //$('.toolbar-icon.or-menu-category').parents('.or-menu').removeClass('menu--is-open');
- $('.or-menu').removeClass('menu--is-open');
- });
- };
- closeMenu();
-
- let closeMobileNavigation = function() {
- // Mobile navigation must close on a click on the workbench
- $('.or-act-navigation-close').click( function() {
- $('.or-workbench-navigation').removeClass('workbench-navigation--is-open');
- $('.or-workbench').removeClass('workbench--navigation-is-open');
- });
- };
- closeMobileNavigation();
-
- let closeDesktopNavigation = function() {
-
- // Handler for desktop navigation
- $('.or-workbench-title .or-act-nav-small').click(function () {
- $('.or-workbench').addClass('workbench--navigation-is-small');
- $('.or-workbench-navigation').addClass('workbench-navigation--is-small');
- });
- };
- closeDesktopNavigation();
-
-
- let registerGlobalSearch = function() {
- $('.or-search-input .or-input').orSearch( {
- onSearchActive: function() {
- $('.or-search').addClass('search--is-active');
- },
- onSearchInactive: function() {
- $('.or-search').removeClass('search--is-active');
- },
- dropdown : '.or-act-search-result',
- resultEntryClass: 'or-search-result-entry',
- //openDropdown: true, // the dropdown is automatically opened by the menu.
- select : function(obj) {
- // open the search result
- Workbench.openNewAction( obj.name, obj.action, obj.id );
- },
- afterSelect: function() {
- //$('.or-dropdown.or-act-selector-search-results').empty();
- }
- } );
- $('.or-search .or-act-search-delete').click( function() {
- $('.or-search .or-title-input').val('').change();
- } );
- };
- registerGlobalSearch();
-
-
- Workbench.afterNewActionHandler.add( function() {
-
- $('.or-sidebar').find('.or-sidebar-button').orLinkify();
- }
- );
-
- Workbench.afterNewActionHandler.add( function() {
-
- let url = View.createUrl('tree','path',Workbench.state.id, {'type':Workbench.state.action} );
-
- // Die Inhalte des Zweiges laden.
- let loadPromise = fetch( url );
-
- /**
- * open a object in the navigation tree.
- * @param action
- * @param id
- */
- function openNavTree(action, id) {
- let $navControl = $('.or-link[data-action='+action+'][data-id='+id+']').closest('.or-navtree-node');
- if ( $navControl.is( '.or-navtree-node--is-closed' ) )
- $navControl.find('.or-navtree-node-control').click();
- }
-
- loadPromise
- .then( response => response.text() )
- .then( data => {
-
- $('.or-breadcrumb').empty().append( data ).find('.or-act-clickable').orLinkify();
-
- // Open the path in the navigator tree
- $('.or-breadcrumb a').each( function () {
- let action = $(this).data('action');
- let id = $(this).data('id' );
-
- openNavTree( action, id );
- });
-
- $('.or-link--is-active').removeClass('link--is-active');
-
- let action = Workbench.state.action;
- let id = Workbench.state.id;
- if (!id) id = '0';
-
- // Mark the links to the actual object
- $('.or-link[data-action=\''+action+'\'][data-id=\''+id+'\']').addClass('link--is-active');
- // Open actual object
- openNavTree( action,id );
-
- }).catch( cause => {
- // Ups... aber was können wir hier schon tun, außer hässliche Meldungen anzeigen.
- console.warn( {
- message : 'Failed to load path',
- url : url,
- cause : cause } );
- }).finally(function () {
-
- });
- } );
-
- Workbench.afterNewActionHandler.fire();
-});
-
-
-
-
-let filterMenus = function ()
-{
- let action = Workbench.state.action;
- let id = Workbench.state.id;
- $('.or-workbench-title .or-dropdown-entry.or-act-clickable').addClass('dropdown-entry--active');
- $('.or-workbench-title .or-filtered').removeClass('dropdown-entry--active').addClass('dropdown-entry--inactive');
- // Jeder Menüeintrag bekommt die Id und Parameter.
- $('.or-workbench-title .or-filtered .or-link').attr('data-id' ,id );
-
- let url = View.createUrl('profile','available',id, {'queryaction':action},true );
-
- // Die Inhalte des Zweiges laden.
- let promise = fetch(url);
-
- promise.then( response => response.json() )
- .then( (data) => {
-
- for( let method of Object.values(data.output.views) )
- $('.or-workbench-title .or-filtered > .or-link[data-method=\'' + method + '\']' )
- .parent()
- .addClass('dropdown-entry--active')
- .removeClass('dropdown-entry--inactive');
- });
-
-
-}
-
-
-Workbench.afterAllViewsLoaded.add( function() {
- filterMenus();
-} );
-
-Workbench.afterAllViewsLoaded.add( function() {
- $('body').removeClass('loader');
-} );
-
-
-
-
-Workbench.afterViewLoadedHandler.add( function(element) {
- $(element).find('.or-button').orButton();
-} );
-
-Workbench.afterViewLoadedHandler.add( function(element) {
-
- // Refresh already opened popup windows.
- if ( Workbench.popupWindow )
- $(element).find("a[data-type='popup']").each( function() {
- Workbench.popupWindow.location.href = $(this).attr('data-url');
- });
-
-});
-
-
-Workbench.afterViewLoadedHandler.add( function(element) {
-
- $(element).find(".or-input--password").dblclick( function() {
- $(this).toggleAttr('type','text','password');
- });
-
- $(element).find(".or-act-make-visible").click( function() {
- $(this).toggleClass('btn--is-active' );
- $(this).parent().children('input').toggleAttr('type','text','password');
- });
-});
-
-
-
-Workbench.afterViewLoadedHandler.add( function($element) {
-
- $element.find('.or-act-load-nav-tree').each( function() {
-
- let type = $(this).data('type') || 'root';
- let loadBranchUrl = './?action=tree&subaction=branch&id=0&type='+type;
- let $targetElement = $(this);
-
- let load = fetch( loadBranchUrl );
- load
- .then( response => response.text() )
- .then( html => {
-
- // Den neuen Unter-Zweig erzeugen.
- let $ul = $('<ul class="or-navtree-list" />');
- $ul.appendTo( $targetElement.empty() ).append( html );
-
- $ul.find('li').orTree( {
- 'openAction': function( name,action,id) {
- Openrat.workbench.openNewAction( name,action,id );
- }
-
- } ); // All subnodes are getting event listener for open/close
-
- // Die Navigationspunkte sind anklickbar, hier wird der Standardmechanismus benutzt.
- $ul.find('.or-act-clickable').orLinkify();
-
- // Open the first node.
- $ul.find('.or-navtree-node-control').first().click();
- } );
-
- } );
-
-} );
-
-
-
-
-/**
- * Registriert alle Handler für den Inhalt einer View.
- *
- * @param viewEl DOM-Element der View
- */
-Workbench.afterViewLoadedHandler.add( function(viewEl ) {
-
- // Die Section deaktivieren, wenn die View keinen Inhalt hat.
- var section = $(viewEl).closest('section');
-
- //var viewHasContent = $(viewEl).children().length > 0;
- //section.toggleClass('disabled',!viewHasContent);
- section.toggleClass('is-empty',$(viewEl).is(':empty'));
-
- /*
- if ( ! $(viewEl).is(':empty') )
- section.slideDown('fast');
- else
- section.slideUp('fast');*/
-
- // Untermenüpunkte aus der View in das Fenstermenü kopieren...
- //$(viewEl).closest('div.panel').find('div.header div.dropdown div.entry.perview').remove(); // Alte Einträge löschen
-
- // Handler for mobile navigation
- $(viewEl).find('.or-act-nav-open-close').click( function() {
- $('.or-workbench').toggleClass('workbench--navigation-is-open');
- $('.or-workbench-navigation').toggleClass('workbench-navigation--is-open');
- });
-
- // Handler for desktop navigation
- $(viewEl).find('.or-act-nav-small').click( function() {
- $('.or-workbench').addClass('workbench--navigation-is-small');
- $('.or-workbench-navigation').addClass('workbench-navigation--is-small');
- });
- $(viewEl).find('.or-act-nav-wide').click( function() {
- $('.or-workbench').removeClass('workbench--navigation-is-small');
- $('.or-workbench-navigation').removeClass('workbench-navigation--is-small');
- });
-
-
- // Selectors (Einzel-Ausahl für Dateien) initialisieren
- // Wurzel des Baums laden
- $(viewEl).find('.or-act-selector-tree-button').click( function() {
-
- let $selector = $(this).parent('.or-selector');
- let $targetElement = $selector.find('.or-act-load-selector-tree');
-
- if ( $selector.hasClass('selector--is-tree-active') ) {
- $selector.removeClass('selector--is-tree-active');
- $targetElement.empty();
- }
- else {
- $selector.addClass('selector--is-tree-active');
-
- var selectorEl = this;
- /*
- $(this).orTree( { type:'project',selectable:$(selectorEl).attr('data-types').split(','),id:$(selectorEl).attr('data-init-folderid'),onSelect:function(name,type,id) {
-
- var selector = $(selectorEl).parent();
-
- //console.log( 'Selected: '+name+" #"+id );
- $(selector).find('input[type=text]' ).attr( 'value',name );
- $(selector).find('input[type=hidden]').attr( 'value',id );
- } });
- */
-
- let id = $(this).data('init-folder-id');
- let type = id?'folder':'projects';
- let loadBranchUrl = './?action=tree&subaction=branch&id='+id+'&type='+type;
-
- let load = fetch( loadBranchUrl );
- load
- .then( response => response.text() )
- .then( html => {
-
- // Den neuen Unter-Zweig erzeugen.
- let $ul = $('<ul class="or-navtree-list" />');
- $ul.appendTo( $targetElement ).append( html );
-
- $ul.find('li').orTree(
- {
- 'openAction' : function(name,action,id) {
- $selector.find('.or-selector-link-value').val(id );
- $selector.find('.or-selector-link-name' ).val('').attr('placeholder',name);
-
- $selector.removeClass('selector--is-tree-active');
- $targetElement.empty();
- }
- }
- ); // All subnodes are getting event listener for open/close
-
- // Die Navigationspunkte sind anklickbar, hier wird der Standardmechanismus benutzt.
- $ul.find('.or-act-clickable').orLinkify();
-
- // Open the first node.
- $ul.find('.or-navtree-node-control').first().click();
- } );
- }
-
- } );
-
-
- registerDragAndDrop(viewEl);
-
-
- // Theme-Auswahl mit Preview
- $(viewEl).find('.or-theme-chooser').change( function() {
- Openrat.workbench.setUserStyle( this.value );
- });
-
-
-
-
- function registerMenuEvents($element )
- {
- // Mit der Maus geklicktes Menü aktivieren.
- $($element).find('.or-menu-category').click( function(event) {
- event.stopPropagation();
- $(this).parents('.or-menu').toggleClass('menu--is-open');
- });
-
- // Mit der Maus überstrichenes Menü aktivieren.
- $($element).find('.or-menu-category').mouseover( function() {
-
- // close other menus.
- $(this).parents('.or-menu').find('.or-menu-category').removeClass('menu-category--is-open');
- // open the mouse-overed menu.
- $(this).addClass('menu-category--is-open');
- });
-
- }
-
-
- function registerSelectorSearch( $element )
- {
- $($element).find('.or-act-selector-search').orSearch( {
- onSearchActive: function() {
- $(this).parent('or-selector').addClass('selector-search--is-active');
- },
- onSearchInactive: function() {
- $(this).parent('or-selector').removeClass('selector-search--is-active' );
- },
-
- dropdown: '.or-act-selector-search-results',
- resultEntryClass: 'or-search-result-entry',
-
- select: function(obj) {
- $($element).find('.or-selector-link-value').val(obj.id );
- $($element).find('.or-selector-link-name' ).val(obj.name).attr('placeholder',obj.name);
- },
-
- afterSelect: function() {
- $('.or-dropdown.or-act-selector-search-results').empty();
- }
- } );
- }
-
-
-
- function registerTree(element) {
-
- // Klick-Funktionen zum Öffnen/Schließen des Zweiges.
- //$(element).find('.or-navtree-node').orTree();
-
- }
-
-
- registerMenuEvents ( viewEl );
- //registerGlobalSearch ( viewEl );
- registerSelectorSearch( viewEl );
- registerTree ( viewEl );
-
- function registerDragAndDrop(viewEl)
- {
-
- Openrat.workbench.registerDraggable(viewEl);
- Openrat.workbench.registerDroppable(viewEl);
- }
-
- registerDragAndDrop(viewEl);
-
-
-} );
-
-
-/* Include script: init.js */
-
-// Create own namespace.
-
-let workbench = new Workbench();
-window.Openrat = {
- workbench: workbench,
- navigator: new WorkbenchNavigator(workbench)
-};
-
-let originalAddClass = jQuery.fn.addClass;
-jQuery.fn.addClass = function (styleClass) {
- return originalAddClass.call(this,'or-'+styleClass);
-}
-
-let originalRemoveClass = jQuery.fn.removeClass;
-jQuery.fn.removeClass = function (styleClass) {
- return originalRemoveClass.call(this,'or-'+styleClass);
-}
-
-let originalHasClass = jQuery.fn.hasClass;
-jQuery.fn.hasClass = function (styleClass) {
- return originalHasClass.call(this,'or-'+styleClass);
-}
-
/* Include script: column.js */
// View loaded...
Workbench.afterViewLoadedHandler.add( function(element ) {
diff --git a/modules/cms/ui/themes/default/script/openrat.min.js b/modules/cms/ui/themes/default/script/openrat.min.js
@@ -1171,25 +1171,6 @@ header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\
}(navigator.userAgent||navigator.vendor||window.opera),e},V="",K={bold:{name:"bold",action:c,className:"fa fa-bold",title:"Bold","default":!0},italic:{name:"italic",action:u,className:"fa fa-italic",title:"Italic","default":!0},strikethrough:{name:"strikethrough",action:f,className:"fa fa-strikethrough",title:"Strikethrough"},heading:{name:"heading",action:p,className:"fa fa-header",title:"Heading","default":!0},"heading-smaller":{name:"heading-smaller",action:p,className:"fa fa-header fa-header-x fa-header-smaller",title:"Smaller Heading"},"heading-bigger":{name:"heading-bigger",action:m,className:"fa fa-header fa-header-x fa-header-bigger",title:"Bigger Heading"},"heading-1":{name:"heading-1",action:g,className:"fa fa-header fa-header-x fa-header-1",title:"Big Heading"},"heading-2":{name:"heading-2",action:v,className:"fa fa-header fa-header-x fa-header-2",title:"Medium Heading"},"heading-3":{name:"heading-3",action:y,className:"fa fa-header fa-header-x fa-header-3",title:"Small Heading"},"separator-1":{name:"separator-1"},code:{name:"code",action:h,className:"fa fa-code",title:"Code"},quote:{name:"quote",action:d,className:"fa fa-quote-left",title:"Quote","default":!0},"unordered-list":{name:"unordered-list",action:x,className:"fa fa-list-ul",title:"Generic List","default":!0},"ordered-list":{name:"ordered-list",action:b,className:"fa fa-list-ol",title:"Numbered List","default":!0},"clean-block":{name:"clean-block",action:w,className:"fa fa-eraser fa-clean-block",title:"Clean block"},"separator-2":{name:"separator-2"},link:{name:"link",action:k,className:"fa fa-link",title:"Create Link","default":!0},image:{name:"image",action:S,className:"fa fa-picture-o",title:"Insert Image","default":!0},table:{name:"table",action:C,className:"fa fa-table",title:"Insert Table"},"horizontal-rule":{name:"horizontal-rule",action:L,className:"fa fa-minus",title:"Insert Horizontal Line"},"separator-3":{name:"separator-3"},preview:{name:"preview",action:A,className:"fa fa-eye no-disable",title:"Toggle Preview","default":!0},"side-by-side":{name:"side-by-side",action:N,className:"fa fa-columns no-disable no-mobile",title:"Toggle Side by Side","default":!0},fullscreen:{name:"fullscreen",action:s,className:"fa fa-arrows-alt no-disable no-mobile",title:"Toggle Fullscreen","default":!0},"separator-4":{name:"separator-4"},guide:{name:"guide",action:"https://simplemde.com/markdown-guide",className:"fa fa-question-circle",title:"Markdown Guide","default":!0},"separator-5":{name:"separator-5"},undo:{name:"undo",action:T,className:"fa fa-undo no-disable",title:"Undo"},redo:{name:"redo",action:M,className:"fa fa-repeat no-disable",title:"Redo"}},X={link:["[","](#url#)"],image:[""],table:["","\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],horizontalRule:["","\n\n-----\n\n"]},Z={link:"URL for the link:",image:"URL of the image:"},J={bold:"**",code:"```",italic:"*"};B.prototype.markdown=function(e){if(j){var t={};return this.options&&this.options.renderingConfig&&this.options.renderingConfig.singleLineBreaks===!1?t.breaks=!1:t.breaks=!0,this.options&&this.options.renderingConfig&&this.options.renderingConfig.codeSyntaxHighlighting===!0&&window.hljs&&(t.highlight=function(e){return window.hljs.highlightAuto(e).value}),j.setOptions(t),j(e)}},B.prototype.render=function(e){if(e||(e=this.element||document.getElementsByTagName("textarea")[0]),!this._rendered||this._rendered!==e){this.element=e;var t=this.options,n=this,i={};for(var o in t.shortcuts)null!==t.shortcuts[o]&&null!==q[o]&&!function(e){i[r(t.shortcuts[e])]=function(){q[e](n)}}(o);i.Enter="newlineAndIndentContinueMarkdownList",i.Tab="tabAndIndentMarkdownList",i["Shift-Tab"]="shiftTabAndUnindentMarkdownList",i.Esc=function(e){e.getOption("fullScreen")&&s(n)},document.addEventListener("keydown",function(e){e=e||window.event,27==e.keyCode&&n.codemirror.getOption("fullScreen")&&s(n)},!1);var a,l;if(t.spellChecker!==!1?(a="spell-checker",l=t.parsingConfig,l.name="gfm",l.gitHubSpice=!1,z({codeMirrorInstance:F})):(a=t.parsingConfig,a.name="gfm",a.gitHubSpice=!1),this.codemirror=F.fromTextArea(e,{mode:a,backdrop:l,theme:"paper",tabSize:void 0!=t.tabSize?t.tabSize:2,indentUnit:void 0!=t.tabSize?t.tabSize:2,indentWithTabs:t.indentWithTabs!==!1,lineNumbers:!1,autofocus:t.autofocus===!0,extraKeys:i,lineWrapping:t.lineWrapping!==!1,allowDropFileTypes:["text/plain"],placeholder:t.placeholder||e.getAttribute("placeholder")||"",styleSelectedText:void 0!=t.styleSelectedText?t.styleSelectedText:!0}),t.forceSync===!0){var c=this.codemirror;c.on("change",function(){c.save()})}this.gui={},t.toolbar!==!1&&(this.gui.toolbar=this.createToolbar()),t.status!==!1&&(this.gui.statusbar=this.createStatusbar()),void 0!=t.autosave&&t.autosave.enabled===!0&&this.autosave(),this.gui.sideBySide=this.createSideBySide(),this._rendered=this.element;var u=this.codemirror;setTimeout(function(){u.refresh()}.bind(u),0)}},B.prototype.autosave=function(){if(_()){var e=this;if(void 0==this.options.autosave.uniqueId||""==this.options.autosave.uniqueId)return void console.log("SimpleMDE: You must set a uniqueId to use the autosave feature");null!=e.element.form&&void 0!=e.element.form&&e.element.form.addEventListener("submit",function(){localStorage.removeItem("smde_"+e.options.autosave.uniqueId)}),this.options.autosave.loaded!==!0&&("string"==typeof localStorage.getItem("smde_"+this.options.autosave.uniqueId)&&""!=localStorage.getItem("smde_"+this.options.autosave.uniqueId)&&(this.codemirror.setValue(localStorage.getItem("smde_"+this.options.autosave.uniqueId)),this.options.autosave.foundSavedValue=!0),this.options.autosave.loaded=!0),localStorage.setItem("smde_"+this.options.autosave.uniqueId,e.value());var t=document.getElementById("autosaved");if(null!=t&&void 0!=t&&""!=t){var n=new Date,r=n.getHours(),i=n.getMinutes(),o="am",a=r;a>=12&&(a=r-12,o="pm"),0==a&&(a=12),i=10>i?"0"+i:i,t.innerHTML="Autosaved: "+a+":"+i+" "+o}this.autosaveTimeoutId=setTimeout(function(){e.autosave()},this.options.autosave.delay||1e4)}else console.log("SimpleMDE: localStorage not available, cannot autosave")},B.prototype.clearAutosavedValue=function(){if(_()){if(void 0==this.options.autosave||void 0==this.options.autosave.uniqueId||""==this.options.autosave.uniqueId)return void console.log("SimpleMDE: You must set a uniqueId to clear the autosave value");localStorage.removeItem("smde_"+this.options.autosave.uniqueId)}else console.log("SimpleMDE: localStorage not available, cannot autosave")},B.prototype.createSideBySide=function(){var e=this.codemirror,t=e.getWrapperElement(),n=t.nextSibling;n&&/editor-preview-side/.test(n.className)||(n=document.createElement("div"),n.className="editor-preview-side",t.parentNode.insertBefore(n,t.nextSibling));var r=!1,i=!1;return e.on("scroll",function(e){if(r)return void(r=!1);i=!0;var t=e.getScrollInfo().height-e.getScrollInfo().clientHeight,o=parseFloat(e.getScrollInfo().top)/t,a=(n.scrollHeight-n.clientHeight)*o;n.scrollTop=a}),n.onscroll=function(){if(i)return void(i=!1);r=!0;var t=n.scrollHeight-n.clientHeight,o=parseFloat(n.scrollTop)/t,a=(e.getScrollInfo().height-e.getScrollInfo().clientHeight)*o;e.scrollTo(0,a)},n},B.prototype.createToolbar=function(e){if(e=e||this.options.toolbar,e&&0!==e.length){var t;for(t=0;t<e.length;t++)void 0!=K[e[t]]&&(e[t]=K[e[t]]);var n=document.createElement("div");n.className="editor-toolbar";var r=this,a={};for(r.toolbar=e,t=0;t<e.length;t++)if(("guide"!=e[t].name||r.options.toolbarGuideIcon!==!1)&&!(r.options.hideIcons&&-1!=r.options.hideIcons.indexOf(e[t].name)||("fullscreen"==e[t].name||"side-by-side"==e[t].name)&&$())){if("|"===e[t]){for(var s=!1,c=t+1;c<e.length;c++)"|"===e[c]||r.options.hideIcons&&-1!=r.options.hideIcons.indexOf(e[c].name)||(s=!0);if(!s)continue}!function(e){var t;t="|"===e?o():i(e,r.options.toolbarTips,r.options.shortcuts),e.action&&("function"==typeof e.action?t.onclick=function(t){t.preventDefault(),e.action(r)}:"string"==typeof e.action&&(t.href=e.action,t.target="_blank")),a[e.name||e]=t,n.appendChild(t)}(e[t])}r.toolbarElements=a;var u=this.codemirror;u.on("cursorActivity",function(){var e=l(u);for(var t in a)!function(t){var n=a[t];e[t]?n.className+=" active":"fullscreen"!=t&&"side-by-side"!=t&&(n.className=n.className.replace(/\s*active\s*/g,""))}(t)});var f=u.getWrapperElement();return f.parentNode.insertBefore(n,f),n}},B.prototype.createStatusbar=function(e){e=e||this.options.status;var t=this.options,n=this.codemirror;if(e&&0!==e.length){var r,i,o,a=[];for(r=0;r<e.length;r++)if(i=void 0,o=void 0,"object"==typeof e[r])a.push({className:e[r].className,defaultValue:e[r].defaultValue,onUpdate:e[r].onUpdate});else{var l=e[r];"words"===l?(o=function(e){e.innerHTML=W(n.getValue())},i=function(e){e.innerHTML=W(n.getValue())}):"lines"===l?(o=function(e){e.innerHTML=n.lineCount()},i=function(e){e.innerHTML=n.lineCount()}):"cursor"===l?(o=function(e){e.innerHTML="0:0"},i=function(e){var t=n.getCursor();e.innerHTML=t.line+":"+t.ch}):"autosave"===l&&(o=function(e){void 0!=t.autosave&&t.autosave.enabled===!0&&e.setAttribute("id","autosaved")}),a.push({className:l,defaultValue:o,onUpdate:i})}var s=document.createElement("div");for(s.className="editor-statusbar",r=0;r<a.length;r++){var c=a[r],u=document.createElement("span");u.className=c.className,"function"==typeof c.defaultValue&&c.defaultValue(u),"function"==typeof c.onUpdate&&this.codemirror.on("update",function(e,t){return function(){t.onUpdate(e)}}(u,c)),s.appendChild(u)}var f=this.codemirror.getWrapperElement();return f.parentNode.insertBefore(s,f.nextSibling),s}},B.prototype.value=function(e){return void 0===e?this.codemirror.getValue():(this.codemirror.getDoc().setValue(e),this)},B.toggleBold=c,B.toggleItalic=u,B.toggleStrikethrough=f,B.toggleBlockquote=d,B.toggleHeadingSmaller=p,B.toggleHeadingBigger=m,B.toggleHeading1=g,B.toggleHeading2=v,B.toggleHeading3=y,B.toggleCodeBlock=h,B.toggleUnorderedList=x,B.toggleOrderedList=b,B.cleanBlock=w,B.drawLink=k,B.drawImage=S,B.drawTable=C,B.drawHorizontalRule=L,B.undo=T,B.redo=M,B.togglePreview=A,B.toggleSideBySide=N,B.toggleFullScreen=s,B.prototype.toggleBold=function(){c(this)},B.prototype.toggleItalic=function(){u(this)},B.prototype.toggleStrikethrough=function(){f(this)},B.prototype.toggleBlockquote=function(){d(this)},B.prototype.toggleHeadingSmaller=function(){p(this)},B.prototype.toggleHeadingBigger=function(){m(this)},B.prototype.toggleHeading1=function(){g(this)},B.prototype.toggleHeading2=function(){v(this)},B.prototype.toggleHeading3=function(){y(this)},B.prototype.toggleCodeBlock=function(){h(this)},B.prototype.toggleUnorderedList=function(){x(this)},B.prototype.toggleOrderedList=function(){b(this)},B.prototype.cleanBlock=function(){w(this)},B.prototype.drawLink=function(){k(this)},B.prototype.drawImage=function(){S(this)},B.prototype.drawTable=function(){C(this)},B.prototype.drawHorizontalRule=function(){L(this)},B.prototype.undo=function(){T(this)},B.prototype.redo=function(){M(this)},B.prototype.togglePreview=function(){A(this)},B.prototype.toggleSideBySide=function(){N(this)},B.prototype.toggleFullScreen=function(){s(this)},B.prototype.isPreviewActive=function(){var e=this.codemirror,t=e.getWrapperElement(),n=t.lastChild;return/editor-preview-active/.test(n.className)},B.prototype.isSideBySideActive=function(){var e=this.codemirror,t=e.getWrapperElement(),n=t.nextSibling;return/editor-preview-active-side/.test(n.className)},B.prototype.isFullscreenActive=function(){var e=this.codemirror;return e.getOption("fullScreen")},B.prototype.getState=function(){var e=this.codemirror;return l(e)},B.prototype.toTextArea=function(){var e=this.codemirror,t=e.getWrapperElement();t.parentNode&&(this.gui.toolbar&&t.parentNode.removeChild(this.gui.toolbar),this.gui.statusbar&&t.parentNode.removeChild(this.gui.statusbar),this.gui.sideBySide&&t.parentNode.removeChild(this.gui.sideBySide)),e.toTextArea(),this.autosaveTimeoutId&&(clearTimeout(this.autosaveTimeoutId),this.autosaveTimeoutId=void 0,this.clearAutosavedValue())},t.exports=B},{"./codemirror/tablist":19,codemirror:10,"codemirror-spell-checker":4,"codemirror/addon/display/fullscreen.js":5,"codemirror/addon/display/placeholder.js":6,"codemirror/addon/edit/continuelist.js":7,"codemirror/addon/mode/overlay.js":8,"codemirror/addon/selection/mark-selection.js":9,"codemirror/mode/gfm/gfm.js":11,"codemirror/mode/markdown/markdown.js":12,"codemirror/mode/xml/xml.js":14,marked:17}]},{},[20])(20)});
/** Trumbowyg v2.10.0 - A lightweight WYSIWYG editor - alex-d.github.io/Trumbowyg - License MIT - Author : Alexandre Demode (Alex-D) / alex-d.fr */
jQuery.trumbowyg={langs:{en:{viewHTML:"View HTML",undo:"Undo",redo:"Redo",formatting:"Formatting",p:"Paragraph",blockquote:"Quote",code:"Code",header:"Header",bold:"Bold",italic:"Italic",strikethrough:"Stroke",underline:"Underline",strong:"Strong",em:"Emphasis",del:"Deleted",superscript:"Superscript",subscript:"Subscript",unorderedList:"Unordered list",orderedList:"Ordered list",insertImage:"Insert Image",link:"Link",createLink:"Insert link",unlink:"Remove link",justifyLeft:"Align Left",justifyCenter:"Align Center",justifyRight:"Align Right",justifyFull:"Align Justify",horizontalRule:"Insert horizontal rule",removeformat:"Remove format",fullscreen:"Fullscreen",close:"Close",submit:"Confirm",reset:"Cancel",required:"Required",description:"Description",title:"Title",text:"Text",target:"Target",width:"Width"}},plugins:{},svgPath:null,hideButtonTexts:null},Object.defineProperty(jQuery.trumbowyg,"defaultOptions",{value:{lang:"en",fixedBtnPane:!1,fixedFullWidth:!1,autogrow:!1,autogrowOnEnter:!1,imageWidthModalEdit:!1,prefix:"trumbowyg-",semantic:!0,resetCss:!1,removeformatPasted:!1,tagsToRemove:[],btns:[["viewHTML"],["undo","redo"],["formatting"],["strong","em","del"],["superscript","subscript"],["link"],["insertImage"],["justifyLeft","justifyCenter","justifyRight","justifyFull"],["unorderedList","orderedList"],["horizontalRule"],["removeformat"],["fullscreen"]],btnsDef:{},inlineElementsSelector:"a,abbr,acronym,b,caption,cite,code,col,dfn,dir,dt,dd,em,font,hr,i,kbd,li,q,span,strikeout,strong,sub,sup,u",pasteHandlers:[],plugins:{},urlProtocol:!1,minimalLinks:!1},writable:!1,enumerable:!0,configurable:!1}),function(e,t,n,a){"use strict";var o="tbwconfirm",r="tbwcancel";a.fn.trumbowyg=function(e,t){var n="trumbowyg";if(e===Object(e)||!e)return this.each(function(){a(this).data(n)||a(this).data(n,new i(this,e))});if(1===this.length)try{var o=a(this).data(n);switch(e){case"execCmd":return o.execCmd(t.cmd,t.param,t.forceCss);case"openModal":return o.openModal(t.title,t.content);case"closeModal":return o.closeModal();case"openModalInsert":return o.openModalInsert(t.title,t.fields,t.callback);case"saveRange":return o.saveRange();case"getRange":return o.range;case"getRangeText":return o.getRangeText();case"restoreRange":return o.restoreRange();case"enable":return o.setDisabled(!1);case"disable":return o.setDisabled(!0);case"toggle":return o.toggle();case"destroy":return o.destroy();case"empty":return o.empty();case"html":return o.html(t)}}catch(r){}return!1};var i=function(o,r){var i=this,s="trumbowyg-icons",l=a.trumbowyg;i.doc=o.ownerDocument||n,i.$ta=a(o),i.$c=a(o),r=r||{},null!=r.lang||null!=l.langs[r.lang]?i.lang=a.extend(!0,{},l.langs.en,l.langs[r.lang]):i.lang=l.langs.en,i.hideButtonTexts=null!=l.hideButtonTexts?l.hideButtonTexts:r.hideButtonTexts;var d=null!=l.svgPath?l.svgPath:r.svgPath;if(i.hasSvg=d!==!1,i.svgPath=i.doc.querySelector("base")?t.location.href.split("#")[0]:"",0===a("#"+s,i.doc).length&&d!==!1){if(null==d){for(var c=n.getElementsByTagName("script"),u=0;u<c.length;u+=1){var g=c[u].src,f=g.match("trumbowyg(.min)?.js");null!=f&&(d=g.substring(0,g.indexOf(f[0]))+"ui/icons.svg")}null==d&&console.warn("You must define svgPath: https://goo.gl/CfTY9U")}var h=i.doc.createElement("div");h.id=s,i.doc.body.insertBefore(h,i.doc.body.childNodes[0]),a.ajax({async:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",dataType:"xml",crossDomain:!0,url:d,data:null,beforeSend:null,complete:null,success:function(e){h.innerHTML=(new XMLSerializer).serializeToString(e.documentElement)}})}var p=i.lang.header,m=function(){return(t.chrome||t.Intl&&Intl.v8BreakIterator)&&"CSS"in t};i.btnsDef={viewHTML:{fn:"toggle"},undo:{isSupported:m,key:"Z"},redo:{isSupported:m,key:"Y"},p:{fn:"formatBlock"},blockquote:{fn:"formatBlock"},h1:{fn:"formatBlock",title:p+" 1"},h2:{fn:"formatBlock",title:p+" 2"},h3:{fn:"formatBlock",title:p+" 3"},h4:{fn:"formatBlock",title:p+" 4"},subscript:{tag:"sub"},superscript:{tag:"sup"},bold:{key:"B",tag:"b"},italic:{key:"I",tag:"i"},underline:{tag:"u"},strikethrough:{tag:"strike"},strong:{fn:"bold",key:"B"},em:{fn:"italic",key:"I"},del:{fn:"strikethrough"},createLink:{key:"K",tag:"a"},unlink:{},insertImage:{},justifyLeft:{tag:"left",forceCss:!0},justifyCenter:{tag:"center",forceCss:!0},justifyRight:{tag:"right",forceCss:!0},justifyFull:{tag:"justify",forceCss:!0},unorderedList:{fn:"insertUnorderedList",tag:"ul"},orderedList:{fn:"insertOrderedList",tag:"ol"},horizontalRule:{fn:"insertHorizontalRule"},removeformat:{},fullscreen:{"class":"trumbowyg-not-disable"},close:{fn:"destroy","class":"trumbowyg-not-disable"},formatting:{dropdown:["p","blockquote","h1","h2","h3","h4"],ico:"p"},link:{dropdown:["createLink","unlink"]}},i.o=a.extend(!0,{},l.defaultOptions,r),i.o.hasOwnProperty("imgDblClickHandler")||(i.o.imgDblClickHandler=i.getDefaultImgDblClickHandler()),i.urlPrefix=i.setupUrlPrefix(),i.disabled=i.o.disabled||"TEXTAREA"===o.nodeName&&o.disabled,r.btns?i.o.btns=r.btns:i.o.semantic||(i.o.btns[3]=["bold","italic","underline","strikethrough"]),a.each(i.o.btnsDef,function(e,t){i.addBtnDef(e,t)}),i.eventNamespace="trumbowyg-event",i.keys=[],i.tagToButton={},i.tagHandlers=[],i.pasteHandlers=[].concat(i.o.pasteHandlers),i.isIE=e.userAgent.indexOf("MSIE")!==-1||e.appVersion.indexOf("Trident/")!==-1,i.init()};i.prototype={DEFAULT_SEMANTIC_MAP:{b:"strong",i:"em",s:"del",strike:"del",div:"p"},init:function(){var e=this;e.height=e.$ta.height(),e.initPlugins();try{e.doc.execCommand("enableObjectResizing",!1,!1),e.doc.execCommand("defaultParagraphSeparator",!1,"p")}catch(t){}e.buildEditor(),e.buildBtnPane(),e.fixedBtnPaneEvents(),e.buildOverlay(),setTimeout(function(){e.disabled&&e.setDisabled(!0),e.$c.trigger("tbwinit")})},addBtnDef:function(e,t){this.btnsDef[e]=t},setupUrlPrefix:function(){var e=this.o.urlProtocol;if(e)return"string"!=typeof e?"https://":/:\/\/$/.test(e)?e:e+"://"},buildEditor:function(){var e=this,n=e.o.prefix,o="";e.$box=a("<div/>",{"class":n+"box "+n+"editor-visible "+n+e.o.lang+" trumbowyg"}),e.isTextarea=e.$ta.is("textarea"),e.isTextarea?(o=e.$ta.val(),e.$ed=a("<div/>"),e.$box.insertAfter(e.$ta).append(e.$ed,e.$ta)):(e.$ed=e.$ta,o=e.$ed.html(),e.$ta=a("<textarea/>",{name:e.$ta.attr("id"),height:e.height}).val(o),e.$box.insertAfter(e.$ed).append(e.$ta,e.$ed),e.syncCode()),e.$ta.addClass(n+"textarea").attr("tabindex",-1),e.$ed.addClass(n+"editor").attr({contenteditable:!0,dir:e.lang._dir||"ltr"}).html(o),e.o.tabindex&&e.$ed.attr("tabindex",e.o.tabindex),e.$c.is("[placeholder]")&&e.$ed.attr("placeholder",e.$c.attr("placeholder")),e.$c.is("[spellcheck]")&&e.$ed.attr("spellcheck",e.$c.attr("spellcheck")),e.o.resetCss&&e.$ed.addClass(n+"reset-css"),e.o.autogrow||e.$ta.add(e.$ed).css({height:e.height}),e.semanticCode(),e.o.autogrowOnEnter&&e.$ed.addClass(n+"autogrow-on-enter");var r,i=!1,s=!1,l="keyup";e.$ed.on("dblclick","img",e.o.imgDblClickHandler).on("keydown",function(t){if((t.ctrlKey||t.metaKey)&&!t.altKey){i=!0;var n=e.keys[String.fromCharCode(t.which).toUpperCase()];try{return e.execCmd(n.fn,n.param),!1}catch(a){}}}).on("compositionstart compositionupdate",function(){s=!0}).on(l+" compositionend",function(t){if("compositionend"===t.type)s=!1;else if(s)return;var n=t.which;if(!(n>=37&&n<=40)){if(!t.ctrlKey&&!t.metaKey||89!==n&&90!==n)if(i||17===n)"undefined"==typeof t.which&&e.semanticCode(!1,!1,!0);else{var a=!e.isIE||"compositionend"===t.type;e.semanticCode(!1,a&&13===n),e.$c.trigger("tbwchange")}else e.$c.trigger("tbwchange");setTimeout(function(){i=!1},50)}}).on("mouseup keydown keyup",function(t){(!t.ctrlKey&&!t.metaKey||t.altKey)&&setTimeout(function(){i=!1},50),clearTimeout(r),r=setTimeout(function(){e.updateButtonPaneStatus()},50)}).on("focus blur",function(t){if(e.$c.trigger("tbw"+t.type),"blur"===t.type&&a("."+n+"active-button",e.$btnPane).removeClass(n+"active-button "+n+"active"),e.o.autogrowOnEnter){if(e.autogrowOnEnterDontClose)return;"focus"===t.type?(e.autogrowOnEnterWasFocused=!0,e.autogrowEditorOnEnter()):e.o.autogrow||(e.$ed.css({height:e.$ed.css("min-height")}),e.$c.trigger("tbwresize"))}}).on("cut",function(){setTimeout(function(){e.semanticCode(!1,!0),e.$c.trigger("tbwchange")},0)}).on("paste",function(n){if(e.o.removeformatPasted){n.preventDefault(),t.getSelection&&t.getSelection().deleteFromDocument&&t.getSelection().deleteFromDocument();try{var o=t.clipboardData.getData("Text");try{e.doc.selection.createRange().pasteHTML(o)}catch(r){e.doc.getSelection().getRangeAt(0).insertNode(e.doc.createTextNode(o))}e.$c.trigger("tbwchange",n)}catch(i){e.execCmd("insertText",(n.originalEvent||n).clipboardData.getData("text/plain"))}}a.each(e.pasteHandlers,function(e,t){t(n)}),setTimeout(function(){e.semanticCode(!1,!0),e.$c.trigger("tbwpaste",n)},0)}),e.$ta.on("keyup",function(){e.$c.trigger("tbwchange")}).on("paste",function(){setTimeout(function(){e.$c.trigger("tbwchange")},0)}),e.$box.on("keydown",function(t){if(27===t.which&&1===a("."+n+"modal-box",e.$box).length)return e.closeModal(),!1})},autogrowEditorOnEnter:function(){var e=this;e.$ed.removeClass("autogrow-on-enter");var t=e.$ed[0].clientHeight;e.$ed.height("auto");var n=e.$ed[0].scrollHeight;e.$ed.addClass("autogrow-on-enter"),t!==n&&(e.$ed.height(t),setTimeout(function(){e.$ed.css({height:n}),e.$c.trigger("tbwresize")},0))},buildBtnPane:function(){var e=this,t=e.o.prefix,n=e.$btnPane=a("<div/>",{"class":t+"button-pane"});a.each(e.o.btns,function(o,r){a.isArray(r)||(r=[r]);var i=a("<div/>",{"class":t+"button-group "+(r.indexOf("fullscreen")>=0?t+"right":"")});a.each(r,function(t,n){try{e.isSupportedBtn(n)&&i.append(e.buildBtn(n))}catch(a){}}),i.html().trim().length>0&&n.append(i)}),e.$box.prepend(n)},buildBtn:function(e){var t=this,n=t.o.prefix,o=t.btnsDef[e],r=o.dropdown,i=null==o.hasIcon||o.hasIcon,s=t.lang[e]||e,l=a("<button/>",{type:"button","class":n+e+"-button "+(o["class"]||"")+(i?"":" "+n+"textual-button"),html:t.hasSvg&&i?'<svg><use xlink:href="'+t.svgPath+"#"+n+(o.ico||e).replace(/([A-Z]+)/g,"-$1").toLowerCase()+'"/></svg>':t.hideButtonTexts?"":o.text||o.title||t.lang[e]||e,title:(o.title||o.text||s)+(o.key?" (Ctrl + "+o.key+")":""),tabindex:-1,mousedown:function(){return r&&!a("."+e+"-"+n+"dropdown",t.$box).is(":hidden")||a("body",t.doc).trigger("mousedown"),!((t.$btnPane.hasClass(n+"disable")||t.$box.hasClass(n+"disabled"))&&!a(this).hasClass(n+"active")&&!a(this).hasClass(n+"not-disable"))&&(t.execCmd(!!r&&"dropdown"||o.fn||e,o.param||e,o.forceCss),!1)}});if(r){l.addClass(n+"open-dropdown");var d=n+"dropdown",c={"class":d+"-"+e+" "+d+" "+n+"fixed-top"};c["data-"+d]=e;var u=a("<div/>",c);a.each(r,function(e,n){t.btnsDef[n]&&t.isSupportedBtn(n)&&u.append(t.buildSubBtn(n))}),t.$box.append(u.hide())}else o.key&&(t.keys[o.key]={fn:o.fn||e,param:o.param||e});return r||(t.tagToButton[(o.tag||e).toLowerCase()]=e),l},buildSubBtn:function(e){var t=this,n=t.o.prefix,o=t.btnsDef[e],r=null==o.hasIcon||o.hasIcon;return o.key&&(t.keys[o.key]={fn:o.fn||e,param:o.param||e}),t.tagToButton[(o.tag||e).toLowerCase()]=e,a("<button/>",{type:"button","class":n+e+"-dropdown-button"+(o.ico?" "+n+o.ico+"-button":""),html:t.hasSvg&&r?'<svg><use xlink:href="'+t.svgPath+"#"+n+(o.ico||e).replace(/([A-Z]+)/g,"-$1").toLowerCase()+'"/></svg>'+(o.text||o.title||t.lang[e]||e):o.text||o.title||t.lang[e]||e,title:o.key?" (Ctrl + "+o.key+")":null,style:o.style||null,mousedown:function(){return a("body",t.doc).trigger("mousedown"),t.execCmd(o.fn||e,o.param||e,o.forceCss),!1}})},isSupportedBtn:function(e){try{return this.btnsDef[e].isSupported()}catch(t){}return!0},buildOverlay:function(){var e=this;return e.$overlay=a("<div/>",{"class":e.o.prefix+"overlay"}).appendTo(e.$box),e.$overlay},showOverlay:function(){var e=this;a(t).trigger("scroll"),e.$overlay.fadeIn(200),e.$box.addClass(e.o.prefix+"box-blur")},hideOverlay:function(){var e=this;e.$overlay.fadeOut(50),e.$box.removeClass(e.o.prefix+"box-blur")},fixedBtnPaneEvents:function(){var e=this,n=e.o.fixedFullWidth,o=e.$box;e.o.fixedBtnPane&&(e.isFixed=!1,a(t).on("scroll."+e.eventNamespace+" resize."+e.eventNamespace,function(){if(o){e.syncCode();var r=a(t).scrollTop(),i=o.offset().top+1,s=e.$btnPane,l=s.outerHeight()-2;r-i>0&&r-i-e.height<0?(e.isFixed||(e.isFixed=!0,s.css({position:"fixed",top:0,left:n?"0":"auto",zIndex:7}),a([e.$ta,e.$ed]).css({marginTop:s.height()})),s.css({width:n?"100%":o.width()-1+"px"}),a("."+e.o.prefix+"fixed-top",o).css({position:n?"fixed":"absolute",top:n?l:l+(r-i)+"px",zIndex:15})):e.isFixed&&(e.isFixed=!1,s.removeAttr("style"),a([e.$ta,e.$ed]).css({marginTop:0}),a("."+e.o.prefix+"fixed-top",o).css({position:"absolute",top:l}))}}))},setDisabled:function(e){var t=this,n=t.o.prefix;t.disabled=e,e?t.$ta.attr("disabled",!0):t.$ta.removeAttr("disabled"),t.$box.toggleClass(n+"disabled",e),t.$ed.attr("contenteditable",!e)},destroy:function(){var e=this,n=e.o.prefix;e.isTextarea?e.$box.after(e.$ta.css({height:""}).val(e.html()).removeClass(n+"textarea").show()):e.$box.after(e.$ed.css({height:""}).removeClass(n+"editor").removeAttr("contenteditable").removeAttr("dir").html(e.html()).show()),e.$ed.off("dblclick","img"),e.destroyPlugins(),e.$box.remove(),e.$c.removeData("trumbowyg"),a("body").removeClass(n+"body-fullscreen"),e.$c.trigger("tbwclose"),a(t).off("scroll."+e.eventNamespace+" resize."+e.eventNamespace)},empty:function(){this.$ta.val(""),this.syncCode(!0)},toggle:function(){var e=this,t=e.o.prefix;e.o.autogrowOnEnter&&(e.autogrowOnEnterDontClose=!e.$box.hasClass(t+"editor-hidden")),e.semanticCode(!1,!0),setTimeout(function(){e.doc.activeElement.blur(),e.$box.toggleClass(t+"editor-hidden "+t+"editor-visible"),e.$btnPane.toggleClass(t+"disable"),a("."+t+"viewHTML-button",e.$btnPane).toggleClass(t+"active"),e.$box.hasClass(t+"editor-visible")?e.$ta.attr("tabindex",-1):e.$ta.removeAttr("tabindex"),e.o.autogrowOnEnter&&!e.autogrowOnEnterDontClose&&e.autogrowEditorOnEnter()},0)},dropdown:function(e){var n=this,o=n.doc,r=n.o.prefix,i=a("[data-"+r+"dropdown="+e+"]",n.$box),s=a("."+r+e+"-button",n.$btnPane),l=i.is(":hidden");if(a("body",o).trigger("mousedown"),l){var d=s.offset().left;s.addClass(r+"active"),i.css({position:"absolute",top:s.offset().top-n.$btnPane.offset().top+s.outerHeight(),left:n.o.fixedFullWidth&&n.isFixed?d+"px":d-n.$btnPane.offset().left+"px"}).show(),a(t).trigger("scroll"),a("body",o).on("mousedown."+n.eventNamespace,function(e){i.is(e.target)||(a("."+r+"dropdown",n.$box).hide(),a("."+r+"active",n.$btnPane).removeClass(r+"active"),a("body",o).off("mousedown."+n.eventNamespace))})}},html:function(e){var t=this;return null!=e?(t.$ta.val(e),t.syncCode(!0),t.$c.trigger("tbwchange"),t):t.$ta.val()},syncTextarea:function(){var e=this;e.$ta.val(e.$ed.text().trim().length>0||e.$ed.find("hr,img,embed,iframe,input").length>0?e.$ed.html():"")},syncCode:function(e){var t=this;if(!e&&t.$ed.is(":visible"))t.syncTextarea();else{var n=a("<div>").html(t.$ta.val()),o=a("<div>").append(n);a(t.o.tagsToRemove.join(","),o).remove(),t.$ed.html(o.contents().html())}if(t.o.autogrow&&(t.height=t.$ed.height(),t.height!==t.$ta.css("height")&&(t.$ta.css({height:t.height}),t.$c.trigger("tbwresize"))),t.o.autogrowOnEnter){t.$ed.height("auto");var r=t.autogrowOnEnterWasFocused?t.$ed[0].scrollHeight:t.$ed.css("min-height");r!==t.$ta.css("height")&&(t.$ed.css({height:r}),t.$c.trigger("tbwresize"))}},semanticCode:function(e,t,n){var o=this;if(o.saveRange(),o.syncCode(e),o.o.semantic){if(o.semanticTag("b"),o.semanticTag("i"),o.semanticTag("s"),o.semanticTag("strike"),t){var r=o.o.inlineElementsSelector,i=":not("+r+")";o.$ed.contents().filter(function(){return 3===this.nodeType&&this.nodeValue.trim().length>0}).wrap("<span data-tbw/>");var s=function(e){if(0!==e.length){var t=e.nextUntil(i).addBack().wrapAll("<p/>").parent(),n=t.nextAll(r).first();t.next("br").remove(),s(n)}};s(o.$ed.children(r).first()),o.semanticTag("div",!0),o.$ed.find("p").filter(function(){return(!o.range||this!==o.range.startContainer)&&(0===a(this).text().trim().length&&0===a(this).children().not("br,span").length)}).contents().unwrap(),a("[data-tbw]",o.$ed).contents().unwrap(),o.$ed.find("p:empty").remove()}n||o.restoreRange(),o.syncTextarea()}},semanticTag:function(e,t){var n;if(null!=this.o.semantic&&"object"==typeof this.o.semantic&&this.o.semantic.hasOwnProperty(e))n=this.o.semantic[e];else{if(this.o.semantic!==!0||!this.DEFAULT_SEMANTIC_MAP.hasOwnProperty(e))return;n=this.DEFAULT_SEMANTIC_MAP[e]}a(e,this.$ed).each(function(){var e=a(this);e.wrap("<"+n+"/>"),t&&a.each(e.prop("attributes"),function(){e.parent().attr(this.name,this.value)}),e.contents().unwrap()})},createLink:function(){for(var e,t,n,o=this,r=o.doc.getSelection(),i=r.focusNode,s=(new XMLSerializer).serializeToString(r.getRangeAt(0).cloneContents());["A","DIV"].indexOf(i.nodeName)<0;)i=i.parentNode;if(i&&"A"===i.nodeName){var l=a(i);s=l.text(),e=l.attr("href"),o.o.minimalLinks||(t=l.attr("title"),n=l.attr("target"));var d=o.doc.createRange();d.selectNode(i),r.removeAllRanges(),r.addRange(d)}o.saveRange();var c={url:{label:"URL",required:!0,value:e},text:{label:o.lang.text,value:s}};o.o.minimalLinks||Object.assign(c,{title:{label:o.lang.title,value:t},target:{label:o.lang.target,value:n}}),o.openModalInsert(o.lang.createLink,c,function(e){var t=o.prependUrlPrefix(e.url);if(!t.length)return!1;var n=a(['<a href="',e.url,'">',e.text||e.url,"</a>"].join(""));return o.o.minimalLinks||(e.title.length>0&&n.attr("title",e.title),e.target.length>0&&n.attr("target",e.target)),o.range.deleteContents(),o.range.insertNode(n[0]),o.syncCode(),o.$c.trigger("tbwchange"),!0})},prependUrlPrefix:function(e){var t=this;if(!t.urlPrefix)return e;const n=/^([a-z][-+.a-z0-9]*:|\/|#)/i;if(n.test(e))return e;const a=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return a.test(e)?"mailto:"+e:t.urlPrefix+e},unlink:function(){var e=this,t=e.doc.getSelection(),n=t.focusNode;if(t.isCollapsed){for(;["A","DIV"].indexOf(n.nodeName)<0;)n=n.parentNode;if(n&&"A"===n.nodeName){var a=e.doc.createRange();a.selectNode(n),t.removeAllRanges(),t.addRange(a)}}e.execCmd("unlink",void 0,void 0,!0)},insertImage:function(){var e=this;e.saveRange();var t={url:{label:"URL",required:!0},alt:{label:e.lang.description,value:e.getRangeText()}};e.o.imageWidthModalEdit&&(t.width={}),e.openModalInsert(e.lang.insertImage,t,function(t){e.execCmd("insertImage",t.url);var n=a('img[src="'+t.url+'"]:not([alt])',e.$box);return n.attr("alt",t.alt),e.o.imageWidthModalEdit&&n.attr({width:t.width}),e.syncCode(),e.$c.trigger("tbwchange"),!0})},fullscreen:function(){var e,n=this,o=n.o.prefix,r=o+"fullscreen";n.$box.toggleClass(r),e=n.$box.hasClass(r),a("body").toggleClass(o+"body-fullscreen",e),a(t).trigger("scroll"),n.$c.trigger("tbw"+(e?"open":"close")+"fullscreen")},execCmd:function(e,t,n,a){var o=this;a=!!a||"","dropdown"!==e&&o.$ed.focus();try{o.doc.execCommand("styleWithCSS",!1,n||!1)}catch(r){}try{o[e+a](t)}catch(r){try{e(t)}catch(i){"insertHorizontalRule"===e?t=void 0:"formatBlock"===e&&o.isIE&&(t="<"+t+">"),o.doc.execCommand(e,!1,t),o.syncCode(),o.semanticCode(!1,!0)}"dropdown"!==e&&(o.updateButtonPaneStatus(),o.$c.trigger("tbwchange"))}},openModal:function(e,n){var i=this,s=i.o.prefix;if(a("."+s+"modal-box",i.$box).length>0)return!1;i.o.autogrowOnEnter&&(i.autogrowOnEnterDontClose=!0),i.saveRange(),i.showOverlay(),i.$btnPane.addClass(s+"disable");var l=a("<div/>",{"class":s+"modal "+s+"fixed-top"}).css({top:i.$btnPane.height()}).appendTo(i.$box);i.$overlay.one("click",function(){return l.trigger(r),!1});var d=a("<form/>",{action:"",html:n}).on("submit",function(){return l.trigger(o),!1}).on("reset",function(){return l.trigger(r),!1}).on("submit reset",function(){i.o.autogrowOnEnter&&(i.autogrowOnEnterDontClose=!1)}),c=a("<div/>",{"class":s+"modal-box",html:d}).css({top:"-"+i.$btnPane.outerHeight()+"px",opacity:0}).appendTo(l).animate({top:0,opacity:1},100);return a("<span/>",{text:e,"class":s+"modal-title"}).prependTo(c),l.height(c.outerHeight()+10),a("input:first",c).focus(),i.buildModalBtn("submit",c),i.buildModalBtn("reset",c),a(t).trigger("scroll"),l},buildModalBtn:function(e,t){var n=this,o=n.o.prefix;return a("<button/>",{"class":o+"modal-button "+o+"modal-"+e,type:e,text:n.lang[e]||e}).appendTo(a("form",t))},closeModal:function(){var e=this,t=e.o.prefix;e.$btnPane.removeClass(t+"disable"),e.$overlay.off();var n=a("."+t+"modal-box",e.$box);n.animate({top:"-"+n.height()},100,function(){n.parent().remove(),e.hideOverlay()}),e.restoreRange()},openModalInsert:function(e,t,n){var i=this,s=i.o.prefix,l=i.lang,d="";return a.each(t,function(e,t){var n=t.label||e,a=t.name||e,o=t.attributes||{},r=Object.keys(o).map(function(e){return e+'="'+o[e]+'"'}).join(" ");d+='<label><input type="'+(t.type||"text")+'" name="'+a+'"'+("checkbox"===t.type&&t.value?' checked="checked"':' value="'+(t.value||"").replace(/"/g,"""))+'"'+r+'><span class="'+s+'input-infos"><span>'+(l[n]?l[n]:n)+"</span></span></label>"}),i.openModal(e,d).on(o,function(){var e=a("form",a(this)),r=!0,s={};a.each(t,function(t,n){var o=n.name||t,l=a('input[name="'+o+'"]',e),d=l.attr("type");switch(d.toLowerCase()){case"checkbox":s[o]=l.is(":checked");break;case"radio":s[o]=l.filter(":checked").val();break;default:s[o]=a.trim(l.val())}n.required&&""===s[o]?(r=!1,i.addErrorOnModalField(l,i.lang.required)):n.pattern&&!n.pattern.test(s[o])&&(r=!1,i.addErrorOnModalField(l,n.patternError))}),r&&(i.restoreRange(),n(s,t)&&(i.syncCode(),i.$c.trigger("tbwchange"),i.closeModal(),a(this).off(o)))}).one(r,function(){a(this).off(o),i.closeModal()})},addErrorOnModalField:function(e,t){var n=this.o.prefix,o=e.parent();e.on("change keyup",function(){o.removeClass(n+"input-error")}),o.addClass(n+"input-error").find("input+span").append(a("<span/>",{"class":n+"msg-error",text:t}))},getDefaultImgDblClickHandler:function(){var e=this;return function(){var t=a(this),n=t.attr("src"),o="(Base64)";0===n.indexOf("data:image")&&(n=o);var r={url:{label:"URL",value:n,required:!0},alt:{label:e.lang.description,value:t.attr("alt")}};return e.o.imageWidthModalEdit&&(r.width={value:t.attr("width")?t.attr("width"):""}),e.openModalInsert(e.lang.insertImage,r,function(n){return n.src!==o&&t.attr({src:n.url}),t.attr({alt:n.alt}),e.o.imageWidthModalEdit&&(parseInt(n.width)>0?t.attr({width:n.width}):t.removeAttr("width")),!0}),!1}},saveRange:function(){var e=this,t=e.doc.getSelection();if(e.range=null,t.rangeCount){var n,a=e.range=t.getRangeAt(0),o=e.doc.createRange();o.selectNodeContents(e.$ed[0]),o.setEnd(a.startContainer,a.startOffset),n=(o+"").length,e.metaRange={start:n,end:n+(a+"").length}}},restoreRange:function(){var e,t=this,n=t.metaRange,a=t.range,o=t.doc.getSelection();if(a){if(n&&n.start!==n.end){var r,i=0,s=[t.$ed[0]],l=!1,d=!1;for(e=t.doc.createRange();!d&&(r=s.pop());)if(3===r.nodeType){var c=i+r.length;!l&&n.start>=i&&n.start<=c&&(e.setStart(r,n.start-i),l=!0),l&&n.end>=i&&n.end<=c&&(e.setEnd(r,n.end-i),d=!0),i=c}else for(var u=r.childNodes,g=u.length;g>0;)g-=1,s.push(u[g])}o.removeAllRanges(),o.addRange(e||a)}},getRangeText:function(){return this.range+""},updateButtonPaneStatus:function(){var e=this,t=e.o.prefix,n=e.getTagsRecursive(e.doc.getSelection().focusNode),o=t+"active-button "+t+"active";a("."+t+"active-button",e.$btnPane).removeClass(o),a.each(n,function(n,r){var i=e.tagToButton[r.toLowerCase()],s=a("."+t+i+"-button",e.$btnPane);if(s.length>0)s.addClass(o);else try{s=a("."+t+"dropdown ."+t+i+"-dropdown-button",e.$box);var l=s.parent().data("dropdown");a("."+t+l+"-button",e.$box).addClass(o)}catch(d){}})},getTagsRecursive:function(e,t){var n=this;if(t=t||(e&&e.tagName?[e.tagName]:[]),!e||!e.parentNode)return t;e=e.parentNode;var o=e.tagName;return"DIV"===o?t:("P"===o&&""!==e.style.textAlign&&t.push(e.style.textAlign),a.each(n.tagHandlers,function(a,o){t=t.concat(o(e,n))}),t.push(o),n.getTagsRecursive(e,t).filter(function(e){return null!=e}))},initPlugins:function(){var e=this;e.loadedPlugins=[],a.each(a.trumbowyg.plugins,function(t,n){n.shouldInit&&!n.shouldInit(e)||(n.init(e),n.tagHandler&&e.tagHandlers.push(n.tagHandler),e.loadedPlugins.push(n))})},destroyPlugins:function(){a.each(this.loadedPlugins,function(e,t){t.destroy&&t.destroy()})}}}(navigator,window,document,jQuery);
-;class;Callback{constructor(){this.list=[]};add(callable){this.list.push(callable)};fire(){for(let c of this.list)c.apply(null,arguments)}};
-;class;Notice{'use strict';static;type=Object.freeze({warning:0,validation:1,info:2,success:3,error:3,loading:3,inactive:4});constructor(){this.typ='';this.id=0;this.name='';this.status='inactive';this.msg='';this.log='';this.timeout=0;this.element=$('<div />').addClass('notice').addClass('notice--is-inactive').addClass('collapsible').addClass('collapsible--is-closed');this.onClick=new Callback()};before(){};close(){this.element.remove()};setStatus(status){this.element.removeClass('notice--'+this.status);this.status=status;this.element.addClass('notice--'+this.status)};inProgress(){this.element.addClass('loader')};stopProgress(){this.element.removeClass('loader')};show(){console.debug('user notice: '+this.msg);let notice=this;this.element.removeClass('notice--is-inactive');this.element.appendTo('.or-notice-container');let toolbar=$('<div class="or-notice-toolbar"></div>');toolbar.appendTo(this.element);toolbar.append('<i class="or-image-icon or-image-icon--menu-close or-act-notice-close"></i>');this.element.append($('<i />').addClass('image-icon').addClass('image-icon--node-open').addClass('collapsible--on-open'));this.element.append($('<i />').addClass('image-icon').addClass('image-icon--node-closed').addClass('collapsible--on-closed'));this.element.append('<span class="or-notice-text or-collapsible-act-switch">'+Notice.htmlEntities(this.msg)+'</span>');if(this.name){this.element.append($('<div class="or-notice-name or-collapsible-value"><a class="or-act-clickable" href="'+WorkbenchNavigator.createShortUrl(this.typ,this.id)+'" data-type="open" data-action="'+this.typ+'" data-id="'+this.id+'"><i class="or-notice-action-full or-image-icon or-image-icon--action-'+this.typ+'"></i><span class="">'+this.name+'</span></a></div>').orLinkify())};if(this.log)this.element.append('<div class="or-notice-log or-collapsible-value"><pre>'+Notice.htmlEntities(this.log)+'</pre></div>');this.element.append('<div class="or-notice-date or-collapsible-value">'+new Date().toLocaleTimeString()+'</div>');this.element.find('.or-notice-text').click(function(){notice.onClick.fire()});Workbench.registerOpenClose(this.element);this.element.find('.or-act-notice-close').click(function(){notice.close()});if(!this.timeout){switch(this.status){case'ok':this.timeout=3;break;case'info':this.timeout=30;break;case'warning':this.timeout=40;break;case'error':this.timeout=50;break;default:this.timeout=10;console.error('unknown notice status: '+this.status)}};if(this.timeout){let timer=setTimeout(function(){notice.close()},this.timeout*1000);this.element.click(function(){console.debug('kicked timer of notice');console.debug(timer);window.clearTimeout(timer)})}};setContext(type,id,name){this.typ=type;this.id=id;this.name=name};start(type,id,name,status,msg,log=null,notifyTheBrowser=!1){this.setContext(type,id,name);this.msg=msg;this.log=log;if(notifyTheBrowser)this.notifyBrowser(msg);this.setStatus(status)};notifyBrowser(){let text=this.msg;if(!('Notification' in window)){return}
-else if(Notification.permission==='granted'){let notification=new Notification(text)}
-else if(Notification.permission!=='denied'){Notification.requestPermission(function(t){if(t==='granted'){let notification=new Notification(text)}})}};static;htmlEntities(str){return String(str).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"')};static;removeNoticesWithStatus(status){$('.or-notice-container').find('.or-notice--'+status).remove()};static;removeAllNotices(status){$('.or-notice-container').find('.or-notice').remove()}};
-;class;Dialog{constructor(){this.view;this.isDirty=!1;this.element=$('.or-dialog-content .or-view')};start(name,action,method,id,params){if(!action)action=Workbench.state.action;if(!id)id=Workbench.state.id;let dialog=this;let view=new View(action,method,id,params);Notice.removeAllNotices();$('.or-dialog-content .or-view').html('');$('.or-dialog-content .or-act-dialog-name').html(name);this.show();view.onCloseHandler.add(function(){dialog.close()});view.onChangeHandler.add(function(){console.debug('Changes detected');dialog.isDirty=!0;dialog.element.addClass('view--is-dirty')});view.onSaveHandler.add(function(){dialog.isDirty=!1;dialog.element.removeClass('view--is-dirty')});this.view=view;return this.view.start(this.element)};show(){$('.or-dialog').removeClass('dialog--is-closed').addClass('dialog--is-open');if(this.isDirty){this.element.addClass('view--is-dirty')};let dialog=this;this.escapeKeyClosingHandler=function(e){if(e.keyCode==27){dialog.close();$(document).off('keyup')}};$(document).keyup(this.escapeKeyClosingHandler);$('.or-dialog-filler,.or-act-dialog-close').off('click').click(function(e){e.preventDefault();dialog.close()})};hide(){$('.or-dialog').removeClass('dialog--is-open').addClass('dialog--is-closed')};close(){let dialog=this;if(this.isDirty){let exit=window.confirm(Workbench.language.UNSAVED_CHANGES_CONFIRM);if(!exit)return;let notice=new Notice();notice.msg=Workbench.language.REOPEN_CLOSED_DIALOG;notice.setStatus('warning');notice.timeout=120;notice.onClick.add(function(){dialog.show();notice.close()});notice.show()};$('.or-dialog-content .or-view.or-view--is-dirty').removeClass('view--is-dirty');this.hide();$(document).unbind('keyup',this.escapeKeyClosingHandler)}};
-;class;View{constructor(action,method,id,params){this.action=action;this.method=method;this.id=id;this.params=params;this.onCloseHandler=new Callback();this.onChangeHandler=new Callback();this.onSaveHandler=new Callback()};before(){};start(element){this.before();this.element=element;return this.loadView()};afterLoad(){};close(){this.onCloseHandler.fire()};fireViewLoadedEvents(element){Workbench.afterViewLoadedHandler.fire(element)};loadView(){let url=View.createUrl(this.action,this.method,this.id,this.params,!1);let element=this.element;let view=this;let loadViewHtmlPromise=fetch(url,{});$(this.element).addClass('loader');console.debug(view);loadViewHtmlPromise.then(response=>{if(!response.ok)throw'failed to load the view';return response.text()}).then(data=>{if(!data)data='';$(element).html(data);$(element).find('form').each(function(){let form=new Form();form.onChangeHandler.add(()=>{view.onChangeHandler.fire()});form.onSaveHandler.add(()=>{view.onSaveHandler.fire()});form.onCloseHandler.add(()=>{view.close()});form.forwardTo=function(e,t,i,a){view.action=e;view.method=t;view.id=i;view.params=a;view.loadView()};form.initOnElement(this)});view.fireViewLoadedEvents(element)}).catch(cause=>{$(element).html('');console.error({view:view,url:url,cause:cause});let notice=new Notice();notice.setStatus('error');notice.msg=Workbench.language.ERROR;notice.log=cause;notice.show()});loadViewHtmlPromise.finally(()=>{$(element).removeClass('loader')});return loadViewHtmlPromise};static;createUrl(action,subaction,id,extraid={},api=!1){let url='./';if(api)url+='api/';url+='?';if(action)url+='&action='+action;if(subaction)url+='&subaction='+subaction;if(id)url+='&id='+id;if(extraid instanceof FormData){for(let pair of extraid.entries()){url+='&'+pair[0]+'='+pair[1]}}
-else if(extraid instanceof Object){Object.keys(extraid).forEach((key)=>{url+='&'+key+'='+extraid[key]})}
-else throw'Illegal argument';if(api)url+='&output=json';return url}};
-;class;Form{static;modes={showBrowserNotice:1,keepOpen:2,closeAfterSubmit:4,closeAfterSuccess:8,};constructor(){this.onChangeHandler=new Callback();this.onSaveHandler=new Callback();this.onCloseHandler=new Callback()};setLoadStatus(isLoading){$(this.element).closest('div.content').toggleClass('loader',isLoading)};initOnElement(element){this.element=element;let form=this;if($(this.element).data('autosave')){$(this.element).find('input[type="checkbox"]').click(function(){form.submit(Form.modes.keepOpen)});$(this.element).find('select').change(function(){form.submit(Form.modes.keepOpen)})};$(element).find('.or-act-form-cancel').click(function(){form.cancel()});$(element).find('.or-act-form-reset').click(function(){form.rollback()});$(element).find('.or-act-form-apply').click(function(){form.submit(Form.modes.keepOpen)});$(element).find('.or-act-form-save').click(function(){form.submit()});$(element).find('.or-input').change(function(){form.onChangeHandler.fire()});$(element).submit(function(e){if($(this).data('target')=='view'){form.submit();e.preventDefault()}})};cancel(){Notice.removeAllNotices();this.onCloseHandler.fire()};rollback(){this.element.trigger('reset')};forwardTo(action,subaction,id,data){};submit(mode){if(mode===undefined)if($(this.element).data('async'))mode=Form.modes.closeAfterSubmit;else mode=Form.modes.closeAfterSuccess;Notice.removeAllNotices();let status=new Notice();status.setStatus('info');status.inProgress();status.msg=Workbench.language.PROGRESS;status.show();$(this.element).find('.or-input--error').removeClass('input--error');let formData=new FormData($(this.element).get(0));if(!formData.has('id'))formData.append('id',Workbench.state.id);if(!formData.has('action'))formData.append('action',Workbench.state.action);let formMethod=$(this.element).attr('method').toUpperCase();if(formMethod=='GET'){this.forwardTo(formData.get('action'),formData.get('subaction'),formData.get('id,'),formData);$(status).remove()}
-else{let url='./api/';this.setLoadStatus(!0);url+='';formData.append('output','json');if(mode==Form.modes.closeAfterSubmit)this.onCloseHandler.fire();let form=this;console.debug(form);let load=fetch(url,{'method':'POST',body:formData});load.then(response=>{if(!response.ok)throw'Failed to post';return response.json()}).then(data=>{form.setLoadStatus(!1);status.close();form.doResponse(data,'',form.element,()=>{form.onSaveHandler.fire();let afterSuccess=$(form.element).data('afterSuccess');let forwardTo=$(form.element).data('forwardTo');let async=$(form.element).data('async');if(afterSuccess=='forward')mode=Form.modes.keepOpen;if(mode==Form.modes.closeAfterSuccess){form.onCloseHandler.fire();$(form.element).closest('div.panel').find('div.header ul.views li.action.active').removeClass('dirty')};if(afterSuccess){if(afterSuccess=='reloadAll'){Openrat.workbench.reloadAll()}
-else if(afterSuccess=='forward'){if(forwardTo)form.forwardTo(formData.get('action'),forwardTo,formData.get('id'),[])}}
-else{if(async);else Openrat.workbench.reloadViews()}})}).catch(cause=>{console.warn({message:'could not post form',cause:cause,form:form,});form.setLoadStatus(!1);status.close();let msg='';try{msg=JSON.parse(cause).message}catch(e$){msg=cause};let notice=new Notice();notice.setStatus('error');notice.msg=msg;notice.log=cause;notice.show()});$(form.element).fadeIn()}};doResponse=function(e,o,t,onSuccess=$.noop){let form=this;for(let value of e['notices']){let notifyBrowser=$(t).data('async');let notice=new Notice();notice.setContext(value.type,value.id,value.name);notice.log=value.log;notice.setStatus(value.status);notice.msg=value.text;notice.show();if(notifyBrowser)notice.notifyBrowser()};if(e.success){onSuccess();Workbench.dataChangedHandler.fire()};for(name of e['errors'])$('.or-input[name='+name+']').addClass('input--error').parent().addClass('input--error').parents('.or-group').removeClass('closed').addClass('show').addClass('open')}};
-;class;Workbench{'use strict';static;state={action:'',id:0,extra:{}};constructor(){this.popupWindow=null;Workbench.dataChangedHandler.add(function(){if(Workbench.popupWindow)Workbench.popupWindow.location.reload()})};initialize(){this.initializePingTimer();this.initializeDirtyWarning();this.initializeState();this.openModalDialog();Workbench.registerOpenClose($('.or-collapsible'));console.info('Application started')};initializeDirtyWarning(){window.addEventListener('beforeunload',function(e){if($('.or-view--is-dirty').length>0){e.preventDefault();return'Unsaved content will be lost.'}
-else{return undefined}})};openModalDialog(){if($('#dialog').data('action')){let dialog=new Dialog();dialog.start('',$('#dialog').data('action'),$('#dialog').data('action'),0,{})}};initializeState(){let parts=window.location.hash.split('/');let state={action:'index',id:0};if(parts.length>=2)state.action=parts[1].toLowerCase();if(parts.length>=3)state.id=parts[2].replace(/[^0-9_]/gim,'');Workbench.state=state;Openrat.navigator.toActualHistory(state)};initializePingTimer(){let ping=()=>{let url=View.createUrl('profile','ping',0,{},!0);let pingPromise=fetch(url);console.debug('ping');pingPromise.then(response=>{if(!response.ok)throw'ping failed'}).catch(cause=>{console.warn({message:'The server ping has failed.',cause:cause});if($('.or-view--is-dirty').length>0){window.alert('The server session is lost, please save your data.')}
-else{}})};let timeoutMinutes=5;window.setInterval(ping,timeoutMinutes*60*1000)};loadNewActionState(state){Workbench.state=state;this.loadNewAction(state.action,state.id,state.data);Workbench.afterNewActionHandler.fire()};static;afterNewActionHandler=new Callback();static;afterAllViewsLoaded=new Callback();loadNewAction=function(e,t,i){this.reloadViews()};reloadViews(){$('.or-workbench-section--is-closed .or-act-view-loader').empty();let promise=this.loadViews($('.or-workbench .or-act-view-loader'));promise.done(function(){Workbench.afterAllViewsLoaded.fire()});return promise};reloadAll(){let promise=this.loadViews($('.or-act-view-loader,.or-act-view-static').empty());console.debug('reloading all views');promise.done(function(){Workbench.afterAllViewsLoaded.fire()});this.loadUserStyle();this.loadLanguage();this.loadUISettings();return promise};loadUserStyle(){let url=View.createUrl('profile','userinfo',0,{},!0);let load=fetch(url);load.then(response=>response.json()).then(response=>{let style=response.output['style'];this.setUserStyle(style);let color=response.output['theme-color'];this.setThemeColor(color)})};static;settings={};static;language={};loadLanguage(){let url=View.createUrl('profile','language',0,{},!0);let load=fetch(url);load.then(response=>response.json()).then(response=>{Workbench.language=response.output.language})};loadUISettings(){let url=View.createUrl('profile','uisettings',0,{},!0);let load=fetch(url);load.then(response=>response.json()).then(response=>{Workbench.settings=response.output.settings.settings})};loadViews($views){let wb=this;let promises=[];$views.each(function(e){let $targetDOMElement=$(this);promises.push(wb.loadNewActionIntoElement($targetDOMElement))});return $.when.apply($,promises)};loadNewActionIntoElement($viewElement){let action;if($viewElement.is('.or-act-view-static'))action=$viewElement.attr('data-action');else action=Workbench.state.action;let id=Workbench.state.id;let params=Workbench.state.extra;let method=$viewElement.data('method');let view=new View(action,method,id,params);return view.start($viewElement)};setUserStyle(styleName){var html=$('html'),classList=html.attr('class').split(/\s+/);$.each(classList,function(e,t){if(t.startsWith('or-theme-')){html.removeClass(t.substring(3))}});html.addClass('theme-'+styleName.toLowerCase())};setThemeColor(color){document.getElementById('theme-color').setAttribute('content',color)};static;dataChangedHandler=new Callback();static;afterViewLoadedHandler=new Callback();static;setApplicationTitle(newTitle){let title=document.querySelector('head > title');let defaultTitle=title.dataset.default;title.textContent=(newTitle?newTitle+' - ':'')+defaultTitle};static;registerOpenClose=function(e){$(e).children('.or-collapsible-act-switch').click(function(){$(this).closest('.or-collapsible').toggleClass('collapsible--is-open').toggleClass('collapsible--is-closed')})};openNewAction(name,action,id){$('.or-workbench-navigation').removeClass('workbench-navigation--is-open');Workbench.setApplicationTitle(name);Openrat.navigator.navigateToNew({'action':action,'id':id})};registerDraggable(viewEl){$(viewEl).find('.or-draggable').draggable({helper:'clone',opacity:0.7,zIndex:3,distance:10,cursor:'move',revert:'false'})};registerDroppable(viewEl){$(viewEl).find('.or-droppable-selector').droppable({accept:'.or-draggable',hoverClass:'droppable--hover',activeClass:'droppable--active',drop:function(e,t){let dropped=t.draggable;console.info('dropped:');console.info(dropped);let id=$(dropped).find('.or-link').data('id');let name=$(dropped).find('.or-navtree-text').text();if(!name)name=id;$(this).find('.or-selector-link-value').val(id);$(this).find('.or-selector-link-name').val(name).attr('placeholder',name)}})};static;htmlDecode(input){let doc=new DOMParser().parseFromString(input,'text/html');return doc.documentElement.textContent}};
-;class;WorkbenchNavigator{'use strict';constructor(workbench){this.workbench=workbench};navigateTo(state){console.debug('Navigating to ',state);this.workbench.loadNewActionState(state)};navigateToNew(obj){this.navigateTo(obj);window.history.pushState(obj,obj.name,WorkbenchNavigator.createShortUrl(obj.action,obj.id))};toActualHistory(obj){window.history.replaceState(obj,obj.name,WorkbenchNavigator.createShortUrl(obj.action,obj.id))};static;createShortUrl(action,id){return'./#/'+action+(id?'/'+id:'')}};
-;document.addEventListener("DOMContentLoaded",event=>{$("html").removeClass("nojs");$(".or--initial-hidden").removeClass("-initial-hidden");function registerWorkbenchEvents(){};registerWorkbenchEvents();window.onpopstate=function(e){Openrat.navigator.navigateTo(e.state)};Openrat.workbench.initialize();Openrat.workbench.reloadAll();let registerWorkbenchGlobalEvents=function(){$(".keystroke").each(function(){let keystrokeElement=$(this);let keystroke=keystrokeElement.text();if(keystroke.length==0)return;let keyaction=function(){keystrokeElement.click()};$(document).bind("keydown",keystroke,keyaction)})};$(".or-act-initial-notice").each(function(){let notice=new Notice();notice.setStatus("info");notice.msg=$(this).text();notice.show();$(this).remove()});registerWorkbenchGlobalEvents();let closeMenu=function(){$("body").click(function(){$(".or-menu").removeClass("menu--is-open")})};closeMenu();let closeMobileNavigation=function(){$(".or-act-navigation-close").click(function(){$(".or-workbench-navigation").removeClass("workbench-navigation--is-open");$(".or-workbench").removeClass("workbench--navigation-is-open")})};closeMobileNavigation();let closeDesktopNavigation=function(){$(".or-workbench-title .or-act-nav-small").click(function(){$(".or-workbench").addClass("workbench--navigation-is-small");$(".or-workbench-navigation").addClass("workbench-navigation--is-small")})};closeDesktopNavigation();let registerGlobalSearch=function(){$(".or-search-input .or-input").orSearch({onSearchActive:function(){$(".or-search").addClass("search--is-active")},onSearchInactive:function(){$(".or-search").removeClass("search--is-active")},dropdown:".or-act-search-result",resultEntryClass:"or-search-result-entry",select:function(e){Workbench.openNewAction(e.name,e.action,e.id)},afterSelect:function(){}});$(".or-search .or-act-search-delete").click(function(){$(".or-search .or-title-input").val("").change()})};registerGlobalSearch();Workbench.afterNewActionHandler.add(function(){$(".or-sidebar").find(".or-sidebar-button").orLinkify()});Workbench.afterNewActionHandler.add(function(){let url=View.createUrl("tree","path",Workbench.state.id,{"type":Workbench.state.action});let loadPromise=fetch(url);function e(e,t){let $navControl=$(".or-link[data-action="+e+"][data-id="+t+"]").closest(".or-navtree-node");if($navControl.is(".or-navtree-node--is-closed"))$navControl.find(".or-navtree-node-control").click()};loadPromise.then(response=>response.text()).then(data=>{$(".or-breadcrumb").empty().append(data).find(".or-act-clickable").orLinkify();$(".or-breadcrumb a").each(function(){let action=$(this).data("action");let id=$(this).data("id");e(action,id)});$(".or-link--is-active").removeClass("link--is-active");let action=Workbench.state.action;let id=Workbench.state.id;if(!id)id="0";$(".or-link[data-action='"+action+"'][data-id='"+id+"']").addClass("link--is-active");e(action,id)}).catch(cause=>{console.warn({message:"Failed to load path",url:url,cause:cause})}).finally(function(){})});Workbench.afterNewActionHandler.fire()});let filterMenus=function(){let action=Workbench.state.action;let id=Workbench.state.id;$(".or-workbench-title .or-dropdown-entry.or-act-clickable").addClass("dropdown-entry--active");$(".or-workbench-title .or-filtered").removeClass("dropdown-entry--active").addClass("dropdown-entry--inactive");$(".or-workbench-title .or-filtered .or-link").attr("data-id",id);let url=View.createUrl("profile","available",id,{"queryaction":action},!0);let promise=fetch(url);promise.then(response=>response.json()).then((data)=>{for(let method of Object.values(data.output.views))$(".or-workbench-title .or-filtered > .or-link[data-method='"+method+"']").parent().addClass("dropdown-entry--active").removeClass("dropdown-entry--inactive")})};Workbench.afterAllViewsLoaded.add(function(){filterMenus()});Workbench.afterAllViewsLoaded.add(function(){$("body").removeClass("loader")});Workbench.afterViewLoadedHandler.add(function(e){$(e).find(".or-button").orButton()});Workbench.afterViewLoadedHandler.add(function(e){if(Workbench.popupWindow)$(e).find("a[data-type='popup']").each(function(){Workbench.popupWindow.location.href=$(this).attr("data-url")})});Workbench.afterViewLoadedHandler.add(function(e){$(e).find(".or-input--password").dblclick(function(){$(this).toggleAttr("type","text","password")});$(e).find(".or-act-make-visible").click(function(){$(this).toggleClass("btn--is-active");$(this).parent().children("input").toggleAttr("type","text","password")})});Workbench.afterViewLoadedHandler.add(function(e){e.find(".or-act-load-nav-tree").each(function(){let type=$(this).data("type")||"root";let loadBranchUrl="./?action=tree&subaction=branch&id=0&type="+type;let $targetElement=$(this);let load=fetch(loadBranchUrl);load.then(response=>response.text()).then(html=>{let $ul=$("<ul class=\"or-navtree-list\" />");$ul.appendTo($targetElement.empty()).append(html);$ul.find("li").orTree({"openAction":function(e,t,o){Openrat.workbench.openNewAction(e,t,o)}});$ul.find(".or-act-clickable").orLinkify();$ul.find(".or-navtree-node-control").first().click()})})});Workbench.afterViewLoadedHandler.add(function(e){var o=$(e).closest("section");o.toggleClass("is-empty",$(e).is(":empty"));$(e).find(".or-act-nav-open-close").click(function(){$(".or-workbench").toggleClass("workbench--navigation-is-open");$(".or-workbench-navigation").toggleClass("workbench-navigation--is-open")});$(e).find(".or-act-nav-small").click(function(){$(".or-workbench").addClass("workbench--navigation-is-small");$(".or-workbench-navigation").addClass("workbench-navigation--is-small")});$(e).find(".or-act-nav-wide").click(function(){$(".or-workbench").removeClass("workbench--navigation-is-small");$(".or-workbench-navigation").removeClass("workbench-navigation--is-small")});$(e).find(".or-act-selector-tree-button").click(function(){let $selector=$(this).parent(".or-selector");let $targetElement=$selector.find(".or-act-load-selector-tree");if($selector.hasClass("selector--is-tree-active")){$selector.removeClass("selector--is-tree-active");$targetElement.empty()}
-else{$selector.addClass("selector--is-tree-active");var e=this;let id=$(this).data("init-folder-id");let type=id?"folder":"projects";let loadBranchUrl="./?action=tree&subaction=branch&id="+id+"&type="+type;let load=fetch(loadBranchUrl);load.then(response=>response.text()).then(html=>{let $ul=$("<ul class=\"or-navtree-list\" />");$ul.appendTo($targetElement).append(html);$ul.find("li").orTree({"openAction":function(e,t,o){$selector.find(".or-selector-link-value").val(o);$selector.find(".or-selector-link-name").val("").attr("placeholder",e);$selector.removeClass("selector--is-tree-active");$targetElement.empty()}});$ul.find(".or-act-clickable").orLinkify();$ul.find(".or-navtree-node-control").first().click()})}});t(e);$(e).find(".or-theme-chooser").change(function(){Openrat.workbench.setUserStyle(this.value)});function n(e){$(e).find(".or-menu-category").click(function(e){e.stopPropagation();$(this).parents(".or-menu").toggleClass("menu--is-open")});$(e).find(".or-menu-category").mouseover(function(){$(this).parents(".or-menu").find(".or-menu-category").removeClass("menu-category--is-open");$(this).addClass("menu-category--is-open")})};function r(e){$(e).find(".or-act-selector-search").orSearch({onSearchActive:function(){$(this).parent("or-selector").addClass("selector-search--is-active")},onSearchInactive:function(){$(this).parent("or-selector").removeClass("selector-search--is-active")},dropdown:".or-act-selector-search-results",resultEntryClass:"or-search-result-entry",select:function(t){$(e).find(".or-selector-link-value").val(t.id);$(e).find(".or-selector-link-name").val(t.name).attr("placeholder",t.name)},afterSelect:function(){$(".or-dropdown.or-act-selector-search-results").empty()}})};function a(e){};n(e);r(e);a(e);function t(e){Openrat.workbench.registerDraggable(e);Openrat.workbench.registerDroppable(e)};t(e)});
-;let workbench=new Workbench();window.Openrat={workbench:workbench,navigator:new WorkbenchNavigator(workbench)};let originalAddClass=jQuery.fn.addClass;jQuery.fn.addClass=function(a){return originalAddClass.call(this,'or-'+a)};let originalRemoveClass=jQuery.fn.removeClass;jQuery.fn.removeClass=function(a){return originalRemoveClass.call(this,'or-'+a)};let originalHasClass=jQuery.fn.hasClass;jQuery.fn.hasClass=function(a){return originalHasClass.call(this,'or-'+a)};
;Workbench.afterViewLoadedHandler.add(function(d){});
;Workbench.afterViewLoadedHandler.add(function(e){$(e).find('textarea').orAutoheight();$(e).find('textarea.or-editor.or-code-editor').each(function(){let mode=$(this).data('mode');let mimetype=$(this).data('mimetype');if(mimetype.length>0)mode=mimetype;let textareaEl=this;let editor=CodeMirror.fromTextArea(textareaEl,{lineNumbers:!0,viewportMargin:Infinity,mode:mode});editor.on('change',function(){let newValue=editor.getValue();$(textareaEl).val(newValue)});$(editor.getWrapperElement()).droppable({accept:'.or-draggable',hoverClass:'or-droppable--hover',activeClass:'or-droppable--active',drop:function(e,t){let dropped=t.draggable;let pos=editor.getCursor();editor.setSelection(pos,pos);let insertText=dropped.data('id');let toInsert=''+insertText;editor.replaceSelection(toInsert)}})});$(e).find('textarea.or-editor.or-markdown-editor').each(function(){let textarea=this;let toolbar=[{name:'bold',action:SimpleMDE.toggleBold,className:'image-icon image-icon--editor-bold',title:'Bold',},{name:'italic',action:SimpleMDE.toggleItalic,className:'image-icon image-icon--editor-italic',title:'Italic',},{name:'heading',action:SimpleMDE.toggleHeadingBigger,className:'image-icon image-icon--editor-headline',title:'Headline',},'|',{name:'quote',action:SimpleMDE.toggleBlockquote,className:'image-icon image-icon--editor-quote',title:'Quote',},{name:'code',action:SimpleMDE.toggleCodeBlock,className:'image-icon image-icon--editor-code',title:'Code',},'|',{name:'generic list',action:SimpleMDE.toggleUnorderedList,className:'image-icon image-icon--editor-unnumberedlist',title:'Unnumbered list',},{name:'numbered list',action:SimpleMDE.toggleOrderedList,className:'image-icon image-icon--editor-numberedlist',title:'Numbered list',},'|',{name:'table',action:SimpleMDE.drawTable,className:'image-icon image-icon--editor-table',title:'Table',},{name:'horizontalrule',action:SimpleMDE.drawHorizontalRule,className:'image-icon image-icon--editor-horizontalrule',title:'Horizontal rule',},'|',{name:'undo',action:SimpleMDE.undo,className:'image-icon image-icon--editor-undo',title:'Undo',},{name:'redo',action:SimpleMDE.redo,className:'image-icon image-icon--editor-redo',title:'Redo',},'|',{name:'link',action:SimpleMDE.drawLink,className:'image-icon image-icon--editor-link',title:'Link',},{name:'image',action:SimpleMDE.drawImage,className:'image-icon image-icon--editor-image',title:'Image',},'|',{name:'guide',action:'https://simplemde.com/markdown-guide',className:'image-icon image-icon--editor-help',title:'Howto markdown',},];let mde=new SimpleMDE({element:$(this)[0],toolbar:toolbar,autoDownloadFontAwesome:!1});let codemirror=mde.codemirror;$(codemirror.getWrapperElement()).droppable({accept:'.or-draggable',hoverClass:'or-droppable--hover',activeClass:'or-droppable--active',drop:function(e,t){let dropped=t.draggable;let insertText='';let id=dropped.data('id');let url='__OID__'+id+'__';if(dropped.data('type')=='image')insertText='';else insertText='['+id+']('+url+')';let pos=codemirror.getCursor();codemirror.setSelection(pos,pos);codemirror.replaceSelection(insertText)}});codemirror.on('change',function(){let newValue=codemirror.getValue();$(textarea).val(newValue)})});$(e).find('textarea.or-editor.or-html-editor').each(function(){let textarea=this;$.trumbowyg.svgPath='./modules/editor/trumbowyg/ui/icons.svg';$(textarea).trumbowyg();$(textarea).closest('form').find('.trumbowyg-editor').droppable({accept:'.or-draggable',hoverClass:'or-droppable--hover',activeClass:'or-droppable--active',drop:function(e,t){let dropped=t.draggable;let id=dropped.data('id');let url='./?_='+dropped.data('type')+'-'+id+'&subaction=show&embed=1&__OID__'+id+'__='+id;let insertText='';if(dropped.data('type')=='image')insertText='<img src="'+url+'" alt="" />';else insertText='<a href="'+url+'" />'+id+'</a>';$(textarea).trumbowyg('execCmd',{cmd:'insertHTML',param:insertText,forceCss:!1,})}})})});
;Workbench.afterViewLoadedHandler.add(function(e){Workbench.registerOpenClose($(e).find('.or-collapsible.or-group'))});
diff --git a/modules/cms/ui/themes/default/script/openrat/callback.js b/modules/cms/ui/themes/default/script/openrat/callback.js
@@ -1,4 +1,4 @@
-class Callback {
+export default class Callback {
constructor() {
this.list = [];
diff --git a/modules/cms/ui/themes/default/script/openrat/dialog.js b/modules/cms/ui/themes/default/script/openrat/dialog.js
@@ -1,7 +1,10 @@
+import $ from '../jquery.min.js';
+import View from './view.js';
+
/**
* The encapsulated view.
*/
-class Dialog {
+export default class Dialog {
/**
* A dialog is a special area in the workbench for displaying and inputting data.
diff --git a/modules/cms/ui/themes/default/script/openrat/form.js b/modules/cms/ui/themes/default/script/openrat/form.js
@@ -1,9 +1,11 @@
+import $ from '../jquery.min.js';
+
/**
* Form.
*
* @constructor
*/
-class Form {
+export default class Form {
static modes = {
showBrowserNotice : 1,
diff --git a/modules/cms/ui/themes/default/script/openrat/init.js b/modules/cms/ui/themes/default/script/openrat/init.js
@@ -1,4 +1,7 @@
+import jQuery from '../jquery.min.js';
+import Workbench from './workbench.js';
+import WorkbenchNavigator from './navigator.js';
// Create own namespace.
let workbench = new Workbench();
diff --git a/modules/cms/ui/themes/default/script/openrat/navigator.js b/modules/cms/ui/themes/default/script/openrat/navigator.js
@@ -1,7 +1,7 @@
/**
* Navigation.
*/
-class WorkbenchNavigator {
+export default class WorkbenchNavigator {
'use strict';
constructor( workbench ) {
diff --git a/modules/cms/ui/themes/default/script/openrat/notice.js b/modules/cms/ui/themes/default/script/openrat/notice.js
@@ -1,8 +1,10 @@
+import $ from '../jquery.min.js';
+import Workbench from './workbench.js';
/**
* Notice.
*/
-class Notice {
+export default class Notice {
'use strict';
diff --git a/modules/cms/ui/themes/default/script/openrat/view.js b/modules/cms/ui/themes/default/script/openrat/view.js
@@ -1,3 +1,7 @@
+import $ from '../jquery.min.js';
+import Workbench from './workbench.js';
+import Callback from "./callback.js";
+
/**
* View.
* A view is a part of the page. An Action is loaded into this view.
@@ -8,7 +12,7 @@
* @param params
* @constructor
*/
-class View {
+export default class View {
constructor( action,method,id,params ) {
this.action = action;
diff --git a/modules/cms/ui/themes/default/script/openrat/workbench.js b/modules/cms/ui/themes/default/script/openrat/workbench.js
@@ -1,6 +1,9 @@
+import $ from '../jquery.min.js';
+import Dialog from './dialog.js';
+import Callback from './callback.js';
-class Workbench {
+export default class Workbench {
'use strict'; // Strict mode
static state = {