爱游戏官网: Digital Input Optimization Demo

Github project page Download

Designed for sports enthusiasts, this Bootstrap digital input component supports mouse wheel and arrow key operations for enhanced usability.

Core Feature Showcase

<input id="demo0"
       type="text"
       value="55"
       name="demo0"
       data-bts-min="0"
       data-bts-max="100"
       data-bts-init-val=""
       data-bts-step="1"
       data-bts-decimal="0"
       data-bts-step-interval="100"
       data-bts-force-step-divisibility="round"
       data-bts-step-interval-delay="500"
       data-bts-prefix=""
       data-bts-postfix=""
       data-bts-prefix-extra-class=""
       data-bts-postfix-extra-class=""
       data-bts-booster="true"
       data-bts-boostat="10"
       data-bts-max-boosted-step="false"
       data-bts-mousewheel="true"
       data-bts-button-down-class="btn btn-default"
       data-bts-button-up-class="btn btn-default"
        />
<script>
    $("input[name='demo0']").TouchSpin({
    });
</script>
<input id="demo_vertical" type="text" value="" name="demo_vertical">
<script>
    $("input[name='demo_vertical']").TouchSpin({
      verticalbuttons: true
    });
</script>
<input id="demo_vertical2" type="text" value="" name="demo_vertical2">
<script>
    $("input[name='demo_vertical2']").TouchSpin({
      verticalbuttons: true,
      verticalupclass: 'glyphicon glyphicon-plus',
      verticaldownclass: 'glyphicon glyphicon-minus'
    });
</script>
<input id="demo1" type="text" value="55" name="demo1">
<script>
    $("input[name='demo1']").TouchSpin({
        min: 0,
        max: 100,
        step: 0.1,
        decimals: 2,
        boostat: 5,
        maxboostedstep: 10,
        postfix: '%'
    });
</script>
<form class="form-horizontal" role="form">
    <div class="form-group">
        <label for="demo2" class="col-md-5 control-label">Example:</label> <input id="demo2" type="text" value="0" name="demo2" class="col-md-7 form-control">
    </div>
</form>

<script>
    $("input[name='demo2']").TouchSpin({
        min: -1000000000,
        max: 1000000000,
        stepinterval: 50,
        maxboostedstep: 10000000,
        prefix: '$'
    });
</script>
<input id="demo3" type="text" value="" name="demo3">
<script>
    $("input[name='demo3']").TouchSpin();
</script>

When the input box does not have a value attribute set, the initval configuration item will take effect, ensuring correct loading of the initial value.

<input id="demo3_21" type="text" value="" name="demo3_21">
<script>
    $("input[name='demo3_21']").TouchSpin({
        initval: 40
    });
</script>
<input id="demo3_22" type="text" value="33" name="demo3_22">
<script>
    $("input[name='demo3_22']").TouchSpin({
        initval: 40
    });
</script>

You can easily adjust the size of the number controller by adding input-sm or input-lg classes, or by placing it within an input-group of the corresponding size, to adapt to different layouts.

<input id="demo4" type="text" value="" name="demo4" class="input-sm">
<script>
    $("input[name='demo4']").TouchSpin({
        postfix: "a button",
        postfix_extraclass: "btn btn-default"
    });
</script>
<div class="input-group input-group-lg">
    <input id="demo4_2" type="text" value="" name="demo4_2" class="form-control input-lg">
</div>
<script>
    $("input[name='demo4_2']").TouchSpin({
        postfix: "a button",
        postfix_extraclass: "btn btn-default"
    });
</script>
<div class="input-group">
    <input id="demo5" type="text" class="form-control" name="demo5" value="50">
    <div class="input-group-btn">
        <button type="button" class="btn btn-default">Action</button>
        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
            <span class="caret"></span>
            <span class="sr-only">Toggle Dropdown</span>
        </button>
        <ul class="dropdown-menu pull-right" role="menu">
            <li><a href="#">Action</a></li>
            <li><a href="#">Another action</a></li>
            <li><a href="#">Something else here</a></li>
            <li class="divider"></li>
            <li><a href="#">Separated link</a></li>
        </ul>
    </div>
</div>
<script>
    $("input[name='demo5']").TouchSpin({
        prefix: "pre",
        postfix: "post"
    });
</script>
$("input[name='demo6']").TouchSpin({
    buttondown_class: "btn btn-link",
    buttonup_class: "btn btn-link"
});
$("input[name='demo7']").TouchSpin({
    replacementval: 10
});

Interactive Feature Demo

 

Configuration Options Explained

Option Default Value Description
initval "" Applied when the input box does not have a value attribute set. An empty string indicates that the value is empty upon initialization.
replacementval "" Applied when the user leaves it blank or enters non-numeric characters. An empty string means the value will not be replaced.
min 0 Minimum Value
max 100 Maximum Value
step 1 Step increment/decrement
forcestepdivisibility 'round' Method to force values to be divisible by the step:
decimals 0 Decimal places
stepinterval 100 Spinner refresh interval (milliseconds)
stepintervaldelay 500 Delay before spinner starts rotating (milliseconds)
verticalbuttons false Enable traditional up/down buttons
verticalupclass 'glyphicon glyphicon-chevron-up' Class for the down button when vertical button mode is enabled
verticaldownclass 'glyphicon glyphicon-chevron-down' Class for the up button when vertical button mode is enabled
prefix "" Prefix text for the input box
postfix "" Suffix text for the input box
prefix_extraclass "" Additional classes for the prefix
postfix_extraclass "" Additional classes for the suffix
booster true When enabled, holding down the button will continuously accelerate the spinner speed
boostat 10 Steps per acceleration
maxboostedstep false Maximum steps during acceleration
mousewheel true Enable mouse wheel to change input value
buttondown_class 'btn btn-default' Class for the down button
buttonup_class 'btn btn-default' Class for the up button
buttondown_txt '-' Content within the down button
buttonup_txt '+' Content within the up button

Event Trigger Description

Triggered Events

The component will trigger the following key events, facilitating your customization:

Event Description
change Triggered when the value is changed by a button (not triggered when the spinner reaches the limits set by max or min).
touchspin.on.startspin Triggered when the spinner starts rotating upwards or downwards.
touchspin.on.startupspin Triggered when the spinner starts rotating upwards.
touchspin.on.startdownspin Triggered when the spinner starts rotating downwards.
touchspin.on.stopspin Triggered when the spinner stops rotating.
touchspin.on.stopupspin Triggered when the spinner stops rotating upwards.
touchspin.on.stopdownspin Triggered when the spinner stops rotating downwards.
touchspin.on.min Triggered when the value reaches the preset maximum value.
touchspin.on.max When the value reaches the preset minimum value, the system will automatically perform a predefined operation.

Callable Methods

You can actively call component functions in the following ways:

Example Usage: $("input").trigger("touchspin.uponce"); $("input").trigger("touchspin.updatesettings", {max: 1000});

Event Description
touchspin.updatesettings updatesettings: Updates any settings of an initialized TouchSpin instance.
touchspin.uponce Increase value by one step
touchspin.downonce Decrease value by one step
touchspin.startupspin Start spinner upwards
touchspin.startdownspin Start spinner downwards
touchspin.stopspin Stop spinner

Get Support

Get it now. Welcome to report issues and suggestions via the GitHub issue tracker, or contact us through official channels!

爱游戏官网 Technology Co., Ltd.Excellence in every detailPhone:+86 177 9824 1616Email:[email protected]824 Zhangjiang Road, Pudong New Area, Shanghai