spinner A spinner input form field

  1. Documentation
  2. Change Log

This is my first extension so I made something simple. A spinner form element similar to Java JSpinner

Resources

Documentation

All spinners are based on the SBaseSpinner class.
Spinners can be Numeric Spinners (SNumericSpinner), Text Spinners (STextSpinner) and Time Spinners (STimeSpinner).
Numeric Spinners are divided in integer and float spinners.This depends on the min, max or step data values of the spinner.If one of those is a float the spinner is treated as a float spinner alse as an integer one.
Spinners attributes are:
type string A read only attribute. It's automatically decided depending on the kind of the spinner. The types can be numeric, string or time.
model CActiveRecord A active record model of the attribute associated with the spinner .
attribute string The attribute of the active record model.
name string The name of the form model attribute.
widthinteger The width of the spinner's input field in pixels (default 30).
heightinteger The height of the spinner (default 22).
bgColorstring The background color of the spinner's buttons (default white).
text string A text printed next to the spinner.
delayinteger The delay of the spinner's values update in ms when the mouse is kept pressed on up/down button (Default is 100).Small delays means faster spinner speed
acceleration string Spinner's speed acceleration when the mouse is kept pressed on up/down button.Valid values are none, slow, normal, fast. Default is none
htmlOptionsarray The textbox htmlOptions.You can set the textbox as editable by setting "readonly"=>false
data array An array with the spinners data.Data elements depend on the spinner's type. These elements can be:
All Spinners:
valuemixed The initial value of the spinner.If not provided the first element of a text spinner or the minimum value of numeric/time spinners is used.Also these values are used if the provided value is invalid (out of range in numeric spinners etc).
Text Spinners:
listarray An array with the list of the string type spinner.
Numeric/Time Spinners:
minmixed The minimum value of the spinner.For numeric spinners must be an integer or float (default 0) and for time spinners a string in the form of HH:MM (default 00:00)
maxmixed The maximum value of the spinner.For numeric spinners must be an integer or float (default 0) and for time spinners a string in the form of HH:MM (default 23:59)
stepmixed The step value of the spinner increase and decrease.For numeric spinners must be an integer or float (default 1) and for time spinners an integer in minutes (default 30)
Numeric (Float) Spinners:
precisioninteger The number of decimal digits displayed in the spinner.
<div>
  <p>
    <b>SNumericSpinner:</b>
    <?php $this->widget('application.extensions.spinner.SNumericSpinner',
        array(
        "name"=>"stockInt",
        "data"=>array(
        "min"=>0,
        "max"=>100,
        "value"=>10
        ),
        "width"=>40,
        "text"=>"A numeric (integer) spinner",
        "delay"=>150,
        "acceleration"=>"slow"
        )
    ); ?><br />
      <?php $this->widget('application.extensions.spinner.SNumericSpinner',
        array(
        "name"=>"stockFloat",
        "data"=>array(
        "min"=>0,
        "max"=>100,
        "step"=>0.5,
        "value"=>5.50
        ),
        "width"=>60,
        "precision"=>2,
        "text"=>"A numeric (float) spinner",
        "delay"=>100,
        "acceleration"=>"fast"
        )
    ); ?>
    </p>
  <p>
    <b>STextSpinner:</b>
    <?php $this->widget('application.extensions.spinner.STextSpinner',
        array(
        "name"=>"category",
        "data"=>array(
        "list"=> array("Category A","Category B","Category C"),
        "value"=> 0,
        ),
        "width"=>100,
        "text"=>"A string spinner",
        )
    ); ?>
  </p>
  <p>
    <b>A Time Spinner:</b>
    <?php $this->widget('application.extensions.spinner.STimeSpinner',
        array(
        "name"=>"time",
        "data"=>array(
        "min"=>"00:00",
        "max"=>"23:59",
        "step"=>15,
        "value"=>"12:00"
        ),
        "width"=>60,
        "text"=>"A Time spinner (15 minutes step)",
        "delay"=>100,
        "acceleration"=>"slow"
        )
    ); ?>
  </p>
</div>

Change Log

January 8, 2010
  • Version 1.3.1 Fixed some bugs related with moddels
    Added htmlOptions attribute
July 16, 2009
  • Version 1.3 Spinners are divided in 3 categories now SNumericSpinner for the int and float spinners, STextSpinner for the string spinners and STimeSpinner for the new time spinners.
    If you are upgrading the only thing you have to change is the : $this->widget('application.extensions.spinner.SSpinner' to $this->widget('application.extensions.spinner.SNumericSpinner' if it's a numeric spinenr etc.
May 22, 2009
  • Version 1.2
    You can set the delay of the spinner's value update so you can control the speed of the spinner when the mouse is kept pressed on a button (Spinner's delay parameter)
    Also when button is kept pressed this speed increases (Spinner's acceleration parameter. Values can be "none", "slow" , "normal" and "fast")
May 21, 2009
  • Version 1.1
    When the mouse is pressed on the spinner the numbers increase/decrease faster
    Fixed a bug with I.E. and string type spinners
May 21, 2009
  • Initial release.
0 0
2 followers
1 136 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: User Interface
Tags:
Developed by: Spyros
Created on: May 21, 2009
Last updated: 14 years ago

Downloads

show all