openrat-cms

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

view.min.js (1835B)


      1 ;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){Openrat.Workbench.afterViewLoadedHandler.fire(e);let f=$(e).data('afterViewLoaded');if(f instanceof Function)f(e)};this.loadView=function(){let url=Openrat.View.createUrl(this.action,this.method,this.id,this.params,!1);let element=this.element;let view=this;let loadViewHtmlPromise=$.ajax(url);$(this.element).empty().fadeTo(1,0.7).addClass('loader');loadViewHtmlPromise.done(function(e,t){$(element).html(e);$(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)});n(element)});loadViewHtmlPromise.fail(function(e,t,i){$(element).html('');Openrat.Workbench.notify('','','error','Server Error',['Server Error while requesting url '+url,t])});let apiUrl=Openrat.View.createUrl(this.action,this.method,this.id,this.params,!0);let loadViewApiPromise=$.getJSON(apiUrl);loadViewHtmlPromise.done(function(){loadViewApiPromise.done(function(e,t){})});loadViewApiPromise.fail(function(e,t,i){Openrat.Workbench.notify('','','error','Server Error',['Server Error while requesting url '+apiUrl,t])})};Openrat.View.createUrl=function(e,subaction,i,extraid={},api=!1){let url='./';if(api)url+='api/';url+='?';if(e)url+='&action='+e;if(subaction)url+='&subaction='+subaction;if(i)url+='&id='+i;if(typeof extraid==='string'){extraid=extraid.replace(/'/g,'"');let extraObject=jQuery.parseJSON(extraid);jQuery.each(extraObject,function(e,t){url=url+'&'+e+'='+t})}
      2 else if(typeof extraid==='object'){jQuery.each(extraid,function(e,t){url=url+'&'+e+'='+t})}
      3 else{};return url}};