Skip to content

Commit

Permalink
Added decimalsDelimiter, buttonDownShow, buttonUpShow to options.
Browse files Browse the repository at this point in the history
Removed typings, instead types are now loaded from npm.
Typescript version bumped to latest.
  • Loading branch information
nkovacic committed Oct 16, 2017
1 parent 9dee43b commit c328b1c
Show file tree
Hide file tree
Showing 22 changed files with 247 additions and 157 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,17 @@ OR
Available options:
```javascript
interface ITouchSpinOptions {
buttonDownClass?: string;
buttonDownShow?: boolean;
buttonDownTxt?: string;
buttonUpClass?: string;
buttonUpShow?: boolean;
buttonUpTxt?: string;
min?: number;
max?: number;
step?: number;
decimals?: number;
decimalsDelimiter?: string;
stepInterval?: number;
forceStepDivisibility?: string; // none | floor | round | ceil
stepIntervalDelay?: number;
Expand All @@ -102,10 +109,6 @@ interface ITouchSpinOptions {
prefixExtraClass?: string;
postfixExtraClass?: string;
mousewheel?: boolean;
buttonDownClass?: string;
buttonUpClass?: string;
buttonDownTxt?: string;
buttonUpTxt?: string;
}
```

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-touchspin",
"version": "1.4.6",
"version": "1.5.0",
"authors": [
"Niko Kovacic <niko.kovacic2@gmail.com>"
],
Expand Down
18 changes: 14 additions & 4 deletions dev/controllers/main.controller.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import * as angular from 'angular';
import { ITouchSpinOptions } from '../../src/angular-touchspin';

