Giter Site home page Giter Site logo

andriisimon / yii2-widget-switchery Goto Github PK

View Code? Open in Web Editor NEW

This project forked from toxor88/yii2-widget-switchery

0.0 0.0 0.0 6 KB

iOS Switchery Slider (http://abpetkov.github.io/switchery/)

License: BSD 3-Clause "New" or "Revised" License

PHP 100.00%

yii2-widget-switchery's Introduction

yii2-widget-switchery

Latest Stable Version License Total Downloads Monthly Downloads Daily Downloads

iOS Switchery Slider (http://abpetkov.github.io/switchery/)

Installation

The preferred way to install this extension is through composer. Check the composer.json for this extension's requirements and dependencies.

To install, either run

$ php composer.phar require toxor88/yii2-widget-switchery "*"

or add

"toxor88/yii2-widget-switchery": "*"

to the require section of your composer.json file.

Demo

You can refer detailed documentation and demos on usage of the extension.

Usage

use toxor88\switchery\Switchery;
use yii\web\JsExpression;

// usage without model
echo '<label>Can do something?</label>';
echo Switchery::widget([
	'name' => 'can_do_something', 
	'clientOptions' => [
		'color'              => '#64bd63',
		'secondaryColor'     => '#dfdfdf',
        'jackColor'          => '#fff',
        'jackSecondaryColor' => null,
        'className'          => 'switchery',
        'disabled'           => false,
        'disabledOpacity'    => 0.5,
        'speed'              => '0.1s',
        'size'               => 'default',
	],
    'clientChangeEvent' => new JsExpression('function() {
        alert("checked: " + this.checked);
    }'),
]);

// usage with model
$form->model($model, 'attribute')->widget(Switchery::className(), [ /* widget options... */ ]);

// if you use the defualt ActiveField template, there can be multiple labels. To avoid it use:
// the label displays after the slider:
$form->model($model, 'attribute')->widget(Switchery::className(), [ /* widget options... */ ])->label(false);

// the label displays before the slider:
$form->model($model, 'attribute')->widget(Switchery::className(), [ 'options' => 'label' => null ])->label('label text or inherited from model');

License

yii2-widget-switchery is released under the BSD 3-Clause License. See the bundled LICENSE for details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.