Skip to content

Instantly share code, notes, and snippets.

@skelet00r
Last active September 5, 2021 17:32
Show Gist options
  • Select an option

  • Save skelet00r/b20160fced5963a338ab to your computer and use it in GitHub Desktop.

Select an option

Save skelet00r/b20160fced5963a338ab to your computer and use it in GitHub Desktop.

Revisions

  1. James Delibas revised this gist Mar 31, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion spinDirective.js
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@ app.directive('spin', function() {
    input.TouchSpin({
    min: min,
    max: max,
    step: step,
    step: parseInt(step),
    initval: initial,
    forcestepdivisibility : 'none',
    booster : false
  2. James Delibas revised this gist Mar 31, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion spinDirective.js
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@ app.directive('spin', function() {
    input.TouchSpin({
    min: min,
    max: max,
    stepinterval: step,
    step: step,
    initval: initial,
    forcestepdivisibility : 'none',
    booster : false
  3. James Delibas revised this gist Mar 31, 2016. 1 changed file with 21 additions and 0 deletions.
    21 changes: 21 additions & 0 deletions license
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    MIT License

    Copyright (c) [2016] [James Delibas]

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.
  4. James Delibas created this gist Oct 29, 2014.
    11 changes: 11 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    <html>
    <body>

    //Note the value attribute rather than ng-model
    <spin value="someScopeValue" min="1" max="{{someOtherScopeValue}}" step="2" />

    $scope.someScopeValue = 2;
    $scope.someOtherScopeValue = 20;

    </body>
    </html>
    45 changes: 45 additions & 0 deletions spinDirective.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    app.directive('spin', function() {
    return {
    templateUrl: 'spinner.html',
    scope: {
    'value' : "="
    },
    restrict: 'E',
    link: function(scope, element, attrs, ngModel) {
    var min,max,step,value,input,initial;

    element = angular.element(element);

    if(typeof attrs === 'undefined'){
    throw new Error('Spin.js attributes missing');
    } else {
    min = typeof attrs.min !== 'undefined' ? attrs.min : 0;
    max = typeof attrs.max !== 'undefined' ? attrs.max : 999;
    step = typeof attrs.step !== 'undefined' ? attrs.step : 1;

    initial = parseInt(scope.value);

    input = $("input[name='spin']",element);
    input.TouchSpin({
    min: min,
    max: max,
    stepinterval: step,
    initval: initial,
    forcestepdivisibility : 'none',
    booster : false
    });

    input.on('change', function(e){
    scope.value = input.val();

    //hack
    if(!scope.$$phase) {
    scope.$apply();
    }

    });

    }
    }
    };
    });
    1 change: 1 addition & 0 deletions spinner.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    <input type="text" name="spin" class="form-control spinner-input">