// Class prototype // --------------- function vWindow(_vApp_pid, _vWindow_name) { // Initialize functions // -------------------- this.create = _vWindow_create; this.setTitle = _vWindow_setTitle; this.setIcon = _vWindow_setIcon; this.setTop = _vWindow_setTop; this.setLeft = _vWindow_setLeft; this.setWidth = _vWindow_setWidth; this.setHeight = _vWindow_setHeight; this.setActive = _vWindow_setActive; this.setState = _vWindow_setState; this.buttonEnable = _vWindow_buttonEnable; this.buttonDisable = _vWindow_buttonDisable; this.changeStatus = _vWindow_changeStatus; this.addMenu = _vWindow_addMenu; this.showMenu = _vWindow_showMenu; this.activeStyle = _vWindow_activeStyle; this.inactiveStyle = _vWindow_inactiveStyle; this.blink = _vWindow_blink; this.enable = _vWindow_enable; this.disable = _vWindow_disable; this.vAlert = _vWindow_vAlert; this.vPrompt = _vWindow_vPrompt; this.center = _vWindow_center; // Functions imported from vElement.js this.add = vOS.vElement.add; this.resize = vOS.vElement.resize; // Shortcut functions this.minimize = function() {this.setState('minimize');} this.normalize = function() {this.setState('normalize');} this.maximize = function() {this.setState('maximize'); return 1;} this.close = function() {this.setState('close');} this.hide = function() {this.setState('hide');} this.show = function() {this.setState('show');} // Initialize properties // --------------------- this.vApp_pid = _vApp_pid; this.vWindow_name = _vWindow_name; this.vWindow_id = vOS.arr_vWindows.length; this.elements = new Array(); this.menus = new Array(); // Put the window in the arr_vWindows array vOS.arr_vWindows[vOS.arr_vWindows.length] = this; // Functions prototype // ------------------- function _vWindow_create(_vWindow_title, _vWindow_icon, _vWindow_top, _vWindow_left, _vWindow_width, _vWindow_height, _vWindow_resizable, _vWindow_taskbar, _vWindow_menu, _vWindow_status) { // Initialize properties // --------------------- this.title = _vWindow_title; this.icon = _vWindow_icon; this.top = _vWindow_top; this.left = _vWindow_left; this.width = _vWindow_width; this.height = _vWindow_height; this.resizable = _vWindow_resizable; this.taskbar = _vWindow_taskbar; this.menu = _vWindow_menu; this.status = _vWindow_status; this.state = "normal"; this.lastState = "normal"; this.oldTop; this.oldLeft; this.oldWidth; this.oldHeight; this.blinking = new Array(); this.btn_allDisabled = 0; this.disabled = 0; // Execute code // ------------ // Window container this.window_container = document.createElement("DIV"); if (typeof this.resizable == "object") { // Make sure the window can not be resized too small if (this.resizable[0] < 100) { this.resizable[0] = 100; } if (this.resizable[1] < 30) { this.resizable[1] = 30; } this.window_container.onmousemove = vOS.iWindow.border_mouseover; this.window_container.onmouseout = vOS.iWindow.border_mouseover; this.window_container.onmouseup = vOS.iWindow.border_mouseover; } this.window_container.onmousedown = vOS.iWindow.active_event; this.window_container.vApp_pid = this.vApp_pid; this.window_container.vWindow_id = this.vWindow_id; this.window_container.vWindow_name = this.vWindow_name; this.window_container.className = "window_container"; this.window_container.style.top = this.top + "px"; this.window_container.style.left = this.left + "px"; this.window_container.style.cursor = 'default'; vOS.screen_container.appendChild(this.window_container); // Window header this.window_header = document.createElement("DIV"); this.window_header.onmousedown = vOS.iWindow.move_event; this.window_header.className = "window_header"; this.window_header.style.width = this.width + "px"; this.window_header.ondblclick = vOS.iWindow.dblclick; this.window_container.appendChild(this.window_header); // Window's icon div this.window_icon = document.createElement("DIV"); this.window_icon.className = "window_icon"; this.window_header.appendChild(this.window_icon); // Window's icon this.window_icon_image = document.createElement("DIV"); this.window_icon_image.style.background = "url(" + this.icon + ")"; this.window_icon_image.style.backgroundRepeat = "no-repeat"; this.window_icon_image.style.width = "16px"; this.window_icon_image.style.height = "16px"; this.window_icon.appendChild(this.window_icon_image); // Window's title this.window_title = document.createElement("DIV"); this.window_title.className = "window_title"; this.window_title.style.width = (this.width - 70) + "px"; this.window_title.style.textOverflow = "ellipsis"; this.window_header.appendChild(this.window_title); this.window_title_text = document.createTextNode(this.title); this.window_title.appendChild(this.window_title_text); // Window's minimize, maximize and close buttons this.window_buttons = document.createElement("DIV"); this.window_buttons.className = "window_buttons"; this.window_header.appendChild(this.window_buttons); //2 empty divs: this.window_replacement_1 = document.createElement("DIV"); this.window_buttons.appendChild(this.window_replacement_1); this.window_replacement_2 = document.createElement("DIV"); this.window_buttons.appendChild(this.window_replacement_2); // Minimize this.window_minimize = document.createElement("DIV"); this.window_minimize.className = "window_minimize"; this.window_minimize.buttonName = "minimize"; this.window_minimize.title = _LANG_["minimize"]; this.window_minimize.onmouseover = vOS.iWindow.button; this.window_minimize.onmouseout = vOS.iWindow.button; this.window_minimize.onmouseup = vOS.iWindow.button; this.window_minimize.onmousedown = vOS.iWindow.button; this.window_buttons.appendChild(this.window_minimize); // Maximize this.window_maximize = document.createElement("DIV"); this.window_maximize.className = "window_maximize"; this.window_maximize.buttonName = "maximize"; this.window_maximize.title = _LANG_["maximize"]; this.window_maximize.onmouseover = vOS.iWindow.button; this.window_maximize.onmouseout = vOS.iWindow.button; this.window_maximize.onmouseup = vOS.iWindow.button; this.window_maximize.onmousedown = vOS.iWindow.button; this.window_buttons.appendChild(this.window_maximize); // Close this.window_close = document.createElement("DIV"); this.window_close.className = "window_close"; this.window_close.buttonName = "close"; this.window_close.title = _LANG_["close"]; this.window_close.onmouseover = vOS.iWindow.button; this.window_close.onmouseout = vOS.iWindow.button; this.window_close.onmouseup = vOS.iWindow.button; this.window_close.onmousedown = vOS.iWindow.button; this.window_buttons.appendChild(this.window_close); //Menu Window if (this.menu) { this.window_menu = document.createElement("DIV"); this.window_menu.className = "window_menu"; this.window_menu.style.width = this.width + "px"; this.window_container.appendChild(this.window_menu); } // The most important div, the one with the content this.window_content = document.createElement("DIV"); if (this.status) { this.window_content.className = "window_content"; } else { this.window_content.className = "window_content_noStatus"; } this.window_content.style.width = this.width + "px"; this.window_content.style.height = this.height + "px"; this.window_content.style.overflow = "hidden"; this.window_content.childrens = new Array(); // Disable scrolling the window_content div down by selecting non-visible // elements with the use of the tab key this.window_content.onscroll = function() { this.scrollTop = 0; }; this.window_container.appendChild(this.window_content); //Status if (this.status) { this.window_status = document.createElement("DIV"); this.window_status.className = "window_status"; this.window_status.style.width = this.width + "px"; this.window_status.style.overflow = "hidden"; this.window_container.appendChild(this.window_status); this.window_status_textContainer = document.createElement("DIV"); this.window_status_textContainer.className = "window_status_text"; this.window_status.appendChild(this.window_status_textContainer); this.window_status_text = document.createTextNode(""); this.window_status_textContainer.appendChild(this.window_status_text); } if (_vWindow_taskbar == true) { // Create a taskbar button this.taskbar_button = new vOS.taskbar.button(this.vWindow_id,this.title,this.icon); } else { this.buttonDisable("minimize"); } // Check if you can see the window vOS.check_window(this.vWindow_id); // Make the window active this.setActive(); } function _vWindow_changeStatus(_vWindow_status) { if (this.status) { _vWindow_temp = this.window_status_textContainer.firstChild; _vWindow_temp.nodeValue = _vWindow_status; } } function _vWindow_addMenu(_vWindow_menu_name, _vWindow_menu_text) { this.menus[_vWindow_menu_name] = document.createElement("SPAN"); this.menus[_vWindow_menu_name].menu_name = _vWindow_menu_name; this.menus[_vWindow_menu_name].className = "window_menu_button"; this.menus[_vWindow_menu_name].appendChild(document.createTextNode(_vWindow_menu_text)); this.window_menu.appendChild(this.menus[_vWindow_menu_name]); // Define event functions this.menus[_vWindow_menu_name].onmouseout = function(e) { // Make sure this menu won't work while resizing a vWindow if (vOS.iWindow.action) { return; } if (!e) { e = event; } var targ = vOS.event(e); if (targ.className != "window_container" && targ.className != "window_container_inactive") { // Loop through the objects until you reach the window_container div while (targ.className != "window_container" && targ.className != "window_container_inactive") { targ = targ.parentNode; } } // Only keep highlighting the menu button if the opened // menu is at the same window if (vOS.vMenu.vWindow_id != targ.vWindow_id) { this.className = "window_menu_button"; } else { // When moving the mouse of the menu button, return to the // state it is supposed to be at if (vOS.vMenu.selectedMenuButtonID != this.menu_name) { this.className = "window_menu_button"; } } } this.menus[_vWindow_menu_name].onmouseover = function(e) { if (!e) { e = event; } // Make sure this menu won't work while resizing a vWindow if (vOS.iWindow.action) { return; } this.className = "window_menu_button_selected"; // Check if a menu is open if ((vOS.vMenu.selectedMenuButtonID) && (vOS.vMenu.selectedMenuButtonID != this.menu_name)) { var targ = vOS.event(e); if (targ.className != "window_container" && targ.className != "window_container_inactive") { // Loop through the objects until you reach the window_container div while (targ.className != "window_container" && targ.className != "window_container_inactive") { targ = targ.parentNode; } } if (vOS.vMenu.vWindow_id == targ.vWindow_id) { eval("vOS.arr_vApps[" + targ.vApp_pid + "].onEvent('" + targ.vWindow_name + "', '" + this.menu_name + "', null);"); } vOS.vMenu.menu_click = false; } } this.menus[_vWindow_menu_name].onmousedown = function(e) { if (!e) { e = event; } var mousebutton = e.which ? e.which : e.button; // Make sure this menu won't work while resizing a vWindow or is hit by the right mousebutton if (vOS.iWindow.action || mousebutton != 1) { this.className = "window_menu_button_selected"; return; } this.className = "window_menu_button_selected"; if (!e) { e = event; } var targ = vOS.event(e); if (targ.className != "window_container" && targ.className != "window_container_inactive") { // Loop through the objects until you reach the window_container div while (targ.className != "window_container" && targ.className != "window_container_inactive") { targ = targ.parentNode; } } // Check if the user clicked on a menu button of an already // opened menu on the same window if ((vOS.vMenu.selectedMenuButtonID != this.menu_name) || ((vOS.vMenu.selectedMenuButtonID == this.menu_name) && (vOS.vMenu.vWindow_id != targ.vWindow_id)) || (vOS.vMenu.vWindow_id.length == 0)) { // When opening a menu from a new window, be sure to set the class // of the menu button of the old window back to normal if (vOS.vMenu.selectedMenuButtonID == this.menu_name) { vOS.vMenu.selectedMenuButton.className = "window_menu_button"; } // Call the function which set everything to open the menu eval("vOS.arr_vApps[" + targ.vApp_pid + "].onEvent('" + targ.vWindow_name + "', '" + this.menu_name + "', null);"); } else { // Clicked on the menu button of an already opened menu, now // close it vOS.vMenu.closeMenu(true); vOS.vMenu.selectedMenuButton = ""; this.className = "window_menu_button_selected"; } return false; } this.menus[_vWindow_menu_name].onmouseup = function(e) { // After resizing a window, be sure to set the menu button style to // "button_selected" if the mouse is on top of the menu button this.className = "window_menu_button_selected"; } } function _vWindow_showMenu(_vWindow_menu_name, _vWindow_menu_array) { // Change back the color of the previous openened menu button if (typeof vOS.vMenu.selectedMenuButton == "object") { if (_vWindow_menu_name != vOS.vMenu.selectedMenuButton.menu_name) { vOS.vMenu.selectedMenuButton.className = "window_menu_button"; } } // Save the menu which is currently opened in a variable vOS.vMenu.selectedMenuButton = this; vOS.vMenu.selectedMenuButtonID = this.menu_name; vOS.vMenu.menu_click = true; vOS.vMenu.showFromButton(this.vApp_pid, this.vWindow_id, _vWindow_menu_name, _vWindow_menu_array); } function _vWindow_buttonEnable(_vWindow_button_name) { var active = vOS.activeWindow != this.vWindow_id ? "_inactive" : ""; switch (_vWindow_button_name) { case "minimize": if (this.window_minimize.buttonName != 'minimize_disabled') return; this.window_minimize.className = "window_minimize" + active; this.window_minimize.buttonName = "minimize"; break; case "maximize": if (this.window_maximize.buttonName != 'maximize_disabled') return; if (this.state == 'maximize') { this.window_maximize.className = "window_normalize" + active; this.window_maximize.buttonName = "normalize"; } else { this.window_maximize.className = "window_maximize" + active; this.window_maximize.buttonName = "maximize"; } break; case "close": if (this.window_close.buttonName != 'close_disabled') return; this.window_close.className = "window_close" + active; this.window_close.buttonName = "close"; break; } // Disable the replacement! if(this.btn_allDisabled) { this.btn_allDisabled = 0 } else if(this.window_replacement_1.className) { this.window_replacement_1.className = ""; } else if(this.window_replacement_2.className) { this.window_replacement_2.className = ""; } } function _vWindow_buttonDisable(_vWindow_button_name) { switch (_vWindow_button_name) { case "minimize": if (this.window_minimize.buttonName != 'minimize') return; this.window_minimize.className = ""; this.window_minimize.buttonName = "minimize_disabled"; break; case "maximize": if (this.window_maximize.buttonName != 'maximize' && this.window_maximize.buttonName != 'normalize') return; this.window_maximize.className = ""; this.window_maximize.buttonName = "maximize_disabled"; break; case "close": if (this.window_close.buttonName != 'close') return; this.window_close.className = ""; this.window_close.buttonName = "close_disabled"; break; } // Enable a replacement if(!this.window_replacement_1.className) { this.window_replacement_1.className = "window_btn_disabled"; } else if(!this.window_replacement_2.className) { this.window_replacement_2.className = "window_btn_disabled"; } else { this.btn_allDisabled = 1; } } function _vWindow_setTitle(_vWindow_title) { // Initialize properties // --------------------- this.title = _vWindow_title; // Execute code // ------------ _vWindow_temp = this.window_title.firstChild; _vWindow_temp.nodeValue = this.title; if (this.taskbar) { this.taskbar_button.setTitle(this.title); } } function _vWindow_setIcon(_vWindow_icon) { // Initialize properties // --------------------- this.icon = _vWindow_icon; // Execute code // ------------ this.window_icon_image.style.background = "url(" + this.icon + ")"; this.window_icon_image.style.backgroundRepeat = "no-repeat"; // Taskbar icon if (this.taskbar) { this.taskbar_button.setIcon(this.icon); } } function _vWindow_setTop(_vWindow_top) { // Initialize properties // --------------------- this.top = _vWindow_top; // Execute code // ------------ this.window_container.style.top = this.top + "px"; // Check if you can see the window vOS.check_window(this.vWindow_id); } function _vWindow_setLeft(_vWindow_left) { // Initialize properties // --------------------- this.left = _vWindow_left; // Execute code // ------------ this.window_container.style.left = this.left + "px"; // Check if you can see the window vOS.check_window(this.vWindow_id); } function _vWindow_setWidth(_vWindow_width) { if(_vWindow_width == this.width) return; _vWindow_width = _vWindow_width > 0 ? _vWindow_width : 0; // Initialize properties // --------------------- this.width = _vWindow_width; // Execute code // ------------ // Check if the size doesn't cross the minimum size if (typeof this.resizable == "object") { if (this.resizable[0] > this.width) { this.width = this.resizable[0]; } } // Titlebar width this.window_header.style.width = this.width + "px"; this.window_title.style.width = (this.width - 70) + "px"; // Content div width this.window_content.style.width = this.width + "px"; //Menu bar and status bar if (this.status) { this.window_status.style.width = this.width + "px"; } if (this.menu) { this.window_menu.style.width = this.width + "px"; } //@ IE BUG this.left -= 1; this.window_container.style.left = this.left + "px"; this.left += 1; this.window_container.style.left = this.left + "px"; // Call the event vOS.arr_vApps[this.vApp_pid].onEvent(this.vWindow_name, null, 'resize'); // Me want elements :) var toReturn = this.resize("x",this); // Check if you can see the window vOS.check_window(this.vWindow_id); if(toReturn) return toReturn } function _vWindow_setHeight(_vWindow_height) { if(_vWindow_height == this.height) return; _vWindow_height = _vWindow_height > 0 ? _vWindow_height : 0; // Initialize properties // --------------------- this.height = _vWindow_height; // Execute code // ------------ // Check if the size doesn't cross the minimum size if (typeof this.resizable == "object") { if (this.resizable[1] > this.height) { this.height = this.resizable[1]; } } this.window_content.style.height = this.height + "px"; // Call the event vOS.arr_vApps[this.vApp_pid].onEvent(this.vWindow_name, null, 'resize'); // Me want elements :) toReturn = this.resize("y",this); // Check if you can see the window vOS.check_window(this.vWindow_id); if(toReturn) return toReturn } function _vWindow_center() { // This function centers the window on the screen this.setLeft(vOS.width() / 2 - this.width / 2); this.setTop(vOS.height() / 2 - this.height / 2); } function _vWindow_activeStyle() { this.window_container.className = "window_container"; if (this.status) { this.window_content.className = "window_content"; this.window_status.className = "window_status"; } else { this.window_content.className = "window_content_noStatus"; } if (this.menu) { this.window_menu.className = "window_menu"; } this.window_header.className = "window_header"; this.window_icon.className = "window_icon"; this.window_title.className = "window_title"; this.window_buttons.className = "window_buttons"; if (this.window_minimize.buttonName == 'minimize') { this.window_minimize.className = "window_minimize"; } if (this.state != 'maximize' && this.window_maximize.buttonName != 'maximize_disabled') { this.window_maximize.className = "window_maximize"; } else if (this.window_maximize.buttonName != 'maximize_disabled') { this.window_maximize.className = "window_normalize"; } if (this.window_close.buttonName == 'close') { this.window_close.className = "window_close"; } } function _vWindow_inactiveStyle() { this.window_container.className = "window_container_inactive"; if (this.status) { this.window_content.className = "window_content_inactive"; this.window_status.className = "window_status_inactive"; } else { this.window_content.className = "window_content_noStatus_inactive"; } if (this.menu) this.window_menu.className = "window_menu_inactive"; this.window_header.className = "window_header_inactive"; this.window_icon.className = "window_icon_inactive"; this.window_title.className = "window_title_inactive"; this.window_buttons.className = "window_buttons_inactive"; if (this.window_minimize.buttonName == 'minimize') { this.window_minimize.className = "window_minimize_inactive"; } if (this.state != 'maximize' && this.window_maximize.buttonName != 'maximize_disabled') { this.window_maximize.className = "window_maximize_inactive"; } else if (this.window_maximize.buttonName != 'maximize_disabled') { this.window_maximize.className = "window_normalize_inactive"; } if (this.window_close.buttonName == 'close') { this.window_close.className = "window_close_inactive"; } } function _vWindow_setActive() { // Execute code // ------------ //You can't make an hidden thing active!!! use .show first if(this.state == "hide") return; // Check if you are not trying to make the current active // window active agáin if (vOS.activeWindow != this.vWindow_id) { //Stop blinking! if(this.blinking['blink']) { clearTimeout(this.blinking['timer']); this.blinking['timer'] = false; this.blinking['blink'] = false; this.blinking['count'] = false; } // Fix the zIndex: if(this.window_container.style.zIndex > 0) { vOS.iWindow.zOrder(this.window_container.style.zIndex); this.window_container.style.zIndex = vOS.zOrder; } else { vOS.zOrder += 1; this.window_container.style.zIndex = vOS.zOrder; } if (vOS.activeWindow != 'a') { var that = vOS.arr_vWindows[vOS.activeWindow]; that.inactiveStyle(); //Set taskbar if (that.taskbar == true) { // Set last active window taskbar button to normal that.taskbar_button.setState("normal"); } } //If the button is minimized, than first maximize it! if (this.state == "minimize") this.setState(this.lastState); // And the new one the active style if(!this.disabled) { this.activeStyle(); } else { this.inactiveStyle(); // !Hier vervolgens de alert of mesgding naar voren halen :) } // set taskbar if (this.taskbar == true) { // Set taskbar button to active this.taskbar_button.setState("active"); this.taskbar_button.scrollView(); } // Save the current window_id as the activeWindow vOS.activeWindow = this.vWindow_id; //Event handling if (that) { vOS.arr_vApps[that.vApp_pid].onEvent(that.vWindow_name, null, 'inactive'); } vOS.arr_vApps[this.vApp_pid].onEvent(this.vWindow_name, null, 'active'); } } function _vWindow_setState(_vWindow_state) { // this.state // this.lastState if(this.disabled == 1) return 0; if (_vWindow_state == "minimize" && this.window_minimize.buttonName != 'minimize_disabled') { this.lastState = this.state; this.state = "minimize"; this.window_container.style.visibility = "hidden"; if (vOS.iWindow.setLastWindowActive(this.window_container.style.zIndex)) { //Make taskbar inactive this.taskbar_button.setState("normal"); } this.window_container.style.zIndex = 0; } else { // If the window is not minimized, make sure it is // visible when the user clicks on it/the taskbar // button var oldState = this.state; this.state = this.lastState; this.window_container.style.visibility = "visible"; // If it was minimized, set it to active :) if(oldState == "minimize") this.setActive(); } if (_vWindow_state == "maximize" && this.window_maximize.buttonName != 'maximize_disabled') { if (this.state != "maximize") { //Set icons and state this.state = "maximize"; this.lastState = "maximize"; this.window_maximize.className = "window_normalize"; this.window_maximize.buttonName = "normalize"; this.window_maximize.title = _LANG_["normalize"]; //Put everything in OLD this.oldWidth = this.width; this.oldHeight = this.height; this.oldLeft = this.left; this.oldTop = this.top; } //Set height and width this.setHeight(vOS.height() - (this.window_container.clientHeight - this.height) - _vTheme_padding_bottom - _vTheme_padding_top); this.setWidth(vOS.width()); //Set top and left this.setTop(_vTheme_padding_top); this.setLeft(_vTheme_padding_left); this.window_container.style.cursor = "default"; } if (_vWindow_state == "normalize" && this.window_maximize.buttonName != 'maximize_disabled') { if(this.state == "maximize") { this.setHeight(this.oldHeight); this.setWidth(this.oldWidth); this.setTop(this.oldTop); this.setLeft(this.oldLeft); } this.state = "normal"; this.lastState = "normal"; this.window_maximize.className = "window_maximize"; this.window_maximize.buttonName = "maximize"; this.window_maximize.title = _LANG_["maximize"]; } if (_vWindow_state == "close") { if (this.taskbar == true) { this.taskbar_button.clear(); } //empty used array's this.elements = null; vOS.arr_vWindows[this.vWindow_id] = null; // Set the window's state to closed this.state = "close"; // Remove the actual window from the screen this.window_container.parentNode.removeChild(this.window_container); vOS.arr_vWindows.splice(this.vWindow_id, 1); //Fix the window id's for (x=0; x < vOS.arr_vWindows.length; x++) { vOS.arr_vWindows[x].vWindow_id = x; vOS.arr_vWindows[x].window_container.vWindow_id = x; if (vOS.arr_vWindows[x].taskbar == true) { vOS.arr_vWindows[x].taskbar_button.button.vWindow_id = x; } } vOS.activeWindow = 'a'; vOS.iWindow.button_id = 'a'; vOS.iWindow.button_event = 'a'; vOS.taskbar.activeButton = 'a'; vOS.iWindow.setLastWindowActive(this.window_container.style.zIndex); this.window_container.style.zIndex = 0; } if(_vWindow_state == "hide") { this.window_container.style.visibility = "hidden"; if (this.taskbar == true) { this.taskbar_button.clear(); } this.state = "hide"; vOS.iWindow.setLastWindowActive(this.window_container.style.zIndex); this.window_container.style.zIndex = 0; } if(_vWindow_state == "show") { this.window_container.style.visibility = "visible"; if (this.taskbar == true) { this.taskbar_button = new vOS.taskbar.button(this.vWindow_id,this.title,this.icon); } this.setActive(); } } function _vWindow_blink() { //Check if the screen isn't closed, already active! and isn't allready blinking! if(this.state != "close" && vOS.activeWindow != this.vWindow_id) { clearTimeout(this.blinking['timer']); this.blinking['blink'] = 1; this.blinking['count'] = 0; vOS.iWindow.doBlink(this.vWindow_id); } } function _vWindow_enable() { this.disabled = 0; this.window_disabled.parentNode.removeChild(this.window_disabled); this.window_disabled = null; this.setActive(); this.activeStyle(); } function _vWindow_disable() { this.disabled = 1; this.window_disabled = document.createElement("DIV"); this.window_disabled.style.position = "absolute"; this.window_disabled.style.background = "url(images/disable.png)"; this.window_disabled.style.left = "0px"; this.window_disabled.style.top = "0px"; this.window_disabled.style.width = this.window_container.offsetWidth + "px"; this.window_disabled.style.height = this.window_container.offsetHeight + "px"; this.window_container.appendChild(this.window_disabled); this.inactiveStyle(); } function _vWindow_vAlert(_vWindow_vAlert_text, _vWindow_vAlert_title, _vWindow_vAlert_buttons) { // Call the function in vOS.vDialog to show a vAlert vOS.vDialog.vAlert(_vWindow_vAlert_text, _vWindow_vAlert_title, _vWindow_vAlert_buttons, "vWindow", this); } function _vWindow_vPrompt(_vWindow_vPrompt_text, _vWindow_vPrompt_title, _vWindow_vPrompt_default) { // Call the function in vOS.vDialog to show a vPrompt vOS.vDialog.vPrompt(_vWindow_vPrompt_text, _vWindow_vPrompt_title, _vWindow_vPrompt_default, "vWindow", this); } } // Class prototype // Class with all external window functions // --------------- function iWindow() { //Function list this.doBlink = _vWindow_doBlink; this.setLastWindowActive = _vWindow_setLastWindowActive; this.active_event = _vWindow_activate_event; this.border_mouseover = _vWindow_border_mouseover; this.border_mousedown = _vWindow_border_mousedown; this.dblclick = _vWindow_dblclick; this.move_event = _vWindow_move_event; this.button = _vWindow_button; this.zOrder = _vWindow_zOrder; //Variable list (accessible for all scripts) this.action = 0; this.button_id = 'a'; this.button_event = 'a'; //Internal variable list (accessible for everything within this class) var dobj; function _vWindow_doBlink(vWindow_id) { that = vOS.arr_vWindows[vWindow_id]; that.blinking['timer'] = setTimeout("vOS.iWindow.doBlink("+vWindow_id+");",1000); that.blinking['blink'] = that.blinking['blink'] == 2 ? 1 : 2; that.blinking['count']++; if(that.blinking['blink'] == 2) { that.inactiveStyle(); if(that.taskbar == true) that.taskbar_button.setState("blink"); } else if(that.blinking['count'] < 11) { that.activeStyle(); if(that.taskbar == true) that.taskbar_button.setState("normal"); } else { clearTimeout(that.blinking['timer']); } } function _vWindow_zOrder(zOrder) { //Order the zOrder: zOrder = parseInt(zOrder); for(x=0; x < vOS.arr_vWindows.length; x++) { var toZorder = parseInt(vOS.arr_vWindows[x].window_container.style.zIndex); if(toZorder > zOrder) { vOS.arr_vWindows[x].window_container.style.zIndex = toZorder - 1; } } } function _vWindow_setLastWindowActive(zIndex) { vOS.zOrder -= 1; _vWindow_zOrder(zIndex); _highest_zIndex = -1; _highest_zIndexWindowId = -1; _zIndex_found = 0; for (x = 0; x < vOS.arr_vWindows.length; x++) { if (parseInt(vOS.arr_vWindows[x].window_container.style.zIndex) > _highest_zIndex) { if (vOS.arr_vWindows[x].state != "minimize" && vOS.arr_vWindows[x].state != "close" && vOS.arr_vWindows[x].state != "hide") { _highest_zIndex = parseInt(vOS.arr_vWindows[x].window_container.style.zIndex); _highest_zIndexWindowId = x; _zIndex_found = 1; } } } if (_zIndex_found) { vOS.arr_vWindows[_highest_zIndexWindowId].setActive(); return 0; } else { vOS.activeWindow = 'a'; return 1; } } function _vWindow_activate_event(e) { // Get the div on which is clicked if (!e) { var e = window.event; } if(vOS.iWindow.action) return; var targ = vOS.event(e); if (targ.className != "window_container" && targ.className != "window_container_inactive") { // Loop through the objects until you reach the window_container div dobj = targ.parentNode; while (dobj.className != "window_container" && dobj.className != "window_container_inactive") { dobj = dobj.parentNode; } } else { dobj = targ; } // Call the object's setActive() function vOS.arr_vWindows[dobj.vWindow_id].setActive(); // Check if the user wants to resize the window var mousebutton = e.which ? e.which : e.button; if ((window["mouseonborder"] == 1) && !vOS.iWindow.action && mousebutton == 1) { vOS.iWindow.action = 1; window["mouseonborder_top"] = e.clientY - vOS.arr_vWindows[dobj.vWindow_id].top; window["mouseonborder_height"] = e.clientY - vOS.arr_vWindows[dobj.vWindow_id].top - vOS.arr_vWindows[dobj.vWindow_id].window_container.clientHeight; window["mouseonborder_left"] = e.clientX - vOS.arr_vWindows[dobj.vWindow_id].left; window["mouseonborder_width"] = e.clientX - vOS.arr_vWindows[dobj.vWindow_id].left - vOS.arr_vWindows[dobj.vWindow_id].window_container.clientWidth; while (dobj.className != "window_container" && dobj.className != "window_container_inactive") { dobj = dobj.parentNode; } document.onmousemove = vOS.iWindow.border_mousedown; document.onmouseup = function (e) { // Remove the two global events used for resizing // the windows window["mouseonborder"] = 0; document.onmouseup = null; document.onmousemove = null; vOS.iWindow.action = 0; } } } // End class prototype function _vWindow_border_mouseover(e) { if (!e) { e = event; } // !Firefox 3.0 mouseover is triggered after onmouseup when closing a window if(!vOS.arr_vWindows[this.vWindow_id]) return; if (vOS.iWindow.action || vOS.arr_vWindows[this.vWindow_id].state == "maximize" || vOS.arr_vWindows[this.vWindow_id].disabled == 1) { // Do not execute this code if the window is maximized or // when the window is being dragged return; } //Set the mouse to normal :) if(e.type == "mouseout") { window["mouseonborder"] = false; this.style.cursor = "default"; return; } // Save the positions of the borders to a variable, so that // the calculations don't have to be repeated too often _vWindow_border_left = parseInt(this.style.left) + 6 > e.clientX; _vWindow_border_right = parseInt(this.style.left) + this.clientWidth - 5 < e.clientX; _vWindow_border_top = parseInt(this.style.top) + 6 > e.clientY; _vWindow_border_bottom = parseInt(this.style.top) + this.clientHeight - 5 < e.clientY; window["mouseonborder"] = 1; // Determine if the mouse is over a border if (_vWindow_border_left || _vWindow_border_right) { // Left or right (also check if the mouse is on a corner) if (_vWindow_border_top || _vWindow_border_bottom) { if (_vWindow_border_left) { if (_vWindow_border_top) { // Top left window["mouseonborderX"] = "left"; window["mouseonborderY"] = "top"; this.style.cursor = "nw-resize"; } else { // Bottom left window["mouseonborderX"] = "left"; window["mouseonborderY"] = "bottom"; this.style.cursor = "sw-resize"; } } else { if (_vWindow_border_top) { // Top right window["mouseonborderX"] = "right"; window["mouseonborderY"] = "top"; this.style.cursor = "ne-resize"; } else { // Bottom right window["mouseonborderX"] = "right"; window["mouseonborderY"] = "bottom"; this.style.cursor = "se-resize"; } } } else { // Left or right this.style.cursor = "w-resize"; if (_vWindow_border_left) { window["mouseonborderX"] = "left"; window["mouseonborderY"] = ""; } else { window["mouseonborderX"] = "right"; window["mouseonborderY"] = ""; } } return; } else if (_vWindow_border_top || _vWindow_border_bottom) { // Top or bottom this.style.cursor = "n-resize"; if (_vWindow_border_top) { window["mouseonborderY"] = "top"; window["mouseonborderX"] = ""; } else { window["mouseonborderY"] = "bottom"; window["mouseonborderX"] = ""; } return; } else { vOS.iWindow.action = 0; window["mouseonborder"] = false; window["mouseonborderY"] = false; window["mouseonborderX"] = false; window["mouseonborder_stopX"] = 0; window["mouseonborder_stopX1"] = 0 window["mouseonborder_stopY"] = 0; window["mouseonborder_stopY1"] = 0; // Normal cursor style when no border is selected this.style.cursor = "default"; return; } } function _vWindow_border_mousedown(e) { if (!e) { e = window.event; } if (!vOS.iWindow.action) { return; } // Move the borders, depending on which is selected. switch (window["mouseonborderX"]) { case "left": _vWindow_border_mousedown_temp_width = vOS.arr_vWindows[dobj.vWindow_id].width - (e.clientX - vOS.arr_vWindows[dobj.vWindow_id].left) + window["mouseonborder_left"]; if (vOS.arr_vWindows[dobj.vWindow_id].resizable[0] < _vWindow_border_mousedown_temp_width) { window["mouseonborder_stopX1"] = 0; if(window["mouseonborder_stopX"] == 1 && _vWindow_border_mousedown_temp_width < vOS.arr_vWindows[dobj.vWindow_id].width) break; if(!vOS.arr_vWindows[dobj.vWindow_id].setWidth(_vWindow_border_mousedown_temp_width)) { vOS.arr_vWindows[dobj.vWindow_id].setLeft(e.clientX - window["mouseonborder_left"]); window["mouseonborder_stopX"] = 0; } else if(window["mouseonborder_stopX"] == 0) { vOS.arr_vWindows[dobj.vWindow_id].setLeft((e.clientX - window["mouseonborder_left"]) - (vOS.arr_vWindows[dobj.vWindow_id].width - _vWindow_border_mousedown_temp_width)); window["mouseonborder_stop"] = 1; window["mouseonborder_stopX"] = 1; } } else if(window["mouseonborder_stopX1"] == 0) { vOS.arr_vWindows[dobj.vWindow_id].setWidth(vOS.arr_vWindows[dobj.vWindow_id].resizable[0]); vOS.arr_vWindows[dobj.vWindow_id].setLeft((e.clientX - window["mouseonborder_left"]) - (vOS.arr_vWindows[dobj.vWindow_id].width - _vWindow_border_mousedown_temp_width)); window["mouseonborder_stopX1"] = 1; } break; case "right": _vWindow_border_mousedown_temp_width = e.clientX - vOS.arr_vWindows[dobj.vWindow_id].left - (vOS.arr_vWindows[dobj.vWindow_id].window_container.clientWidth - vOS.arr_vWindows[dobj.vWindow_id].width) - window["mouseonborder_width"]; if(window["mouseonborder_stopX"] == 1 && _vWindow_border_mousedown_temp_width < vOS.arr_vWindows[dobj.vWindow_id].width) break; if(vOS.arr_vWindows[dobj.vWindow_id].setWidth(_vWindow_border_mousedown_temp_width)) { window["mouseonborder_stopX"] = 1; } else { window["mouseonborder_stopX"] = 0; } break; } switch (window["mouseonborderY"]) { case "top": if((e.clientY - window["mouseonborder_top"]) <= _vTheme_padding_top) break; _vWindow_border_mousedown_temp_height = vOS.arr_vWindows[dobj.vWindow_id].height - (e.clientY - vOS.arr_vWindows[dobj.vWindow_id].top) + window["mouseonborder_top"]; if (vOS.arr_vWindows[dobj.vWindow_id].resizable[1] < _vWindow_border_mousedown_temp_height) { window["mouseonborder_stopY1"] = 0; if(window["mouseonborder_stopY"] == 1 && _vWindow_border_mousedown_temp_height < vOS.arr_vWindows[dobj.vWindow_id].height) break; if(!vOS.arr_vWindows[dobj.vWindow_id].setHeight(_vWindow_border_mousedown_temp_height)) { vOS.arr_vWindows[dobj.vWindow_id].setTop(e.clientY - window["mouseonborder_top"]); window["mouseonborder_stopY"] = 0; } else if(window["mouseonborder_stopY"] == 0) { vOS.arr_vWindows[dobj.vWindow_id].setTop((e.clientY - window["mouseonborder_top"]) - (vOS.arr_vWindows[dobj.vWindow_id].height - _vWindow_border_mousedown_temp_height)); window["mouseonborder_stopY"] = 1; } } else if(window["mouseonborder_stopY1"] == 0) { vOS.arr_vWindows[dobj.vWindow_id].setHeight(vOS.arr_vWindows[dobj.vWindow_id].resizable[1]); vOS.arr_vWindows[dobj.vWindow_id].setTop((e.clientY - window["mouseonborder_top"]) - (vOS.arr_vWindows[dobj.vWindow_id].height - _vWindow_border_mousedown_temp_height)); window["mouseonborder_stopY1"] = 1; } break; case "bottom": _vWindow_border_mousedown_temp_height = e.clientY - vOS.arr_vWindows[dobj.vWindow_id].top - (vOS.arr_vWindows[dobj.vWindow_id].window_container.clientHeight - vOS.arr_vWindows[dobj.vWindow_id].height) - window["mouseonborder_height"]; if(window["mouseonborder_stopY"] == 1 && _vWindow_border_mousedown_temp_height < vOS.arr_vWindows[dobj.vWindow_id].height) break; if(vOS.arr_vWindows[dobj.vWindow_id].setHeight(_vWindow_border_mousedown_temp_height)) { window["mouseonborder_stopY"] = 1; } else { window["mouseonborder_stopY"] = 0; } break; } } function _vWindow_dblclick(e) { // Get the div on which is clicked if (!e) { var e = window.event; } var targ = vOS.event(e); //Don't change state if you are dragging a window or hit a button twice if (vOS.iWindow.action || targ.buttonName) { return; } // Loop through the objects until you reach the window_container div dobj = targ.parentNode; while (dobj.className != "window_container" && dobj.className != "window_container_inactive") { dobj = dobj.parentNode; } // Check if the user is allow to maximize or normalize the window by double // clicking, by checking if there is a Maximize button on the window if (vOS.arr_vWindows[dobj.vWindow_id].window_maximize.className != "") { if (vOS.arr_vWindows[dobj.vWindow_id].state == 'normal') { vOS.arr_vWindows[dobj.vWindow_id].maximize(); } else { vOS.arr_vWindows[dobj.vWindow_id].normalize(); } } } function _vWindow_move_event(e) { if (vOS.iWindow.action || window["mouseonborder"]) { return; } // Get the div on which is clicked if (!e) { var e = window.event; } var targ = vOS.event(e); // Loop through the objects until you reach the window_container div dobj = targ.parentNode; while (dobj.className != "window_container" && dobj.className != "window_container_inactive") { dobj = dobj.parentNode; } //Make the screen active vOS.arr_vWindows[dobj.vWindow_id].setActive(); //If maximized, do not drag! or if you try to drag with another then the left mouse var mousebutton = e.which ? e.which : e.button; if (mousebutton == 2 || mousebutton == 3) { // Show a maximize, normalize minimize screen var that = vOS.arr_vWindows[dobj.vWindow_id]; var maximize = (that.window_maximize.buttonName == 'maximize_disabled' || (that.window_maximize.buttonName == 'normalize' && that.state != 'minimize')) ? 1 : 0; var normalize = ((that.window_maximize.buttonName == 'maximize_disabled' || that.window_maximize.buttonName == 'maximize') && that.state != 'minimize') ? 1 : 0; var minimize = (that.window_minimize.buttonName == 'minimize_disabled' || that.state == 'minimize') ? 1 : 0; var close = that.window_close.buttonName == 'close_disabled' || that.disabled == 1 ? 1 : 0; var popupMenu = [ [_LANG_["maximize"],"images/icons/icoMaximize.gif","vOS.arr_vWindows[" + dobj.vWindow_id + "].maximize()",maximize], [_LANG_["normalize"], "images/icons/icoNormalize.gif", "vOS.arr_vWindows[" + dobj.vWindow_id + "].normalize()",normalize], [_LANG_["minimize"], "images/icons/icoMinimize.gif", "vOS.arr_vWindows[" + dobj.vWindow_id + "].minimize()",minimize], ["-"], [_LANG_["close"],"images/icons/icoClose.gif","vOS.arr_vApps[" + that.vApp_pid + "].onEvent('" + vOS.arr_vWindows[dobj.vWindow_id].vWindow_name + "', null, 'close');",close] ]; vOS.vMenu.system(e.clientY, e.clientX, popupMenu); vOS.vMenu.menu_click = true; return; } else if (vOS.arr_vWindows[dobj.vWindow_id].state == "maximize" || mousebutton != 1) { return; } vOS.iWindow.action = 1; mouseposition_x = e.clientX - parseInt(dobj.style.left + 0, 10); mouseposition_y = e.clientY - parseInt(dobj.style.top + 0, 10); document.onmousemove = _vWindow_movemouse_event; document.onmouseup = _vWindow_stop_event; return true; } function _vWindow_movemouse_event(e) { if (!e) { e = event; } dobj.style.left = e.clientX - mouseposition_x + "px"; dobj.style.top = e.clientY - mouseposition_y + "px"; } function _vWindow_stop_event(e) { //Check witch button called this event: if (!e) { var e = window.event; } var mousebutton = e.which ? e.which : e.button; if(mousebutton == 1) { //Check the window vOS.arr_vWindows[dobj.vWindow_id].setLeft(parseInt(dobj.style.left + 0, 10)); vOS.arr_vWindows[dobj.vWindow_id].setTop(parseInt(dobj.style.top + 0, 10)); vOS.iWindow.action = 0; // Remove the two global events used for resizing // the windows document.onmouseup = null; document.onmousemove = null; } } function _vWindow_button(e) { // Get the div on which is clicked if (!e) { var e = window.event; } var targ = vOS.event(e); if (targ.buttonName == 'minimize_disabled' || targ.buttonName == 'maximize_disabled' || targ.buttonName == 'close_disabled') { return 0; } // Loop through the objects until you reach the window_container div temp = targ.parentNode; while (temp.className != "window_container" && temp.className != "window_container_inactive") { temp = temp.parentNode; } var mousebutton = e.which ? e.which : e.button; switch (e.type) { case "mouseover": if (vOS.iWindow.button_event == targ.buttonName && vOS.iWindow.button_id == temp.vWindow_id) { targ.className = "window_" + targ.buttonName + "_down"; } else if (!vOS.iWindow.action && vOS.iWindow.button_event == 'a' && vOS.iWindow.button_id == 'a') { if (vOS.activeWindow == temp.vWindow_id) { targ.className = "window_" + targ.buttonName + "_hover"; } else { targ.className = "window_" + targ.buttonName + "_hover_inactive"; } } break; case "mouseout": if (vOS.activeWindow == temp.vWindow_id) { targ.className = "window_" + targ.buttonName; } else { targ.className = "window_" + targ.buttonName + "_inactive"; } if(vOS.iWindow.button_event != "a") vOS.iWindow.action = 0; break; case "mouseup": if (vOS.iWindow.button_event == targ.buttonName && vOS.iWindow.button_id == temp.vWindow_id && mousebutton == 1) { vOS.iWindow.action = 0; targ.className = "window_" + targ.buttonName + "_hover"; // When closing the window, clear the variables which // hold the ID of the window of which the button is // pressed down if (targ.buttonName == "close") { //_vMousedown_button_event = 'a'; //_vMousedown_button_id = 'a'; vOS.arr_vApps[temp.vApp_pid].onEvent(vOS.arr_vWindows[temp.vWindow_id].vWindow_name, null, 'close'); } else { // Execute action corresponding to the pressed button // When maximizing/normalizing, make the window active // targ.buttonName holds the name of the button vOS.arr_vWindows[temp.vWindow_id].setState(targ.buttonName); } } break; case "mousedown": if (mousebutton == 1) { vOS.iWindow.button_id = temp.vWindow_id; vOS.iWindow.button_event = targ.buttonName; vOS.arr_vWindows[temp.vWindow_id].setActive(); targ.className = "window_" + targ.buttonName + "_down"; vOS.iWindow.action = 1; document.onmouseup = function() { vOS.iWindow.button_event = 'a'; vOS.iWindow.button_id = 'a'; document.onmouseup = null; } } break; } } } add_counter(10);