Git Product home page Git Product logo

yii2-slider's Introduction

Krajee Logo
yii2-slider
Donate

Stable Version Unstable Version License Total Downloads Monthly Downloads Daily Downloads

An advanced slider input for Yii Framework 2 based on seiyria/bootstrap-slider plugin, which is a fork of the bootstrap-slider by Stefan Petre from eyecon.ru. The slider input offers these advanced features

  • vertical or horizontal orientation of slider
  • setup your minimum and maximum values
  • setup your step increments
  • range selector (multiple handles to control the range)
  • three shapes for handles
  • touch capablity and support for touch devices

Additional enhancements added for this widget (by Krajee):

  • allows to configure slider selection and handle colors.
  • preselected styles to color your slider and handles.
  • automatically trigger change of base field on slider stop to enforce Yii ActiveField validation
  • automatically set plugin options based on base field value (parse array input value for range)
  • automatically disable slider based on disabled/readonly options.

Demo

You can see detailed documentation on usage of the extension.

Latest Release

Refer the CHANGE LOG for details on updates to various releases.

Installation

The preferred way to install this extension is through composer.

NOTE: Check the composer.json for this extension's requirements and dependencies. Read this web tip /wiki on setting the minimum-stability settings for your application's composer.json.

Either run

$ php composer.phar require kartik-v/yii2-slider "dev-master"

or add

"kartik-v/yii2-slider": "dev-master"

to the require section of your composer.json file.

Usage

Slider

use kartik\slider\Slider;
echo Slider::widget([
    'name' => 'slider',
    'sliderColor' => Slider::TYPE_DANGER,
    'handleColor' => Slider::TYPE_DANGER,
    'pluginOptions' => [
        'orientation' => 'horizontal',
        'handle' => 'round',
        'min' => 0,
        'max' => 255,
        'step' => 1
    ],
]); 

License

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

yii2-slider's People

Contributors

arnaud-g1 avatar chabberwock avatar jasonhancock avatar kartik-v avatar katag9k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

yii2-slider's Issues

Slider just display Textbox, not like interface as in demo

Hi,
I downloaded the lastest version of Slider widget.
And I also use a code segment in http://demos.krajee.com/slider:
echo Slider::widget([
'name'=>'rating_1',
'value'=>7,
'sliderColor'=>Slider::TYPE_GREY,
'handleColor'=>Slider::TYPE_DANGER,
'pluginOptions'=>[
'handle'=>'triangle',
'tooltip'=>'always'
]
]);

But I only get a Textbox with the value is 7.
Please help me this.Thanks

Value pluginOptions

Здравствуйте.
При использование слайдера в GridView некорректно заносится предустановленное значение — value для range:

'columns' => [
 [
                    'attribute'=>'payment',
                    'filterType'=>GridView::FILTER_SLIDER,
                    'filterWidgetOptions'=>[
                        'pluginOptions'=>[
                            'value'=>[5,99],
                            'min'=>1,
                            'max'=>1000,
                            'range'=>true
                        ],
                    ]
 ]
]

Для моего случая помогло комментирование 55-ой строки в yii2-slider / slider / Slider.php

$this->pluginOptions['value'] = (!empty($this->value)) ? $this->value : null;

$this->value — это свойство является пустым, а во всех случаях оно заполняется только после инициализации слайдера, следовательно свойство pluginOptions['value'] перезаписывается на null

Not null value if slider is not touched.

Good afternoon.
I'm doing a catalog. Your widget I use for the price filter.
I show the maximum and minimum price for the category of goods.
I pass the filter parameters using POST in the session.
I ran into a problem. When I change the category, price remains from the previous category and goods not found, while I did not touch the slider. Logically, the value of the price field must be empty, since I did not write this value and not touch the slider. But the widget send in POST maximum and minimum value.

`<?php

                echo '<b class="label label-default">$'.$min.'</b> ' . Slider::widget([

                        'model' => $model,

                        'attribute' => 'price',

                        'sliderColor'=>Slider::TYPE_WARNING,

                        'handleColor'=>Slider::TYPE_DANGER,

                        'pluginOptions'=>[

                                'type'=>'text',

                                'handle'=>'custom',

                                'min'=>(int)$min,

                                'max'=>(int)$max,

                                'step'=>50,

                                'range'=>true

                        ],

                    ]) . ' <b class="label label-default">$'.$max.'</b>';

?>`


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Javascript error

When adding any type of slider for instance

