Skip to content

Commit 1e78c90

Browse files
authored
Merge pull request #281 from afilahkle/master
Event delegation
2 parents 1a25519 + b0a8632 commit 1e78c90

File tree

6 files changed

+132
-132
lines changed

6 files changed

+132
-132
lines changed

2-ui/2-events/03-event-delegation/1-hide-message-delegate/task.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ importance: 5
22

33
---
44

5-
# Hide messages with delegation
5+
# إخفاء الرسائل باستخدام التفويض
66

7-
There's a list of messages with removal buttons `[x]`. Make the buttons work.
7+
هناك قائمة بالرسائل مع أزرار إزالة `[x]`. اجعل الأزرار تعمل.
88

9-
Like this:
9+
مثل هذا:
1010

1111
[iframe src="solution" height=420]
1212

13-
P.S. Should be only one event listener on the container, use event delegation.
13+
ملاحظة: يجب أن يكون هناك مستمع واحد فقط للحدث على الحاوية ، استخدم تفويض الحدث.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The solution has two parts.
1+
الحل له جزأين.
22

3-
1. Wrap every tree node title into `<span>`. Then we can CSS-style them on `:hover` and handle clicks exactly on text, because `<span>` width is exactly the text width (unlike without it).
4-
2. Set a handler to the `tree` root node and handle clicks on that `<span>` titles.
3+
1. قم بلف كل عنوان عقدة شجرة في `<span>`. ثم يمكننا تصميم CSS عليها على `:hover` والتعامل مع النقرات بالضبط على النص ، لأن عرض `<span>` هو بالضبط عرض النص (على عكس بدونه).
4+
2. قم بتعيين معالج لعقدة الجذر `tree` وتعامل مع النقرات على تلك العناوين `<span>`.

2-ui/2-events/03-event-delegation/2-sliding-tree/task.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ importance: 5
22

33
---
44

5-
# Tree menu
5+
# قائمة الشجرة
66

7-
Create a tree that shows/hides node children on click:
7+
قم بإنشاء شجرة تعرض / تخفي عقد الأطفال عند النقر:
88

99
[iframe border=1 src="solution"]
1010

11-
Requirements:
11+
المتطلبات:
1212

13-
- Only one event handler (use delegation)
14-
- A click outside the node title (on an empty space) should not do anything.
13+
- معالج واحد فقط للحدث (استخدم التفويض)
14+
- يجب ألا يؤدي النقر خارج عنوان العقدة (على مساحة فارغة) إلى أي شيء.

2-ui/2-events/03-event-delegation/3-sortable-table/task.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,42 @@ importance: 4
22

33
---
44

5-
# Sortable table
5+
# جدول قابل للفرز
66

7-
Make the table sortable: clicks on `<th>` elements should sort it by corresponding column.
7+
اجعل الجدول قابلًا للفرز: يجب أن تقوم النقرات على عناصر `<th>` بفرزه حسب العمود المقابل.
88

9-
Each `<th>` has the type in the attribute, like this:
9+
كل `<th>` لديه النوع في السمة ، مثل هذا:
1010

1111
```html
1212
<table id="grid">
1313
<thead>
1414
<tr>
1515
*!*
16-
<th data-type="number">Age</th>
17-
<th data-type="string">Name</th>
16+
<th data-type="number">العمر</th>
17+
<th data-type="string">الاسم</th>
1818
*/!*
1919
</tr>
2020
</thead>
2121
<tbody>
2222
<tr>
2323
<td>5</td>
24-
<td>John</td>
24+
<td>جون</td>
2525
</tr>
2626
<tr>
2727
<td>10</td>
28-
<td>Ann</td>
28+
<td>آن</td>
2929
</tr>
3030
...
3131
</tbody>
3232
</table>
3333
```
3434

35-
In the example above the first column has numbers, and the second one -- strings. The sorting function should handle sort according to the type.
35+
في المثال أعلاه ، يحتوي العمود الأول على أرقام ، والثاني - على سلاسل. يجب أن تتعامل وظيفة الفرز مع الترتيب وفقًا للنوع.
3636

