"use strict"; function init_before_move(win_id) { var cursor_mousedown_x = null; var cursor_mousedown_y = null; var active_window = null; var window_obj_width = null; var window_obj_height = null; var window_obj_left = null; var window_obj_top = null; var window_obj_offset_x = null; var window_obj_offset_y = null; var move_x = null; var move_y = null; var active_win_id = null; var window_id = null; //alert("clicking to move"); //alert("Window Clicked ID: "+ win_id); active_win_id = set_active_window(win_id); global_active_window = document.getElementById(active_win_id); //2023-09-22: //instead of assigning default CSS animations for all //CSS properties, assign CSS animations to a window depending //on its action. This function removes CSS animations from //the window, and sets animation to the top, and left. //See file: 'window_2.js' set_animations_move_window(win_id); //2024-07-16: //this function updates the window's details //menu values (if it is currently displayed), //such as Top and Left coords. //see file: 'show_window_details.js' update_details(win_id); //alert(active_win_id); if (global_active_window != null && active_win_id != false) { //alert("Active Window Exists"); if (global_left_mouse_button_down == true) { //alert("Left Mouse Button is Down"); global_window_mode = "move"; //set the window mode to "move" from the default of "standby" if (global_window_mode == "move") { cursor_mousedown_x = global_mouse_coords_x; cursor_mousedown_y = global_mouse_coords_y; window_id = global_active_window.id; if (window_id != null) { active_window = document.getElementById(window_id); if (active_window != null) { get_coords(); window_obj_offset_x = parseFloat(parseFloat(global_mouse_coords_x) - parseFloat(active_window.style.left)); // null; //cursor_x - (elem_left); window_obj_offset_y = parseFloat(parseFloat(global_mouse_coords_y) - parseFloat(active_window.style.top)); // null; //cursor_y - (elem_top); /////window_obj_offset_y = window_obj_offset_y - window.scrollY; ////window_obj_offset_y = window_obj_offset_y; ////window_obj_offset_y = window_obj_offset_y + Math.abs(window.scrollY); ////window_obj_offset_y = parseFloat(window_obj_offset_y * get_pixel_ratio()); // + Math.abs(parseFloat(window.scrollY)); ////window_obj_offset_y = parseFloat(window_obj_offset_y) + Math.abs(window.scrollY); // alert(window_obj_offset_y); active_window.setAttribute("data-cursor_offset_x", window_obj_offset_x); active_window.setAttribute("data-cursor_offset_y", window_obj_offset_y); //set_active_window(active_window.id); // active_window.style.style.boxShadow = "3px 3px 3px #444444"; //update_window_details(window_id); //if window details are showing, update them place_ui_blocking_layer(); //2024-05-18: //set all windows' zIndex property in order. tabbed windows are set //with the lowest zIndex. cascaded windows are set next. minimized //windows are set next. finally, the maximized window(s) are set. //see file: 'window_2.js' ////set_all_window_zIndexes(); ////reset_all_window_zIndexes(); move_all_minimized_windows_to_front(); ////move_all_maximized_windows_to_front(); } } } } } } function move_elem_to_cursor(event) { var is_minimized = null; var offset_x = null; var offset_y = null; var elem = null; var is_maximized = null; var window_state = null; elem = global_active_window; if (elem != null) { is_maximized = global_active_window.getAttribute("data-is_maximized"); } else { return; } if (global_left_mouse_button_down == true) { if (is_maximized == "true") { //alert("Window is maximized - no movement"); return; } if (global_window_mode == "move") { offset_x = parseFloat(elem.getAttribute("data-cursor_offset_x")); offset_y = parseFloat(elem.getAttribute("data-cursor_offset_y")); //Just experimenting with moving the web window while keeping the background image's position to 0px,0px (stuck to the corner of the screen even when the window moves) /* global_active_window.style.backgroundPositionX = parseFloat(parseFloat(global_active_window.style.left) * -1.0) + "px"; global_active_window.style.backgroundPositionY = parseFloat(parseFloat(global_active_window.style.top) * -1.0) + "px"; */ if (offset_x >= 1.0) { //do nothing } else { offset_x = get_win_cursor_offset_x(); global_active_window.setAttribute("data-cursor_offset_x", offset_x); if (offset_x === null) { //offset_x = (((parseFloat(global_active_window.offsetLeft) * 1.0)) - 75); offset_x = 1; return; } } if (offset_y > -1) { //do nothing } else { /*offset_y = get_win_cursor_offset_y(); global_active_window.setAttribute("data-cursor_offset_y", offset_y); if (offset_y == null) { // offset_x = 1; ////return; } */ } if (global_active_window != null) { //2024-07-16: //this function updates the window's details //menu values (if it is currently displayed), //such as Top and Left coords. //see file: 'show_window_details.js' update_details(global_active_window.id); //constraints if (constrain_param_x(offset_x) === true) { global_active_window.style.left = (parseFloat(global_mouse_coords_x) - parseFloat(offset_x)) + "px"; } else { //event.stopPropagation(); //return false; } ////if (constrain_param_y(offset_y) === true) { var doc_height = parseFloat(document.documentElement.scrollHeight); var win_scroll_y = parseFloat(window.scrollY); var scroll_y_offset = doc_height - win_scroll_y; ////alert(scroll_y_offset); ////alert(offset_y); ////alert(window.scrollY); ////global_active_window.style.top = (parseFloat(parseFloat(global_mouse_coords_y) + parseFloat(window.scrollY)) * get_pixel_ratio()) - parseFloat(offset_y) + "px"; ////global_active_window.style.top = ((parseFloat(window.scrollY)) + parseFloat(global_mouse_coords_y)) - (parseFloat(offset_y)) + "px"; //(parseFloat(global_mouse_coords_y) - (parseFloat(offset_y) * 0) + parseFloat(window.scrollY)) + "px"; ////global_active_window.style.top = parseFloat(global_mouse_coords_y / get_pixel_ratio()) + (Math.abs(parseFloat(window.scrollY))) - parseFloat(offset_y * 0) + "px"; //(parseFloat(global_mouse_coords_y) - (parseFloat(offset_y) * 0) + parseFloat(window.scrollY)) + "px"; ////global_active_window.style.top = parseFloat(global_mouse_coords_y) + parseFloat(window.scrollY * 0) + "px"; //(parseFloat(global_mouse_coords_y) - (parseFloat(offset_y) * 0) + parseFloat(window.scrollY)) + "px"; ////global_active_window.style.top = (parseFloat(global_mouse_coords_y) + (parseFloat(window.scrollY))) + "px"; // - parseFloat(offset_y)) + "px"; // + parseFloat(document.documentElement.scrollTop) + "px"; ////global_active_window.style.top = (parseFloat(event.clientY) * parseFloat(get_pixel_ratio())) + (Math.abs(parseFloat(window.scrollY)) * get_pixel_ratio()) + "px"; ////global_active_window.style.top = (parseFloat(event.clientY)) - (parseFloat(offset_y)) + Math.abs(parseFloat(window.scrollY)) + "px"; ////global_active_window.style.top = (parseFloat(event.clientY) / get_pixel_ratio()) + "px"; //global_active_window.style.top = (parseFloat(event.clientY) * get_pixel_ratio()) + "px"; global_active_window.style.top = (((global_mouse_coords_y) - (offset_y))) + "px"; //* get_pixel_ratio()) + "px"; ////global_active_window.style.top = (parseFloat(global_active_window.style.top) - 10) + "px"; ////} ////else { //event.stopPropagation(); //return false; ////} //end constraints //save_cascade_params(global_active_window.id); is_minimized = global_active_window.getAttribute("data-is_minimized"); //alert(is_minimized); window_state = global_active_window.getAttribute("data-window_state"); if (global_active_window.getAttribute("data-is_minimized") == "true") { //don't remember the window's params when the window is minimized; only in a cascaded state } else { if (global_active_window.getAttribute("data-window_state") == "Cascade") { save_window_params(global_active_window.id); } } } //this function places a CSS drop shadow if the minimized window //is moved away from its stack of minimized windows. It's //triggered upon when a minimized window is moved to an //X coordinate that is greater than 0. If left position is 0, //then remove the drop shadow. restore_shadow_when_minimized_window_moves(global_active_window.id); } } else { return; } } function restore_shadow_when_minimized_window_moves(win_id) { var win = null; var win_left = null; ////alert("m00o_coVV!1"); win = document.getElementById(win_id); if (win !== null) { win_left = parseFloat(win.style.left); if (win_left <= 7) { win.style.boxShadow = "none"; // global_inactive_window_dropshadow; } else { win.style.boxShadow = global_active_window_dropshadow; } } } function get_win_cursor_offset_x() { var elem = null; var offset_x = null; var elem_left = null; var cursor_x = null; elem = document.getElementById(global_active_window_id); if (elem != null) { elem_left = parseFloat(elem.style.left); cursor_x = parseFloat(global_mouse_coords_x); offset_x = elem_left - cursor_x; elem.setAttribute("data-cursor_offset_x", offset_x); return offset_x; } else { return null; } } function get_win_cursor_offset_y() { var elem = null; var offset_y = null; var elem_top = null; var cursor_y = null; elem = document.getElementById(global_active_window_id); if (elem != null) { elem_top = parseFloat(elem.style.top); cursor_y = parseFloat(global_mouse_coords_y); offset_y = elem_top - cursor_y; elem.setAttribute("data-cursor_offset_y", offset_y); return offset_y; } else { return null; } } //2024-04-21: //the original function is better, so I'm changing back to it. //I will be modifying it, so it won't be a replica of the original //function: 'constrain_param_x_OLD_2(offset_x)' function constrain_param_x(offset_x) { var r = null; r = false; //restrict top & left movement by setting constrains on upper and left position coords if ((parseFloat(global_mouse_coords_x) - parseFloat(offset_x)) >= ((parseFloat(global_active_window.offsetWidth) * -1.0) + 75)) { r = true; } else { ////global_active_window.style.left = "1px"; global_active_window.style.left = (((parseFloat(global_active_window.offsetWidth) * -1.0)) + 75) + "px"; // event.preventDefault(); // event.stopPropagation(); r = false; } return r; } //2024-04-21: //This function has been revised. its previous code is placed into a function named: //'constrain_param_x_OLD(offset_x)' for references purposes. //the revised function has changed the window's X constraint parameter so that the //window can be moved left beyond the page's 0 pixel location. moving the window will //now have an X constraint that allows the user to move the window farther to the left. //The window will now be constrained to its width minus 100+/- pixels or so. This //allows the window to move to a negative X position determined by the window's //current width.This way, you will be able to have more space for moving windows //around the desktop. function constrain_param_x_TEST(offset_x) { var r = null; r = false; //restrict top & left movement by setting constrains on upper and left position coords if ((parseFloat(global_mouse_coords_x) - parseFloat(offset_x)) >= (((parseFloat(global_active_window.offsetLeft) * -1.0)) + 75)) { r = true; } else { global_active_window.style.left = (((parseFloat(global_active_window.offsetLeft) * -1.0)) + 75) + "px"; ////global_active_window.style.left = "1px"; // event.preventDefault(); // event.stopPropagation(); r = false; } return r; } //2024-04-21: //This function has been revised. Keeping it here for backup purposes in case ever needed //for reference. This function's name has been changed from 'constrain_param_x(offset_x)' to //'constrain_param_x_OLD(offset_x)'. The revised function now has the name 'constrain_param_x(offset_x)'. //changing the window's X constraint parameter so that the window can be moved left beyond //the page's 0 pixel location. moving the window will now have an X constraint that //allows the user to move the window farther to the left. The window will now be constrained //to its width minus 100+/- pixels or so. This allows the window to move to a negative X position //determined by the window's current width. This way, you will be able to have more space //for moving windows around the desktop. function constrain_param_x_OLD_2(offset_x) { var r = null; r = false; //restrict top & left movement by setting constrains on upper and left position coords if ((parseFloat(global_mouse_coords_x) - parseFloat(offset_x)) >= 1.0) { r = true; } else { global_active_window.style.left = "1px"; // event.preventDefault(); // event.stopPropagation(); r = false; } return r; } function constrain_param_y(offset_y) { var r = null; var wih = null; //window inner height var s var bsh = null; //scroll height var max_y = null; var menu_bar_offset_y = null; var menu_bar = null; var screen_y_offset = null; var pixel_ratio = null; var tabbed_window_container_offset_Y = null; //get the ratio of screen pixels to CSS pixels. //This ratio is needed to compensate for any changes //in the page's zoom level. pixel_ratio = get_pixel_ratio(); // if (pixel_ratio === 1.25) { pixel_ratio = 0.8; //if the pixel ratio is 1.25 (100%), then set the ratio to 0.8 } menu_bar = document.getElementById("div_wrapper_0"); if (menu_bar != null) { menu_bar_offset_y = parseFloat(menu_bar.style.height) + 5; } else { menu_bar_offset_y = 27 + 5; } wih = parseFloat(self.innerHeight); bsh = parseFloat(document.body.scrollTop); screen_y_offset = parseFloat(screen.height) - parseFloat(screen.availHeight); //max_y = wih + bsh; // - screen_y_offset; max_y = parseFloat(document.documentElement.scrollHeight) / pixel_ratio; //max_y = (wih + (pixel_ratio * wih)) + bsh; //max_y = max_y - screen_y_offset; //max_y = parseFloat(document.offsetHeight); //max_y = max_y + screen_y_offset; //max_y = max_y - menu_bar_offset_y; //alert(); r = false; //alert(max_y); // alert(menu_bar_offset_y); //2024-04-21: //if there are any tabbed windows preset, then get the Y offset of the //tabbed windows' container. see file: 'common_functions.js'. tabbed_window_container_offset_Y = get_tabbed_window_bar_offset_Y(); if (typeof tabbed_window_container_offset_Y === "number") { if (tabbed_window_container_offset_Y > 0) { //the tabbed window container is numeric. continue. //if the tabbed windows' container exists and has an offset Y value, then at least 1 of the windows must be //tabbed. Tabbed windows have a top-padding value of about 30. Set the Y constraint to the bottom of that //top-padding value. See 'tab_windows.js' tabbed_window_container_offset_Y = (tabbed_window_container_offset_Y + 20); // 59); if (pixel_ratio === 0.8) { //adjust the offset Y parameter of the tabbed windows' container for the page's pixel ratio. tabbed_window_container_offset_Y = (tabbed_window_container_offset_Y / pixel_ratio); } else { //adjust the offset Y parameter of the tabbed windows' container for the page's pixel ratio. tabbed_window_container_offset_Y = (tabbed_window_container_offset_Y * pixel_ratio); } } } else { //the value of the variable isn't a numeric data type. //set the value to 0. tabbed_window_container_offset_Y = 0; } //restrict top & left movement by setting constrains on upper and left position coords if ((parseFloat(global_mouse_coords_y) - parseFloat(offset_y)) >= (menu_bar_offset_y + tabbed_window_container_offset_Y)) { if ((parseFloat(global_mouse_coords_y) - parseFloat(offset_y)) <= (max_y) - 30) { r = true; } else { //global_active_window.style.top = ((max_y) - parseFloat(offset_y) - 18.0) + "px"; global_active_window.style.top = ((max_y) - 29) + "px"; r = false; } } else { global_active_window.style.top = (menu_bar_offset_y + tabbed_window_container_offset_Y) + "px"; // event.preventDefault(); // event.stopPropagation(); r = false; } return r; } /* function move_window_to(x, y, z, t) { if (t != null && t > 0) { } else if (t != null && typeof t != "number") { } } function move_window_x_right(x, elem_id) { var elem = null; var i = null; i = 0; elem = document.getElementById(elem_id); if (elem != null) { if (x != null && typeof x == "number" && x > 0) { //move ++ x elem.style.position = "absolute"; for (i = 0; i < self.innerWidth; i++) { move_x_right(elem, (parseFloat(elem.style.left)), (i * 1.01) + 400); } } else if (x == 0) { //stop return; } else { console.log("No Such Element. See Function move_window_x in move_window.js"); //dunno wtf... return false; } } } function move_window_x_left(x, elem_id) { var elem = null; var i = null; elem = document.getElementById(elem_id); if (elem != null) { if (x != null && typeof x == "number" && Math.abs(x) > 0) { elem.style.position = "absolute"; for (i = parseFloat(elem.style.left); i > 0; i--) { move_x_left(elem, (parseFloat(elem.style.left)), (i * 1.01) + 400); } } else if (x == 0) { //stop return; } else { console.log("No Such Element. See Function move_window_x in move_window.js"); //dunno wtf... return false; } } } function move_x_right(obj, x, delay) { var move_x_px = null; if (typeof parseFloat(x) == "number" && x != null && obj != null) { move_x_px = parseFloat(obj.style.left) + parseFloat(x); global_move_x_delay_timer_id = setTimeout("set_x('" + obj.id + "', " + move_x_px + ");clearTimeout(global_move_x_delay_timer_id);", delay); } else { clearTimeout(global_move_x_delay_timer_id); } } function move_x_left(obj, x, delay) { var move_x_px = null; if (typeof parseFloat(x) == "number" && x != null && obj != null) { move_x_px = parseFloat(obj.style.left) - parseFloat(x); global_move_x_delay_timer_id = setTimeout("set_x('" + obj.id + "', " + move_x_px + ");clearTimeout(global_move_x_delay_timer_id);", delay); } else { clearTimeout(global_move_x_delay_timer_id); } } function set_x(elem_id, x) { var elem = null; elem = document.getElementById(elem_id); //// elem.style.left = parseFloat(x) + "px"; elem.style.left = (parseFloat(elem.style.left) + x) + "px"; return parseFloat(elem.style.left); } */