openrat-cms

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

commit cfbc2c98df1d57d9c244930bfb277e864b000e6d
parent bd959ecf72927bf737aa05ad6256b030beeba347
Author: Jan Dankert <devnull@localhost>
Date:   Fri, 13 Jul 2018 22:01:02 +0200

Browser-Notices nur bei asynchronen Actions verwenden, denn bei synchronen Actions reicht 1 Meldung, wir wollen den Benutzer nicht nerven.

Diffstat:
modules/cms-ui/themes/default/script/openrat.js | 9+++++++--
modules/cms-ui/themes/default/script/openrat.min.js | 8++++----
modules/template-engine/components/html/form/form.js | 8+++++++-
modules/template-engine/components/html/form/form.min.js | 8++++----
4 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/modules/cms-ui/themes/default/script/openrat.js b/modules/cms-ui/themes/default/script/openrat.js @@ -35,6 +35,12 @@ $( function() Workbench.initialize(); + // Per Klick wird die Notice entfernt. + $('#noticebar .notice').click( function() + { + $(this).fadeOut('fast',function() { $(this).remove(); } ); + } ); + loadTree(); // Initial Loading of the navigationtree @@ -740,8 +746,7 @@ function notify( type,msg ) // Notice-Bar mit dieser Meldung erweitern. var notice = $('<div class="notice '+type+'"><div class="text">'+msg+'</div></div>'); $('#noticebar').prepend(notice); // Notice anhängen. - notifyBrowser(msg); - + // Per Klick wird die Notice entfernt. $(notice).fadeIn().click( function() { diff --git a/modules/cms-ui/themes/default/script/openrat.min.js b/modules/cms-ui/themes/default/script/openrat.min.js @@ -1,10 +1,10 @@ -;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();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);$('#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')){} 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)} else{r.moveStart('character',e.length+a.length+i.length)};r.select()} -else if(typeof n.selectionStart!='undefined'){var d=n.selectionStart,s=n.selectionEnd,a=n.value.substring(d,s);n.value=n.value.substr(0,d)+e+a+i+n.value.substr(s);var o;if(a.length==0){o=d+e.length} +else if(typeof n.selectionStart!='undefined'){var d=n.selectionStart,c=n.selectionEnd,a=n.value.substring(d,c);n.value=n.value.substr(0,d)+e+a+i+n.value.substr(c);var o;if(a.length==0){o=d+e.length} else{o=d+e.length+a.length+i.length};n.selectionStart=o;n.selectionEnd=o} else{o=n.value.length;var a=prompt('Text');n.value=n.value.substr(0,o)+e+a+i+n.value.substr(o)}};function createUrl(t,e,i,n,o){var a='./';a+='?action='+t;if(e!=null)a+='&subaction='+e;a+='&id='+i;if(o)a+='&embed=1';if(typeof n==='string'){jQuery.each(jQuery.parseJSON(n),function(t,e){if(t=='action'||t=='subaction'||t=='id')return;a=a+'&'+t+'='+e})} else if(typeof n==='object'){jQuery.each(n,function(t,e){if(t=='action'||t=='subaction'||t=='id')return;a=a+'&'+t+'='+e})} -else{};return a};function resizeWorkbenchContainer(t){};function resizeWorkbench(){};function resizeTabs(t){};function help(t,e,i){var n=$(t).closest('div.panel').find('li.action.active').attr('data-action'),a=$(t).closest('div.panel').find('li.action.active').attr('data-method');window.open(e+n+'/'+a+i,'OpenRat_Help','location=no,menubar=no,scrollbars=yes,toolbar=no,resizable=yes')};function notify(t,e){var i=$('<div class="notice '+t+'"><div class="text">'+e+'</div></div>');$('#noticebar').prepend(i);notifyBrowser(e);$(i).fadeIn().click(function(){$(this).fadeOut('fast',function(){$(this).remove()})})};- \ No newline at end of file +else{};return a};function resizeWorkbenchContainer(t){};function resizeWorkbench(){};function resizeTabs(t){};function help(t,e,i){var n=$(t).closest('div.panel').find('li.action.active').attr('data-action'),a=$(t).closest('div.panel').find('li.action.active').attr('data-method');window.open(e+n+'/'+a+i,'OpenRat_Help','location=no,menubar=no,scrollbars=yes,toolbar=no,resizable=yes')};function notify(t,e){var i=$('<div class="notice '+t+'"><div class="text">'+e+'</div></div>');$('#noticebar').prepend(i);$(i).fadeIn().click(function(){$(this).fadeOut('fast',function(){$(this).remove()})})};+ \ 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 @@ -149,7 +149,13 @@ function doResponse(data,status,element) // Notice-Bar mit dieser Meldung erweitern. var notice = $('<div class="notice '+value.status+'"><div class="text">'+value.text+'</div></div>'); - notifyBrowser(value.text); + + // 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); + $.each(value.log, function(name,value) { $(notice).append('<div class="log">'+value+'</div>'); }); 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 a=CKEDITOR.instances['pageelement_edit_editor'];if(a){var l=a.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 o=$(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,o)} -else{var i='./api/';$(e).closest('div.content').addClass('loader');i+='?output=json';o['output']='json';if($(e).data('async')||$(e).data('async')=='true'){$('div#dialog > .view').html('').hide()};$.ajax({'type':'POST',url:i,data:o,success:function(o,i,a){$(e).closest('div.content').removeClass('loader');$(t).remove();doResponse(o,i,e)},error:function(o,i,n){$(e).closest('div.content').removeClass('loader');$(t).remove();var r;try{var a=jQuery.parseJSON(o.responseText);r=a.error+'/'+a.description+': '+a.reason}catch(s){r=o.responseText};notify('error',r)}});$(e).fadeIn()}};function doResponse(e,t,o){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>');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 a;if(e.status=='ok'){a=3;if($(o).data('async')!='true'){$('div#dialog > .view').html('').hide();$(o).closest('div.panel').find('div.header ul.views li.action.active').removeClass('dirty')}} -else{a=8};setTimeout(function(){$(i).fadeOut('slow').remove()},a*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)$(o).closest('div.panel').find('li.action.active').orLoadView()};- \ No newline at end of file +;$(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)} +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