37-
Only `"string"` and `"number"` types should be supported.
37+
يجب دعم أنواع `"string"` و `"number"` فقط.
3838

39-
The working example:
39+
المثال العامل:
4040

4141
[iframe border=1 src="solution" height=190]
4242

43-
P.S. The table can be big, with any number of rows and columns.
43+
ملاحظة: يمكن أن يكون الجدول كبيرًا ، بأي عدد من الصفوف والأعمدة.

2-ui/2-events/03-event-delegation/4-behavior-tooltip/task.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,37 @@ importance: 5
22

33
---
44

5-
# Tooltip behavior
5+
# سلوك التلميح
66

7-
Create JS-code for the tooltip behavior.
7+
قم بإنشاء كود JS لسلوك التلميح.
88

9-
When a mouse comes over an element with `data-tooltip`, the tooltip should appear over it, and when it's gone then hide.
9+
عندما يأتي الماوس فوق عنصر مع `data-tooltip` ، يجب أن يظهر التلميح فوقه ، وعندما يذهب يختفي.
1010

11-
An example of annotated HTML:
11+
مثال على HTML المشروح:
1212
```html
13-
<button data-tooltip="the tooltip is longer than the element">Short button</button>
14-
<button data-tooltip="HTML<br>tooltip">One more button</button>
13+
<button data-tooltip="التلميح أطول من العنصر">زر قصير</button>
14+
<button data-tooltip="تلميح HTML<br>">زر آخر</button>
1515
```
1616

17-
Should work like this:
17+
يجب أن يعمل هكذا:
1818

1919
[iframe src="solution" height=200 border=1]
2020

21-
In this task we assume that all elements with `data-tooltip` have only text inside. No nested tags (yet).
21+
في هذه المهمة نفترض أن جميع العناصر مع `data-tooltip` لديها نص فقط بداخلها. لا توجد علامات متداخلة (بعد).
2222

23-
Details:
23+
التفاصيل:
2424

25-
- The distance between the element and the tooltip should be `5px`.
26-
- The tooltip should be centered relative to the element, if possible.
27-
- The tooltip should not cross window edges. Normally it should be above the element, but if the element is at the page top and there's no space for the tooltip, then below it.
28-
- The tooltip content is given in the `data-tooltip` attribute. It can be arbitrary HTML.
25+
- يجب أن يكون المسافة بين العنصر والتلميح `5px`.
26+
- يجب أن يكون التلميح مركزًا بالنسبة للعنصر ، إذا كان ذلك ممكنًا.
27+
- يجب ألا يتجاوز التلميح حواف النافذة. عادةً ما يكون فوق العنصر ، ولكن إذا كان العنصر في أعلى الصفحة ولا يوجد مساحة للتلميح ، فأدناه.
28+
- يتم إعطاء محتوى التلميح في سمة `data-tooltip`. يمكن أن يكون HTML تعسفيًا.
2929

30-
You'll need two events here:
31-
- `mouseover` triggers when a pointer comes over an element.
32-
- `mouseout` triggers when a pointer leaves an element.
30+
ستحتاج إلى حدثين هنا:
31+
- يُطلق الحدث `mouseover` عندما يأتي مؤشر فوق عنصر.
32+
- يُطلق الحدث `mouseout` عندما يغادر المؤشر عنصرًا.
3333

34-
Please use event delegation: set up two handlers on `document` to track all "overs" and "outs" from elements with `data-tooltip` and manage tooltips from there.
34+
يرجى استخدام تفويض الحدث: قم بإعداد معالجين على `document` لتتبع جميع "overs" و "outs" من العناصر مع `data-tooltip` وإدارة التلميحات من هناك.
3535

36-
After the behavior is implemented, even people unfamiliar with JavaScript can add annotated elements.
36+
بعد تنفيذ السلوك ، يمكن حتى للأشخاص غير الملمين بـ JavaScript إضافة عناصر مُلحقة.
3737

38-
P.S. Only one tooltip may show up at a time.
38+
ملاحظة: قد يظهر تلميح واحد فقط في وقت واحد.

0 commit comments

Comments
 (0)