openrat-cms

# OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs

commit 8830f4cd608fa06ea759b95799f37276781a4123
parent d0b77e3615faac4a8e320a53652013b87d405b6a
Author: Jan Dankert <develop@jandankert.de>
Date:   Mon, 14 Oct 2019 23:11:15 +0200

New: Namespacing all javascript classes.

Diffstat:
modules/cms-ui/themes/default/production/combined.min.js | 485++++---------------------------------------------------------------------------
modules/cms-ui/themes/default/script/openrat/common.js | 582+++++++++++++++++++++++--------------------------------------------------------
modules/cms-ui/themes/default/script/openrat/common.min.js | 16+++++++---------
modules/cms-ui/themes/default/script/openrat/form.js | 10+++++-----
modules/cms-ui/themes/default/script/openrat/form.min.js | 155++-----------------------------------------------------------------------------
modules/cms-ui/themes/default/script/openrat/init.js | 2+-
modules/cms-ui/themes/default/script/openrat/init.min.js | 6++----
modules/cms-ui/themes/default/script/openrat/navigator.js | 17+++++------------
modules/cms-ui/themes/default/script/openrat/navigator.min.js | 42++----------------------------------------
modules/cms-ui/themes/default/script/openrat/view.js | 9+++------
modules/cms-ui/themes/default/script/openrat/view.min.js | 82++-----------------------------------------------------------------------------
modules/cms-ui/themes/default/script/openrat/workbench.js | 144++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
modules/cms-ui/themes/default/script/openrat/workbench.min.js | 174++-----------------------------------------------------------------------------
modules/cms-ui/themes/default/script/plugin/jquery-plugin-orLinkify.js | 9++-------
modules/cms-ui/themes/default/script/plugin/jquery-plugin-orLinkify.min.js | 4++--
modules/cms-ui/themes/default/script/plugin/jquery-plugin-orTree.js | 2+-
modules/cms-ui/themes/default/script/plugin/jquery-plugin-orTree.min.js | 4++--
modules/template-engine/components/html/form/form.js | 9++++-----
modules/template-engine/components/html/form/form.min.js | 8++++----
modules/template-engine/components/html/upload/upload.js | 2+-
modules/template-engine/components/html/upload/upload.min.js | 4++--
21 files changed, 374 insertions(+), 1392 deletions(-)

