GithubHelp home page GithubHelp logo

jtsage / jquery-mobile-spinbox Goto Github PK

View Code? Open in Web Editor NEW
19.0 4.0 15.0 1015 KB

A simple spinner for number inputs in jQueryMobile

Home Page: http://dev.jtsage.com/jQM-Spinbox/

Python 13.49% JavaScript 43.19% HTML 43.32%

jquery-mobile-spinbox's Introduction

jQuery-Mobile-Spinbox

Spinbox is a jQuery-mobile based number spinner. Full Documentation and Demos

The spinbox control is simple to use - just load the script after jQM, and set your data-type="spinbox". Initial input type can be whatever you want, nothing is changed - min/max are enforced with the buttons.

<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script> 
<script type="text/javascript" src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script>

<!-- Optional Mousewheel support: http://brandonaaron.net/code/mousewheel/docs -->
<script type="text/javascript" src="PATH/TO/YOUR/COPY/OF/jquery.mousewheel.min.js"></script>

<script type="text/javascript" src="http://dev.jtsage.com/cdn/spinbox/latest/jqm-spinbox.min.js"></script>

A typical input:

<div class="ui-field-contain">
    <label for="spin">Input spinner</label>
    <input type="text" data-role="spinbox" name="spin" id="spin" value="60" min="0" max="100" />
</div>

jquery-mobile-spinbox's People

Contributors

adamjimenez avatar amatthews91 avatar jhogervorst avatar jtsage avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

jquery-mobile-spinbox's Issues

drag out and release

Hi, if you are on a desktop machine with a mouse you can start a spin but if you then drag the mouse outside of the + or - button and release the mouse the spin continues.

How can I change min/max value dynamically?

I created spinbox as below.

var spinbox = "

"

$(target).append(spinbox);

Then change min/max/value in other function as below since I would like to change min/max value depends on user's selection.

$('#' + id).spinbox({"dmax": max});
$('#' + id).spinbox({"dmin": min});
$('#' + id).val(val);
$('#' + id).text("refresh");

But UI(+,-) button layout seems something wrong.
When use following function to change max/min value, UI's becomes normal.

$('#' + id).attr("min", min);
$('#' + id).attr("max", max);

However above min/max values are not read after function creation. So it does not work correctly.

As temporary solution, I've modified jqm-spinbox.js as below to read min/max value from attribution when user press spinbox and it works.

_offset: function( obj, direction ) {
var tmp,
w = this,
o = this.options;
if ( !w.disabled ) {
o.dmin = ( typeof w.d.input.attr('min') !== 'undefined' ) ? parseInt(w.d.input.attr('min'),10) : Number.MAX_VALUE * -1; <= Added
o.dmax = ( typeof w.d.input.attr('max') !== 'undefined' ) ? parseInt(w.d.input.attr('max'),10) : Number.MAX_VALUE; <= Added

How can I set min/max value correctly?

Thanks

Horizontal spinner breaks across lines

Hi,
The horizontal spinner on my android smartphone breaks the buttons and text into separate lines. Not occurring on a desktop browser if [more than] enough width is provided.
Added the following line:

$ diff jqm-spinbox.js.1 jqm-spinbox.js
43a44
>                 w.d.input.css({'display':'inline-block'});

"-" button increases amount

The "-" button is now increasing the number in the input field. The Spinbox Demo page is showing this as well.

feature request: step

First of all, thank you very much for this nice plugin.

I have some numeric fields that holds decimal numbers, so the current implementation (for integers) is not working for those fields. Is there any chance to add a "step" attribute to the spinbox so that the plus/minus buttons would increment/decrease the value by e.g. 0.1? I would be more than happy to see this feature.

Non-integer Step

When the step option is set to a non-integer value (ie. 0.5), it seems the step is rounded (ie. 0.5 = 1).

I recommend you move the following code outside of the "if" statement it is currently in:

w.places = w._decimalPlaces(o.step);

Horizontal Spinner is broken

The horizontal Spinner is broken, or at least looks broken.

Tested on:
Firefox 19.0.2 (Ubuntu 12.10)
Chromium 24.0.1312.56 (Ubuntu 12.10)
Android Browser (Android 4.2.2)

spinnerbug

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.