export class MainController {
public touchSpinOptions: angular.touchspin.ITouchSpinOptions;
public touchSpinVerticalOptions: angular.touchspin.ITouchSpinOptions;
public touchSpinOptions: ITouchSpinOptions;
public touchSpinDelimiterOptions: ITouchSpinOptions;
public touchSpinVerticalOptions: ITouchSpinOptions;
public currency: number;
public currency1: number;
public currency2: number;
public currency3: number;
public touchSpinDisabled: boolean;

constructor() {
this.currency = 10;
this.currency1 = 20;
this.currency2 = 30;
this.currency3 = 50;
this.touchSpinDisabled = false;
this.touchSpinOptions = {
decimals: 2,
Expand All @@ -19,6 +25,10 @@ export class MainController {
//postfix: '%'
};

this.touchSpinDelimiterOptions = angular.extend({}, this.touchSpinOptions, <ITouchSpinOptions>{
decimalsDelimiter: ','
});

this.touchSpinVerticalOptions = {
decimals: 2,
max: 100,
Expand All @@ -29,7 +39,7 @@ export class MainController {
};
}

onTouchSpinChange(value: number) {
console.log(value)
onTouchSpinChange(oldValue: number, value: number) {
console.log('OldValue: ' + oldValue + ', newValue: ' + value);
}
}
11 changes: 10 additions & 1 deletion dev/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,16 @@
Example 3:
</label>
<div class="col-md-8">
<touch-spin ng-model="vm.currency2" options="vm.touchSpinOptions" on-change="vm.onTouchSpinChange(value)">
<touch-spin ng-model="vm.currency2" options="vm.touchSpinOptions">
</touch-spin>
</div>
</div>
<div class="form-group">
<label for="demo2" class="col-md-4 control-label">
Example 4:
</label>
<div class="col-md-8">
<touch-spin ng-model="vm.currency3" options="vm.touchSpinDelimiterOptions" on-change="vm.onTouchSpinChange(oldValue, value)">
</touch-spin>
</div>
</div>
Expand Down
11 changes: 8 additions & 3 deletions dev/main.module.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { AngularES6 } from '../src/utilities/angular-es6';
import { ITouchSpinConfigProvider, ITouchSpinOptions } from '../src/angular-touchspin';

import './styles/vendor';
import 'font-awesome-webpack';

let touchspinModule = require<string>('../src/angular-touchspin.module');

import { MainController } from './controllers/main.controller';

export default angular
export default AngularES6
.module('nk.touchspin.test', [touchspinModule])
.controller('MainController', MainController)
.config(function(touchSpinConfigProvider: angular.touchspin.ITouchSpinConfigProvider) {
touchSpinConfigProvider.defaults(<angular.touchspin.ITouchSpinOptions>{
.config(function(touchSpinConfigProvider: ITouchSpinConfigProvider) {
touchSpinConfigProvider.defaults(<ITouchSpinOptions>{
decimals: 2,
verticalButtons: false
});
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-touchspin.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* angular-touchspin JavaScript Library v1.4.6
* angular-touchspin JavaScript Library v1.5.0
*
* @license MIT
*
Expand Down
160 changes: 94 additions & 66 deletions dist/angular-touchspin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/angular-touchspin.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/angular-touchspin.min.js

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-touchspin",
"version": "1.4.6",
"version": "1.5.0",
"author": "Niko Kovačič <niko.kovacic2@gmail.com>",
"title": "Angular Touchspin",
"description": "A input spinner component for Bootstrap 3 and angular",
Expand All @@ -17,7 +17,8 @@
"angular touchspin"
],
"main": "./dist/angular-touchspin.js",
"licence": "MIT",
"types": "./src/angular-touchspin.d.ts",
"license": "MIT",
"dependencies": {
"angular": "~1.5"
},
Expand Down Expand Up @@ -45,10 +46,12 @@
"style-loader": "~0.13",
"tslint": "~3.7",
"ts-loader": "~0.8",
"typescript": "~1.8",
"typescript": "~2.5",
"url-loader": "~0.5",
"webpack": "~1.13",
"webpack-dev-server": "~1.14",
"wrench": "~1.5"
"wrench": "~1.5",
"@types/angular": "~1.5",
"@types/webpack-env": "~1.13"
}
}
20 changes: 13 additions & 7 deletions src/angular-touchspin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,28 @@

//// <reference path="../angularjs/angular.d.ts" />


declare module "angular-touchspin" {
let _: string;
let _: string;
export = _;
}

declare module angular.touchspin {
export type ITouchSpinOptions = angularTouchSpin.ITouchSpinOptions;
export type ITouchSpinConfig = angularTouchSpin.ITouchSpinConfig;
export type ITouchSpinConfigProvider = angularTouchSpin.ITouchSpinConfigProvider;

declare namespace angularTouchSpin {
interface ITouchSpinOptions {
buttonDownClass?: string;
buttonDownShow?: boolean;
buttonDownTxt?: string;
buttonUpClass?: string;
buttonUpShow?: boolean;
buttonUpTxt?: string;
min?: number;
max?: number;
step?: number;
decimals?: number;
decimalsDelimiter?: string;
stepInterval?: number;
forceStepDivisibility?: string; // none | floor | round | ceil
stepIntervalDelay?: number;
Expand All @@ -28,10 +38,6 @@ declare module angular.touchspin {
prefixExtraClass?: string;
postfixExtraClass?: string;
mousewheel?: boolean;
buttonDownClass?: string;
buttonUpClass?: string;
buttonDownTxt?: string;
buttonUpTxt?: string;
}

interface ITouchSpinConfig extends ITouchSpinOptions { }
Expand Down
6 changes: 3 additions & 3 deletions src/components/touchend/touchend.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as angular from 'angular';

export class TouchEndController {
private

constructor(private $element: ng.IAugmentedJQuery, private $attrs: ng.IAttributes, private $scope: ng.IScope) {
constructor(private $element: ng.IAugmentedJQuery, private $attrs: angular.IAttributes, private $scope: ng.IScope) {
'ngInject';

if (angular.version.major === 1 && angular.version.minor < 5) {
Expand All @@ -15,8 +17,6 @@ export class TouchEndController {

private initializeEvents() {
this.$element.on('touchend', (event) => {
console.log('touchend');

this.$scope.$apply(() => {
this.$scope.$eval(this.$attrs['nkTouchend'], { $event: event });
});
Expand Down
4 changes: 3 additions & 1 deletion src/components/touchend/touchend.directive.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { IDirective } from 'angular';

import { TouchEndController } from './touchend.controller';

export class TouchEndDirective implements ng.IDirective {
export class TouchEndDirective implements IDirective {
public restrict = 'A';
public controller = TouchEndController;
}
Loading

0 comments on commit c328b1c

Please sign in to comment.