@@ -891,58 +891,75 @@ Turtles.TurtlesView = class {
891891 } ;
892892 } ;
893893
894- /**
895- * Makes clear button by initailising 'CLEARBUTTON' SVG.
896- * Assigns click listener function to call allClear() method.
897- */
894+ const renderClearConfirmation = ( ) => {
895+ const modalContainer = document . getElementById ( "clear-modal-container" ) ;
896+ const clearDropdown = document . getElementById ( "cleardropdown" ) ;
897+ clearDropdown . innerHTML = "" ;
898+
899+ const title = document . createElement ( "div" ) ;
900+ title . innerHTML = `<h2 style="color: #0066FF; font-size: 24px; text-align: left; margin: 0;">${ _ ( "Clear Workspace" ) } </h2>` ;
901+ clearDropdown . appendChild ( title ) ;
902+
903+ const confirmationMessage = document . createElement ( "div" ) ;
904+ confirmationMessage . innerHTML = `<div style="color: #666666; font-size: 16px; margin-bottom: 24px; text-align: left;">
905+ ${ _ ( "Are you sure you want to clear the workspace ?" ) }
906+ </div>` ;
907+ clearDropdown . appendChild ( confirmationMessage ) ;
908+
909+ const confirmButton = document . createElement ( "button" ) ;
910+ confirmButton . innerHTML = _ ( "Confirm" ) ;
911+ confirmButton . style . cssText = `
912+ background-color: #2196F3;
913+ color: white;
914+ border: none;
915+ border-radius: 4px;
916+ padding: 8px 16px;
917+ font-weight: bold;
918+ cursor: pointer;
919+ margin-right: 16px;
920+ ` ;
921+ confirmButton . onclick = ( ) => {
922+ this . activity . _allClear ( ) ;
923+ modalContainer . style . display = "none" ;
924+ } ;
925+ clearDropdown . appendChild ( confirmButton ) ;
926+
927+ const cancelButton = document . createElement ( "button" ) ;
928+ cancelButton . innerHTML = _ ( "Cancel" ) ;
929+ cancelButton . style . cssText = `
930+ background-color: #f1f1f1;
931+ color: black;
932+ border: none;
933+ border-radius: 4px;
934+ padding: 8px 16px;
935+ font-weight: bold;
936+ cursor: pointer;
937+ ` ;
938+ cancelButton . onclick = ( ) => {
939+ modalContainer . style . display = "none" ;
940+ } ;
941+ clearDropdown . appendChild ( cancelButton ) ;
942+
943+ modalContainer . style . display = "flex" ;
944+ } ;
945+
946+
898947 const __makeClearButton = ( ) => {
948+ // Create the Clear button using the existing _makeButton helper
899949 this . _clearButton = _makeButton (
900950 CLEARBUTTON ,
901951 {
902- " name" : "Clean" ,
903- " label" : _ ( "Clean" )
952+ name : "Clean" ,
953+ label : _ ( "Clean" ) ,
904954 } ,
905955 this . _w - 5 - 2 * 55 ,
906956 70 + LEADING + 6
907957 ) ;
908-
909- this . _clearButton . onclick = ( ) => {
910- const clearBox = document . getElementById ( "ClearButton" ) ;
911- const clearContent = document . getElementById ( "ClearContent" ) ;
912- clearContent . innerHTML = _ ( "Confirm" ) ;
913- clearBox . style . visibility = "visible" ;
914- const auxToolbar = docById ( "aux-toolbar" ) ;
915- const clearBtnPosition = auxToolbar . style . display === "block" ? "183px" : "125px" ;
916- clearBox . style . top = clearBtnPosition ;
917- const func = this . activity . _allClear ;
918- clearBox . addEventListener ( "click" , function ( event ) {
919- if ( event . target . id == "clearClose" ) {
920- this . style . visibility = "hidden" ;
921- }
922- else {
923- func ( ) ;
924- clearBox . style . visibility = "hidden" ;
925- if ( auxToolbar . style . display === "block" ) {
926- setTimeout ( ( ) => {
927- docById ( "Grid" ) . style . top = "136px" ;
928- docById ( "Expand" ) . style . top = "136px" ;
929- docById ( "Collapse" ) . style . top = "136px" ;
930- docById ( "Clean" ) . style . top = "136px" ;
931- } , 0 ) ;
932- } else {
933- docById ( "Grid" ) . style . top = "76px" ;
934- docById ( "Expand" ) . style . top = "76px" ;
935- docById ( "Collapse" ) . style . top = "76px" ;
936- docById ( "Clean" ) . style . top = "76px" ;
937- }
938- }
939- } ) ;
940- } ;
941-
942- if ( doCollapse ) {
943- __collapse ( ) ;
944- }
958+
959+ // Assign click listener to the Clear button
960+ this . _clearButton . onclick = renderClearConfirmation ;
945961 } ;
962+
946963
947964 /**
948965 * Makes collapse button by initailising 'COLLAPSEBUTTON' SVG.
0 commit comments