diff --git a/2-ui/2-events/01-introduction-browser-events/01-hide-other/solution.view/index.html b/2-ui/2-events/01-introduction-browser-events/01-hide-other/solution.view/index.html index 7228a45de..a3835be85 100644 --- a/2-ui/2-events/01-introduction-browser-events/01-hide-other/solution.view/index.html +++ b/2-ui/2-events/01-introduction-browser-events/01-hide-other/solution.view/index.html @@ -7,13 +7,13 @@ - + -
Text
+
متن
diff --git a/2-ui/2-events/01-introduction-browser-events/01-hide-other/task.md b/2-ui/2-events/01-introduction-browser-events/01-hide-other/task.md index 7cb0cb0c9..ada109129 100644 --- a/2-ui/2-events/01-introduction-browser-events/01-hide-other/task.md +++ b/2-ui/2-events/01-introduction-browser-events/01-hide-other/task.md @@ -2,10 +2,10 @@ importance: 5 --- -# Hide on click +# مخفی کردن در صورت کلیک -Add JavaScript to the `button` to make `
` disappear when we click it. +یک کد جاوا‌اسکریپتی به `button` اضافه کنید تا `
` در زمان کلیک شدن مخفی شود. -The demo: +دمو: [iframe border=1 src="solution" height=80] diff --git a/2-ui/2-events/01-introduction-browser-events/02-hide-self-onclick/solution.md b/2-ui/2-events/01-introduction-browser-events/02-hide-self-onclick/solution.md index cded5b622..b69020042 100644 --- a/2-ui/2-events/01-introduction-browser-events/02-hide-self-onclick/solution.md +++ b/2-ui/2-events/01-introduction-browser-events/02-hide-self-onclick/solution.md @@ -1,5 +1,5 @@ -Can use `this` in the handler to reference "the element itself" here: +برای دسترسی به "خود عنصر" می‌توانیم درون کنترل‌کننده از `this` استفاده کنیم: ```html run height=50 - + ``` diff --git a/2-ui/2-events/01-introduction-browser-events/02-hide-self-onclick/task.md b/2-ui/2-events/01-introduction-browser-events/02-hide-self-onclick/task.md index 9ee8f18e1..15b1d6404 100644 --- a/2-ui/2-events/01-introduction-browser-events/02-hide-self-onclick/task.md +++ b/2-ui/2-events/01-introduction-browser-events/02-hide-self-onclick/task.md @@ -2,11 +2,11 @@ importance: 5 --- -# Hide self +# مخفی کردن خود عنصر -Create a button that hides itself on click. +یک button بسازید که وقتی کلیک می‌شود خودش را مخفی کند. ```online -Like this: - +مثل این: + ``` diff --git a/2-ui/2-events/01-introduction-browser-events/03-which-handlers-run/solution.md b/2-ui/2-events/01-introduction-browser-events/03-which-handlers-run/solution.md index d569f0e4d..98cf4fc68 100644 --- a/2-ui/2-events/01-introduction-browser-events/03-which-handlers-run/solution.md +++ b/2-ui/2-events/01-introduction-browser-events/03-which-handlers-run/solution.md @@ -1,8 +1,8 @@ -The answer: `1` and `2`. +جواب: `1` و `2`. -The first handler triggers, because it's not removed by `removeEventListener`. To remove the handler we need to pass exactly the function that was assigned. And in the code a new function is passed, that looks the same, but is still another function. +کنترل‌کننده اول اجرا می‌شود زیرا توسط `removeEventListener` حذف نمی‌شود. برای حذف کنترل‌کننده باید دقیقا خود تابعی که استفاده کردیم را به ورودی بدهیم. و در این کد یک تابع جدید به عنوان ورودی استفاده شده که فقط شبیه هستند، اما یک تابع نیستند. -To remove a function object, we need to store a reference to it, like this: +برای حذف یک شئ تابع باید آنرا در یک متغیر به عنوان مرجع ذخیره کنیم. مانند: ```js function handler() { @@ -13,4 +13,4 @@ button.addEventListener("click", handler); button.removeEventListener("click", handler); ``` -The handler `button.onclick` works independently and in addition to `addEventListener`. +کنترل‌کننده `button.onclick` جدا و علاوه بر `addEventListener` کار می‌کند. diff --git a/2-ui/2-events/01-introduction-browser-events/03-which-handlers-run/task.md b/2-ui/2-events/01-introduction-browser-events/03-which-handlers-run/task.md index f8cd75d5a..653c96852 100644 --- a/2-ui/2-events/01-introduction-browser-events/03-which-handlers-run/task.md +++ b/2-ui/2-events/01-introduction-browser-events/03-which-handlers-run/task.md @@ -2,11 +2,11 @@ importance: 5 --- -# Which handlers run? +# کدام کنترل‌کننده اجرا شود؟ -There's a button in the variable. There are no handlers on it. +یک دکمه درون متغیر ذخیره شده. ولی هیچ کنترل‌کننده به آن اختصاص نیافته. -Which handlers run on click after the following code? Which alerts show up? +با توجه به کد زیر، کدام کنترل‌کننده بعد از کلیک اجرا می‌شود؟ کدوم پیغام نمایش داده می‌شود؟ ```js no-beautify button.addEventListener("click", () => alert("1")); diff --git a/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/solution.md b/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/solution.md index b04cb8231..3f78573aa 100644 --- a/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/solution.md +++ b/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/solution.md @@ -1,11 +1,11 @@ -First we need to choose a method of positioning the ball. +اول نیاز داریم که روش قرارگیری توپ را انتخاب کنیم. -We can't use `position:fixed` for it, because scrolling the page would move the ball from the field. +نمی‌توانیم از `position:fixed` به این منظور استفاده کنیم. چون اسکرول کردن صفحه باید توپ را در زمین جابجا کند. -So we should use `position:absolute` and, to make the positioning really solid, make `field` itself positioned. +پس باید از `position:absolute` استفاده کنیم و برای اینکه از موقعیت توپ مطمئن شویم، روش قرارگیری `field` را نیز تنظیم می‌کنیم. -Then the ball will be positioned relatively to the field: +در این صورت، توپ نسبت به زمین قرار گرفته می‌شود: ```css #field { @@ -16,36 +16,36 @@ Then the ball will be positioned relatively to the field: #ball { position: absolute; - left: 0; /* relative to the closest positioned ancestor (field) */ + left: 0; /* نسبت به نزدیکترین والدی که موقعیت آن تنظیم شده (field) */ top: 0; - transition: 1s all; /* CSS animation for left/top makes the ball fly */ + transition: 1s all; /* انیمیشن‌های CSS برای چپ/بالا، انگار توپ پرتاب شده */ } ``` -Next we need to assign the correct `ball.style.left/top`. They contain field-relative coordinates now. +حال باید مقدارهای درستی به `ball.style.left/top` بدهیم. این مقدار نسبت به زمین خواهد بود. -Here's the picture: +مانند این تصویر: ![](move-ball-coords.svg) -We have `event.clientX/clientY` -- window-relative coordinates of the click. +ما `event.clientX/clientY` را داریم، مختصات اشاره‌گر موس نسبت به پنجره. -To get field-relative `left` coordinate of the click, we can substract the field left edge and the border width: +برای اینکه مقدار `left` مختصات اشاره‌گر موس در زمان کلیک را نسبت به زمین بگیریم، باید چپ زمین و عرض حاشیه را از هم کم کنیم. ```js let left = event.clientX - fieldCoords.left - field.clientLeft; ``` -Normally, `ball.style.left` means the "left edge of the element" (the ball). So if we assign that `left`, then the ball edge, not center, would be under the mouse cursor. +معمولا، `ball.style.left` به معنی "حاشیه چپ عنصر" (توپ) است. پس اگر که به `left` مقدار دهیم، پس گوشیه توپ، و نه وسط آن زیر موس قرار می‌گیرد. -We need to move the ball half-width left and half-height up to make it center. +باید که توپ را به اندازه نصف طولش به چپ، و به اندازه نصف ارتفاع آن به بالا ببریم تا وسط قرار گیرد. -So the final `left` would be: +پس مقدار نهایی `left` به صورت زیر است: ```js let left = event.clientX - fieldCoords.left - field.clientLeft - ball.offsetWidth/2; ``` -The vertical coordinate is calculated using the same logic. +مختصات عمودی نیز با همین منطق محاسبه می‌شود. -Please note that the ball width/height must be known at the time we access `ball.offsetWidth`. Should be specified in HTML or CSS. +لطفا توجه کنید که طول/ارتفاع توب باید در زمانی که به `ball.offsetWidth` معلوم باشد. پس باید در HTML یا CSS آنها را مقدار دهی کنیم. diff --git a/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/solution.view/index.html b/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/solution.view/index.html index 3ebe8739e..c25185051 100644 --- a/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/solution.view/index.html +++ b/2-ui/2-events/01-introduction-browser-events/04-move-ball-field/solution.view/index.html @@ -27,7 +27,7 @@ - Click on a field to move the ball there. + روی زمین کلیک کنید تا توپ حرکت کند.
@@ -39,29 +39,29 @@ diff --git a/2-ui/2-events/01-introduction-browser-events/06-hide-message/source.view/index.html b/2-ui/2-events/01-introduction-browser-events/06-hide-message/source.view/index.html index 07adbf985..de645fe2c 100644 --- a/2-ui/2-events/01-introduction-browser-events/06-hide-message/source.view/index.html +++ b/2-ui/2-events/01-introduction-browser-events/06-hide-message/source.view/index.html @@ -8,21 +8,21 @@ - The button code (may need to adjust CSS): + کد دکمه (ممکن است که نیاز به تغییر CSS داشته باشید):
-

Horse

-

The horse is one of two extant subspecies of Equus ferus. It is an odd-toed ungulate mammal belonging to the taxonomic family Equidae. The horse has evolved over the past 45 to 55 million years from a small multi-toed creature, Eohippus, into the large, single-toed animal of today.

+

اسب

+

اسب یا باره یکی از دو زیرگونه‌های اسب وحشی است. این جانور پستاندار و فَردسُم است و به تیره اسبیان تعلق دارد. فرگشت اسب از ۴۵ تا ۵۵ میلیون سال پیش به این سو آغاز شده‌است، گذشتهٔ اسب‌های بزرگ و تک‌سم امروزی به جانورانی کوچک‌جثه و چندسم بازمی‌گردد.

-

Donkey

-

The donkey or ass (Equus africanus asinus) is a domesticated member of the horse family, Equidae. The wild ancestor of the donkey is the African wild ass, E. africanus. The donkey has been used as a working animal for at least 5000 years.

+

الاغ

+

الاغ یا درازگوش جانوری اهلی از خانوادهٔ اسبیان است. خر وحشی آفریقایی جد وحشی خرهای اهلی است. این حیوان حدود ۵۰۰۰ سال پیش در مصر یا بین‌النهرین اهلی شد. انسان‌ها از این حیوان بیشتر برای بارکشی استفاده می‌کنند.

-

Cat

-

The domestic cat (Latin: Felis catus) is a small, typically furry, carnivorous mammal. They are often called house cats when kept as indoor pets or simply cats when there is no need to distinguish them from other felids and felines. Cats are often valued by humans for companionship and for their ability to hunt vermin. +

گربه

+

گُربه یک گونهٔ اهلی گوشت‌خوار از پستانداران است که جثهٔ کوچکی دارد. گربه تنها گونهٔ اهلی در خانوادهٔ گربه‌ایان است و برای تمیز دادن آن از اعضای وحشی این خانواده، اغلب از آن تحت عنوان گربهٔ خانگی یاد می‌شود.

diff --git a/2-ui/2-events/01-introduction-browser-events/06-hide-message/task.md b/2-ui/2-events/01-introduction-browser-events/06-hide-message/task.md index 152cf41fe..48a1303ba 100644 --- a/2-ui/2-events/01-introduction-browser-events/06-hide-message/task.md +++ b/2-ui/2-events/01-introduction-browser-events/06-hide-message/task.md @@ -2,12 +2,12 @@ importance: 5 --- -# Add a closing button +# دکمه بسته‌شدن اضافه کنید -There's a list of messages. +لیستی از پیام‌ها موجود است. -Use JavaScript to add a closing button to the right-upper corner of each message. +با استفاده از جاوااسکریپت یک دکمه بستن به گوشه بالا راست هر پیام اضافه کنید. -The result should look like this: +نتیجه باید چنین چیزی باشد: [iframe src="solution" height=450] diff --git a/2-ui/2-events/01-introduction-browser-events/07-carousel/solution.md b/2-ui/2-events/01-introduction-browser-events/07-carousel/solution.md index 1c6b52cea..175ba07c3 100644 --- a/2-ui/2-events/01-introduction-browser-events/07-carousel/solution.md +++ b/2-ui/2-events/01-introduction-browser-events/07-carousel/solution.md @@ -1,17 +1,17 @@ -The images ribbon can be represented as `ul/li` list of images ``. +نوار عکس‌ها را می‌توان به عنوان یک لیست `ul/li‍` شامل عکس‌ها `` نشان داد. -Normally, such a ribbon is wide, but we put a fixed-size `
` around to "cut" it, so that only a part of the ribbon is visible: +معمولا، چنین نوار عریض است، اما ما یک `
` با سیز ثایت دور قرار می‌دهیم تا آنرا "ببریم". با اینکار فقط قستمی از آن نمایش داده می‌شود: ![](carousel1.svg) -To make the list show horizontally we need to apply correct CSS properties for `
  • `, like `display: inline-block`. +برا اینکه لیست را افقی نمایش دهیم باید خصوصیات CSS‌ درستی را برای `
  • ` نسبت دهیم. مثلا `display: inline-block`. -For `` we should also adjust `display`, because by default it's `inline`. There's extra space reserved under `inline` elements for "letter tails", so we can use `display:block` to remove it. +برای `` باید `display` را تغییر دهیم. چرا که مقدار پیشفرض آن `inline` است. فضای رزورشده اضافی زیر عناصر `inline` قرار دارد (برای "letter tail" ها)، برای حذف آن می‌توانیم از `display:block` کمک بگیریم. -To do the scrolling, we can shift `
      `. There are many ways to do it, for instance by changing `margin-left` or (better performance) use `transform: translateX()`: +برای پیمایش کردن، می‌توانیم `
        ` را تغییر مکان دهیم. راه‌های زیادی برای این کار وجود دارد. برای مثال عوض کردن مقدار `margin-left` یا (برای کارایی بالاتر) استفاده از `transform: translateX()‍`: ![](carousel2.svg) -The outer `
        ` has a fixed width, so "extra" images are cut. +‍`
        ` بیرونی طول ثابتی دارد. پس عکس‌های "اضافه" برش داده می‌شوند. -The whole carousel is a self-contained "graphical component" on the page, so we'd better wrap it into a single `