jQuery

How to Write the Simplest Stepper Script
How to Write the Simplest Stepper Script

In this article, we’ll go over the development of a simple stepper script. A stepper is a script that switches between screens/slides by clicking next or previous buttons. The definition may not be ideal, but the example should clearly demonstrate what it is and how it's used.

Personally, I’ve used similar implementations in a few of my past projects. So I thought — why not build a proper boilerplate for future use and publish it here as a blog article?

Including the Libraries

We’ll need:

  1. Bootstrap — to easily style buttons and fonts
  2. Font Awesome — to use three icons (arrow back, up, and forward)
  3. Animate.css — for simple animations (though you can use plain CSS if you prefer)
  4. jQuery — yes, it's time to move away from it and catch events with pure JS, but for now, let’s stick with it 🙂

Here’s how it looks:

<link rel="stylesheet" href="../library/bootstrap-4/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="../library/font-awesome/css/all.min.css">
<link rel="stylesheet" href="../library/animate.css/animate.min.css">
<script src="../library/jquery/dist/jquery.min.js"></script>

read more...

How to make tabs with flexbox and jQuery
How to make tabs with flexbox and jQuery

In this tutorial, we’ll go over how to create SEO-friendly tabs using flex and jQuery.
Our code will be divided into three parts.

HTML Code

First, the HTML code — the foundation we start with:

<div class="tabs" data-tabs="name"> 
<ul class="tab-items"> 
<li class="tab__item active" data-tab-item="tab-item-1"> 
Tab 1 
</li> 
<li class="tab__item" data-tab-item="tab-item-2"> 
Tab 2 
</li> 
<li class="tab__item" data-tab-item="tab-item-3"> 
Tab 3 
</li> 
</ul> 

<div class="tab-contents"> 
<div class="tab__content active" data-tab-content="tab-item-1"> 
Contents of Tab 1 
</div> 
<div class="tab__content" data-tab-content="tab-item-2"> 
Contents of Tab 2 
</div> 
<div class="tab__content" data-tab-content="tab-item-3">
Tab content 3
</div>
</div>
</div>

Roughly speaking, our code consists of three sections:

  1. A wrapper for the tab group, defined by the data attribute data-tabs.
  2. The tabs themselves. Each tab has its own identifier defined by data-tab-item. This value must match one of the data-tab-content attributes in the content blocks.
  3. The tab content blocks, wrapped in a container with the class tab-contents. Each content block has a data-tab-content attribute, which must match one of the tab item values. These attributes are used to map which tab displays which content.

read more...

How to set default parameters for a widget in Yii2
How to set default parameters for a widget in Yii2

To set default parameters for a widget in Yii2, you need to use the dependency injection container.

Example with DatePicker:

Yii::$container -> set('yiijuiDatePicker', [
	'language' => 'en-US',
]);

The first parameter in set is the class name, and the second is the array of parameters to configure. This way, we can preconfigure our widget properly from the start.