/* Copyright 2006 por Connecty Networks. Todos os direitos reservados */
function Desktop() { this.init(); this.cfg = { hasSizeBtn: false, hasCloseBtn: false, hasRefreshBtn: false, hasSettingsBtn: false, hasDrag: false, hasOnCloseConfirm: false, isSystem: true, title: "Origo desktop", module: "desktop"
}
this.panelsCount = 3; this.defaultProfile["panels"] = []; this.domModel = [ { tag: "table", className: "sys_table", width: "100%", id: "tray", childs: [ { tag: "tr", childs: [ { tag: "td", align: "right", style: {verticalAlign: "top", padding: "5px"}, childs: [ createButtonDom("Mostrar tudo", "showAll()", "img/ws/show_all.gif"), { tag: "span", innerHTML: "&nbsp;&nbsp;|&nbsp;&nbsp;" }, createButtonDom("Esconder tudo", "hideAll()", "img/ws/hide_all.gif"), { tag: "span", innerHTML: "&nbsp;&nbsp;|&nbsp;&nbsp;" }, createButtonDom("Personaliza&ccedil;&atilde;o do meu Origo", "showPage(\"settings\")", theme.icons.settings), { tag: "span", innerHTML: "&nbsp;&nbsp;|&nbsp;&nbsp;" }, { tag: "span", id: "authButton" } ]} ]} ]}, { tag: "table", width: "100%", className: "top_search_tbl", border: 0, childs: [ { tag: "tr", childs: [ { tag: "td", className: "top_search_td", width: 245, valign: "top", innerHTML: "<img src='img/ws/1x1.gif' width=1 height=40>" }, { tag: "td", className: "top_search_td", width: 280, valign: "top", childs: [ {tag: "img", id: "server_logo", className: "top_search_input_logo", style: {marginTop: ie_nav ? "13px" : "15px"}}, { tag: "input", type: "text", id: "search_text", className: "top_search_input", style: {marginTop: ie_nav ? "13px" : "15px"} } ]}, { tag: "td", className: "top_search_bg", valign: "top", childs: [ { tag: "a", href:"", childs: [ { tag: "img", src: "img/ws/sss.gif", border: "0", style: {position: "relative", top: "10px", cursor: "pointer"}, events: {onclick: "goTopSearch()"}} ]} ]} ]}, { tag: "tr", childs: [ { tag: "td" }, { tag: "td", className: "servers_tabs", id: "servers_tabs" }, { tag: "td", align: "right", style: {paddingRight: "20px", paddingTop: (ie_nav?"12px":"16px"), verticalAlign: "top"}, childs: [ { tag: "span", id: "title_menu_btn", childs: [ createButtonDom("Menu T&iacute;tulo", "switchTitleMenu()", "img/ws/down.gif", "title_menu_icon") ]}, { tag: "span", innerHTML: "&nbsp;&nbsp;&nbsp;&nbsp;" }, createButtonDom("Mais Widgets", "switchMenu()", "widgets/menu/ico.gif", "widgets_menu_btn") ]} ]} ]}, { tag: "table", className: "sys_table", width: "100%", id: "tray1", border: "0", style: {display: "none", marginTop: "15px"}, childs: [ { tag: "tr", childs: [ { tag: "td", width: "70px", align: "center", childs: [createButtonDom2("E-Mail", "openTitleMenuWidget('PopMail')", "img/ws/mail.gif")] }, { tag: "td", width: "70px", align: "center", childs: [createButtonDom2("Favoritos", "openTitleMenuWidget('Bookmarks')", "img/ws/favorites.gif")] }, { tag: "td", width: "70px", align: "center", childs: [createButtonDom2("Jogos", "openTitleMenuWidget('Flash')", "img/ws/jogos.gif")] }, { tag: "td", align: "center", childs: [ { tag: "div", id: "main_title", style: {marginTop: "10px"} } ]}, { tag: "td", width: "70px", align: "center", childs: [createButtonDom2("Post-It", "openTitleMenuWidget('Webnote')", "img/ws/postit.gif")] }, { tag: "td", width: "70px", align: "center", childs: [createButtonDom2("Messenger", "openTitleMenuWidget('Messenger')", "img/ws/messenger.gif")] }, { tag: "td", width: "70px", align: "center", childs: [createButtonDom2("Tarefas", "openTitleMenuWidget('ToDoList')", "img/ws/fazer.gif")] }, { tag: "td", width: "10px", style: {verticalAlign: "bottom"}, childs: [ createButtonDom("", "switchTitleMenu()", "img/ws/up.gif"), ]} ]} ]}, { tag: "table", className: "sys_table", width: "100%", style: {marginTop: "15px"}, childs: [ { tag: "tr", childs: [ { tag: "td", id: "pager", width: "100%", className: "desktop_column", align: "center", style: {padding: "0px"}} ]} ]}
]
this.domModelPanels = [ { tag: "table", width: "100%", style: {margin: "0px", padding: "0px"}, childs: { tag: "tr", childs: [ {tag: "td", id: "panel0", width: "33%", className: "desktop_column", style: {paddingBottom: "50px"}}, {tag: "td", id: "panel1", width: "33%", className: "desktop_column", style: {paddingBottom: "50px"}}, {tag: "td", id: "panel2", width: "33%", className: "desktop_column", style: {paddingBottom: "50px"}} ]}
}, { tag: "div", id: "area", className: "area", name: "area", display: false}
]
this.getSignature = function() { return SYSWIDGET_WKEY+1;}
this.isMenuShow = false; this.switchMenu = function() { if(this.isMenuShow) { menu.hide();} else { menu.show();}
}
this.isTitleMenuShow = false; this.switchTitleMenu = function() { if(this.isTitleMenuShow) { this.elements.tray1.style.display = 'none'; this.elements.title_menu_btn.style.display = 'inline'; this.isTitleMenuShow = false;} else { this.elements.tray1.style.display = ie_nav ? 'block' : 'table'; this.elements.title_menu_btn.style.display = 'none'; this.isTitleMenuShow = true;}
menu.hide(); this.isMenuShow = false;}
this.openTitleMenuWidget = function(wname) { kernel.runWidget(wname, desktop.getTinyPanel(), false, false);}
this.goTopSearch =function() { var str = trim(this.elements.search_text.value); if(str != "") { var url = websearch_servers[this.activeTab].url+escape(str); window.open(url);}
}
this.activeTab = 0; this.getSearchServerIcon = function(serverId) { return (websearch_servers[serverId].logo != "") ? "var/img/"+websearch_servers[serverId].logo : "img/ws/1x1.gif";}
this.showServerTab = function(serverId) { if(this.activeTab) { this.elements["tab_"+this.activeTab].style.backgroundImage = "url(img/ws/tabi.gif)";}
this.elements["tab_"+serverId].style.backgroundImage = "url(img/ws/taba.gif)"; this.activeTab = serverId; this.elements.server_logo.src = this.getSearchServerIcon(serverId);}
this.setServer = function(serverId) { this.showServerTab(serverId); this.elements.search_text.focus();}
this.pages = {}; this.activePage = null; this.getPageId = function(name) { return "page"+name;}
this.addPage = function(name, title) { this.buildDomModel(this.elements.pager, {tag: "div", id: this.getPageId(name), display: false, style: {width: "100%", height: "100%"}}); return this.elements[this.getPageId(name)];}
this.showPage = function(name) { if(name != "panels") { hideEl(this.elements[this.getPageId("panels")]);}
if(name == this.activePage) return; if(this.activePage) { hideEl(this.elements[this.getPageId(this.activePage)]);}
showEl(this.elements[this.getPageId(name)]); this.activePage = name;}
this.closeCurrentPage = function() { if(this.activePage) { hideEl(this.elements[this.getPageId(this.activePage)]); this.activePage = null;}
showEl(this.elements[this.getPageId("panels")]);}
this.buildWindow = function(parent) { this.buildDomModel(parent, this.domModel); for(i=0; i<websearch_servers.length; i++) { this.buildDomModel(this.elements.servers_tabs, { tag: "div", className: "search_tab", style: { backgroundImage: "url(img/ws/tabi.gif)" }, id: "tab_"+i, events: {onclick: "setServer('"+i+"')"}, childs: [ { tag: "img", src: this.getSearchServerIcon(i), className: "search_tab_icon" } ]});}
}
this.buildInterface = function() { var panels = this.addPage('panels', "Panels"); this.buildDomModel(panels, this.domModelPanels); this.showPage('panels'); var firstServerId = null; for(var i in websearch_servers) { firstServerId = i; break;}
if(firstServerId) { this.showServerTab(firstServerId);}
}
this.getPanel = function(n) { return this.elements["panel"+n];}
this.getTinyPanel = function() { var p = 0; var minh = 100000; for(i=this.panelsCount-1; i>=0; i--) { var h = 0; panel = this.getPanel(i); for(j=0; j<panel.childNodes.length; j++) { h += panel.childNodes[j].offsetHeight;}
if(h <= minh) { minh = h; p = i;}
}
return this.getPanel(p);}
this.getBelongPanel = function(pos) { for(i=0; i<this.panelsCount; i++) { if(isPosInObj(pos, this.getPanel(i))) { return this.getPanel(i);}
}
return null;}
this.getWindowAtPos = function(panel, pos) { for(i=0; i<panel.childNodes.length; i++) { if(isPosInObj(pos, panel.childNodes[i])) { return panel.childNodes[i];}
}
return null;}
this.startArea = function(el) { with(this.elements) { area.style.position = 'static'; el.parentNode.insertBefore(area, el); area.style.height = el.offsetHeight + "px"; area.style.display = 'block';}
}
this.stopArea = function() { with(this.elements) { area.style.height = 0; area.style.display = 'none'; area.parentNode.removeChild(area);}
}
this.processArea = function(pos) { p = this.getBelongPanel(pos); if(p) { if(p.hasChildNodes()) { w = this.getWindowAtPos(p, pos); if(w) { if(w.name != 'area') { w = this.getWindowAtPos(p, pos); p.insertBefore(this.elements.area, w);}
} else { this.elements.area.parentNode.removeChild(this.elements.area); p.appendChild(this.elements.area);}
} else { this.elements.area.parentNode.removeChild(this.elements.area); p.appendChild(this.elements.area);}
}
}
this.putWindow = function(pos) { panel = this.getBelongPanel(mpos); if(panel) { drag.el.parentNode.removeChild(drag.el); panel.insertBefore(drag.el, this.elements.area);}
}
this.showAll = function() { for(i in kernel.widgets) { if(kernel.widgets[i] &&
!kernel.widgets[i].cfg.isSystem &&
kernel.widgets[i].cfg.hasSizeBtn) { kernel.widgets[i].show();}
}
}
this.hideAll = function() { for(i in kernel.widgets) { if(kernel.widgets[i] &&
!kernel.widgets[i].cfg.isSystem &&
kernel.widgets[i].cfg.hasSizeBtn) { kernel.widgets[i].hide();}
}
}
this.wakeUp = function() { for(i in this.profile.windows) { kernel.runWidget(this.profile.windows[i].module, this.getPanel(this.profile.windows[i].panel), this.profile.windows[i].id);}
}
this.savePanels = function() { this.profile.windows = []; var n = 0; for(var p=0; p<this.panelsCount; p++) { for(i=0; i<this.getPanel(p).childNodes.length; i++) { var wid = this.getPanel(p).childNodes[i].wid; if(wid) { this.profile.windows.push({module: kernel.getWidget(wid).cfg.module, id:wid, panel: p});}
}
}
this.save();}
}
Desktop.prototype = new Widget();