0 added
0 removed
Original
2026-01-01
Modified
2026-03-09
1
<p>The boss is pleased with your progress so far, and he is now entrusting you with a serious assignment. You need to program a popup window. For the sake of brevity, we will simply refer to this window as a “popup”.</p>
1
<p>The boss is pleased with your progress so far, and he is now entrusting you with a serious assignment. You need to program a popup window. For the sake of brevity, we will simply refer to this window as a “popup”.</p>
2
<blockquote><p>Meow! You have proven that you know how to write code and solve problems. It’s time to promote you from intern to junior employee!</p>
2
<blockquote><p>Meow! You have proven that you know how to write code and solve problems. It’s time to promote you from intern to junior employee!</p>
3
<p>However, there is no time to rest on your laurels. There is a lot of work to do. I want you to breathe some new life into some interfaces and to add user interaction elements.</p>
3
<p>However, there is no time to rest on your laurels. There is a lot of work to do. I want you to breathe some new life into some interfaces and to add user interaction elements.</p>
4
<p>Program a popup window with company contact information. You need an element with the modal class.</p>
4
<p>Program a popup window with company contact information. You need an element with the modal class.</p>
5
<p>When you click on a button with the button-open class, the modal--show class should be added to the popup so that the window will appear on the page.</p>
5
<p>When you click on a button with the button-open class, the modal--show class should be added to the popup so that the window will appear on the page.</p>
6
<p>When you click on a button with the button-close class, the modal-show class should be removed from the window and the popup should close.</p>
6
<p>When you click on a button with the button-close class, the modal-show class should be removed from the window and the popup should close.</p>
7
<p>The popup should close if the user presses the ESC key while the window is open.</p>
7
<p>The popup should close if the user presses the ESC key while the window is open.</p>
8
<p>Let’s get to work.</p>
8
<p>Let’s get to work.</p>
9
</blockquote><p>We first need to understand what we mean by “reviving” the interface?</p>
9
</blockquote><p>We first need to understand what we mean by “reviving” the interface?</p>
10
<p>We already have a ready-made layout and styles. The web designer has already prepared the current states of all the elements. However, currently the page is static. It is just a collection of tags and text. We have a popup with the modal class in the markup. It is not visible on the page. If we were to add the modal--show class to this popup, the window would appear in the interface. However, won’t the user change the classes in the markup himself after all?</p>
10
<p>We already have a ready-made layout and styles. The web designer has already prepared the current states of all the elements. However, currently the page is static. It is just a collection of tags and text. We have a popup with the modal class in the markup. It is not visible on the page. If we were to add the modal--show class to this popup, the window would appear in the interface. However, won’t the user change the classes in the markup himself after all?</p>
11
<p>If you were to picture to yourself how the user interacts with the page, you would get something like the following scenario: We see a button on the page, but the popup is hidden. → The user clicks on the button. → The popup appears on the page..</p>
11
<p>If you were to picture to yourself how the user interacts with the page, you would get something like the following scenario: We see a button on the page, but the popup is hidden. → The user clicks on the button. → The popup appears on the page..</p>
12
<p>The stage where the user clicks on the button is the link connecting the state of the closed and open popups. The interface is now “live” and responds to user actions. An action where a user does something with the page elements (for example, clicks on a button or presses a key) is called an <b>event</b>. In fact, we need to work with events in order to carry out Muffin’s assignment.</p>
12
<p>The stage where the user clicks on the button is the link connecting the state of the closed and open popups. The interface is now “live” and responds to user actions. An action where a user does something with the page elements (for example, clicks on a button or presses a key) is called an <b>event</b>. In fact, we need to work with events in order to carry out Muffin’s assignment.</p>
13
<p>First we will use querySelector to find the popup that we will be working with and to save it as a variable. Then we will check how the window looks when it is open.</p>
13
<p>First we will use querySelector to find the popup that we will be working with and to save it as a variable. Then we will check how the window looks when it is open.</p>
14
<p>We have already explained how querySelector works. If you need to refresh your knowledge, you should check out<a>this assignment</a>from the “Introduction to JavaScript in the browser” chapter. And if you want to refresh your memory about how to add a classList.add() class, then take a look at <a>this assignment</a>.</p>
14
<p>We have already explained how querySelector works. If you need to refresh your knowledge, you should check out<a>this assignment</a>from the “Introduction to JavaScript in the browser” chapter. And if you want to refresh your memory about how to add a classList.add() class, then take a look at <a>this assignment</a>.</p>