openrat-cms

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

commit f808b08090dda23fd3d46fcf4f259e77e4e08604
parent fc1e06c13c86b3386a1028d6be7fd0289dd34a93
Author: Jan Dankert <develop@jandankert.de>
Date:   Fri, 26 Apr 2019 23:08:56 +0200

Refactoring: JS-Klasse 'View' zum Kapseln einer View.

Diffstat:
modules/cms-ui/themes/default/production/combined.min.js | 10+++++-----
modules/cms-ui/themes/default/script/openrat.js | 117++++++++++++++++++++++++++++++++++++++++++-------------------------------------
modules/cms-ui/themes/default/script/openrat.min.js | 6+++---
modules/template-engine/components/html/form/form.js | 11+++--------
modules/template-engine/components/html/form/form.min.js | 4++--
5 files changed, 75 insertions(+), 73 deletions(-)

diff --git a/modules/cms-ui/themes/default/production/combined.min.js b/modules/cms-ui/themes/default/production/combined.min.js @@ -10999,17 +10999,17 @@ 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 */;$(document).on('orViewLoaded',function(o,n){var e=document.querySelectorAll('img.image-icon');SVGInjector(e)}); /* ./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 */;$(document).on('orViewLoaded',function(e,t){if($('div.panel form input[type=password]').length>0&&$('#uname').attr('value')!=''){$('div.panel form input[name=login_name] ').attr('value',$('#uname').attr('value'));$('div.panel form input[name=login_password]').attr('value',$('#upassword').attr('value'))};$(e.target).find('form[data-autosave="true"] input[type="checkbox"]').click(function(){$(this).closest('form').submit()});$(e.target).find('.or-form-btn--cancel').click(function(){$(e.target).html('').parent().removeClass('is-open')});$(e.target).find('form').submit(function(e){if($(this).data('target')=='view'){formSubmit($(this));e.preventDefault()}})});function formSubmit(e){var r=$('<div class="notice info"><div class="text loader"></div></div>');$('#noticebar').prepend(r);$(r).show();$(e).find('.error').removeClass('error');var a=$(e).serializeArray(),t={};$(a).each(function(e,r){t[r.name]=r.value});var s=$(e).attr('method').toUpperCase();if(s=='GET'){Workbench.loadViewIntoElement($(e).parent('.view'),t.action,t.subaction,t.id,t)} -else{var o='./api/';$(e).closest('div.content').addClass('loader');o+='?output=json';a['output']='json';if($(e).data('async')||$(e).data('async')=='true'){$('#dialog > .view').html('');$('#dialog').removeClass('is-open').addClass('is-closed')};$.ajax({'type':'POST',url:o,data:a,success:function(t,a,o){$(e).closest('div.content').removeClass('loader');$(r).remove();doResponse(t,a,e)},error:function(t,a,o){$(e).closest('div.content').removeClass('loader');$(r).remove();try{let error=jQuery.parseJSON(t.responseText);notify('','','error',error.error,[error.description])}catch(s){let msg=t.responseText;notify('','','error','Server Error',[msg])}}});$(e).fadeIn()}};function doResponse(e,t,r){if(t!='success'){alert('Server error: '+t);return};$.each(e['notices'],function(t,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')};$(document).trigger('orDataChanged')} +/* ./modules//template-engine/components/html/form/form.min.js */;$(document).on('orViewLoaded',function(e,t){$(e.target).find('form[data-autosave="true"] input[type="checkbox"]').click(function(){$(this).closest('form').submit()});$(e.target).find('.or-form-btn--cancel').click(function(){$(e.target).html('').parent().removeClass('is-open')});$(e.target).find('form').submit(function(e){if($(this).data('target')=='view'){formSubmit($(this));e.preventDefault()}})});function formSubmit(e){var r=$('<div class="notice info"><div class="text loader"></div></div>');$('#noticebar').prepend(r);$(r).show();$(e).find('.error').removeClass('error');var o=$(e).serializeArray(),t={};$(o).each(function(e,r){t[r.name]=r.value});var s=$(e).attr('method').toUpperCase();if(s=='GET'){let view=new View(t.action,t.subaction,t.id,t);view.start($(e).parent('.view'))} +else{var a='./api/';$(e).closest('div.content').addClass('loader');a+='?output=json';o['output']='json';if($(e).data('async')||$(e).data('async')=='true'){$('#dialog > .view').html('');$('#dialog').removeClass('is-open').addClass('is-closed')};$.ajax({'type':'POST',url:a,data:o,success:function(t,o,a){$(e).closest('div.content').removeClass('loader');$(r).remove();doResponse(t,o,e)},error:function(t,o,a){$(e).closest('div.content').removeClass('loader');$(r).remove();try{let error=jQuery.parseJSON(t.responseText);notify('','','error',error.error,[error.description])}catch(s){let msg=t.responseText;notify('','','error','Server Error',[msg])}}});$(e).fadeIn()}};function doResponse(e,t,r){if(t!='success'){alert('Server error: '+t);return};$.each(e['notices'],function(t,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')};$(document).trigger('orDataChanged')} else{}});$.each(e['errors'],function(e,t){$('input[name='+t+']').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/tree/tree.min.js */;$(document).on('orViewLoaded',function(o,n){}); -/* ./modules/cms-ui/themes/default/script/openrat.min.js */;var OR_THEMES_EXT_DIR='modules/cms-ui/themes/';$(function(){$('html').removeClass('nojs');$('.initial-hidden').removeClass('initial-hidden');registerHeaderEvents();registerWorkbenchEvents();$('.view').each(function(e){afterViewLoaded(this)});window.onpopstate=function(e){Navigator.navigateTo(e.state)};initActualHistoryState();Workbench.initialize();loadTree();$(document).keyup(function(e){if(e.keyCode==27){$('#dialog .view').fadeOut('fast').html('');$('#dialog').removeClass('is-open').addClass('is-closed')}});$('.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 e={};e.name=window.document.title;var t=new URLSearchParams(window.location.search);if(t.has('action')){e.action=t.get('action');e.id=t.get('id');e.name=window.document.title;e.data={};var t=Array.from(t.entries());for(var i in t){e.data[t[i][0]]=t[i][1]};Navigator.toActualHistory(e);filterMenus(e.action,e.id,e.data)}};var Navigator=new function(){'use strict';this.navigateTo=function(e){Workbench.loadNewActionState(e)};this.navigateToNew=function(e){Workbench.loadNewActionState(e);window.history.pushState(e,e.name,createUrl(e.action,null,e.id,e.data,!1))};this.navigateToNewAction=function(e,t,i,n){var o={action:e,method:t,id:i,data:n};this.navigateToNew(o)};this.toActualHistory=function(e){window.history.replaceState(e,e.name,createUrl(e.action,null,e.id,e.data,!1))}},Workbench=new function(){'use strict';this.initialize=function(){this.initializePingTimer()};this.initializePingTimer=function(){var e=function(){$.ajax(createUrl('title','ping',0))},t=5;window.setInterval(e,t*60*1000)};this.loadNewActionState=function(e){Workbench.loadNewAction(e.action,e.id,e.data)};this.loadNewAction=function(e,t,i){$('#editor').attr('data-action',e);$('#editor').attr('data-id',t);$('#editor').attr('data-extra',JSON.stringify(i));$('#workbench section.closed .view-loader').empty();$('#workbench section.open .view-loader').each(function(e){var t=$(this);Workbench.loadNewActionIntoElement(t)});filterMenus(e,t,i)};this.loadNewActionIntoElement=function(e){var t=$('#editor').attr('data-action'),i=$('#editor').attr('data-id'),n=$('#editor').attr('data-extra'),o=e.data('method');Workbench.loadViewIntoElement(e,t,o,i,n)};this.loadViewIntoElement=function(e,t,i,n,o){var a=createUrl(t,i,n,o,!0);e.empty().fadeTo(1,0.7).addClass('loader').html('').load(a,function(n,o,a){e.fadeTo(350,1);$(e).removeClass('loader');if(o=='error'){$(e).html('');notify('','','error','Server Error',['Server Error while requesting '+t+' -> '+i,n]);return};afterViewLoaded(e)})}};function registerWorkbenchEvents(){$('div.header').dblclick(function(){fullscreen(this)});$('div#filler').click(function(){if($('div#dialog').hasClass('modal')){} -else{$('div#dialog').removeClass('is-open').addClass('is-closed');$('div#dialog > .view').html('')}})};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 registerHeaderEvents(){$('body').click(function(){$('.toolbar-icon.menu').parents('.or-menu').removeClass('open')});$('#title .toolbar-icon.menu').click(function(e){e.stopPropagation();$(this).parents('.or-menu').toggleClass('open')});$('#title .toolbar-icon.menu').mouseover(function(){$(this).parents('.or-menu').find('.toolbar-icon.menu').removeClass('open');$(this).addClass('open')});$('#title div.search input').orSearch({dropdown:'#title div.search div.dropdown'})};function fullscreen(e){$(e).closest('div.panel').fadeOut('fast',function(){$(this).toggleClass('fullscreen').fadeIn('fast')})};function loadTree(){$('.or-navtree .or-navtree-node').orTree()};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');n=$('#editor').attr('data-id');$('div#dialog > .view').html('<div class="header"><img class="icon" title="" src="./themes/default/images/icon/'+i+'.png" />'+e+'</div>');$('div#dialog > .view').data('id',n);$('div#dialog').removeClass('is-closed').addClass('is-open');Workbench.loadViewIntoElement($('div#dialog > .view'),t,i,n,o)};function startEdit(e,t,i,n,o){if(!t)t=$('#editor').attr('data-action');if(!n)n=$('#editor').attr('data-id');$edit=$('#edit');$edit.addClass('is-open');Workbench.loadViewIntoElement($('#edit > .view'),t,i,n,o)};function modalView(e,t){alert('modalView() called');return};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(e,t,i){$('div.clickable').addClass('active');$('div.clickable.filtered').removeClass('active').addClass('inactive');$('div.clickable.filtered.on-action-'+e).addClass('active').removeClass('inactive');$('div.clickable.filtered a').attr('data-action',e);$('div.clickable.filtered a').attr('data-id',t);$('div.clickable.filtered a').attr('data-extra',JSON.stringify(i))};function setNewAction(e,t,i){Navigator.navigateToNewAction(e,'edit',t,i)};function setNewId(e){};function notifyBrowser(e){if(!('Notification' in window)){return} +/* ./modules/cms-ui/themes/default/script/openrat.min.js */;var OR_THEMES_EXT_DIR='modules/cms-ui/themes/';$(function(){$('html').removeClass('nojs');$('.initial-hidden').removeClass('initial-hidden');registerHeaderEvents();registerWorkbenchEvents();$('.view').each(function(e){afterViewLoaded(this)});window.onpopstate=function(e){Navigator.navigateTo(e.state)};initActualHistoryState();Workbench.initialize();loadTree();$(document).keyup(function(e){if(e.keyCode==27){$('#dialog .view').fadeOut('fast').html('');$('#dialog').removeClass('is-open').addClass('is-closed')}});$('.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 e={};e.name=window.document.title;var t=new URLSearchParams(window.location.search);if(t.has('action')){e.action=t.get('action');e.id=t.get('id');e.name=window.document.title;e.data={};var t=Array.from(t.entries());for(var i in t){e.data[t[i][0]]=t[i][1]};Navigator.toActualHistory(e);filterMenus(e.action,e.id,e.data)}};var Navigator=new function(){'use strict';this.navigateTo=function(e){Workbench.loadNewActionState(e)};this.navigateToNew=function(e){Workbench.loadNewActionState(e);window.history.pushState(e,e.name,createUrl(e.action,null,e.id,e.data,!1))};this.navigateToNewAction=function(e,t,i,n){var o={action:e,method:t,id:i,data:n};this.navigateToNew(o)};this.toActualHistory=function(e){window.history.replaceState(e,e.name,createUrl(e.action,null,e.id,e.data,!1))}},Workbench=new function(){'use strict';this.initialize=function(){this.initializePingTimer()};this.initializePingTimer=function(){var e=function(){$.ajax(createUrl('title','ping',0))},t=5;window.setInterval(e,t*60*1000)};this.loadNewActionState=function(e){Workbench.loadNewAction(e.action,e.id,e.data)};this.loadNewAction=function(e,t,i){$('#editor').attr('data-action',e);$('#editor').attr('data-id',t);$('#editor').attr('data-extra',JSON.stringify(i));$('#workbench section.closed .view-loader').empty();$('#workbench section.open .view-loader').each(function(e){var t=$(this);Workbench.loadNewActionIntoElement(t)});filterMenus(e,t,i)};this.loadNewActionIntoElement=function(e){var t=$('#editor').attr('data-action'),i=$('#editor').attr('data-id'),n=$('#editor').attr('data-extra'),o=e.data('method');let view=new View(t,o,i,n);view.start(e)}};function registerWorkbenchEvents(){$('div.header').dblclick(function(){fullscreen(this)});$('div#filler').click(function(){if($('div#dialog').hasClass('modal')){} +else{$('div#dialog').removeClass('is-open').addClass('is-closed');$('div#dialog > .view').html('')}})};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 registerHeaderEvents(){$('body').click(function(){$('.toolbar-icon.menu').parents('.or-menu').removeClass('open')});$('#title .toolbar-icon.menu').click(function(e){e.stopPropagation();$(this).parents('.or-menu').toggleClass('open')});$('#title .toolbar-icon.menu').mouseover(function(){$(this).parents('.or-menu').find('.toolbar-icon.menu').removeClass('open');$(this).addClass('open')});$('#title div.search input').orSearch({dropdown:'#title div.search div.dropdown'})};function fullscreen(e){$(e).closest('div.panel').fadeOut('fast',function(){$(this).toggleClass('fullscreen').fadeIn('fast')})};function loadTree(){$('.or-navtree .or-navtree-node').orTree()};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 View(e,t,i,n){this.action=e;this.method=t;this.id=i;this.params=n;this.before=function(){};this.start=function(e){this.before();this.element=e;this.loadView()};this.afterLoad=function(){};this.loadView=function(){let url=createUrl(this.action,this.method,this.id,this.params,!0);let element=this.element;$(this.element).empty().fadeTo(1,0.7).addClass('loader').html('').load(url,function(e,t,i){$(element).fadeTo(350,1);$(element).removeClass('loader');if(t=='error'){$(element).html('');notify('','','error','Server Error',['Server Error while requesting url '+url,e]);return};afterViewLoaded(element)})}};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(){$('div#dialog > .view').html('<div class="header"><img class="icon" title="" src="./themes/default/images/icon/'+i+'.png" />'+e+'</div>');$('div#dialog > .view').data('id',n);$('div#dialog').removeClass('is-closed').addClass('is-open')};view.start($('div#dialog > .view'))};function startEdit(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);$edit=$('#edit');$edit.addClass('is-open');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(e,t,i){$('div.clickable').addClass('active');$('div.clickable.filtered').removeClass('active').addClass('inactive');$('div.clickable.filtered.on-action-'+e).addClass('active').removeClass('inactive');$('div.clickable.filtered a').attr('data-action',e);$('div.clickable.filtered a').attr('data-id',t);$('div.clickable.filtered a').attr('data-extra',JSON.stringify(i))};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 r=document.selection.createRange(),o=r.text;r.text=t+o+i;r=document.selection.createRange();if(o.length==0){r.move('character',-i.length)} else{r.moveStart('character',t.length+o.length+i.length)};r.select()} -else if(typeof n.selectionStart!='undefined'){var l=n.selectionStart,c=n.selectionEnd,o=n.value.substring(l,c);n.value=n.value.substr(0,l)+t+o+i+n.value.substr(c);var a;if(o.length==0){a=l+t.length} +else if(typeof n.selectionStart!='undefined'){var l=n.selectionStart,s=n.selectionEnd,o=n.value.substring(l,s);n.value=n.value.substr(0,l)+t+o+i+n.value.substr(s);var a;if(o.length==0){a=l+t.length} else{a=l+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+='?action='+e;if(t!=null)o+='&subaction='+t;o+='&id='+i;if(a)o+='&embed=1';if(typeof n==='string'){n=n.replace(/'/g,'"');var r=jQuery.parseJSON(n);jQuery.each(r,function(e,t){if(e=='action'||e=='subaction'||e=='id')return;o=o+'&'+e+'='+t})} else if(typeof n==='object'){jQuery.each(n,function(e,t){if(e=='action'||e=='subaction'||e=='id')return;o=o+'&'+e+'='+t})} diff --git a/modules/cms-ui/themes/default/script/openrat.js b/modules/cms-ui/themes/default/script/openrat.js @@ -230,34 +230,12 @@ var Workbench = new function() var method = targetDOMElement.data('method'); - Workbench.loadViewIntoElement(targetDOMElement,action,method,id,params) + //Workbench.loadViewIntoElement(targetDOMElement,action,method,id,params) + let view = new View( action,method,id,params ); + view.start( targetDOMElement ); } - this.loadViewIntoElement = function(targetDOMElement,action,method,id,params) { - - var url = createUrl(action,method,id,params,true); // URL für das Laden erzeugen. - - targetDOMElement.empty().fadeTo(1,0.7).addClass('loader').html('').load(url,function(response, status, xhr) { - targetDOMElement.fadeTo(350,1); - - $(targetDOMElement).removeClass("loader"); - - if ( status == "error" ) - { - // Seite nicht gefunden. - $(targetDOMElement).html(""); - - notify('','','error','Server Error',['Server Error while requesting '+action+' -> '+method,response]); - return; - } - - afterViewLoaded( targetDOMElement ); - - }); - - } - } @@ -546,6 +524,52 @@ function postUrl(url,element) } +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.loadView = function() { + + let url = createUrl( this.action,this.method,this.id,this.params,true); // URL für das Laden erzeugen. + let element = this.element; + + $(this.element).empty().fadeTo(1,0.7).addClass('loader').html('').load(url,function(response, status, xhr) { + $(element).fadeTo(350,1); + + $(element).removeClass("loader"); + + if ( status == "error" ) + { + // Seite nicht gefunden. + $(element).html(""); + + notify('','','error','Server Error',['Server Error while requesting url '+url, response]); + return; + } + + afterViewLoaded( element ); + }); + + } + +} + /** * Setzt neuen modalen Dialog und aktualisiert alle Fenster. @@ -561,13 +585,18 @@ function startDialog( name,action,method,id,params ) if (!action) action = $('#editor').attr('data-action'); - id = $('#editor').attr('data-id'); + if (!id) + id = $('#editor').attr('data-id'); + + let view = new View( action,method,id,params ); - $('div#dialog > .view').html('<div class="header"><img class="icon" title="" src="./themes/default/images/icon/'+method+'.png" />'+name+'</div>'); - $('div#dialog > .view').data('id',id); - $('div#dialog').removeClass('is-closed').addClass('is-open'); + view.before = function() { + $('div#dialog > .view').html('<div class="header"><img class="icon" title="" src="./themes/default/images/icon/'+method+'.png" />'+name+'</div>'); + $('div#dialog > .view').data('id',id); + $('div#dialog').removeClass('is-closed').addClass('is-open'); + } - Workbench.loadViewIntoElement( $('div#dialog > .view'), action, method, id, params ); + view.start( $('div#dialog > .view') ); } @@ -588,38 +617,16 @@ function startEdit( name,action,method,id,params ) if (!id) id = $('#editor').attr('data-id'); - $edit = $('#edit'); + let view = new View( action,method,id,params ); + $edit = $('#edit'); $edit.addClass('is-open'); - Workbench.loadViewIntoElement( $('#edit > .view'), action, method, id, params ); + view.start( $('#edit > .view') ); } /** - * Setzt neue modale View und aktualisiert alle Fenster. - * @param element - * @param action Action - * @param id Id - */ -function modalView( element,view ) -{ - alert('modalView() called'); - return; - /* - var action = $(element).closest('div.panel').find('li.active').attr('data-action'); - var method = $(element).closest('div.panel').find('li.active').attr('data-method'); - var id = $(element).closest('div.panel').find('li.active').attr('data-id' ); - $(element).closest('div.content').modal( { "overlayClose":"true","xxxonClose":function(){alert("close)");} } ); - loadView( $(element).closest('div.content'), action, method,id ); - */ - // Alle refresh-fähigen Views mit dem neuen Objekt laden. - // refreshAllRefreshables(); -} - - - -/** * Setzt einen Fenster-Titel für die ganze Anwendung. */ function setTitle( title ) diff --git a/modules/cms-ui/themes/default/script/openrat.min.js b/modules/cms-ui/themes/default/script/openrat.min.js @@ -1,9 +1,9 @@ -;var OR_THEMES_EXT_DIR='modules/cms-ui/themes/';$(function(){$('html').removeClass('nojs');$('.initial-hidden').removeClass('initial-hidden');registerHeaderEvents();registerWorkbenchEvents();$('.view').each(function(e){afterViewLoaded(this)});window.onpopstate=function(e){Navigator.navigateTo(e.state)};initActualHistoryState();Workbench.initialize();loadTree();$(document).keyup(function(e){if(e.keyCode==27){$('#dialog .view').fadeOut('fast').html('');$('#dialog').removeClass('is-open').addClass('is-closed')}});$('.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 e={};e.name=window.document.title;var t=new URLSearchParams(window.location.search);if(t.has('action')){e.action=t.get('action');e.id=t.get('id');e.name=window.document.title;e.data={};var t=Array.from(t.entries());for(var i in t){e.data[t[i][0]]=t[i][1]};Navigator.toActualHistory(e);filterMenus(e.action,e.id,e.data)}};var Navigator=new function(){'use strict';this.navigateTo=function(e){Workbench.loadNewActionState(e)};this.navigateToNew=function(e){Workbench.loadNewActionState(e);window.history.pushState(e,e.name,createUrl(e.action,null,e.id,e.data,!1))};this.navigateToNewAction=function(e,t,i,n){var o={action:e,method:t,id:i,data:n};this.navigateToNew(o)};this.toActualHistory=function(e){window.history.replaceState(e,e.name,createUrl(e.action,null,e.id,e.data,!1))}},Workbench=new function(){'use strict';this.initialize=function(){this.initializePingTimer()};this.initializePingTimer=function(){var e=function(){$.ajax(createUrl('title','ping',0))},t=5;window.setInterval(e,t*60*1000)};this.loadNewActionState=function(e){Workbench.loadNewAction(e.action,e.id,e.data)};this.loadNewAction=function(e,t,i){$('#editor').attr('data-action',e);$('#editor').attr('data-id',t);$('#editor').attr('data-extra',JSON.stringify(i));$('#workbench section.closed .view-loader').empty();$('#workbench section.open .view-loader').each(function(e){var t=$(this);Workbench.loadNewActionIntoElement(t)});filterMenus(e,t,i)};this.loadNewActionIntoElement=function(e){var t=$('#editor').attr('data-action'),i=$('#editor').attr('data-id'),n=$('#editor').attr('data-extra'),o=e.data('method');Workbench.loadViewIntoElement(e,t,o,i,n)};this.loadViewIntoElement=function(e,t,i,n,o){var a=createUrl(t,i,n,o,!0);e.empty().fadeTo(1,0.7).addClass('loader').html('').load(a,function(n,o,a){e.fadeTo(350,1);$(e).removeClass('loader');if(o=='error'){$(e).html('');notify('','','error','Server Error',['Server Error while requesting '+t+' -> '+i,n]);return};afterViewLoaded(e)})}};function registerWorkbenchEvents(){$('div.header').dblclick(function(){fullscreen(this)});$('div#filler').click(function(){if($('div#dialog').hasClass('modal')){} -else{$('div#dialog').removeClass('is-open').addClass('is-closed');$('div#dialog > .view').html('')}})};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 registerHeaderEvents(){$('body').click(function(){$('.toolbar-icon.menu').parents('.or-menu').removeClass('open')});$('#title .toolbar-icon.menu').click(function(e){e.stopPropagation();$(this).parents('.or-menu').toggleClass('open')});$('#title .toolbar-icon.menu').mouseover(function(){$(this).parents('.or-menu').find('.toolbar-icon.menu').removeClass('open');$(this).addClass('open')});$('#title div.search input').orSearch({dropdown:'#title div.search div.dropdown'})};function fullscreen(e){$(e).closest('div.panel').fadeOut('fast',function(){$(this).toggleClass('fullscreen').fadeIn('fast')})};function loadTree(){$('.or-navtree .or-navtree-node').orTree()};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');n=$('#editor').attr('data-id');$('div#dialog > .view').html('<div class="header"><img class="icon" title="" src="./themes/default/images/icon/'+i+'.png" />'+e+'</div>');$('div#dialog > .view').data('id',n);$('div#dialog').removeClass('is-closed').addClass('is-open');Workbench.loadViewIntoElement($('div#dialog > .view'),t,i,n,o)};function startEdit(e,t,i,n,o){if(!t)t=$('#editor').attr('data-action');if(!n)n=$('#editor').attr('data-id');$edit=$('#edit');$edit.addClass('is-open');Workbench.loadViewIntoElement($('#edit > .view'),t,i,n,o)};function modalView(e,t){alert('modalView() called');return};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(e,t,i){$('div.clickable').addClass('active');$('div.clickable.filtered').removeClass('active').addClass('inactive');$('div.clickable.filtered.on-action-'+e).addClass('active').removeClass('inactive');$('div.clickable.filtered a').attr('data-action',e);$('div.clickable.filtered a').attr('data-id',t);$('div.clickable.filtered a').attr('data-extra',JSON.stringify(i))};function setNewAction(e,t,i){Navigator.navigateToNewAction(e,'edit',t,i)};function setNewId(e){};function notifyBrowser(e){if(!('Notification' in window)){return} +;var OR_THEMES_EXT_DIR='modules/cms-ui/themes/';$(function(){$('html').removeClass('nojs');$('.initial-hidden').removeClass('initial-hidden');registerHeaderEvents();registerWorkbenchEvents();$('.view').each(function(e){afterViewLoaded(this)});window.onpopstate=function(e){Navigator.navigateTo(e.state)};initActualHistoryState();Workbench.initialize();loadTree();$(document).keyup(function(e){if(e.keyCode==27){$('#dialog .view').fadeOut('fast').html('');$('#dialog').removeClass('is-open').addClass('is-closed')}});$('.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 e={};e.name=window.document.title;var t=new URLSearchParams(window.location.search);if(t.has('action')){e.action=t.get('action');e.id=t.get('id');e.name=window.document.title;e.data={};var t=Array.from(t.entries());for(var i in t){e.data[t[i][0]]=t[i][1]};Navigator.toActualHistory(e);filterMenus(e.action,e.id,e.data)}};var Navigator=new function(){'use strict';this.navigateTo=function(e){Workbench.loadNewActionState(e)};this.navigateToNew=function(e){Workbench.loadNewActionState(e);window.history.pushState(e,e.name,createUrl(e.action,null,e.id,e.data,!1))};this.navigateToNewAction=function(e,t,i,n){var o={action:e,method:t,id:i,data:n};this.navigateToNew(o)};this.toActualHistory=function(e){window.history.replaceState(e,e.name,createUrl(e.action,null,e.id,e.data,!1))}},Workbench=new function(){'use strict';this.initialize=function(){this.initializePingTimer()};this.initializePingTimer=function(){var e=function(){$.ajax(createUrl('title','ping',0))},t=5;window.setInterval(e,t*60*1000)};this.loadNewActionState=function(e){Workbench.loadNewAction(e.action,e.id,e.data)};this.loadNewAction=function(e,t,i){$('#editor').attr('data-action',e);$('#editor').attr('data-id',t);$('#editor').attr('data-extra',JSON.stringify(i));$('#workbench section.closed .view-loader').empty();$('#workbench section.open .view-loader').each(function(e){var t=$(this);Workbench.loadNewActionIntoElement(t)});filterMenus(e,t,i)};this.loadNewActionIntoElement=function(e){var t=$('#editor').attr('data-action'),i=$('#editor').attr('data-id'),n=$('#editor').attr('data-extra'),o=e.data('method');let view=new View(t,o,i,n);view.start(e)}};function registerWorkbenchEvents(){$('div.header').dblclick(function(){fullscreen(this)});$('div#filler').click(function(){if($('div#dialog').hasClass('modal')){} +else{$('div#dialog').removeClass('is-open').addClass('is-closed');$('div#dialog > .view').html('')}})};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 registerHeaderEvents(){$('body').click(function(){$('.toolbar-icon.menu').parents('.or-menu').removeClass('open')});$('#title .toolbar-icon.menu').click(function(e){e.stopPropagation();$(this).parents('.or-menu').toggleClass('open')});$('#title .toolbar-icon.menu').mouseover(function(){$(this).parents('.or-menu').find('.toolbar-icon.menu').removeClass('open');$(this).addClass('open')});$('#title div.search input').orSearch({dropdown:'#title div.search div.dropdown'})};function fullscreen(e){$(e).closest('div.panel').fadeOut('fast',function(){$(this).toggleClass('fullscreen').fadeIn('fast')})};function loadTree(){$('.or-navtree .or-navtree-node').orTree()};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 View(e,t,i,n){this.action=e;this.method=t;this.id=i;this.params=n;this.before=function(){};this.start=function(e){this.before();this.element=e;this.loadView()};this.afterLoad=function(){};this.loadView=function(){let url=createUrl(this.action,this.method,this.id,this.params,!0);let element=this.element;$(this.element).empty().fadeTo(1,0.7).addClass('loader').html('').load(url,function(e,t,i){$(element).fadeTo(350,1);$(element).removeClass('loader');if(t=='error'){$(element).html('');notify('','','error','Server Error',['Server Error while requesting url '+url,e]);return};afterViewLoaded(element)})}};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(){$('div#dialog > .view').html('<div class="header"><img class="icon" title="" src="./themes/default/images/icon/'+i+'.png" />'+e+'</div>');$('div#dialog > .view').data('id',n);$('div#dialog').removeClass('is-closed').addClass('is-open')};view.start($('div#dialog > .view'))};function startEdit(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);$edit=$('#edit');$edit.addClass('is-open');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(e,t,i){$('div.clickable').addClass('active');$('div.clickable.filtered').removeClass('active').addClass('inactive');$('div.clickable.filtered.on-action-'+e).addClass('active').removeClass('inactive');$('div.clickable.filtered a').attr('data-action',e);$('div.clickable.filtered a').attr('data-id',t);$('div.clickable.filtered a').attr('data-extra',JSON.stringify(i))};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 r=document.selection.createRange(),o=r.text;r.text=t+o+i;r=document.selection.createRange();if(o.length==0){r.move('character',-i.length)} else{r.moveStart('character',t.length+o.length+i.length)};r.select()} -else if(typeof n.selectionStart!='undefined'){var l=n.selectionStart,c=n.selectionEnd,o=n.value.substring(l,c);n.value=n.value.substr(0,l)+t+o+i+n.value.substr(c);var a;if(o.length==0){a=l+t.length} +else if(typeof n.selectionStart!='undefined'){var l=n.selectionStart,s=n.selectionEnd,o=n.value.substring(l,s);n.value=n.value.substr(0,l)+t+o+i+n.value.substr(s);var a;if(o.length==0){a=l+t.length} else{a=l+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+='?action='+e;if(t!=null)o+='&subaction='+t;o+='&id='+i;if(a)o+='&embed=1';if(typeof n==='string'){n=n.replace(/'/g,'"');var r=jQuery.parseJSON(n);jQuery.each(r,function(e,t){if(e=='action'||e=='subaction'||e=='id')return;o=o+'&'+e+'='+t})} else if(typeof n==='object'){jQuery.each(n,function(e,t){if(e=='action'||e=='subaction'||e=='id')return;o=o+'&'+e+'='+t})} diff --git a/modules/template-engine/components/html/form/form.js b/modules/template-engine/components/html/form/form.js @@ -1,13 +1,6 @@ // $(document).on('orViewLoaded',function(event, data) { - if ( $('div.panel form input[type=password]').length>0 && $('#uname').attr('value')!='' ) - { - $('div.panel form input[name=login_name] ').attr('value',$('#uname' ).attr('value')); - $('div.panel form input[name=login_password]').attr('value',$('#upassword').attr('value')); - } - - // Autosave in Formularen. Bei Veränderungen wird das Formular sofort abgeschickt. $(event.target).find('form[data-autosave="true"] input[type="checkbox"]').click( function() { $(this).closest('form').submit(); @@ -65,7 +58,9 @@ function formSubmit(form) { // Mehrseitiges Formular // Die eingegebenen Formulardaten werden zur nächsten Action geschickt. - Workbench.loadViewIntoElement( $(form).parent('.view'),data.action, data.subaction,data.id,data ); + //Workbench.loadViewIntoElement( $(form).parent('.view'),data.action, data.subaction,data.id,data ); + let view = new View( data.action, data.subaction,data.id,data ); + view.start( $(form).parent('.view') ); } else { 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 @@ -;$(document).on('orViewLoaded',function(e,t){if($('div.panel form input[type=password]').length>0&&$('#uname').attr('value')!=''){$('div.panel form input[name=login_name] ').attr('value',$('#uname').attr('value'));$('div.panel form input[name=login_password]').attr('value',$('#upassword').attr('value'))};$(e.target).find('form[data-autosave="true"] input[type="checkbox"]').click(function(){$(this).closest('form').submit()});$(e.target).find('.or-form-btn--cancel').click(function(){$(e.target).html('').parent().removeClass('is-open')});$(e.target).find('form').submit(function(e){if($(this).data('target')=='view'){formSubmit($(this));e.preventDefault()}})});function formSubmit(e){var r=$('<div class="notice info"><div class="text loader"></div></div>');$('#noticebar').prepend(r);$(r).show();$(e).find('.error').removeClass('error');var a=$(e).serializeArray(),t={};$(a).each(function(e,r){t[r.name]=r.value});var s=$(e).attr('method').toUpperCase();if(s=='GET'){Workbench.loadViewIntoElement($(e).parent('.view'),t.action,t.subaction,t.id,t)} -else{var o='./api/';$(e).closest('div.content').addClass('loader');o+='?output=json';a['output']='json';if($(e).data('async')||$(e).data('async')=='true'){$('#dialog > .view').html('');$('#dialog').removeClass('is-open').addClass('is-closed')};$.ajax({'type':'POST',url:o,data:a,success:function(t,a,o){$(e).closest('div.content').removeClass('loader');$(r).remove();doResponse(t,a,e)},error:function(t,a,o){$(e).closest('div.content').removeClass('loader');$(r).remove();try{let error=jQuery.parseJSON(t.responseText);notify('','','error',error.error,[error.description])}catch(s){let msg=t.responseText;notify('','','error','Server Error',[msg])}}});$(e).fadeIn()}};function doResponse(e,t,r){if(t!='success'){alert('Server error: '+t);return};$.each(e['notices'],function(t,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')};$(document).trigger('orDataChanged')} +;$(document).on('orViewLoaded',function(e,t){$(e.target).find('form[data-autosave="true"] input[type="checkbox"]').click(function(){$(this).closest('form').submit()});$(e.target).find('.or-form-btn--cancel').click(function(){$(e.target).html('').parent().removeClass('is-open')});$(e.target).find('form').submit(function(e){if($(this).data('target')=='view'){formSubmit($(this));e.preventDefault()}})});function formSubmit(e){var r=$('<div class="notice info"><div class="text loader"></div></div>');$('#noticebar').prepend(r);$(r).show();$(e).find('.error').removeClass('error');var o=$(e).serializeArray(),t={};$(o).each(function(e,r){t[r.name]=r.value});var s=$(e).attr('method').toUpperCase();if(s=='GET'){let view=new View(t.action,t.subaction,t.id,t);view.start($(e).parent('.view'))} +else{var a='./api/';$(e).closest('div.content').addClass('loader');a+='?output=json';o['output']='json';if($(e).data('async')||$(e).data('async')=='true'){$('#dialog > .view').html('');$('#dialog').removeClass('is-open').addClass('is-closed')};$.ajax({'type':'POST',url:a,data:o,success:function(t,o,a){$(e).closest('div.content').removeClass('loader');$(r).remove();doResponse(t,o,e)},error:function(t,o,a){$(e).closest('div.content').removeClass('loader');$(r).remove();try{let error=jQuery.parseJSON(t.responseText);notify('','','error',error.error,[error.description])}catch(s){let msg=t.responseText;notify('','','error','Server Error',[msg])}}});$(e).fadeIn()}};function doResponse(e,t,r){if(t!='success'){alert('Server error: '+t);return};$.each(e['notices'],function(t,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')};$(document).trigger('orDataChanged')} else{}});$.each(e['errors'],function(e,t){$('input[name='+t+']').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