diff --git a/2-ui/4-forms-controls/2-focus-blur/article.md b/2-ui/4-forms-controls/2-focus-blur/article.md index d4348d25b..aabb67eac 100644 --- a/2-ui/4-forms-controls/2-focus-blur/article.md +++ b/2-ui/4-forms-controls/2-focus-blur/article.md @@ -1,25 +1,25 @@ -# Focusing: focus/blur +# ফোকাসিং: focus/blur -An element receives the focus when the user either clicks on it or uses the `key:Tab` key on the keyboard. There's also an `autofocus` HTML attribute that puts the focus onto an element by default when a page loads and other means of getting the focus. +কোন এলিমেন্টে ক্লিক বা কি বোর্ডের `key:Tab` প্রেসের মাধ্যমে নেভিগেশনের সময় ফোকাস ইভেন্ট সংগঠিত হয়। এছাড়াও HTML এ `autofocus` নামের একটি অ্যাট্রিবিউট আছে যা পেজ লোড হওয়ার সময় এলিমেন্টকে ফোকাস করে। -Focusing on an element generally means: "prepare to accept the data here", so that's the moment when we can run the code to initialize the required functionality. +কোন এলিমেন্টে ফোকাস বলতে বুঝায়: "এটির মধ্যে ডাটা যোগ করা সম্ভব", সুতরাং এর দ্বারা বোঝায় এলিমেন্টটিতে ডাটা নেয়ার জন্য প্রস্তুত। -The moment of losing the focus ("blur") can be even more important. That's when a user clicks somewhere else or presses `key:Tab` to go to the next form field, or there are other means as well. +যখন কোন এলিমেন্ট ফোকাস হারায় তখন তাকে বলে ("blur") এবং এটি সম্পর্কেও জেনে রাখা গুরুত্বপূর্ন। যখন ইউজার অন্য কোথাও ক্লিক করে অথবা `key:Tab` প্রেস করে তখন এটি সংগঠিত হয়। -Losing the focus generally means: "the data has been entered", so we can run the code to check it or even to save it to the server and so on. +ফোকাস হারানো দ্বারা বুঝায়: "ডাটা সংযুক্ত করা হয়েছে", সুতরাং আমরা কোডের মাধ্যমে ডাটা যাচাই বাছাই করে তা সার্ভারে পাঠাতে পারি। -There are important peculiarities when working with focus events. We'll do the best to cover them further on. +ফোকাস ইভেন্ট নিয়ে কাজ করার সময় আমরা কিছুটা ব্যতিক্রম ব্যপার দেখব। তবে এই অধ্যায়ে আমরা এই নিয়ে বিস্তারিত আলোচনা করব। -## Events focus/blur +## ইভেন্টস focus/blur -The `focus` event is called on focusing, and `blur` -- when the element loses the focus. +যখন কোন এলিমেন্টকে ফোকাস করা হয় তখন `focus` ইভেন্ট সংগঠিত হয়, এবং যখন এলিমেন্ট ফোকাস হারায় তখন `blur` ইভেন্ট সংগঠিত হয়। -Let's use them for validation of an input field. +চলুন ভ্যালিডেশনের জন্য এদের ব্যবহার করি। -In the example below: +নিচের উদাহরণে: -- The `blur` handler checks if the field has an email entered, and if not -- shows an error. -- The `focus` handler hides the error message (on `blur` it will be checked again): +- `blur` হ্যান্ডেলার চেক করবে ইনপুট কি ইমেইল? যদি না হয় তাহলে এরর দেখাবে। +- আবার অই ফিল্ডে ফোকাস হলে `focus` হ্যান্ডেলার এরর মেসেজ হাইড করবে (এবং যদি ফোকাস হারায় আবারো `blur` হ্যান্ডেলার কল হবে): ```html run autorun height=60 ``` -The order is like this: `1 - 2 - 0`. Normally, `
  • ` does not support focusing, but `tabindex` full enables it, along with events and styling with `:focus`. +নেভিগেশন ক্রমটি হবে: `1 - 2 - 0`। সাধারণত, `
  • ` ফোকাস সাপোর্ট করে না, কিন্তু `tabindex` এর জন্য এটি এখন ফোকাসেবল এর ফলে আমরা ইভেন্ট সমূহ ও ফোকাস স্ট্যাইল `:focus` নিয়েও কাজ করতে পারি। -```smart header="The property `elem.tabIndex` works too" -We can add `tabindex` from JavaScript by using the `elem.tabIndex` property. That has the same effect. +```smart header="`elem.tabIndex` এটিও কাজ করবে" +আমরা জাভাস্ক্রিপ্টের সাহায্যেও `tabindex` প্রপার্টিটি কোন এলিমেন্টে `elem.tabIndex` এভাবে সেট করতে পারি। ``` -## Delegation: focusin/focusout +## ডেলিগেশন: focusin/focusout -Events `focus` and `blur` do not bubble. +`focus` এবং `blur` ইভেন্ট bubbling সাপোর্ট করে না। -For instance, we can't put `onfocus` on the `
    ` to highlight it, like this: +যেমন, আমরা `` এলিমেন্ট হতে `onfocus` এর জন্য এলিমেন্ট কে এভাবে হাইলাইট করতে পারব না: ```html autorun height=80 @@ -167,13 +163,13 @@ For instance, we can't put `onfocus` on the `` to highlight it, like this: ``` -The example above doesn't work, because when user focuses on an ``, the `focus` event triggers on that input only. It doesn't bubble up. So `form.onfocus` never triggers. +এটি কাজ করবে না, কেননা যখন আমরা কোন `` ফোকাস করি, তখন `focus` ইভেন্টটি শুধুমাত্র ঐ ইনপুটে ট্রিগার হয়। এটি bubble হয় না। সুতরাং `form.onfocus` কখনো ট্রিগার হবে না। -There are two solutions. +এটি আমরা দুভাবে সমাধান করতে পারি। -First, there's a funny historical feature: `focus/blur` do not bubble up, but propagate down on the capturing phase. +তবে এদের একটি মজার ফিচার আছে: `focus/blur` যদিও bubbling সাপোর্ট করে না, তবে capturing phase সাপোর্ট করে যার ফলে ইভেন্ট নিচের দিকে যায় -This will work: +এটি কাজ করবে: ```html autorun height=80 @@ -192,11 +188,11 @@ This will work: ``` -Second, there are `focusin` and `focusout` events -- exactly the same as `focus/blur`, but they bubble. +দ্বিতীয়টি হল, `focus/blur` এর পরিবর্তে `focusin` এবং `focusout` ইভেন্টস, এরা bubbling সাপোর্ট করে। -Note that they must be assigned using `elem.addEventListener`, not `on`. +তবে এদের অবশ্যই `elem.addEventListener` এর মাধ্যমে অ্যাসাইন করতে হবে, `on` কাজ করবে না। -So here's another working variant: +সুতরাং আমরা এটি এভাবেও করতে পারি: ```html autorun height=80 @@ -214,12 +210,12 @@ So here's another working variant: ``` -## Summary +## সারাংশ -Events `focus` and `blur` trigger on an element focusing/losing focus. +কোন এলিমেন্ট ফোকাস হলে বা ফোকাস হারালে `focus` এবং `blur` ইভেন্ট ট্রিগার হয়। -Their specials are: -- They do not bubble. Can use capturing state instead or `focusin/focusout`. -- Most elements do not support focus by default. Use `tabindex` to make anything focusable. +কিছু বিশেষ বৈশিষ্ট্য: +- `focus/blur` bubbling সাপোর্ট করে না।এর পরিবর্তে আমরা `focusin/focusout` ব্যবহার করতে পারি। +- বেশিরভাগ এলিমেন্ট ডিফল্টভাবে ফোকাস সাপোর্ট করে না। কোন এলিমেন্টকে ফোকাসেবল করার জন্য আমরা `tabindex` ব্যবহার করি। -The current focused element is available as `document.activeElement`. +কারেন্ট ফোকাস এলিমেন্ট অ্যাক্সেস করতে পারি `document.activeElement` এর মাধ্যমে।