engine/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/plugin.js

7 lines
22 KiB
JavaScript

/*
* Aloha Editor
* Author & Copyright (c) 2010 Gentics Software GmbH
* aloha-sales@gentics.com
* Licensed unter the terms of http://www.aloha-editor.com/license.html
*/
GENTICS.Aloha.GCN=new GENTICS.Aloha.Plugin("com.gentics.aloha.plugins.GCN");GENTICS.Aloha.GCN.languages=["en","de","fr","eo","fi","it"];GENTICS.Aloha.GCN.maximized=false;GENTICS.Aloha.GCN.buttons={};GENTICS.Aloha.GCN.lastActiveEditable={};GENTICS.Aloha.GCN.backendUrl="../CNPortletapp/";GENTICS.Aloha.GCN.restUrl=GENTICS.Aloha.GCN.backendUrl+"rest";GENTICS.Aloha.GCN.closeLightbox=function(){jQuery.prettyPhoto.close();GENTICS.Aloha.Ribbon.show();if(GENTICS.Aloha.GCN.lastActiveEditable!=undefined){GENTICS.Aloha.GCN.lastActiveEditable.activate();GENTICS.Aloha.GCN.lastActiveEditable.obj.focus()}};GENTICS.Aloha.GCN.init=function(){var that=this;jQuery().prettyPhoto({theme:"light_square",opacity:0.4,markup:'<div class="pp_pic_holder"> <div class="pp_top"> <div class="pp_left"></div> <div class="pp_middle"></div> <div class="pp_right"></div> </div> <div class="pp_content_container"> <div class="pp_left"> <div class="pp_right"> <div class="pp_content"> <div class="pp_fade"> <a href="#" class="pp_expand" title="Expand the image">Expand</a> <div class="pp_loaderIcon"></div> <div class="pp_hoverContainer"> <a class="pp_next" href="#">next</a> <a class="pp_previous" href="#">previous</a> </div> <div id="pp_full_res"></div> <div class="pp_details"> </div> </div> </div> </div> </div> </div> <div class="pp_bottom"> <div class="pp_left"></div> <div class="pp_middle"></div> <div class="pp_right"></div> </div> </div> <div class="pp_overlay"></div> <div class="ppt"></div>'});var maximizeOptions=null;if(this.isGCNFrame()){GENTICS.Aloha.settings.ribbon=false;jQuery("head").append('<link type="text/css" href="'+this.createGCNURL({url:that.settings.stag_prefix,params:{"do":20,url:"lib/css/gui.css"}})+'" rel="stylesheet">');jQuery("body").append('<div style="z-index: 999999; position: absolute; visibility: hidden" class="gentics_submenu" id="nodesubmenu1"> </div>');jQuery("head").append('<script type="text/javascript" src="'+this.createGCNURL({url:this.settings.stag_prefix,params:{"do":20,url:"lib/js/layer.js"}})+'"><\/script>');jQuery("head").append('<script type="text/javascript" src="'+this.createGCNURL({url:this.settings.stag_prefix,params:{"do":20,url:"lib/js/tools.js"}})+'"><\/script>');jQuery("head").append('<script type="text/javascript" src="'+this.createGCNURL({url:this.settings.stag_prefix,params:{"do":20,url:"lib/js/menu1.js"}})+'"><\/script>');if(top.menu){top.menu.location=this.createGCNURL({url:this.settings.stag_prefix,params:{"do":14004,MENU_LAYER:0,ass_pre_flapped:0,aloha:true}})}jQuery("html").click(function(){hide_layer(get_layer("nodesubmenu1"));if(top.menu){top.menu.nodesubmenu1_clicked=false}});jQuery("html").mouseover(function(){if(top.tree&&top.tree.frame_small){top.tree.frame_small()}})}GENTICS.Aloha.GCN.updateFrameUI();jQuery(window).unload(function(){that.restoreFrameUI();if(GENTICS.Aloha.isModified()){if(confirm(GENTICS.Aloha.i18n(GENTICS.Aloha,"confirm_editable_modified"))){that.savePage({silent:true,async:false});return false}}});this.alohaEditables(this.settings.editables);this.alohaBlocks(this.settings.blocks);if(this.settings.welcomeMessages){jQuery.each(this.settings.welcomeMessages,function(index,message){GENTICS.Aloha.showMessage(new GENTICS.Aloha.Message({title:"Gentics Content.Node",text:message.message,type:GENTICS.Aloha.Message.Type.ALERT}))})}if(GENTICS.Aloha.Log.isDebugEnabled()){var editables=0;var blocks=0;if(this.settings.editables){editables=this.settings.editables.length}if(this.settings.blocks){blocks=this.settings.blocks.length}GENTICS.Aloha.Log.debug(this,"Loaded page with id { "+this.settings.id+" }.");GENTICS.Aloha.Log.debug(this,"Found "+editables+" editables and "+blocks+" blocks.")}var pageMenu=new Array();pageMenu.push(new GENTICS.Aloha.ui.Button({label:this.i18n("button.preview"),onclick:function(){that.previewPage()}}));pageMenu.push(new GENTICS.Aloha.ui.Button({label:this.i18n("button.edit"),onclick:function(){that.editPage()}}));pageMenu.push(new GENTICS.Aloha.ui.Button({label:this.i18n("button.livepreview"),onclick:function(){that.savePage({onsuccess:function(){that.openGCNURL({url:that.settings.stag_prefix,popup:true,params:{live:that.settings.id,"do":14001}})},onfailure:function(){},silent:true})}}));var propsBackParam=this.isGCNFrame()?"":'a:3:{s:4:"REDO";s:5:"14012";s:6:"realid";s:'+String(this.settings.id).length+':"'+this.settings.id+'";s:4:"real";s:4:"edit";}';pageMenu.push(new GENTICS.Aloha.ui.Button({label:this.i18n("button.properties"),onclick:function(){that.openGCNURL({url:that.settings.stag_prefix,params:{"do":14000,PAGE_ID:that.settings.id,FOLDER_ID:that.settings.folderId,back:propsBackParam}})}}));var pageButton=new GENTICS.Aloha.ui.Button({label:this.i18n("button.page"),menu:pageMenu});GENTICS.Aloha.Ribbon.addButton(pageButton);if(this.settings.languageMenu&&this.settings.languageMenu.length>0){var menu=Array();jQuery.each(this.settings.languageMenu,function(index,language){menu.push(new GENTICS.Aloha.ui.Button({label:language.name,icon:that.createGCNURL({url:that.settings.stag_prefix,params:{"do":14203,base:"doc_hi.png",lang:language.code,module:"content"}}),onclick:function(){that.openGCNURL({url:that.settings.stag_prefix,params:{"do":14015,t_type:10007,redo:14001,CONTENTGROUP_ID:language.id}})}}))});GENTICS.Aloha.Ribbon.addButton(new GENTICS.Aloha.ui.Button({label:this.i18n("button.language"),menu:menu}))}var publishParams=this.isGCNFrame()?{"do":14003,cmd:"pub"}:{"do":14012,realid:this.settings.id,real:"pub"};var publishAtParams=this.isGCNFrame()?{"do":14021}:{"do":14021,PAGE_ID:this.settings.id,FOLDER_ID:this.settings.folderId,back:propsBackParam};var saveButtonMenu=Array();saveButtonMenu.push(new GENTICS.Aloha.ui.Button({label:this.i18n("button.publish"),onclick:function(){that.openGCNURL({url:that.settings.stag_prefix,params:publishParams})}}));if(this.isGCNFrame()){saveButtonMenu.push(new GENTICS.Aloha.ui.Button({label:this.i18n("button.publishat"),onclick:function(){that.openGCNURL({url:that.settings.stag_prefix,params:publishAtParams})}}))}var saveButton=new GENTICS.Aloha.ui.Button({label:this.i18n("button.save"),onclick:function(){that.savePage()},menu:saveButtonMenu});GENTICS.Aloha.Ribbon.addButton(saveButton);if(GENTICS.Aloha.settings.readonly){GENTICS.Aloha.Ribbon.addButton(new GENTICS.Aloha.ui.Button({label:this.i18n("button.quit"),onclick:function(){that.quitEdit()}}))}else{var cancelButton=new GENTICS.Aloha.ui.Button({label:this.i18n("button.cancel"),onclick:function(){that.cancelEdit(function(){that.previewPage()})},menu:[new GENTICS.Aloha.ui.Button({label:this.i18n("button.quit"),onclick:function(){that.quitEdit()}})]});GENTICS.Aloha.Ribbon.addButton(cancelButton)}if(this.isGCNFrame()){GENTICS.Aloha.Ribbon.hide()}GENTICS.Aloha.Ribbon.setIcon("GENTICS_logo");var contentTagsMenu=new Array();var constructs=new Array();if(this.settings.constructCategories){for(var i=0;i<this.settings.constructCategories.length;i++){constructs=new Array();for(var j=0;j<this.settings.constructCategories[i].constructs.length;j++){constructs.push(new GENTICS.Aloha.ui.Button({label:this.settings.constructCategories[i].constructs[j].name,icon:this.createGCNURL({url:that.settings.stag_prefix,params:{"do":11,img:"constr/"+this.settings.constructCategories[i].constructs[j].icon,module:"content"}}),constructId:this.settings.constructCategories[i].constructs[j].id,onclick:function(){that.createTag(this.constructId)}}))}contentTagsMenu.push(new GENTICS.Aloha.ui.Button({label:this.settings.constructCategories[i].name,icon:this.createGCNURL({url:that.settings.stag_prefix,params:{"do":11,img:"constructopen.gif",module:"content"}}),menu:constructs,onclick:function(){}}))}if(contentTagsMenu.length>0){GENTICS.Aloha.FloatingMenu.addButton("GENTICS.Aloha.continuoustext",new GENTICS.Aloha.ui.Button({tooltip:this.i18n("insert_tag"),icon:this.createGCNURL({url:that.settings.stag_prefix,params:{"do":11,img:"constructopen.gif",module:"content"}}),menu:contentTagsMenu,size:"medium"}),GENTICS.Aloha.i18n(GENTICS.Aloha,"floatingmenu.tab.insert"),1)}}GENTICS.Utils.Position.addMouseMoveCallback(function(){if(GENTICS.Aloha.activeEditable){jQuery(".GENTICS_editable_active .GENTICS_editicon:not(.GENTICS_editicon_hover)").fadeIn("fast")}else{jQuery(".GENTICS_editicon:not(.GENTICS_editicon_hover)").show()}});GENTICS.Utils.Position.addMouseStopCallback(function(){if(GENTICS.Aloha.activeEditable){jQuery(".GENTICS_editable_active .GENTICS_editicon:not(.GENTICS_editicon_hover)").fadeOut("normal")}else{jQuery(".GENTICS_editicon:not(.GENTICS_editicon_hover)").fadeOut("normal")}});GENTICS.Aloha.EventRegistry.subscribe(GENTICS.Aloha,"editableActivated",function(){jQuery(".GENTICS_editicon").fadeOut("normal")})};GENTICS.Aloha.GCN.alohaEditables=function(editables){if(editables){jQuery.each(editables,function(index,editable){jQuery("#"+editable.id).aloha()})}};GENTICS.Aloha.GCN.alohaBlocks=function(blocks){if(blocks){jQuery.each(blocks,function(index,block){jQuery("#"+block.id).addClass("GENTICS_block").attr("contenteditable",false);if(!GENTICS.Aloha.settings.readonly){var imgTag=jQuery("<img>");imgTag.attr("border",0);imgTag.attr("src",block.iconurl);var buttonTag=jQuery("<button>");buttonTag.click(function(){GENTICS.Aloha.GCN.openTagFill(block.tagid)});buttonTag.attr("alt",block.icontitle).attr("title",block.icontitle).addClass("GENTICS_editicon").mouseover(function(){jQuery(this).addClass("GENTICS_editicon_hover")}).mouseout(function(){jQuery(this).removeClass("GENTICS_editicon_hover")}).prepend(imgTag);jQuery("#"+block.id).prepend(buttonTag)}})}};GENTICS.Aloha.GCN.maximizeOptions={fsContent_cols:"0,*,0",frameset0_cols:"315,*",frameset2_rows:"101,*"};GENTICS.Aloha.GCN.toggleEditFrame=function(){if(!top.main){return}if(this.isEditFrameMaximized()){this.normalizeEditFrame()}else{this.maximizeEditFrame()}};GENTICS.Aloha.GCN.normalizeEditFrame=function(){top.main.document.getElementById("fsContent").cols=this.maximizeOptions.fsContent_cols;top.document.getElementsByTagName("frameset")[0].cols=this.maximizeOptions.frameset0_cols;top.document.getElementsByTagName("frameset")[2].rows=this.maximizeOptions.frameset2_rows;this.buttons.maximizeButton.setPressed(false)};GENTICS.Aloha.GCN.maximizeEditFrame=function(){this.maximizeOptions.fsContent_cols=top.main.document.getElementById("fsContent").cols;this.maximizeOptions.frameset0_cols=top.document.getElementsByTagName("frameset")[0].cols;this.maximizeOptions.frameset2_rows=top.document.getElementsByTagName("frameset")[2].rows;top.main.document.getElementById("fsContent").cols="0,*,0";top.document.getElementsByTagName("frameset")[0].cols="0,*";top.document.getElementsByTagName("frameset")[2].rows="0,*";this.buttons.maximizeButton.setPressed(true)};GENTICS.Aloha.GCN.isEditFrameMaximized=function(){if(!this.isGCNFrame()){return false}if(top.document.getElementsByTagName("frameset")[0].cols=="0,*"){return true}else{return false}};GENTICS.Aloha.GCN.isGCNFrame=function(){if(!window.parent){return false}var assistant=jQuery("frame",window.parent.document).eq(0);if(assistant.attr("name")==="ass"){return true}assistant=jQuery("frame",window.parent.document).eq(2);if(assistant.attr("name")==="ass"){return true}return false};GENTICS.Aloha.GCN.updateFrameUI=function(){if(this.isGCNFrame()){var assistantFrameset=jQuery("frameset",window.parent.document);this.originalColumns=assistantFrameset.attr("cols");this.originalRows=assistantFrameset.attr("rows");if(this.originalColumns){assistantFrameset.attr("cols","0,*,0")}if(this.originalRows){assistantFrameset.attr("rows","*,0,0")}var menuFrame=jQuery(window.parent.parent.frames[2].document);menuFrame.find("#ProgressStatusInfo_0").hide()}};GENTICS.Aloha.GCN.restoreFrameUI=function(){if(this.isGCNFrame()){var assistantFrameset=jQuery("frameset",window.parent.document);if(this.originalColumns){assistantFrameset.attr("cols",this.originalColumns)}if(this.originalRows){assistantFrameset.attr("rows",this.originalRows)}}};GENTICS.Aloha.GCN.cancelEdit=function(callback){var that=this;for(var i in GENTICS.Aloha.editables){if(GENTICS.Aloha.editables[i].setUnmodified){GENTICS.Aloha.editables[i].setUnmodified()}}this.performRESTRequest({url:this.settings.stag_prefix+this.restUrl+"/page/cancel/"+this.settings.id,description:"restcall.cancelpage",success:callback,error:function(data){GENTICS.Aloha.showMessage(new GENTICS.Aloha.Message({title:"Gentics Content.Node",text:that.i18n("restcall.cancelpage.error"),type:GENTICS.Aloha.Message.Type.ALERT}))}})};GENTICS.Aloha.GCN.quitEdit=function(){var that=this;if(this.isEditFrameMaximized()){this.normalizeEditFrame()}this.cancelEdit(function(){if(that.settings.backurl){document.location.href=that.settings.backurl}else{if(that.isGCNFrame()){that.openGCNURL({url:that.settings.stag_prefix,params:{"do":13011}})}else{that.openGCNURL({url:that.settings.stag_prefix,params:{"do":14300,close:true}})}}})};GENTICS.Aloha.GCN.previewPage=function(){var that=this;this.openGCNURL({url:this.settings.stag_prefix+this.backendUrl+"/alohapage",params:{realid:that.settings.id,language:that.settings.languageid,real:"view",links:that.settings.links}})};GENTICS.Aloha.GCN.editPage=function(){var that=this;this.openGCNURL({url:this.settings.stag_prefix+this.backendUrl+"/alohapage",params:{realid:that.settings.id,language:that.settings.languageid,real:"edit",links:that.settings.links}})};GENTICS.Aloha.GCN.savePage=function(data){var that=this;if(typeof data=="undefined"){data={}}if(typeof data.async=="undefined"){data.async=true}if(!data.async){var saveProgress=new GENTICS.Aloha.Message({title:"Gentics Content.Node",text:GENTICS.Aloha.i18n(that,"save.progress"),type:GENTICS.Aloha.Message.Type.WAIT});GENTICS.Aloha.showMessage(saveProgress)}var requestBody={unlock:data.closeAfterSave?true:false,page:{id:this.settings.id,templateId:this.settings.templateId,folderId:this.settings.folderId,name:this.settings.name,fileName:this.settings.fileName,description:this.settings.description,priority:this.settings.priority}};requestBody.page.tags={};for(var i=0;i<GENTICS.Aloha.editables.length;++i){var editable=GENTICS.Aloha.editables[i];var gcnEditable=this.findLoadedEditable(editable.getId());if(gcnEditable){var content=editable.getContents();content=content.replace(/<span class=\"GENTICS_block\" id=\"(\w+)\">x<\/span>/g,"<node $1>");if(gcnEditable.metaproperty){if(gcnEditable.metaproperty.indexOf("page.")!=0){continue}var prop=gcnEditable.metaproperty.replace(/^page\./,"");requestBody.page[prop]=content}else{var properties={};if(!requestBody.page.tags[gcnEditable.tagname]){requestBody.page.tags[gcnEditable.tagname]={name:gcnEditable.tagname,active:true,properties:{}}}requestBody.page.tags[gcnEditable.tagname].properties[gcnEditable.partname]={type:"RICHTEXT",stringValue:content}}}else{}}var onsuccess=data?data.onsuccess:undefined;var onfailure=data?data.onfailure:undefined;if(typeof onfailure!="function"){onfailure=function(data){GENTICS.Aloha.showMessage(new GENTICS.Aloha.Message({title:"Gentics Content.Node",text:that.i18n("restcall.savepage.error"),type:GENTICS.Aloha.Message.Type.ALERT}))}}var showMessages=data&&data.silent?false:true;this.performRESTRequest({url:this.settings.stag_prefix+this.restUrl+"/page/save/"+this.settings.id,body:requestBody,description:"restcall.savepage",success:function(data){for(var i in GENTICS.Aloha.editables){if(GENTICS.Aloha.editables[i].setUnmodified){GENTICS.Aloha.editables[i].setUnmodified()}}if(typeof saveProgress!="undefined"){GENTICS.Aloha.hideMessage(saveProgress)}if(showMessages&&data.messages){jQuery.each(data.messages,function(index,message){GENTICS.Aloha.showMessage(new GENTICS.Aloha.Message({title:"Gentics Content.Node",text:message.message,type:GENTICS.Aloha.Message.Type.ALERT}))})}if(onsuccess){onsuccess(data)}},error:function(data){if(typeof saveProgress!="undefined"){GENTICS.Aloha.hideMessage(saveProgress)}if(onfailure){onfailure(data)}},async:data.async})};GENTICS.Aloha.GCN.publishPage=function(success){var that=this;this.savePage({onsuccess:function(){var publishParams=success?{"do":14022,page_id:that.settings.id}:(that.isGCNFrame()?{"do":14003,cmd:"pub",PAGE_ID:that.settings.id}:{"do":14012,realid:that.settings.id,real:"pub"});if(success){that.performRESTRequest({url:that.settings.stag_prefix,params:publishParams,success:function(){success.apply()}})}else{that.openGCNURL({url:that.settings.stag_prefix,params:publishParams})}},onfailure:function(){},silent:success?true:false})};GENTICS.Aloha.GCN.publishPageAt=function(){var that=this;this.savePage({onsuccess:function(){var propsBackParam=that.isGCNFrame()?"":'a:3:{s:4:"REDO";s:5:"14012";s:6:"realid";s:'+String(that.settings.id).length+':"'+that.settings.id+'";s:4:"real";s:4:"edit";}';var publishAtParams=that.isGCNFrame()?{"do":14021}:{"do":14021,PAGE_ID:that.settings.id,FOLDER_ID:that.settings.folderId,back:propsBackParam};that.openGCNURL({url:that.settings.stag_prefix,params:publishAtParams})},onfailure:function(){}})};GENTICS.Aloha.GCN.findLoadedEditable=function(id){if(this.settings.editables){for(var i=0;i<this.settings.editables.length;++i){if(this.settings.editables[i].id==id){return this.settings.editables[i]}}}};GENTICS.Aloha.GCN.makeClean=function(obj){if(this.settings.blocks){jQuery.each(this.settings.blocks,function(index,block){obj.find("#"+block.id).replaceWith('<span class="GENTICS_block" id="'+block.tagname+'">x</span>')})}};GENTICS.Aloha.GCN.performRESTRequest=function(data){var that=this;if(!data.type){data.type="POST"}var ajaxObject={type:data.type,dataType:"json",timeout:10000,contentType:"application/json; charset=utf-8",data:jQuery.toJSON(data.body)};ajaxObject.url=data.url+"?sid="+this.settings.sid+"&time="+(new Date()).getTime();if(data.params){for(var paramName in data.params){ajaxObject.url+="&"+paramName+"="+encodeURI(data.params[paramName])}}if(typeof data.async!="undefined"){ajaxObject.async=data.async}if(data.success){ajaxObject.success=data.success}if(data.error){ajaxObject.error=data.error}jQuery.ajax(ajaxObject)};GENTICS.Aloha.GCN.createGCNURL=function(data){var url=data.url+"?sid="+this.settings.sid+"&time="+(new Date()).getTime();for(var paramName in data.params){url+="&"+paramName+"="+encodeURI(data.params[paramName])}return url};GENTICS.Aloha.GCN.openGCNURL=function(data){var url=this.createGCNURL(data);var popup=data.popup;if(this.isEditFrameMaximized()){this.normalizeEditFrame()}this.openURL(url,popup)};GENTICS.Aloha.GCN.openURL=function(url,popup){if(GENTICS.Aloha.isModified()){this.savePage({unlock:false,onsuccess:function(){if(GENTICS.Aloha.Log.isDebugEnabled()){this.log("debug","opening url: "+url)}if(popup){window.open(url)}else{document.location.href=url}},silent:true,async:false})}else{if(GENTICS.Aloha.Log.isDebugEnabled()){this.log("debug","opening url: "+url)}if(popup){window.open(url)}else{document.location.href=url}}};GENTICS.Aloha.GCN.openTagFill=function(tagid){var that=this;GENTICS.Aloha.FloatingMenu.setScope("GENTICS.Aloha.empty");if(GENTICS.Aloha.activeEditable){GENTICS.Aloha.activeEditable.blur();GENTICS.Aloha.Ribbon.hide()}var editdo=10008;var block=this.getBlock(tagid);if(block&&block.editdo){editdo=block.editdo}var tagfillBackParam=this.isGCNFrame()?"":"realid|"+this.settings.id;var editLink=this.createGCNURL({url:this.settings.stag_prefix,params:{"do":editdo,id:tagid,type:"page",keepsid:1,backparam:tagfillBackParam}});if(GENTICS.Aloha.isModified()){this.savePage({onsuccess:function(){GENTICS.Aloha.Ribbon.hide();try{GENTICS.Aloha.activeEditable.blur();GENTICS.Aloha.GCN.lastActiveEditable=GENTICS.Aloha.activeEditable}catch(e){GENTICS.Aloha.GCN.lastActiveEditable=undefined}jQuery.prettyPhoto.open(new Array(editLink+"&iframe=true&width=100%&height=100%"))},unlock:false,silent:true,async:false})}else{GENTICS.Aloha.Ribbon.hide();try{GENTICS.Aloha.activeEditable.blur();GENTICS.Aloha.GCN.lastActiveEditable=GENTICS.Aloha.activeEditable}catch(e){GENTICS.Aloha.GCN.lastActiveEditable=undefined}jQuery.prettyPhoto.open(new Array(editLink+"&iframe=true&width=100%&height=100%"))}};GENTICS.Aloha.GCN.createTag=function(constructId){var that=this;this.performRESTRequest({url:this.settings.stag_prefix+this.restUrl+"/page/newtag/"+this.settings.id,params:{constructId:constructId},description:"restcall.createtag",success:function(data){that.performRESTRequest({url:that.settings.stag_prefix+that.backendUrl+"/alohatag",type:"GET",params:{realid:that.settings.id,real:"edit",template:"<node "+data.tag.name+">",language:that.settings.languageid,links:that.settings.links},success:function(data){that.handleBlock(data,true)},error:function(){GENTICS.Aloha.showMessage(new GENTICS.Aloha.Message({title:"Gentics Content.Node",text:GENTICS.Aloha.i18n(that,"restcall.createtag.error"),type:GENTICS.Aloha.Message.Type.ALERT}))}})}})};GENTICS.Aloha.GCN.getBlock=function(tagid){if(!this.settings.blocks){return false}for(var i=0;i<this.settings.blocks.length;++i){if(this.settings.blocks[i].tagid==tagid){return this.settings.blocks[i]}}return false};GENTICS.Aloha.GCN.reloadBlock=function(tagid){var block=this.getBlock(tagid);var that=this;if(!block){return}this.performRESTRequest({url:this.settings.stag_prefix+this.backendUrl+"/alohatag",type:"GET",params:{realid:that.settings.id,real:"edit",template:"<node "+block.tagname+">",language:that.settings.languageid,links:that.settings.links},success:function(data){that.handleBlock(data,false)},error:function(){GENTICS.Aloha.showMessage(new GENTICS.Aloha.Message({title:"Gentics Content.Node",text:GENTICS.Aloha.i18n(that,"restcall.reloadtag.error"),type:GENTICS.Aloha.Message.Type.ALERT}))}})};GENTICS.Aloha.GCN.handleBlock=function(data,insert){if(this.settings.renderBlockContentURL){data.content=this.renderBlockContent(data.content)}var blockObj=jQuery(data.content);jQuery("#"+blockObj.attr("id")).replaceWith(data.content);if(insert){GENTICS.Aloha.Markup.insertHTMLCode(data.content)}if(data.editables){if(!this.settings.editables){this.settings.editables=new Array()}for(var i=0;i<data.editables.length;++i){this.settings.editables.push(data.editables[i])}this.alohaEditables(data.editables)}if(data.blocks){if(!this.settings.blocks){this.settings.blocks=new Array()}for(var i=0;i<data.blocks.length;++i){this.settings.blocks.push(data.blocks[i])}this.alohaBlocks(data.blocks)}};GENTICS.Aloha.GCN.renderBlockContent=function(content){var that=this;var newContent=content;jQuery.ajax({url:this.settings.renderBlockContentURL,type:"POST",timeout:10000,data:{content:content},dataType:"text",async:false,success:function(data){newContent=data}});return newContent};function cn3_go_list(url){GENTICS.Aloha.GCN.openURL(url)};