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"+html+"";} this.$["content"].innerHTML=html;},getMenuHTML:function(){var html="";if(this.profile["itemId"]!=null){var mi=this.findItem(this.profile["itemId"]);if(mi!=null){var items=mi.childs;for(var i=0;i"+t+"";var shtml="";}else{var ihtml=""+t+"";var shtml=" class='active'";} html+=""+ihtml+"";}}} return"";},formatTitle:function(mi){return mi.hint?""+mi.title+" ":mi.title;}}); core.launcher.registerLoadedApps(["submenu"]); core.data.theme_style_keys["submenu"] = 'submenu'; core.apps.webnote=function(args){this.defaultProfile={title:"",app_style:"",show_date:0,show_author:0,webnote_content_type:'0',text_id:null,hide_more:0,hide_delay:"5",hide_user:0,hide_timer:0}} core.apps.webnote.prototype={buildContent:function(el){this.buildModel(el,[{tag:"div",display:false,className:"summary_box",id:"summary_box"},{tag:"div",display:false,id:"link_more",className:"link_more_box",childs:[{tag:"a",innerHTML:"more...",events:{onclick:"onMoreClick"}}]},{tag:"div",display:false,className:"content_box",id:"content_box"},{tag:"a",className:"webnote_btn_close",id:"btn_close",events:{onclick:"onBtnCloseClick"},display:false},{tag:"div",id:this.id,display:false},{tag:"div",id:"date_box",className:"date_box",display:false,innerHTML:"Posted on: ",childs:[{tag:"span",id:"date"}]},{tag:"div",id:"author_box",className:"author_box",display:false,innerHTML:"Posted by: ",childs:[{tag:"span",id:"author"}]}]);this.callFunction("initAdmin");this.callFunction("initContributor");},onOpen:function(){this.setTitle(this.profile["title"]);this.refresh();},refresh:function(){if(this.profile["text_id"]){core.data.texts.get(this.profile["text_id"],this.setContent.bind(this));}else{this.setContent(null);}},setContent:function(text){if(this.profile["text_id"]!=null){var data=text;}else if(core.usertype>=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.text_popup=function(args){this.defaultProfile={title:"",app_style:"",content_doc_id:null,page_content:"summary",popup_doc_id:null,popup_content:"content",popup_width:400,popup_height:300}} core.apps.text_popup.prototype={buildContent:function(el){this.$["content"].onclick=this.onContentClick.bindAsEventListener(this);},onOpen:function(){this.setTitle(this.profile["title"]);this.refresh();},onAppStyleChanged:function(){if(!this.popup)return;this.popup.setStyle(this.getAppStyleSelector());},refresh:function(){if(this.profile["content_doc_id"]){core.data.texts.get(this.profile["content_doc_id"],this.setContentDoc.bind(this));}else{this.setContentDoc(null);}},onContentClick:function(e){e=core.browser.event.fix(e);if(e&&e.target.tagName=="A"){return;} this.showPopup();},setContentDoc:function(doc){if(this.profile["content_doc_id"]==null){this.$["content"].innerHTML="";}else{this.$["content"].innerHTML=doc[this.profile["page_content"]];}},showPopup:function(){if(this.profile["popup_doc_id"]==null)return;if(!this.popup){this.popup=new core.objects.text_popup();} this.popup.setStyle(this.getAppStyleSelector());var scroll=core.browser.getScroll();var wsize=core.browser.getWindowSize();var pos={left:Math.round((wsize.width-this.profile["popup_width"])*0.5)-20,width:this.profile["popup_width"],height:this.profile["popup_height"]} this.popup.setPosition(pos);this.popup.show("Loading...");core.data.texts.get(this.profile["popup_doc_id"],this.setPopupDoc.bind(this));},setPopupDoc:function(doc){this.popup.setStyle(this.getAppStyleSelector());this.popup.show(doc[this.profile["popup_content"]]);},onClose:function(){if(!this.popup)return;this.popup.kill();this.popup=null;}} core.apps.text_popup.extendPrototype(core.components.html_component);core.apps.text_popup.extendPrototype(core.components.desktop_app); core.objects.text_popup=function(){var scroll=core.browser.getScroll();var wsize=core.browser.getWindowSize();this.position={width:400,height:300,top:scroll.top+100} this.position.left=Math.round((wsize.width-400)*0.5)-20;} core.objects.text_popup.prototype={show:function(html){if(!this.is_rendered){this.render();this.is_rendered=true;} this.showElement("popup_wrapper");this.updatePosition();this.$["content"].innerHTML=html||"";},render:function(){this.displayTpl(document.body,"text_popup");},setStyle:function(class_name){if(!this.is_rendered)return;this.$["popup_wrapper"].className=class_name;},setPosition:function(pos){for(var k in pos){this.position[k]=pos[k];} this.updatePosition();},updatePosition:function(){if(!this.is_rendered)return;var els=this.$["window"].style;els.left=this.position.left+"px";els.top=this.position.top+"px";els.width=this.position.width+"px";els.height=this.position.height+"px";},hide:function(){if(!this.is_rendered)return;this.hideElement("popup_wrapper");},kill:function(){if(!this.is_rendered)return;document.body.removeChild(this.$["popup_wrapper"]);},startResize:function(e){if(this.is_resizing)return;this.is_resizing=true;e=core.browser.event.fix(e);document.onmouseup=this.stopResize.bindAsEventListener(this);this._old_mouse_move=document.onmousemove;this._tmp_size={width:this.position.width,height:this.position.height} this._roffset={left:e.clientX,top:e.clientY} document.onmousemove=this.resize.bindAsEventListener(this);document.ondragstart=function(){return false} core.browser.event.kill(e);return false;},resize:function(e){e=core.browser.event.fix(e);var win=core.browser.getWindowSize();var ofs={width:Math.max(this._roffset.left-Math.min(win.width,e.clientX)),height:Math.max(this._roffset.top-Math.min(win.height,e.clientY))} this.position.width=Math.max(this._tmp_size.width-ofs.width,100),this.position.height=Math.max(this._tmp_size.height-ofs.height,50) this.updatePosition();},stopResize:function(e){this.is_resizing=false;document.onmouseup=null;document.onmousemove=this._old_mouse_move;},startMove:function(e){if(this.is_moving)return;this.is_moving=true;e=core.browser.event.fix(e);document.onmouseup=this.stopMove.bindAsEventListener(this);this._old_mouse_move=document.onmousemove;this._tmp_pos={left:this.position.left,top:this.position.top} this._roffset={left:e.clientX,top:e.clientY} document.onmousemove=this.move.bindAsEventListener(this);document.ondragstart=function(){return false} core.browser.event.kill(e);return false;},move:function(e){e=core.browser.event.fix(e);var win=core.browser.getWindowSize();var pos={left:Math.max(this._roffset.left-Math.min(win.width,e.clientX)),top:Math.max(this._roffset.top-Math.min(win.height,e.clientY))} this.position.left=Math.max(this._tmp_pos.left-pos.left,0),this.position.top=Math.max(this._tmp_pos.top-pos.top,0) this.updatePosition();},stopMove:function(e){this.is_moving=false;document.onmouseup=null;document.onmousemove=this._old_mouse_move;}} core.objects.text_popup.extendPrototype(core.components.html_component); core.templates['text_popup']={"tag":"div","childs":[{"tag":"div","childs":[{"tag":"div","className":"text_popup_content","id":"content"},{"tag":"div","className":"control_move","events":"onmousedown=startMove","innerHTML":"MOVE"},{"tag":"div","className":"control_close","events":"onclick=hide","innerHTML":"CLOSE"},{"tag":"div","className":"control_resize","events":"onmousedown=startResize","cssText":"display: none"},{"tag":"div","className":"border_l"},{"tag":"div","className":"border_r"},{"tag":"div","className":"border_t"},{"tag":"div","className":"border_tl"},{"tag":"div","className":"border_tr"},{"tag":"div","className":"border_b"},{"tag":"div","className":"border_bl"},{"tag":"div","className":"border_br"}],"className":"text_popup","id":"window"}],"id":"popup_wrapper"}; core.launcher.registerLoadedApps(["text_popup"]); core.data.theme_style_keys["text_popup"] = 'text_popup'; core.apps.image_gallery=function(args){this.defaultProfile={title:"",app_style:"",image_height:100,popup:false,cols:3,show_documents:false,spacing:1,items:[],items_per_page:9}} core.apps.image_gallery.prototype={onOpen:function(){this.setTitle(this.profile["title"]);this.$["window"].style.overflow="hidden";this.buildModel(this.$["content"],[{tag:"div",id:"pager_top"},{tag:"div",className:"image_gallery",id:"image_gallery",childs:[{tag:"table",id:'table',childs:[{tag:"tbody",id:"table_body"}]}]},{tag:"div",id:"pager_bottom"}]);this.refresh();},refresh:function(){this.offset=0;this.renderPage();if(this.profile.items.length>this.profile.items_per_page){this.showElements(["pager_top","pager_bottom"]);if(!this.pagers){var p={per_page:this.profile.items_per_page,parent:this.$["pager_top"],callback:this.setOffset.bind(this),class_name:"pager"} this.pagers={top:new core.objects.pager(p)};p.parent=this.$["pager_bottom"];this.pagers["bottom"]=new core.objects.pager(p);} this.pagers["top"].setData(this.offset,this.profile.items.length,this.profile.items_per_page);this.pagers["bottom"].setData(this.offset,this.profile.items.length,this.profile.items_per_page);}else{this.hideElements(["pager_top","pager_bottom"]);}},setOffset:function(ofs){this.offset=ofs;this.pagers["top"].setData(this.offset,this.profile.items.length,this.profile.items_per_page);this.pagers["bottom"].setData(this.offset,this.profile.items.length,this.profile.items_per_page);this.renderPage();},renderPage:function(){core.browser.element.removeChilds(this.$["table_body"]);var col_width=Math.floor(98/this.profile.cols)+"%",rows=Math.ceil(this.profile.items_per_page/this.profile.cols),m=[],mr,item_idx=0,img_src,is_empty_cell,page_item,cell_m;if(this.profile.show_documents){var document_items=[];for(var i in this.profile.items){if((typeof(this.profile.items[i].doc)!="undefined"&&this.profile.items[i].doc.id)||this.profile.items[i].html){document_items[document_items.length]=clone(this.profile.items[i]);}}} for(var r=0;r=this.profile.items_per_page)continue;cell_m=[];if(page_item.file&&!this.profile.show_documents){cell_m.push({tag:"img",className:"gallery_img",events:{onclick:["onImgClick",item_idx+this.offset],ondblclick:["onImgDblClick",item_idx+this.offset]},src:core.common.getUserFile(page_item.file),alt:page_item.alt,style:{width:"auto",height:this.profile.image_height+"px",cursor:((page_item.url&&page_item.url!="http://")?"pointer":"default")}});} if(page_item.code&&!this.profile.show_documents){cell_m.push({tag:"div",style:{width:"auto",height:page_item.file?"auto":this.profile.image_height+"px"},innerHTML:this.processCode(page_item.code)});} if((page_item.html&&!this.profile.show_documents)||(this.profile.show_documents&&typeof(page_item.doc)=="undefined")){cell_m.push({tag:"div",innerHTML:page_item.html});} if(typeof(page_item.doc)!='undefined'){if(page_item.doc.id&&this.profile.show_documents){cell_m.push({tag:"div",id:"document_container_"+page_item.doc.id,innerHTML:'Loading document...',className:'gallery_document_item'});}} mr.childs.push({tag:"td",style:{width:col_width},childs:[{tag:"div",did:'div',className:is_empty_cell?"cell_div empty":"cell_div",style:{margin:this.profile.spacing+"px"},childs:[{tag:"div",className:"img_box",childs:[{tag:"div",className:"t",innerHTML:"
"},{tag:"div",className:"m",childs:[{tag:"div",className:"mr",childs:[{tag:"div",className:"mc",childs:cell_m}]}]},{tag:"div",className:"b",innerHTML:"
"}]}]}]});item_idx++;} m.push(mr);} this.buildModel(this.$.table_body,m);for(var i in document_items){core.data.texts.get(document_items[i].doc.id,this.renderDocument.bind(this));}},renderDocument:function(text){$('document_container_'+text.id).innerHTML=text.content;},onImgClick:function(e,idx){clearTimeout(this.img_click_timeout);this.img_click_timeout=setTimeout(this.imgClick.bind(this,idx),core.config.dbl_click_delay);},imgClick:function(idx){if(this.profile.items[idx].url){desktop.loadURL(this.profile.items[idx].url);}else if(this.profile.popup&&this.profile.items[idx].file){var images=[],active_image_idx=0;for(var i=0;i=USERTYPE_ADMIN){this.openImagesManager(false,idx);}},processCode:function(code){var code=code.replace(/width\s*=\s*"\d*"/ig,'width="100%"');code=code.replace(/height\s*=\s*"\d*"/ig,'height="'+this.profile["image_height"]+'"');code=code.replace(/width\s*:\s*\d*px\s*;/ig,'width: 100%;');code=code.replace(/height\s*:\s*\d*px\s*/ig,'height: '+this.profile["image_height"]+'px;');code=code.replace(/height\s*=\s*'\d*'/ig,"height='"+this.profile["image_height"]+"'");code=code.replace(/width\s*=\s*'\d*'/ig,"width='100%'");if(code.search(/-1){if(code.search(/wmode/)<0){code=code.replace(/=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