diff --git a/modules/cms-ui/themes/default/production/combined.min.js b/modules/cms-ui/themes/default/production/combined.min.js @@ -275,11 +275,11 @@ else{return{top:0,left:0}}},_cacheMargins:function(){this.margins={left:(parseIn else{this.currentItem.show()};if(this.fromOutside&&!e){s.push(function(t){this._trigger("receive",t,this._uiHash(this.fromOutside))})};if((this.fromOutside||this.domPosition.prev!==this.currentItem.prev().not(".ui-sortable-helper")[0]||this.domPosition.parent!==this.currentItem.parent()[0])&&!e){s.push(function(t){this._trigger("update",t,this._uiHash())})};if(this!==this.currentContainer){if(!e){s.push(function(t){this._trigger("remove",t,this._uiHash())});s.push((function(t){return function(e){t._trigger("receive",e,this._uiHash(this))}}).call(this,this.currentContainer));s.push((function(t){return function(e){t._trigger("update",e,this._uiHash(this))}}).call(this,this.currentContainer))}};function o(t,e,i){return function(s){i._trigger(t,s,e._uiHash(e))}};for(i=this.containers.length-1;i>=0;i--){if(!e){s.push(o("deactivate",this,this.containers[i]))};if(this.containers[i].containerCache.over){s.push(o("out",this,this.containers[i]));this.containers[i].containerCache.over=0}};if(this.storedCursor){this.document.find("body").css("cursor",this.storedCursor);this.storedStylesheet.remove()};if(this._storedOpacity){this.helper.css("opacity",this._storedOpacity)};if(this._storedZIndex){this.helper.css("zIndex",this._storedZIndex==="auto"?"":this._storedZIndex)};this.dragging=!1;if(!e){this._trigger("beforeStop",t,this._uiHash())};this.placeholder[0].parentNode.removeChild(this.placeholder[0]);if(!this.cancelHelperRemoval){if(this.helper[0]!==this.currentItem[0]){this.helper.remove()};this.helper=null};if(!e){for(i=0;i<s.length;i++){s[i].call(this,t)};this._trigger("stop",t,this._uiHash())};this.fromOutside=!1;return!this.cancelHelperRemoval},_trigger:function(){if(t.Widget.prototype._trigger.apply(this,arguments)===!1){this.cancel()}},_uiHash:function(e){var i=e||this;return{helper:i.helper,placeholder:i.placeholder||t([]),position:i.position,originalPosition:i.originalPosition,offset:i.positionAbs,item:i.currentItem,sender:e?e.element:null}}})})); /* ./modules/cms-ui/themes/default/script/plugin/jquery-plugin-orSearch.min.js */;jQuery.fn.orSearch=function(e){var t=$.extend({'dropdown':'unknown'},e);return $(this).keyup(function(){let searchArgument=$(this).val();if(searchArgument.length>3){$(t.dropdown).empty();$.ajax({'type':'GET',url:'./api/?action=search&subaction=quicksearch&output=json&search='+searchArgument,data:null,success:function(e,a,n){for(id in e.output.result){let result=e.output.result[id];let div=$('<div class="entry clickable" title="'+result.desc+'"></div>');let link=$('<a href="./?action='+result.type+'&id='+result.id+'"></a>');$(link).attr('data-type','open').attr('data-name',result.name).attr('data-action',result.type).attr('data-id',result.id).attr('data-extra','[]');$(link).append('<i class="image-icon image-icon--action-'+result.type+'" />');$(link).append('<span>'+result.name+'</span>');$(div).append(link);$(t.dropdown).append(div)};$(t.dropdown).closest('.or-menu').addClass('open');$(t.dropdown).find('.clickable').orLinkify()}})} else{$(t.dropdown).empty()}})}; -/* ./modules/cms-ui/themes/default/script/plugin/jquery-plugin-orLinkify.min.js */;var popupWindow;jQuery.fn.orLinkify=function(){$(this).find("a").click(function(t){t.preventDefault()});return $(this).click(function(){$(this).find("a").first().each(function(){let type=$(this).attr("data-type");if($(this).parent().hasClass("inactive"))return;switch(type){case"post":submitLink(this,$(this).attr("data-data"));break;case"dialog":startDialog($(this).attr("data-name"),$(this).attr("data-action"),$(this).attr("data-method"),$(this).attr("data-id"),$(this).attr("data-extra"));break;case"edit":startEdit($(this).attr("data-name"),$(this).attr("data-action"),$(this).attr("data-method"),$(this).attr("data-id"),$(this).attr("data-extra"));break;case"url":throw"probably unused, isn't it?";submitUrl(this,$(this).attr("data-url"));break;case"external":window.open($(this).attr("data-url")," _blank");break;case"popup":popupWindow=window.open($(this).attr("data-url"),"Popup","location=no,menubar=no,scrollbars=yes,toolbar=no,resizable=yes");break;case"help":help(this,$(this).attr("data-url"),$(this).attr("data-suffix"));break;case"fullscreen":fullscreen(this);break;case"open":openNewAction($(this).attr("data-name"),$(this).attr("data-action"),$(this).attr("data-id"),jQuery.parseJSON($(this).attr("data-extra").replace(/'/g,"\"")));break;default:alert("Fatal: Cannot open link: "+$(this).html())}})})};$(document).on("orViewLoaded",function(t,a){if(typeof popupWindow!="undefined")$(t.target).find("a[data-type='popup']").each(function(){popupWindow.location.href=$(this).attr("data-url")})});$(document).on("orDataChanged",function(t,a){if(typeof popupWindow!="undefined")popupWindow.location.reload()}); +/* ./modules/cms-ui/themes/default/script/plugin/jquery-plugin-orLinkify.min.js */;var popupWindow;jQuery.fn.orLinkify=function(){$(this).find("a").click(function(t){t.preventDefault()});return $(this).click(function(){$(this).find("a").first().each(function(){let type=$(this).attr("data-type");if($(this).parent().hasClass("inactive"))return;switch(type){case"post":submitLink(this,$(this).attr("data-data"));break;case"dialog":startDialog($(this).attr("data-name"),$(this).attr("data-action"),$(this).attr("data-method"),$(this).attr("data-id"),$(this).attr("data-extra"));break;case"edit":startEdit($(this).attr("data-name"),$(this).attr("data-action"),$(this).attr("data-method"),$(this).attr("data-id"),$(this).attr("data-extra"));break;case"external":window.open($(this).attr("data-url")," _blank");break;case"popup":popupWindow=window.open($(this).attr("data-url"),"Popup","location=no,menubar=no,scrollbars=yes,toolbar=no,resizable=yes");break;case"help":help(this,$(this).attr("data-url"),$(this).attr("data-suffix"));break;case"fullscreen":fullscreen(this);break;case"open":openNewAction($(this).attr("data-name"),$(this).attr("data-action"),$(this).attr("data-id"));break;default:throw"UI error: Unknown link type: "+type+" in link "+$(this).html()}})})};$(document).on("orViewLoaded",function(t,a){if(typeof popupWindow!="undefined")$(t.target).find("a[data-type='popup']").each(function(){popupWindow.location.href=$(this).attr("data-url")})});$(document).on("orDataChanged",function(t,a){if(typeof popupWindow!="undefined")popupWindow.location.reload()}); /* ./modules/cms-ui/themes/default/script/plugin/jquery-plugin-orTree.min.js */;jQuery.fn.orTree=function(){$(this).each(function(a,e){$(e).children('.or-navtree-node-control').click(function(){var a=$(this).parent('.or-navtree-node');if($(a).is('.or-navtree-node--is-open')){$(a).children('ul').slideUp('fast').remove();$(a).removeClass('or-navtree-node--is-open').addClass('or-navtree-node--is-closed').find('.tree-icon').removeClass('image-icon--node-open').addClass('image-icon--node-closed')} else{$(e).closest('div.view').addClass('loader');var o=$(a).data('type'),t=$(a).data('id'),i=$(a).data('extra'),n='./api/?action=tree&subaction=loadBranch&id='+t+'&type='+o+'&output=json';if(typeof i==='string'){jQuery.each(jQuery.parseJSON(i.replace(/'/g,'"')),function(e,a){n=n+'&'+e+'='+a})} else if(typeof i==='object'){jQuery.each(i,function(e,a){n=n+'&'+e+'='+a})} -else{};$.getJSON(n,function(a){let ul=$('<ul class="or-navtree-list" />');$(e).append(ul);let output=a['output'];$.each(output['branch'],function(a,e){let new_li=$('<li class="or-navtree-node or-navtree-node--is-closed or-draggable or-draggable--type-'+e.type+'" data-id="'+e.internalId+'" data-type="'+e.type+'" data-extra="'+JSON.stringify(e.extraId).replace(/"/g,'\'')+'"><div class="tree or-navtree-node-control"><i class="tree-icon image-icon image-icon--node-closed"></i></div><div class="clickable"><a href="./#/'+e.action+(e.internalId!='0'?'/'+e.internalId:'')+'" class="entry" data-extra="'+JSON.stringify(e.extraId).replace(/"/g,'\'')+'" data-id="'+e.internalId+'" data-action="'+e.action+'" data-type="open" title="'+e.description+'"><i class="image-icon image-icon--action-'+e['icon']+'"></i> '+e.text+'</a></div></li>');$(ul).append(new_li);$(new_li).orTree();$(new_li).find('.clickable').orLinkify();$(new_li).find('.clickable a').click(function(e){e.preventDefault()});registerTreeBranchEvents(ul)});$(ul).slideDown('fast')}).fail(function(){notify('','','ERROR','failed to load subtree',[])}).always(function(){$(e).closest('div.view').removeClass('loader')});$(a).addClass('or-navtree-node--is-open').removeClass('or-navtree-node--is-closed').find('.tree-icon').addClass('image-icon--node-open').removeClass('image-icon--node-closed')}})})}; +else{};$.getJSON(n,function(a){let ul=$('<ul class="or-navtree-list" />');$(e).append(ul);let output=a['output'];$.each(output['branch'],function(a,e){let new_li=$('<li class="or-navtree-node or-navtree-node--is-closed or-draggable or-draggable--type-'+e.type+'" data-id="'+e.internalId+'" data-type="'+e.type+'" data-extra="'+JSON.stringify(e.extraId).replace(/"/g,'\'')+'"><div class="tree or-navtree-node-control"><i class="tree-icon image-icon image-icon--node-closed"></i></div><div class="clickable"><a href="./#/'+e.action+(e.internalId!='0'?'/'+e.internalId:'')+'" class="entry" data-extra="'+JSON.stringify(e.extraId).replace(/"/g,'\'')+'" data-id="'+e.internalId+'" data-action="'+e.action+'" data-type="open" title="'+e.description+'"><i class="image-icon image-icon--action-'+e['icon']+'"></i> '+e.text+'</a></div></li>');$(ul).append(new_li);$(new_li).orTree();$(new_li).find('.clickable').orLinkify();$(new_li).find('.clickable a').click(function(e){e.preventDefault()});registerTreeBranchEvents(ul)});$(ul).slideDown('fast')}).fail(function(){Openrat.Workbench.notify('','','ERROR','failed to load subtree',[],!1)}).always(function(){$(e).closest('div.view').removeClass('loader')});$(a).addClass('or-navtree-node--is-open').removeClass('or-navtree-node--is-closed').find('.tree-icon').addClass('image-icon--node-open').removeClass('image-icon--node-closed')}})})}; /* ./modules/cms-ui/themes/default/script/plugin/jquery-plugin-orAutoheight.min.js */;jQuery.fn.orAutoheight=function(){var t=function(t){var n=$(t).val().split('\n').length;$(t).attr('rows',n+3)};$(this).each(function(n){t(this)});return $(this).keypress(function(){t(this)})}; /* ./modules/cms-ui/themes/default/script/jquery-qrcode.min.js *//*! jquery-qrcode v0.14.0 - https://larsjung.de/jquery-qrcode/ */ !function(r){"use strict";function t(t,e,n,o){function a(r,t){return r-=o,t-=o,0>r||r>=c||0>t||t>=c?!1:f.isDark(r,t)}function i(r,t,e,n){var o=u.isDark,a=1/l;u.isDark=function(i,u){var f=u*a,c=i*a,l=f+a,g=c+a;return o(i,u)&&(r>l||f>e||t>g||c>n)}}var u={},f=r(n,e);f.addData(t),f.make(),o=o||0;var c=f.getModuleCount(),l=f.getModuleCount()+2*o;return u.text=t,u.level=e,u.version=n,u.moduleCount=l,u.isDark=a,u.addBlank=i,u}function e(r,e,n,o,a){n=Math.max(1,n||1),o=Math.min(40,o||40);for(var i=n;o>=i;i+=1)try{return t(r,e,i,a)}catch(u){}}function n(r,t,e){var n=e.size,o="bold "+e.mSize*n+"px "+e.fontname,a=w("<canvas/>")[0].getContext("2d");a.font=o;var i=a.measureText(e.label).width,u=e.mSize,f=i/n,c=(1-f)*e.mPosX,l=(1-u)*e.mPosY,g=c+f,s=l+u,v=.01;1===e.mode?r.addBlank(0,l-v,n,s+v):r.addBlank(c-v,l-v,g+v,s+v),t.fillStyle=e.fontcolor,t.font=o,t.fillText(e.label,c*n,l*n+.75*e.mSize*n)}function o(r,t,e){var n=e.size,o=e.image.naturalWidth||1,a=e.image.naturalHeight||1,i=e.mSize,u=i*o/a,f=(1-u)*e.mPosX,c=(1-i)*e.mPosY,l=f+u,g=c+i,s=.01;3===e.mode?r.addBlank(0,c-s,n,g+s):r.addBlank(f-s,c-s,l+s,g+s),t.drawImage(e.image,f*n,c*n,u*n,i*n)}function a(r,t,e){w(e.background).is("img")?t.drawImage(e.background,0,0,e.size,e.size):e.background&&(t.fillStyle=e.background,t.fillRect(e.left,e.top,e.size,e.size));var a=e.mode;1===a||2===a?n(r,t,e):(3===a||4===a)&&o(r,t,e)}function i(r,t,e,n,o,a,i,u){r.isDark(i,u)&&t.rect(n,o,a,a)}function u(r,t,e,n,o,a,i,u,f,c){i?r.moveTo(t+a,e):r.moveTo(t,e),u?(r.lineTo(n-a,e),r.arcTo(n,e,n,o,a)):r.lineTo(n,e),f?(r.lineTo(n,o-a),r.arcTo(n,o,t,o,a)):r.lineTo(n,o),c?(r.lineTo(t+a,o),r.arcTo(t,o,t,e,a)):r.lineTo(t,o),i?(r.lineTo(t,e+a),r.arcTo(t,e,n,e,a)):r.lineTo(t,e)}function f(r,t,e,n,o,a,i,u,f,c){i&&(r.moveTo(t+a,e),r.lineTo(t,e),r.lineTo(t,e+a),r.arcTo(t,e,t+a,e,a)),u&&(r.moveTo(n-a,e),r.lineTo(n,e),r.lineTo(n,e+a),r.arcTo(n,e,n-a,e,a)),f&&(r.moveTo(n-a,o),r.lineTo(n,o),r.lineTo(n,o-a),r.arcTo(n,o,n-a,o,a)),c&&(r.moveTo(t+a,o),r.lineTo(t,o),r.lineTo(t,o-a),r.arcTo(t,o,t+a,o,a))}function c(r,t,e,n,o,a,i,c){var l=r.isDark,g=n+a,s=o+a,v=e.radius*a,h=i-1,d=i+1,w=c-1,m=c+1,y=l(i,c),T=l(h,w),p=l(h,c),B=l(h,m),A=l(i,m),E=l(d,m),k=l(d,c),M=l(d,w),C=l(i,w);y?u(t,n,o,g,s,v,!p&&!C,!p&&!A,!k&&!A,!k&&!C):f(t,n,o,g,s,v,p&&C&&T,p&&A&&B,k&&A&&E,k&&C&&M)}function l(r,t,e){var n,o,a=r.moduleCount,u=e.size/a,f=i;for(e.radius>0&&e.radius<=.5&&(f=c),t.beginPath(),n=0;a>n;n+=1)for(o=0;a>o;o+=1){var l=e.left+o*u,g=e.top+n*u,s=u;f(r,t,e,l,g,s,n,o)}if(w(e.fill).is("img")){t.strokeStyle="rgba(0,0,0,0.5)",t.lineWidth=2,t.stroke();var v=t.globalCompositeOperation;t.globalCompositeOperation="destination-out",t.fill(),t.globalCompositeOperation=v,t.clip(),t.drawImage(e.fill,0,0,e.size,e.size),t.restore()}else t.fillStyle=e.fill,t.fill()}function g(r,t){var n=e(t.text,t.ecLevel,t.minVersion,t.maxVersion,t.quiet);if(!n)return null;var o=w(r).data("qrcode",n),i=o[0].getContext("2d");return a(n,i,t),l(n,i,t),o}function s(r){var t=w("<canvas/>").attr("width",r.size).attr("height",r.size);return g(t,r)}function v(r){return w("<img/>").attr("src",s(r)[0].toDataURL("image/png"))}function h(r){var t=e(r.text,r.ecLevel,r.minVersion,r.maxVersion,r.quiet);if(!t)return null;var n,o,a=r.size,i=r.background,u=Math.floor,f=t.moduleCount,c=u(a/f),l=u(.5*(a-c*f)),g={position:"relative",left:0,top:0,padding:0,margin:0,width:a,height:a},s={position:"absolute",padding:0,margin:0,width:c,height:c,"background-color":r.fill},v=w("<div/>").data("qrcode",t).css(g);for(i&&v.css("background-color",i),n=0;f>n;n+=1)for(o=0;f>o;o+=1)t.isDark(n,o)&&w("<div/>").css(s).css({left:l+o*c,top:l+n*c}).appendTo(v);return v}function d(r){return m&&"canvas"===r.render?s(r):m&&"image"===r.render?v(r):h(r)}var w=window.jQuery,m=function(){var r=document.createElement("canvas");return!(!r.getContext||!r.getContext("2d"))}(),y={render:"canvas",minVersion:1,maxVersion:40,ecLevel:"L",left:0,top:0,size:200,fill:"#000",background:null,text:"no text",radius:0,quiet:0,mode:0,mSize:.1,mPosX:.5,mPosY:.5,label:"no label",fontname:"sans",fontcolor:"#000",image:null};w.fn.qrcode=function(r){var t=w.extend({},y,r);return this.each(function(r,e){"canvas"===e.nodeName.toLowerCase()?g(e,t):w(e).append(d(t))})}}(function(){var r=function(){function r(t,e){if("undefined"==typeof t.length)throw new Error(t.length+"/"+e);var n=function(){for(var r=0;r<t.length&&0==t[r];)r+=1;for(var n=new Array(t.length-r+e),o=0;o<t.length-r;o+=1)n[o]=t[o+r];return n}(),o={};return o.getAt=function(r){return n[r]},o.getLength=function(){return n.length},o.multiply=function(t){for(var e=new Array(o.getLength()+t.getLength()-1),n=0;n<o.getLength();n+=1)for(var a=0;a<t.getLength();a+=1)e[n+a]^=i.gexp(i.glog(o.getAt(n))+i.glog(t.getAt(a)));return r(e,0)},o.mod=function(t){if(o.getLength()-t.getLength()<0)return o;for(var e=i.glog(o.getAt(0))-i.glog(t.getAt(0)),n=new Array(o.getLength()),a=0;a<o.getLength();a+=1)n[a]=o.getAt(a);for(var a=0;a<t.getLength();a+=1)n[a]^=i.gexp(i.glog(t.getAt(a))+e);return r(n,0).mod(t)},o}var t=function(t,e){var o=236,i=17,l=t,g=n[e],s=null,v=0,d=null,w=new Array,m={},y=function(r,t){v=4*l+17,s=function(r){for(var t=new Array(r),e=0;r>e;e+=1){t[e]=new Array(r);for(var n=0;r>n;n+=1)t[e][n]=null}return t}(v),T(0,0),T(v-7,0),T(0,v-7),A(),B(),k(r,t),l>=7&&E(r),null==d&&(d=D(l,g,w)),M(d,t)},T=function(r,t){for(var e=-1;7>=e;e+=1)if(!(-1>=r+e||r+e>=v))for(var n=-1;7>=n;n+=1)-1>=t+n||t+n>=v||(e>=0&&6>=e&&(0==n||6==n)||n>=0&&6>=n&&(0==e||6==e)||e>=2&&4>=e&&n>=2&&4>=n?s[r+e][t+n]=!0:s[r+e][t+n]=!1)},p=function(){for(var r=0,t=0,e=0;8>e;e+=1){y(!0,e);var n=a.getLostPoint(m);(0==e||r>n)&&(r=n,t=e)}return t},B=function(){for(var r=8;v-8>r;r+=1)null==s[r][6]&&(s[r][6]=r%2==0);for(var t=8;v-8>t;t+=1)null==s[6][t]&&(s[6][t]=t%2==0)},A=function(){for(var r=a.getPatternPosition(l),t=0;t<r.length;t+=1)for(var e=0;e<r.length;e+=1){var n=r[t],o=r[e];if(null==s[n][o])for(var i=-2;2>=i;i+=1)for(var u=-2;2>=u;u+=1)-2==i||2==i||-2==u||2==u||0==i&&0==u?s[n+i][o+u]=!0:s[n+i][o+u]=!1}},E=function(r){for(var t=a.getBCHTypeNumber(l),e=0;18>e;e+=1){var n=!r&&1==(t>>e&1);s[Math.floor(e/3)][e%3+v-8-3]=n}for(var e=0;18>e;e+=1){var n=!r&&1==(t>>e&1);s[e%3+v-8-3][Math.floor(e/3)]=n}},k=function(r,t){for(var e=g<<3|t,n=a.getBCHTypeInfo(e),o=0;15>o;o+=1){var i=!r&&1==(n>>o&1);6>o?s[o][8]=i:8>o?s[o+1][8]=i:s[v-15+o][8]=i}for(var o=0;15>o;o+=1){var i=!r&&1==(n>>o&1);8>o?s[8][v-o-1]=i:9>o?s[8][15-o-1+1]=i:s[8][15-o-1]=i}s[v-8][8]=!r},M=function(r,t){for(var e=-1,n=v-1,o=7,i=0,u=a.getMaskFunction(t),f=v-1;f>0;f-=2)for(6==f&&(f-=1);;){for(var c=0;2>c;c+=1)if(null==s[n][f-c]){var l=!1;i<r.length&&(l=1==(r[i]>>>o&1));var g=u(n,f-c);g&&(l=!l),s[n][f-c]=l,o-=1,-1==o&&(i+=1,o=7)}if(n+=e,0>n||n>=v){n-=e,e=-e;break}}},C=function(t,e){for(var n=0,o=0,i=0,u=new Array(e.length),f=new Array(e.length),c=0;c<e.length;c+=1){var l=e[c].dataCount,g=e[c].totalCount-l;o=Math.max(o,l),i=Math.max(i,g),u[c]=new Array(l);for(var s=0;s<u[c].length;s+=1)u[c][s]=255&t.getBuffer()[s+n];n+=l;var v=a.getErrorCorrectPolynomial(g),h=r(u[c],v.getLength()-1),d=h.mod(v);f[c]=new Array(v.getLength()-1);for(var s=0;s<f[c].length;s+=1){var w=s+d.getLength()-f[c].length;f[c][s]=w>=0?d.getAt(w):0}}for(var m=0,s=0;s<e.length;s+=1)m+=e[s].totalCount;for(var y=new Array(m),T=0,s=0;o>s;s+=1)for(var c=0;c<e.length;c+=1)s<u[c].length&&(y[T]=u[c][s],T+=1);for(var s=0;i>s;s+=1)for(var c=0;c<e.length;c+=1)s<f[c].length&&(y[T]=f[c][s],T+=1);return y},D=function(r,t,e){for(var n=u.getRSBlocks(r,t),c=f(),l=0;l<e.length;l+=1){var g=e[l];c.put(g.getMode(),4),c.put(g.getLength(),a.getLengthInBits(g.getMode(),r)),g.write(c)}for(var s=0,l=0;l<n.length;l+=1)s+=n[l].dataCount;if(c.getLengthInBits()>8*s)throw new Error("code length overflow. ("+c.getLengthInBits()+">"+8*s+")");for(c.getLengthInBits()+4<=8*s&&c.put(0,4);c.getLengthInBits()%8!=0;)c.putBit(!1);for(;;){if(c.getLengthInBits()>=8*s)break;if(c.put(o,8),c.getLengthInBits()>=8*s)break;c.put(i,8)}return C(c,n)};return m.addData=function(r){var t=c(r);w.push(t),d=null},m.isDark=function(r,t){if(0>r||r>=v||0>t||t>=v)throw new Error(r+","+t);return s[r][t]},m.getModuleCount=function(){return v},m.make=function(){y(!1,p())},m.createTableTag=function(r,t){r=r||2,t="undefined"==typeof t?4*r:t;var e="";e+='<table style="',e+=" border-width: 0px; border-style: none;",e+=" border-collapse: collapse;",e+=" padding: 0px; margin: "+t+"px;",e+='">',e+="<tbody>";for(var n=0;n<m.getModuleCount();n+=1){e+="<tr>";for(var o=0;o<m.getModuleCount();o+=1)e+='<td style="',e+=" border-width: 0px; border-style: none;",e+=" border-collapse: collapse;",e+=" padding: 0px; margin: 0px;",e+=" width: "+r+"px;",e+=" height: "+r+"px;",e+=" background-color: ",e+=m.isDark(n,o)?"#000000":"#ffffff",e+=";",e+='"/>';e+="</tr>"}return e+="</tbody>",e+="</table>"},m.createImgTag=function(r,t){r=r||2,t="undefined"==typeof t?4*r:t;var e=m.getModuleCount()*r+2*t,n=t,o=e-t;return h(e,e,function(t,e){if(t>=n&&o>t&&e>=n&&o>e){var a=Math.floor((t-n)/r),i=Math.floor((e-n)/r);return m.isDark(i,a)?0:1}return 1})},m};t.stringToBytes=function(r){for(var t=new Array,e=0;e<r.length;e+=1){var n=r.charCodeAt(e);t.push(255&n)}return t},t.createStringToBytes=function(r,t){var e=function(){for(var e=s(r),n=function(){var r=e.read();if(-1==r)throw new Error;return r},o=0,a={};;){var i=e.read();if(-1==i)break;var u=n(),f=n(),c=n(),l=String.fromCharCode(i<<8|u),g=f<<8|c;a[l]=g,o+=1}if(o!=t)throw new Error(o+" != "+t);return a}(),n="?".charCodeAt(0);return function(r){for(var t=new Array,o=0;o<r.length;o+=1){var a=r.charCodeAt(o);if(128>a)t.push(a);else{var i=e[r.charAt(o)];"number"==typeof i?(255&i)==i?t.push(i):(t.push(i>>>8),t.push(255&i)):t.push(n)}}return t}};var e={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},n={L:1,M:0,Q:3,H:2},o={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},a=function(){var t=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],n=1335,a=7973,u=21522,f={},c=function(r){for(var t=0;0!=r;)t+=1,r>>>=1;return t};return f.getBCHTypeInfo=function(r){for(var t=r<<10;c(t)-c(n)>=0;)t^=n<<c(t)-c(n);return(r<<10|t)^u},f.getBCHTypeNumber=function(r){for(var t=r<<12;c(t)-c(a)>=0;)t^=a<<c(t)-c(a);return r<<12|t},f.getPatternPosition=function(r){return t[r-1]},f.getMaskFunction=function(r){switch(r){case o.PATTERN000:return function(r,t){return(r+t)%2==0};case o.PATTERN001:return function(r,t){return r%2==0};case o.PATTERN010:return function(r,t){return t%3==0};case o.PATTERN011:return function(r,t){return(r+t)%3==0};case o.PATTERN100:return function(r,t){return(Math.floor(r/2)+Math.floor(t/3))%2==0};case o.PATTERN101:return function(r,t){return r*t%2+r*t%3==0};case o.PATTERN110:return function(r,t){return(r*t%2+r*t%3)%2==0};case o.PATTERN111:return function(r,t){return(r*t%3+(r+t)%2)%2==0};default:throw new Error("bad maskPattern:"+r)}},f.getErrorCorrectPolynomial=function(t){for(var e=r([1],0),n=0;t>n;n+=1)e=e.multiply(r([1,i.gexp(n)],0));return e},f.getLengthInBits=function(r,t){if(t>=1&&10>t)switch(r){case e.MODE_NUMBER:return 10;case e.MODE_ALPHA_NUM:return 9;case e.MODE_8BIT_BYTE:return 8;case e.MODE_KANJI:return 8;default:throw new Error("mode:"+r)}else if(27>t)switch(r){case e.MODE_NUMBER:return 12;case e.MODE_ALPHA_NUM:return 11;case e.MODE_8BIT_BYTE:return 16;case e.MODE_KANJI:return 10;default:throw new Error("mode:"+r)}else{if(!(41>t))throw new Error("type:"+t);switch(r){case e.MODE_NUMBER:return 14;case e.MODE_ALPHA_NUM:return 13;case e.MODE_8BIT_BYTE:return 16;case e.MODE_KANJI:return 12;default:throw new Error("mode:"+r)}}},f.getLostPoint=function(r){for(var t=r.getModuleCount(),e=0,n=0;t>n;n+=1)for(var o=0;t>o;o+=1){for(var a=0,i=r.isDark(n,o),u=-1;1>=u;u+=1)if(!(0>n+u||n+u>=t))for(var f=-1;1>=f;f+=1)0>o+f||o+f>=t||(0!=u||0!=f)&&i==r.isDark(n+u,o+f)&&(a+=1);a>5&&(e+=3+a-5)}for(var n=0;t-1>n;n+=1)for(var o=0;t-1>o;o+=1){var c=0;r.isDark(n,o)&&(c+=1),r.isDark(n+1,o)&&(c+=1),r.isDark(n,o+1)&&(c+=1),r.isDark(n+1,o+1)&&(c+=1),(0==c||4==c)&&(e+=3)}for(var n=0;t>n;n+=1)for(var o=0;t-6>o;o+=1)r.isDark(n,o)&&!r.isDark(n,o+1)&&r.isDark(n,o+2)&&r.isDark(n,o+3)&&r.isDark(n,o+4)&&!r.isDark(n,o+5)&&r.isDark(n,o+6)&&(e+=40);for(var o=0;t>o;o+=1)for(var n=0;t-6>n;n+=1)r.isDark(n,o)&&!r.isDark(n+1,o)&&r.isDark(n+2,o)&&r.isDark(n+3,o)&&r.isDark(n+4,o)&&!r.isDark(n+5,o)&&r.isDark(n+6,o)&&(e+=40);for(var l=0,o=0;t>o;o+=1)for(var n=0;t>n;n+=1)r.isDark(n,o)&&(l+=1);var g=Math.abs(100*l/t/t-50)/5;return e+=10*g},f}(),i=function(){for(var r=new Array(256),t=new Array(256),e=0;8>e;e+=1)r[e]=1<<e;for(var e=8;256>e;e+=1)r[e]=r[e-4]^r[e-5]^r[e-6]^r[e-8];for(var e=0;255>e;e+=1)t[r[e]]=e;var n={};return n.glog=function(r){if(1>r)throw new Error("glog("+r+")");return t[r]},n.gexp=function(t){for(;0>t;)t+=255;for(;t>=256;)t-=255;return r[t]},n}(),u=function(){var r=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t=function(r,t){var e={};return e.totalCount=r,e.dataCount=t,e},e={},o=function(t,e){switch(e){case n.L:return r[4*(t-1)+0];case n.M:return r[4*(t-1)+1];case n.Q:return r[4*(t-1)+2];case n.H:return r[4*(t-1)+3];default:return}};return e.getRSBlocks=function(r,e){var n=o(r,e);if("undefined"==typeof n)throw new Error("bad rs block @ typeNumber:"+r+"/errorCorrectLevel:"+e);for(var a=n.length/3,i=new Array,u=0;a>u;u+=1)for(var f=n[3*u+0],c=n[3*u+1],l=n[3*u+2],g=0;f>g;g+=1)i.push(t(c,l));return i},e}(),f=function(){var r=new Array,t=0,e={};return e.getBuffer=function(){return r},e.getAt=function(t){var e=Math.floor(t/8);return 1==(r[e]>>>7-t%8&1)},e.put=function(r,t){for(var n=0;t>n;n+=1)e.putBit(1==(r>>>t-n-1&1))},e.getLengthInBits=function(){return t},e.putBit=function(e){var n=Math.floor(t/8);r.length<=n&&r.push(0),e&&(r[n]|=128>>>t%8),t+=1},e},c=function(r){var n=e.MODE_8BIT_BYTE,o=t.stringToBytes(r),a={};return a.getMode=function(){return n},a.getLength=function(r){return o.length},a.write=function(r){for(var t=0;t<o.length;t+=1)r.put(o[t],8)},a},l=function(){var r=new Array,t={};return t.writeByte=function(t){r.push(255&t)},t.writeShort=function(r){t.writeByte(r),t.writeByte(r>>>8)},t.writeBytes=function(r,e,n){e=e||0,n=n||r.length;for(var o=0;n>o;o+=1)t.writeByte(r[o+e])},t.writeString=function(r){for(var e=0;e<r.length;e+=1)t.writeByte(r.charCodeAt(e))},t.toByteArray=function(){return r},t.toString=function(){var t="";t+="[";for(var e=0;e<r.length;e+=1)e>0&&(t+=","),t+=r[e];return t+="]"},t},g=function(){var r=0,t=0,e=0,n="",o={},a=function(r){n+=String.fromCharCode(i(63&r))},i=function(r){if(0>r);else{if(26>r)return 65+r;if(52>r)return 97+(r-26);if(62>r)return 48+(r-52);if(62==r)return 43;if(63==r)return 47}throw new Error("n:"+r)};return o.writeByte=function(n){for(r=r<<8|255&n,t+=8,e+=1;t>=6;)a(r>>>t-6),t-=6},o.flush=function(){if(t>0&&(a(r<<6-t),r=0,t=0),e%3!=0)for(var o=3-e%3,i=0;o>i;i+=1)n+="="},o.toString=function(){return n},o},s=function(r){var t=r,e=0,n=0,o=0,a={};a.read=function(){for(;8>o;){if(e>=t.length){if(0==o)return-1;throw new Error("unexpected end of file./"+o)}var r=t.charAt(e);if(e+=1,"="==r)return o=0,-1;r.match(/^\s$/)||(n=n<<6|i(r.charCodeAt(0)),o+=6)}var a=n>>>o-8&255;return o-=8,a};var i=function(r){if(r>=65&&90>=r)return r-65;if(r>=97&&122>=r)return r-97+26;if(r>=48&&57>=r)return r-48+52;if(43==r)return 62;if(47==r)return 63;throw new Error("c:"+r)};return a},v=function(r,t){var e=r,n=t,o=new Array(r*t),a={};a.setPixel=function(r,t,n){o[t*e+r]=n},a.write=function(r){r.writeString("GIF87a"),r.writeShort(e),r.writeShort(n),r.writeByte(128),r.writeByte(0),r.writeByte(0),r.writeByte(0),r.writeByte(0),r.writeByte(0),r.writeByte(255),r.writeByte(255),r.writeByte(255),r.writeString(","),r.writeShort(0),r.writeShort(0),r.writeShort(e),r.writeShort(n),r.writeByte(0);var t=2,o=u(t);r.writeByte(t);for(var a=0;o.length-a>255;)r.writeByte(255),r.writeBytes(o,a,255),a+=255;r.writeByte(o.length-a),r.writeBytes(o,a,o.length-a),r.writeByte(0),r.writeString(";")};var i=function(r){var t=r,e=0,n=0,o={};return o.write=function(r,o){if(r>>>o!=0)throw new Error("length over");for(;e+o>=8;)t.writeByte(255&(r<<e|n)),o-=8-e,r>>>=8-e,n=0,e=0;n=r<<e|n,e+=o},o.flush=function(){e>0&&t.writeByte(n)},o},u=function(r){for(var t=1<<r,e=(1<<r)+1,n=r+1,a=f(),u=0;t>u;u+=1)a.add(String.fromCharCode(u));a.add(String.fromCharCode(t)),a.add(String.fromCharCode(e));var c=l(),g=i(c);g.write(t,n);var s=0,v=String.fromCharCode(o[s]);for(s+=1;s<o.length;){var h=String.fromCharCode(o[s]);s+=1,a.contains(v+h)?v+=h:(g.write(a.indexOf(v),n),a.size()<4095&&(a.size()==1<<n&&(n+=1),a.add(v+h)),v=h)}return g.write(a.indexOf(v),n),g.write(e,n),g.flush(),c.toByteArray()},f=function(){var r={},t=0,e={};return e.add=function(n){if(e.contains(n))throw new Error("dup key:"+n);r[n]=t,t+=1},e.size=function(){return t},e.indexOf=function(t){return r[t]},e.contains=function(t){return"undefined"!=typeof r[t]},e};return a},h=function(r,t,e,n){for(var o=v(r,t),a=0;t>a;a+=1)for(var i=0;r>i;i+=1)o.setPixel(i,a,e(i,a));var u=l();o.write(u);for(var f=g(),c=u.toByteArray(),s=0;s<c.length;s+=1)f.writeByte(c[s]);f.flush();var h="";return h+="<img",h+=' src="',h+="data:image/gif;base64,",h+=f,h+='"',h+=' width="',h+=r,h+='"',h+=' height="',h+=t,h+='"',n&&(h+=' alt="',h+=n,h+='"'),h+="/>"};return t}();return function(r){"function"==typeof define&&define.amd?define([],r):"object"==typeof exports&&(module.exports=r())}(function(){return r}),!function(r){r.stringToBytes=function(r){function t(r){for(var t=[],e=0;e<r.length;e++){var n=r.charCodeAt(e);128>n?t.push(n):2048>n?t.push(192|n>>6,128|63&n):55296>n||n>=57344?t.push(224|n>>12,128|n>>6&63,128|63&n):(e++,n=65536+((1023&n)<<10|1023&r.charCodeAt(e)),t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n))}return t}return t(r)}}(r),r}()); @@ -10987,466 +10987,23 @@ jQuery.trumbowyg={langs:{en:{viewHTML:"View HTML",undo:"Undo",redo:"Redo",format /* ./modules//template-engine/components/html/column/column.min.js */;$(document).on('orViewLoaded',function(o,n){}); /* ./modules//template-engine/components/html/image/image.min.js */; /* ./modules//template-engine/components/html/group/group.min.js */;$(document).on('orViewLoaded',function(e,o){registerOpenClose($(e.target).find('fieldset.toggle-open-close'))}); -/* ./modules//template-engine/components/html/form/form.min.js */;function doResponse(e,s,r){if(s!='success'){alert('Server error: '+s);return};$.each(e['notices'],function(s,e){if($(r).data('async')=='true')notifyBrowser(e.text);notify(e.type,e.name,e.status,e.text,e.log);if(e.status=='ok'){if($(r).data('async')!='true'){$('#dialog > .view').html('').hide();$('#dialog').removeClass('is-open').addClass('is-closed');$(r).closest('div.panel').find('div.header ul.views li.action.active').removeClass('dirty')};let afterSuccess=$(r).data('afterSuccess');if(afterSuccess){if(afterSuccess=='reloadAll'){Workbench.reloadAll()}} -else{Workbench.reloadViews()};$(document).trigger('orDataChanged')} -else{}});$.each(e['errors'],function(s,e){$('input[name='+e+']').addClass('error').parent().addClass('error').parents('fieldset').addClass('show').addClass('open')});if(!e.control){};if(e.control.redirect)window.location.href=e.control.redirect}; -/* ./modules//template-engine/components/html/upload/upload.min.js */;$(document).on('orViewLoaded',function(e,n){var a=$(e.target).find('form'),o=$(e.target).find('div.or-dropzone-upload > div.input');o.on('dragenter',function(e){e.stopPropagation();e.preventDefault();$(this).css('border','1px dotted gray')});o.on('dragover',function(e){e.stopPropagation();e.preventDefault()});o.on('drop',function(e){$(this).css('border','1px dotted red');e.preventDefault();var n=e.originalEvent.dataTransfer.files;handleFileUpload(a,n)});$(e.target).find('input[type=file]').change(function(){var e=$(this).prop('files');handleFileUpload(a,e)})});function handleFileUpload(e,o){for(var t=0,r;r=o[t];t++){var n=new FormData();n.append('file',r);n.append('action','folder');n.append('subaction',$(e).data('method'));n.append('output','json');n.append('token',$(e).find('input[name=token]').val());n.append('id',$(e).find('input[name=id]').val());var a=$('<div class="notice info"><div class="text loader"></div></div>');$('#noticebar').prepend(a);$(a).show();$.ajax({'type':'POST',url:'./api/',cache:!1,contentType:!1,processData:!1,data:n,success:function(n,o,t){$(a).remove();doResponse(n,o,e)},error:function(n,o,d){$(e).closest('div.content').removeClass('loader');$(a).remove();var r;try{var t=jQuery.parseJSON(n.responseText);r=t.error+'/'+t.description+': '+t.reason}catch(i){r=n.responseText};notify('error',r)}})}}; +/* ./modules//template-engine/components/html/form/form.min.js */;function doResponse(e,r,a){if(r!='success'){alert('Server error: '+r);return};$.each(e['notices'],function(r,e){let notifyBrowser=$(a).data('async')=='true';Openrat.Workbench.notify(e.type,e.name,e.status,e.text,e.log,notifyBrowser);if(e.status=='ok'){if($(a).data('async')!='true'){$('#dialog > .view').html('').hide();$('#dialog').removeClass('is-open').addClass('is-closed');$(a).closest('div.panel').find('div.header ul.views li.action.active').removeClass('dirty')};let afterSuccess=$(a).data('afterSuccess');if(afterSuccess){if(afterSuccess=='reloadAll'){Openrat.Workbench.reloadAll()}} +else{Openrat.Workbench.reloadViews()};$(document).trigger('orDataChanged')} +else{}});$.each(e['errors'],function(r,e){$('input[name='+e+']').addClass('error').parent().addClass('error').parents('fieldset').addClass('show').addClass('open')});if(!e.control){};if(e.control.redirect)window.location.href=e.control.redirect}; +/* ./modules//template-engine/components/html/upload/upload.min.js */;$(document).on('orViewLoaded',function(e,n){var a=$(e.target).find('form'),o=$(e.target).find('div.or-dropzone-upload > div.input');o.on('dragenter',function(e){e.stopPropagation();e.preventDefault();$(this).css('border','1px dotted gray')});o.on('dragover',function(e){e.stopPropagation();e.preventDefault()});o.on('drop',function(e){$(this).css('border','1px dotted red');e.preventDefault();var n=e.originalEvent.dataTransfer.files;handleFileUpload(a,n)});$(e.target).find('input[type=file]').change(function(){var e=$(this).prop('files');handleFileUpload(a,e)})});function handleFileUpload(e,o){for(var t=0,r;r=o[t];t++){var n=new FormData();n.append('file',r);n.append('action','folder');n.append('subaction',$(e).data('method'));n.append('output','json');n.append('token',$(e).find('input[name=token]').val());n.append('id',$(e).find('input[name=id]').val());var a=$('<div class="notice info"><div class="text loader"></div></div>');$('#noticebar').prepend(a);$(a).show();$.ajax({'type':'POST',url:'./api/',cache:!1,contentType:!1,processData:!1,data:n,success:function(n,o,t){$(a).remove();doResponse(n,o,e)},error:function(n,o,d){$(e).closest('div.content').removeClass('loader');$(a).remove();var r;try{var t=jQuery.parseJSON(n.responseText);r=t.error+'/'+t.description+': '+t.reason}catch(i){r=n.responseText};Openrat.Workbench.notify('Upload error',r)}})}}; /* ./modules//template-engine/components/html/tree/tree.min.js */;$(document).on('orViewLoaded',function(o,n){}); -/* ./modules/cms-ui/themes/default/script/openrat/init.min.js */ -// Create own namespace. - -window.openrat = {}; - -/* ./modules/cms-ui/themes/default/script/openrat/view.min.js *//** - * View. - * Eine View ist ein HTML-Fragment, in das eine Action geladen wird. - * Das Erzeugen der View, das Laden vom Server sowie das Schließen sind hier gekapselt. - * - * @param action - * @param method - * @param id - * @param params - * @constructor - */ -function View( action,method,id,params ) { - - this.action = action; - this.method = method; - this.id = id; - this.params = params; - - this.before = function() {}; - - this.start = function( element ) { - this.before(); - this.element = element; - this.loadView(); - } - - this.afterLoad = function() { - - } - - this.close = function() { - } - - - function registerViewEvents(element) { - - registerMenuEvents( element ); - registerSearch ( element ); - registerTree ( element ); - afterViewLoaded ( element ); - - } - - - this.loadView = function() { - - let url = createUrl( this.action,this.method,this.id,this.params,true); // URL für das Laden erzeugen. - let element = this.element; - let view = this; - - $(this.element).empty().fadeTo(1,0.7).addClass('loader').html('').load(url,function(response, status, xhr) { - - $(element).fadeTo(350,1); - - $(element).removeClass("loader"); - - $(element).find('form').each( function() { - let form = new Form(); - form.close = function() { - view.close(); - } - form.initOnElement(this); - - }); - if ( status == "error" ) - { - // Seite nicht gefunden. - $(element).html(""); - - notify('','','error','Server Error',['Server Error while requesting url '+url, response]); - return; - } - - registerViewEvents( element ); - - }); - - } - -} - -/* ./modules/cms-ui/themes/default/script/openrat/form.min.js */ -/** - * Form. - * - * @constructor - */ -function Form() { - - this.setLoadStatus = function( isLoading ) { - $(this.element).closest('div.content').toggleClass('loader',isLoading); - } - - this.initOnElement = function( element ) { - this.element = element; - - let form = this; - - // Autosave in Formularen. - // Bei Veränderungen von Checkboxen wird das Formular sofort abgeschickt. - $(element).find('form[data-autosave="true"] input[type="checkbox"]').click( function() { - form.submit(); - }); - - // 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-form-btn--cancel').click( function() { - form.cancel(); - - }); - $(element).find('.or-form-btn--reset').click( function() { - form.rollback(); - - }); - - // 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. - }); - } - - this.cancel = function() { - //$(this.element).html('').parent().removeClass('is-open'); - this.close(); - } - - - this.rollback = function() { - this.element.trigger('reset'); - } - - this.close = function() { - - } - - this.submit = function() { - - - // Show progress - let status = $('<div class="notice info"><div class="text loader"></div></div>'); - $('#noticebar').prepend(status); // Notice anhängen. - $(status).show(); - - // Alle vorhandenen Error-Marker entfernen. - // Falls wieder ein Fehler auftritt, werden diese erneut gesetzt. - $(this.element).find('.error').removeClass('error'); - - var params = $(this.element).serializeArray(); - var data = {}; - $(params).each(function(index, obj){ - data[obj.name] = obj.value; - }); - - // If form does not contain action/id, get it from the workbench. - if (!data.id) - data.id = Workbench.state.id; - if (!data.action) - data.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. - //Workbench.loadViewIntoElement( $(form).parent('.view'),data.action, data.subaction,data.id,data ); - this.forwardTo( data.action, data.subaction,data.id,data ); - } - 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. - data.output = 'json'; - - if ( $(this.element).data('async') || $(this.element).data('async')=='true') - { - // Verarbeitung erfolgt asynchron, das heißt, dass der evtl. geöffnete Dialog - // beendet wird. - this.close(); - // Async: Window is closed, but the action will be startet now. - } - - let form = this; - $.ajax( { 'type':'POST',url:url, data:data, success:function(data, textStatus, jqXHR) - { - form.setLoadStatus(false); - $(status).remove(); - - doResponse(data,textStatus,form.element); - }, - error:function(jqXHR, textStatus, errorThrown) { - form.setLoadStatus(false); - $(status).remove(); - - try - { - let error = jQuery.parseJSON( jqXHR.responseText ); - notify('','','error',error.error,[error.description]); - } - catch( e ) - { - let msg = jqXHR.responseText; - notify('','','error','Server Error',[msg]); - } - - - } - - } ); - $(form.element).fadeIn(); - } - - } -} - - -/* ./modules/cms-ui/themes/default/script/openrat/workbench.min.js */ - -var Workbench = new function() -{ - 'use strict'; // Strict mode - - - /** - * Initializes the Workbench. - */ - this.initialize = function() { - - // Initialze Ping timer. - this.initializePingTimer(); - this.initializeState(); - this.initializeMenues(); - this.openModalDialog(); - } - - - /** - * Starts a dialog, if necessary. - */ - this.openModalDialog = function () { - - if ( $('#dialog').data('action') ) { - startDialog('',$('#dialog').data('action'),$('#dialog').data('action'),0,{}) - } - } - - - this.initializeMenues = function () { - - filterMenus(); - } - - - /** - * Sets the workbench state with action/id. - * - * Example: #/name/1 is translated to the state {action:name,id:1} - */ - this.initializeState = function () { - - 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; - - // TODO: Remove this sometimes.... only state. - $('#editor').attr('data-action',state.action); - $('#editor').attr('data-id' ,state.id ); - $('#editor').attr('data-extra' ,'{}' ); - - } - - /** - * Registriert den Ping-Timer für den Sitzungserhalt. - */ - this.initializePingTimer = function() { - - /** - * 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) - */ - var ping = function() - { - $.ajax( createUrl('title','ping',0) ); - //window.console && console.log("session-ping"); - } - - // Alle 5 Minuten pingen. - var timeoutMinutes = 5; - - window.setInterval( ping, timeoutMinutes*60*1000 ); - } - - - - this.loadNewActionState = function(state) { - - Workbench.state = state; - Workbench.loadNewAction(state.action,state.id,state.data); - - - filterMenus(); - - $(document).trigger('orNewAction'); - } - - /** - * - */ - - this.loadNewAction = function(action, id, params ) { - - $('#editor').attr('data-action',action); - $('#editor').attr('data-id' ,id ); - $('#editor').attr('data-extra' ,JSON.stringify(params)); - - this.reloadViews(); - } - - - /** - * - */ - - this.reloadViews = function() { - - // View in geschlossenen Sektionen löschen, damit diese nicht stehen bleiben. - $('#workbench section.closed .view-loader').empty(); - - Workbench.loadViews( $('#workbench section.open .view-loader') ); - } - - - this.reloadAll = function() { - - // View in geschlossenen Sektionen löschen, damit diese nicht stehen bleiben. - $('#workbench .view').empty(); - - Workbench.loadViews( $('#workbench .view') ); - } - - - - this.loadViews = function( $views ) - { - - $views.each(function (idx) { - - let $targetDOMElement = $(this); - - Workbench.loadNewActionIntoElement( $targetDOMElement ) - }); - } - - - - this.loadNewActionIntoElement = function( $viewElement ) - { - let action; - if ( $viewElement.is('.view-static') ) - // Static views have always the same action. - action = $viewElement.attr('data-action'); - else - action = $('#editor').attr('data-action'); - - let id = $('#editor').attr('data-id' ); - let params = $('#editor').attr('data-extra' ); - - let method = $viewElement.data('method'); - - let view = new View( action,method,id,params ); - view.start( $viewElement ); - } - - -} - - - -/* ./modules/cms-ui/themes/default/script/openrat/navigator.min.js *//** - * Navigation. - */ -var Navigator = new function () { - 'use strict'; - - /** - * Navigiert zu einer Action, aber ohne ein neues History-Element einzufügen. - */ - this.navigateTo = function(state) { - Workbench.loadNewActionState(state); - } - - - /** - * - * Navigiert zu einer neue Action und fügt einen neuen History-Eintrag hinzu. - */ - this.navigateToNew = function(obj) { - - Workbench.loadNewActionState(obj); - window.history.pushState(obj,obj.name,'./#/'+obj.action+(obj.id?'/'+obj.id:'') ); - } - - this.navigateToNewAction = function(action, method, id, params ) { - var state = {action:action,method:method,id:id.replace(/[^0-9_]/gim,""),data:params}; - this.navigateToNew(state); - } - - /** - * Setzt den State für den aktuellen History-Eintrag. - * @param obj - */ - this.toActualHistory = function(obj) { - window.history.replaceState(obj,obj.name,createUrl(obj.action,null,obj.id,obj.data,false) ); - } -} - -openrat.navigator = Navigator; -/* ./modules/cms-ui/themes/default/script/openrat/common.min.js */;var OR_THEMES_EXT_DIR='modules/cms-ui/themes/';$(function(){$('html').removeClass('nojs');$('.initial-hidden').removeClass('initial-hidden');registerWorkbenchEvents();window.onpopstate=function(e){Navigator.navigateTo(e.state)};initActualHistoryState();Workbench.initialize();Workbench.reloadAll();registerNavigation();$('.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)});$('#noticebar .notice .image-icon--menu-close').click(function(){$(this).closest('.notice').fadeOut('fast',function(){$(this).remove()})});$('#noticebar .notice').each(function(){let noticeToClose=this;setTimeout(function(){$(noticeToClose).fadeOut('slow',function(){$(this).remove()})},30*1000)});registerOpenClose($('section.toggle-open-close'));$('section.toggle-open-close .on-click-open-close').click(function(){var t=$(this).closest('section');if(t.hasClass('disabled'))return;var e=t.find('div.view-loader');if(e.children().length==0)Workbench.loadNewActionIntoElement(e)})});function initActualHistoryState(){var t={};t.name=window.document.title;var e=new URLSearchParams(window.location.search);if(e.has('action')){t.action=e.get('action');t.id=e.get('id');t.name=window.document.title;t.data={};var e=Array.from(e.entries());for(var i in e){t.data[e[i][0]]=e[i][1]};Navigator.toActualHistory(t)}};function registerNavigation(){$(document).on('orNewAction',function(e,t){let url='./api/?action=tree&subaction=path&id='+Workbench.state.id+'&type='+Workbench.state.action+'&output=json';$.getJSON(url,function(e){$('nav .or-navtree-node').removeClass('or-navtree-node--selected');let output=e['output'];$.each(output.path,function(e,t){$nav=$('nav .or-navtree-node[data-type='+t.type+'][data-id='+t.id+'].or-navtree-node--is-closed .or-navtree-node-control');$nav.click()});if(output.actual)$('nav .or-navtree-node[data-type='+output.actual.type+'][data-id='+output.actual.id+']').addClass('or-navtree-node--selected')}).fail(function(e){console.warn(e);console.warn('failed to load path from '+url)}).always(function(){})})};function registerWorkbenchEvents(){$('div.header').dblclick(function(){fullscreen(this)})};function loadView(e,t,i,n,o){Navigator.navigateToNewAction(t,i,n,o)};function afterViewLoaded(e){var t=$(e).closest('section');t.toggleClass('is-empty',$(e).is(':empty'));$(e).trigger('orViewLoaded');$(e).closest('div.panel').find('div.header div.dropdown div.entry.perview').remove();$(e).find('.toggle-nav-open-close').click(function(){$('nav').toggleClass('open')});$(e).find('.toggle-nav-small').click(function(){$('nav').toggleClass('small')});$(e).find('div.headermenu > a').each(function(e,t){});$(e).find('div.header > a.back').each(function(t,i){$(i).removeClass('button').wrap('<div class="entry perview" />').parent().appendTo($(e).closest('div.panel').find('div.header div.dropdown').first())});$(e).find('div.selector.tree').each(function(){var e=this;$(this).orTree({type:'project',selectable:$(e).attr('data-types').split(','),id:$(e).attr('data-init-folderid'),onSelect:function(t,i,n){var o=$(e).parent();$(o).find('input[type=text]').attr('value',t);$(o).find('input[type=hidden]').attr('value',n)}})});registerDragAndDrop(e);$(e).find('input').change(function(){$(this).parent('div.view').addClass('dirty')});$(e).find('.or-theme-chooser').change(function(){setUserStyle(this.value)})};function registerDragAndDrop(e){registerDraggable(e);registerDroppable(e)};function registerDraggable(e){$(e).find('.or-draggable').draggable({helper:'clone',opacity:0.7,zIndex:2,distance:10,cursor:'move',revert:'false'})};function registerTreeBranchEvents(e){registerDraggable(e)};function registerDroppable(e){$(e).find('.or-droppable').droppable({accept:'.or-draggable',hoverClass:'or-droppable--hover',activeClass:'or-droppable--active',drop:function(e,t){let dropped=t.draggable;$(this).find('.or-selector-link-value').val(dropped.data('id'));$(this).find('.or-selector-link-name').val(dropped.data('id'))}})};function registerMenuEvents(e){$('body').click(function(){$('.toolbar-icon.menu').parents('.or-menu').removeClass('open')});$(e).find('.toolbar-icon.menu').click(function(e){e.stopPropagation();$(this).parents('.or-menu').toggleClass('open')});$(e).find('.toolbar-icon.menu').mouseover(function(){$(this).parents('.or-menu').find('.toolbar-icon.menu').removeClass('open');$(this).addClass('open')})};function registerSearch(e){$(e).find('.search input').orSearch({dropdown:'#title div.search div.dropdown'})};function registerTree(e){$(e).find('.or-navtree-node').orTree()};function fullscreen(e){$(e).closest('div.panel').fadeOut('fast',function(){$(this).toggleClass('fullscreen').fadeIn('fast')})};function submitUrl(e,t){postUrl(t,e)};function postUrl(e,t){e+='&output=json';$.ajax({'type':'POST',url:e,data:{},success:function(e,i,n){$('div.panel div.status div.loader').html('&nbsp;');doResponse(e,i,t)}})};function startDialog(e,t,i,n,o){if(!t)t=$('#editor').attr('data-action');if(!n)n=$('#editor').attr('data-id');let view=new View(t,i,n,o);view.before=function(){$('#dialog > .view').html('<div class="header"><img class="icon" title="" src="./themes/default/images/icon/'+i+'.png" />'+e+'</div>');$('#dialog > .view').data('id',n);$('#dialog').removeClass('is-closed').addClass('is-open');let view=this;this.escapeKeyClosingHandler=function(e){if(e.keyCode==27){view.close();$(document).off('keyup')}};$(document).keyup(this.escapeKeyClosingHandler);$('#dialog .filler').click(function(){view.close()})};view.close=function(){if($('div#dialog').hasClass('modal'))return;$('#dialog .view').fadeOut('fast').html('');$('#dialog').removeClass('is-open').addClass('is-closed');$(document).unbind('keyup',this.escapeKeyClosingHandler)};view.start($('div#dialog > .view'))};function startEdit(e,t,i,n,o){if(!t)t=Workbench.state.action;if(!n)n=Workbench.state.id;let view=new View(t,i,n,o);view.before=function(){let view=this;$edit=$('#edit');$edit.addClass('is-open');$('#editor').addClass('is-closed');$('#edit .filler').click(function(){view.close()})};view.close=function(){$edit.removeClass('is-open');$('#editor').removeClass('is-closed')};view.start($('#edit > .view'))};function setTitle(e){if(e)$('head > title').text(e+' - '+$('head > title').data('default'));else $('head > title').text($('head > title').data('default'))};function openNewAction(e,t,i,n){$('nav').removeClass('open');setTitle(e);setNewAction(t,i,n)};function filterMenus(){let action=Workbench.state.action;let id=Workbench.state.id;$('div.clickable').addClass('active');$('div.clickable.filtered').removeClass('active').addClass('inactive');$('div.clickable.filtered.on-action-'+action).addClass('active').removeClass('inactive');$('div.clickable.filtered a').attr('data-id',id)};function setNewAction(e,t,i){Navigator.navigateToNewAction(e,'edit',t,i)};function setNewId(e){};function notifyBrowser(e){if(!('Notification' in window)){return} -else if(Notification.permission==='granted'){let notification=new Notification(e)} -else if(Notification.permission!=='denied'){Notification.requestPermission(function(t){if(t==='granted'){let notification=new Notification(e)}})}};function setUserStyle(e){var t=$('html'),i=t.attr('class').split(/\s+/);$.each(i,function(e,i){if(i.startsWith('theme-')){t.removeClass(i)}});t.addClass('theme-'+e.toLowerCase())};function insert(e,t,i){var n=document.forms[0].elements[e];n.focus();if(typeof document.selection!='undefined'){var l=document.selection.createRange(),o=l.text;l.text=t+o+i;l=document.selection.createRange();if(o.length==0){l.move('character',-i.length)} +/* ./modules/cms-ui/themes/default/script/openrat/init.min.js */;window.Openrat={}; +/* ./modules/cms-ui/themes/default/script/openrat/view.min.js */;Openrat.View=function(e,t,i,r){this.action=e;this.method=t;this.id=i;this.params=r;this.before=function(){};this.start=function(e){this.before();this.element=e;this.loadView()};this.afterLoad=function(){};this.close=function(){};function n(e){afterViewLoaded(e)};this.loadView=function(){let url=createUrl(this.action,this.method,this.id,this.params,!0);let element=this.element;let view=this;$(this.element).empty().fadeTo(1,0.7).addClass('loader').html('').load(url,function(e,t,i){$(element).fadeTo(350,1);$(element).removeClass('loader');$(element).find('form').each(function(){let form=new Openrat.Form();form.close=function(){view.close()};form.initOnElement(this)});if(t=='error'){$(element).html('');Openrat.Workbench.notify('','','error','Server Error',['Server Error while requesting url '+url,e]);return};n(element)})}}; +/* ./modules/cms-ui/themes/default/script/openrat/form.min.js */;Openrat.Form=function(){this.setLoadStatus=function(t){$(this.element).closest('div.content').toggleClass('loader',t)};this.initOnElement=function(t){this.element=t;let form=this;$(t).find('form[data-autosave="true"] input[type="checkbox"]').click(function(){form.submit()});$(t).find('.or-form-btn--cancel').click(function(){form.cancel()});$(t).find('.or-form-btn--reset').click(function(){form.rollback()});$(t).submit(function(t){if($(this).data('target')=='view'){form.submit();t.preventDefault()}})};this.cancel=function(){this.close()};this.rollback=function(){this.element.trigger('reset')};this.close=function(){};this.submit=function(){let status=$('<div class="notice info"><div class="text loader"></div></div>');$('#noticebar').prepend(status);$(status).show();$(this.element).find('.error').removeClass('error');var e=$(this.element).serializeArray(),t={};$(e).each(function(e,r){t[r.name]=r.value});if(!t.id)t.id=Openrat.Workbench.state.id;if(!t.action)t.action=Openrat.Workbench.state.action;let formMethod=$(this.element).attr('method').toUpperCase();if(formMethod=='GET'){this.forwardTo(t.action,t.subaction,t.id,t)} +else{let url='./api/';this.setLoadStatus(!0);url+='';t.output='json';if($(this.element).data('async')||$(this.element).data('async')=='true'){this.close()};let form=this;$.ajax({'type':'POST',url:url,data:t,success:function(t,e,r){form.setLoadStatus(!1);$(status).remove();doResponse(t,e,form.element)},error:function(t,e,r){form.setLoadStatus(!1);$(status).remove();try{let error=jQuery.parseJSON(t.responseText);Openrat.Workbench.notify('','','error',error.error,[error.description])}catch(o){let msg=t.responseText;Openrat.Workbench.notify('','','error','Server Error',[msg])}}});$(form.element).fadeIn()}}}; +/* ./modules/cms-ui/themes/default/script/openrat/workbench.min.js */;Openrat.Workbench=new function(){'use strict';this.state={};this.initialize=function(){this.initializePingTimer();this.initializeState();this.initializeMenues();this.openModalDialog()};this.openModalDialog=function(){if($('#dialog').data('action')){startDialog('',$('#dialog').data('action'),$('#dialog').data('action'),0,{})}};this.initializeMenues=function(){filterMenus()};this.initializeState=function(){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,'');Openrat.Workbench.state=state;$('#editor').attr('data-action',state.action);$('#editor').attr('data-id',state.id);$('#editor').attr('data-extra','{}');Openrat.Navigator.toActualHistory(state)};this.initializePingTimer=function(){var t=function(){$.ajax(createUrl('title','ping',0))},i=5;window.setInterval(t,i*60*1000)};this.loadNewActionState=function(t){Openrat.Workbench.state=t;Openrat.Workbench.loadNewAction(t.action,t.id,t.data);filterMenus();$(document).trigger('orNewAction')};this.loadNewAction=function(t,i,e){$('#editor').attr('data-action',t);$('#editor').attr('data-id',i);$('#editor').attr('data-extra',JSON.stringify(e));this.reloadViews()};this.reloadViews=function(){$('#workbench section.closed .view-loader').empty();Openrat.Workbench.loadViews($('#workbench section.open .view-loader'))};this.reloadAll=function(){$('#workbench .view').empty();Openrat.Workbench.loadViews($('#workbench .view'))};this.loadViews=function(t){t.each(function(t){let $targetDOMElement=$(this);Openrat.Workbench.loadNewActionIntoElement($targetDOMElement)})};this.loadNewActionIntoElement=function(t){let action;if(t.is('.view-static'))action=t.attr('data-action');else action=$('#editor').attr('data-action');let id=$('#editor').attr('data-id');let params=$('#editor').attr('data-extra');let method=t.data('method');let view=new Openrat.View(action,method,id,params);view.start(t)};this.setUserStyle=function(t){var i=$('html'),e=i.attr('class').split(/\s+/);$.each(e,function(t,e){if(e.startsWith('theme-')){i.removeClass(e)}});i.addClass('theme-'+t.toLowerCase())};let notifyBrowser=function(t){if(!('Notification' in window)){return} +else if(Notification.permission==='granted'){let notification=new Notification(t)} +else if(Notification.permission!=='denied'){Notification.requestPermission(function(i){if(i==='granted'){let notification=new Notification(t)}})}};this.notify=function(t,e,i,o,log=[],notifyBrowser=!1){if(notifyBrowser)notifyBrowser(o);let notice=$('<div class="notice '+i+'"></div>');let toolbar=$('<div class="or-notice-toolbar"></div>');if(log.length)$(toolbar).append('<i class="or-action-full image-icon image-icon--menu-fullscreen"></i>');$(toolbar).append('<i class="or-action-close image-icon image-icon--menu-close"></i>');$(notice).append(toolbar);let id=0;if(e)$(notice).append('<div class="name clickable"><a href="" data-type="open" data-action="'+t+'" data-id="'+id+'"><i class="or-action-full image-icon image-icon--action-'+t+'"></i> '+e+'</a></div>');$(notice).append('<div class="text">'+htmlEntities(o)+'</div>');if(log.length){let logLi=log.reduce((result,item)=>{result+='<li><pre>'+htmlEntities(item)+'</pre></li>';return result},'');$(notice).append('<div class="log"><ul>'+logLi+'</ul></div>')};$('#noticebar').prepend(notice);$(notice).orLinkify();$(notice).find('.or-action-full').click(function(){$(notice).toggleClass('full')});$(notice).find('.or-action-close').click(function(){$(notice).fadeOut('fast',function(){$(notice).remove()})});let timeout=1;if(i=='ok')timeout=20;if(i=='info')timeout=60;if(i=='warning')timeout=120;if(i=='error')timeout=120;if(timeout>0)setTimeout(function(){$(notice).fadeOut('slow',function(){$(this).remove()})},timeout*1000)}}; +/* ./modules/cms-ui/themes/default/script/openrat/navigator.min.js */;Openrat.Navigator=new function(){'use strict';this.navigateTo=function(t){Openrat.Workbench.loadNewActionState(t)};this.navigateToNew=function(t){this.navigateTo(t);window.history.pushState(t,t.name,'./#/'+t.action+(t.id?'/'+t.id:''))};this.toActualHistory=function(t){window.history.replaceState(t,t.name,createUrl(t.action,null,t.id,t.data,!1))}}; +/* ./modules/cms-ui/themes/default/script/openrat/common.min.js */;var OR_THEMES_EXT_DIR='modules/cms-ui/themes/';$(function(){$('html').removeClass('nojs');$('.initial-hidden').removeClass('initial-hidden');function e(){function e(e){$(e).closest('div.panel').fadeOut('fast',function(){$(this).toggleClass('fullscreen').fadeIn('fast')})};$('div.header').dblclick(function(){e(this)})};e();window.onpopstate=function(e){Openrat.Navigator.navigateTo(e.state)};Openrat.Workbench.initialize();Openrat.Workbench.reloadAll();let registerWorkbenchGlobalEvents=function(){function e(){$(document).on('orNewAction',function(e,t){let url='./api/?action=tree&subaction=path&id='+Openrat.Workbench.state.id+'&type='+Openrat.Workbench.state.action+'&output=json';$.getJSON(url,function(e){$('nav .or-navtree-node').removeClass('or-navtree-node--selected');let output=e['output'];$.each(output.path,function(e,t){$nav=$('nav .or-navtree-node[data-type='+t.type+'][data-id='+t.id+'].or-navtree-node--is-closed .or-navtree-node-control');$nav.click()});if(output.actual)$('nav .or-navtree-node[data-type='+output.actual.type+'][data-id='+output.actual.id+']').addClass('or-navtree-node--selected')}).fail(function(e){console.warn(e);console.warn('failed to load path from '+url)}).always(function(){})})};e();$('.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)});$('#noticebar .notice .image-icon--menu-close').click(function(){$(this).closest('.notice').fadeOut('fast',function(){$(this).remove()})});$('#noticebar .notice').each(function(){let noticeToClose=this;setTimeout(function(){$(noticeToClose).fadeOut('slow',function(){$(this).remove()})},30*1000)});$('section.toggle-open-close .on-click-open-close').click(function(){var t=$(this).closest('section');if(t.hasClass('disabled'))return;var e=t.find('div.view-loader');if(e.children().length==0)Openrat.Workbench.loadNewActionIntoElement(e)})};registerWorkbenchGlobalEvents()});function afterViewLoaded(e){var n=$(e).closest('section');n.toggleClass('is-empty',$(e).is(':empty'));$(e).trigger('orViewLoaded');$(e).closest('div.panel').find('div.header div.dropdown div.entry.perview').remove();$(e).find('.toggle-nav-open-close').click(function(){$('nav').toggleClass('open')});$(e).find('.toggle-nav-small').click(function(){$('nav').toggleClass('small')});$(e).find('div.headermenu > a').each(function(e,t){});$(e).find('div.header > a.back').each(function(t,n){$(n).removeClass('button').wrap('<div class="entry perview" />').parent().appendTo($(e).closest('div.panel').find('div.header div.dropdown').first())});$(e).find('div.selector.tree').each(function(){var e=this;$(this).orTree({type:'project',selectable:$(e).attr('data-types').split(','),id:$(e).attr('data-init-folderid'),onSelect:function(t,n,i){var o=$(e).parent();$(o).find('input[type=text]').attr('value',t);$(o).find('input[type=hidden]').attr('value',i)}})});t(e);$(e).find('input').change(function(){$(this).parent('div.view').addClass('dirty')});$(e).find('.or-theme-chooser').change(function(){Openrat.Workbench.setUserStyle(this.value)});function i(e){$('body').click(function(){$('.toolbar-icon.menu').parents('.or-menu').removeClass('open')});$(e).find('.toolbar-icon.menu').click(function(e){e.stopPropagation();$(this).parents('.or-menu').toggleClass('open')});$(e).find('.toolbar-icon.menu').mouseover(function(){$(this).parents('.or-menu').find('.toolbar-icon.menu').removeClass('open');$(this).addClass('open')})};function o(e){$(e).find('.search input').orSearch({dropdown:'#title div.search div.dropdown'})};function a(e){$(e).find('.or-navtree-node').orTree()};i(e);o(e);a(e);function t(e){registerDraggable(e);registerDroppable(e)};t(e)};function registerDraggable(e){$(e).find('.or-draggable').draggable({helper:'clone',opacity:0.7,zIndex:2,distance:10,cursor:'move',revert:'false'})};function registerTreeBranchEvents(e){registerDraggable(e)};function registerDroppable(e){$(e).find('.or-droppable').droppable({accept:'.or-draggable',hoverClass:'or-droppable--hover',activeClass:'or-droppable--active',drop:function(e,t){let dropped=t.draggable;$(this).find('.or-selector-link-value').val(dropped.data('id'));$(this).find('.or-selector-link-name').val(dropped.data('id'))}})};function startDialog(e,t,n,i,o){if(!t)t=$('#editor').attr('data-action');if(!i)i=$('#editor').attr('data-id');let view=new Openrat.View(t,n,i,o);view.before=function(){$('#dialog > .view').html('<div class="header"><img class="icon" title="" src="./themes/default/images/icon/'+n+'.png" />'+e+'</div>');$('#dialog > .view').data('id',i);$('#dialog').removeClass('is-closed').addClass('is-open');let view=this;this.escapeKeyClosingHandler=function(e){if(e.keyCode==27){view.close();$(document).off('keyup')}};$(document).keyup(this.escapeKeyClosingHandler);$('#dialog .filler').click(function(){view.close()})};view.close=function(){if($('div#dialog').hasClass('modal'))return;$('#dialog .view').fadeOut('fast').html('');$('#dialog').removeClass('is-open').addClass('is-closed');$(document).unbind('keyup',this.escapeKeyClosingHandler)};view.start($('div#dialog > .view'))};function startEdit(e,t,n,i,o){if(!t)t=Openrat.Workbench.state.action;if(!i)i=Openrat.Workbench.state.id;let view=new Openrat.View(t,n,i,o);view.before=function(){let view=this;$edit=$('#edit');$edit.addClass('is-open');$('#editor').addClass('is-closed');$('#edit .filler').click(function(){view.close()})};view.close=function(){$edit.removeClass('is-open');$('#editor').removeClass('is-closed')};view.start($('#edit > .view'))};function setTitle(e){if(e)$('head > title').text(e+' - '+$('head > title').data('default'));else $('head > title').text($('head > title').data('default'))};function openNewAction(e,t,n){$('nav').removeClass('open');setTitle(e);Openrat.Navigator.navigateToNew({'action':t,'id':n})};function filterMenus(){let action=Openrat.Workbench.state.action;let id=Openrat.Workbench.state.id;$('div.clickable').addClass('active');$('div.clickable.filtered').removeClass('active').addClass('inactive');$('div.clickable.filtered.on-action-'+action).addClass('active').removeClass('inactive');$('div.clickable.filtered a').attr('data-id',id)};function insert(e,t,i){var n=document.forms[0].elements[e];n.focus();if(typeof document.selection!='undefined'){var l=document.selection.createRange(),o=l.text;l.text=t+o+i;l=document.selection.createRange();if(o.length==0){l.move('character',-i.length)} else{l.moveStart('character',t.length+o.length+i.length)};l.select()} -else if(typeof n.selectionStart!='undefined'){var s=n.selectionStart,c=n.selectionEnd,o=n.value.substring(s,c);n.value=n.value.substr(0,s)+t+o+i+n.value.substr(c);var a;if(o.length==0){a=s+t.length} -else{a=s+t.length+o.length+i.length};n.selectionStart=a;n.selectionEnd=a} -else{a=n.value.length;var o=prompt('Text');n.value=n.value.substr(0,a)+t+o+i+n.value.substr(a)}};function createUrl(e,t,i,n,a){var o='./';o+='?';if(e)o+='&action='+e;if(t)o+='&subaction='+t;if(i)o+='&id='+i;if(typeof n==='string'){n=n.replace(/'/g,'"');var l=jQuery.parseJSON(n);jQuery.each(l,function(e,t){o=o+'&'+e+'='+t})} -else if(typeof n==='object'){jQuery.each(n,function(e,t){o=o+'&'+e+'='+t})} -else{};return o};function resizeWorkbenchContainer(e){};function resizeWorkbench(){};function resizeTabs(e){};function help(e,t,i){var n=$(e).closest('div.panel').find('li.action.active').attr('data-action'),o=$(e).closest('div.panel').find('li.action.active').attr('data-method');window.open(t+n+'/'+o+i,'OpenRat_Help','location=no,menubar=no,scrollbars=yes,toolbar=no,resizable=yes')};function notify(e,t,i,n,log=[]){let notice=$('<div class="notice '+i+'"></div>');let toolbar=$('<div class="or-notice-toolbar"></div>');if(log.length)$(toolbar).append('<i class="or-action-full image-icon image-icon--menu-fullscreen"></i>');$(toolbar).append('<i class="or-action-close image-icon image-icon--menu-close"></i>');$(notice).append(toolbar);id=0;if(t)$(notice).append('<div class="name clickable"><a href="" data-type="open" data-action="'+e+'" data-id="'+id+'"><i class="or-action-full image-icon image-icon--action-'+e+'"></i> '+t+'</a></div>');$(notice).append('<div class="text">'+htmlEntities(n)+'</div>');if(log.length){let logLi=log.reduce((result,item)=>{result+='<li><pre>'+htmlEntities(item)+'</pre></li>';return result},'');$(notice).append('<div class="log"><ul>'+logLi+'</ul></div>')};$('#noticebar').prepend(notice);$(notice).orLinkify();$(notice).find('.or-action-full').click(function(){$(notice).toggleClass('full')});$(notice).find('.or-action-close').click(function(){$(notice).fadeOut('fast',function(){$(notice).remove()})});let timeout=1;if(i=='ok')timeout=20;if(i=='info')timeout=60;if(i=='warning')timeout=120;if(i=='error')timeout=120;if(timeout>0)setTimeout(function(){$(notice).fadeOut('slow',function(){$(this).remove()})},timeout*1000)};function htmlEntities(e){return String(e).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;')};function registerOpenClose(e){$(e).children('.on-click-open-close').click(function(){$(this).closest('.toggle-open-close').toggleClass('open closed')})};- \ No newline at end of file +else if(typeof n.selectionStart!='undefined'){var r=n.selectionStart,s=n.selectionEnd,o=n.value.substring(r,s);n.value=n.value.substr(0,r)+t+o+i+n.value.substr(s);var a;if(o.length==0){a=r+t.length} +else{a=r+t.length+o.length+i.length};n.selectionStart=a;n.selectionEnd=a} +else{a=n.value.length;var o=prompt('Text');n.value=n.value.substr(0,a)+t+o+i+n.value.substr(a)}};function createUrl(e,t,i,o,a){var n='./';n+='?';if(e)n+='&action='+e;if(t)n+='&subaction='+t;if(i)n+='&id='+i;if(typeof o==='string'){o=o.replace(/'/g,'"');var l=jQuery.parseJSON(o);jQuery.each(l,function(e,t){n=n+'&'+e+'='+t})} +else if(typeof o==='object'){jQuery.each(o,function(e,t){n=n+'&'+e+'='+t})} +else{};return n};function help(e,t,n){var i=$(e).closest('div.panel').find('li.action.active').attr('data-action'),o=$(e).closest('div.panel').find('li.action.active').attr('data-method');window.open(t+i+'/'+o+n,'OpenRat_Help','location=no,menubar=no,scrollbars=yes,toolbar=no,resizable=yes')};function htmlEntities(e){return String(e).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;')};function registerOpenClose(e){$(e).children('.on-click-open-close').click(function(){$(this).closest('.toggle-open-close').toggleClass('open closed')})};+ \ No newline at end of file diff --git a/modules/cms-ui/themes/default/script/openrat/common.js b/modules/cms-ui/themes/default/script/openrat/common.js @@ -11,164 +11,141 @@ $( function() { /* Fade in all elements. */ $('.initial-hidden').removeClass('initial-hidden'); - registerWorkbenchEvents(); + /** + * Registriert alle Events, die in der Workbench laufen sollen. + */ + function registerWorkbenchEvents() + { + // Modalen Dialog erzeugen. - // Listening to the "popstate" event: - window.onpopstate = function (ev) { - Navigator.navigateTo(ev.state); - }; - - initActualHistoryState(); - - Workbench.initialize(); - Workbench.reloadAll(); + /* + if ( $('#workbench div.panel.modal').length > 0 ) + { + $('#workbench div.panel.modal').parent().addClass('modal'); + $('div#filler').fadeTo(500,0.5); + $('#workbench').addClass('modal'); + } + */ + + /** + * Schaltet die Vollbildfunktion an oder aus. + * + * @param element Das Element, auf dem die Vollbildfunktion ausgeführt wurde + */ + function fullscreen( element ) { + $(element).closest('div.panel').fadeOut('fast', function() + { + $(this).toggleClass('fullscreen').fadeIn('fast'); + } ); + } - registerNavigation(); - // 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 ); - } ); + $('div.header').dblclick( function() + { + fullscreen( this ); + } ); + } + registerWorkbenchEvents(); - // Per Klick wird die Notice entfernt. - $('#noticebar .notice .image-icon--menu-close').click(function () { - $(this).closest('.notice').fadeOut('fast', function () { - $(this).remove(); - }); - }); - // Die Notices verschwinden automatisch. - $('#noticebar .notice').each(function () { - let noticeToClose = this; - setTimeout( function() { - $(noticeToClose).fadeOut('slow', function() { $(this).remove(); } ); - },30/*seconds*/ *1000 ); - }); + // Listening to the "popstate" event: + window.onpopstate = function (ev) { + Openrat.Navigator.navigateTo(ev.state); + }; + Openrat.Workbench.initialize(); + Openrat.Workbench.reloadAll(); - registerOpenClose($('section.toggle-open-close')); - $('section.toggle-open-close .on-click-open-close').click(function () { - var section = $(this).closest('section'); + let registerWorkbenchGlobalEvents = function() { - // disabled sections are ignored. - if (section.hasClass('disabled')) - return; + function registerNavigation() { + $(document).on('orNewAction',function(event, data) { - // if view is empty, lets load the content. - var view = section.find('div.view-loader'); - if (view.children().length == 0) - Workbench.loadNewActionIntoElement(view); - }); -}); + let url = './api/?action=tree&subaction=path&id=' + Openrat.Workbench.state.id + '&type=' + Openrat.Workbench.state.action + '&output=json'; + // Die Inhalte des Zweiges laden. + $.getJSON(url, function (json) { -function initActualHistoryState() { - var state = {}; - state.name = window.document.title; + $('nav .or-navtree-node').removeClass('or-navtree-node--selected'); - var params = new URLSearchParams( window.location.search ); + let output = json['output']; + $.each(output.path, function (idx, path) { - if (params.has('action')){ + $nav = $('nav .or-navtree-node[data-type='+path.type+'][data-id='+path.id+'].or-navtree-node--is-closed .or-navtree-node-control'); + $nav.click(); + }); + if ( output.actual ) + $('nav .or-navtree-node[data-type='+output.actual.type+'][data-id='+output.actual.id+']').addClass('or-navtree-node--selected'); - state.action = params.get('action'); - state.id = params.get('id' ); - state.name = window.document.title; + }).fail(function (e) { + // Ups... aber was können wir hier schon tun, außer hässliche Meldungen anzeigen. + console.warn(e); + console.warn('failed to load path from '+url); + }).always(function () { - state.data = {}; + }); + }); + } - //Iterate the search parameters. + registerNavigation(); - var params = Array.from( params.entries() ); - for( var entry in params ) { - state.data[params[entry][0]] = params[entry][1]; - }; + // 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 ); + } ); - Navigator.toActualHistory( state ); - } -} + // Per Klick wird die Notice entfernt. + $('#noticebar .notice .image-icon--menu-close').click(function () { + $(this).closest('.notice').fadeOut('fast', function () { + $(this).remove(); + }); + }); + // Die Notices verschwinden automatisch. + $('#noticebar .notice').each(function () { + let noticeToClose = this; + setTimeout( function() { + $(noticeToClose).fadeOut('slow', function() { $(this).remove(); } ); + },30/*seconds*/ *1000 ); -function registerNavigation() { - $(document).on('orNewAction',function(event, data) { - - let url = './api/?action=tree&subaction=path&id=' + Workbench.state.id + '&type=' + Workbench.state.action + '&output=json'; - - // Die Inhalte des Zweiges laden. - $.getJSON(url, function (json) { + }); - $('nav .or-navtree-node').removeClass('or-navtree-node--selected'); - let output = json['output']; - $.each(output.path, function (idx, path) { - $nav = $('nav .or-navtree-node[data-type='+path.type+'][data-id='+path.id+'].or-navtree-node--is-closed .or-navtree-node-control'); - $nav.click(); - }); - if ( output.actual ) - $('nav .or-navtree-node[data-type='+output.actual.type+'][data-id='+output.actual.id+']').addClass('or-navtree-node--selected'); + $('section.toggle-open-close .on-click-open-close').click(function () { + var section = $(this).closest('section'); - }).fail(function (e) { - // Ups... aber was können wir hier schon tun, außer hässliche Meldungen anzeigen. - console.warn(e); - console.warn('failed to load path from '+url); - }).always(function () { + // disabled sections are ignored. + if (section.hasClass('disabled')) + return; + // if view is empty, lets load the content. + var view = section.find('div.view-loader'); + if (view.children().length == 0) + Openrat.Workbench.loadNewActionIntoElement(view); }); - }); -} + } + registerWorkbenchGlobalEvents(); -/** - * Registriert alle Events, die in der Workbench laufen sollen. - */ -function registerWorkbenchEvents() -{ - // Modalen Dialog erzeugen. +}); - /* - if ( $('#workbench div.panel.modal').length > 0 ) - { - $('#workbench div.panel.modal').parent().addClass('modal'); - $('div#filler').fadeTo(500,0.5); - $('#workbench').addClass('modal'); - } - */ - - - $('div.header').dblclick( function() - { - fullscreen( this ); - } ); -} -/** - * Laden einer View. - * - * @param contentEl - * @param action - * @param method - * @param id - * @param params - */ -function loadView(contentEl,action,method,id,params ) -{ - Navigator.navigateToNewAction( action,method,id,params ); -} @@ -245,21 +222,70 @@ function afterViewLoaded(viewEl ) // Theme-Auswahl mit Preview $(viewEl).find('.or-theme-chooser').change( function() { - setUserStyle( this.value ); + Openrat.Workbench.setUserStyle( this.value ); }); -} -function registerDragAndDrop(viewEl) -{ + function registerMenuEvents($element ) + { + //$e = $($element); - registerDraggable(viewEl); - registerDroppable(viewEl); -} + // Mit der Maus irgendwo hin geklickt, das Menü muss schließen. + $('body').click( function() { + $('.toolbar-icon.menu').parents('.or-menu').removeClass('open'); + }); + // Mit der Maus geklicktes Menü aktivieren. + $($element).find('.toolbar-icon.menu').click( function(event) { + event.stopPropagation(); + $(this).parents('.or-menu').toggleClass('open'); + }); + + // Mit der Maus überstrichenes Menü aktivieren. + $($element).find('.toolbar-icon.menu').mouseover( function() { + + // close other menus. + $(this).parents('.or-menu').find('.toolbar-icon.menu').removeClass('open'); + // open the mouse-overed menu. + $(this).addClass('open'); + }); + + } + + function registerSearch($element ) + { + //$e = $($element); + $($element).find('.search input').orSearch( { dropdown:'#title div.search div.dropdown' } ); + + } + + + + function registerTree(element) { + + // Klick-Funktionen zum Öffnen/Schließen des Zweiges. + $(element).find('.or-navtree-node').orTree(); + + } + + + registerMenuEvents( viewEl ); + registerSearch ( viewEl ); + registerTree ( viewEl ); + + function registerDragAndDrop(viewEl) + { + + registerDraggable(viewEl); + registerDroppable(viewEl); + } + + registerDragAndDrop(viewEl); +} + function registerDraggable(viewEl) { @@ -287,26 +313,6 @@ function registerTreeBranchEvents(viewEl) function registerDroppable(viewEl) { - /* - $(viewEl).find('div.header > a.back').each( function(idx,el) { - $('div.content li.object > .entry[data-type=\'folder\']').droppable({ - accept: 'li.object', hoverClass: 'drophover', activeClass: 'dropactive', drop: function (event, ui) { - let dropped = ui.draggable; - let droppedOn = $(this).parent(); - - //alert('Moving '+$(dropped).attr('data-id')+' to folder '+$(droppedOn).attr('data-id') ); - startDialog($(this).text(), $(dropped).attr('data-type'), 'copy', $(droppedOn).attr('data-id'), { - 'action': $(dropped).attr('data-type'), - 'subaction': 'copy', - 'id': $(dropped).attr('data-id'), - 'targetFolderId': $(droppedOn).attr('data-id') - }); - //$(dropped).css({top: 0,left: 0}); // Nicht auf das eigene Fenster fallen lassen. - $(dropped).detach().css({top: 0, left: 0}).appendTo(droppedOn).click(); - } - }); - } -*/ $(viewEl).find('.or-droppable').droppable({ accept: '.or-draggable', @@ -327,100 +333,6 @@ function registerDroppable(viewEl) { -function registerMenuEvents($element ) -{ - //$e = $($element); - - // Mit der Maus irgendwo hin geklickt, das Menü muss schließen. - $('body').click( function() { - $('.toolbar-icon.menu').parents('.or-menu').removeClass('open'); - }); - // Mit der Maus geklicktes Menü aktivieren. - $($element).find('.toolbar-icon.menu').click( function(event) { - event.stopPropagation(); - $(this).parents('.or-menu').toggleClass('open'); - }); - - // Mit der Maus überstrichenes Menü aktivieren. - $($element).find('.toolbar-icon.menu').mouseover( function() { - - // close other menus. - $(this).parents('.or-menu').find('.toolbar-icon.menu').removeClass('open'); - // open the mouse-overed menu. - $(this).addClass('open'); - }); - -} - -function registerSearch($element ) -{ - //$e = $($element); - $($element).find('.search input').orSearch( { dropdown:'#title div.search div.dropdown' } ); - -} - - - -function registerTree(element) { - - // Klick-Funktionen zum Öffnen/Schließen des Zweiges. - $(element).find('.or-navtree-node').orTree(); - -} - - - -/** - * Schaltet die Vollbildfunktion an oder aus. - * - * @param element Das Element, auf dem die Vollbildfunktion ausgeführt wurde - */ -function fullscreen( element ) { - $(element).closest('div.panel').fadeOut('fast', function() - { - $(this).toggleClass('fullscreen').fadeIn('fast'); - } ); -} - - - - -/** - * Setzt neue View und aktualisiert alle Fenster. - * @param element - * @param action Action - * @param id Id - * @deprecated - */ - -function submitUrl( element,url ) -{ - postUrl( url,element ); - - // Alle refresh-fähigen Views mit dem neuen Objekt laden. - //refreshAllRefreshables(); -} - - -/** - * @deprecated - - * @param url - * @param element - */ -function postUrl(url,element) -{ - url += '&output=json'; - $.ajax( { 'type':'POST',url:url, data:{}, success:function(data, textStatus, jqXHR) - { - $('div.panel div.status div.loader').html('&nbsp;'); - doResponse(data,textStatus,element); - } } ); - -} - - - @@ -441,7 +353,7 @@ function startDialog( name,action,method,id,params ) if (!id) id = $('#editor').attr('data-id'); - let view = new View( action,method,id,params ); + let view = new Openrat.View( action,method,id,params ); view.before = function() { $('#dialog > .view').html('<div class="header"><img class="icon" title="" src="./themes/default/images/icon/'+method+'.png" />'+name+'</div>'); @@ -497,12 +409,12 @@ function startEdit( 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; + action = Openrat.Workbench.state.action; if (!id) - id = Workbench.state.id; + id = Openrat.Workbench.state.id; - let view = new View( action,method,id,params ); + let view = new Openrat.View( action,method,id,params ); view.before = function() { @@ -541,27 +453,29 @@ function setTitle( title ) $('head > title').text( $('head > title').data('default') ); } + + /** * Setzt neue Action und aktualisiert alle Fenster. * * @param action Action * @param id Id */ -function openNewAction( name,action,id,extraId ) +function openNewAction( name,action,id ) { // Im Mobilmodus soll das Menü verschwinden, wenn eine neue Action geoeffnet wird. $('nav').removeClass('open'); setTitle( name ); // Title setzen. - - setNewAction( action,id,extraId ); + + Openrat.Navigator.navigateToNew( {'action':action, 'id':id } ); } function filterMenus() { - let action = Workbench.state.action; - let id = Workbench.state.id; + let action = Openrat.Workbench.state.action; + let id = Openrat.Workbench.state.id; $('div.clickable').addClass('active'); $('div.clickable.filtered').removeClass('active').addClass('inactive'); @@ -577,83 +491,8 @@ function filterMenus() -/** - * Setzt neue Action und aktualisiert alle Fenster. - * - * @param action Action - * @param id Id - */ -function setNewAction( action,id,extraId ) -{ - Navigator.navigateToNewAction(action,'edit',id,extraId); - // Alle refresh-fähigen Views mit dem neuen Objekt laden. - //refreshAllRefreshables(); -} - - -/** - * Setzt neue Id und aktualisiert alle Fenster. - * @param id Id - */ -function setNewId( id ) { -} - - - -/** - * Notification im Browser anzeigen. - * Quelle: https://developer.mozilla.org/en-US/docs/Web/API/notification - * @param text Text der Nachricht. - */ -function notifyBrowser(text) -{ - // Let's check if the browser supports notifications - if (!("Notification" in window)) { - return; - //alert("This browser does not support desktop notification"); - } - - // 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. -} - - - -/** - * Setzt einen neuen Theme. - * @param styleName - * @returns - */ -function setUserStyle( styleName ) -{ - var html = $('html'); - var classList = html.attr('class').split(/\s+/); - $.each(classList, function(index, item) { - if (item.startsWith('theme-')) { - html.removeClass(item); - } - }); - html.addClass( 'theme-' + styleName.toLowerCase() ); -} - @@ -767,34 +606,6 @@ function createUrl(action,subaction,id,extraid,embed) } -/** - * Setzt Breite/Höhe für einen Container in der Workbench. - * - * Sind weitere Container enthalten, werden diese rekursiv angepasst. - * - * @param container - */ -function resizeWorkbenchContainer( container ) -{ -} - - - -/** - * Fenstergröße wurde verändert, nun die Größe der DIVs neu berechnen. - */ -function resizeWorkbench() -{ -} - - -/** - * Größe der TABs pro Frame neu berechnen. - */ -function resizeTabs( panel ) -{ -} - function help(el,url,suffix) { @@ -805,69 +616,6 @@ function help(el,url,suffix) } -/** - * Show a notice bubble in the UI. - * @param type - * @param name - * @param status - * @param msg - * @param log - */ -function notify( type,name,status,msg,log=[] ) -{ - // Notice-Bar mit dieser Meldung erweitern. - - let notice = $('<div class="notice '+status+'"></div>'); - - let toolbar = $('<div class="or-notice-toolbar"></div>'); - if ( log.length ) - $(toolbar).append('<i class="or-action-full image-icon image-icon--menu-fullscreen"></i>'); - $(toolbar).append('<i class="or-action-close image-icon image-icon--menu-close"></i>'); - $(notice).append(toolbar); - - id = 0; // TODO - if (name) - $(notice).append('<div class="name clickable"><a href="" data-type="open" data-action="'+type+'" data-id="'+id+'"><i class="or-action-full image-icon image-icon--action-'+type+'"></i> '+name+'</a></div>'); - - $(notice).append( '<div class="text">'+htmlEntities(msg)+'</div>'); - - if (log.length) { - - let logLi = log.reduce((result, item) => { - result += '<li><pre>'+htmlEntities(item)+'</pre></li>'; - return result; - }, ''); - $(notice).append('<div class="log"><ul>'+logLi+'</ul></div>'); - } - - $('#noticebar').prepend(notice); // Notice anhängen. - $(notice).orLinkify(); // Enable links - - - // Toogle Fullscreen for notice - $(notice).find('.or-action-full').click( function() { - $(notice).toggleClass('full'); - }); - - // Close the notice on click - $(notice).find('.or-action-close').click( function() { - $(notice).fadeOut('fast',function() { $(notice).remove(); } ); - }); - - // Fadeout the notice after a while. - let timeout = 1; - if ( status == 'ok' ) timeout = 20; - if ( status == 'info' ) timeout = 60; - if ( status == 'warning') timeout = 120; - if ( status == 'error' ) timeout = 120; - - if (timeout > 0) - setTimeout( function() { - $(notice).fadeOut('slow', function() { $(this).remove(); } ); - },timeout*1000 ); -} - - function htmlEntities(str) { return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;'); } diff --git a/modules/cms-ui/themes/default/script/openrat/common.min.js b/modules/cms-ui/themes/default/script/openrat/common.min.js @@ -1,9 +1,7 @@ -;var OR_THEMES_EXT_DIR='modules/cms-ui/themes/';$(function(){$('html').removeClass('nojs');$('.initial-hidden').removeClass('initial-hidden');registerWorkbenchEvents();window.onpopstate=function(e){Navigator.navigateTo(e.state)};initActualHistoryState();Workbench.initialize();Workbench.reloadAll();registerNavigation();$('.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)});$('#noticebar .notice .image-icon--menu-close').click(function(){$(this).closest('.notice').fadeOut('fast',function(){$(this).remove()})});$('#noticebar .notice').each(function(){let noticeToClose=this;setTimeout(function(){$(noticeToClose).fadeOut('slow',function(){$(this).remove()})},30*1000)});registerOpenClose($('section.toggle-open-close'));$('section.toggle-open-close .on-click-open-close').click(function(){var t=$(this).closest('section');if(t.hasClass('disabled'))return;var e=t.find('div.view-loader');if(e.children().length==0)Workbench.loadNewActionIntoElement(e)})});function initActualHistoryState(){var t={};t.name=window.document.title;var e=new URLSearchParams(window.location.search);if(e.has('action')){t.action=e.get('action');t.id=e.get('id');t.name=window.document.title;t.data={};var e=Array.from(e.entries());for(var i in e){t.data[e[i][0]]=e[i][1]};Navigator.toActualHistory(t)}};function registerNavigation(){$(document).on('orNewAction',function(e,t){let url='./api/?action=tree&subaction=path&id='+Workbench.state.id+'&type='+Workbench.state.action+'&output=json';$.getJSON(url,function(e){$('nav .or-navtree-node').removeClass('or-navtree-node--selected');let output=e['output'];$.each(output.path,function(e,t){$nav=$('nav .or-navtree-node[data-type='+t.type+'][data-id='+t.id+'].or-navtree-node--is-closed .or-navtree-node-control');$nav.click()});if(output.actual)$('nav .or-navtree-node[data-type='+output.actual.type+'][data-id='+output.actual.id+']').addClass('or-navtree-node--selected')}).fail(function(e){console.warn(e);console.warn('failed to load path from '+url)}).always(function(){})})};function registerWorkbenchEvents(){$('div.header').dblclick(function(){fullscreen(this)})};function loadView(e,t,i,n,o){Navigator.navigateToNewAction(t,i,n,o)};function afterViewLoaded(e){var t=$(e).closest('section');t.toggleClass('is-empty',$(e).is(':empty'));$(e).trigger('orViewLoaded');$(e).closest('div.panel').find('div.header div.dropdown div.entry.perview').remove();$(e).find('.toggle-nav-open-close').click(function(){$('nav').toggleClass('open')});$(e).find('.toggle-nav-small').click(function(){$('nav').toggleClass('small')});$(e).find('div.headermenu > a').each(function(e,t){});$(e).find('div.header > a.back').each(function(t,i){$(i).removeClass('button').wrap('<div class="entry perview" />').parent().appendTo($(e).closest('div.panel').find('div.header div.dropdown').first())});$(e).find('div.selector.tree').each(function(){var e=this;$(this).orTree({type:'project',selectable:$(e).attr('data-types').split(','),id:$(e).attr('data-init-folderid'),onSelect:function(t,i,n){var o=$(e).parent();$(o).find('input[type=text]').attr('value',t);$(o).find('input[type=hidden]').attr('value',n)}})});registerDragAndDrop(e);$(e).find('input').change(function(){$(this).parent('div.view').addClass('dirty')});$(e).find('.or-theme-chooser').change(function(){setUserStyle(this.value)})};function registerDragAndDrop(e){registerDraggable(e);registerDroppable(e)};function registerDraggable(e){$(e).find('.or-draggable').draggable({helper:'clone',opacity:0.7,zIndex:2,distance:10,cursor:'move',revert:'false'})};function registerTreeBranchEvents(e){registerDraggable(e)};function registerDroppable(e){$(e).find('.or-droppable').droppable({accept:'.or-draggable',hoverClass:'or-droppable--hover',activeClass:'or-droppable--active',drop:function(e,t){let dropped=t.draggable;$(this).find('.or-selector-link-value').val(dropped.data('id'));$(this).find('.or-selector-link-name').val(dropped.data('id'))}})};function registerMenuEvents(e){$('body').click(function(){$('.toolbar-icon.menu').parents('.or-menu').removeClass('open')});$(e).find('.toolbar-icon.menu').click(function(e){e.stopPropagation();$(this).parents('.or-menu').toggleClass('open')});$(e).find('.toolbar-icon.menu').mouseover(function(){$(this).parents('.or-menu').find('.toolbar-icon.menu').removeClass('open');$(this).addClass('open')})};function registerSearch(e){$(e).find('.search input').orSearch({dropdown:'#title div.search div.dropdown'})};function registerTree(e){$(e).find('.or-navtree-node').orTree()};function fullscreen(e){$(e).closest('div.panel').fadeOut('fast',function(){$(this).toggleClass('fullscreen').fadeIn('fast')})};function submitUrl(e,t){postUrl(t,e)};function postUrl(e,t){e+='&output=json';$.ajax({'type':'POST',url:e,data:{},success:function(e,i,n){$('div.panel div.status div.loader').html('&nbsp;');doResponse(e,i,t)}})};function startDialog(e,t,i,n,o){if(!t)t=$('#editor').attr('data-action');if(!n)n=$('#editor').attr('data-id');let view=new View(t,i,n,o);view.before=function(){$('#dialog > .view').html('<div class="header"><img class="icon" title="" src="./themes/default/images/icon/'+i+'.png" />'+e+'</div>');$('#dialog > .view').data('id',n);$('#dialog').removeClass('is-closed').addClass('is-open');let view=this;this.escapeKeyClosingHandler=function(e){if(e.keyCode==27){view.close();$(document).off('keyup')}};$(document).keyup(this.escapeKeyClosingHandler);$('#dialog .filler').click(function(){view.close()})};view.close=function(){if($('div#dialog').hasClass('modal'))return;$('#dialog .view').fadeOut('fast').html('');$('#dialog').removeClass('is-open').addClass('is-closed');$(document).unbind('keyup',this.escapeKeyClosingHandler)};view.start($('div#dialog > .view'))};function startEdit(e,t,i,n,o){if(!t)t=Workbench.state.action;if(!n)n=Workbench.state.id;let view=new View(t,i,n,o);view.before=function(){let view=this;$edit=$('#edit');$edit.addClass('is-open');$('#editor').addClass('is-closed');$('#edit .filler').click(function(){view.close()})};view.close=function(){$edit.removeClass('is-open');$('#editor').removeClass('is-closed')};view.start($('#edit > .view'))};function setTitle(e){if(e)$('head > title').text(e+' - '+$('head > title').data('default'));else $('head > title').text($('head > title').data('default'))};function openNewAction(e,t,i,n){$('nav').removeClass('open');setTitle(e);setNewAction(t,i,n)};function filterMenus(){let action=Workbench.state.action;let id=Workbench.state.id;$('div.clickable').addClass('active');$('div.clickable.filtered').removeClass('active').addClass('inactive');$('div.clickable.filtered.on-action-'+action).addClass('active').removeClass('inactive');$('div.clickable.filtered a').attr('data-id',id)};function setNewAction(e,t,i){Navigator.navigateToNewAction(e,'edit',t,i)};function setNewId(e){};function notifyBrowser(e){if(!('Notification' in window)){return} -else if(Notification.permission==='granted'){let notification=new Notification(e)} -else if(Notification.permission!=='denied'){Notification.requestPermission(function(t){if(t==='granted'){let notification=new Notification(e)}})}};function setUserStyle(e){var t=$('html'),i=t.attr('class').split(/\s+/);$.each(i,function(e,i){if(i.startsWith('theme-')){t.removeClass(i)}});t.addClass('theme-'+e.toLowerCase())};function insert(e,t,i){var n=document.forms[0].elements[e];n.focus();if(typeof document.selection!='undefined'){var l=document.selection.createRange(),o=l.text;l.text=t+o+i;l=document.selection.createRange();if(o.length==0){l.move('character',-i.length)} +;var OR_THEMES_EXT_DIR='modules/cms-ui/themes/';$(function(){$('html').removeClass('nojs');$('.initial-hidden').removeClass('initial-hidden');function e(){function e(e){$(e).closest('div.panel').fadeOut('fast',function(){$(this).toggleClass('fullscreen').fadeIn('fast')})};$('div.header').dblclick(function(){e(this)})};e();window.onpopstate=function(e){Openrat.Navigator.navigateTo(e.state)};Openrat.Workbench.initialize();Openrat.Workbench.reloadAll();let registerWorkbenchGlobalEvents=function(){function e(){$(document).on('orNewAction',function(e,t){let url='./api/?action=tree&subaction=path&id='+Openrat.Workbench.state.id+'&type='+Openrat.Workbench.state.action+'&output=json';$.getJSON(url,function(e){$('nav .or-navtree-node').removeClass('or-navtree-node--selected');let output=e['output'];$.each(output.path,function(e,t){$nav=$('nav .or-navtree-node[data-type='+t.type+'][data-id='+t.id+'].or-navtree-node--is-closed .or-navtree-node-control');$nav.click()});if(output.actual)$('nav .or-navtree-node[data-type='+output.actual.type+'][data-id='+output.actual.id+']').addClass('or-navtree-node--selected')}).fail(function(e){console.warn(e);console.warn('failed to load path from '+url)}).always(function(){})})};e();$('.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)});$('#noticebar .notice .image-icon--menu-close').click(function(){$(this).closest('.notice').fadeOut('fast',function(){$(this).remove()})});$('#noticebar .notice').each(function(){let noticeToClose=this;setTimeout(function(){$(noticeToClose).fadeOut('slow',function(){$(this).remove()})},30*1000)});$('section.toggle-open-close .on-click-open-close').click(function(){var t=$(this).closest('section');if(t.hasClass('disabled'))return;var e=t.find('div.view-loader');if(e.children().length==0)Openrat.Workbench.loadNewActionIntoElement(e)})};registerWorkbenchGlobalEvents()});function afterViewLoaded(e){var n=$(e).closest('section');n.toggleClass('is-empty',$(e).is(':empty'));$(e).trigger('orViewLoaded');$(e).closest('div.panel').find('div.header div.dropdown div.entry.perview').remove();$(e).find('.toggle-nav-open-close').click(function(){$('nav').toggleClass('open')});$(e).find('.toggle-nav-small').click(function(){$('nav').toggleClass('small')});$(e).find('div.headermenu > a').each(function(e,t){});$(e).find('div.header > a.back').each(function(t,n){$(n).removeClass('button').wrap('<div class="entry perview" />').parent().appendTo($(e).closest('div.panel').find('div.header div.dropdown').first())});$(e).find('div.selector.tree').each(function(){var e=this;$(this).orTree({type:'project',selectable:$(e).attr('data-types').split(','),id:$(e).attr('data-init-folderid'),onSelect:function(t,n,i){var o=$(e).parent();$(o).find('input[type=text]').attr('value',t);$(o).find('input[type=hidden]').attr('value',i)}})});t(e);$(e).find('input').change(function(){$(this).parent('div.view').addClass('dirty')});$(e).find('.or-theme-chooser').change(function(){Openrat.Workbench.setUserStyle(this.value)});function i(e){$('body').click(function(){$('.toolbar-icon.menu').parents('.or-menu').removeClass('open')});$(e).find('.toolbar-icon.menu').click(function(e){e.stopPropagation();$(this).parents('.or-menu').toggleClass('open')});$(e).find('.toolbar-icon.menu').mouseover(function(){$(this).parents('.or-menu').find('.toolbar-icon.menu').removeClass('open');$(this).addClass('open')})};function o(e){$(e).find('.search input').orSearch({dropdown:'#title div.search div.dropdown'})};function a(e){$(e).find('.or-navtree-node').orTree()};i(e);o(e);a(e);function t(e){registerDraggable(e);registerDroppable(e)};t(e)};function registerDraggable(e){$(e).find('.or-draggable').draggable({helper:'clone',opacity:0.7,zIndex:2,distance:10,cursor:'move',revert:'false'})};function registerTreeBranchEvents(e){registerDraggable(e)};function registerDroppable(e){$(e).find('.or-droppable').droppable({accept:'.or-draggable',hoverClass:'or-droppable--hover',activeClass:'or-droppable--active',drop:function(e,t){let dropped=t.draggable;$(this).find('.or-selector-link-value').val(dropped.data('id'));$(this).find('.or-selector-link-name').val(dropped.data('id'))}})};function startDialog(e,t,n,i,o){if(!t)t=$('#editor').attr('data-action');if(!i)i=$('#editor').attr('data-id');let view=new Openrat.View(t,n,i,o);view.before=function(){$('#dialog > .view').html('<div class="header"><img class="icon" title="" src="./themes/default/images/icon/'+n+'.png" />'+e+'</div>');$('#dialog > .view').data('id',i);$('#dialog').removeClass('is-closed').addClass('is-open');let view=this;this.escapeKeyClosingHandler=function(e){if(e.keyCode==27){view.close();$(document).off('keyup')}};$(document).keyup(this.escapeKeyClosingHandler);$('#dialog .filler').click(function(){view.close()})};view.close=function(){if($('div#dialog').hasClass('modal'))return;$('#dialog .view').fadeOut('fast').html('');$('#dialog').removeClass('is-open').addClass('is-closed');$(document).unbind('keyup',this.escapeKeyClosingHandler)};view.start($('div#dialog > .view'))};function startEdit(e,t,n,i,o){if(!t)t=Openrat.Workbench.state.action;if(!i)i=Openrat.Workbench.state.id;let view=new Openrat.View(t,n,i,o);view.before=function(){let view=this;$edit=$('#edit');$edit.addClass('is-open');$('#editor').addClass('is-closed');$('#edit .filler').click(function(){view.close()})};view.close=function(){$edit.removeClass('is-open');$('#editor').removeClass('is-closed')};view.start($('#edit > .view'))};function setTitle(e){if(e)$('head > title').text(e+' - '+$('head > title').data('default'));else $('head > title').text($('head > title').data('default'))};function openNewAction(e,t,n){$('nav').removeClass('open');setTitle(e);Openrat.Navigator.navigateToNew({'action':t,'id':n})};function filterMenus(){let action=Openrat.Workbench.state.action;let id=Openrat.Workbench.state.id;$('div.clickable').addClass('active');$('div.clickable.filtered').removeClass('active').addClass('inactive');$('div.clickable.filtered.on-action-'+action).addClass('active').removeClass('inactive');$('div.clickable.filtered a').attr('data-id',id)};function insert(e,t,i){var n=document.forms[0].elements[e];n.focus();if(typeof document.selection!='undefined'){var l=document.selection.createRange(),o=l.text;l.text=t+o+i;l=document.selection.createRange();if(o.length==0){l.move('character',-i.length)} else{l.moveStart('character',t.length+o.length+i.length)};l.select()} -else if(typeof n.selectionStart!='undefined'){var s=n.selectionStart,c=n.selectionEnd,o=n.value.substring(s,c);n.value=n.value.substr(0,s)+t+o+i+n.value.substr(c);var a;if(o.length==0){a=s+t.length} -else{a=s+t.length+o.length+i.length};n.selectionStart=a;n.selectionEnd=a} -else{a=n.value.length;var o=prompt('Text');n.value=n.value.substr(0,a)+t+o+i+n.value.substr(a)}};function createUrl(e,t,i,n,a){var o='./';o+='?';if(e)o+='&action='+e;if(t)o+='&subaction='+t;if(i)o+='&id='+i;if(typeof n==='string'){n=n.replace(/'/g,'"');var l=jQuery.parseJSON(n);jQuery.each(l,function(e,t){o=o+'&'+e+'='+t})} -else if(typeof n==='object'){jQuery.each(n,function(e,t){o=o+'&'+e+'='+t})} -else{};return o};function resizeWorkbenchContainer(e){};function resizeWorkbench(){};function resizeTabs(e){};function help(e,t,i){var n=$(e).closest('div.panel').find('li.action.active').attr('data-action'),o=$(e).closest('div.panel').find('li.action.active').attr('data-method');window.open(t+n+'/'+o+i,'OpenRat_Help','location=no,menubar=no,scrollbars=yes,toolbar=no,resizable=yes')};function notify(e,t,i,n,log=[]){let notice=$('<div class="notice '+i+'"></div>');let toolbar=$('<div class="or-notice-toolbar"></div>');if(log.length)$(toolbar).append('<i class="or-action-full image-icon image-icon--menu-fullscreen"></i>');$(toolbar).append('<i class="or-action-close image-icon image-icon--menu-close"></i>');$(notice).append(toolbar);id=0;if(t)$(notice).append('<div class="name clickable"><a href="" data-type="open" data-action="'+e+'" data-id="'+id+'"><i class="or-action-full image-icon image-icon--action-'+e+'"></i> '+t+'</a></div>');$(notice).append('<div class="text">'+htmlEntities(n)+'</div>');if(log.length){let logLi=log.reduce((result,item)=>{result+='<li><pre>'+htmlEntities(item)+'</pre></li>';return result},'');$(notice).append('<div class="log"><ul>'+logLi+'</ul></div>')};$('#noticebar').prepend(notice);$(notice).orLinkify();$(notice).find('.or-action-full').click(function(){$(notice).toggleClass('full')});$(notice).find('.or-action-close').click(function(){$(notice).fadeOut('fast',function(){$(notice).remove()})});let timeout=1;if(i=='ok')timeout=20;if(i=='info')timeout=60;if(i=='warning')timeout=120;if(i=='error')timeout=120;if(timeout>0)setTimeout(function(){$(notice).fadeOut('slow',function(){$(this).remove()})},timeout*1000)};function htmlEntities(e){return String(e).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;')};function registerOpenClose(e){$(e).children('.on-click-open-close').click(function(){$(this).closest('.toggle-open-close').toggleClass('open closed')})};- \ No newline at end of file +else if(typeof n.selectionStart!='undefined'){var r=n.selectionStart,s=n.selectionEnd,o=n.value.substring(r,s);n.value=n.value.substr(0,r)+t+o+i+n.value.substr(s);var a;if(o.length==0){a=r+t.length} +else{a=r+t.length+o.length+i.length};n.selectionStart=a;n.selectionEnd=a} +else{a=n.value.length;var o=prompt('Text');n.value=n.value.substr(0,a)+t+o+i+n.value.substr(a)}};function createUrl(e,t,i,o,a){var n='./';n+='?';if(e)n+='&action='+e;if(t)n+='&subaction='+t;if(i)n+='&id='+i;if(typeof o==='string'){o=o.replace(/'/g,'"');var l=jQuery.parseJSON(o);jQuery.each(l,function(e,t){n=n+'&'+e+'='+t})} +else if(typeof o==='object'){jQuery.each(o,function(e,t){n=n+'&'+e+'='+t})} +else{};return n};function help(e,t,n){var i=$(e).closest('div.panel').find('li.action.active').attr('data-action'),o=$(e).closest('div.panel').find('li.action.active').attr('data-method');window.open(t+i+'/'+o+n,'OpenRat_Help','location=no,menubar=no,scrollbars=yes,toolbar=no,resizable=yes')};function htmlEntities(e){return String(e).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;')};function registerOpenClose(e){$(e).children('.on-click-open-close').click(function(){$(this).closest('.toggle-open-close').toggleClass('open closed')})};+ \ No newline at end of file diff --git a/modules/cms-ui/themes/default/script/openrat/form.js b/modules/cms-ui/themes/default/script/openrat/form.js @@ -4,7 +4,7 @@ * * @constructor */ -function Form() { +Openrat.Form = function() { this.setLoadStatus = function( isLoading ) { $(this.element).closest('div.content').toggleClass('loader',isLoading); @@ -85,9 +85,9 @@ function Form() { // If form does not contain action/id, get it from the workbench. if (!data.id) - data.id = Workbench.state.id; + data.id = Openrat.Workbench.state.id; if (!data.action) - data.action = Workbench.state.action; + data.action = Openrat.Workbench.state.action; let formMethod = $(this.element).attr('method').toUpperCase(); @@ -132,12 +132,12 @@ function Form() { try { let error = jQuery.parseJSON( jqXHR.responseText ); - notify('','','error',error.error,[error.description]); + Openrat.Workbench.notify('','','error',error.error,[error.description]); } catch( e ) { let msg = jqXHR.responseText; - notify('','','error','Server Error',[msg]); + Openrat.Workbench.notify('','','error','Server Error',[msg]); } diff --git a/modules/cms-ui/themes/default/script/openrat/form.min.js b/modules/cms-ui/themes/default/script/openrat/form.min.js @@ -1,152 +1,2 @@ - -/** - * Form. - * - * @constructor - */ -function Form() { - - this.setLoadStatus = function( isLoading ) { - $(this.element).closest('div.content').toggleClass('loader',isLoading); - } - - this.initOnElement = function( element ) { - this.element = element; - - let form = this; - - // Autosave in Formularen. - // Bei Veränderungen von Checkboxen wird das Formular sofort abgeschickt. - $(element).find('form[data-autosave="true"] input[type="checkbox"]').click( function() { - form.submit(); - }); - - // 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-form-btn--cancel').click( function() { - form.cancel(); - - }); - $(element).find('.or-form-btn--reset').click( function() { - form.rollback(); - - }); - - // 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. - }); - } - - this.cancel = function() { - //$(this.element).html('').parent().removeClass('is-open'); - this.close(); - } - - - this.rollback = function() { - this.element.trigger('reset'); - } - - this.close = function() { - - } - - this.submit = function() { - - - // Show progress - let status = $('<div class="notice info"><div class="text loader"></div></div>'); - $('#noticebar').prepend(status); // Notice anhängen. - $(status).show(); - - // Alle vorhandenen Error-Marker entfernen. - // Falls wieder ein Fehler auftritt, werden diese erneut gesetzt. - $(this.element).find('.error').removeClass('error'); - - var params = $(this.element).serializeArray(); - var data = {}; - $(params).each(function(index, obj){ - data[obj.name] = obj.value; - }); - - // If form does not contain action/id, get it from the workbench. - if (!data.id) - data.id = Workbench.state.id; - if (!data.action) - data.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. - //Workbench.loadViewIntoElement( $(form).parent('.view'),data.action, data.subaction,data.id,data ); - this.forwardTo( data.action, data.subaction,data.id,data ); - } - 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. - data.output = 'json'; - - if ( $(this.element).data('async') || $(this.element).data('async')=='true') - { - // Verarbeitung erfolgt asynchron, das heißt, dass der evtl. geöffnete Dialog - // beendet wird. - this.close(); - // Async: Window is closed, but the action will be startet now. - } - - let form = this; - $.ajax( { 'type':'POST',url:url, data:data, success:function(data, textStatus, jqXHR) - { - form.setLoadStatus(false); - $(status).remove(); - - doResponse(data,textStatus,form.element); - }, - error:function(jqXHR, textStatus, errorThrown) { - form.setLoadStatus(false); - $(status).remove(); - - try - { - let error = jQuery.parseJSON( jqXHR.responseText ); - notify('','','error',error.error,[error.description]); - } - catch( e ) - { - let msg = jqXHR.responseText; - notify('','','error','Server Error',[msg]); - } - - - } - - } ); - $(form.element).fadeIn(); - } - - } -} - +;Openrat.Form=function(){this.setLoadStatus=function(t){$(this.element).closest('div.content').toggleClass('loader',t)};this.initOnElement=function(t){this.element=t;let form=this;$(t).find('form[data-autosave="true"] input[type="checkbox"]').click(function(){form.submit()});$(t).find('.or-form-btn--cancel').click(function(){form.cancel()});$(t).find('.or-form-btn--reset').click(function(){form.rollback()});$(t).submit(function(t){if($(this).data('target')=='view'){form.submit();t.preventDefault()}})};this.cancel=function(){this.close()};this.rollback=function(){this.element.trigger('reset')};this.close=function(){};this.submit=function(){let status=$('<div class="notice info"><div class="text loader"></div></div>');$('#noticebar').prepend(status);$(status).show();$(this.element).find('.error').removeClass('error');var e=$(this.element).serializeArray(),t={};$(e).each(function(e,r){t[r.name]=r.value});if(!t.id)t.id=Openrat.Workbench.state.id;if(!t.action)t.action=Openrat.Workbench.state.action;let formMethod=$(this.element).attr('method').toUpperCase();if(formMethod=='GET'){this.forwardTo(t.action,t.subaction,t.id,t)} +else{let url='./api/';this.setLoadStatus(!0);url+='';t.output='json';if($(this.element).data('async')||$(this.element).data('async')=='true'){this.close()};let form=this;$.ajax({'type':'POST',url:url,data:t,success:function(t,e,r){form.setLoadStatus(!1);$(status).remove();doResponse(t,e,form.element)},error:function(t,e,r){form.setLoadStatus(!1);$(status).remove();try{let error=jQuery.parseJSON(t.responseText);Openrat.Workbench.notify('','','error',error.error,[error.description])}catch(o){let msg=t.responseText;Openrat.Workbench.notify('','','error','Server Error',[msg])}}});$(form.element).fadeIn()}}};+ \ No newline at end of file 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,4 @@ // Create own namespace. -window.openrat = {}; +window.Openrat = {}; diff --git a/modules/cms-ui/themes/default/script/openrat/init.min.js b/modules/cms-ui/themes/default/script/openrat/init.min.js @@ -1,4 +1 @@ - -// Create own namespace. - -window.openrat = {}; +;window.Openrat={};+ \ No newline at end of file diff --git a/modules/cms-ui/themes/default/script/openrat/navigator.js b/modules/cms-ui/themes/default/script/openrat/navigator.js @@ -1,14 +1,14 @@ /** * Navigation. */ -var Navigator = new function () { +Openrat.Navigator = new function () { 'use strict'; /** - * Navigiert zu einer Action, aber ohne ein neues History-Element einzufügen. + * Navigiert zu einer Action. */ this.navigateTo = function(state) { - Workbench.loadNewActionState(state); + Openrat.Workbench.loadNewActionState(state); } @@ -18,15 +18,11 @@ var Navigator = new function () { */ this.navigateToNew = function(obj) { - Workbench.loadNewActionState(obj); + this.navigateTo(obj); + window.history.pushState(obj,obj.name,'./#/'+obj.action+(obj.id?'/'+obj.id:'') ); } - this.navigateToNewAction = function(action, method, id, params ) { - var state = {action:action,method:method,id:id.replace(/[^0-9_]/gim,""),data:params}; - this.navigateToNew(state); - } - /** * Setzt den State für den aktuellen History-Eintrag. * @param obj @@ -35,5 +31,3 @@ var Navigator = new function () { window.history.replaceState(obj,obj.name,createUrl(obj.action,null,obj.id,obj.data,false) ); } } - -openrat.navigator = Navigator;- \ No newline at end of file diff --git a/modules/cms-ui/themes/default/script/openrat/navigator.min.js b/modules/cms-ui/themes/default/script/openrat/navigator.min.js @@ -1,39 +1 @@ -/** - * Navigation. - */ -var Navigator = new function () { - 'use strict'; - - /** - * Navigiert zu einer Action, aber ohne ein neues History-Element einzufügen. - */ - this.navigateTo = function(state) { - Workbench.loadNewActionState(state); - } - - - /** - * - * Navigiert zu einer neue Action und fügt einen neuen History-Eintrag hinzu. - */ - this.navigateToNew = function(obj) { - - Workbench.loadNewActionState(obj); - window.history.pushState(obj,obj.name,'./#/'+obj.action+(obj.id?'/'+obj.id:'') ); - } - - this.navigateToNewAction = function(action, method, id, params ) { - var state = {action:action,method:method,id:id.replace(/[^0-9_]/gim,""),data:params}; - this.navigateToNew(state); - } - - /** - * Setzt den State für den aktuellen History-Eintrag. - * @param obj - */ - this.toActualHistory = function(obj) { - window.history.replaceState(obj,obj.name,createUrl(obj.action,null,obj.id,obj.data,false) ); - } -} - -openrat.navigator = Navigator;- \ No newline at end of file +;Openrat.Navigator=new function(){'use strict';this.navigateTo=function(t){Openrat.Workbench.loadNewActionState(t)};this.navigateToNew=function(t){this.navigateTo(t);window.history.pushState(t,t.name,'./#/'+t.action+(t.id?'/'+t.id:''))};this.toActualHistory=function(t){window.history.replaceState(t,t.name,createUrl(t.action,null,t.id,t.data,!1))}};+ \ No newline at end of file diff --git a/modules/cms-ui/themes/default/script/openrat/view.js b/modules/cms-ui/themes/default/script/openrat/view.js @@ -9,7 +9,7 @@ * @param params * @constructor */ -function View( action,method,id,params ) { +Openrat.View = function( action,method,id,params ) { this.action = action; this.method = method; @@ -34,9 +34,6 @@ function View( action,method,id,params ) { function registerViewEvents(element) { - registerMenuEvents( element ); - registerSearch ( element ); - registerTree ( element ); afterViewLoaded ( element ); } @@ -55,7 +52,7 @@ function View( action,method,id,params ) { $(element).removeClass("loader"); $(element).find('form').each( function() { - let form = new Form(); + let form = new Openrat.Form(); form.close = function() { view.close(); } @@ -67,7 +64,7 @@ function View( action,method,id,params ) { // Seite nicht gefunden. $(element).html(""); - notify('','','error','Server Error',['Server Error while requesting url '+url, response]); + Openrat.Workbench.notify('','','error','Server Error',['Server Error while requesting url '+url, response]); return; } diff --git a/modules/cms-ui/themes/default/script/openrat/view.min.js b/modules/cms-ui/themes/default/script/openrat/view.min.js @@ -1,80 +1 @@ -/** - * View. - * Eine View ist ein HTML-Fragment, in das eine Action geladen wird. - * Das Erzeugen der View, das Laden vom Server sowie das Schließen sind hier gekapselt. - * - * @param action - * @param method - * @param id - * @param params - * @constructor - */ -function View( action,method,id,params ) { - - this.action = action; - this.method = method; - this.id = id; - this.params = params; - - this.before = function() {}; - - this.start = function( element ) { - this.before(); - this.element = element; - this.loadView(); - } - - this.afterLoad = function() { - - } - - this.close = function() { - } - - - function registerViewEvents(element) { - - registerMenuEvents( element ); - registerSearch ( element ); - registerTree ( element ); - afterViewLoaded ( element ); - - } - - - this.loadView = function() { - - let url = createUrl( this.action,this.method,this.id,this.params,true); // URL für das Laden erzeugen. - let element = this.element; - let view = this; - - $(this.element).empty().fadeTo(1,0.7).addClass('loader').html('').load(url,function(response, status, xhr) { - - $(element).fadeTo(350,1); - - $(element).removeClass("loader"); - - $(element).find('form').each( function() { - let form = new Form(); - form.close = function() { - view.close(); - } - form.initOnElement(this); - - }); - if ( status == "error" ) - { - // Seite nicht gefunden. - $(element).html(""); - - notify('','','error','Server Error',['Server Error while requesting url '+url, response]); - return; - } - - registerViewEvents( element ); - - }); - - } - -} +;Openrat.View=function(e,t,i,r){this.action=e;this.method=t;this.id=i;this.params=r;this.before=function(){};this.start=function(e){this.before();this.element=e;this.loadView()};this.afterLoad=function(){};this.close=function(){};function n(e){afterViewLoaded(e)};this.loadView=function(){let url=createUrl(this.action,this.method,this.id,this.params,!0);let element=this.element;let view=this;$(this.element).empty().fadeTo(1,0.7).addClass('loader').html('').load(url,function(e,t,i){$(element).fadeTo(350,1);$(element).removeClass('loader');$(element).find('form').each(function(){let form=new Openrat.Form();form.close=function(){view.close()};form.initOnElement(this)});if(t=='error'){$(element).html('');Openrat.Workbench.notify('','','error','Server Error',['Server Error while requesting url '+url,e]);return};n(element)})}};+ \ No newline at end of file diff --git a/modules/cms-ui/themes/default/script/openrat/workbench.js b/modules/cms-ui/themes/default/script/openrat/workbench.js @@ -1,10 +1,13 @@ -var Workbench = new function() +Openrat.Workbench = new function() { 'use strict'; // Strict mode + this.state = {}; + + /** * Initializes the Workbench. */ @@ -52,13 +55,15 @@ var Workbench = new function() // Only numbers and '_' allowed in the id. state.id = parts[2].replace(/[^0-9_]/gim,""); - Workbench.state = state; + Openrat.Workbench.state = state; // TODO: Remove this sometimes.... only state. $('#editor').attr('data-action',state.action); $('#editor').attr('data-id' ,state.id ); $('#editor').attr('data-extra' ,'{}' ); + Openrat.Navigator.toActualHistory( state ); + } /** @@ -87,8 +92,8 @@ var Workbench = new function() this.loadNewActionState = function(state) { - Workbench.state = state; - Workbench.loadNewAction(state.action,state.id,state.data); + Openrat.Workbench.state = state; + Openrat.Workbench.loadNewAction(state.action,state.id,state.data); filterMenus(); @@ -119,7 +124,7 @@ var Workbench = new function() // View in geschlossenen Sektionen löschen, damit diese nicht stehen bleiben. $('#workbench section.closed .view-loader').empty(); - Workbench.loadViews( $('#workbench section.open .view-loader') ); + Openrat.Workbench.loadViews( $('#workbench section.open .view-loader') ); } @@ -128,7 +133,7 @@ var Workbench = new function() // View in geschlossenen Sektionen löschen, damit diese nicht stehen bleiben. $('#workbench .view').empty(); - Workbench.loadViews( $('#workbench .view') ); + Openrat.Workbench.loadViews( $('#workbench .view') ); } @@ -140,7 +145,7 @@ var Workbench = new function() let $targetDOMElement = $(this); - Workbench.loadNewActionIntoElement( $targetDOMElement ) + Openrat.Workbench.loadNewActionIntoElement( $targetDOMElement ) }); } @@ -160,11 +165,134 @@ var Workbench = new function() let method = $viewElement.data('method'); - let view = new View( action,method,id,params ); + let view = new Openrat.View( action,method,id,params ); view.start( $viewElement ); } + + + /** + * Setzt einen neuen Theme. + * @param styleName + * @returns + */ + this.setUserStyle = function( styleName ) + { + var html = $('html'); + var classList = html.attr('class').split(/\s+/); + $.each(classList, function(index, item) { + if (item.startsWith('theme-')) { + html.removeClass(item); + } + }); + html.addClass( 'theme-' + styleName.toLowerCase() ); + } + + + + + /** + * Show a notification in the browser. + * Source: https://developer.mozilla.org/en-US/docs/Web/API/notification + * @param text text of message + */ + let notifyBrowser = function(text) + { + // 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. + } + + + + /** + * Show a notice bubble in the UI. + * @param type + * @param name + * @param status + * @param msg + * @param log + */ + this.notify = function( type,name,status,msg,log=[],notifyBrowser=false ) + { + // Notice-Bar mit dieser Meldung erweitern. + + if ( notifyBrowser ) + notifyBrowser( msg ); // Notify browser if wanted. + + let notice = $('<div class="notice '+status+'"></div>'); + + let toolbar = $('<div class="or-notice-toolbar"></div>'); + if ( log.length ) + $(toolbar).append('<i class="or-action-full image-icon image-icon--menu-fullscreen"></i>'); + $(toolbar).append('<i class="or-action-close image-icon image-icon--menu-close"></i>'); + $(notice).append(toolbar); + + let id = 0; // TODO id of objects to click on + if (name) + $(notice).append('<div class="name clickable"><a href="" data-type="open" data-action="'+type+'" data-id="'+id+'"><i class="or-action-full image-icon image-icon--action-'+type+'"></i> '+name+'</a></div>'); + + $(notice).append( '<div class="text">'+htmlEntities(msg)+'</div>'); + + if (log.length) { + + let logLi = log.reduce((result, item) => { + result += '<li><pre>'+htmlEntities(item)+'</pre></li>'; + return result; + }, ''); + $(notice).append('<div class="log"><ul>'+logLi+'</ul></div>'); + } + + $('#noticebar').prepend(notice); // Notice anhängen. + $(notice).orLinkify(); // Enable links + + + // Toogle Fullscreen for notice + $(notice).find('.or-action-full').click( function() { + $(notice).toggleClass('full'); + }); + + // Close the notice on click + $(notice).find('.or-action-close').click( function() { + $(notice).fadeOut('fast',function() { $(notice).remove(); } ); + }); + + // Fadeout the notice after a while. + let timeout = 1; + if ( status == 'ok' ) timeout = 20; + if ( status == 'info' ) timeout = 60; + if ( status == 'warning') timeout = 120; + if ( status == 'error' ) timeout = 120; + + if (timeout > 0) + setTimeout( function() { + $(notice).fadeOut('slow', function() { $(this).remove(); } ); + },timeout*1000 ); + } + + + } diff --git a/modules/cms-ui/themes/default/script/openrat/workbench.min.js b/modules/cms-ui/themes/default/script/openrat/workbench.min.js @@ -1,170 +1,3 @@ - - -var Workbench = new function() -{ - 'use strict'; // Strict mode - - - /** - * Initializes the Workbench. - */ - this.initialize = function() { - - // Initialze Ping timer. - this.initializePingTimer(); - this.initializeState(); - this.initializeMenues(); - this.openModalDialog(); - } - - - /** - * Starts a dialog, if necessary. - */ - this.openModalDialog = function () { - - if ( $('#dialog').data('action') ) { - startDialog('',$('#dialog').data('action'),$('#dialog').data('action'),0,{}) - } - } - - - this.initializeMenues = function () { - - filterMenus(); - } - - - /** - * Sets the workbench state with action/id. - * - * Example: #/name/1 is translated to the state {action:name,id:1} - */ - this.initializeState = function () { - - 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; - - // TODO: Remove this sometimes.... only state. - $('#editor').attr('data-action',state.action); - $('#editor').attr('data-id' ,state.id ); - $('#editor').attr('data-extra' ,'{}' ); - - } - - /** - * Registriert den Ping-Timer für den Sitzungserhalt. - */ - this.initializePingTimer = function() { - - /** - * 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) - */ - var ping = function() - { - $.ajax( createUrl('title','ping',0) ); - //window.console && console.log("session-ping"); - } - - // Alle 5 Minuten pingen. - var timeoutMinutes = 5; - - window.setInterval( ping, timeoutMinutes*60*1000 ); - } - - - - this.loadNewActionState = function(state) { - - Workbench.state = state; - Workbench.loadNewAction(state.action,state.id,state.data); - - - filterMenus(); - - $(document).trigger('orNewAction'); - } - - /** - * - */ - - this.loadNewAction = function(action, id, params ) { - - $('#editor').attr('data-action',action); - $('#editor').attr('data-id' ,id ); - $('#editor').attr('data-extra' ,JSON.stringify(params)); - - this.reloadViews(); - } - - - /** - * - */ - - this.reloadViews = function() { - - // View in geschlossenen Sektionen löschen, damit diese nicht stehen bleiben. - $('#workbench section.closed .view-loader').empty(); - - Workbench.loadViews( $('#workbench section.open .view-loader') ); - } - - - this.reloadAll = function() { - - // View in geschlossenen Sektionen löschen, damit diese nicht stehen bleiben. - $('#workbench .view').empty(); - - Workbench.loadViews( $('#workbench .view') ); - } - - - - this.loadViews = function( $views ) - { - - $views.each(function (idx) { - - let $targetDOMElement = $(this); - - Workbench.loadNewActionIntoElement( $targetDOMElement ) - }); - } - - - - this.loadNewActionIntoElement = function( $viewElement ) - { - let action; - if ( $viewElement.is('.view-static') ) - // Static views have always the same action. - action = $viewElement.attr('data-action'); - else - action = $('#editor').attr('data-action'); - - let id = $('#editor').attr('data-id' ); - let params = $('#editor').attr('data-extra' ); - - let method = $viewElement.data('method'); - - let view = new View( action,method,id,params ); - view.start( $viewElement ); - } - - -} - - +;Openrat.Workbench=new function(){'use strict';this.state={};this.initialize=function(){this.initializePingTimer();this.initializeState();this.initializeMenues();this.openModalDialog()};this.openModalDialog=function(){if($('#dialog').data('action')){startDialog('',$('#dialog').data('action'),$('#dialog').data('action'),0,{})}};this.initializeMenues=function(){filterMenus()};this.initializeState=function(){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,'');Openrat.Workbench.state=state;$('#editor').attr('data-action',state.action);$('#editor').attr('data-id',state.id);$('#editor').attr('data-extra','{}');Openrat.Navigator.toActualHistory(state)};this.initializePingTimer=function(){var t=function(){$.ajax(createUrl('title','ping',0))},i=5;window.setInterval(t,i*60*1000)};this.loadNewActionState=function(t){Openrat.Workbench.state=t;Openrat.Workbench.loadNewAction(t.action,t.id,t.data);filterMenus();$(document).trigger('orNewAction')};this.loadNewAction=function(t,i,e){$('#editor').attr('data-action',t);$('#editor').attr('data-id',i);$('#editor').attr('data-extra',JSON.stringify(e));this.reloadViews()};this.reloadViews=function(){$('#workbench section.closed .view-loader').empty();Openrat.Workbench.loadViews($('#workbench section.open .view-loader'))};this.reloadAll=function(){$('#workbench .view').empty();Openrat.Workbench.loadViews($('#workbench .view'))};this.loadViews=function(t){t.each(function(t){let $targetDOMElement=$(this);Openrat.Workbench.loadNewActionIntoElement($targetDOMElement)})};this.loadNewActionIntoElement=function(t){let action;if(t.is('.view-static'))action=t.attr('data-action');else action=$('#editor').attr('data-action');let id=$('#editor').attr('data-id');let params=$('#editor').attr('data-extra');let method=t.data('method');let view=new Openrat.View(action,method,id,params);view.start(t)};this.setUserStyle=function(t){var i=$('html'),e=i.attr('class').split(/\s+/);$.each(e,function(t,e){if(e.startsWith('theme-')){i.removeClass(e)}});i.addClass('theme-'+t.toLowerCase())};let notifyBrowser=function(t){if(!('Notification' in window)){return} +else if(Notification.permission==='granted'){let notification=new Notification(t)} +else if(Notification.permission!=='denied'){Notification.requestPermission(function(i){if(i==='granted'){let notification=new Notification(t)}})}};this.notify=function(t,e,i,o,log=[],notifyBrowser=!1){if(notifyBrowser)notifyBrowser(o);let notice=$('<div class="notice '+i+'"></div>');let toolbar=$('<div class="or-notice-toolbar"></div>');if(log.length)$(toolbar).append('<i class="or-action-full image-icon image-icon--menu-fullscreen"></i>');$(toolbar).append('<i class="or-action-close image-icon image-icon--menu-close"></i>');$(notice).append(toolbar);let id=0;if(e)$(notice).append('<div class="name clickable"><a href="" data-type="open" data-action="'+t+'" data-id="'+id+'"><i class="or-action-full image-icon image-icon--action-'+t+'"></i> '+e+'</a></div>');$(notice).append('<div class="text">'+htmlEntities(o)+'</div>');if(log.length){let logLi=log.reduce((result,item)=>{result+='<li><pre>'+htmlEntities(item)+'</pre></li>';return result},'');$(notice).append('<div class="log"><ul>'+logLi+'</ul></div>')};$('#noticebar').prepend(notice);$(notice).orLinkify();$(notice).find('.or-action-full').click(function(){$(notice).toggleClass('full')});$(notice).find('.or-action-close').click(function(){$(notice).fadeOut('fast',function(){$(notice).remove()})});let timeout=1;if(i=='ok')timeout=20;if(i=='info')timeout=60;if(i=='warning')timeout=120;if(i=='error')timeout=120;if(timeout>0)setTimeout(function(){$(notice).fadeOut('slow',function(){$(this).remove()})},timeout*1000)}};+ \ No newline at end of file diff --git a/modules/cms-ui/themes/default/script/plugin/jquery-plugin-orLinkify.js b/modules/cms-ui/themes/default/script/plugin/jquery-plugin-orLinkify.js @@ -38,11 +38,6 @@ jQuery.fn.orLinkify = function() startEdit($(this).attr('data-name'),$(this).attr('data-action'),$(this).attr('data-method'),$(this).attr('data-id'),$(this).attr('data-extra') ); break; - case 'url': - throw "probably unused, isn't it?"; - submitUrl(this,$(this).attr('data-url') ); - break; - case 'external': window.open( $(this).attr('data-url'),' _blank' ); break; @@ -60,11 +55,11 @@ jQuery.fn.orLinkify = function() break; case 'open': - openNewAction( $(this).attr('data-name'),$(this).attr('data-action'),$(this).attr('data-id'),jQuery.parseJSON($(this).attr('data-extra').replace(/'/g,'"'))); + openNewAction( $(this).attr('data-name'),$(this).attr('data-action'),$(this).attr('data-id') ); break; default: - alert('Fatal: Cannot open link: '+$(this).html() ); + throw "UI error: Unknown link type: "+type+" in link "+$(this).html(); } } ); }); diff --git a/modules/cms-ui/themes/default/script/plugin/jquery-plugin-orLinkify.min.js b/modules/cms-ui/themes/default/script/plugin/jquery-plugin-orLinkify.min.js @@ -1 +1 @@ -;var popupWindow;jQuery.fn.orLinkify=function(){$(this).find("a").click(function(t){t.preventDefault()});return $(this).click(function(){$(this).find("a").first().each(function(){let type=$(this).attr("data-type");if($(this).parent().hasClass("inactive"))return;switch(type){case"post":submitLink(this,$(this).attr("data-data"));break;case"dialog":startDialog($(this).attr("data-name"),$(this).attr("data-action"),$(this).attr("data-method"),$(this).attr("data-id"),$(this).attr("data-extra"));break;case"edit":startEdit($(this).attr("data-name"),$(this).attr("data-action"),$(this).attr("data-method"),$(this).attr("data-id"),$(this).attr("data-extra"));break;case"url":throw"probably unused, isn't it?";submitUrl(this,$(this).attr("data-url"));break;case"external":window.open($(this).attr("data-url")," _blank");break;case"popup":popupWindow=window.open($(this).attr("data-url"),"Popup","location=no,menubar=no,scrollbars=yes,toolbar=no,resizable=yes");break;case"help":help(this,$(this).attr("data-url"),$(this).attr("data-suffix"));break;case"fullscreen":fullscreen(this);break;case"open":openNewAction($(this).attr("data-name"),$(this).attr("data-action"),$(this).attr("data-id"),jQuery.parseJSON($(this).attr("data-extra").replace(/'/g,"\"")));break;default:alert("Fatal: Cannot open link: "+$(this).html())}})})};$(document).on("orViewLoaded",function(t,a){if(typeof popupWindow!="undefined")$(t.target).find("a[data-type='popup']").each(function(){popupWindow.location.href=$(this).attr("data-url")})});$(document).on("orDataChanged",function(t,a){if(typeof popupWindow!="undefined")popupWindow.location.reload()});- \ No newline at end of file +;var popupWindow;jQuery.fn.orLinkify=function(){$(this).find("a").click(function(t){t.preventDefault()});return $(this).click(function(){$(this).find("a").first().each(function(){let type=$(this).attr("data-type");if($(this).parent().hasClass("inactive"))return;switch(type){case"post":submitLink(this,$(this).attr("data-data"));break;case"dialog":startDialog($(this).attr("data-name"),$(this).attr("data-action"),$(this).attr("data-method"),$(this).attr("data-id"),$(this).attr("data-extra"));break;case"edit":startEdit($(this).attr("data-name"),$(this).attr("data-action"),$(this).attr("data-method"),$(this).attr("data-id"),$(this).attr("data-extra"));break;case"external":window.open($(this).attr("data-url")," _blank");break;case"popup":popupWindow=window.open($(this).attr("data-url"),"Popup","location=no,menubar=no,scrollbars=yes,toolbar=no,resizable=yes");break;case"help":help(this,$(this).attr("data-url"),$(this).attr("data-suffix"));break;case"fullscreen":fullscreen(this);break;case"open":openNewAction($(this).attr("data-name"),$(this).attr("data-action"),$(this).attr("data-id"));break;default:throw"UI error: Unknown link type: "+type+" in link "+$(this).html()}})})};$(document).on("orViewLoaded",function(t,a){if(typeof popupWindow!="undefined")$(t.target).find("a[data-type='popup']").each(function(){popupWindow.location.href=$(this).attr("data-url")})});$(document).on("orDataChanged",function(t,a){if(typeof popupWindow!="undefined")popupWindow.location.reload()});+ \ No newline at end of file diff --git a/modules/cms-ui/themes/default/script/plugin/jquery-plugin-orTree.js b/modules/cms-ui/themes/default/script/plugin/jquery-plugin-orTree.js @@ -72,7 +72,7 @@ jQuery.fn.orTree = function () }).fail(function () { // Ups... aber was können wir hier schon tun, außer hässliche Meldungen anzeigen. - notify('','','ERROR','failed to load subtree',[]); + Openrat.Workbench.notify('','','ERROR','failed to load subtree',[],false); }).always(function () { // Die Loader-Animation entfernen. diff --git a/modules/cms-ui/themes/default/script/plugin/jquery-plugin-orTree.min.js b/modules/cms-ui/themes/default/script/plugin/jquery-plugin-orTree.min.js @@ -1,4 +1,4 @@ ;jQuery.fn.orTree=function(){$(this).each(function(a,e){$(e).children('.or-navtree-node-control').click(function(){var a=$(this).parent('.or-navtree-node');if($(a).is('.or-navtree-node--is-open')){$(a).children('ul').slideUp('fast').remove();$(a).removeClass('or-navtree-node--is-open').addClass('or-navtree-node--is-closed').find('.tree-icon').removeClass('image-icon--node-open').addClass('image-icon--node-closed')} else{$(e).closest('div.view').addClass('loader');var o=$(a).data('type'),t=$(a).data('id'),i=$(a).data('extra'),n='./api/?action=tree&subaction=loadBranch&id='+t+'&type='+o+'&output=json';if(typeof i==='string'){jQuery.each(jQuery.parseJSON(i.replace(/'/g,'"')),function(e,a){n=n+'&'+e+'='+a})} else if(typeof i==='object'){jQuery.each(i,function(e,a){n=n+'&'+e+'='+a})} -else{};$.getJSON(n,function(a){let ul=$('<ul class="or-navtree-list" />');$(e).append(ul);let output=a['output'];$.each(output['branch'],function(a,e){let new_li=$('<li class="or-navtree-node or-navtree-node--is-closed or-draggable or-draggable--type-'+e.type+'" data-id="'+e.internalId+'" data-type="'+e.type+'" data-extra="'+JSON.stringify(e.extraId).replace(/"/g,'\'')+'"><div class="tree or-navtree-node-control"><i class="tree-icon image-icon image-icon--node-closed"></i></div><div class="clickable"><a href="./#/'+e.action+(e.internalId!='0'?'/'+e.internalId:'')+'" class="entry" data-extra="'+JSON.stringify(e.extraId).replace(/"/g,'\'')+'" data-id="'+e.internalId+'" data-action="'+e.action+'" data-type="open" title="'+e.description+'"><i class="image-icon image-icon--action-'+e['icon']+'"></i> '+e.text+'</a></div></li>');$(ul).append(new_li);$(new_li).orTree();$(new_li).find('.clickable').orLinkify();$(new_li).find('.clickable a').click(function(e){e.preventDefault()});registerTreeBranchEvents(ul)});$(ul).slideDown('fast')}).fail(function(){notify('','','ERROR','failed to load subtree',[])}).always(function(){$(e).closest('div.view').removeClass('loader')});$(a).addClass('or-navtree-node--is-open').removeClass('or-navtree-node--is-closed').find('.tree-icon').addClass('image-icon--node-open').removeClass('image-icon--node-closed')}})})};- \ No newline at end of file +else{};$.getJSON(n,function(a){let ul=$('<ul class="or-navtree-list" />');$(e).append(ul);let output=a['output'];$.each(output['branch'],function(a,e){let new_li=$('<li class="or-navtree-node or-navtree-node--is-closed or-draggable or-draggable--type-'+e.type+'" data-id="'+e.internalId+'" data-type="'+e.type+'" data-extra="'+JSON.stringify(e.extraId).replace(/"/g,'\'')+'"><div class="tree or-navtree-node-control"><i class="tree-icon image-icon image-icon--node-closed"></i></div><div class="clickable"><a href="./#/'+e.action+(e.internalId!='0'?'/'+e.internalId:'')+'" class="entry" data-extra="'+JSON.stringify(e.extraId).replace(/"/g,'\'')+'" data-id="'+e.internalId+'" data-action="'+e.action+'" data-type="open" title="'+e.description+'"><i class="image-icon image-icon--action-'+e['icon']+'"></i> '+e.text+'</a></div></li>');$(ul).append(new_li);$(new_li).orTree();$(new_li).find('.clickable').orLinkify();$(new_li).find('.clickable a').click(function(e){e.preventDefault()});registerTreeBranchEvents(ul)});$(ul).slideDown('fast')}).fail(function(){Openrat.Workbench.notify('','','ERROR','failed to load subtree',[],!1)}).always(function(){$(e).closest('div.view').removeClass('loader')});$(a).addClass('or-navtree-node--is-open').removeClass('or-navtree-node--is-closed').find('.tree-icon').addClass('image-icon--node-open').removeClass('image-icon--node-closed')}})})};+ \ No newline at end of file diff --git a/modules/template-engine/components/html/form/form.js b/modules/template-engine/components/html/form/form.js @@ -24,10 +24,9 @@ function doResponse(data,status,element) // 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. - if ($(element).data('async') == 'true') - notifyBrowser(value.text); + let notifyBrowser = $(element).data('async') == 'true'; - notify(value.type, value.name, value.status, value.text, value.log ); // Notice anhängen. + Openrat.Workbench.notify(value.type, value.name, value.status, value.text, value.log, notifyBrowser ); // Notice anhängen. if ( value.status == 'ok' ) // Kein Fehler? { @@ -50,10 +49,10 @@ function doResponse(data,status,element) { if ( afterSuccess == 'reloadAll' ) { - Workbench.reloadAll(); + Openrat.Workbench.reloadAll(); } } else { - Workbench.reloadViews(); + Openrat.Workbench.reloadViews(); } $(document).trigger('orDataChanged'); diff --git a/modules/template-engine/components/html/form/form.min.js b/modules/template-engine/components/html/form/form.min.js @@ -1,3 +1,3 @@ -;function doResponse(e,s,r){if(s!='success'){alert('Server error: '+s);return};$.each(e['notices'],function(s,e){if($(r).data('async')=='true')notifyBrowser(e.text);notify(e.type,e.name,e.status,e.text,e.log);if(e.status=='ok'){if($(r).data('async')!='true'){$('#dialog > .view').html('').hide();$('#dialog').removeClass('is-open').addClass('is-closed');$(r).closest('div.panel').find('div.header ul.views li.action.active').removeClass('dirty')};let afterSuccess=$(r).data('afterSuccess');if(afterSuccess){if(afterSuccess=='reloadAll'){Workbench.reloadAll()}} -else{Workbench.reloadViews()};$(document).trigger('orDataChanged')} -else{}});$.each(e['errors'],function(s,e){$('input[name='+e+']').addClass('error').parent().addClass('error').parents('fieldset').addClass('show').addClass('open')});if(!e.control){};if(e.control.redirect)window.location.href=e.control.redirect};- \ No newline at end of file +;function doResponse(e,r,a){if(r!='success'){alert('Server error: '+r);return};$.each(e['notices'],function(r,e){let notifyBrowser=$(a).data('async')=='true';Openrat.Workbench.notify(e.type,e.name,e.status,e.text,e.log,notifyBrowser);if(e.status=='ok'){if($(a).data('async')!='true'){$('#dialog > .view').html('').hide();$('#dialog').removeClass('is-open').addClass('is-closed');$(a).closest('div.panel').find('div.header ul.views li.action.active').removeClass('dirty')};let afterSuccess=$(a).data('afterSuccess');if(afterSuccess){if(afterSuccess=='reloadAll'){Openrat.Workbench.reloadAll()}} +else{Openrat.Workbench.reloadViews()};$(document).trigger('orDataChanged')} +else{}});$.each(e['errors'],function(r,e){$('input[name='+e+']').addClass('error').parent().addClass('error').parents('fieldset').addClass('show').addClass('open')});if(!e.control){};if(e.control.redirect)window.location.href=e.control.redirect};+ \ No newline at end of file diff --git a/modules/template-engine/components/html/upload/upload.js b/modules/template-engine/components/html/upload/upload.js @@ -77,7 +77,7 @@ function handleFileUpload(form,files) msg = jqXHR.responseText; } - notify('error',msg); + Openrat.Workbench.notify('Upload error',msg); } } ); diff --git a/modules/template-engine/components/html/upload/upload.min.js b/modules/template-engine/components/html/upload/upload.min.js @@ -1 +1 @@ -;$(document).on('orViewLoaded',function(e,n){var a=$(e.target).find('form'),o=$(e.target).find('div.or-dropzone-upload > div.input');o.on('dragenter',function(e){e.stopPropagation();e.preventDefault();$(this).css('border','1px dotted gray')});o.on('dragover',function(e){e.stopPropagation();e.preventDefault()});o.on('drop',function(e){$(this).css('border','1px dotted red');e.preventDefault();var n=e.originalEvent.dataTransfer.files;handleFileUpload(a,n)});$(e.target).find('input[type=file]').change(function(){var e=$(this).prop('files');handleFileUpload(a,e)})});function handleFileUpload(e,o){for(var t=0,r;r=o[t];t++){var n=new FormData();n.append('file',r);n.append('action','folder');n.append('subaction',$(e).data('method'));n.append('output','json');n.append('token',$(e).find('input[name=token]').val());n.append('id',$(e).find('input[name=id]').val());var a=$('<div class="notice info"><div class="text loader"></div></div>');$('#noticebar').prepend(a);$(a).show();$.ajax({'type':'POST',url:'./api/',cache:!1,contentType:!1,processData:!1,data:n,success:function(n,o,t){$(a).remove();doResponse(n,o,e)},error:function(n,o,d){$(e).closest('div.content').removeClass('loader');$(a).remove();var r;try{var t=jQuery.parseJSON(n.responseText);r=t.error+'/'+t.description+': '+t.reason}catch(i){r=n.responseText};notify('error',r)}})}};- \ No newline at end of file +;$(document).on('orViewLoaded',function(e,n){var a=$(e.target).find('form'),o=$(e.target).find('div.or-dropzone-upload > div.input');o.on('dragenter',function(e){e.stopPropagation();e.preventDefault();$(this).css('border','1px dotted gray')});o.on('dragover',function(e){e.stopPropagation();e.preventDefault()});o.on('drop',function(e){$(this).css('border','1px dotted red');e.preventDefault();var n=e.originalEvent.dataTransfer.files;handleFileUpload(a,n)});$(e.target).find('input[type=file]').change(function(){var e=$(this).prop('files');handleFileUpload(a,e)})});function handleFileUpload(e,o){for(var t=0,r;r=o[t];t++){var n=new FormData();n.append('file',r);n.append('action','folder');n.append('subaction',$(e).data('method'));n.append('output','json');n.append('token',$(e).find('input[name=token]').val());n.append('id',$(e).find('input[name=id]').val());var a=$('<div class="notice info"><div class="text loader"></div></div>');$('#noticebar').prepend(a);$(a).show();$.ajax({'type':'POST',url:'./api/',cache:!1,contentType:!1,processData:!1,data:n,success:function(n,o,t){$(a).remove();doResponse(n,o,e)},error:function(n,o,d){$(e).closest('div.content').removeClass('loader');$(a).remove();var r;try{var t=jQuery.parseJSON(n.responseText);r=t.error+'/'+t.description+': '+t.reason}catch(i){r=n.responseText};Openrat.Workbench.notify('Upload error',r)}})}};+ \ No newline at end of file