core.apps.picture=function(args){this.defaultProfile={title:"",app_style:"",height:200,popup:false,path:null,alt:"",picture_position:"fit",variable_content:false,url:""}} core.apps.picture.prototype={buildContent:function(el){this.buildModel(this.$["content"],[{tag:"div",id:"box",className:"app_picture_container",childs:[{tag:"div",className:"center",childs:[{tag:"img",id:"img",events:{onclick:"onImgClick"}}]}]}]);},onOpen:function(){this.setTitle(this.profile["title"]);this.$["window"].style.overflow="hidden";this.refresh();},onImgClick:function(){if(this.profile.url){location.href=this.profile.url;}else if(this.profile["popup"]){var img_url=this.profile["variable_content"]?core.data.variable_content.image:this.profile["path"];desktop.openImageBox([img_url]);}},refresh:function(){var el=this.$["img"];if(this.profile["variable_content"]){var f=core.data.variable_content.image;if(core.usertypethis.img_preloader.height){style={width:this.img_preloader.width*(this.$["box"].offsetHeight/this.img_preloader.height),height:this.$["box"].offsetHeight} if(style.width>this.$["box"].offsetWidth){style.width=this.$["box"].offsetWidth;style.height=this.img_preloader.height*(style.width/this.img_preloader.width);}}else{style={width:this.$["box"].offsetWidth,height:this.img_preloader.height*(this.$["box"].offsetWidth/this.img_preloader.width)} if(style.height>this.$["box"].offsetHeight){style.height=this.$["box"].offsetHeight;style.width=this.img_preloader.width*(style.height/this.img_preloader.height);}} style.marginLeft=-0.5*style.width;style.marginTop=-0.5*style.height;break;case"fill":if(this.img_preloader.width>this.img_preloader.height){style={width:this.img_preloader.width*(this.$["box"].offsetHeight/this.img_preloader.height),height:this.$["box"].offsetHeight} if(style.width1){for(var i=0;i1){for(var i=0;i"+s+"";},findItem:function(node){if(!node)node=core.data.main_menu;var res=null;for(var i=0;i=USERTYPE_ADMIN){var data={summary:"Click here to select document",content:"Click here to select document"}}else{var data={summary:"",content:""}} if(this.profile["show_date"]&&data.modified){this.showElement("date_box");var d=new Date(data.modified*1000);this.$["date"].innerHTML=d.format("l d M Y");}else{this.hideElement("date_box");} if(this.profile["hide_user"]==1){this.showElement("btn_close");} if(this.profile["hide_timer"]==1){this.onDelayTimeOut(this.id,this.profile["hide_delay"]);} if(this.profile["show_author"]&&data.author){this.showElement("author_box");this.$["author"].innerHTML=data.author;}else{this.hideElement("author_box");} if(this.profile["webnote_content_type"]==0){this.hideElements(["summary_box","link_more"]);this.showElement("content_box");}else{this.showElement("summary_box");if(this.profile["hide_more"]){this.hideElement("link_more");}else{this.showElement("link_more");} this.hideElement("content_box");} this.$["summary_box"].innerHTML=data.summary;this.$["content_box"].innerHTML=data.content;},onMoreClick:function(e){this.hideElements(["link_more","summary_box"]);this.showElement("content_box");},getParentByClassName:function(el,className){if(el.className===className){return el;}else{return this.getParentByClassName(el.parentNode,className);}},onBtnCloseClick:function(e){if(this.profile["hide_user"]!=1)return false;var parent=this.getParentByClassName(e.target,'app_mc');parent.style.display="none";},onDelayTimeOut:function(id,time){if(core.usertype!=USERTYPE_ADMIN){window.setTimeout(function(first){var currentElement=document.getElementById(first);var parent=core.apps.webnote.prototype.getParentByClassName(currentElement,'app_mc');parent.style.display="none";},time*1000,this.id);}}} core.apps.webnote.extendPrototype(core.components.html_component);core.apps.webnote.extendPrototype(core.components.desktop_app); core.launcher.registerLoadedApps(["webnote"]); core.data.theme_style_keys["webnote"] = 'webnote'; core.apps.form=function(args){this.defaultProfile={title:"",app_style:"",form_id:null,target_url:""}} core.apps.form.prototype={onOpen:function(){var fp={parent_el:this.$["content"]} this.form=new core.objects.form(fp);this.setTitle(this.profile["title"]);this.refresh();},refresh:function(){this.$["content"].innerHTML="";var form_id=this.profile["form_id"];if(!form_id)return;if(!core.data.forms||!core.data.forms[form_id]){this.loadFormData();return} this.renderForm();},loadFormData:function(){this.$["content"].innerHTML="Loading...";var p={dialog:"forms_manager",act:"get",id:this.profile["form_id"]} core.transport.send("/controller.php",p,this.onFormDataResponce.bind(this));},onFormDataResponce:function(r){if(!r||r.status!="ok"){this.$["content"].innerHTML="Form missed";return;} if(!core.data.forms){core.data.forms={}} core.data.forms[r.form_id]=r.form;this.renderForm();},renderForm:function(){this.$["content"].innerHTML="";var form=core.data.forms[this.profile["form_id"]];if(!form){return;} var fp={target_value:this.profile["target_url"],target_type:"url"} this.form.setProperties(fp);this.form.setStructure(form,this.profile["form_id"]);this.form.render();}} core.apps.form.extendPrototype(core.components.html_component);core.apps.form.extendPrototype(core.components.desktop_app); core.launcher.registerLoadedApps(["form"]); core.data.theme_style_keys["form"] = 'form'; core.apps.iframe=function(args){this.defaultProfile={title:"",app_style:"",height:200,url:""}} core.apps.iframe.prototype={buildContent:function(el){this.buildModel(el,{tag:"iframe",id:"browser",vspace:"0",hspace:"0",marginwidth:"0",marginheight:"0",frameBorder:"0",allowTransparency:true,style:{width:"100%",height:"0",border:"0",backgroundColor:"transparent"}});},onOpen:function(){this.setTitle(this.profile["title"]);this.refresh();},refresh:function(){this.$["browser"].style.height=this.profile["height"]+"px";this.$["browser"].src=this.profile["url"]||"about:blank";}} core.apps.iframe.extendPrototype(core.components.html_component);core.apps.iframe.extendPrototype(core.components.desktop_app); core.launcher.registerLoadedApps(["iframe"]); core.data.theme_style_keys["iframe"] = 'iframe'; core.apps.slideshow=function(args){this.defaultProfile={title:"",app_style:"",labels:[],images:[],alts:[],urls:[],interval:5,effect:"fade",height:200,popup:true,numbers:true,caption:true,nav_handle_mouseover:false,title_in_nav:false,keywords:"",picture_position:"fit"} this.animation_frames=20;this.animation_frame_delay=20;} core.apps.slideshow.prototype={buildContent:function(el){var h=this.profile["height"]+"px";this.buildModel(this.$["content"],{tag:"div",className:"slideshow",id:"slideshow",childs:[{tag:"div",className:"slideshow_box",id:"box",childs:[{tag:"div",className:"picture_container",id:"active_slide",style:{zIndex:1},display:false,childs:[{tag:"div",childs:[{tag:"img",id:"active_img",className:"slideshow_img",events:{onclick:"popupImage"}}]}]},{tag:"div",className:"picture_container",id:"next_slide",style:{zIndex:2},display:false,childs:[{tag:"div",childs:[{tag:"img",id:"next_img",className:"slideshow_img"}]}]}]},{tag:"div",id:"box_nav_content",className:"nav",childs:[{tag:"div",className:"caption",id:"box_nav_text"},{tag:"div",className:"numbers",id:"box_nav"}]}]});},onOpen:function(){this.setTitle(this.profile["title"]);this.$["window"].style.overflow="hidden";this.refresh();},onClose:function(){clearTimeout(this.timeout);},updateBoxSize:function(){var h=this.profile.height+"px";this.$["box"].style.height=h;this.$["active_slide"].style.height=h;this.$["active_slide"].style.width=this.$["box"].offsetWidth+"px";this.$["next_slide"].style.height=h;this.$["next_slide"].style.width=this.$["box"].offsetWidth+"px";},popupImage:function(){var url=this.slides[this.active_slide].url;if(url){location.href=url;}else if(this.profile["popup"]){var images=this.getImagesList();desktop.openImageBox(images,this.active_slide);}},getImagesList:function(){var res=[];for(var i=0;i=this.slides.length){this.active_slide=0;} this.showActiveSlide();},loadSlide:function(){if(!this.img_preloader){this.img_preloader=new Image();this.img_preloader.onload=this.onSlidePreloaded.bind(this);} this.img_preloader.src=this.getImageSrc(this.active_slide);},onSlidePreloaded:function(){this.loaded_slides[this.active_slide]={width:this.img_preloader.width,height:this.img_preloader.height} this.showActiveSlide();},startAnimation:function(){this.animation_started=true;this.setSlideSrc("next",this.active_slide);this.callFunction("initEffect_"+this.profile["effect"]);for(var i=0;i1){var pos=1;}else{var pos=frame/(this.animation_frames-1);} this.callFunction("processEffect_"+this.profile["effect"],pos);if(pos==1){this.endAnimation();}},endAnimation:function(){this.callFunction("finishEffect_"+this.profile["effect"]);this.setSlideSrc("active",this.active_slide);this.setSlideSrc("next",false);this.animation_started=false;this.timeout=setTimeout(this.nextSlide.bind(this),1000*this.profile["interval"]);},initEffect_fade:function(){this.$["active_slide"].style.left=0;this.$["next_slide"].style.left=0;this.setElementOpacity("next_slide",0);},processEffect_fade:function(pos){var v=100-pos*100 this.setElementOpacity("active_slide",100-pos*100);this.setElementOpacity("next_slide",pos*100);},finishEffect_fade:function(){this.setElementOpacity("active_slide",100);},initEffect_scroll:function(){this.$["next_slide"].style.left="20000px";},processEffect_scroll:function(pos){var w=this.$["box"].offsetWidth;this.$["active_slide"].style.left=(-w*pos)+"px";this.$["next_slide"].style.left=(w-w*pos)+"px";},finishEffect_scroll:function(){this.$["next_slide"].style.left=0;this.$["active_slide"].style.left=0;},setSlideSrc:function(key,idx){if(idx===false){this.hideElement(key+"_slide");return;} this.showElement(key+"_slide");var img_el=this.$[key+"_img"];img_el.src=this.getImageSrc(idx);var style={};var original_size=this.loaded_slides[idx];switch(this.profile["picture_position"]){case"size_height":style.height=this.$["box"].offsetHeight;style.width=original_size.width*(this.$["box"].offsetHeight/original_size.height);style.marginLeft=-0.5*style.width;style.marginTop=-0.5*style.height;break;case"size_width":style.width=this.$["box"].offsetWidth;style.height=original_size.height*(this.$["box"].offsetWidth/original_size.width);style.marginLeft=-0.5*style.width;style.marginTop=-0.5*style.height;break;case"fit":if(original_size.width>original_size.height){style={width:original_size.width*(this.$["box"].offsetHeight/original_size.height),height:this.$["box"].offsetHeight} if(style.width>this.$["box"].offsetWidth){style.width=this.$["box"].offsetWidth;style.height=original_size.height*(style.width/original_size.width);}}else{style={width:this.$["box"].offsetWidth,height:original_size.height*(this.$["box"].offsetWidth/original_size.width)} if(style.height>this.$["box"].offsetHeight){style.height=this.$["box"].offsetHeight;style.width=original_size.width*(style.height/original_size.height);}} style.marginLeft=-0.5*style.width;style.marginTop=-0.5*style.height;break;case"fill":if(original_size.width>original_size.height){style={width:original_size.width*(this.$["box"].offsetHeight/original_size.height),height:this.$["box"].offsetHeight} if(style.width