// Functions prototype // ------------------- function vElement() { // Initialize functions // -------------------- this.add = _vElement_add; this.fixFill = _vElement_fixFill; this.fixNormal = _vElement_fixNormal; this.hide = _vElement_hide; this.show = _vElement_show; this.setWidth = _vElement_setWidth; this.setHeight = _vElement_setHeight; this.remove = _vElement_remove; this.getWindow = getWindow; // Event functions this.addEvent = _vElement_addEvent; this.removeEvent = _vElement_removeEvent; this.processEvent = _vElement_processEvent; // Functions to call to from applications (on events) this.resize = resize; this.temp = new Array(); // Functions // --------- function _vElement_add() { // Get to the real window var that = this.window_content ? this.window_content : this; var windows = vOS.vElement.getWindow(that); switch(arguments[0]) { case "label": windows.elements[arguments[1]] = label(that,arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7]); break; case "progressbar": windows.elements[arguments[1]] = progressbar(that,arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7]); break; case "group": windows.elements[arguments[1]] = group(that,arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7]); break; case "image": windows.elements[arguments[1]] = image(that,arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7]); break; case "infobox": windows.elements[arguments[1]] = infobox(that,arguments[2],arguments[3]); break; case "panel": windows.elements[arguments[1]] = panel(that,arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]); break; case "line": windows.elements[arguments[1]] = line(that,arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7]); break; case "splitX": windows.elements[arguments[1]] = splitX(that,arguments[2]); break; case "splitY": windows.elements[arguments[1]] = splitY(that,arguments[2]); break; case "timer": windows.elements[arguments[1]] = timer(that,arguments[1],arguments[2],arguments[3]); break; case "textarea": windows.elements[arguments[1]] = textarea(that,arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7]); break; case "textbox": windows.elements[arguments[1]] = textbox(that,arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7]); break; case "hyperlink": windows.elements[arguments[1]] = hyperlink(that,arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7]); break; case "toolbar": windows.elements[arguments[1]] = toolbar(that,arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]); break; case "button": windows.elements[arguments[1]] = button(that,arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7]); break; case "splitterY": windows.elements[arguments[1]] = splitterY(that,arguments[2],arguments[3],arguments[4]); break; case "splitterX": windows.elements[arguments[1]] = splitterX(that,arguments[2],arguments[3],arguments[4]); break; case "radioGroup": windows.elements[arguments[1]] = radioGroup(that); break; case "radio": windows.elements[arguments[1]] = radio(that,arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]); break; case "checkbox": windows.elements[arguments[1]] = checkbox(that,arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]); break; case "tab": windows.elements[arguments[1]] = tab(that,arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]); break; case "selectbox": windows.elements[arguments[1]] = selectbox(that,arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7]); break; case "listview": windows.elements[arguments[1]] = listview(that,arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7]); break; case "combobox": windows.elements[arguments[1]] = combobox(that,arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7]); break; default: alert("Element "+ arguments[0] +" does not exist!"); break; } // Add global things windows.elements[arguments[1]].vElement_name = arguments[1]; // The functions function label(that,value,fill,top,left,width,height) { var label = document.createElement("DIV"); that.childrens.push(label); label.innerHTML = value; label.className = "vElement_label"; label.remove = vOS.vElement.remove; that.appendChild(label); label.setWidth = vOS.vElement.setWidth; label.setHeight = vOS.vElement.setHeight; if(fill) { label.fix = vOS.vElement.fixFill; label.fix(); } else { label.style.top = top + "px"; label.style.left = left + "px"; label.setWidth(width); label.setHeight(height); } return label; } function progressbar(that,max,fill,top,left,width,height) { var prog = document.createElement("DIV"); that.childrens.push(prog); prog.current = 0; prog.maxProg = max; prog.className = "vElement_progress"; prog.remove = vOS.vElement.remove; that.appendChild(prog); var bar = document.createElement("DIV"); bar.className = "vElement_progressbar"; prog.bar = bar; prog.appendChild(bar); bar.style.width = "0%"; prog.plus = function(add) { this.current += add; this.calculate(); } prog.min = function(add) { this.current -= add; this.calculate(); } prog.set = function(add) { this.current = add; this.calculate(); } prog.calculate = function() { var percentage = (this.current / this.maxProg) * 100; if(percentage > 100) percentage = 100; else if(percentage < 0) percentage = 0; this.bar.style.width = percentage + "%"; } prog.setWidth = vOS.vElement.setWidth; prog.setHeight = vOS.vElement.setHeight; if(fill) { prog.fix = vOS.vElement.fixFill; prog.fix(); } else { prog.style.top = top + "px"; prog.style.left = left + "px"; prog.setWidth(width); prog.setHeight(height); } return prog; } function group(that,value,fill,top,left,width,height) { var group = document.createElement("FIELDSET"); that.childrens.push(group); group.add = vOS.vElement.add; group.childrens = new Array(); var legend = document.createElement("LEGEND"); legend.innerHTML = value; group.className = "vElement_group"; group.remove = vOS.vElement.remove; that.appendChild(group); group.appendChild(legend); group.setWidth = vOS.vElement.setWidth; group.setHeight = vOS.vElement.setHeight; if(fill) { group.fix = vOS.vElement.fixFill; group.fix(); } else { group.style.top = top + "px"; group.style.left = left + "px"; group.setWidth(width); group.setHeight(height); } return group; } function image(that,src,fill,top,left,width,height) { var image = document.createElement("IMG"); that.childrens.push(image); image.src = src; image.className = "vElement_image"; image.remove = vOS.vElement.remove; that.appendChild(image); image.addEvent = vOS.vElement.addEvent; image.removeEvent = vOS.vElement.removeEvent; image.setWidth = vOS.vElement.setWidth; image.setHeight = vOS.vElement.setHeight; if(fill) { image.fix = vOS.vElement.fixFill; image.fix(); } else { image.style.top = top + "px"; image.style.left = left + "px"; image.setWidth(width); image.setHeight(height); } return image; } function panel(that,fill,top,left,width,height) { var panel = document.createElement("DIV"); panel.add = vOS.vElement.add; panel.childrens = new Array(); that.childrens.push(panel); panel.className = "vElement_panel"; panel.remove = vOS.vElement.remove; that.appendChild(panel); panel.setWidth = vOS.vElement.setWidth; panel.setHeight = vOS.vElement.setHeight; if(fill) { panel.fix = vOS.vElement.fixFill; panel.fix(); } else { panel.style.top = top + "px"; panel.style.left = left + "px"; panel.setWidth(width); panel.setHeight(height); } panel.hide = function() { this.style.display = "none"; } panel.show = function() { this.style.display = "block"; } return panel; } function line(that,color,fill,top,left,width,height) { var line = document.createElement("DIV"); that.childrens.push(line); line.style.backgroundColor = color; line.className = "vElement_line"; line.remove = vOS.vElement.remove; that.appendChild(line); line.setWidth = vOS.vElement.setWidth; line.setHeight = vOS.vElement.setHeight; if(fill) { line.fix = vOS.vElement.fixFill; line.fix(); } else { line.style.top = top + "px"; line.style.left = left + "px"; line.setWidth(width); line.setHeight(height); } return line; } function infobox(that,title) { // Add a container var infobox = document.createElement("DIV"); that.childrens.push(infobox); infobox.className = "vElement_infobox"; infobox.remove = vOS.vElement.remove; that.appendChild(infobox); // Add the title var infoboxTitle = document.createElement("DIV"); infobox.appendChild(infoboxTitle); infobox.xTitle = infoboxTitle; infoboxTitle.isHidden = 0; infoboxTitle.innerHTML = title; infoboxTitle.className = "vElement_infoboxTitle"; infoboxTitle.onmouseover = function() { infoboxTitle.className = "vElement_infoboxTitle_over"; } infoboxTitle.onmouseout = function() { infoboxTitle.className = "vElement_infoboxTitle"; } infoboxTitle.onmousedown = function() { this.parentNode.xContainer.style.display = this.isHidden ? "block" : "none"; this.isHidden = this.isHidden ? 0 : 1; } // Create infocontainer var infocontainer = document.createElement("DIV"); infobox.xContainer = infocontainer; infocontainer.className = "vElement_infoboxContainer"; infocontainer.childrens = new Array(); infobox.appendChild(infocontainer); infobox.add = function() { switch(arguments[0]) { case "button": var item = document.createElement("DIV"); this.xContainer.childrens.push(item); item.className = "button"; item.remove = vOS.vElement.remove; item.style.background = "url("+arguments[2]+") no-repeat left"; item.innerHTML = arguments[3]; // Events windows.elements[arguments[1]] = item; windows.elements[arguments[1]].vElement_name = arguments[1]; item.addEvent = vOS.vElement.addEvent; item.removeEvent = vOS.vElement.removeEvent; this.xContainer.appendChild(item); break; case "text": var item = document.createElement("DIV"); this.xContainer.childrens.push(item); item.className = "text"; item.remove = vOS.vElement.remove; item.innerHTML = arguments[1]; this.xContainer.appendChild(item); break; case "title": var item = document.createElement("DIV"); this.xContainer.childrens.push(item); item.className = "title"; item.remove = vOS.vElement.remove; item.innerHTML = arguments[1]; this.xContainer.appendChild(item); break; case "subtitle": var item = document.createElement("DIV"); this.xContainer.childrens.push(item); item.className = "subtitle"; item.remove = vOS.vElement.remove; item.innerHTML = arguments[1]; this.xContainer.appendChild(item); break; } } infobox.clear = function() { while(this.xContainer.childrens.length != 0) { this.xContainer.childrens[0].remove(); } } return infobox; } function splitY(that,arrHeight) { that.split = "y"; // Keep in mind how much undefined heights there are var undefHeight = 0; var totalHeight = 0; for(var x = 0; x < arrHeight.length; x++) { if(arrHeight[x][0] == 0) { undefHeight++; } else { totalHeight += arrHeight[x][1]; } } // Calculate the height for the undefined ones var calHeight = (that.clientHeight - totalHeight) / undefHeight; // Now add the vOS.vElement var totalHeight = 0; var tempElements = new Array(); for(var x = 0; x < arrHeight.length; x++) { var split = document.createElement("DIV"); that.childrens.push(split); split.add = vOS.vElement.add; split.remove = vOS.vElement.remove; split.id = "_vElement_splitX"; split.className = "vElement_splitX"; split.Static = arrHeight[x][0]; split.minHeight = arrHeight[x][1]; split.childrens = new Array(); split.style.top = totalHeight + "px"; split.style.width = that.clientWidth + "px"; // If is undefined use the calculated height var height = arrHeight[x][0] ? arrHeight[x][1] : calHeight; split.style.height = (height > 0 ? height : 0) + "px"; split.setHeight = function(stat, height) { height = height > 0 ? height : 0; if(height == this.clientHeight) return; this.Static = stat; this.minHeight = height; // Check if it hasn't had a collission: var temp = 0; var stop = 0; while((temp2 = vOS.vElement.getWindow(this).resize("y")) != 0 && stop != 10) { stop++; height = height + temp2[0]; this.minHeight = height; temp += temp2[0]; } return temp; } that.appendChild(split); // Add it to the temp tempElements.push(split); // Add height to totalHeight totalHeight += height; } return tempElements; } function splitX(that,arrWidth) { that.split = "x"; // Keep in mind how much undefined heights there are var undefWidth = 0; var totalWidth = 0; for(var x = 0; x < arrWidth.length; x++) { if(arrWidth[x][0] == 0) { undefWidth++; } else { totalWidth += arrWidth[x][1]; } } // Calculate the Width for the undefined ones var calWidth = (that.clientWidth - totalWidth) / undefWidth; // Now add the elements var totalWidth = 0; var tempElements = new Array(); for(var x = 0; x < arrWidth.length; x++) { var split = document.createElement("DIV"); that.childrens.push(split); split.add = vOS.vElement.add; split.remove = vOS.vElement.remove; split.id = "_vElement_splitY"; split.className = "vElement_splitY"; split.Static = arrWidth[x][0]; split.minWidth = arrWidth[x][1]; split.childrens = new Array(); split.style.left = totalWidth + "px"; split.style.height = that.clientHeight + "px"; // If is undefined use the calculated Width var width = arrWidth[x][0] ? arrWidth[x][1] : calWidth; split.style.width = (width > 0 ? width : 0) + "px"; split.hide = vOS.vElement.hide; split.show = vOS.vElement.show; split.setWidth = function(stat, width) { width = width > 0 ? width : 0; if(width == this.clientWidth) return; this.Static = stat; this.minWidth = width; // Check for collisions: var temp = 0; var stop = 0; while((temp2 = vOS.vElement.getWindow(this).resize("x")) != 0 && stop != 10) { stop++; width = width + temp2[1] this.minWidth = width; temp += temp2[1]; } return temp; } that.appendChild(split); // Add it to the temp tempElements.push(split); // Add Width to totalWidth totalWidth += width; } return tempElements; } function textarea(that,value,fill,top,left,width,height) { var textarea = document.createElement("TEXTAREA"); that.childrens.push(textarea); textarea.value = value; textarea.className = "vElement_textarea"; textarea.remove = vOS.vElement.remove; that.appendChild(textarea); textarea.addEvent = vOS.vElement.addEvent; textarea.removeEvent = vOS.vElement.removeEvent; textarea.setWidth = vOS.vElement.setWidth; textarea.setHeight = vOS.vElement.setHeight; if(fill) { textarea.fix = vOS.vElement.fixFill; textarea.fix(); } else { textarea.style.top = top + "px"; textarea.style.left = left + "px"; textarea.setWidth(width); textarea.setHeight(height); } return textarea; } function textbox(that,value,fill,top,left,width,height) { var textbox = document.createElement("INPUT"); textbox.type = "text"; that.childrens.push(textbox); textbox.value = value; textbox.className = "vElement_textarea"; textbox.remove = vOS.vElement.remove; that.appendChild(textbox); textbox.addEvent = vOS.vElement.addEvent; textbox.removeEvent = vOS.vElement.removeEvent; textbox.setWidth = vOS.vElement.setWidth; textbox.setHeight = vOS.vElement.setHeight; if(fill) { textbox.fix = vOS.vElement.fixFill; textbox.fix(); } else { textbox.style.top = top + "px"; textbox.style.left = left + "px"; textbox.setWidth(width); textbox.setHeight(height); } return textbox; } function hyperlink(that,value,fill,top,left,width,height) { var hyper = document.createElement("DIV"); hyper.type = "text"; that.childrens.push(hyper); hyper.innerHTML = value; hyper.className = "vElement_hyperlink"; hyper.remove = vOS.vElement.remove; that.appendChild(hyper); hyper.addEvent = vOS.vElement.addEvent; hyper.removeEvent = vOS.vElement.removeEvent; hyper.setWidth = vOS.vElement.setWidth; hyper.setHeight = vOS.vElement.setHeight; if(fill) { hyper.fix = vOS.vElement.fixFill; hyper.fix(); } else { hyper.style.top = top + "px"; hyper.style.left = left + "px"; hyper.setWidth(width); hyper.setHeight(height); } return hyper; } function button(that,value,fill,top,left,width,height) { var button = document.createElement("DIV"); button.className = "vElement_button"; button.onmouseout = function(){ if(!vOS.iWindow.action) this.className = "vElement_button"; } button.onmouseover = function(){ if(!vOS.iWindow.action) this.className = "vElement_buttonHover"; } button.onmousedown = function(){ if(!vOS.iWindow.action) this.className = "vElement_buttonDown"; } button.onmouseup = function(){ if(!vOS.iWindow.action) this.className = "vElement_buttonHover"; } that.childrens.push(button); button.innerHTML = value; button.className = "vElement_button"; button.remove = vOS.vElement.remove; that.appendChild(button); button.addEvent = vOS.vElement.addEvent; button.removeEvent = vOS.vElement.removeEvent; button.setWidth = vOS.vElement.setWidth; button.setHeight = vOS.vElement.setHeight; button.middle = 1; if(fill) { button.fix = vOS.vElement.fixFill; button.fix(); } else { button.style.top = top + "px"; button.style.left = left + "px"; button.setWidth(width); button.setHeight(height); } return button; } function toolbar(that,imageWidth,fill,top,left,width,height) { var toolbar = document.createElement("DIV"); toolbar.imageWidth = imageWidth; toolbar.childrens = new Array(); toolbar.className = "vElement_toolbar"; that.childrens.push(toolbar); that.appendChild(toolbar); toolbar.setWidth = vOS.vElement.setWidth; toolbar.setHeight = vOS.vElement.setHeight; // Add a fixfill function if(fill) { toolbar.fixit = vOS.vElement.fixFill; toolbar.fixit(); toolbar.fix = function(){ toolbar.fixit(); var y = 0; for(x = 0; x < this.childrens.length; x++) { if(this.childrens[x].offsetTop > 5) { y = 1; } } if(y) { this.hiddenButton.style.display = "block"; vOS.vElement.fixNormal(this.hiddenButton); } else { this.hiddenButton.style.display = "none"; } }; } else { toolbar.style.top = top + "px"; toolbar.style.left = left + "px"; toolbar.setWidth(width); toolbar.setHeight(height); vOS.vElement.fixNormal(toolbar); } // Add a button for hidden things var hiddenButton = document.createElement("DIV"); hiddenButton.className = "vElement_toolbarHiddenButton"; hiddenButton.innerHTML = "   "; hiddenButton.style.height = toolbar.clientHeight+"px"; hiddenButton.style.display = "none"; hiddenButton.oHeight = toolbar.clientHeight; hiddenButton.onmousedown = function(e) { var e = !window.event ? e : window.event; var mousebutton = e.which ? e.which : e.button; if (mousebutton == 1) { var popupMenu = new Array(); var topmenu = this.parentNode; var windows = vOS.vElement.getWindow(this); for(x = 0; x < topmenu.childrens.length; x++) { if(topmenu.childrens[x].offsetTop > 5) { if(topmenu.childrens[x].tValue) popupMenu.push(new Array(topmenu.childrens[x].tValue,topmenu.childrens[x].tImage,"vOS.arr_vApps['"+windows.vApp_pid+"'].onEvent('"+windows.vWindow_name+"', '"+topmenu.childrens[x].vElement_name+"', '"+e.type.toLowerCase()+"', '')")); else popupMenu.push(new Array("-")); } } vOS.vMenu.system(e.clientY, e.clientX, popupMenu); vOS.vMenu.menu_click = true; } } toolbar.appendChild(hiddenButton); toolbar.hiddenButton = hiddenButton; // Here is the add function toolbar.add = function() { switch(arguments[0]) { case "button": // 2 => value 3 => image var button = document.createElement("DIV"); button.className = "vElement_toolbarButton"; button.onmouseout = function(){ if(!vOS.iWindow.action) this.className = "vElement_toolbarButton"; } button.onmouseover = function(){ if(!vOS.iWindow.action) this.className = "vElement_toolbarButtonHover"; } button.onmousedown = function(){ if(!vOS.iWindow.action) this.className = "vElement_toolbarButtonDown"; } button.onmouseup = function(){ if(!vOS.iWindow.action) this.className = "vElement_toolbarButtonHover"; } if(arguments[2] && arguments[4]) { button.innerHTML = arguments[2]; button.style.paddingRight = "4px"; } button.remove = vOS.vElement.remove; button.style.height = this.clientHeight-2+"px"; button.title = arguments[2]; if(arguments[3]) { button.style.paddingLeft = (this.imageWidth + 8) + "px"; button.style.backgroundImage = "url("+arguments[3]+")"; } this.appendChild(button); // Save the arguments: button.tValue = arguments[2]; button.tImage = arguments[3]; // Fix height: button.style.height = button.clientHeight - (button.offsetHeight - button.clientHeight) + "px"; button.style.lineHeight = button.clientHeight +"px"; // Events windows.elements[arguments[1]] = button; windows.elements[arguments[1]].vElement_name = arguments[1]; button.addEvent = vOS.vElement.addEvent; button.removeEvent = vOS.vElement.removeEvent; this.childrens.push(button); break; case "separator": var sep = document.createElement("DIV"); this.appendChild(sep); sep.className = "vElement_toolbarSeparator"; sep.removeEvent = vOS.vElement.removeEvent; sep.style.height = (this.clientHeight - 4) + "px"; this.childrens.push(sep); break; } } toolbar.remove = vOS.vElement.remove; return toolbar; } function splitterY(that,element,direction,minWidth) { // Direction: 0 = direction is left, give less width, 1 = direction is left, give more width var splitter = document.createElement("DIV"); that.childrens.push(splitter); splitter.className="vElement_splitterY"; splitter.remove = vOS.vElement.remove; splitter.element = element; splitter.direction = direction; that.appendChild(splitter); splitter.fix = vOS.vElement.fixFill; splitter.fix(); splitter.onmousedown = function(e) { e = !e ? window.event : e; // Use element temp vOS.vElement.temp = new Array(); vOS.vElement.temp["x"] = e.clientX; vOS.vElement.temp["element"] = this.element; vOS.vElement.temp["direction"] = this.direction; vOS.vElement.temp["minWidth"] = minWidth; vOS.vElement.temp["stop"] = 0; document.onmousemove = function(e) { e = !e ? window.event : e; var width = vOS.vElement.temp["direction"] ? vOS.vElement.temp["element"].clientWidth + (vOS.vElement.temp["x"] - e.clientX) : vOS.vElement.temp["element"].clientWidth - (vOS.vElement.temp["x"] - e.clientX); if(width >= vOS.vElement.temp["minWidth"]) { if(vOS.vElement.temp["stop"] == 1 && vOS.vElement.temp["element"].clientWidth < width) return 0; if(!(temp = vOS.vElement.temp["element"].setWidth(vOS.vElement.temp["element"].Static,width))) { vOS.vElement.temp["x"] = e.clientX; vOS.vElement.temp["stop"] = 0; } else if(!vOS.vElement.temp["stop"]) { vOS.vElement.temp["x"] = vOS.vElement.temp["direction"] ? e.clientX - temp : e.clientX + temp; vOS.vElement.temp["stop"] = 1; } } else { vOS.vElement.temp["x"] = vOS.vElement.temp["direction"] ? e.clientX + (width - vOS.vElement.temp["minWidth"]) : e.clientX - (width - vOS.vElement.temp["minWidth"]); vOS.vElement.temp["element"].setWidth(vOS.vElement.temp["element"].Static,vOS.vElement.temp["minWidth"]); } } document.onmouseup = function(e) { document.onmousemove = null; } } return splitter; } function splitterX(that,element,direction,minHeight) { // Direction: 1 = direction is up, give more height, 0 = direction is up, give less height var splitter = document.createElement("DIV"); that.childrens.push(splitter); splitter.className="vElement_splitterX"; splitter.remove = vOS.vElement.remove; splitter.element = element; splitter.direction = direction; that.appendChild(splitter); splitter.fix = vOS.vElement.fixFill; splitter.fix(); splitter.onmousedown = function(e) { e = !e ? window.event : e; // Use element temp vOS.vElement.temp = new Array(); vOS.vElement.temp["y"] = e.clientY; vOS.vElement.temp["element"] = this.element; vOS.vElement.temp["direction"] = this.direction; vOS.vElement.temp["minHeight"] = minHeight; vOS.vElement.temp["stop"] = 0; document.onmousemove = function(e) { e = !e ? window.event : e; var height = vOS.vElement.temp["direction"] ? vOS.vElement.temp["element"].clientHeight + (vOS.vElement.temp["y"] - e.clientY) : vOS.vElement.temp["element"].clientHeight - (vOS.vElement.temp["y"] - e.clientY); if(height >= vOS.vElement.temp["minHeight"]) { if(vOS.vElement.temp["stop"] == 1 && vOS.vElement.temp["element"].clientHeight < height) return 0; if(!(temp = vOS.vElement.temp["element"].setHeight(vOS.vElement.temp["element"].Static,height))) { vOS.vElement.temp["y"] = e.clientY; vOS.vElement.temp["stop"] = 0; } else if(!vOS.vElement.temp["stop"]) { vOS.vElement.temp["y"] = vOS.vElement.temp["direction"] ? e.clientY - temp : e.clientY + temp; vOS.vElement.temp["stop"] = 1; } } else { vOS.vElement.temp["y"] = vOS.vElement.temp["direction"] ? e.clientY + (height - vOS.vElement.temp["minHeight"]) : e.clientY - (height - vOS.vElement.temp["minHeight"]); vOS.vElement.temp["element"].setHeight(vOS.vElement.temp["element"].Static,vOS.vElement.temp["minHeight"]); } } document.onmouseup = function(e) { document.onmousemove = null; } } return splitter; } function radioGroup(that) { var group = document.createElement("DIV"); group.add = vOS.vElement.add; group.remove = vOS.vElement.remove; group.childrens = new Array(); group.className = "vElement_radioGroup"; that.childrens.push(group); // Add a var to put the selected one into group.selected = null; that.appendChild(group); // Fix it into the parent group.fix = vOS.vElement.fixFill; group.fix(); return group; } function radio(that,value,top,left,width,height) { var radio = document.createElement("DIV"); that.childrens.push(radio); radio.remove = vOS.vElement.remove; radio.className = "vElement_radio"; radio.onmouseover = function(){if(!vOS.iWindow.action) this.checked == 1 ? this.className = "vElement_radio_checkedHover" : this.className = "vElement_radioHover";}; radio.onmouseout = function(){if(!vOS.iWindow.action) this.checked == 1 ? this.className = "vElement_radio_checked" : this.className = "vElement_radio";}; radio.onmouseup = function(){ if(!vOS.iWindow.action) { this.check(); this.className = "vElement_radio_checkedHover"; } }; radio.check = function() { if(this.parentNode.selected != this && this.parentNode.selected) { this.parentNode.selected.className = "vElement_radio"; this.parentNode.selected.checked = 0; } this.checked = 1; this.className = "vElement_radio_checked" this.parentNode.selected = this; }; radio.innerHTML = value; that.appendChild(radio); that.childrens.push(radio); radio.addEvent = vOS.vElement.addEvent; radio.removeEvent = vOS.vElement.removeEvent; radio.setWidth = vOS.vElement.setWidth; radio.setHeight = vOS.vElement.setHeight; radio.style.top = top + "px"; radio.style.left = left + "px"; radio.setWidth(width); radio.setHeight(height); return radio; } function checkbox(that,value,top,left,width,height) { checkbox = document.createElement("DIV"); checkbox.remove = vOS.vElement.remove; checkbox.className = "vElement_checkbox"; checkbox.onmouseover = function(){if(!vOS.iWindow.action) this.checked == 1 ? this.className = "vElement_checkbox_checkedHover" : this.className = "vElement_checkboxHover";}; checkbox.onmouseout = function(){if(!vOS.iWindow.action) this.checked == 1 ? this.className = "vElement_checkbox_checked" : this.className = "vElement_checkbox";}; checkbox.onmouseup = function(){ if(!vOS.iWindow.action) { if(this.checked == 1) { this.className = "vElement_checkboxHover"; this.checked = 0; } else { this.className = "vElement_checkbox_checkedHover"; this.checked = 1; } } }; checkbox.check = function() { this.className = "vElement_checkbox_checked"; this.checked = 1; }; checkbox.uncheck = function() { this.className = "vElement_checkbox"; this.checked = 0; }; checkbox.innerHTML = value; that.appendChild(checkbox); that.childrens.push(checkbox); checkbox.addEvent = vOS.vElement.addEvent; checkbox.removeEvent = vOS.vElement.removeEvent; checkbox.setWidth = vOS.vElement.setWidth; checkbox.setHeight = vOS.vElement.setHeight; checkbox.style.top = top + "px"; checkbox.style.left = left + "px"; checkbox.setWidth(width); checkbox.setHeight(height); return checkbox; } function tab(that,fill,top,left,width,height) { var tab = document.createElement("DIV"); that.childrens.push(tab); tab.childrens = new Array(); tab.className = "vElement_tab"; tab.remove = vOS.vElement.remove; that.appendChild(tab); tab.setWidth = vOS.vElement.setWidth; tab.setHeight1 = vOS.vElement.setHeight; tab.add = function(name,text) { var page = document.createElement("DIV"); page.add = vOS.vElement.add; page.childrens = new Array(); page.className = "tab_page"; page.active = null; page.noResize = 1; this.content.appendChild(page); this.childrens.push(page); page.remove = function() { if(this.parentNode) { // Remove an element (also get it out of the childrens array) var tab = this.parentNode.parentNode; for(var x = 0; x < tab.childrens.length; x++) { if(tab.childrens[x] == this) break; } var windows = vOS.vElement.getWindow(this); var tempArr = tab.childrens.slice(0,x); tempArr = tempArr.concat(tab.childrens.slice((x+1),tab.childrens.length)); tab.childrens = tempArr; tab.content.removeChild(this); tab.buttons.removeChild(this.button); windows.resize(); } } // Now add a button var button = document.createElement("DIV"); this.buttons.appendChild(button); button.page = page; page.button = button; button.name = name; button.onmouseover = function() { if(this.parentNode.active != this) this.className = "button_hover"; } button.onmouseout = function() { if(this.parentNode.active != this) this.className = "button"; } button.onmousedown = function() { this.parentNode.parentNode.parentNode.active = this.name; if(this.parentNode.active) { this.parentNode.active.className = "button"; this.parentNode.active.page.style.display = "none"; this.parentNode.active.page.noResize = 1; // run change event var vWindow = vOS.vElement.getWindow(this); vOS.arr_vApps[vWindow.vApp_pid].onEvent(vWindow.vWindow_name,this.parentNode.parentNode.parentNode.vElement_name,"change"); } this.parentNode.active = this; this.className = "button_selected"; this.page.style.display = "block"; this.page.noResize = 0; vOS.vElement.getWindow(this).resize(null, null, 1); } if(!this.buttons.active) { button.onmousedown(); } else { button.className = "button"; } var btnleft = document.createElement("DIV"); btnleft.className = "left"; button.appendChild(btnleft); var btntitle = document.createElement("DIV"); btntitle.className = "title"; btntitle.innerHTML = text; button.appendChild(btntitle); var btnright = document.createElement("DIV"); btnright.className = "right"; button.appendChild(btnright); windows.elements[name] = page; } tab.setHeight = function(height) { this.setHeight1(height); this.content.style.height = (this.clientHeight - this.header.clientHeight) + "px"; this.content.oHeight = (this.clientHeight - this.header.clientHeight); vOS.vElement.fixNormal(this.content); } // Add head var head = document.createElement("DIV"); head.className = "tab_head"; tab.header = head; tab.appendChild(head); // Add space for scroller var controls = document.createElement("DIV"); controls.className = "tab_controls"; head.appendChild(controls); // Add space for buttons var buttons = document.createElement("DIV"); buttons.className = "tab_buttons"; tab.buttons = buttons; buttons.active = null; head.appendChild(buttons); // Add space for content var content = document.createElement("DIV"); content.className = "tab_content"; tab.content = content; tab.appendChild(content); if(fill) { tab.fix1 = vOS.vElement.fixFill; tab.fix = function() { this.fix1(); this.content.style.height = (this.clientHeight - this.header.clientHeight) + "px"; this.content.oHeight = (this.clientHeight - this.header.clientHeight); vOS.vElement.fixNormal(this.content); } tab.fix(); } else { tab.style.top = top + "px"; tab.style.left = left + "px"; tab.setWidth(width); tab.setHeight(height); } return tab; } function selectbox(that,multi,fill,top,left,width,height) { var select = document.createElement("DIV"); select.className = "vElement_selectbox"; select.remove = vOS.vElement.remove; that.appendChild(select); that.childrens.push(select); select.items = new Array(); select.multi = multi; select.selectbox = null; // Add some own functions select.add = function(id,text) { var option = document.createElement("DIV"); option.optId = id; option.parent = this; option.selected = 0; option.className = "vElement_optionbox"; option.innerHTML = text; this.items[id] = option; option.select = function() { if(!this.selected) this.onmousedown(); } option.unselect = function() { if(this.selected) { this.onmousedown(); this.onmouseout(); } } option.remove = function() { if(this.selected && !this.parentNode.multi) this.parentNode.selectbox = null; this.parentNode.removeChild(this); } option.changeText = function(text) { this.innerHTML = text; } option.changeId = function(id) { this.optId = id; } option.onmouseover = function() { if(!this.selected) this.className = "vElement_optionbox_hover"; } option.onmouseout = function() { if(!this.selected) this.className = "vElement_optionbox"; } option.onmousedown = function() { if(this.selected) { this.className = "vElement_optionbox_hover"; this.selected = 0; if(!this.parentNode.multi) { this.parentNode.selected = null; } } else { if(!this.parentNode.multi) { if(this.parentNode.items[this.parent.selected]) { this.parentNode.items[this.parent.selected].className = "vElement_optionbox"; this.parentNode.items[this.parent.selected].selected = 0; } this.parentNode.selected = this.optId; } this.className = "vElement_optionbox_down"; this.selected = 1; } } this.appendChild(option); } // Now add global event's select.addEvent = vOS.vElement.addEvent; select.removeEvent = vOS.vElement.removeEvent; select.setWidth = vOS.vElement.setWidth; select.setHeight = vOS.vElement.setHeight; if(fill) { select.fix = vOS.vElement.fixFill; select.fix(); } else { select.style.top = top + "px"; select.style.left = left + "px"; select.setWidth(width); select.setHeight(height); } return select; } function listview(that,array,fill,top,left,width,height) { var list = document.createElement("DIV"); list.className = "vElement_listview"; that.appendChild(list); that.childrens.push(list); list.spacer = document.createElement("DIV"); list.spacer.className = "spacer"; list.appendChild(list.spacer); list.header = document.createElement("DIV"); list.header.order = null; list.header.className = "head"; list.spacer.appendChild(list.header); list.content = document.createElement("DIV"); list.content.className = "content"; list.spacer.appendChild(list.content); // Declare variables var totalWidth = 0; list.head = new Array(); list.columns = new Array(); list.rows = new Array(); // Start script list.xResize = function() { // Define variables var totalWidth = 0; var undefElement = null; // Get the total width + undef element for(var x in this.head) { if(!this.head[x].fill) { totalWidth += this.head[x].oWidth; this.head[x].setWidth(this.head[x].oWidth); } else undefElement = x; } // If it's no fix element then return now if(!this.hasFix) { this.spacer.style.width = totalWidth + "px"; } else { // Calculate the width for the undefined element var undefWidth = this.clientWidth - totalWidth; this.head[undefElement].setWidth(undefWidth); // Stop sizing... show overflow auto if(this.clientWidth < (totalWidth + this.head[undefElement].offsetWidth)) this.spacer.style.width = (totalWidth + this.head[undefElement].offsetWidth) + "px"; else this.spacer.style.width = this.clientWidth + "px"; } //Fix the columns var cellToFix = new Array(); for(var x in this.head) { if(this.head[x].offsetWidth != this.columns[x].offsetWidth) cellToFix.push(x); } // Fix the rows for(var y = 0; y < cellToFix.length; y++) { this.columns[cellToFix[y]].setWidth(this.head[cellToFix[y]].offsetWidth); } } // Add the columns for(var x in array) { if(x == 0) { list.hasImage = array[x][0]; list.hasFix = array[x][1]; } else { var head = document.createElement("DIV"); head.innerHTML = array[x][0]; head.order = 0; // 0 = no, 1 = ASC, 2 = DESC list.head.push(head); list.header.appendChild(head); // The events head.onmouseover = function() { var order = this.order == 1 ? "up " : (this.order == 2 ? "down " : ""); this.className = order + "hover"; } head.onmouseout = function() { var order = this.order == 1 ? "up" : (this.order == 2 ? "down" : ""); this.className = order; } head.onmousedown = function() { var order = ""; if(this.order == 1) { this.order = 2; order = "down "; } else if(this.order == 2) { this.order = 0; order = ""; } else { if(this.parentNode.order) { this.parentNode.order.className = ""; this.parentNode.order.order = 0; } this.parentNode.order = this; this.order = 1; order = "up "; } this.className = order + "hover"; } head.setWidth = vOS.vElement.setWidth; if(array[x][1] || !list.hasFix) head.setWidth(array[x][1]); else head.fill = 1; // Add a column var column = document.createElement("DIV"); list.content.appendChild(column); list.columns.push(column); column.className = "column"; column.setWidth = vOS.vElement.setWidth; column.setWidth(head.offsetWidth); } } // Declare functions list.add = function(array, group, image) { // Add a row var row = new Object(); row.group = group; row.image = image; row.cells = new Array(); this.rows.push(row); for(var x in array) { var cell = document.createElement("DIV"); cell.innerHTML = array[x]; this.columns[x].appendChild(cell); row.cells.push(cell); } return row; } list.clear = function() { for(var x = 0; x < this.columns.length; x++) { this.columns[x].innerHTML = ""; } } // Declare standard events / functions list.addEvent = vOS.vElement.addEvent; list.removeEvent = vOS.vElement.removeEvent; list.setWidth1 = vOS.vElement.setWidth; list.setHeight = vOS.vElement.setHeight; list.remove = vOS.vElement.remove; if(fill) { list.fix1 = vOS.vElement.fixFill; list.fix = function(dir) { this.fix1(); if(dir == "x" || !dir) this.xResize(); }; list.fix(); } else { list.style.top = top + "px"; list.style.left = left + "px"; list.setWidth = function(width) { this.setWidth1(width); this.xResize(); } list.setWidth(width); list.setHeight(height); } return list; } function combobox(that,top,left,width,height,array) { var combobox = document.createElement("SELECT"); combobox.className = "vElement_combobox"; combobox.style.position = "absolute"; combobox.style.top = top + "px"; combobox.style.left = left + "px"; combobox.style.width = width + "px"; combobox.style.height = height + "px"; that.appendChild(combobox); that.childrens.push(combobox); for (var x = 0; x < array.length; x++) { var theOption = document.createElement("OPTION"); theOption.appendChild(document.createTextNode(array[x])); combobox.appendChild(theOption); } combobox.addEvent = vOS.vElement.addEvent; return combobox; } function timer(that,name,timeout,repeat) { var vWindow = vOS.vElement.getWindow(that); var timer = new Object(); timer.id = vOS.arr_vApps[vWindow.vApp_pid].timers.length; timer.name = name; timer.repeat = repeat; timer.vWindow = vWindow; timer.timeout = timeout; timer.start = function() { this.timer = window.setTimeout("vOS.arr_vApps["+this.vWindow.vApp_pid+"].timers["+this.id+"].tick()",this.timeout); } timer.tick = function() { if(this.repeat) this.start(); vOS.arr_vApps[this.vWindow.vApp_pid].onEvent(this.vWindow.vWindow_name,this.name,"tick"); } timer.stop = function() { window.clearTimeout(this.timer); } vOS.arr_vApps[vWindow.vApp_pid].timers.push(timer); return timer; } } // Global functions for elements function _vElement_fixFill(dir) { if(!dir || dir == "x") { this.style.width = this.parentNode.clientWidth + "px"; var newWidth = this.parentNode.clientWidth - (this.offsetWidth - this.parentNode.clientWidth); this.style.width = (newWidth > 0 ? newWidth : 0) + "px"; } if(!dir || dir == "y") { this.style.height = this.parentNode.clientHeight + "px"; var newHeight = this.parentNode.clientHeight - (this.offsetHeight - this.parentNode.clientHeight); if(this.middle == 1) this.style.lineHeight = newHeight +"px"; this.style.height = (newHeight > 0 ? newHeight : 0) + "px"; } } function _vElement_fixNormal(that) { if(typeof(that.oWidth) != "undefined") { that.style.width = that.oWidth + "px"; var width = that.oWidth - (that.offsetWidth - that.oWidth); that.style.width = (width > 0 ? width : 0) + "px"; } if(typeof(that.oHeight) != "undefined") { that.style.height = that.oHeight + "px"; var height = that.oHeight - (that.offsetHeight - that.oHeight); that.style.height = (height > 0 ? height : 0) + "px"; } if(that.middle == 1) that.style.lineHeight = that.clientHeight + "px"; if(that.xResize) that.xResize(); } function _vElement_setWidth(width) { this.fix = null; this.oWidth = width > 0 ? width : 0; vOS.vElement.fixNormal(this); } function _vElement_setHeight(height) { this.fix = null; this.oHeight = height > 0 ? height : 0; vOS.vElement.fixNormal(this); } function _vElement_hide() { if(this.xHidden == 1) return 0; this.xHidden = 1; this.oldWidth = this.minWidth; this.minWidth = 0; this.style.visibility = "hidden"; vOS.vElement.getWindow(this).resize(); } function _vElement_show() { if(!this.xHidden) return 0; this.xHidden = 0; this.minWidth = this.oldWidth; this.style.visibility = "visible"; vOS.vElement.getWindow(this).resize(); } function _vElement_remove() { // Remove an element (also get it out of the childrens array) if(this.parentNode) { // Get the first one with children var element = this.parentNode; while(!element.childrens) { element = element.parentNode; } for(var x = 0; x < element.childrens.length; x++) { if(element.childrens[x] == this) { break; } } var windows = vOS.vElement.getWindow(this); var tempArr = element.childrens.slice(0,x); tempArr = tempArr.concat(element.childrens.slice((x+1),element.childrens.length)); element.childrens = tempArr; element.removeChild(this); windows.resize(); } } // Event functions function _vElement_addEvent(_vElement_event) { // Execute code // ------------ _vElement_event = _vElement_event.toLowerCase(); if (this.attachEvent) { if (_vElement_event.substr(0, 2) != "on") { _vElement_event = "on" + _vElement_event; } this.attachEvent(_vElement_event, vOS.vElement.processEvent); } else { if (_vElement_event.substr(0, 2) == "on") { _vElement_event = _vElement_event.substr(2); } this.addEventListener(_vElement_event, vOS.vElement.processEvent, false); } } function _vElement_removeEvent(_vElement_event) { // Execute code // ------------ _vElement_event = _vElement_event.toLowerCase(); if (this.detachEvent) { if (_vElement_event.substr(0, 2) != "on") { _vElement_event = "on" + _vElement_event; } this.detachEvent(_vElement_event, vOS.vElement.processEvent); } else { if (_vElement_event.substr(0, 2) == "on") { _vElement_event = _vElement_event.substr(2); } this.removeEventListener(_vElement_event, vOS.vElement.processEvent, false); } } function _vElement_processEvent(e) { // Execute code // ------------ var targ = vOS.event(e); var temp = targ.vElement_name; while (targ.className != "window_container" && targ.className != "window_container_inactive") { targ = targ.parentNode; } vOS.arr_vApps[targ.vApp_pid].onEvent(targ.vWindow_name, temp, e.type.toLowerCase(), e); } // Global functions not for elements function getWindow(windows) { while (windows.className != "window_container" && windows.className != "window_container_inactive") { windows = windows.parentNode; } return vOS.arr_vWindows[windows.vWindow_id]; } function resize(dir,fix,fixElement,loop) { // ! change this vvvv var arrElement = new Array(); arrElement.push(this.window_content); // Check if the resize was normal :) var stopx = 0; var stopy = 0; // Go through the elements for(var x = 0; x < arrElement.length; x++) { var children = arrElement[x].childrens; if(arrElement[x].split == "y" && (!dir || dir == "y")) { // Save the undefined height (not static ones) and the total height of the var undefHeight = 0; var undefMinHeight = 0; var totalHeight = 0; for(var i = 0; i < children.length; i++) { if(children[i].childrens && children[i].childrens.length) arrElement.push(children[i]); if(children[i].Static == 0) { undefHeight++; undefMinHeight += children[i].minHeight; } else { totalHeight += children[i].minHeight; } } // Fix the heights var totalHeight = (arrElement[x].clientHeight - totalHeight); var tempHeight = totalHeight; var calHeight = totalHeight / undefHeight; for(var i = 0; i < children.length; i++) { if(children[i].Static == 0) { if(children[i].minHeight > calHeight && undefHeight > 1) { tempHeight -= children[i].minHeight; undefHeight--; // Calculate the new calHeight calHeight = tempHeight / undefHeight; } } } // See if things went wrong stopx = totalHeight - undefMinHeight < stopx ? totalHeight - undefMinHeight : stopx; // Now finaly give all the elements the right height :D var totalHeight = 0; for(var i = 0; i < children.length; i++) { children[i].style.top = totalHeight + "px"; var height = children[i].Static ? children[i].minHeight : (calHeight > children[i].minHeight ? calHeight : children[i].minHeight); children[i].style.height = height + "px"; children[i].style.width = arrElement[x].clientWidth + "px"; totalHeight += height; } } else if(arrElement[x].split == "x" && (!dir || dir == "x")) { // Save the undefined width (not static ones) and the total width of the var undefWidth = 0; var undefMinWidth = 0; var totalWidth = 0; for(var i = 0; i < children.length; i++) { if(children[i].childrens && children[i].childrens.length) arrElement.push(children[i]); if(children[i].Static == 0) { undefWidth++; undefMinWidth += children[i].minWidth; } else { totalWidth += children[i].minWidth; } } // Fix the widths var totalWidth = (arrElement[x].clientWidth - totalWidth); var tempWidth = totalWidth; var calWidth = totalWidth / undefWidth; for(var i = 0; i < children.length; i++) { if(children[i].Static == 0) { if(children[i].minWidth > calWidth && undefWidth > 1) { tempWidth -= children[i].minWidth; undefWidth--; // Calculate the new calWidth calWidth = tempWidth / undefWidth; } } } // See if things went wrong stopy = totalWidth - undefMinWidth < stopy ? totalWidth - undefMinWidth : stopy; // Now finaly give all the elements the right width :D var totalWidth = 0; for(var i = 0; i < children.length; i++) { children[i].style.left = totalWidth + "px"; var width = children[i].Static ? children[i].minWidth : (calWidth > children[i].minWidth ? calWidth : children[i].minWidth); children[i].style.width = width + "px"; children[i].style.height = arrElement[x].clientHeight + "px"; totalWidth += width; } } else if(arrElement[x].split) { for(var i = 0; i < children.length; i++) { if(children[i].childrens && children[i].childrens.length) arrElement.push(children[i]); if(arrElement[x].split == "y") children[i].style.width = arrElement[x].clientWidth + "px"; else children[i].style.height = arrElement[x].clientHeight + "px"; } } else { for(var i = 0; i < children.length; i++) { if(children[i].noResize) continue; if(children[i].childrens && children[i].childrens.length) arrElement.push(children[i]); if(children[i].fix) children[i].fix(dir); else if(fixElement) vOS.vElement.fixNormal(children[i]); } } } // Check if we need to fix something var hasFixed = loop ? 1 : 0; if(stopx < 0 && fix) { fix.setHeight((fix.window_content ? fix.window_content.clientHeight : fix.clientHeight) - stopx); hasFixed = 1; } if(stopy < 0 && fix) { fix.setWidth((fix.window_content ? fix.window_content.clientWidth : fix.clientWidth) - stopy); hasFixed = 1; } if((stopx < 0 || stopy < 0) && fix) { loop = loop ? loop + 1 : 1; if(loop == 10) return 1; return this.resize(dir,fix,fixElement,loop); } if(stopx < 0 || stopy < 0) return [stopx,stopy]; else return hasFixed; } } add_counter(10);