'test', 'sliderColor' => Slider::TYPE_DANGER, 'handleColor' => Slider::TYPE_DANGER, 'pluginOptions' => [ 'orientation' => 'horizontal', 'handle' => 'round', 'min' => 0, 'max' => 255, 'step' => 1 ], ]); ?>

I get javascript error: "Uncaught ReferenceError: slider_6c3130ac is not defined "

And on the page source it tries to load it without quatation:

jQuery('#w1').slider(slider_6c3130ac)

Question: Composer warnings

require.kartik-v/yii2-slider : unbound version constraints (dev-master) should be avoided
require.kartik-v/yii2-widget-colorinput : unbound version constraints (*) should be avoided
require.kartik-v/yii2-widget-sidenav : unbound version constraints (*) should be avoided

I am in composer hell this morning. Nothing to do with kartik I trust, but in the course of debugging I find these warnings produced by "composer diagnose".

I don't understand much of composer, but this warning makes sense to me. One day I will run composer update and pull in updates from kartik that have breaking changes for me, isn't that right?

The only way for me to future-proof my updates is to clone (freeze) your repos? Or to never run a blanket composer update? Not sure what people are doing for this. Not sure why kartick has no versioning?

What's the ID of the slider initialized?

Hi

I'm using the Slider plugin for Yii2 and have set 'id' => 'amount-slider' under Slider widget configuration. I also have some JS on my page and am trying to set the slider value with $('#amount-slider').slider('setValue', temp);. This gives me an error:
Error: cannot call methods on slider prior to initialization; attempted to call method 'setValue'.

So I'm asking how is the widget initialized and how can I access it with JS? I got it working for a moment, but then I lost some of my code and cannot figure it out again.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

$ instead of jQuery used in Slider.php

In Slider.php at line #114 there's a reference to jquery through $. But there's no alias $ in the global scope in yii2 by default, so I get something like this:

TypeError: undefined is not a function (evaluating '$('#control-deviation')')

Values not working in range select

echo $form->field($model, 'hours')->widget(Slider::classname(), [
            'value' => '5,7',
            'pluginOptions' => [
                'min' => 0,
                'max' => 24,
                'step' => 1,
                'range' => true
            ]
        ]);

I selected current max value as 7, but it's 24..
git


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Slider setting value to five instead of zero when value is set to zero

I have this slider:

Slider::widget([
'name'=>'currentValue',
'id'=>'currentValue',
'value'=> $currentValueTotal,
'sliderColor'=>Slider::TYPE_GREY,
'handleColor'=>"#66BB6A",
'pluginOptions'=>[
'handle'=>'round',
'min' => 0,
'max' => (($currentValueTotal > 0) ? $currentValueTotal + 15000 : 1000000),
'step' => 10
]
])

If the value is set to zero the slider will instead load with the value of 5. Can you fix this please?

This was also mentioned by another user in the comments of your demo.
http://demos.krajee.com/slider#comment-2020068029

Thanks for your help


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Append/Prepend options

Adding optional 'prepend' and 'append' properties would be nice as it would allow an easier way to do what Usage Example 4 is showing (adding badges before and after the widget).
This would be particularly useful when rendering the slider using Form Builder.

renderAjax issue

If i load the model update view into a modal with renderAjax, then its not shown correctly:

    <-div class="form-group field-usertask-prio_order">
   <-label class="control-label" for="usertask-prio_order">Prio Order
   <-input id="usertask-prio_order" class="form-control ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all" name="UserTask[prio_order]" value="1" data-krajee-slider="slider_8711e32c" type="text">

By default if i open it without renderAjax the same view, it looks fine

Prio Order

What's the issue ?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Formatter property is not passed correctly to plugin

According to the documentation of the Bootstrap Slider plugin at https://github.com/seiyria/bootstrap-slider the formatter property provides a callback function. However, the slider plugin passes the formatter property as a string instead of as an anonymous function. This results in an Uncaught TypeError: this.options.formatter is not a function on the client.

Code to reproduce the bug:

echo \kartik\slider\Slider::widget([
    'name' => 'test',
    'pluginOptions' => [
        'formatter' => 'function(value) { console.log(value); }'
    ],
]);

issue with ie8

Hi,

this line code

if (availableHandleModifiers.indexOf(this.handle) !== -1){

on line 160 of slider.js uses a method not supported on ie8,

if ($.inArray(this.handle, availableHandleModifiers) !== -1){

is more a more compatible solution.

thank you for your nice extension.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

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.