openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit f34b281844ce851f2d8d99ee2d26ee82d61da0ea
parent cfbc2c98df1d57d9c244930bfb277e864b000e6d
Author: Jan Dankert <devnull@localhost>
Date:   Fri, 13 Jul 2018 22:31:04 +0200

Formulare werden jetzt nur noch 1x abgeschickt und im Dialog sollte das Abschicken jetzt auch funktionieren.

Diffstat:
modules/cms-ui/themes/default/script/openrat.js | 2+-
modules/cms-ui/themes/default/script/openrat.min.js | 2+-
modules/template-engine/components/html/form/form.js | 13+++++++++++--
modules/template-engine/components/html/form/form.min.js | 2+-
4 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/modules/cms-ui/themes/default/script/openrat.js b/modules/cms-ui/themes/default/script/openrat.js @@ -22,7 +22,7 @@ $( function() filterMenus(action); - $('#workbench .view').each( function(index) { + $('.view').each( function(index) { registerViewEvents(this); }); diff --git a/modules/cms-ui/themes/default/script/openrat.min.js b/modules/cms-ui/themes/default/script/openrat.min.js @@ -1,4 +1,4 @@ -;var DEFAULT_CONTENT_ACTION='edit',OR_THEMES_EXT_DIR='modules/cms-ui/themes/';$(function(){$('html').removeClass('nojs');$('.initial-hidden').removeClass('initial-hidden');registerHeaderEvents();registerWorkbenchEvents();var t=$('#editor').data('action');filterMenus(t);$('#workbench .view').each(function(t){registerViewEvents(this)});window.onpopstate=function(t){Navigator.navigateTo(t.state)};initActualHistoryState();Workbench.initialize();$('#noticebar .notice').click(function(){$(this).fadeOut('fast',function(){$(this).remove()})});loadTree()});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)}};var Navigator=new function(){'use strict';this.navigateTo=function(t){Workbench.loadNewActionState(t)};this.navigateToNew=function(t){Workbench.loadNewActionState(t);window.history.pushState(t,t.name,createUrl(t.action,null,t.id,t.data,!1))};this.navigateToNewAction=function(t,e,i,n){var a={action:t,method:e,id:i,data:n};this.navigateToNew(a)};this.toActualHistory=function(t){window.history.replaceState(t,t.name,createUrl(t.action,null,t.id,t.data,!1))}},Workbench=new function(){'use strict';this.initialize=function(){this.initializePingTimer()};this.initializePingTimer=function(){var t=function(){$.ajax(createUrl('title','ping',0))},e=5;window.setInterval(t,e*60*1000)};this.loadNewActionState=function(t){Workbench.loadNewAction(t.action,t.id,t.data)};this.loadNewAction=function(t,e,i){$('#editor').attr('data-action',t);$('#editor').attr('data-id',e);$('#workbench .view-loader').each(function(n){var a=$(this),o=a.data('method');Workbench.loadViewIntoElement(a,t,o,e,i)});filterMenus(t)};this.loadViewIntoElement=function(t,e,i,n,a){var o=createUrl(e,i,n,a,!0);t.empty().fadeTo(1,0.7).addClass('loader').html('').load(o,function(e,i,n){t.fadeTo(350,1);$(t).removeClass('loader');if(i=='error'){$(t).html('');notify('error',e);return};registerViewEvents(t)})}};function registerWorkbenchEvents(){$('div.header').dblclick(function(){fullscreen(this)});$('div#filler').click(function(){if($('div#dialog').hasClass('modal')){} +;var DEFAULT_CONTENT_ACTION='edit',OR_THEMES_EXT_DIR='modules/cms-ui/themes/';$(function(){$('html').removeClass('nojs');$('.initial-hidden').removeClass('initial-hidden');registerHeaderEvents();registerWorkbenchEvents();var t=$('#editor').data('action');filterMenus(t);$('.view').each(function(t){registerViewEvents(this)});window.onpopstate=function(t){Navigator.navigateTo(t.state)};initActualHistoryState();Workbench.initialize();$('#noticebar .notice').click(function(){$(this).fadeOut('fast',function(){$(this).remove()})});loadTree()});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)}};var Navigator=new function(){'use strict';this.navigateTo=function(t){Workbench.loadNewActionState(t)};this.navigateToNew=function(t){Workbench.loadNewActionState(t);window.history.pushState(t,t.name,createUrl(t.action,null,t.id,t.data,!1))};this.navigateToNewAction=function(t,e,i,n){var a={action:t,method:e,id:i,data:n};this.navigateToNew(a)};this.toActualHistory=function(t){window.history.replaceState(t,t.name,createUrl(t.action,null,t.id,t.data,!1))}},Workbench=new function(){'use strict';this.initialize=function(){this.initializePingTimer()};this.initializePingTimer=function(){var t=function(){$.ajax(createUrl('title','ping',0))},e=5;window.setInterval(t,e*60*1000)};this.loadNewActionState=function(t){Workbench.loadNewAction(t.action,t.id,t.data)};this.loadNewAction=function(t,e,i){$('#editor').attr('data-action',t);$('#editor').attr('data-id',e);$('#workbench .view-loader').each(function(n){var a=$(this),o=a.data('method');Workbench.loadViewIntoElement(a,t,o,e,i)});filterMenus(t)};this.loadViewIntoElement=function(t,e,i,n,a){var o=createUrl(e,i,n,a,!0);t.empty().fadeTo(1,0.7).addClass('loader').html('').load(o,function(e,i,n){t.fadeTo(350,1);$(t).removeClass('loader');if(i=='error'){$(t).html('');notify('error',e);return};registerViewEvents(t)})}};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(t,e,i,n,a){Navigator.navigateToNewAction(e,i,n,a)};function registerViewEvents(t){$(t).trigger('orViewLoaded');$(t).closest('div.panel').find('div.header div.dropdown div.entry.perview').remove();$(t).find('div.headermenu > a').each(function(t,e){});$(t).find('div.header > a.back').each(function(e,i){$(i).removeClass('button').wrap('<div class="entry perview" />').parent().appendTo($(t).closest('div.panel').find('div.header div.dropdown').first())});$(t).find('div.selector.tree').each(function(){var t=this;$(this).orTree({type:'project',selectable:$(t).attr('data-types').split(','),id:$(t).attr('data-init-folderid'),onSelect:function(e,i,n){var a=$(t).parent();$(a).find('input[type=text]').attr('value',e);$(a).find('input[type=hidden]').attr('value',n)}})});$('div.content li.object').draggable({cursor:'move',revert:'invalid'});$('div.content li.object > .entry[data-type=\'folder\']').droppable({accept:'li.object',hoverClass:'drophover',activeClass:'dropactive',drop:function(t,e){var i=e.draggable,n=$(this).parent();startDialog($(this).text(),$(i).attr('data-type'),'copy',$(n).attr('data-id'),{'action':$(i).attr('data-type'),'subaction':'copy','id':$(i).attr('data-id'),'targetFolderId':$(n).attr('data-id')});$(i).detach().css({top:0,left:0}).appendTo(n).click()}});$(t).find('input').change(function(){$('#editor').find('header').addClass('dirty')})};function registerHeaderEvents(){$('body').click(function(){$('.toolbar-icon.menu').parent().removeClass('open')});$('#title .toolbar-icon.menu').click(function(t){t.stopPropagation();$(this).parent().toggleClass('open')});$('#title .toolbar-icon.menu').mouseover(function(){$(this).parent().find('.toolbar-icon.menu').removeClass('open');$(this).addClass('open')});$('#title div.search input').blur(function(){$('div.search input div.dropdown').fadeOut()});$('#title div.search input').orSearch({dropdown:'#title div.search div.dropdown'})};function fullscreen(t){$(t).closest('div.panel').fadeOut('fast',function(){$(this).toggleClass('fullscreen').fadeIn('fast')})};function loadTree(){$('#navigation').html('&nbsp;');$('#navigation').orTree({type:'root',id:0,onSelect:function(t,e,i,n){openNewAction(t,e,i,n)}});$('#navigation > div.sheet.action-tree.method-tree > ul.tree > div.tree').delay(500).click();$('#navigation > div.sheet.action-tree.method-tree > ul.tree > div.tree').delay(500).click()};function submitUrl(t,e){postUrl(e,t)};function postUrl(t,e){t+='&output=json';$.ajax({'type':'POST',url:t,data:{},success:function(t,i,n){$('div.panel div.status div.loader').html('&nbsp;');doResponse(t,i,e)}})};function startDialog(t,e,i,n,a){if(!e)e=$('#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" />'+t+'</div>');$('div#dialog > .view').data('id',n);$('div#dialog').removeClass('is-closed').addClass('is-open');Workbench.loadViewIntoElement($('div#dialog > .view'),e,i,n,a)};function modalView(t,e){var i=$(t).closest('div.panel').find('li.active').attr('data-action'),n=$(t).closest('div.panel').find('li.active').attr('data-method'),a=$(t).closest('div.panel').find('li.active').attr('data-id');$(t).closest('div.content').modal({'overlayClose':'true','xxxonClose':function(){alert('close)')}});loadView($(t).closest('div.content'),i,n,a)};function setTitle(t){if(t)$('head > title').text(t+' - '+$('head > title').data('default'));else $('head > title').text($('head > title').data('default'))};function openNewAction(t,e,i,n){setTitle(t);setNewAction(e,i,n)};function filterMenus(t){$('div.clickable').addClass('active');$('div.clickable.filtered').removeClass('active').addClass('inactive');$('div.clickable.filtered.on-action-'+t).addClass('active').removeClass('inactive')};function setNewAction(t,e,i){Navigator.navigateToNewAction(t,'edit',e,i)};function setNewId(t){};function notifyBrowser(t){if(!('Notification' in window)){return} else if(Notification.permission==='granted'){var e=new Notification(t)} else if(Notification.permission!=='denied'){Notification.requestPermission(function(e){if(e==='granted'){var i=new Notification(t)}})}};function setUserStyle(t){var e=$('html'),i=e.attr('class').split(/\s+/);$.each(i,function(t,i){if(i.startsWith('theme-')){e.removeClass(i)}});e.addClass('theme-'+t.toLowerCase())};function insert(t,e,i){var n=document.forms[0].elements[t];n.focus();if(typeof document.selection!='undefined'){var r=document.selection.createRange(),a=r.text;r.text=e+a+i;r=document.selection.createRange();if(a.length==0){r.move('character',-i.length)} diff --git a/modules/template-engine/components/html/form/form.js b/modules/template-engine/components/html/form/form.js @@ -14,9 +14,12 @@ $(document).on('orViewLoaded',function(event, data) { }); // 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(); }); + */ $(event.target).find('input.submit.cancel').click( function() { // TODO: cancel dialog screen (if clicked in dialog) @@ -24,8 +27,14 @@ $(document).on('orViewLoaded',function(event, data) { // Submithandler for the whole form. $(event.target).find('form').submit(function( event ) { - formSubmit($(this)); - event.preventDefault(); + + // + if ($(this).data('target')=='view') + { + formSubmit($(this)); + event.preventDefault(); + } + // target=top will load the native way without javascript. }); } ); 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('input.submit.ok').click(function(){$(this).closest('form').submit()});$(e.target).find('input.submit.cancel').click(function(){});$(e.target).find('form').submit(function(e){formSubmit($(this));e.preventDefault()})});function formSubmit(e){if($('#pageelement_edit_editor').length>0){var o=CKEDITOR.instances['pageelement_edit_editor'];if(o){var l=o.getData();$('#pageelement_edit_editor').html(l)}};var t=$('<div class="notice info"><div class="text loader"></div></div>');$('#noticebar').prepend(t);$(t).show();$(e).find('.error').removeClass('error');var a=$(e).serializeArray(),d=$(e).attr('method').toUpperCase();if(d=='GET'){var r=$(e).data('action'),n=$(e).data('method'),s=$(e).data('id');loadView($(e).closest('div.content'),r,n,s,a)} +;$(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('input.submit.cancel').click(function(){});$(e.target).find('form').submit(function(e){if($(this).data('target')=='view'){formSubmit($(this));e.preventDefault()}})});function formSubmit(e){if($('#pageelement_edit_editor').length>0){var o=CKEDITOR.instances['pageelement_edit_editor'];if(o){var l=o.getData();$('#pageelement_edit_editor').html(l)}};var t=$('<div class="notice info"><div class="text loader"></div></div>');$('#noticebar').prepend(t);$(t).show();$(e).find('.error').removeClass('error');var a=$(e).serializeArray(),d=$(e).attr('method').toUpperCase();if(d=='GET'){var r=$(e).data('action'),n=$(e).data('method'),s=$(e).data('id');loadView($(e).closest('div.content'),r,n,s,a)} else{var i='./api/';$(e).closest('div.content').addClass('loader');i+='?output=json';a['output']='json';if($(e).data('async')||$(e).data('async')=='true'){$('div#dialog > .view').html('').hide()};$.ajax({'type':'POST',url:i,data:a,success:function(a,i,o){$(e).closest('div.content').removeClass('loader');$(t).remove();doResponse(a,i,e)},error:function(a,i,n){$(e).closest('div.content').removeClass('loader');$(t).remove();var r;try{var o=jQuery.parseJSON(a.responseText);r=o.error+'/'+o.description+': '+o.reason}catch(s){r=a.responseText};notify('error',r)}});$(e).fadeIn()}};function doResponse(e,t,a){if(t!='success'){alert('Server error: '+t);return};$.each(e['notices'],function(t,e){var i=$('<div class="notice '+e.status+'"><div class="text">'+e.text+'</div></div>');if($(a).data('async')=='true')notifyBrowser(e.text);$.each(e.log,function(e,t){$(i).append('<div class="log">'+t+'</div>')});$('#noticebar').prepend(i);$(i).fadeIn().click(function(){$(this).fadeOut('fast',function(){$(this).remove()})});var o;if(e.status=='ok'){o=3;if($(a).data('async')!='true'){$('div#dialog > .view').html('').hide();$(a).closest('div.panel').find('div.header ul.views li.action.active').removeClass('dirty')}} else{o=8};setTimeout(function(){$(i).fadeOut('slow').remove()},o*1000)});$.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;if(e.control.new_style)setUserStyle(e.control.new_style);if(e.control.refresh);else if(e.control.next_view);else if(e.errors.length==0)$(a).closest('div.panel').find('li.action.active').orLoadView()}; \ No newline at end of file