mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 19:51:53 +00:00
WIP
This commit is contained in:
+82
-92
@@ -19,19 +19,19 @@ class AuthService {
|
||||
* Required by HTTP interceptor.
|
||||
* Function is attached to provider to be invisible for regular users of this service.
|
||||
*/
|
||||
pushToBuffer = function(config: ng.IRequestConfig, deferred: ng.IDeferred<any>) {
|
||||
pushToBuffer = (config: ng.IRequestConfig, deferred: ng.IDeferred<any>) => {
|
||||
this.buffer.push({
|
||||
config,
|
||||
deferred
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
$get = [
|
||||
'$rootScope', '$injector', function($rootScope: ng.IScope, $injector: ng.auto.IInjectorService) {
|
||||
'$rootScope', '$injector', ($rootScope: ng.IScope, $injector: ng.auto.IInjectorService) => {
|
||||
let $http: ng.IHttpService; //initialized later because of circular dependency problem
|
||||
function retry(config: ng.IRequestConfig, deferred: ng.IDeferred<any>) {
|
||||
$http = $http || $injector.get<ng.IHttpService>('$http');
|
||||
$http(config).then(function(response) {
|
||||
$http(config).then(response => {
|
||||
deferred.resolve(response);
|
||||
});
|
||||
}
|
||||
@@ -49,7 +49,7 @@ class AuthService {
|
||||
retryAll();
|
||||
}
|
||||
};
|
||||
} as any
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
@@ -61,13 +61,13 @@ angular.module('http-auth-interceptor', [])
|
||||
* $http interceptor.
|
||||
* On 401 response - it stores the request and broadcasts 'event:angular-auth-loginRequired'.
|
||||
*/
|
||||
.config(['$httpProvider', 'authServiceProvider', function($httpProvider: ng.IHttpProvider, authServiceProvider: any) {
|
||||
.config(['$httpProvider', 'authServiceProvider', ($httpProvider: ng.IHttpProvider, authServiceProvider: any) => {
|
||||
|
||||
$httpProvider.defaults.headers.common = {Authorization: 'Bearer token'};
|
||||
$httpProvider.defaults.headers.get['Authorization'] = 'Bearer token';
|
||||
$httpProvider.defaults.headers.post['Authorization'] = function(config: ng.IRequestConfig): string { return 'Bearer token'; };
|
||||
$httpProvider.defaults.headers.post['Authorization'] = (config: ng.IRequestConfig) => 'Bearer token';
|
||||
|
||||
const interceptor = ['$rootScope', '$q', function($rootScope: ng.IScope, $q: ng.IQService) {
|
||||
const interceptor = ['$rootScope', '$q', ($rootScope: ng.IScope, $q: ng.IQService) => {
|
||||
function success(response: ng.IHttpPromiseCallbackArg<any>) {
|
||||
return response;
|
||||
}
|
||||
@@ -83,13 +83,10 @@ angular.module('http-auth-interceptor', [])
|
||||
return $q.reject(response);
|
||||
}
|
||||
|
||||
return function(promise: ng.IHttpPromise<any>) {
|
||||
return promise.then(success, error);
|
||||
};
|
||||
|
||||
} as any];
|
||||
return (promise: ng.IHttpPromise<any>) => promise.then(success, error);
|
||||
}];
|
||||
$httpProvider.interceptors.push(interceptor);
|
||||
} as any]);
|
||||
}]);
|
||||
|
||||
namespace HttpAndRegularPromiseTests {
|
||||
interface Person {
|
||||
@@ -161,8 +158,8 @@ namespace My.Namespace {
|
||||
|
||||
// IModule Registering Test
|
||||
let mod = angular.module('tests', []);
|
||||
mod.controller('name', function($scope: ng.IScope) { });
|
||||
mod.controller('name', ['$scope', function($scope: ng.IScope) { }]);
|
||||
mod.controller('name', ($scope: ng.IScope) => { });
|
||||
mod.controller('name', ['$scope', ($scope: ng.IScope) => { }]);
|
||||
mod.controller('name', class {
|
||||
// Uncommenting the next line should lead to a type error because this signature isn't compatible
|
||||
// with the signature of the `$onChanges` hook:
|
||||
@@ -170,8 +167,8 @@ mod.controller('name', class {
|
||||
});
|
||||
mod.controller({
|
||||
MyCtrl: class{},
|
||||
MyCtrl2: function() {}, // tslint:disable-line:object-literal-shorthand
|
||||
MyCtrl3: ['$fooService', function($fooService: any) { }]
|
||||
MyCtrl2() {},
|
||||
MyCtrl3: ['$fooService', ($fooService: any) => { }]
|
||||
});
|
||||
mod.directive('myDirectiveA', ($rootScope: ng.IRootScopeService) => {
|
||||
return (scope, el, attrs) => {
|
||||
@@ -183,7 +180,7 @@ mod.directive('myDirectiveA', ($rootScope: ng.IRootScopeService) => {
|
||||
scope.$watch(() => foo, () => el.text(foo));
|
||||
};
|
||||
});
|
||||
mod.directive('myDirectiveB', ['$rootScope', function($rootScope: ng.IRootScopeService) {
|
||||
mod.directive('myDirectiveB', ['$rootScope', ($rootScope: ng.IRootScopeService) => {
|
||||
return {
|
||||
link(scope, el, attrs) {
|
||||
el.click(e => {
|
||||
@@ -200,28 +197,28 @@ mod.directive({
|
||||
template: 'my-bar-dir.tpl.html'
|
||||
})]
|
||||
});
|
||||
mod.factory('name', function($scope: ng.IScope) { });
|
||||
mod.factory('name', ['$scope', function($scope: ng.IScope) { }]);
|
||||
mod.factory('name', ($scope: ng.IScope) => {});
|
||||
mod.factory('name', ['$scope', ($scope: ng.IScope) => {}]);
|
||||
mod.factory({
|
||||
name1: function(foo: any) { }, // tslint:disable-line:object-literal-shorthand
|
||||
name2: ['foo', function(foo: any) { }]
|
||||
name1(foo: any) {},
|
||||
name2: ['foo', (foo: any) => {}]
|
||||
});
|
||||
mod.filter('name', function($scope: ng.IScope) { });
|
||||
mod.filter('name', ['$scope', function($scope: ng.IScope) { }]);
|
||||
mod.filter('name', ($scope: ng.IScope) => {});
|
||||
mod.filter('name', ['$scope', ($scope: ng.IScope) => {}]);
|
||||
mod.filter({
|
||||
name1: function(foo: any) { }, // tslint:disable-line:object-literal-shorthand
|
||||
name2: ['foo', function(foo: any) { }]
|
||||
name1(foo: any) {},
|
||||
name2: ['foo', (foo: any) => {}]
|
||||
});
|
||||
mod.provider('name', function($scope: ng.IScope) { return { $get: () => { } }; });
|
||||
mod.provider('name', ($scope: ng.IScope) => ({ $get: () => { } }));
|
||||
mod.provider('name', TestProvider);
|
||||
mod.provider('name', ['$scope', function($scope: ng.IScope) { } as any]);
|
||||
mod.provider('name', ['$scope', ($scope: ng.IScope) => {}]);
|
||||
mod.provider(My.Namespace);
|
||||
mod.service('name', function($scope: ng.IScope) { });
|
||||
mod.service('name', ['$scope', function($scope: ng.IScope) { } as any]);
|
||||
mod.service('name', ($scope: ng.IScope) => {});
|
||||
mod.service('name', ['$scope', ($scope: ng.IScope) => {}]);
|
||||
mod.service({
|
||||
MyCtrl: class{},
|
||||
MyCtrl2: function() {}, // tslint:disable-line:object-literal-shorthand
|
||||
MyCtrl3: ['$fooService', function($fooService: any) { }]
|
||||
MyCtrl2: () => {}, // tslint:disable-line:object-literal-shorthand
|
||||
MyCtrl3: ['$fooService', ($fooService: any) => {}]
|
||||
});
|
||||
mod.constant('name', 23);
|
||||
mod.constant('name', '23');
|
||||
@@ -229,8 +226,8 @@ mod.constant(My.Namespace);
|
||||
mod.value('name', 23);
|
||||
mod.value('name', '23');
|
||||
mod.value(My.Namespace);
|
||||
mod.decorator('name', function($scope: ng.IScope) {});
|
||||
mod.decorator('name', ['$scope', function($scope: ng.IScope) {} as any]);
|
||||
mod.decorator('name', ($scope: ng.IScope) => {});
|
||||
mod.decorator('name', ['$scope', ($scope: ng.IScope) => {}]);
|
||||
|
||||
class TestProvider implements ng.IServiceProvider {
|
||||
constructor(private $scope: ng.IScope) {
|
||||
@@ -242,7 +239,7 @@ class TestProvider implements ng.IServiceProvider {
|
||||
|
||||
// QProvider tests
|
||||
angular.module('qprovider-test', [])
|
||||
.config(['$qProvider', function($qProvider: ng.IQProvider) {
|
||||
.config(['$qProvider', ($qProvider: ng.IQProvider) => {
|
||||
const provider: ng.IQProvider = $qProvider.errorOnUnhandledRejections(false);
|
||||
const currentValue: boolean = $qProvider.errorOnUnhandledRejections();
|
||||
}]);
|
||||
@@ -590,7 +587,7 @@ namespace TestPromise {
|
||||
function test_angular_forEach() {
|
||||
const values: { [key: string]: string } = { name: 'misko', gender: 'male' };
|
||||
const log: string[] = [];
|
||||
angular.forEach(values, function(value, key) {
|
||||
angular.forEach(values, (value, key) => {
|
||||
this.push(key + ': ' + value);
|
||||
}, log);
|
||||
//expect(log).toEqual(['name: misko', 'gender: male']);
|
||||
@@ -708,19 +705,12 @@ angular.module('AnotherSampleDirective', []).directive('myDirective', ['$interpo
|
||||
const defer = $q.defer();
|
||||
defer.reject();
|
||||
defer.resolve();
|
||||
defer.promise.then(function(d) {
|
||||
return d;
|
||||
}).then(function(): any {
|
||||
return null;
|
||||
}, function(): any {
|
||||
return null;
|
||||
})
|
||||
.catch((): any => {
|
||||
return null;
|
||||
})
|
||||
.finally((): any => {
|
||||
return null;
|
||||
});
|
||||
defer.promise.then(d => d)
|
||||
.then(
|
||||
(): any => null,
|
||||
(): any => null)
|
||||
.catch((): any => null)
|
||||
.finally((): any => null);
|
||||
let promise = new $q((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
@@ -740,39 +730,39 @@ angular.module('AnotherSampleDirective', []).directive('myDirective', ['$interpo
|
||||
|
||||
// test from https://docs.angularjs.org/guide/directive
|
||||
angular.module('docsSimpleDirective', [])
|
||||
.controller('Controller', ['$scope', function($scope: any) {
|
||||
.controller('Controller', ['$scope', ($scope: any) => {
|
||||
$scope.customer = {
|
||||
name: 'Naomi',
|
||||
address: '1600 Amphitheatre'
|
||||
};
|
||||
}])
|
||||
.directive('myCustomer', function() {
|
||||
.directive('myCustomer', () => {
|
||||
return {
|
||||
template: 'Name: {{customer.name}} Address: {{customer.address}}'
|
||||
};
|
||||
});
|
||||
|
||||
angular.module('docsTemplateUrlDirective', [])
|
||||
.controller('Controller', ['$scope', function($scope: any) {
|
||||
.controller('Controller', ['$scope', ($scope: any) => {
|
||||
$scope.customer = {
|
||||
name: 'Naomi',
|
||||
address: '1600 Amphitheatre'
|
||||
};
|
||||
}])
|
||||
.directive('myCustomer', function() {
|
||||
.directive('myCustomer', () => {
|
||||
return {
|
||||
templateUrl: 'my-customer.html'
|
||||
};
|
||||
});
|
||||
|
||||
angular.module('docsRestrictDirective', [])
|
||||
.controller('Controller', ['$scope', function($scope: any) {
|
||||
.controller('Controller', ['$scope', ($scope: any) => {
|
||||
$scope.customer = {
|
||||
name: 'Naomi',
|
||||
address: '1600 Amphitheatre'
|
||||
};
|
||||
}])
|
||||
.directive('myCustomer', function() {
|
||||
.directive('myCustomer', () => {
|
||||
return {
|
||||
restrict: 'E',
|
||||
templateUrl: 'my-customer.html'
|
||||
@@ -780,19 +770,19 @@ angular.module('docsRestrictDirective', [])
|
||||
});
|
||||
|
||||
angular.module('docsScopeProblemExample', [])
|
||||
.controller('NaomiController', ['$scope', function($scope: any) {
|
||||
.controller('NaomiController', ['$scope', ($scope: any) => {
|
||||
$scope.customer = {
|
||||
name: 'Naomi',
|
||||
address: '1600 Amphitheatre'
|
||||
};
|
||||
}])
|
||||
.controller('IgorController', ['$scope', function($scope: any) {
|
||||
.controller('IgorController', ['$scope', ($scope: any) => {
|
||||
$scope.customer = {
|
||||
name: 'Igor',
|
||||
address: '123 Somewhere'
|
||||
};
|
||||
}])
|
||||
.directive('myCustomer', function() {
|
||||
.directive('myCustomer', () => {
|
||||
return {
|
||||
restrict: 'E',
|
||||
templateUrl: 'my-customer.html'
|
||||
@@ -800,11 +790,11 @@ angular.module('docsScopeProblemExample', [])
|
||||
});
|
||||
|
||||
angular.module('docsIsolateScopeDirective', [])
|
||||
.controller('Controller', ['$scope', function($scope: any) {
|
||||
.controller('Controller', ['$scope', ($scope: any) => {
|
||||
$scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' };
|
||||
$scope.igor = { name: 'Igor', address: '123 Somewhere' };
|
||||
}])
|
||||
.directive('myCustomer', function() {
|
||||
.directive('myCustomer', () => {
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
@@ -815,11 +805,11 @@ angular.module('docsIsolateScopeDirective', [])
|
||||
});
|
||||
|
||||
angular.module('docsIsolationExample', [])
|
||||
.controller('Controller', ['$scope', function($scope: any) {
|
||||
.controller('Controller', ['$scope', ($scope: any) => {
|
||||
$scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' };
|
||||
$scope.vojta = { name: 'Vojta', address: '3456 Somewhere Else' };
|
||||
}])
|
||||
.directive('myCustomer', function() {
|
||||
.directive('myCustomer', () => {
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
@@ -830,10 +820,10 @@ angular.module('docsIsolationExample', [])
|
||||
});
|
||||
|
||||
angular.module('docsTimeDirective', [])
|
||||
.controller('Controller', ['$scope', function($scope: any) {
|
||||
.controller('Controller', ['$scope', ($scope: any) => {
|
||||
$scope.format = 'M/d/yy h:mm:ss a';
|
||||
}])
|
||||
.directive('myCurrentTime', ['$interval', 'dateFilter', function($interval: any, dateFilter: any) {
|
||||
.directive('myCurrentTime', ['$interval', 'dateFilter', ($interval: any, dateFilter: any) => {
|
||||
|
||||
return {
|
||||
link(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes) {
|
||||
@@ -844,17 +834,17 @@ angular.module('docsTimeDirective', [])
|
||||
element.text(dateFilter(new Date(), format));
|
||||
}
|
||||
|
||||
scope.$watch(attrs['myCurrentTime'], function(value: any) {
|
||||
scope.$watch(attrs['myCurrentTime'], (value: any) => {
|
||||
format = value;
|
||||
updateTime();
|
||||
});
|
||||
|
||||
element.on('$destroy', function() {
|
||||
element.on('$destroy', () => {
|
||||
$interval.cancel(timeoutId);
|
||||
});
|
||||
|
||||
// start the UI update process; save the timeoutId for canceling
|
||||
timeoutId = $interval(function() {
|
||||
timeoutId = $interval(() => {
|
||||
updateTime(); // update DOM
|
||||
}, 1000);
|
||||
}
|
||||
@@ -862,10 +852,10 @@ angular.module('docsTimeDirective', [])
|
||||
}]);
|
||||
|
||||
angular.module('docsTransclusionDirective', [])
|
||||
.controller('Controller', ['$scope', function($scope: any) {
|
||||
.controller('Controller', ['$scope', ($scope: any) => {
|
||||
$scope.name = 'Tobias';
|
||||
}])
|
||||
.directive('myDialog', function() {
|
||||
.directive('myDialog', () => {
|
||||
return {
|
||||
restrict: 'E',
|
||||
transclude: true,
|
||||
@@ -874,10 +864,10 @@ angular.module('docsTransclusionDirective', [])
|
||||
});
|
||||
|
||||
angular.module('docsTransclusionExample', [])
|
||||
.controller('Controller', ['$scope', function($scope: any) {
|
||||
.controller('Controller', ['$scope', ($scope: any) => {
|
||||
$scope.name = 'Tobias';
|
||||
}])
|
||||
.directive('myDialog', function() {
|
||||
.directive('myDialog', () => {
|
||||
return {
|
||||
restrict: 'E',
|
||||
transclude: true,
|
||||
@@ -890,16 +880,16 @@ angular.module('docsTransclusionExample', [])
|
||||
});
|
||||
|
||||
angular.module('docsIsoFnBindExample', [])
|
||||
.controller('Controller', ['$scope', '$timeout', function($scope: any, $timeout: any) {
|
||||
.controller('Controller', ['$scope', '$timeout', ($scope: any, $timeout: any) => {
|
||||
$scope.name = 'Tobias';
|
||||
$scope.hideDialog = function() {
|
||||
$scope.hideDialog = () => {
|
||||
$scope.dialogIsHidden = true;
|
||||
$timeout(function() {
|
||||
$timeout(() => {
|
||||
$scope.dialogIsHidden = false;
|
||||
}, 2000);
|
||||
};
|
||||
}])
|
||||
.directive('myDialog', function() {
|
||||
.directive('myDialog', () => {
|
||||
return {
|
||||
restrict: 'E',
|
||||
transclude: true,
|
||||
@@ -911,8 +901,8 @@ angular.module('docsIsoFnBindExample', [])
|
||||
});
|
||||
|
||||
angular.module('dragModule', [])
|
||||
.directive('myDraggable', ['$document', function($document: any) {
|
||||
return function(scope: any, element: any, attr: any) {
|
||||
.directive('myDraggable', ['$document', ($document: any) => {
|
||||
return (scope: any, element: any, attr: any) => {
|
||||
let startX = 0, startY = 0, x = 0, y = 0;
|
||||
|
||||
element.css({
|
||||
@@ -922,7 +912,7 @@ angular.module('dragModule', [])
|
||||
cursor: 'pointer'
|
||||
});
|
||||
|
||||
element.on('mousedown', function(event: any) {
|
||||
element.on('mousedown', (event: any) => {
|
||||
// Prevent default dragging of selected content
|
||||
event.preventDefault();
|
||||
startX = event.pageX - x;
|
||||
@@ -948,7 +938,7 @@ angular.module('dragModule', [])
|
||||
}]);
|
||||
|
||||
angular.module('docsTabsExample', [])
|
||||
.directive('myTabs', function() {
|
||||
.directive('myTabs', () => {
|
||||
return {
|
||||
restrict: 'E',
|
||||
transclude: true,
|
||||
@@ -956,14 +946,14 @@ angular.module('docsTabsExample', [])
|
||||
controller($scope: ng.IScope) {
|
||||
const panes: any = $scope['panes'] = [];
|
||||
|
||||
$scope['select'] = function(pane: any) {
|
||||
angular.forEach(panes, function(pane: any) {
|
||||
$scope['select'] = (pane: any) => {
|
||||
angular.forEach(panes, (pane: any) => {
|
||||
pane.selected = false;
|
||||
});
|
||||
pane.selected = true;
|
||||
};
|
||||
|
||||
this.addPane = function(pane: any) {
|
||||
this.addPane = (pane: any) => {
|
||||
if (panes.length === 0) {
|
||||
$scope['select'](pane);
|
||||
}
|
||||
@@ -973,7 +963,7 @@ angular.module('docsTabsExample', [])
|
||||
templateUrl: 'my-tabs.html'
|
||||
};
|
||||
})
|
||||
.directive('myPane', function() {
|
||||
.directive('myPane', () => {
|
||||
return {
|
||||
require: '^myTabs',
|
||||
restrict: 'E',
|
||||
@@ -989,7 +979,7 @@ angular.module('docsTabsExample', [])
|
||||
});
|
||||
|
||||
angular.module('multiSlotTranscludeExample', [])
|
||||
.directive('dropDownMenu', function() {
|
||||
.directive('dropDownMenu', () => {
|
||||
return {
|
||||
transclude: {
|
||||
button: 'button',
|
||||
@@ -1047,15 +1037,15 @@ interface ICopyExampleScope {
|
||||
}
|
||||
|
||||
angular.module('copyExample', [])
|
||||
.controller('ExampleController', ['$scope', function($scope: ICopyExampleScope) {
|
||||
.controller('ExampleController', ['$scope', ($scope: ICopyExampleScope) => {
|
||||
$scope.master = { };
|
||||
|
||||
$scope.update = function(user) {
|
||||
$scope.update = user => {
|
||||
// Example with 1 argument
|
||||
$scope.master = angular.copy(user);
|
||||
};
|
||||
|
||||
$scope.reset = function() {
|
||||
$scope.reset = () => {
|
||||
// Example with 2 arguments
|
||||
angular.copy($scope.master, $scope.user);
|
||||
};
|
||||
@@ -1128,7 +1118,7 @@ function NgModelControllerTyping() {
|
||||
var $q: angular.IQService;
|
||||
|
||||
// See https://docs.angularjs.org/api/ng/type/ngModel.NgModelController#$validators
|
||||
ngModel.$validators['validCharacters'] = function(modelValue, viewValue) {
|
||||
ngModel.$validators['validCharacters'] = (modelValue, viewValue) => {
|
||||
const value = modelValue || viewValue;
|
||||
return /[0-9]+/.test(value) &&
|
||||
/[a-z]+/.test(value) &&
|
||||
@@ -1136,7 +1126,7 @@ function NgModelControllerTyping() {
|
||||
/\W+/.test(value);
|
||||
};
|
||||
|
||||
ngModel.$asyncValidators['uniqueUsername'] = function(modelValue, viewValue) {
|
||||
ngModel.$asyncValidators['uniqueUsername'] = (modelValue, viewValue) => {
|
||||
const value = modelValue || viewValue;
|
||||
return $http.get('/api/users/' + value).
|
||||
then(function resolved() {
|
||||
@@ -1250,8 +1240,8 @@ function parseWithParams() {
|
||||
|
||||
function doBootstrap(element: Element | JQuery, mode: string): ng.auto.IInjectorService {
|
||||
if (mode === 'debug') {
|
||||
return angular.bootstrap(element, ['main', function($provide: ng.auto.IProvideService) {
|
||||
$provide.decorator('$rootScope', function($delegate: ng.IRootScopeService) {
|
||||
return angular.bootstrap(element, ['main', ($provide: ng.auto.IProvideService) => {
|
||||
$provide.decorator('$rootScope', ($delegate: ng.IRootScopeService) => {
|
||||
$delegate['debug'] = true;
|
||||
});
|
||||
}, 'debug-helpers'], {
|
||||
|
||||
@@ -65,7 +65,7 @@ circleCustomDrag = d3Drag.drag<SVGCircleElement, CircleDatum, CustomSubject | d3
|
||||
|
||||
let containerAccessor: (this: SVGCircleElement, d: CircleDatum, i: number, group: SVGCircleElement[] | NodeListOf<SVGCircleElement>) => d3Drag.DragContainerElement;
|
||||
|
||||
containerAccessor = function (d, i, group) {
|
||||
containerAccessor = function(d, i, group) {
|
||||
console.log('Node Id of circle: ', d.nodeId);
|
||||
// console.log(this.a); // fails, a is not a property of SVGCircleElement
|
||||
return this.ownerSVGElement; // this-type is SVGCircleElement
|
||||
@@ -73,7 +73,7 @@ containerAccessor = function (d, i, group) {
|
||||
|
||||
// Test chainability
|
||||
circleDrag = circleDrag
|
||||
.container(function (d, i, group) { // container accessor function setter
|
||||
.container(function(d, i, group) { // container accessor function setter
|
||||
console.log('Node Id of circle: ', d.nodeId); // CircleDatum type
|
||||
// console.log(this.a); // fails, a is not a property of SVGCircleElement
|
||||
return this.ownerSVGElement; // this-type is SVGCircleElement
|
||||
@@ -93,12 +93,12 @@ containerAccessor = circleDrag.container();
|
||||
|
||||
let filterFn: (this: SVGCircleElement, datum: CircleDatum, index: number, group: SVGCircleElement[] | NodeListOf<SVGCircleElement>) => boolean;
|
||||
|
||||
filterFn = function (d) {
|
||||
filterFn = function(d) {
|
||||
return (d.color !== 'green' && this.r.baseVal.value < 10) ? !event.button : true; // 'this' is SVGCircleElement and d is CircleDatum
|
||||
};
|
||||
|
||||
// chainable
|
||||
circleDrag = circleDrag.filter(function (d, i, group) {
|
||||
circleDrag = circleDrag.filter(function(d, i, group) {
|
||||
|
||||
return (d.color !== 'green' && this.r.baseVal.value < 10) ? !event.button : true; // 'this' is SVGCircleElement and d is CircleDatum
|
||||
});
|
||||
@@ -108,7 +108,7 @@ filterFn = circleDrag.filter();
|
||||
|
||||
// set and get subject ---------------------------------------------------------
|
||||
|
||||
circleCustomDrag.subject(function (d, i, g) {
|
||||
circleCustomDrag.subject(function(d, i, g) {
|
||||
// Cast event type for completeness, otherwise event is of type any.
|
||||
let e = <d3Drag.D3DragEvent<SVGCircleElement, CircleDatum, CustomSubject | d3Drag.SubjectPosition>> event;
|
||||
let that: SVGCircleElement = this;
|
||||
|
||||
+21
-27
@@ -31,11 +31,11 @@ interface ParsedTestObject {
|
||||
let parseArray: d3Dsv.DSVParsedArray<d3Dsv.DSVRowString>;
|
||||
let parseMappedArray: d3Dsv.DSVParsedArray<ParsedTestObject>;
|
||||
|
||||
let parseRowsArray: Array<Array<string>>;
|
||||
let parseRowsMappedArray: Array<ParsedTestObject>;
|
||||
let parseRowsArray: string[][];
|
||||
let parseRowsMappedArray: ParsedTestObject[];
|
||||
|
||||
|
||||
let columns: Array<string>;
|
||||
let columns: string[];
|
||||
let num: number;
|
||||
let date: Date;
|
||||
let str: string;
|
||||
@@ -57,10 +57,10 @@ str = parseArray[0]['Year'];
|
||||
|
||||
// with row mapper ---------------------------------------------------------------------------
|
||||
|
||||
parseMappedArray = d3Dsv.csvParse(csvTestStringWithHeader, function (rawRow, index, columns) {
|
||||
parseMappedArray = d3Dsv.csvParse(csvTestStringWithHeader, (rawRow, index, columns) => {
|
||||
let rr: d3Dsv.DSVRowString = rawRow;
|
||||
let i: number = index;
|
||||
let c: Array<string> = columns;
|
||||
let c: string[] = columns;
|
||||
let pr: ParsedTestObject;
|
||||
|
||||
pr = {
|
||||
@@ -94,8 +94,8 @@ str = parseRowsArray[0][0]; // 'Year' of first row
|
||||
|
||||
// with row mapper ---------------------------------------------------------------------------
|
||||
|
||||
parseRowsMappedArray = d3Dsv.csvParseRows(csvTestString, function (rawRow, index) {
|
||||
let rr: Array<string> = rawRow;
|
||||
parseRowsMappedArray = d3Dsv.csvParseRows(csvTestString, (rawRow, index) => {
|
||||
let rr: string[] = rawRow;
|
||||
let i: number = index;
|
||||
let pr: ParsedTestObject;
|
||||
|
||||
@@ -122,14 +122,12 @@ str = d3Dsv.csvFormat(parseRowsMappedArray, columns);
|
||||
|
||||
// csvFormatRows(...) ========================================================================
|
||||
|
||||
str = d3Dsv.csvFormatRows(parseRowsMappedArray.map(function(d, i) {
|
||||
return [
|
||||
str = d3Dsv.csvFormatRows(parseRowsMappedArray.map((d, i) => [
|
||||
d.year.getFullYear().toString(),
|
||||
d.make,
|
||||
d.model,
|
||||
d.length.toString()
|
||||
];
|
||||
}));
|
||||
]));
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
// Test TSV
|
||||
@@ -148,10 +146,10 @@ str = parseArray[0]['Year'];
|
||||
|
||||
// with row mapper ---------------------------------------------------------------------------
|
||||
|
||||
parseMappedArray = d3Dsv.tsvParse(tsvTestStringWithHeader, function (rawRow, index, columns) {
|
||||
parseMappedArray = d3Dsv.tsvParse(tsvTestStringWithHeader, (rawRow, index, columns) => {
|
||||
let rr: d3Dsv.DSVRowString = rawRow;
|
||||
let i: number = index;
|
||||
let c: Array<string> = columns;
|
||||
let c: string[] = columns;
|
||||
let pr: ParsedTestObject;
|
||||
|
||||
pr = {
|
||||
@@ -185,8 +183,8 @@ str = parseRowsArray[0][0]; // 'Year' of first row
|
||||
|
||||
// with row mapper ---------------------------------------------------------------------------
|
||||
|
||||
parseRowsMappedArray = d3Dsv.tsvParseRows(tsvTestString, function (rawRow, index) {
|
||||
let rr: Array<string> = rawRow;
|
||||
parseRowsMappedArray = d3Dsv.tsvParseRows(tsvTestString, (rawRow, index) => {
|
||||
let rr: string[] = rawRow;
|
||||
let i: number = index;
|
||||
let pr: ParsedTestObject;
|
||||
|
||||
@@ -213,14 +211,12 @@ str = d3Dsv.tsvFormat(parseRowsMappedArray, columns);
|
||||
|
||||
// tsvFormatRows(...) ========================================================================
|
||||
|
||||
str = d3Dsv.tsvFormatRows(parseRowsMappedArray.map(function(d, i) {
|
||||
return [
|
||||
str = d3Dsv.tsvFormatRows(parseRowsMappedArray.map((d, i) => [
|
||||
d.year.getFullYear().toString(),
|
||||
d.make,
|
||||
d.model,
|
||||
d.length.toString()
|
||||
];
|
||||
}));
|
||||
]));
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
// Test DSV Generalized Parsers and Formatters
|
||||
@@ -244,10 +240,10 @@ str = parseArray[0]['Year'];
|
||||
|
||||
// with row mapper ---------------------------------------------------------------------------
|
||||
|
||||
parseMappedArray = dsv.parse(pipedTestStringWithHeader, function (rawRow, index, columns) {
|
||||
parseMappedArray = dsv.parse(pipedTestStringWithHeader, (rawRow, index, columns) => {
|
||||
let rr: d3Dsv.DSVRowString = rawRow;
|
||||
let i: number = index;
|
||||
let c: Array<string> = columns;
|
||||
let c: string[] = columns;
|
||||
let pr: ParsedTestObject;
|
||||
|
||||
pr = {
|
||||
@@ -281,8 +277,8 @@ str = parseRowsArray[0][0]; // 'Year' of first row
|
||||
|
||||
// with row mapper ---------------------------------------------------------------------------
|
||||
|
||||
parseRowsMappedArray = dsv.parseRows(pipedTestString, function (rawRow, index) {
|
||||
let rr: Array<string> = rawRow;
|
||||
parseRowsMappedArray = dsv.parseRows(pipedTestString, (rawRow, index) => {
|
||||
let rr: string[] = rawRow;
|
||||
let i: number = index;
|
||||
let pr: ParsedTestObject;
|
||||
|
||||
@@ -309,11 +305,9 @@ str = dsv.format(parseRowsMappedArray, columns);
|
||||
|
||||
// formatRows(...) ========================================================================
|
||||
|
||||
str = dsv.formatRows(parseRowsMappedArray.map(function(d, i) {
|
||||
return [
|
||||
str = dsv.formatRows(parseRowsMappedArray.map((d, i) => [
|
||||
d.year.getFullYear().toString(),
|
||||
d.make,
|
||||
d.model,
|
||||
d.length.toString()
|
||||
];
|
||||
}));
|
||||
]));
|
||||
|
||||
Vendored
+17
-20
@@ -1,4 +1,4 @@
|
||||
// Type definitions for D3JS d3-dsv module v1.0.1
|
||||
// Type definitions for D3JS d3-dsv module 1.0
|
||||
// Project: https://github.com/d3/d3-dsv/
|
||||
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -16,7 +16,7 @@ export interface DSVRowAny {
|
||||
}
|
||||
|
||||
export interface DSVParsedArray<T> extends Array<T> {
|
||||
columns: Array<string>;
|
||||
columns: string[];
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
@@ -26,21 +26,20 @@ export interface DSVParsedArray<T> extends Array<T> {
|
||||
// csvParse(...) ============================================================================
|
||||
|
||||
export function csvParse(csvString: string): DSVParsedArray<DSVRowString>;
|
||||
export function csvParse<ParsedRow extends DSVRowAny>(csvString: string, row: (rawRow: DSVRowString, index: number, columns: Array<string>) => ParsedRow): DSVParsedArray<ParsedRow>;
|
||||
export function csvParse<ParsedRow extends DSVRowAny>(csvString: string, row: (rawRow: DSVRowString, index: number, columns: string[]) => ParsedRow): DSVParsedArray<ParsedRow>;
|
||||
|
||||
// csvParseRows(...) ========================================================================
|
||||
|
||||
export function csvParseRows(csvString: string): Array<Array<string>>;
|
||||
export function csvParseRows<ParsedRow extends DSVRowAny>(csvString: string, row: (rawRow: Array<string>, index: number) => ParsedRow): Array<ParsedRow>;
|
||||
export function csvParseRows(csvString: string): string[][];
|
||||
export function csvParseRows<ParsedRow extends DSVRowAny>(csvString: string, row: (rawRow: string[], index: number) => ParsedRow): ParsedRow[];
|
||||
|
||||
// csvFormat(...) ============================================================================
|
||||
|
||||
export function csvFormat(rows: Array<DSVRowAny>): string;
|
||||
export function csvFormat(rows: Array<DSVRowAny>, columns: Array<string>): string;
|
||||
export function csvFormat(rows: DSVRowAny[], columns?: string[]): string;
|
||||
|
||||
// csvFormatRows(...) ========================================================================
|
||||
|
||||
export function csvFormatRows(rows: Array<Array<string>>): string;
|
||||
export function csvFormatRows(rows: string[][]): string;
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
// TSV Parsers and Formatters
|
||||
@@ -49,21 +48,20 @@ export function csvFormatRows(rows: Array<Array<string>>): string;
|
||||
// tsvParse(...) ============================================================================
|
||||
|
||||
export function tsvParse(tsvString: string): DSVParsedArray<DSVRowString>;
|
||||
export function tsvParse<MappedRow extends DSVRowAny>(tsvString: string, row: (rawRow: DSVRowString, index: number, columns: Array<string>) => MappedRow): DSVParsedArray<MappedRow>;
|
||||
export function tsvParse<MappedRow extends DSVRowAny>(tsvString: string, row: (rawRow: DSVRowString, index: number, columns: string[]) => MappedRow): DSVParsedArray<MappedRow>;
|
||||
|
||||
// tsvParseRows(...) ========================================================================
|
||||
|
||||
export function tsvParseRows(tsvString: string): Array<Array<string>>;
|
||||
export function tsvParseRows<MappedRow extends DSVRowAny>(tsvString: string, row: (rawRow: Array<string>, index: number) => MappedRow): Array<MappedRow>;
|
||||
export function tsvParseRows(tsvString: string): string[][];
|
||||
export function tsvParseRows<MappedRow extends DSVRowAny>(tsvString: string, row: (rawRow: string[], index: number) => MappedRow): MappedRow[];
|
||||
|
||||
// tsvFormat(...) ============================================================================
|
||||
|
||||
export function tsvFormat(rows: Array<DSVRowAny>): string;
|
||||
export function tsvFormat(rows: Array<DSVRowAny>, columns: Array<string>): string;
|
||||
export function tsvFormat(rows: DSVRowAny[], columns?: string[]): string;
|
||||
|
||||
// tsvFormatRows(...) ========================================================================
|
||||
|
||||
export function tsvFormatRows(rows: Array<Array<string>>): string;
|
||||
export function tsvFormatRows(rows: string[][]): string;
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
// DSV Generalized Parsers and Formatters
|
||||
@@ -71,12 +69,11 @@ export function tsvFormatRows(rows: Array<Array<string>>): string;
|
||||
|
||||
export interface DSV {
|
||||
parse(dsvString: string): DSVParsedArray<DSVRowString>;
|
||||
parse<ParsedRow extends DSVRowAny>(dsvString: string, row: (rawRow: DSVRowString, index: number, columns: Array<string>) => ParsedRow): DSVParsedArray<ParsedRow>;
|
||||
parseRows(dsvString: string): Array<Array<string>>;
|
||||
parseRows<ParsedRow extends DSVRowAny>(dsvString: string, row: (rawRow: Array<string>, index: number) => ParsedRow): Array<ParsedRow>;
|
||||
format(rows: Array<DSVRowAny>): string;
|
||||
format(rows: Array<DSVRowAny>, columns: Array<string>): string;
|
||||
formatRows(rows: Array<Array<string>>): string;
|
||||
parse<ParsedRow extends DSVRowAny>(dsvString: string, row: (rawRow: DSVRowString, index: number, columns: string[]) => ParsedRow): DSVParsedArray<ParsedRow>;
|
||||
parseRows(dsvString: string): string[][];
|
||||
parseRows<ParsedRow extends DSVRowAny>(dsvString: string, row: (rawRow: string[], index: number) => ParsedRow): ParsedRow[];
|
||||
format(rows: DSVRowAny[], columns?: string[]): string;
|
||||
formatRows(rows: string[][]): string;
|
||||
}
|
||||
|
||||
export function dsvFormat(delimiter: string): DSV;
|
||||
|
||||
@@ -1 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
{ "extends": "../../tslint.json" }
|
||||
+10
-10
@@ -105,7 +105,7 @@ forceCollide = d3Force.forceCollide<SimNode>();
|
||||
forceCollide = d3Force.forceCollide<SimNode>(15);
|
||||
|
||||
// with radius accessor function
|
||||
forceCollide = d3Force.forceCollide<SimNode>(function (node, index, nodes) {
|
||||
forceCollide = d3Force.forceCollide<SimNode>((node, index, nodes) => {
|
||||
let n: SimNode = node;
|
||||
let i: number = index;
|
||||
let ns: SimNode[] = nodes;
|
||||
@@ -120,7 +120,7 @@ let radiusAccessor: (node: SimNode, i: number, nodes: SimNode[]) => number;
|
||||
// radius
|
||||
|
||||
forceCollide = forceCollide.radius(20);
|
||||
forceCollide = forceCollide.radius(function (node, index, nodes) {
|
||||
forceCollide = forceCollide.radius((node, index, nodes) => {
|
||||
let n: SimNode = node;
|
||||
let i: number = index;
|
||||
let ns: SimNode[] = nodes;
|
||||
@@ -184,7 +184,7 @@ num = simLink.s;
|
||||
|
||||
// id (node id accessor)
|
||||
|
||||
forceLink = forceLink.id(function (node, index, nodes) {
|
||||
forceLink = forceLink.id((node, index, nodes) => {
|
||||
let n: SimNode = node;
|
||||
let i: number = index;
|
||||
let ns: SimNode[] = nodes;
|
||||
@@ -194,7 +194,7 @@ forceLink = forceLink.id(function (node, index, nodes) {
|
||||
// distance
|
||||
|
||||
forceLink = forceLink.distance(50);
|
||||
forceLink = forceLink.distance(function (link, index, links) {
|
||||
forceLink = forceLink.distance((link, index, links) => {
|
||||
let l: SimLink = link;
|
||||
let i: number = index;
|
||||
let ls: SimLink[] = links;
|
||||
@@ -206,7 +206,7 @@ linkNumberAccessor = forceLink.distance();
|
||||
// strength
|
||||
|
||||
forceLink = forceLink.strength(0.95);
|
||||
forceLink = forceLink.strength(function (link, index, links) {
|
||||
forceLink = forceLink.strength((link, index, links) => {
|
||||
let l: SimLink = link;
|
||||
let i: number = index;
|
||||
let ls: SimLink[] = links;
|
||||
@@ -242,7 +242,7 @@ let simNodeNumberAccessor: (node: SimNode, i: number, nodes: SimNode[]) => numbe
|
||||
// strength
|
||||
|
||||
forceCharge = forceCharge.strength(-3000);
|
||||
forceCharge = forceCharge.strength(function (node, index, nodes) {
|
||||
forceCharge = forceCharge.strength((node, index, nodes) => {
|
||||
let n: SimNode = node;
|
||||
let i: number = index;
|
||||
let ns: SimNode[] = nodes;
|
||||
@@ -286,7 +286,7 @@ forcePosX = d3Force.forceX<SimNode>();
|
||||
// strength
|
||||
|
||||
forcePosX = forcePosX.strength(0.2);
|
||||
forcePosX = forcePosX.strength(function (node, index, nodes) {
|
||||
forcePosX = forcePosX.strength((node, index, nodes) => {
|
||||
let n: SimNode = node;
|
||||
let i: number = index;
|
||||
let ns: SimNode[] = nodes;
|
||||
@@ -297,7 +297,7 @@ simNodeNumberAccessor = forcePosX.strength();
|
||||
// x
|
||||
|
||||
forcePosX = forcePosX.x(100);
|
||||
forcePosX = forcePosX.x(function (node, index, nodes) {
|
||||
forcePosX = forcePosX.x((node, index, nodes) => {
|
||||
let n: SimNode = node;
|
||||
let i: number = index;
|
||||
let ns: SimNode[] = nodes;
|
||||
@@ -341,7 +341,7 @@ forcePosY = d3Force.forceY<SimNode>();
|
||||
// strength
|
||||
|
||||
forcePosY = forcePosY.strength(0.2);
|
||||
forcePosY = forcePosY.strength(function (node, index, nodes) {
|
||||
forcePosY = forcePosY.strength((node, index, nodes) => {
|
||||
let n: SimNode = node;
|
||||
let i: number = index;
|
||||
let ns: SimNode[] = nodes;
|
||||
@@ -352,7 +352,7 @@ simNodeNumberAccessor = forcePosY.strength();
|
||||
// y
|
||||
|
||||
forcePosY = forcePosY.y(100);
|
||||
forcePosY = forcePosY.y(function (node, index, nodes) {
|
||||
forcePosY = forcePosY.y((node, index, nodes) => {
|
||||
let n: SimNode = node;
|
||||
let i: number = index;
|
||||
let ns: SimNode[] = nodes;
|
||||
|
||||
+10
-20
@@ -126,19 +126,15 @@ clampFlag = linearScaleNumber.clamp();
|
||||
|
||||
linearScaleString = linearScaleString.interpolate(interpolateCubehelix.gamma(3));
|
||||
|
||||
linearScaleNumString = linearScaleNumString.interpolate(function (a, b) {
|
||||
linearScaleNumString = linearScaleNumString.interpolate((a, b) => {
|
||||
// take two numbers
|
||||
return function (t: number) {
|
||||
return (a * (1 - t) + b * t) + 'px'; // a and b are numbers based on Range Type, return value of interpolator is string based on Output type
|
||||
};
|
||||
return (t: number) => (a * (1 - t) + b * t) + 'px'; // a and b are numbers based on Range Type, return value of interpolator is string based on Output type
|
||||
});
|
||||
|
||||
// Changes scale output type (inferred generic)
|
||||
linearScaleNumString = linearScaleNumber.interpolate(function (a, b) {
|
||||
linearScaleNumString = linearScaleNumber.interpolate((a, b) => {
|
||||
// take two numbers
|
||||
return function (t: number) {
|
||||
return (a * (1 - t) + b * t) + 'px'; // a and b are numbers based on Range Type, return value of interpolator is string based on Output type
|
||||
};
|
||||
return (t: number) => (a * (1 - t) + b * t) + 'px'; // a and b are numbers based on Range Type, return value of interpolator is string based on Output type
|
||||
});
|
||||
|
||||
// nice(...) -----------------------------------------------------------------------
|
||||
@@ -249,11 +245,9 @@ clampFlag = powerScaleNumber.clamp();
|
||||
|
||||
powerScaleString = powerScaleString.interpolate(interpolateCubehelix.gamma(3));
|
||||
|
||||
powerScaleNumString = powerScaleNumString.interpolate(function (a, b) {
|
||||
powerScaleNumString = powerScaleNumString.interpolate((a, b) => {
|
||||
// take two numbers
|
||||
return function (t: number) {
|
||||
return (a * (1 - t) + b * t) + 'px'; // a and b are numbers based on Range Type, return value of interpolator is string based on Output type
|
||||
};
|
||||
return (t: number) => (a * (1 - t) + b * t) + 'px'; // a and b are numbers based on Range Type, return value of interpolator is string based on Output type
|
||||
});
|
||||
|
||||
// nice(...) -----------------------------------------------------------------------
|
||||
@@ -356,11 +350,9 @@ clampFlag = logScaleNumber.clamp();
|
||||
|
||||
logScaleString = logScaleString.interpolate(interpolateCubehelix.gamma(3));
|
||||
|
||||
logScaleNumString = logScaleNumString.interpolate(function (a, b) {
|
||||
logScaleNumString = logScaleNumString.interpolate((a, b) => {
|
||||
// take two numbers
|
||||
return function (t: number) {
|
||||
return (a * (1 - t) + b * t) + 'px'; // a and b are numbers based on Range Type, return value of interpolator is string based on Output type
|
||||
};
|
||||
return (t: number) => (a * (1 - t) + b * t) + 'px'; // a and b are numbers based on Range Type, return value of interpolator is string based on Output type
|
||||
});
|
||||
|
||||
// nice(...) -----------------------------------------------------------------------
|
||||
@@ -517,11 +509,9 @@ clampFlag = localTimeScaleNumber.clamp();
|
||||
|
||||
localTimeScaleString = localTimeScaleString.interpolate(interpolateCubehelix.gamma(3));
|
||||
|
||||
localTimeScaleNumString = localTimeScaleNumString.interpolate(function (a, b) {
|
||||
localTimeScaleNumString = localTimeScaleNumString.interpolate((a, b) => {
|
||||
// take two numbers
|
||||
return function (t: number) {
|
||||
return (a * (1 - t) + b * t) + 'px'; // a and b are numbers based on Range Type, return value of interpolator is string based on Output type
|
||||
};
|
||||
return (t: number) => (a * (1 - t) + b * t) + 'px'; // a and b are numbers based on Range Type, return value of interpolator is string based on Output type
|
||||
});
|
||||
|
||||
// nice(...) -----------------------------------------------------------------------
|
||||
|
||||
+42
-42
@@ -86,7 +86,7 @@ svgArc = svgArc.context(null); // use as path string generator for SVG
|
||||
|
||||
canvasArc = canvasArc.innerRadius(40);
|
||||
|
||||
svgArc = svgArc.innerRadius(function (d) {
|
||||
svgArc = svgArc.innerRadius(d => {
|
||||
return d.iRadius; // datum type is ArcDatum
|
||||
});
|
||||
accessorArcDatumNumber = svgArc.innerRadius();
|
||||
@@ -95,7 +95,7 @@ accessorArcDatumNumber = svgArc.innerRadius();
|
||||
|
||||
canvasArc = canvasArc.outerRadius(60);
|
||||
|
||||
svgArc = svgArc.outerRadius(function (d) {
|
||||
svgArc = svgArc.outerRadius(d => {
|
||||
return d.oRadius; // datum type is ArcDatum
|
||||
});
|
||||
accessorArcDatumNumber = svgArc.outerRadius();
|
||||
@@ -104,7 +104,7 @@ accessorArcDatumNumber = svgArc.outerRadius();
|
||||
|
||||
canvasArc = canvasArc.cornerRadius(4);
|
||||
|
||||
svgArc = svgArc.cornerRadius(function (d) {
|
||||
svgArc = svgArc.cornerRadius(d => {
|
||||
return d.oRadius / 10; // datum type is ArcDatum
|
||||
});
|
||||
accessorArcDatumNumber = svgArc.cornerRadius();
|
||||
@@ -113,7 +113,7 @@ accessorArcDatumNumber = svgArc.cornerRadius();
|
||||
|
||||
canvasArc = canvasArc.startAngle(0);
|
||||
|
||||
svgArc = svgArc.startAngle(function (d) {
|
||||
svgArc = svgArc.startAngle(d => {
|
||||
return d.sAngle; // datum type is ArcDatum
|
||||
});
|
||||
accessorArcDatumNumber = svgArc.startAngle();
|
||||
@@ -122,7 +122,7 @@ accessorArcDatumNumber = svgArc.startAngle();
|
||||
|
||||
canvasArc = canvasArc.endAngle(Math.PI / 2);
|
||||
|
||||
svgArc = svgArc.endAngle(function (d) {
|
||||
svgArc = svgArc.endAngle(d => {
|
||||
return d.eAngle; // datum type is ArcDatum
|
||||
});
|
||||
accessorArcDatumNumber = svgArc.endAngle();
|
||||
@@ -131,7 +131,7 @@ accessorArcDatumNumber = svgArc.endAngle();
|
||||
|
||||
canvasArc = canvasArc.padAngle(0);
|
||||
|
||||
svgArc = svgArc.padAngle(function (d) {
|
||||
svgArc = svgArc.padAngle(d => {
|
||||
return d.pAngle; // datum type is ArcDatum
|
||||
});
|
||||
accessorArcDatumNumber = svgArc.padAngle();
|
||||
@@ -140,7 +140,7 @@ accessorArcDatumNumber = svgArc.padAngle();
|
||||
|
||||
canvasArc = canvasArc.padRadius(0);
|
||||
|
||||
svgArc = svgArc.padRadius(function (d) {
|
||||
svgArc = svgArc.padRadius(d => {
|
||||
return Math.sqrt(d.iRadius * d.iRadius + d.oRadius * d.oRadius);
|
||||
});
|
||||
|
||||
@@ -192,10 +192,10 @@ class Arcer {
|
||||
this.cornerRadius = 3;
|
||||
|
||||
this.arc = d3Shape.arc<Arcer, ArcerDatum>()
|
||||
.innerRadius(function (d) {
|
||||
.innerRadius(d => {
|
||||
return Math.min(d.innerRadius, this.innerRadius);
|
||||
})
|
||||
.outerRadius(function (d) {
|
||||
.outerRadius(d => {
|
||||
return Math.min(d.outerRadius, this.outerRadius);
|
||||
})
|
||||
.cornerRadius(this.cornerRadius)
|
||||
@@ -274,7 +274,7 @@ defaultPieValueAccessor = defaultPie.value();
|
||||
|
||||
let pieValueAccessor: (d: PieDatum, i?: number, data?: PieDatum[]) => number;
|
||||
|
||||
pie = pie.value(function (d, i, data) {
|
||||
pie = pie.value((d, i, data) => {
|
||||
console.log(data.length > 0 ? data[0].val : 'no data'); // data type is Array<PieDatum>
|
||||
return d.val; // d type is PieDatum
|
||||
});
|
||||
@@ -286,7 +286,7 @@ pieValueAccessor = pie.value();
|
||||
|
||||
let pieSorter: ((a: PieDatum, b: PieDatum) => number) | null;
|
||||
|
||||
pie = pie.sort(function (a, b) {
|
||||
pie = pie.sort((a, b) => {
|
||||
return b.val - a.val; // type of a and b is PieDatum
|
||||
});
|
||||
|
||||
@@ -298,7 +298,7 @@ pie = pie.sort(null);
|
||||
|
||||
let pieValuesSorter: ((a: number, b: number) => number) | null;
|
||||
|
||||
pie = pie.sortValues(function (a, b) {
|
||||
pie = pie.sortValues((a, b) => {
|
||||
return b - a; // type of a and b is number
|
||||
});
|
||||
|
||||
@@ -310,7 +310,7 @@ pie = pie.sortValues(null);
|
||||
|
||||
defaultPie = defaultPie.startAngle(0);
|
||||
|
||||
pie = pie.startAngle(function (d) {
|
||||
pie = pie.startAngle(d => {
|
||||
console.log(d.length > 0 ? d[0].val : 'no data'); // data type is Array<PieDatum>
|
||||
return 0;
|
||||
});
|
||||
@@ -320,7 +320,7 @@ accessorPieDatumNumber = pie.startAngle();
|
||||
|
||||
defaultPie = defaultPie.endAngle(2 * Math.PI);
|
||||
|
||||
pie = pie.endAngle(function (d) {
|
||||
pie = pie.endAngle(d => {
|
||||
console.log(d.length > 0 ? d[0].val : 'no data'); // data type is Array<PieDatum>
|
||||
return 2 * Math.PI;
|
||||
});
|
||||
@@ -330,7 +330,7 @@ accessorPieDatumNumber = pie.endAngle();
|
||||
|
||||
defaultPie = defaultPie.padAngle(0.03);
|
||||
|
||||
pie = pie.padAngle(function (d) {
|
||||
pie = pie.padAngle(d => {
|
||||
console.log(d.length > 0 ? d[0].val : 'no data'); // data type is Array<PieDatum>
|
||||
return 0.03;
|
||||
|
||||
@@ -396,7 +396,7 @@ line = line.context(null); // use as path string generator for SVG
|
||||
|
||||
defaultLine = defaultLine.x(30);
|
||||
|
||||
line = line.x(function (d, t, data) {
|
||||
line = line.x((d, t, data) => {
|
||||
console.log('Number of Points: ', data.length);
|
||||
console.log('X-Coordinate of first point: ', data[0].x); // data type is Array<LineDatum>
|
||||
return d.x; // d type is LineDatum
|
||||
@@ -408,7 +408,7 @@ lineXYAccessorFn = line.x();
|
||||
|
||||
defaultLine = defaultLine.y(10);
|
||||
|
||||
line = line.y(function (d, t, data) {
|
||||
line = line.y((d, t, data) => {
|
||||
console.log('Number of Points: ', data.length);
|
||||
console.log('Y-Coordinate of first point: ', data[0].y); // data type is Array<LineDatum>
|
||||
return d.y; // d type is LineDatum
|
||||
@@ -420,7 +420,7 @@ lineXYAccessorFn = line.y();
|
||||
|
||||
defaultLine = defaultLine.defined(true);
|
||||
|
||||
line = line.defined(function (d, t, data) {
|
||||
line = line.defined((d, t, data) => {
|
||||
console.log('Number of Points: ', data.length);
|
||||
console.log('Y-Coordinate of first point: ', data[0].y); // data type is Array<LineDatum>
|
||||
return !d.missing; // d type is LineDatum
|
||||
@@ -468,7 +468,7 @@ radialLine = radialLine.context(null); // use as path string generator for SVG
|
||||
|
||||
defaultRadialLine = defaultRadialLine.angle(Math.PI);
|
||||
|
||||
radialLine = radialLine.angle(function (d, t, data) {
|
||||
radialLine = radialLine.angle((d, t, data) => {
|
||||
console.log('Number of Points: ', data.length);
|
||||
console.log('Angle of first point: ', data[0].angle); // data type is Array<RadialLineDatum>
|
||||
return d.angle; // d type is RadialLineDatum
|
||||
@@ -480,7 +480,7 @@ radialLineAngRAccessorFn = radialLine.angle();
|
||||
|
||||
defaultRadialLine = defaultRadialLine.radius(30);
|
||||
|
||||
radialLine = radialLine.radius(function (d, t, data) {
|
||||
radialLine = radialLine.radius((d, t, data) => {
|
||||
console.log('Number of Points: ', data.length);
|
||||
console.log('Angle of first point: ', data[0].angle); // data type is Array<RadialLineDatum>
|
||||
return d.radius; // d type is RadialLineDatum
|
||||
@@ -492,7 +492,7 @@ radialLineAngRAccessorFn = radialLine.radius();
|
||||
|
||||
defaultRadialLine = defaultRadialLine.defined(true);
|
||||
|
||||
radialLine = radialLine.defined(function (d, t, data) {
|
||||
radialLine = radialLine.defined((d, t, data) => {
|
||||
console.log('Number of Points: ', data.length);
|
||||
console.log('Angle of first point: ', data[0].angle); // data type is Array<RadialLineDatum>
|
||||
return !d.missing; // d type is RadialLineDatum
|
||||
@@ -569,7 +569,7 @@ area = area.context(null); // use as path string generator for SVG
|
||||
|
||||
defaultArea = defaultArea.x(30);
|
||||
|
||||
area = area.x(function (d, t, data) {
|
||||
area = area.x((d, t, data) => {
|
||||
console.log('Number of Points: ', data.length);
|
||||
console.log('X0-Coordinate of first point: ', data[0].x0); // data type is Array<AreaDatum>
|
||||
return d.x0; // d type is AreaDatum
|
||||
@@ -581,7 +581,7 @@ areaXYAccessorFn = area.x();
|
||||
|
||||
defaultArea = defaultArea.x0(30);
|
||||
|
||||
area = area.x0(function (d, t, data) {
|
||||
area = area.x0((d, t, data) => {
|
||||
console.log('Number of Points: ', data.length);
|
||||
console.log('X0-Coordinate of first point: ', data[0].x0); // data type is Array<AreaDatum>
|
||||
return d.x0; // d type is AreaDatum
|
||||
@@ -593,7 +593,7 @@ areaXYAccessorFn = area.x0();
|
||||
|
||||
defaultArea = defaultArea.x1(30);
|
||||
|
||||
area = area.x1(function (d, t, data) {
|
||||
area = area.x1((d, t, data) => {
|
||||
console.log('Number of Points: ', data.length);
|
||||
console.log('X1-Coordinate of first point: ', data[0].x1); // data type is Array<AreaDatum>
|
||||
return d.x1; // d type is AreaDatum
|
||||
@@ -605,7 +605,7 @@ areaXYAccessorFnMaybe = area.x1();
|
||||
|
||||
defaultArea = defaultArea.y(10);
|
||||
|
||||
area = area.y(function (d, t, data) {
|
||||
area = area.y((d, t, data) => {
|
||||
console.log('Number of Points: ', data.length);
|
||||
console.log('Y0-Coordinate of first point: ', data[0].y0); // data type is Array<AreaDatum>
|
||||
return d.y0; // d type is AreaDatum
|
||||
@@ -617,7 +617,7 @@ areaXYAccessorFn = area.y();
|
||||
|
||||
defaultArea = defaultArea.y0(10);
|
||||
|
||||
area = area.y0(function (d, t, data) {
|
||||
area = area.y0((d, t, data) => {
|
||||
console.log('Number of Points: ', data.length);
|
||||
console.log('Y0-Coordinate of first point: ', data[0].y0); // data type is Array<AreaDatum>
|
||||
return d.y0; // d type is AreaDatum
|
||||
@@ -629,7 +629,7 @@ areaXYAccessorFn = area.y0();
|
||||
|
||||
defaultArea = defaultArea.y1(10);
|
||||
|
||||
area = area.y1(function (d, t, data) {
|
||||
area = area.y1((d, t, data) => {
|
||||
console.log('Number of Points: ', data.length);
|
||||
console.log('Y1-Coordinate of first point: ', data[0].y1); // data type is Array<AreaDatum>
|
||||
return d.y1; // d type is AreaDatum
|
||||
@@ -641,7 +641,7 @@ areaXYAccessorFnMaybe = area.y1();
|
||||
|
||||
defaultArea = defaultArea.defined(true);
|
||||
|
||||
area = area.defined(function (d, t, data) {
|
||||
area = area.defined((d, t, data) => {
|
||||
console.log('Number of Points: ', data.length);
|
||||
console.log('Y0-Coordinate of first point: ', data[0].y0); // data type is Array<AreaDatum>
|
||||
return !d.missing; // d type is AreaDatum
|
||||
@@ -699,7 +699,7 @@ radialArea = radialArea.context(null); // use as path string generator for SVG
|
||||
|
||||
defaultRadialArea = defaultRadialArea.angle(Math.PI);
|
||||
|
||||
radialArea = radialArea.angle(function (d, t, data) {
|
||||
radialArea = radialArea.angle((d, t, data) => {
|
||||
console.log('Number of Points: ', data.length);
|
||||
console.log('Start angle of first point: ', data[0].startAngle); // data type is Array<RadialAreaDatum>
|
||||
return d.startAngle; // d type is RadialAreaDatum
|
||||
@@ -711,7 +711,7 @@ radialAreaAngRAccessorFn = radialArea.angle();
|
||||
|
||||
defaultRadialArea = defaultRadialArea.startAngle(Math.PI);
|
||||
|
||||
radialArea = radialArea.startAngle(function (d, t, data) {
|
||||
radialArea = radialArea.startAngle((d, t, data) => {
|
||||
console.log('Number of Points: ', data.length);
|
||||
console.log('Start angle of first point: ', data[0].startAngle); // data type is Array<RadialAreaDatum>
|
||||
return d.startAngle; // d type is RadialAreaDatum
|
||||
@@ -723,7 +723,7 @@ radialAreaAngRAccessorFn = radialArea.startAngle();
|
||||
|
||||
defaultRadialArea = defaultRadialArea.endAngle(Math.PI);
|
||||
|
||||
radialArea = radialArea.endAngle(function (d, t, data) {
|
||||
radialArea = radialArea.endAngle((d, t, data) => {
|
||||
console.log('Number of Points: ', data.length);
|
||||
console.log('End angle of first point: ', data[0].endAngle); // data type is Array<RadialAreaDatum>
|
||||
return d.endAngle; // d type is RadialAreaDatum
|
||||
@@ -735,7 +735,7 @@ radialAreaAngRAccessorFnMaybe = radialArea.endAngle();
|
||||
|
||||
defaultRadialArea = defaultRadialArea.radius(10);
|
||||
|
||||
radialArea = radialArea.radius(function (d, t, data) {
|
||||
radialArea = radialArea.radius((d, t, data) => {
|
||||
console.log('Number of Points: ', data.length);
|
||||
console.log('Inner radius of first point: ', data[0].innerRadius); // data type is Array<RadialAreaDatum>
|
||||
return d.innerRadius; // d type is RadialAreaDatum
|
||||
@@ -747,7 +747,7 @@ radialAreaAngRAccessorFn = radialArea.radius();
|
||||
|
||||
defaultRadialArea = defaultRadialArea.innerRadius(10);
|
||||
|
||||
radialArea = radialArea.innerRadius(function (d, t, data) {
|
||||
radialArea = radialArea.innerRadius((d, t, data) => {
|
||||
console.log('Number of Points: ', data.length);
|
||||
console.log('Inner radius of first point: ', data[0].innerRadius); // data type is Array<RadialAreaDatum>
|
||||
return d.innerRadius; // d type is RadialAreaDatum
|
||||
@@ -759,7 +759,7 @@ radialAreaAngRAccessorFn = radialArea.innerRadius();
|
||||
|
||||
defaultRadialArea = defaultRadialArea.outerRadius(20);
|
||||
|
||||
radialArea = radialArea.outerRadius(function (d, t, data) {
|
||||
radialArea = radialArea.outerRadius((d, t, data) => {
|
||||
console.log('Number of Points: ', data.length);
|
||||
console.log('Outer radius of first point: ', data[0].outerRadius); // data type is Array<RadialAreaDatum>
|
||||
return d.outerRadius; // d type is RadialAreaDatum
|
||||
@@ -771,7 +771,7 @@ radialAreaAngRAccessorFnMaybe = radialArea.outerRadius();
|
||||
|
||||
defaultRadialArea = defaultRadialArea.defined(true);
|
||||
|
||||
radialArea = radialArea.defined(function (d, t, data) {
|
||||
radialArea = radialArea.defined((d, t, data) => {
|
||||
console.log('Number of Points: ', data.length);
|
||||
console.log('Inner radius of first point: ', data[0].innerRadius); // data type is Array<RadialAreaDatum>
|
||||
return !d.missing; // d type is RadialAreaDatum
|
||||
@@ -925,7 +925,7 @@ interface SymbolDatum {
|
||||
let customSymbol: d3Shape.SymbolType;
|
||||
|
||||
customSymbol = {
|
||||
draw: function (context: CanvasPathMethods, size: number): void {
|
||||
draw(context: CanvasPathMethods, size: number): void {
|
||||
// draw custom symbol using canvas path methods
|
||||
}
|
||||
};
|
||||
@@ -955,7 +955,7 @@ svgSymbol = svgSymbol.context(null); // use as path string generator for SVG
|
||||
|
||||
canvasSymbol = canvasSymbol.size(30);
|
||||
|
||||
svgSymbol = svgSymbol.size(function (d) {
|
||||
svgSymbol = svgSymbol.size(d => {
|
||||
return d.size; // datum type is SymbolDatum
|
||||
});
|
||||
|
||||
@@ -966,7 +966,7 @@ sizeAccessorFn = svgSymbol.size();
|
||||
|
||||
canvasSymbol = canvasSymbol.type(d3Shape.symbolDiamond);
|
||||
|
||||
svgSymbol = svgSymbol.type(function (d) {
|
||||
svgSymbol = svgSymbol.type(d => {
|
||||
let t: d3Shape.SymbolType;
|
||||
switch (d.type) { // datum type is SymbolDatum
|
||||
case 'circle':
|
||||
@@ -1023,10 +1023,10 @@ class Symbolizer {
|
||||
break;
|
||||
}
|
||||
this.symbol = d3Shape.symbol<Symbolizer, SymbolDatum>()
|
||||
.size(function (this: Symbolizer, d?: SymbolDatum) {
|
||||
.size(function(this: Symbolizer, d?: SymbolDatum) {
|
||||
return d ? d.size : this.size;
|
||||
})
|
||||
.type(function (this: Symbolizer, d?: SymbolDatum) {
|
||||
.type(function(this: Symbolizer, d?: SymbolDatum) {
|
||||
let type = this.type;
|
||||
if (d && d.type) {
|
||||
switch (d.type) {
|
||||
@@ -1118,7 +1118,7 @@ overlyComplicatedStack = d3Shape.stack<StackDatum, StackKey>();
|
||||
|
||||
defaultStack = defaultStack.keys(['bananas', 'apples', 'oranges']);
|
||||
|
||||
overlyComplicatedStack = overlyComplicatedStack.keys(function (data: StackDatum[], keys: StackKey[]) {
|
||||
overlyComplicatedStack = overlyComplicatedStack.keys((data: StackDatum[], keys: StackKey[]) => {
|
||||
return keys;
|
||||
});
|
||||
|
||||
@@ -1129,7 +1129,7 @@ keysAccessor = overlyComplicatedStack.keys();
|
||||
|
||||
defaultStack = defaultStack.value(30);
|
||||
|
||||
overlyComplicatedStack = overlyComplicatedStack.value(function (d, key, j, data) {
|
||||
overlyComplicatedStack = overlyComplicatedStack.value((d, key, j, data) => {
|
||||
return d.values[key.name];
|
||||
});
|
||||
|
||||
|
||||
@@ -97,30 +97,30 @@ let circles: Selection<SVGCircleElement, CircleDatum, SVGSVGElement, SVGDatum>;
|
||||
|
||||
circles = select<SVGSVGElement, any>('svg')
|
||||
.datum(dimensions)
|
||||
.attr('width', function (d) { return d.width; })
|
||||
.attr('height', function (d) { return d.height; })
|
||||
.attr('width', d => d.width)
|
||||
.attr('height', d => d.height)
|
||||
.selectAll()
|
||||
.data(startCircleData)
|
||||
.enter()
|
||||
.append<SVGCircleElement>('circle')
|
||||
.attr('cx', function (d) { return d.cx; })
|
||||
.attr('cy', function (d) { return d.cy; })
|
||||
.attr('r', function (d) { return d.r; })
|
||||
.style('stroke', function (d) { return d.color; })
|
||||
.style('fill', function (d) { return d.color; });
|
||||
.attr('cx', d => d.cx)
|
||||
.attr('cy', d => d.cy)
|
||||
.attr('r', d => d.r)
|
||||
.style('stroke', d => d.color)
|
||||
.style('fill', d => d.color);
|
||||
|
||||
circles = circles
|
||||
.data(endCircleData, function (d) { return d.nodeId; });
|
||||
.data(endCircleData, d => d.nodeId);
|
||||
|
||||
let enterCircles = circles
|
||||
.enter()
|
||||
.append<SVGCircleElement>('circle')
|
||||
.classed('big', function (d) { return d.r > 10; })
|
||||
.attr('cx', function (d) { return d.cx; })
|
||||
.attr('cy', function (d) { return d.cy; })
|
||||
.attr('r', function (d) { return d.r; })
|
||||
.style('stroke', function (d) { return d.color; })
|
||||
.style('fill', function (d) { return d.color; });
|
||||
.classed('big', d => d.r > 10)
|
||||
.attr('cx', d => d.cx)
|
||||
.attr('cy', d => d.cy)
|
||||
.attr('r', d => d.r)
|
||||
.style('stroke', d => d.color)
|
||||
.style('fill', d => d.color);
|
||||
|
||||
|
||||
let exitCircles = circles.exit<CircleDatum>(); // Note: need to re-type datum type, as the exit selection elements have the 'old data'
|
||||
@@ -171,9 +171,7 @@ let delay: number = enterTransition.delay();
|
||||
|
||||
let easingFn: (normalizedTime: number) => number;
|
||||
|
||||
enterTransition = enterTransition.ease(function (t) {
|
||||
return t;
|
||||
}); // settable and chainable
|
||||
enterTransition = enterTransition.ease(t => t); // settable and chainable
|
||||
easingFn = enterTransition.ease();
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -327,7 +325,7 @@ select<HTMLBodyElement, { test: string }>('body')
|
||||
.transition().duration(500)
|
||||
.text('Let us start with this transition text.')
|
||||
.transition().duration(100)
|
||||
.text(function (d) { return d.test; }); // selection datum type
|
||||
.text(d => d.test); // selection datum type
|
||||
|
||||
|
||||
// test, when it is not certain, whether an element of the type to be selected exists
|
||||
@@ -461,8 +459,8 @@ enterTransition = enterTransition.each(function (d, i, g) { // check chaining r
|
||||
|
||||
function changeExitColor(transition: d3Transition.Transition<SVGCircleElement, CircleDatum, any, any>, fill: string, stroke: string) {
|
||||
transition
|
||||
.style('fill', function (d) { return (d.r < 10) ? fill : 'black'; }) // datum type is CircleDatum
|
||||
.style('stroke', function (d) { return (this.r.baseVal.value < 10) ? stroke : 'black'; }); // this type is SVGCircleElement
|
||||
.style('fill', d => (d.r < 10) ? fill : 'black') // datum type is CircleDatum
|
||||
.style('stroke', function(d) { return (this.r.baseVal.value < 10) ? stroke : 'black'; }); // this type is SVGCircleElement
|
||||
}
|
||||
|
||||
// returns 'this' transition
|
||||
|
||||
@@ -30,8 +30,8 @@ interface CanvasDatum {
|
||||
|
||||
let canvas = select<HTMLCanvasElement, any>('canvas')
|
||||
.datum<CanvasDatum>({ width: 500, height: 400, radius: 2.5 })
|
||||
.attr('width', function (d) { return d.width; })
|
||||
.attr('height', function (d) { return d.height; });
|
||||
.attr('width', d => d.width)
|
||||
.attr('height', d => d.height);
|
||||
|
||||
let context = canvas.node()!.getContext('2d');
|
||||
|
||||
@@ -44,8 +44,7 @@ function drawPointsOnCanvas(radius: number) {
|
||||
}
|
||||
|
||||
function drawPointOnCanvas(radius: number) {
|
||||
|
||||
return function (point: [number, number]) {
|
||||
return (point: [number, number]) => {
|
||||
if (context) {
|
||||
context.moveTo(point[0] + radius, point[1]);
|
||||
context.arc(point[0], point[1], radius, 0, 2 * Math.PI);
|
||||
@@ -64,8 +63,8 @@ interface SVGDatum {
|
||||
|
||||
let svg = select<SVGSVGElement, undefined>('svg')
|
||||
.datum<SVGDatum>({ width: 500, height: 500, filterBrushEvent: true })
|
||||
.attr('width', function (d) { return d.width; })
|
||||
.attr('height', function (d) { return d.height; });
|
||||
.attr('width', d => d.width)
|
||||
.attr('height', d => d.height);
|
||||
|
||||
|
||||
let g = svg.append<SVGGElement>('g');
|
||||
@@ -73,8 +72,8 @@ let g = svg.append<SVGGElement>('g');
|
||||
g.selectAll()
|
||||
.data<[number, number]>(points)
|
||||
.enter().append<SVGCircleElement>('circle')
|
||||
.attr('cx', function (d) { return d[0]; })
|
||||
.attr('cy', function (d) { return d[1]; })
|
||||
.attr('cx', d => d[0])
|
||||
.attr('cy', d => d[1])
|
||||
.attr('r', 2.5);
|
||||
|
||||
// For test of using zoomBehavior to transform selections and transitions ----
|
||||
@@ -135,7 +134,6 @@ svgZoom = d3Zoom.zoom<SVGRectElement, SVGDatum>();
|
||||
|
||||
// chainable
|
||||
svgZoom = svgZoom.filter(function (d, i, group) {
|
||||
|
||||
// Cast d3 event to D3ZoomEvent to be used in filter logic
|
||||
let e = <d3Zoom.D3ZoomEvent<SVGRectElement, SVGDatum>> event;
|
||||
|
||||
@@ -235,8 +233,8 @@ canvas.call(canvasZoom);
|
||||
|
||||
// attach the zoom behavior to an overlay svg rectangle
|
||||
let svgOverlay: Selection<SVGRectElement, SVGDatum, HTMLElement, any> = svg.append<SVGRectElement>('rect')
|
||||
.attr('width', function (d) { return d.width; })
|
||||
.attr('height', function (d) { return d.height; })
|
||||
.attr('width', d => d.width)
|
||||
.attr('height', d => d.height)
|
||||
.style('fill', 'none')
|
||||
.style('pointer-events', 'all')
|
||||
.call(svgZoom);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace DagreTests {
|
||||
const gDagre = new dagre.graphlib.Graph();
|
||||
gDagre.setGraph({})
|
||||
.setDefaultEdgeLabel(function(){ return ; })
|
||||
.setDefaultEdgeLabel(() => {})
|
||||
.setNode("a", {})
|
||||
.setEdge("b", "c")
|
||||
.setEdge("c", "d", {class: "class"});
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
/// <reference types="jquery" />
|
||||
/// <reference types="jquery.dataTables" />
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$(document).ready(() => {
|
||||
var config: DataTables.Settings = {
|
||||
// FixedHeader extension options
|
||||
fixedHeader: {
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
/// <reference types="jquery" />
|
||||
/// <reference types="jquery.dataTables" />
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$(document).ready(() => {
|
||||
var config: DataTables.Settings = {
|
||||
// Select extension options
|
||||
select: {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
/// <reference path="index.d.ts"/>
|
||||
|
||||
//constructor
|
||||
var constructorNoOptions = new Dropkick('#my-select');
|
||||
var constructorNoOptions2 = new Dropkick(new HTMLSelectElement());
|
||||
|
||||
@@ -12,7 +12,7 @@ App.country.get('presidentName');
|
||||
App.president = Em.Object.create({
|
||||
firstName: 'Barack',
|
||||
lastName: 'Obama',
|
||||
fullName: function () {
|
||||
fullName: function() {
|
||||
return this.get('firstName') + ' ' + this.get('lastName');
|
||||
}.property()
|
||||
});
|
||||
@@ -33,7 +33,7 @@ declare class MyPerson2 extends Em.Object {
|
||||
}
|
||||
var tom = Person1.create<MyPerson2>({
|
||||
name: 'Tom Dale',
|
||||
helloWorld: function() {
|
||||
helloWorld() {
|
||||
this.say('Hi my name is ' + this.get('name'));
|
||||
}
|
||||
});
|
||||
@@ -106,9 +106,8 @@ App.userController = Em.Object.create({
|
||||
})
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('highlight', function(property: string, options: any) {
|
||||
return new Handlebars.SafeString('<span class="highlight">' + "some value" + '</span>');
|
||||
});
|
||||
Handlebars.registerHelper('highlight', (property: string, options: any) =>
|
||||
new Handlebars.SafeString('<span class="highlight">' + "some value" + '</span>'));
|
||||
|
||||
var coolView = App.CoolView.create();
|
||||
|
||||
@@ -154,9 +153,9 @@ var promise = new Em.RSVP.Promise<string, string>(function(resolve: Function, re
|
||||
reject('no-k!');
|
||||
});
|
||||
|
||||
promise.then(function(value: any) {
|
||||
promise.then((value: any) => {
|
||||
// on fulfillment
|
||||
}, function(reason: any) {
|
||||
}, (reason: any) => {
|
||||
// on rejection
|
||||
});
|
||||
|
||||
|
||||
+110
-117
@@ -6,15 +6,15 @@ function sample1() {
|
||||
selection: false,
|
||||
});
|
||||
|
||||
canvas.on('object:moving', function(e: fabric.IEvent) {
|
||||
canvas.on('object:moving', (e: fabric.IEvent) => {
|
||||
e.target.opacity = 0.5;
|
||||
});
|
||||
canvas.on('object:modified', function(e: fabric.IEvent) {
|
||||
canvas.on('object:modified', (e: fabric.IEvent) => {
|
||||
e.target.opacity = 1;
|
||||
});
|
||||
|
||||
for (var i = 0, len = 15; i < len; i++) {
|
||||
fabric.Image.fromURL('../assets/ladybug.png', function(img) {
|
||||
fabric.Image.fromURL('../assets/ladybug.png', img => {
|
||||
img.set({
|
||||
left: fabric.util.getRandomInt(0, 600),
|
||||
top: fabric.util.getRandomInt(0, 500),
|
||||
@@ -36,11 +36,11 @@ function sample2() {
|
||||
|
||||
var dot: fabric.Circle, i: number,
|
||||
t1: number, t2: number,
|
||||
startTimer = function() {
|
||||
startTimer = () => {
|
||||
t1 = new Date().getTime();
|
||||
return t1;
|
||||
},
|
||||
stopTimer = function() {
|
||||
stopTimer = () => {
|
||||
t2 = new Date().getTime();
|
||||
return t2 - t1;
|
||||
},
|
||||
@@ -89,16 +89,16 @@ function sample2() {
|
||||
|
||||
function sample3() {
|
||||
|
||||
var $: (id: string) => HTMLElement = function(id: string) { return document.getElementById(id) };
|
||||
var $: (id: string) => HTMLElement = (id: string) => document.getElementById(id);
|
||||
|
||||
function applyFilter(index: number, filter: any) {
|
||||
var obj: fabric.Image = <fabric.Image>canvas.getActiveObject();
|
||||
var obj: fabric.Image = <fabric.Image> canvas.getActiveObject();
|
||||
obj.filters[index] = filter;
|
||||
obj.applyFilters(canvas.renderAll.bind(canvas));
|
||||
}
|
||||
|
||||
function applyFilterValue(index: number, prop: string, value: any) {
|
||||
var obj: fabric.Image = <fabric.Image>canvas.getActiveObject();
|
||||
var obj: fabric.Image = <fabric.Image> canvas.getActiveObject();
|
||||
if (obj.filters[index]) {
|
||||
obj.applyFilters(canvas.renderAll.bind(canvas));
|
||||
}
|
||||
@@ -108,20 +108,20 @@ function sample3() {
|
||||
f = fabric.Image.filters;
|
||||
|
||||
canvas.on({
|
||||
'object:selected': function() {
|
||||
fabric.util.toArray(document.getElementsByTagName('input')).forEach(function(el) { el.disabled = false; })
|
||||
'object:selected': () => {
|
||||
fabric.util.toArray(document.getElementsByTagName('input')).forEach(el => { el.disabled = false; });
|
||||
|
||||
var filters = ['grayscale', 'invert', 'remove-white', 'sepia', 'sepia2', 'brightness',
|
||||
'noise', 'gradient-transparency', 'pixelate', 'blur', 'sharpen'];
|
||||
|
||||
for (var i = 0; i < filters.length; i++) {
|
||||
var checkBox = <HTMLInputElement>$(filters[i]);
|
||||
var image = <fabric.Image>canvas.getActiveObject();
|
||||
var checkBox = <HTMLInputElement> $(filters[i]);
|
||||
var image = <fabric.Image> canvas.getActiveObject();
|
||||
checkBox.checked = !!image.filters[i];
|
||||
}
|
||||
},
|
||||
'selection:cleared': function() {
|
||||
fabric.util.toArray(document.getElementsByTagName('input')).forEach(function(el) { el.disabled = true; })
|
||||
'selection:cleared': () => {
|
||||
fabric.util.toArray(document.getElementsByTagName('input')).forEach(el => { el.disabled = true; });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -139,8 +139,8 @@ function sample3() {
|
||||
};
|
||||
$('remove-white').onclick = function(this: HTMLInputElement) {
|
||||
applyFilter(2, this.checked && new f.RemoveWhite({
|
||||
threshold: parseInt((<HTMLInputElement>$('remove-white-threshold')).value),
|
||||
distance: parseInt((<HTMLInputElement>$('remove-white-distance')).value)
|
||||
threshold: parseInt((<HTMLInputElement> $('remove-white-threshold')).value, 10),
|
||||
distance: parseInt((<HTMLInputElement> $('remove-white-distance')).value, 10)
|
||||
}));
|
||||
};
|
||||
$('remove-white-threshold').onchange = function(this: HTMLInputElement) {
|
||||
@@ -157,7 +157,7 @@ function sample3() {
|
||||
};
|
||||
$('brightness').onclick = function(this: HTMLInputElement) {
|
||||
applyFilter(5, this.checked && new f.Brightness({
|
||||
brightness: parseInt((<HTMLInputElement>$('brightness-value')).value, 10)
|
||||
brightness: parseInt((<HTMLInputElement> $('brightness-value')).value, 10)
|
||||
}));
|
||||
};
|
||||
$('brightness-value').onchange = function(this: HTMLInputElement) {
|
||||
@@ -165,7 +165,7 @@ function sample3() {
|
||||
};
|
||||
$('noise').onclick = function(this: HTMLInputElement) {
|
||||
applyFilter(6, this.checked && new f.Noise({
|
||||
noise: parseInt((<HTMLInputElement>$('noise-value')).value, 10)
|
||||
noise: parseInt((<HTMLInputElement> $('noise-value')).value, 10)
|
||||
}));
|
||||
};
|
||||
$('noise-value').onchange = function(this: HTMLInputElement) {
|
||||
@@ -173,7 +173,7 @@ function sample3() {
|
||||
};
|
||||
$('gradient-transparency').onclick = function(this: HTMLInputElement) {
|
||||
applyFilter(7, this.checked && new f.GradientTransparency({
|
||||
threshold: parseInt((<HTMLInputElement>$('gradient-transparency-value')).value, 10)
|
||||
threshold: parseInt((<HTMLInputElement> $('gradient-transparency-value')).value, 10)
|
||||
}));
|
||||
};
|
||||
$('gradient-transparency-value').onchange = function(this: HTMLInputElement) {
|
||||
@@ -181,7 +181,7 @@ function sample3() {
|
||||
};
|
||||
$('pixelate').onclick = function(this: HTMLInputElement) {
|
||||
applyFilter(8, this.checked && new f.Pixelate({
|
||||
blocksize: parseInt((<HTMLInputElement>$('pixelate-value')).value, 10)
|
||||
blocksize: parseInt((<HTMLInputElement> $('pixelate-value')).value, 10)
|
||||
}));
|
||||
};
|
||||
$('pixelate-value').onchange = function(this: HTMLInputElement) {
|
||||
@@ -225,25 +225,25 @@ function sample4() {
|
||||
|
||||
canvas.add(rect);
|
||||
|
||||
var angleControl = <HTMLInputElement>$('angle-control');
|
||||
var angleControl = <HTMLInputElement> $('angle-control');
|
||||
angleControl.onchange = function(this: HTMLInputElement) {
|
||||
rect.setAngle(+this.value).setCoords();
|
||||
canvas.renderAll();
|
||||
};
|
||||
|
||||
var scaleControl = <HTMLInputElement>$('scale-control');
|
||||
var scaleControl = <HTMLInputElement> $('scale-control');
|
||||
scaleControl.onchange = function(this: HTMLInputElement) {
|
||||
rect.scale(+this.value).setCoords();
|
||||
canvas.renderAll();
|
||||
};
|
||||
|
||||
var topControl = <HTMLInputElement>$('top-control');
|
||||
var topControl = <HTMLInputElement> $('top-control');
|
||||
topControl.onchange = function(this: HTMLInputElement) {
|
||||
rect.setTop(+this.value).setCoords();
|
||||
canvas.renderAll();
|
||||
};
|
||||
|
||||
var leftControl = <HTMLInputElement>$('left-control');
|
||||
var leftControl = <HTMLInputElement> $('left-control');
|
||||
leftControl.onchange = function(this: HTMLInputElement) {
|
||||
rect.setLeft(+this.value).setCoords();
|
||||
canvas.renderAll();
|
||||
@@ -275,7 +275,7 @@ declare module "fabric" {
|
||||
|
||||
function sample5() {
|
||||
var makeCircle = function(left: number, top: number, line1?: fabric.Line, line2?: fabric.Line, line3?: fabric.Line, line4?: fabric.Line): fabric.Circle {
|
||||
var c = <fabric.CircleWithLineInfos>new fabric.Circle({
|
||||
var c = <fabric.CircleWithLineInfos> new fabric.Circle({
|
||||
left: left,
|
||||
top: top,
|
||||
strokeWidth: 5,
|
||||
@@ -290,7 +290,7 @@ function sample5() {
|
||||
c.line4 = line4;
|
||||
c.hasControls = c.hasBorders = false;
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
function makeLine(coords: number[]) {
|
||||
return new fabric.Line(coords, {
|
||||
@@ -321,8 +321,8 @@ function sample5() {
|
||||
makeCircle(line6.x2, line6.y2, line6)
|
||||
);
|
||||
|
||||
canvas.on('object:moving', function(e) {
|
||||
var p = <fabric.CircleWithLineInfos>e.target;
|
||||
canvas.on('object:moving', e => {
|
||||
var p = <fabric.CircleWithLineInfos> e.target;
|
||||
p.line1 && p.line1.set({ 'x2': p.left, 'y2': p.top });
|
||||
p.line2 && p.line2.set({ 'x1': p.left, 'y1': p.top });
|
||||
p.line3 && p.line3.set({ 'x1': p.left, 'y1': p.top });
|
||||
@@ -333,7 +333,7 @@ function sample5() {
|
||||
|
||||
function sample6() {
|
||||
var canvas = new fabric.Canvas('c');
|
||||
fabric.loadSVGFromURL('../assets/135.svg', function(objects) {
|
||||
fabric.loadSVGFromURL('../assets/135.svg', objects => {
|
||||
var obj = objects[0].scale(0.25);
|
||||
canvas.centerObject(obj);
|
||||
canvas.add(obj);
|
||||
@@ -343,10 +343,10 @@ function sample6() {
|
||||
canvas.add(obj.clone(() => { }).set({ left: 100, top: 400, angle: -15 }));
|
||||
canvas.add(obj.clone(() => { }).set({ left: 480, top: 400, angle: 15 }));
|
||||
|
||||
canvas.on('mouse:move', function(options) {
|
||||
canvas.on('mouse:move', options => {
|
||||
var p = canvas.getPointer(options.e);
|
||||
|
||||
canvas.forEachObject(function(obj) {
|
||||
canvas.forEachObject(obj => {
|
||||
var distX = Math.abs(p.x - obj.left),
|
||||
distY = Math.abs(p.y - obj.top),
|
||||
dist = Math.round(Math.sqrt(Math.pow(distX, 2) + Math.pow(distY, 2)));
|
||||
@@ -368,9 +368,9 @@ function sample7() {
|
||||
|
||||
var canvas = new fabric.Canvas('c', { selection: false });
|
||||
|
||||
setInterval(function() {
|
||||
fabric.Image.fromURL('../assets/ladybug.png', function(obj) {
|
||||
var img = <fabric.ImageWithInfo>obj;
|
||||
setInterval(() => {
|
||||
fabric.Image.fromURL('../assets/ladybug.png', obj => {
|
||||
var img = <fabric.ImageWithInfo> obj;
|
||||
img.set('left', fabric.util.getRandomInt(200, 600)).set('top', -50);
|
||||
img.movingLeft = !!Math.round(Math.random());
|
||||
canvas.add(img);
|
||||
@@ -379,14 +379,13 @@ function sample7() {
|
||||
|
||||
|
||||
var animate = (function animate() {
|
||||
canvas.forEachObject(function(obj) {
|
||||
var img = <fabric.ImageWithInfo>obj;
|
||||
canvas.forEachObject(obj => {
|
||||
var img = <fabric.ImageWithInfo> obj;
|
||||
img.left += (img.movingLeft ? -1 : 1);
|
||||
img.top += 1;
|
||||
if (img.left > 900 || img.top > 500) {
|
||||
canvas.remove(img);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
img.setAngle(img.getAngle() + 2);
|
||||
}
|
||||
});
|
||||
@@ -404,7 +403,7 @@ function sample8() {
|
||||
str = '0' + str;
|
||||
}
|
||||
return str;
|
||||
};
|
||||
}
|
||||
|
||||
var getRandomInt = fabric.util.getRandomInt;
|
||||
|
||||
@@ -428,19 +427,18 @@ function sample8() {
|
||||
// canvas.controlsAboveOverlay = true;
|
||||
|
||||
function updateComplexity() {
|
||||
setTimeout(function() {
|
||||
var element = <HTMLElement>document.getElementById('complexity').childNodes[1];
|
||||
setTimeout(() => {
|
||||
var element = <HTMLElement> document.getElementById('complexity').childNodes[1];
|
||||
element.innerHTML = ' ' + canvas.complexity();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
document.getElementById('commands').onclick = function(ev: any) {
|
||||
document.getElementById('commands').onclick = (ev: any) => {
|
||||
var ev: any = ev || window.event;
|
||||
|
||||
if (ev.preventDefault) {
|
||||
ev.preventDefault()
|
||||
}
|
||||
else if (ev.returnValue) {
|
||||
ev.preventDefault();
|
||||
} else if (ev.returnValue) {
|
||||
ev.returnValue = false;
|
||||
}
|
||||
|
||||
@@ -521,8 +519,9 @@ function sample8() {
|
||||
break;
|
||||
|
||||
case 'shape':
|
||||
var id: any = element.id, match: RegExpExecArray;
|
||||
if (match = /\d+$/.exec(id)) {
|
||||
var id: any = element.id;
|
||||
const match = /\d+$/.exec(id);
|
||||
if (match) {
|
||||
fabric.loadSVGFromURL('../assets/' + match[0] + '.svg', function(objects, options) {
|
||||
var loadedObject = fabric.util.groupSVGElements(objects, options);
|
||||
|
||||
@@ -552,31 +551,29 @@ function sample8() {
|
||||
updateComplexity();
|
||||
};
|
||||
|
||||
document.getElementById('execute').onclick = function() {
|
||||
var code = (<HTMLInputElement>document.getElementById('canvas-console')).value;
|
||||
document.getElementById('execute').onclick = () => {
|
||||
var code = (<HTMLInputElement> document.getElementById('canvas-console')).value;
|
||||
if (!(/^\s+$/).test(code)) {
|
||||
eval(code);
|
||||
eval(code); // tslint:disable-line:no-eval
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
document.getElementById('rasterize').onclick = function() {
|
||||
document.getElementById('rasterize').onclick = () => {
|
||||
if (!fabric.Canvas.supports('toDataURL')) {
|
||||
alert('This browser doesn\'t provide means to serialize canvas to an image');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
window.open(canvas.toDataURL('png'));
|
||||
}
|
||||
};
|
||||
|
||||
var removeSelectedEl = document.getElementById('remove-selected');
|
||||
removeSelectedEl.onclick = function() {
|
||||
removeSelectedEl.onclick = () => {
|
||||
var activeObject = canvas.getActiveObject(),
|
||||
activeGroup = canvas.getActiveGroup();
|
||||
if (activeObject) {
|
||||
canvas.remove(activeObject);
|
||||
}
|
||||
else if (activeGroup) {
|
||||
} else if (activeGroup) {
|
||||
var objectsInGroup = activeGroup.getObjects();
|
||||
canvas.discardActiveGroup();
|
||||
objectsInGroup.forEach(function(object) {
|
||||
@@ -586,12 +583,11 @@ function sample8() {
|
||||
};
|
||||
|
||||
var supportsInputOfType = function(type: string) {
|
||||
return function() {
|
||||
var el = <HTMLInputElement>document.createElement('input');
|
||||
return () => {
|
||||
var el = document.createElement('input');
|
||||
try {
|
||||
el.type = type;
|
||||
}
|
||||
catch (err) { }
|
||||
} catch (err) { }
|
||||
return el.type === type;
|
||||
};
|
||||
};
|
||||
@@ -600,14 +596,14 @@ function sample8() {
|
||||
supportsColorpicker = supportsInputOfType('color');
|
||||
|
||||
if (supportsSlider()) {
|
||||
(function() {
|
||||
(() => {
|
||||
var controls = document.getElementById('controls');
|
||||
|
||||
var sliderLabel = <HTMLLabelElement>document.createElement('label');
|
||||
var sliderLabel = document.createElement('label');
|
||||
sliderLabel.htmlFor = 'opacity';
|
||||
sliderLabel.innerHTML = 'Opacity: ';
|
||||
|
||||
var slider = <HTMLInputElement>document.createElement('input');
|
||||
var slider = document.createElement('input');
|
||||
|
||||
try { slider.type = 'range'; } catch (err) { }
|
||||
|
||||
@@ -632,15 +628,15 @@ function sample8() {
|
||||
}
|
||||
|
||||
if (supportsColorpicker()) {
|
||||
(function() {
|
||||
(() => {
|
||||
var controls = document.getElementById('controls');
|
||||
|
||||
var label = <HTMLLabelElement>document.createElement('label');
|
||||
var label = document.createElement('label');
|
||||
label.htmlFor = 'color';
|
||||
label.innerHTML = 'Color: ';
|
||||
label.style.marginLeft = '10px';
|
||||
|
||||
var colorpicker = <HTMLInputElement>document.createElement('input');
|
||||
var colorpicker = document.createElement('input');
|
||||
colorpicker.type = 'color';
|
||||
colorpicker.id = 'color';
|
||||
colorpicker.style.width = '40px';
|
||||
@@ -663,7 +659,7 @@ function sample8() {
|
||||
}
|
||||
|
||||
var lockHorizontallyEl = document.getElementById('lock-horizontally');
|
||||
lockHorizontallyEl.onclick = function() {
|
||||
lockHorizontallyEl.onclick = () => {
|
||||
var activeObject: any = canvas.getActiveObject();
|
||||
if (activeObject) {
|
||||
activeObject.lockMovementX = !activeObject.lockMovementX;
|
||||
@@ -674,7 +670,7 @@ function sample8() {
|
||||
};
|
||||
|
||||
var lockVerticallyEl = document.getElementById('lock-vertically');
|
||||
lockVerticallyEl.onclick = function() {
|
||||
lockVerticallyEl.onclick = () => {
|
||||
var activeObject: any = canvas.getActiveObject();
|
||||
if (activeObject) {
|
||||
activeObject.lockMovementY = !activeObject.lockMovementY;
|
||||
@@ -685,7 +681,7 @@ function sample8() {
|
||||
};
|
||||
|
||||
var lockScalingXEl = document.getElementById('lock-scaling-x');
|
||||
lockScalingXEl.onclick = function() {
|
||||
lockScalingXEl.onclick = () => {
|
||||
var activeObject: any = canvas.getActiveObject();
|
||||
if (activeObject) {
|
||||
activeObject.lockScalingX = !activeObject.lockScalingX;
|
||||
@@ -696,7 +692,7 @@ function sample8() {
|
||||
};
|
||||
|
||||
var lockScalingYEl = document.getElementById('lock-scaling-y');
|
||||
lockScalingYEl.onclick = function() {
|
||||
lockScalingYEl.onclick = () => {
|
||||
var activeObject: any = canvas.getActiveObject();
|
||||
if (activeObject) {
|
||||
activeObject.lockScalingY = !activeObject.lockScalingY;
|
||||
@@ -707,7 +703,7 @@ function sample8() {
|
||||
};
|
||||
|
||||
var lockRotationEl = document.getElementById('lock-rotation');
|
||||
lockRotationEl.onclick = function() {
|
||||
lockRotationEl.onclick = () => {
|
||||
var activeObject: any = canvas.getActiveObject();
|
||||
if (activeObject) {
|
||||
activeObject.lockRotation = !activeObject.lockRotation;
|
||||
@@ -738,7 +734,7 @@ function sample8() {
|
||||
activeObjectButtons.push(colorEl);
|
||||
}
|
||||
|
||||
for (var i = activeObjectButtons.length; i--;) {
|
||||
for (var i = activeObjectButtons.length; i--; ) {
|
||||
activeObjectButtons[i];
|
||||
}
|
||||
|
||||
@@ -748,7 +744,7 @@ function sample8() {
|
||||
function onObjectSelected(e: fabric.IEvent) {
|
||||
var selectedObject = e.target;
|
||||
|
||||
for (var i = activeObjectButtons.length; i--;) {
|
||||
for (var i = activeObjectButtons.length; i--; ) {
|
||||
activeObjectButtons[i];
|
||||
}
|
||||
|
||||
@@ -760,39 +756,38 @@ function sample8() {
|
||||
}
|
||||
|
||||
canvas.on('selection:cleared', function(e) {
|
||||
for (var i = activeObjectButtons.length; i--;) {
|
||||
for (var i = activeObjectButtons.length; i--; ) {
|
||||
activeObjectButtons[i];
|
||||
}
|
||||
});
|
||||
|
||||
var drawingModeEl = document.getElementById('drawing-mode'),
|
||||
drawingOptionsEl = document.getElementById('drawing-mode-options'),
|
||||
drawingColorEl = <HTMLInputElement>document.getElementById('drawing-color'),
|
||||
drawingLineWidthEl = <HTMLInputElement>document.getElementById('drawing-line-width');
|
||||
drawingColorEl = document.getElementById('drawing-color'),
|
||||
drawingLineWidthEl = document.getElementById('drawing-line-width');
|
||||
|
||||
drawingModeEl.onclick = function() {
|
||||
drawingModeEl.onclick = () => {
|
||||
var canvasWithDrawingMode: any = canvas;
|
||||
canvasWithDrawingMode.isDrawingMode = !canvasWithDrawingMode.isDrawingMode;
|
||||
if (canvasWithDrawingMode.isDrawingMode) {
|
||||
drawingModeEl.innerHTML = 'Cancel drawing mode';
|
||||
drawingModeEl.className = 'is-drawing';
|
||||
drawingOptionsEl.style.display = '';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
drawingModeEl.innerHTML = 'Enter drawing mode';
|
||||
drawingModeEl.className = '';
|
||||
drawingOptionsEl.style.display = 'none';
|
||||
}
|
||||
};
|
||||
|
||||
canvas.on('path:created', function() {
|
||||
canvas.on('path:created', () => {
|
||||
updateComplexity();
|
||||
});
|
||||
|
||||
drawingColorEl.onchange = function() {
|
||||
drawingColorEl.onchange = () => {
|
||||
canvas.freeDrawingColor = drawingColorEl.value;
|
||||
};
|
||||
drawingLineWidthEl.onchange = function() {
|
||||
drawingLineWidthEl.onchange = () => {
|
||||
canvas.freeDrawingLineWidth = parseInt(drawingLineWidthEl.value, 10) || 1; // disallow 0, NaN, etc.
|
||||
};
|
||||
|
||||
@@ -803,7 +798,7 @@ function sample8() {
|
||||
var text = 'Lorem ipsum dolor sit amet,\nconsectetur adipisicing elit,\nsed do eiusmod tempor incididunt\nut labore et dolore magna aliqua.\n' +
|
||||
'Ut enim ad minim veniam,\nquis nostrud exercitation ullamco\nlaboris nisi ut aliquip ex ea commodo consequat.';
|
||||
|
||||
document.getElementById('add-text').onclick = function() {
|
||||
document.getElementById('add-text').onclick = () => {
|
||||
var textSample = new fabric.Text(text.slice(0, getRandomInt(0, text.length)), {
|
||||
left: getRandomInt(350, 400),
|
||||
top: getRandomInt(350, 400),
|
||||
@@ -829,8 +824,7 @@ function sample8() {
|
||||
// groupObjects.forEach(function(obj) {
|
||||
// canvas.remove(obj);
|
||||
// });
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//canvas.remove(obj);
|
||||
}
|
||||
canvas.renderAll();
|
||||
@@ -838,7 +832,7 @@ function sample8() {
|
||||
}
|
||||
};
|
||||
|
||||
setTimeout(function() {
|
||||
setTimeout(() => {
|
||||
canvas.calcOffset();
|
||||
}, 100);
|
||||
|
||||
@@ -847,7 +841,7 @@ function sample8() {
|
||||
//initAligningGuidelines(canvas);
|
||||
}
|
||||
|
||||
gradientifyBtn.onclick = function() {
|
||||
gradientifyBtn.onclick = () => {
|
||||
var obj = canvas.getActiveObject();
|
||||
if (obj) {
|
||||
obj.setGradient("fill", {
|
||||
@@ -862,13 +856,13 @@ function sample8() {
|
||||
}
|
||||
};
|
||||
|
||||
var textEl = <HTMLInputElement>document.getElementById('text');
|
||||
var textEl = document.getElementById('text');
|
||||
if (textEl) {
|
||||
textEl.onfocus = function() {
|
||||
var activeObject = canvas.getActiveObject();
|
||||
|
||||
if (activeObject && activeObject.type === 'text') {
|
||||
this.value = (<fabric.Text>activeObject).text;
|
||||
this.value = (<fabric.Text> activeObject).text;
|
||||
}
|
||||
};
|
||||
textEl.onkeyup = function(e) {
|
||||
@@ -876,9 +870,8 @@ function sample8() {
|
||||
if (activeObject) {
|
||||
if (!this.value) {
|
||||
canvas.discardActiveObject();
|
||||
}
|
||||
else {
|
||||
(<fabric.Text>activeObject).text = this.value;
|
||||
} else {
|
||||
(<fabric.Text> activeObject).text = this.value;
|
||||
}
|
||||
canvas.renderAll();
|
||||
}
|
||||
@@ -889,9 +882,9 @@ function sample8() {
|
||||
if (cmdUnderlineBtn) {
|
||||
activeObjectButtons.push(cmdUnderlineBtn);
|
||||
cmdUnderlineBtn.onclick = function() {
|
||||
var activeObject = <fabric.Text>canvas.getActiveObject();
|
||||
var activeObject = <fabric.Text> canvas.getActiveObject();
|
||||
if (activeObject && activeObject.type === 'text') {
|
||||
activeObject.textDecoration = (activeObject.textDecoration == 'underline' ? '' : 'underline');
|
||||
activeObject.textDecoration = (activeObject.textDecoration === 'underline' ? '' : 'underline');
|
||||
this.className = activeObject.textDecoration ? 'selected' : '';
|
||||
canvas.renderAll();
|
||||
}
|
||||
@@ -902,9 +895,9 @@ function sample8() {
|
||||
if (cmdLinethroughBtn) {
|
||||
activeObjectButtons.push(cmdLinethroughBtn);
|
||||
cmdLinethroughBtn.onclick = function() {
|
||||
var activeObject = <fabric.Text>canvas.getActiveObject();
|
||||
var activeObject = <fabric.Text> canvas.getActiveObject();
|
||||
if (activeObject && activeObject.type === 'text') {
|
||||
activeObject.textDecoration = (activeObject.textDecoration == 'line-through' ? '' : 'line-through');
|
||||
activeObject.textDecoration = (activeObject.textDecoration === 'line-through' ? '' : 'line-through');
|
||||
this.className = activeObject.textDecoration ? 'selected' : '';
|
||||
canvas.renderAll();
|
||||
}
|
||||
@@ -915,9 +908,9 @@ function sample8() {
|
||||
if (cmdOverlineBtn) {
|
||||
activeObjectButtons.push(cmdOverlineBtn);
|
||||
cmdOverlineBtn.onclick = function() {
|
||||
var activeObject = <fabric.Text>canvas.getActiveObject();
|
||||
var activeObject = <fabric.Text> canvas.getActiveObject();
|
||||
if (activeObject && activeObject.type === 'text') {
|
||||
activeObject.textDecoration = (activeObject.textDecoration == 'overline' ? '' : 'overline');
|
||||
activeObject.textDecoration = (activeObject.textDecoration === 'overline' ? '' : 'overline');
|
||||
this.className = activeObject.textDecoration ? 'selected' : '';
|
||||
canvas.renderAll();
|
||||
}
|
||||
@@ -928,9 +921,9 @@ function sample8() {
|
||||
if (cmdBoldBtn) {
|
||||
activeObjectButtons.push(cmdBoldBtn);
|
||||
cmdBoldBtn.onclick = function() {
|
||||
var activeObject = <fabric.Text>canvas.getActiveObject();
|
||||
var activeObject = <fabric.Text> canvas.getActiveObject();
|
||||
if (activeObject && activeObject.type === 'text') {
|
||||
activeObject.fontWeight = (activeObject.fontWeight == 'bold' ? '' : 'bold');
|
||||
activeObject.fontWeight = (activeObject.fontWeight === 'bold' ? '' : 'bold');
|
||||
this.className = activeObject.fontWeight ? 'selected' : '';
|
||||
canvas.renderAll();
|
||||
}
|
||||
@@ -941,9 +934,9 @@ function sample8() {
|
||||
if (cmdItalicBtn) {
|
||||
activeObjectButtons.push(cmdItalicBtn);
|
||||
cmdItalicBtn.onclick = function() {
|
||||
var activeObject = <fabric.Text>canvas.getActiveObject();
|
||||
var activeObject = <fabric.Text> canvas.getActiveObject();
|
||||
if (activeObject && activeObject.type === 'text') {
|
||||
activeObject.fontStyle = (activeObject.fontStyle == 'italic' ? '' : 'italic');
|
||||
activeObject.fontStyle = (activeObject.fontStyle === 'italic' ? '' : 'italic');
|
||||
this.className = activeObject.fontStyle ? 'selected' : '';
|
||||
canvas.renderAll();
|
||||
}
|
||||
@@ -954,7 +947,7 @@ function sample8() {
|
||||
if (cmdShadowBtn) {
|
||||
activeObjectButtons.push(cmdShadowBtn);
|
||||
cmdShadowBtn.onclick = function() {
|
||||
var activeObject = <fabric.Text>canvas.getActiveObject();
|
||||
var activeObject = <fabric.Text> canvas.getActiveObject();
|
||||
if (activeObject && activeObject.type === 'text') {
|
||||
activeObject.shadow = !activeObject.shadow ? 'rgba(0,0,0,0.2) 2px 2px 10px' : '';
|
||||
this.className = activeObject.shadow ? 'selected' : '';
|
||||
@@ -967,7 +960,7 @@ function sample8() {
|
||||
if (textAlignSwitch) {
|
||||
activeObjectButtons.push(textAlignSwitch);
|
||||
textAlignSwitch.onchange = function(this: HTMLInputElement) {
|
||||
var activeObject = <fabric.Text>canvas.getActiveObject();
|
||||
var activeObject = <fabric.Text> canvas.getActiveObject();
|
||||
if (activeObject && activeObject.type === 'text') {
|
||||
activeObject.textAlign = this.value.toLowerCase();
|
||||
canvas.renderAll();
|
||||
@@ -979,7 +972,7 @@ function sample8() {
|
||||
if (fontFamilySwitch) {
|
||||
activeObjectButtons.push(fontFamilySwitch);
|
||||
fontFamilySwitch.onchange = function(this: HTMLInputElement) {
|
||||
var activeObject = <fabric.Text>canvas.getActiveObject();
|
||||
var activeObject = <fabric.Text> canvas.getActiveObject();
|
||||
if (activeObject && activeObject.type === 'text') {
|
||||
activeObject.fontFamily = this.value;
|
||||
canvas.renderAll();
|
||||
@@ -990,7 +983,7 @@ function sample8() {
|
||||
var bgColorField = document.getElementById('text-bg-color');
|
||||
if (bgColorField) {
|
||||
bgColorField.onchange = function(this: HTMLInputElement) {
|
||||
var activeObject = <fabric.Text>canvas.getActiveObject();
|
||||
var activeObject = <fabric.Text> canvas.getActiveObject();
|
||||
if (activeObject && activeObject.type === 'text') {
|
||||
activeObject.backgroundColor = this.value;
|
||||
canvas.renderAll();
|
||||
@@ -1001,7 +994,7 @@ function sample8() {
|
||||
var strokeColorField = document.getElementById('text-stroke-color');
|
||||
if (strokeColorField) {
|
||||
strokeColorField.onchange = function(this: HTMLInputElement) {
|
||||
var activeObject = <fabric.Text>canvas.getActiveObject();
|
||||
var activeObject = <fabric.Text> canvas.getActiveObject();
|
||||
if (activeObject && activeObject.type === 'text') {
|
||||
activeObject.stroke = this.value;
|
||||
canvas.renderAll();
|
||||
@@ -1010,10 +1003,10 @@ function sample8() {
|
||||
}
|
||||
|
||||
if (supportsSlider) {
|
||||
(function() {
|
||||
(() => {
|
||||
var container = document.getElementById('text-controls');
|
||||
var slider = <HTMLInputElement>document.createElement('input');
|
||||
var label = <HTMLLabelElement>document.createElement('label');
|
||||
var slider = document.createElement('input');
|
||||
var label = document.createElement('label');
|
||||
label.innerHTML = 'Line height: ';
|
||||
try { slider.type = 'range'; } catch (err) { }
|
||||
slider.min = "0";
|
||||
@@ -1024,21 +1017,21 @@ function sample8() {
|
||||
label.appendChild(slider);
|
||||
slider.title = "Line height";
|
||||
slider.onchange = function() {
|
||||
var activeObject = <fabric.Text>canvas.getActiveObject();
|
||||
var activeObject = <fabric.Text> canvas.getActiveObject();
|
||||
if (activeObject && activeObject.type === 'text') {
|
||||
activeObject.lineHeight = +this.value;
|
||||
canvas.renderAll();
|
||||
}
|
||||
};
|
||||
|
||||
canvas.on('object:selected', function(e: fabric.IEvent) {
|
||||
slider.value = String((<fabric.Text>e.target).lineHeight);
|
||||
canvas.on('object:selected', (e: fabric.IEvent) => {
|
||||
slider.value = String((<fabric.Text> e.target).lineHeight);
|
||||
});
|
||||
})();
|
||||
}
|
||||
|
||||
document.getElementById('load-svg').onclick = function() {
|
||||
var svg = (<HTMLInputElement>document.getElementById('svg-console')).value;
|
||||
document.getElementById('load-svg').onclick = () => {
|
||||
var svg = (<HTMLInputElement> document.getElementById('svg-console')).value;
|
||||
fabric.loadSVGFromString(svg, function(objects, options) {
|
||||
var obj = fabric.util.groupSVGElements(objects, options);
|
||||
canvas.add(obj).centerObject(obj).renderAll();
|
||||
@@ -1049,6 +1042,6 @@ function sample8() {
|
||||
|
||||
function sample9() {
|
||||
var canvas = new fabric.Canvas('c');
|
||||
canvas.setBackgroundImage('yolo.jpg', () => { "a" }, { opacity: 45 });
|
||||
canvas.setBackgroundImage('yolo.jpg', () => { "a" });
|
||||
canvas.setBackgroundImage('yolo.jpg', () => { "a"; }, { opacity: 45 });
|
||||
canvas.setBackgroundImage('yolo.jpg', () => { "a"; });
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": false,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
|
||||
@@ -8,7 +8,7 @@ class CallbacksTest {
|
||||
|
||||
interface CustomType {
|
||||
myTypeOfClass: string;
|
||||
};
|
||||
}
|
||||
|
||||
opts.onAutoRetry = (id, name, attemptNumber) => {};
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ const child = new (forever.Monitor)('your-filename.js', {
|
||||
args: []
|
||||
});
|
||||
|
||||
child.on('exit', function() {
|
||||
child.on('exit', () => {
|
||||
console.log('your-filename.js has exited after 3 restarts');
|
||||
});
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ $('#calendar').fullCalendar({
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
dayClick: function () {
|
||||
dayClick() {
|
||||
alert('a day has been clicked!');
|
||||
}
|
||||
});
|
||||
@@ -68,13 +68,13 @@ $('#calendar').fullCalendar({
|
||||
$('#calendar').fullCalendar('option', 'aspectRatio', 1.8);
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
viewRender: function (view) {
|
||||
viewRender(view) {
|
||||
alert('The new title of the view is ' + view.title);
|
||||
}
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
windowResize: function (view) {
|
||||
windowResize(view) {
|
||||
alert('The calendar has adjusted to a window resize');
|
||||
}
|
||||
});
|
||||
@@ -88,7 +88,7 @@ $('#calendar').fullCalendar({
|
||||
var view = $('#calendar').fullCalendar('getView');
|
||||
alert("The view's title is " + view.title);
|
||||
|
||||
$(document).ready(function () {
|
||||
$(document).ready(() => {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
@@ -152,7 +152,7 @@ $(document).ready(function () {
|
||||
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
$(document).ready(() => {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
@@ -217,7 +217,7 @@ $(document).ready(function () {
|
||||
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
$(document).ready(() => {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
@@ -271,7 +271,7 @@ $(document).ready(function () {
|
||||
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
$(document).ready(() => {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
@@ -336,7 +336,7 @@ $(document).ready(function () {
|
||||
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
$(document).ready(() => {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
@@ -390,21 +390,21 @@ $(document).ready(function () {
|
||||
|
||||
});
|
||||
|
||||
$('#my-prev-button').click(function () {
|
||||
$('#my-prev-button').click(() => {
|
||||
$('#calendar').fullCalendar('prev');
|
||||
});
|
||||
|
||||
$('#my-next-button').click(function () {
|
||||
$('#my-next-button').click(() => {
|
||||
$('#calendar').fullCalendar('next');
|
||||
});
|
||||
|
||||
$('#my-today-button').click(function () {
|
||||
$('#my-today-button').click(() => {
|
||||
$('#calendar').fullCalendar('today');
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar('gotoDate', 1, 0, 1);
|
||||
|
||||
$('#my-button').click(function () {
|
||||
$('#my-button').click(() => {
|
||||
var d = $('#calendar').fullCalendar('getDate');
|
||||
alert("The current date of the calendar is " + d);
|
||||
});
|
||||
@@ -429,7 +429,7 @@ $('#calendar').fullCalendar({
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
dayClick: function (date, allDay, jsEvent, view) {
|
||||
dayClick(date, allDay, jsEvent, view) {
|
||||
|
||||
if (allDay) {
|
||||
alert('Clicked on the entire day: ' + date);
|
||||
@@ -448,7 +448,7 @@ $('#calendar').fullCalendar({
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
eventClick: function (calEvent, jsEvent, view) {
|
||||
eventClick(calEvent, jsEvent, view) {
|
||||
|
||||
alert('Event: ' + calEvent.title);
|
||||
alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
|
||||
@@ -469,7 +469,7 @@ $('#calendar').fullCalendar({
|
||||
}
|
||||
// other events here
|
||||
],
|
||||
eventClick: function (event) {
|
||||
eventClick(event) {
|
||||
if (event.url) {
|
||||
window.open(event.url);
|
||||
return false;
|
||||
@@ -489,7 +489,7 @@ $('#calendar').fullCalendar({
|
||||
custom_param1: 'something',
|
||||
custom_param2: 'somethingelse'
|
||||
},
|
||||
error: function () {
|
||||
error() {
|
||||
alert('there was an error while fetching events!');
|
||||
},
|
||||
color: 'yellow', // a non-ajax option
|
||||
@@ -511,7 +511,7 @@ $('#calendar').fullCalendar({
|
||||
custom_param1: 'something',
|
||||
custom_param2: 'somethingelse'
|
||||
},
|
||||
error: function () {
|
||||
error() {
|
||||
alert('there was an error while fetching events!');
|
||||
},
|
||||
color: 'yellow', // a non-ajax option
|
||||
@@ -601,7 +601,7 @@ $('#calendar').fullCalendar({
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
events: function (start: moment.Moment, end: moment.Moment, timezone: string | boolean, callback: (events: FullCalendar.EventObject[]) => void) {
|
||||
events(start: moment.Moment, end: moment.Moment, timezone: string | boolean, callback: (events: FullCalendar.EventObject[]) => void) {
|
||||
$.ajax({
|
||||
url: 'myxmlfeed.php',
|
||||
dataType: 'xml',
|
||||
@@ -610,9 +610,9 @@ $('#calendar').fullCalendar({
|
||||
start: Math.round(start.toDate().getTime() / 1000),
|
||||
end: Math.round(end.toDate().getTime() / 1000)
|
||||
},
|
||||
success: function (doc) {
|
||||
success(doc) {
|
||||
var events: any[] = [];
|
||||
$(doc).find('event').each(function () {
|
||||
$(doc).find('event').each(() => {
|
||||
events.push({
|
||||
title: $(this).attr('title'),
|
||||
start: $(this).attr('start') // will be parsed
|
||||
@@ -630,7 +630,7 @@ $('#calendar').fullCalendar({
|
||||
|
||||
// your event source
|
||||
{
|
||||
events: function (start: moment.Moment, end: moment.Moment, timezone: string | boolean, callback: (events: FullCalendar.EventObject[]) => void) {
|
||||
events(start: moment.Moment, end: moment.Moment, timezone: string | boolean, callback: (events: FullCalendar.EventObject[]) => void) {
|
||||
// ...
|
||||
},
|
||||
color: 'yellow', // an option!
|
||||
@@ -651,7 +651,7 @@ $('#calendar').fullCalendar({
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
eventClick: function (event, element) {
|
||||
eventClick(event, element) {
|
||||
|
||||
event.title = "CLICKED!";
|
||||
|
||||
@@ -683,7 +683,7 @@ $('#calendar').fullCalendar({
|
||||
}
|
||||
// more events here
|
||||
],
|
||||
eventRender: function (event: EventWithDescription, element: any, view: any) {
|
||||
eventRender(event: EventWithDescription, element: any, view: any) {
|
||||
element.qtip({
|
||||
content: event.description
|
||||
});
|
||||
@@ -696,7 +696,7 @@ $('#my-draggable').draggable({
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
droppable: true,
|
||||
drop: function (date, allDay) {
|
||||
drop(date, allDay) {
|
||||
alert("Dropped on " + date + " with allDay=" + allDay);
|
||||
}
|
||||
});
|
||||
@@ -704,7 +704,7 @@ $('#calendar').fullCalendar({
|
||||
$('#calendar').fullCalendar({
|
||||
droppable: true,
|
||||
dropAccept: '.cool-event',
|
||||
drop: function () {
|
||||
drop() {
|
||||
alert('dropped!');
|
||||
}
|
||||
});
|
||||
@@ -712,7 +712,7 @@ $('#calendar').fullCalendar({
|
||||
$('#draggable1').draggable();
|
||||
$('#draggable2').draggable();
|
||||
|
||||
$(document).ready(function () {
|
||||
$(document).ready(() => {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
@@ -777,10 +777,10 @@ $(document).ready(function () {
|
||||
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
$(document).ready(() => {
|
||||
/* initialize the external events
|
||||
-----------------------------------------------------------------*/
|
||||
$('#external-events div.external-event').each(function () {
|
||||
$('#external-events div.external-event').each(() => {
|
||||
|
||||
// create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)
|
||||
// it doesn't need to have a start or end
|
||||
@@ -810,7 +810,7 @@ $(document).ready(function () {
|
||||
},
|
||||
editable: true,
|
||||
droppable: true, // this allows things to be dropped onto the calendar !!!
|
||||
drop: function (date, allDay) { // this function is called when something is dropped
|
||||
drop(date, allDay) { // this function is called when something is dropped
|
||||
|
||||
// retrieve the dropped element's stored Event Object
|
||||
var originalEventObject = $(this).data('eventObject');
|
||||
|
||||
Vendored
+20
-21
@@ -1,10 +1,9 @@
|
||||
// Type definitions for FullCalendar 2.7.2
|
||||
// Type definitions for FullCalendar 2.7
|
||||
// Project: http://fullcalendar.io/
|
||||
// Definitions by: Neil Stalker <https://github.com/nestalk>, Marcelo Camargo <https://github.com/hasellcamargo>, Patrick Niemann <https://github.com/panic175>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="jquery"/>
|
||||
/// <reference types="moment" />
|
||||
|
||||
import * as moment from 'moment';
|
||||
|
||||
@@ -20,7 +19,7 @@ export interface Calendar {
|
||||
export interface BusinessHours {
|
||||
start: moment.Duration | string | Date;
|
||||
end: moment.Duration | string | Date;
|
||||
dow: Array<number>;
|
||||
dow: number[];
|
||||
}
|
||||
|
||||
export interface Timespan {
|
||||
@@ -50,7 +49,7 @@ export interface Options extends AgendaOptions, EventDraggingResizingOptions, Dr
|
||||
weekMode?: string;
|
||||
weekNumbers?: boolean;
|
||||
weekNumberCalculation?: any; // String/Function
|
||||
businessHours?: boolean | BusinessHours | Array<BusinessHours>;
|
||||
businessHours?: boolean | BusinessHours | BusinessHours[];
|
||||
height?: number;
|
||||
contentHeight?: number;
|
||||
aspectRatio?: number;
|
||||
@@ -83,10 +82,10 @@ export interface Options extends AgendaOptions, EventDraggingResizingOptions, Dr
|
||||
titleFormat?: any; // String
|
||||
|
||||
buttonText?: ButtonTextObject;
|
||||
monthNames?: Array<string>;
|
||||
monthNamesShort?: Array<string>;
|
||||
dayNames?: Array<string>;
|
||||
dayNamesShort?: Array<string>;
|
||||
monthNames?: string[];
|
||||
monthNamesShort?: string[];
|
||||
dayNames?: string[];
|
||||
dayNamesShort?: string[];
|
||||
weekNumberTitle?: string;
|
||||
|
||||
// Clicking & Hovering - http://fullcalendar.io/docs/mouse/
|
||||
@@ -137,12 +136,12 @@ export interface Options extends AgendaOptions, EventDraggingResizingOptions, Dr
|
||||
eventDestroy?: (event: EventObject, element: JQuery, view: ViewObject) => void;
|
||||
|
||||
//scheduler options
|
||||
resourceAreaWidth?:number,
|
||||
schedulerLicenseKey?:string,
|
||||
customButtons?:any,
|
||||
resourceLabelText?:any,
|
||||
resourceColumns?:any,
|
||||
displayEventTime?:any,
|
||||
resourceAreaWidth?: number;
|
||||
schedulerLicenseKey?: string;
|
||||
customButtons?: any;
|
||||
resourceLabelText?: any;
|
||||
resourceColumns?: any;
|
||||
displayEventTime?: any;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -218,7 +217,7 @@ export interface EventObject extends Timespan {
|
||||
title: string;
|
||||
allDay?: boolean;
|
||||
url?: string;
|
||||
className?: string | Array<string>;
|
||||
className?: string | string[];
|
||||
editable?: boolean;
|
||||
startEditable?: boolean;
|
||||
durationEditable?: boolean;
|
||||
@@ -253,7 +252,7 @@ export interface EventSource extends JQueryAjaxSettings {
|
||||
backgroundColor?: string;
|
||||
borderColor?: string;
|
||||
textColor?: string;
|
||||
className?: any; // string/Array<string>
|
||||
className?: any; // string/string[]
|
||||
editable?: boolean;
|
||||
allDayDefault?: boolean;
|
||||
ignoreTimezone?: boolean;
|
||||
@@ -366,17 +365,17 @@ declare global {
|
||||
/**
|
||||
* Reports changes for multiple events and renders them on the calendar.
|
||||
*/
|
||||
fullCalendar(method: 'updateEvents', events: Array<EventObject>): void;
|
||||
fullCalendar(method: 'updateEvents', events: EventObject[]): void;
|
||||
|
||||
/**
|
||||
* Retrieves events that FullCalendar has in memory.
|
||||
*/
|
||||
fullCalendar(method: 'clientEvents', idOrfilter?: any): Array<EventObject>;
|
||||
fullCalendar(method: 'clientEvents', idOrfilter?: any): EventObject[];
|
||||
|
||||
/**
|
||||
* Retrieves events that FullCalendar has in memory.
|
||||
*/
|
||||
fullCalendar(method: 'clientEvents', idOrfilter?: (e: EventObject) => boolean): Array<EventObject>;
|
||||
fullCalendar(method: 'clientEvents', idOrfilter?: (e: EventObject) => boolean): EventObject[];
|
||||
|
||||
/**
|
||||
* Removes events from the calendar.
|
||||
@@ -407,11 +406,11 @@ declare global {
|
||||
* Renders a new event on the calendar.
|
||||
*/
|
||||
fullCalendar(method: 'renderEvent', event: EventObject, stick?: boolean): void;
|
||||
|
||||
|
||||
/**
|
||||
* Renders new events on the calendar.
|
||||
*/
|
||||
fullCalendar(method: 'renderEvents', events: Array<EventObject>, stick?: boolean): void;
|
||||
fullCalendar(method: 'renderEvents', events: EventObject[], stick?: boolean): void;
|
||||
|
||||
/**
|
||||
* Rerenders all events on the calendar.
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false,
|
||||
"unified-signatures": false
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ let chartData = {
|
||||
let chart = new FusionCharts(chartData);
|
||||
chart.render();
|
||||
chart.isActive();
|
||||
chart.addEventListener('ready', function(eventObject) {
|
||||
chart.addEventListener('ready', eventObject => {
|
||||
eventObject.type;
|
||||
});
|
||||
chart.chartType();
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/// <reference path="index.d.ts" />
|
||||
/// <reference types="jquery" />
|
||||
|
||||
var pattern = GeoPattern.generate('GitHub');
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import * as React from "react";
|
||||
import * as Halogen from "halogen";
|
||||
|
||||
class HalogenTests_ClipLoader_withNoProps extends React.Component<React.Props<{}>, {}>{
|
||||
class HalogenTests_ClipLoader_withNoProps extends React.Component<React.Props<{}>, {}> {
|
||||
render() {
|
||||
return (
|
||||
<Halogen.ClipLoader />
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class HalogenTests_ClipLoader_withAllProps extends React.Component<React.Props<{}>, {}>{
|
||||
class HalogenTests_ClipLoader_withAllProps extends React.Component<React.Props<{}>, {}> {
|
||||
render() {
|
||||
return (
|
||||
<Halogen.ClipLoader loading={false} color="black" id="MyLoader" className="loader" verticalAlign="bottom" size="200px" />
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import * as React from "react";
|
||||
import * as Halogen from "halogen";
|
||||
|
||||
class HalogenTests_FadeLoader_withNoProps extends React.Component<React.Props<{}>, {}>{
|
||||
class HalogenTests_FadeLoader_withNoProps extends React.Component<React.Props<{}>, {}> {
|
||||
render() {
|
||||
return (
|
||||
<Halogen.FadeLoader />
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class HalogenTests_FadeLoader_withAllProps extends React.Component<React.Props<{}>, {}>{
|
||||
class HalogenTests_FadeLoader_withAllProps extends React.Component<React.Props<{}>, {}> {
|
||||
render() {
|
||||
return (
|
||||
<Halogen.FadeLoader loading={false} color="black" id="MyLoader" className="loader" verticalAlign="middle"
|
||||
size="100px" margin="10px" height="200px" width="200px" radius="5px" />
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import * as React from "react";
|
||||
import * as Halogen from "halogen";
|
||||
|
||||
class HalogenTests_PacmanLoader_withNoProps extends React.Component<React.Props<{}>, {}>{
|
||||
class HalogenTests_PacmanLoader_withNoProps extends React.Component<React.Props<{}>, {}> {
|
||||
render() {
|
||||
return (
|
||||
<Halogen.PacmanLoader />
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class HalogenTests_PacmanLoader_withAllProps extends React.Component<React.Props<{}>, {}>{
|
||||
class HalogenTests_PacmanLoader_withAllProps extends React.Component<React.Props<{}>, {}> {
|
||||
render() {
|
||||
return (
|
||||
<Halogen.PacmanLoader loading={false} color="black" id="MyLoader" className="loader" verticalAlign="middle" margin={10} size={200} />
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import * as React from "react";
|
||||
import * as Halogen from "halogen";
|
||||
|
||||
class HalogenTests_RotateLoader_withNoProps extends React.Component<React.Props<{}>, {}>{
|
||||
class HalogenTests_RotateLoader_withNoProps extends React.Component<React.Props<{}>, {}> {
|
||||
render() {
|
||||
return (
|
||||
<Halogen.RotateLoader />
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class HalogenTests_RotateLoader_withAllProps extends React.Component<React.Props<{}>, {}>{
|
||||
class HalogenTests_RotateLoader_withAllProps extends React.Component<React.Props<{}>, {}> {
|
||||
render() {
|
||||
return (
|
||||
<Halogen.RotateLoader loading={false} color="black" id="MyLoader" className="loader" verticalAlign="middle" margin="10px" size="100px" />
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,17 +10,17 @@ interface User {
|
||||
}
|
||||
|
||||
interface Users {
|
||||
[id: number]: User
|
||||
[id: number]: User;
|
||||
}
|
||||
|
||||
var users:Users = {
|
||||
var users: Users = {
|
||||
1: {
|
||||
id: 1,
|
||||
name: 'Test User'
|
||||
}
|
||||
};
|
||||
|
||||
var validate = function(decoded: User, request: Hapi.Request, callback: hapiAuthJwt2.ValidateCallback) {
|
||||
function validate(decoded: User, request: Hapi.Request, callback: hapiAuthJwt2.ValidateCallback) {
|
||||
if (!users[decoded.id]) {
|
||||
return callback(null, false);
|
||||
}
|
||||
@@ -28,8 +28,8 @@ var validate = function(decoded: User, request: Hapi.Request, callback: hapiAuth
|
||||
return callback(null, true);
|
||||
}
|
||||
|
||||
server.register(hapiAuthJwt2, function(err) {
|
||||
server.auth.strategy('jwt', 'jwt', <hapiAuthJwt2.Options>{
|
||||
server.register(hapiAuthJwt2, err => {
|
||||
server.auth.strategy('jwt', 'jwt', <hapiAuthJwt2.Options> {
|
||||
key: 'NeverShareYourSecret',
|
||||
validateFunc: validate,
|
||||
verifyOptions: {
|
||||
|
||||
+2
-2
@@ -253,7 +253,7 @@ console.log(stack2);
|
||||
|
||||
// nextTick(fn)
|
||||
|
||||
let myFn = function () {
|
||||
let myFn = () => {
|
||||
console.log('Do this later');
|
||||
};
|
||||
|
||||
@@ -269,7 +269,7 @@ console.log('Do this first');
|
||||
|
||||
// once(fn)
|
||||
|
||||
myFn = function () {
|
||||
myFn = () => {
|
||||
console.log('Ran myFn');
|
||||
};
|
||||
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
import {isHoliday, isHolidayAt, getHolidaysOf} from 'japanese-holidays'
|
||||
import {isHoliday, isHolidayAt, getHolidaysOf} from 'japanese-holidays';
|
||||
|
||||
const date = new Date(2017, 0, 9)
|
||||
const h: string | undefined = isHoliday(date)
|
||||
if (h != undefined) {
|
||||
h.charAt(0)
|
||||
const date = new Date(2017, 0, 9);
|
||||
const h: string | undefined = isHoliday(date);
|
||||
if (h !== undefined) {
|
||||
h.charAt(0);
|
||||
}
|
||||
|
||||
const noFurikae: string | undefined = isHoliday(date, false)
|
||||
const noFurikae: string | undefined = isHoliday(date, false);
|
||||
|
||||
const hAt = isHolidayAt(date)
|
||||
if (hAt != undefined) {
|
||||
hAt.charAt(0)
|
||||
const hAt = isHolidayAt(date);
|
||||
if (hAt !== undefined) {
|
||||
hAt.charAt(0);
|
||||
}
|
||||
|
||||
isHolidayAt(date, false)
|
||||
isHolidayAt(date, false);
|
||||
|
||||
const holidays = getHolidaysOf(2017)
|
||||
const first = holidays[0]
|
||||
const n: string = first.name
|
||||
const m: number = first.month
|
||||
const d: number = first.date
|
||||
const holidays = getHolidaysOf(2017);
|
||||
const first = holidays[0];
|
||||
const n: string = first.name;
|
||||
const m: number = first.month;
|
||||
const d: number = first.date;
|
||||
|
||||
@@ -95,9 +95,9 @@ describe('jasminewd', () => {
|
||||
describe('jasmine matchers', () => {
|
||||
it('should be able to add matchers', () => {
|
||||
let matchers = {
|
||||
toBeLotsMoreThan: function() {
|
||||
toBeLotsMoreThan() {
|
||||
return {
|
||||
compare: function(actual: number, expected: number) {
|
||||
compare(actual: number, expected: number) {
|
||||
return {
|
||||
pass: actual > expected + 100
|
||||
};
|
||||
@@ -105,9 +105,9 @@ describe('jasminewd', () => {
|
||||
};
|
||||
},
|
||||
// Example custom matcher returning a promise that resolves to true/false.
|
||||
toBeDisplayed: function() {
|
||||
toBeDisplayed() {
|
||||
return {
|
||||
compare: function(actual: any, expected: void) {
|
||||
compare(actual: any, expected: void) {
|
||||
return {
|
||||
pass: (actual.isDisplayed() as Promise<boolean>)
|
||||
};
|
||||
|
||||
+40
-40
@@ -2,19 +2,19 @@ import * as J from 'jenkins';
|
||||
|
||||
const jenkins = J({ baseUrl: 'http://user:pass@localhost:8080', crumbIssuer: true });
|
||||
|
||||
jenkins.info(function(err, data) {
|
||||
jenkins.info((err, data) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('info', data);
|
||||
});
|
||||
|
||||
jenkins.build.get('example', 1, function(err, data) {
|
||||
jenkins.build.get('example', 1, (err, data) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('build', data);
|
||||
});
|
||||
|
||||
jenkins.build.log('example', 1, function(err, data) {
|
||||
jenkins.build.log('example', 1, (err, data) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('log', data);
|
||||
@@ -22,181 +22,181 @@ jenkins.build.log('example', 1, function(err, data) {
|
||||
|
||||
var log = jenkins.build.logStream('example', 1);
|
||||
|
||||
log.on('data', function(text: string) {
|
||||
log.on('data', (text: string) => {
|
||||
process.stdout.write(text);
|
||||
});
|
||||
|
||||
log.on('error', function(err: Error) {
|
||||
log.on('error', (err: Error) => {
|
||||
console.log('error', err);
|
||||
});
|
||||
|
||||
log.on('end', function() {
|
||||
log.on('end', () => {
|
||||
console.log('end');
|
||||
});
|
||||
|
||||
jenkins.build.stop('example', 1, function(err) {
|
||||
jenkins.build.stop('example', 1, (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
jenkins.job.build('example', function(err, data) {
|
||||
jenkins.job.build('example', (err, data) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('queue item number', data);
|
||||
});
|
||||
|
||||
jenkins.job.build({ name: 'example', parameters: { name: 'value' } }, function(err) {
|
||||
jenkins.job.build({ name: 'example', parameters: { name: 'value' } }, (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
jenkins.job.config('example', function(err, data) {
|
||||
jenkins.job.config('example', (err, data) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('xml', data);
|
||||
});
|
||||
|
||||
jenkins.job.config('example', '<xml></xml>', function(err) {
|
||||
jenkins.job.config('example', '<xml></xml>', (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
jenkins.job.copy('fromJob', 'example', function(err) {
|
||||
jenkins.job.copy('fromJob', 'example', (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
jenkins.job.create('example', '<xml></xml>', function(err) {
|
||||
jenkins.job.create('example', '<xml></xml>', (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
jenkins.job.destroy('example', function(err) {
|
||||
jenkins.job.destroy('example', (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
jenkins.job.disable('example', function(err) {
|
||||
jenkins.job.disable('example', (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
jenkins.job.enable('example', function(err) {
|
||||
jenkins.job.enable('example', (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
jenkins.job.exists('example', function(err, exists) {
|
||||
jenkins.job.exists('example', (err, exists) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('exists', exists);
|
||||
});
|
||||
|
||||
jenkins.job.get('example', function(err, data) {
|
||||
jenkins.job.get('example', (err, data) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('job', data);
|
||||
});
|
||||
|
||||
jenkins.job.list(function(err, data) {
|
||||
jenkins.job.list((err, data) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('jobs', data);
|
||||
});
|
||||
|
||||
jenkins.node.config('example', function(err, data) {
|
||||
jenkins.node.config('example', (err, data) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('xml', data);
|
||||
});
|
||||
|
||||
jenkins.node.create('slave', function(err) {
|
||||
jenkins.node.create('slave', (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
jenkins.node.destroy('slave', function(err) {
|
||||
jenkins.node.destroy('slave', (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
jenkins.node.disconnect('slave', 'no longer used', function(err) {
|
||||
jenkins.node.disconnect('slave', 'no longer used', (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
jenkins.node.disable('slave', 'network failure', function(err) {
|
||||
jenkins.node.disable('slave', 'network failure', (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
jenkins.node.enable('slave', function(err) {
|
||||
jenkins.node.enable('slave', (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
jenkins.node.exists('slave', function(err, exists) {
|
||||
jenkins.node.exists('slave', (err, exists) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('exists', exists);
|
||||
});
|
||||
|
||||
jenkins.node.get('slave', function(err, data) {
|
||||
jenkins.node.get('slave', (err, data) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('node', data);
|
||||
});
|
||||
|
||||
jenkins.node.list(function(err, data) {
|
||||
jenkins.node.list((err, data) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('nodes', data);
|
||||
});
|
||||
|
||||
jenkins.queue.list(function(err, data) {
|
||||
jenkins.queue.list((err, data) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('queues', data);
|
||||
});
|
||||
|
||||
jenkins.queue.item(130, function(err, data) {
|
||||
jenkins.queue.item(130, (err, data) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('item', data);
|
||||
});
|
||||
|
||||
jenkins.queue.cancel(23, function(err) {
|
||||
jenkins.queue.cancel(23, (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
jenkins.view.config('example', function(err, data) {
|
||||
jenkins.view.config('example', (err, data) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('xml', data);
|
||||
});
|
||||
|
||||
jenkins.view.config('example', '<xml></xml>', function(err) {
|
||||
jenkins.view.config('example', '<xml></xml>', (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
jenkins.view.create('example', 'list', function(err) {
|
||||
jenkins.view.create('example', 'list', (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
jenkins.view.destroy('example', function(err) {
|
||||
jenkins.view.destroy('example', (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
jenkins.view.exists('example', function(err, exists) {
|
||||
jenkins.view.exists('example', (err, exists) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('exists', exists);
|
||||
});
|
||||
|
||||
jenkins.view.get('example', function(err, data) {
|
||||
jenkins.view.get('example', (err, data) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('view', data);
|
||||
});
|
||||
|
||||
jenkins.view.list(function(err, data) {
|
||||
jenkins.view.list((err, data) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log('views', data);
|
||||
});
|
||||
|
||||
jenkins.view.add('example', 'jobExample', function(err) {
|
||||
jenkins.view.add('example', 'jobExample', (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
jenkins.view.remove('example', 'jobExample', function(err) {
|
||||
jenkins.view.remove('example', 'jobExample', (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
|
||||
|
||||
+5
-5
@@ -8,19 +8,19 @@ interface TestStore {
|
||||
const db = new Store<TestStore>('data', {type: 'memory'});
|
||||
|
||||
// save with custom ID
|
||||
db.save('bar', 123, function(err, id) {
|
||||
db.save('bar', 123, (err, id) => {
|
||||
// now the data is stored in the file data/anId.json
|
||||
});
|
||||
|
||||
// save with generated ID
|
||||
db.save(333, function(err, id) {
|
||||
db.save(333, (err, id) => {
|
||||
// id is a unique ID
|
||||
});
|
||||
|
||||
// save synchronously
|
||||
db.saveSync('foo', 'test');
|
||||
|
||||
db.get('bar', function(err, obj) {
|
||||
db.get('bar', (err, obj) => {
|
||||
// obj = { foo: ''bar' }
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@ db.get('bar', function(err, obj) {
|
||||
const val = db.getSync('bar');
|
||||
|
||||
// get all available objects
|
||||
db.all(function(err, objs) {
|
||||
db.all((err, objs) => {
|
||||
// objs is a map: ID => OBJECT
|
||||
});
|
||||
|
||||
@@ -36,7 +36,7 @@ db.all(function(err, objs) {
|
||||
var objs = db.allSync();
|
||||
|
||||
// delete by ID
|
||||
db.delete('foo', function(err) {
|
||||
db.delete('foo', err => {
|
||||
// the file data/myId.json was removed
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
// basic usage
|
||||
$(document).ready(function () {
|
||||
$(document).ready(() => {
|
||||
$('.date').mask('00/00/0000');
|
||||
$('.time').mask('00:00:00');
|
||||
$('.date_time').mask('00/00/0000 00:00:00');
|
||||
@@ -42,17 +42,17 @@ $(document).ready(function () {
|
||||
|
||||
// callback examples
|
||||
let options: jQueryMask.Options = {
|
||||
onComplete: function (cep: Object) {
|
||||
onComplete(cep: Object) {
|
||||
alert('CEP Completed!:' + cep);
|
||||
},
|
||||
onKeyPress: function (cep: Object, event: Event, currentField: JQuery, options: jQueryMask.Options) {
|
||||
onKeyPress(cep: Object, event: Event, currentField: JQuery, options: jQueryMask.Options) {
|
||||
console.log('An key was pressed!:', cep, ' event: ', event,
|
||||
'currentField: ', currentField, ' options: ', options);
|
||||
},
|
||||
onChange: function (cep: Object) {
|
||||
onChange(cep: Object) {
|
||||
console.log('cep changed! ', cep);
|
||||
},
|
||||
onInvalid: function (val: Object, e: Event, f: JQuery, invalid: jQueryMask.Invalid[], options: jQueryMask.Options) {
|
||||
onInvalid(val: Object, e: Event, f: JQuery, invalid: jQueryMask.Invalid[], options: jQueryMask.Options) {
|
||||
var error = invalid[0];
|
||||
console.log("Digit: ", error.v, " is invalid for the position: ", error.p, ". We expect something like: ", error.e);
|
||||
}
|
||||
@@ -62,7 +62,7 @@ $('.cep_with_callback').mask('00000-000', options);
|
||||
|
||||
// on the fly mask changed
|
||||
options = {
|
||||
onKeyPress: function (cep, e, field, options) {
|
||||
onKeyPress(cep, e, field, options) {
|
||||
let masks: string[] = ['00000-000', '0-00-00-00'];
|
||||
let mask: string = (cep.length > 7) ? masks[1] : masks[0];
|
||||
$('.crazy_cep').mask(mask, options);
|
||||
@@ -72,12 +72,12 @@ options = {
|
||||
$('.crazy_cep').mask('00000-000', options);
|
||||
|
||||
// mask as a function
|
||||
let maskBehavior: (value: string) => string = function (val: string) {
|
||||
let maskBehavior: (value: string) => string = val => {
|
||||
return val.replace(/\D/g, '').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009';
|
||||
};
|
||||
|
||||
options = {
|
||||
onKeyPress: function(val: string, e: Event, field: JQuery, options: jQueryMask.Options) {
|
||||
onKeyPress(val: string, e: Event, field: JQuery, options: jQueryMask.Options) {
|
||||
field.mask(maskBehavior.apply({}, arguments), options);
|
||||
}
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -70,7 +70,7 @@ var logger1: JL.JSNLogLogger = JL('mylogger');
|
||||
var exception = {};
|
||||
|
||||
logger1.trace('log message').debug({ x: 1, y: 2});
|
||||
logger1.info(function() { return 5; });
|
||||
logger1.info(() => 5);
|
||||
logger1.warn('log message');
|
||||
logger1.error('log message');
|
||||
logger1.fatal('log message');
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
/// <reference types="jquery"/>
|
||||
|
||||
import {jui, UtilColor, UtilBase} from "./index";
|
||||
|
||||
jui.ready(["util.color"], function(color: UtilColor) {
|
||||
jui.ready(["util.color"], (color: UtilColor) => {
|
||||
console.log(color.rgb("#ff0000"));
|
||||
});
|
||||
|
||||
|
||||
+16
-16
@@ -4,7 +4,7 @@ import {jui} from 'jui-core';
|
||||
import {GridTable, GridXTable, GridRow} from "./index";
|
||||
|
||||
|
||||
jui.ready([ "grid.table" ], function(table: GridTable) {
|
||||
jui.ready([ "grid.table" ], (table: GridTable) => {
|
||||
let table_1: GridTable = table("#table_1", {
|
||||
data: [
|
||||
{ name: "Hong", age: "20", location: "Ilsan" },
|
||||
@@ -21,13 +21,13 @@ jui.ready([ "grid.table" ], function(table: GridTable) {
|
||||
table_1.scroll(100);
|
||||
});
|
||||
|
||||
jui.ready([ "grid.table" ], function(table: GridTable) {
|
||||
jui.ready([ "grid.table" ], (table: GridTable) => {
|
||||
let table_3: GridTable = table("#table_3", {
|
||||
event: {
|
||||
expand: function(row: any, e: any): void {
|
||||
expand(row: any, e: any): void {
|
||||
$(row.list[0]).html("<i class='icon-right'></i>");
|
||||
},
|
||||
expandend: function(row: any, e: any): void {
|
||||
expandend(row: any, e: any): void {
|
||||
$(row.list[0]).html("<i class='icon-left'></i>");
|
||||
}
|
||||
},
|
||||
@@ -40,7 +40,7 @@ jui.ready([ "grid.table" ], function(table: GridTable) {
|
||||
{ name: "Park", age: "10", location: "Dangjin" }
|
||||
]);
|
||||
|
||||
let table_3_submit: Function = function(index: number) {
|
||||
let table_3_submit: Function = (index: number) => {
|
||||
var name = $(table_3.root).find(".name").val(),
|
||||
age = $(table_3.root).find(".age").val(),
|
||||
location = $(table_3.root).find(".location").val();
|
||||
@@ -51,7 +51,7 @@ jui.ready([ "grid.table" ], function(table: GridTable) {
|
||||
};
|
||||
});
|
||||
|
||||
jui.ready([ "grid.xtable" ], function(xtable: GridXTable) {
|
||||
jui.ready([ "grid.xtable" ], (xtable: GridXTable) => {
|
||||
var page = 1;
|
||||
|
||||
let xtable_2: GridXTable = xtable("#xtable_2", {
|
||||
@@ -62,7 +62,7 @@ jui.ready([ "grid.xtable" ], function(xtable: GridXTable) {
|
||||
bufferCount: 20
|
||||
});
|
||||
|
||||
let xtable_2_submit: Function = function() {
|
||||
let xtable_2_submit: Function = () => {
|
||||
var result: any[] = [];
|
||||
|
||||
for(var i = 0; i < 1000000; i++) {
|
||||
@@ -74,7 +74,7 @@ jui.ready([ "grid.xtable" ], function(xtable: GridXTable) {
|
||||
xtable_2.resize();
|
||||
};
|
||||
|
||||
let xtable_2_page: Function = function(no: number) {
|
||||
let xtable_2_page: Function = (no: number) => {
|
||||
page += no;
|
||||
page = (page < 1) ? 1 : page;
|
||||
xtable_2.page(page);
|
||||
@@ -82,7 +82,7 @@ jui.ready([ "grid.xtable" ], function(xtable: GridXTable) {
|
||||
});
|
||||
|
||||
|
||||
jui.ready([ "grid.xtable" ], function(xtable: GridXTable) {
|
||||
jui.ready([ "grid.xtable" ], (xtable: GridXTable) => {
|
||||
let xtable_4: GridXTable = xtable("#xtable_4", {
|
||||
fields: [ "name", "age", "location" ],
|
||||
data: [
|
||||
@@ -96,15 +96,15 @@ jui.ready([ "grid.xtable" ], function(xtable: GridXTable) {
|
||||
bufferCount: 20
|
||||
});
|
||||
|
||||
let xtable_4_submit: Function = function(isMulti: boolean) {
|
||||
let xtable_4_submit: Function = (isMulti: boolean) => {
|
||||
if(isMulti) {
|
||||
xtable_4.filter(function(data: any) {
|
||||
xtable_4.filter((data: any) => {
|
||||
if(data.age >= 30 || data.name.indexOf("ng") !== -1) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
xtable_4.filter(function(data: any) {
|
||||
xtable_4.filter((data: any) => {
|
||||
if(data.location.indexOf("eo") !== -1) {
|
||||
return true;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ jui.ready([ "grid.xtable" ], function(xtable: GridXTable) {
|
||||
};
|
||||
});
|
||||
|
||||
jui.ready([ "grid.xtable" ], function(xtable: GridXTable) {
|
||||
jui.ready([ "grid.xtable" ], (xtable: GridXTable) => {
|
||||
let xtable_6: GridXTable = xtable("#xtable_6", {
|
||||
fields: [ "name", "age", "location" ],
|
||||
resize: true,
|
||||
@@ -129,7 +129,7 @@ jui.ready([ "grid.xtable" ], function(xtable: GridXTable) {
|
||||
}
|
||||
});
|
||||
|
||||
let xtable_6_submit: Function = function() {
|
||||
let xtable_6_submit: Function = () => {
|
||||
var result: any[] = [];
|
||||
|
||||
for(var i = 0; i < 1000000; i++) {
|
||||
@@ -140,7 +140,7 @@ jui.ready([ "grid.xtable" ], function(xtable: GridXTable) {
|
||||
};
|
||||
});
|
||||
|
||||
jui.ready([ "grid.xtable" ], function(xtable: GridXTable) {
|
||||
jui.ready([ "grid.xtable" ], (xtable: GridXTable) => {
|
||||
let xtable_8: GridXTable = xtable("#xtable_8", {
|
||||
fields: [ "url", "count" ],
|
||||
resize: true,
|
||||
@@ -152,7 +152,7 @@ jui.ready([ "grid.xtable" ], function(xtable: GridXTable) {
|
||||
none: $("#tpl_none").html()
|
||||
},
|
||||
event: {
|
||||
select: function(row: GridRow, e: any) {
|
||||
select(row: GridRow, e: any) {
|
||||
if(row.type === "fold") {
|
||||
xtable_8.open(row.index);
|
||||
} else {
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ jui.ready([
|
||||
'ui.progress',
|
||||
'ui.property',
|
||||
'ui.select'
|
||||
], function (
|
||||
], (
|
||||
accordion: UIAccordion,
|
||||
autocomplete: UIAutoComplete,
|
||||
colorpicker: UIColorPicker,
|
||||
@@ -30,7 +30,7 @@ jui.ready([
|
||||
progress: UIProgress,
|
||||
property: UIProperty,
|
||||
select: UISelect
|
||||
) {
|
||||
) => {
|
||||
let a: UIAccordion = accordion("#test", {
|
||||
multipanel: false
|
||||
});
|
||||
|
||||
+12
-22
@@ -3741,17 +3741,13 @@ namespace TestFind {
|
||||
result = _(dictionary).find<TResult>({a: 42}, 1);
|
||||
}
|
||||
|
||||
result = <number>_.findLast([1, 2, 3, 4], function (num) {
|
||||
return num % 2 == 0;
|
||||
});
|
||||
result = <number>_.findLast([1, 2, 3, 4], num => num % 2 == 0);
|
||||
result = <IFoodCombined>_.findLast(foodsCombined, { 'type': 'vegetable' });
|
||||
result = <IFoodCombined>_.findLast(foodsCombined, 'organic');
|
||||
|
||||
result = <IFoodCombined>_.findLast(foodsCombined, 'organic', 1);
|
||||
|
||||
result = <number>_([1, 2, 3, 4]).findLast(function (num) {
|
||||
return num % 2 == 0;
|
||||
});
|
||||
result = <number>_([1, 2, 3, 4]).findLast(num => num % 2 == 0);
|
||||
result = <IFoodCombined>_(foodsCombined).findLast({ 'type': 'vegetable' });
|
||||
result = <IFoodCombined>_(foodsCombined).findLast('organic');
|
||||
|
||||
@@ -4711,29 +4707,23 @@ namespace TestReduce {
|
||||
c: number;
|
||||
}
|
||||
|
||||
result = <number>_.reduce<number, number>([1, 2, 3], function (sum: number, num: number) {
|
||||
return sum + num;
|
||||
});
|
||||
result = <number>_.reduce<number, number>([1, 2, 3], (sum: number, num: number) => sum + num);
|
||||
|
||||
// chained
|
||||
result = _.chain([1, 2 ,3]).reduce(function (sum: number, num: number) {
|
||||
return sum + num;
|
||||
}).value();
|
||||
result = _.chain([1, 2 ,3]).reduce((sum: number, num: number) => sum + num).value();
|
||||
|
||||
result = <ABC>_.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function (r: ABC, num: number, key: string) {
|
||||
result = <ABC>_.reduce({ 'a': 1, 'b': 2, 'c': 3 }, (r: ABC, num: number, key: string) => {
|
||||
r[key] = num * 3;
|
||||
return r;
|
||||
}, {});
|
||||
|
||||
result = <number>_([1, 2, 3]).reduce<number>(function (sum: number, num: number) {
|
||||
return sum + num;
|
||||
});
|
||||
result = <ABC>_({ 'a': 1, 'b': 2, 'c': 3 }).reduce<number, ABC>(function (r: ABC, num: number, key: string) {
|
||||
result = <number>_([1, 2, 3]).reduce<number>((sum: number, num: number) => sum + num);
|
||||
result = <ABC>_({ 'a': 1, 'b': 2, 'c': 3 }).reduce<number, ABC>((r: ABC, num: number, key: string) => {
|
||||
r[key] = num * 3;
|
||||
return r;
|
||||
}, <ABC> {});
|
||||
|
||||
result = <number[]>_.reduceRight([[0, 1], [2, 3], [4, 5]], function (a: number[], b: number[]) { return a.concat(b); }, <number[]>[]);
|
||||
result = <number[]>_.reduceRight([[0, 1], [2, 3], [4, 5]], (a: number[], b: number[]) => a.concat(b), <number[]>[]);
|
||||
}
|
||||
// _.reject
|
||||
namespace TestReject {
|
||||
@@ -5173,9 +5163,9 @@ namespace TestSortBy {
|
||||
}
|
||||
}
|
||||
|
||||
result = <IStoogesAge[]>_.sortBy(stoogesAges, function(stooge) { return Math.sin(stooge.age); }, function(stooge) { return stooge.name.slice(1); });
|
||||
result = <IStoogesAge[]>_.sortBy(stoogesAges, stooge => Math.sin(stooge.age), stooge => stooge.name.slice(1));
|
||||
result = <IStoogesAge[]>_.sortBy(stoogesAges, ['name', 'age']);
|
||||
result = <IStoogesAge[]>_.sortBy(stoogesAges, 'name', function(stooge) { return Math.sin(stooge.age); });
|
||||
result = <IStoogesAge[]>_.sortBy(stoogesAges, 'name', stooge => Math.sin(stooge.age));
|
||||
|
||||
result = <IFoodOrganic[]>_(foodsOrganic).sortBy('organic', (food) => food.name, { organic: true }).value();
|
||||
|
||||
@@ -6017,7 +6007,7 @@ namespace TestOnce {
|
||||
}
|
||||
}
|
||||
|
||||
var greetPartial = function (greeting: string, name: string) { return greeting + ' ' + name; };
|
||||
var greetPartial = (greeting: string, name: string) => greeting + ' ' + name;
|
||||
var hi = _.partial(greetPartial, 'hi');
|
||||
hi('moe');
|
||||
|
||||
@@ -8620,7 +8610,7 @@ namespace TestDefaults {
|
||||
let s5: S5;
|
||||
|
||||
{
|
||||
let result: Obj;
|
||||
let result: Obj;
|
||||
|
||||
result = _.defaults(obj);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/// <reference path="index.d.ts" />
|
||||
import * as loopback from 'loopback';
|
||||
import * as boot from 'loopback-boot';
|
||||
import * as cookieParser from 'cookie-parser';
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/// <reference path="index.d.ts" />
|
||||
import * as loopback from 'loopback';
|
||||
import * as cookieParser from 'cookie-parser';
|
||||
|
||||
@@ -13,7 +12,7 @@ class Server {
|
||||
|
||||
this.app.use(cookieParser());
|
||||
|
||||
this.app.start = function() {
|
||||
this.app.start = () => {
|
||||
// start the web server
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ var marker = L.marker(new L.LatLng([0, 0]), {
|
||||
}).addTo(map);
|
||||
|
||||
// every time the marker is dragged, update the coordinates container
|
||||
marker.on('dragend', function() {
|
||||
marker.on('dragend', () => {
|
||||
var m = marker.getLatLng();
|
||||
coordinates.innerHTML = 'Latitude: ' + m.lat + '<br />Longitude: ' + m.lng;
|
||||
});
|
||||
@@ -36,6 +36,6 @@ var marker2 = L.mapbox.featureLayer({
|
||||
|
||||
// Iterate over the featureLayer we've called "marker"
|
||||
// and open its popup instead of clicking to trigger it.
|
||||
marker2.eachLayer(function(marker: L.Marker) {
|
||||
marker2.eachLayer((marker: L.Marker) => {
|
||||
marker.openPopup();
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
import memoize = require('memoizee');
|
||||
|
||||
var fn = function (one: string, two?: number, three?: any) { /* ... */ };
|
||||
var fn = (one: string, two?: number, three?: any) => { /* ... */ };
|
||||
|
||||
let memoized = memoize(fn);
|
||||
memoized('foo', 3, 'bar');
|
||||
@@ -18,15 +18,15 @@ memoized('foo', 3, 13);
|
||||
memoized = memoize(fn, { primitive: true });
|
||||
memoized('/path/one');
|
||||
memoized('/path/one');
|
||||
memoized = memoize(fn, { dispose: function (value: number) { /*…*/ } });
|
||||
memoized = memoize(fn, { dispose(value: number) { /*…*/ } });
|
||||
var foo3 = memoized('foo', 3);
|
||||
var bar7 = memoized('bar', 7);
|
||||
memoized.clear('foo', 3); // Dispose called with foo3 value
|
||||
memoized.clear('bar', 7); // Dispose called with bar7 value
|
||||
memoized.delete('foo', 0);
|
||||
var mFn = memoize(function (hash: any) {
|
||||
var mFn = memoize((hash: any) => {
|
||||
// body of memoized function
|
||||
}, { normalizer: function (args: any) {
|
||||
}, { normalizer: (args: any) => {
|
||||
// args is arguments object as accessible in memoized function
|
||||
return JSON.stringify(args[0]);
|
||||
} });
|
||||
@@ -36,11 +36,11 @@ mFn({ foo: 'bar' });
|
||||
memoized = memoize(fn, { length: 2, resolvers: [String, Boolean] });
|
||||
memoized(String(12), [1, 2, 3].length);
|
||||
memoized("12", Number(true));
|
||||
memoized(String({ toString: function () { return "12"; } }), Number({}));
|
||||
memoized(String({ toString() { return "12"; } }), Number({}));
|
||||
|
||||
{
|
||||
var afn = function (a: number, b: number) {
|
||||
return new Promise(function (res) { res(a + b); });
|
||||
var afn = (a: number, b: number) => {
|
||||
return new Promise(res => { res(a + b); });
|
||||
};
|
||||
let memoized = memoize(afn, { promise: true });
|
||||
memoized(3, 7);
|
||||
@@ -52,10 +52,10 @@ memoized = memoize(fn, { maxAge: 1000, preFetch: 0.6 });
|
||||
memoized('foo', 3);
|
||||
memoized('foo', 3);
|
||||
|
||||
setTimeout(function () {
|
||||
setTimeout(() => {
|
||||
memoized('foo', 3);
|
||||
}, 500);
|
||||
|
||||
setTimeout(function () {
|
||||
setTimeout(() => {
|
||||
memoized('foo', 3);
|
||||
}, 1300);
|
||||
|
||||
@@ -15,38 +15,38 @@ const selector = {
|
||||
limit: 5,
|
||||
fields: { createdAt: 1 },
|
||||
reacrive: true,
|
||||
transform: function () {}
|
||||
transform: () => {}
|
||||
};
|
||||
|
||||
Collection.before.find(function (userId: string, selector: Mongo.Selector, options: { multi?: boolean; upsert?: boolean; }): void {});
|
||||
Collection.before.findOne(function (userId: string, selector: Mongo.Selector, options: { multi?: boolean; upsert?: boolean; }): void {});
|
||||
Collection.before.insert(function (userId: string, doc: Model): void {});
|
||||
Collection.before.remove(function (userId: string, doc: Model): void {});
|
||||
Collection.before.update(function (userId: string, doc: Model, fieldNames: string[], modifier: Mongo.Modifier, options: { multi?: boolean; upsert?: boolean; }): void {});
|
||||
Collection.before.upsert(function (userId: string, doc: Model, selector: Mongo.Selector, modifier: Mongo.Modifier, options: { multi?: boolean; upsert?: boolean; }): void {});
|
||||
Collection.before.find((userId: string, selector: Mongo.Selector, options: { multi?: boolean; upsert?: boolean; }) => {});
|
||||
Collection.before.findOne((userId: string, selector: Mongo.Selector, options: { multi?: boolean; upsert?: boolean; }) => {});
|
||||
Collection.before.insert((userId: string, doc: Model) => {});
|
||||
Collection.before.remove((userId: string, doc: Model) => {});
|
||||
Collection.before.update((userId: string, doc: Model, fieldNames: string[], modifier: Mongo.Modifier, options: { multi?: boolean; upsert?: boolean; }) => {});
|
||||
Collection.before.upsert((userId: string, doc: Model, selector: Mongo.Selector, modifier: Mongo.Modifier, options: { multi?: boolean; upsert?: boolean; }) => {});
|
||||
|
||||
Collection.after.find(function (userId: string, selector: Mongo.Selector, options: { multi?: boolean; upsert?: boolean; }, cursor: Mongo.Cursor<Model>): void {});
|
||||
Collection.after.findOne(function (userId: string, selector: Mongo.Selector, options: { multi?: boolean; upsert?: boolean; }, doc: Model): void {});
|
||||
Collection.after.insert(function (userId: string, doc: Model): void {});
|
||||
Collection.after.remove(function (userId: string, doc: Model): void {});
|
||||
Collection.after.update(function (userId: string, doc: Model, fieldNames: string[], modifier: Mongo.Modifier, options: { multi?: boolean; upsert?: boolean; }): void {}, { fetchPrevious: true });
|
||||
Collection.after.upsert(function (userId: string, doc: Model, selector: Mongo.Selector, modifier: Mongo.Modifier, options: { multi?: boolean; upsert?: boolean; }): void {});
|
||||
Collection.after.find((userId: string, selector: Mongo.Selector, options: { multi?: boolean; upsert?: boolean; }, cursor: Mongo.Cursor<Model>) => {});
|
||||
Collection.after.findOne((userId: string, selector: Mongo.Selector, options: { multi?: boolean; upsert?: boolean; }, doc: Model) => {});
|
||||
Collection.after.insert((userId: string, doc: Model) => {});
|
||||
Collection.after.remove((userId: string, doc: Model) => {});
|
||||
Collection.after.update((userId: string, doc: Model, fieldNames: string[], modifier: Mongo.Modifier, options: { multi?: boolean; upsert?: boolean; }) => {}, { fetchPrevious: true });
|
||||
Collection.after.upsert((userId: string, doc: Model, selector: Mongo.Selector, modifier: Mongo.Modifier, options: { multi?: boolean; upsert?: boolean; }) => {});
|
||||
|
||||
cursor = Collection.direct.find({ _id: doc._id }, { sort: { createdAt: -1 }, skip: 5, limit: 5, fields: { createdAt: 1 }, reactive: true, transform: function () {} });
|
||||
cursor = Collection.direct.find(doc._id, { sort: { createdAt: -1 }, skip: 5, limit: 5, fields: { createdAt: 1 }, reactive: true, transform: function () {} });
|
||||
cursor = Collection.direct.find({ _id: doc._id }, { sort: { createdAt: -1 }, skip: 5, limit: 5, fields: { createdAt: 1 }, reactive: true, transform: () => {} });
|
||||
cursor = Collection.direct.find(doc._id, { sort: { createdAt: -1 }, skip: 5, limit: 5, fields: { createdAt: 1 }, reactive: true, transform: () => {} });
|
||||
|
||||
doc = Collection.direct.findOne({ _id: doc._id }, { sort: { createdAt: -1 }, skip: 5, fields: { createdAt: 1 }, reactive: true, transform: function () {} });
|
||||
doc = Collection.direct.findOne(doc._id, { sort: { createdAt: -1 }, skip: 5, fields: { createdAt: 1 }, reactive: true, transform: function () {} });
|
||||
doc = Collection.direct.findOne({ _id: doc._id }, { sort: { createdAt: -1 }, skip: 5, fields: { createdAt: 1 }, reactive: true, transform: () => {} });
|
||||
doc = Collection.direct.findOne(doc._id, { sort: { createdAt: -1 }, skip: 5, fields: { createdAt: 1 }, reactive: true, transform: () => {} });
|
||||
|
||||
doc._id = Collection.direct.insert(doc, function () {});
|
||||
doc._id = Collection.direct.insert(doc, () => {});
|
||||
|
||||
doc.value = Collection.direct.remove({ _id: doc._id }, function () {});
|
||||
doc.value = Collection.direct.remove(doc._id, function () {});
|
||||
doc.value = Collection.direct.remove({ _id: doc._id }, () => {});
|
||||
doc.value = Collection.direct.remove(doc._id, () => {});
|
||||
|
||||
doc.value = Collection.direct.update({ _id: doc._id }, { $inc: { votes: 2 } }, { multi: true, upsert: true }, function () {});
|
||||
doc.value = Collection.direct.update(doc._id, { $inc: { votes: 2 } }, { multi: true, upsert: true }, function () {});
|
||||
doc.value = Collection.direct.update({ _id: doc._id }, { $inc: { votes: 2 } }, { multi: true, upsert: true }, () => {});
|
||||
doc.value = Collection.direct.update(doc._id, { $inc: { votes: 2 } }, { multi: true, upsert: true }, () => {});
|
||||
|
||||
let { numberAffected, insertedId }: { numberAffected?: number; insertedId?: string; } = Collection.direct.upsert(doc._id, { $inc: { votes: 2 } }, { multi: true }, function () {});
|
||||
let { numberAffected, insertedId }: { numberAffected?: number; insertedId?: string; } = Collection.direct.upsert(doc._id, { $inc: { votes: 2 } }, { multi: true }, () => {});
|
||||
|
||||
Collection.hookOptions = {
|
||||
before: {
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
declare var $: any;
|
||||
|
||||
window.alert = function(thing?: string) {
|
||||
window.alert = (thing?: string) => {
|
||||
$('#content').append('<div>' + thing + '</div>');
|
||||
};
|
||||
|
||||
$(function () {
|
||||
$(() => {
|
||||
var audio = new Audio();
|
||||
audio.src = Modernizr.audio.ogg ? 'background.ogg' :
|
||||
Modernizr.audio.mp3 ? 'background.mp3' :
|
||||
@@ -54,7 +54,7 @@ $(function () {
|
||||
});
|
||||
|
||||
|
||||
Modernizr.on('flash', function( result ) {
|
||||
Modernizr.on('flash', result => {
|
||||
if (result) {
|
||||
// the browser has flash
|
||||
} else {
|
||||
@@ -62,7 +62,7 @@ Modernizr.on('flash', function( result ) {
|
||||
}
|
||||
});
|
||||
|
||||
Modernizr.addTest('itsTuesday', function() {
|
||||
Modernizr.addTest('itsTuesday', () => {
|
||||
var d = new Date();
|
||||
return d.getDay() === 2;
|
||||
});
|
||||
@@ -71,7 +71,7 @@ Modernizr.addTest('hasJquery', 'jQuery' in window);
|
||||
|
||||
var detects = {
|
||||
hasjquery: 'jQuery' in window,
|
||||
itstuesday: function() {
|
||||
itstuesday: () => {
|
||||
var d = new Date();
|
||||
return d.getDay() === 2;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ if (query) {
|
||||
Modernizr.prefixed('boxSizing');
|
||||
|
||||
var raf = Modernizr.prefixed('requestAnimationFrame', window);
|
||||
raf(function() {
|
||||
raf(() => {
|
||||
});
|
||||
|
||||
var rAFProp = Modernizr.prefixed('requestAnimationFrame', window, false);
|
||||
@@ -125,19 +125,19 @@ Modernizr.testProp('pointerEvents'); // true
|
||||
Modernizr.testProp('pointerEvents', 'none'); // true
|
||||
Modernizr.testProp('pointerEvents', 'penguin'); // false
|
||||
|
||||
Modernizr.testStyles('#modernizr { width: 9px; color: papayawhip; }', function(elem, rule) {
|
||||
Modernizr.testStyles('#modernizr { width: 9px; color: papayawhip; }', (elem, rule) => {
|
||||
// elem is the first DOM node in the page (by default #modernizr)
|
||||
// rule is the first argument you supplied - the CSS rule in string form
|
||||
Modernizr.addTest('widthworks', elem.style.width === '9px');
|
||||
});
|
||||
|
||||
Modernizr.testStyles('#modernizr {width: 1px}; #modernizr2 {width: 2px}', function(elem) {
|
||||
Modernizr.testStyles('#modernizr {width: 1px}; #modernizr2 {width: 2px}', elem => {
|
||||
document.getElementById('modernizr').style.width === '1px'; // true
|
||||
document.getElementById('modernizr2').style.width === '2px'; // true
|
||||
elem.firstChild === document.getElementById('modernizr2'); // true
|
||||
}, 1);
|
||||
|
||||
Modernizr.testStyles('#modernizr {width: 1px}; #modernizr2 {width: 2px}', function(elem) {
|
||||
Modernizr.testStyles('#modernizr {width: 1px}; #modernizr2 {width: 2px}', elem => {
|
||||
document.getElementById('modernizr').style.width === '1px'; // true
|
||||
document.getElementById('modernizr2').style.width === '2px'; // true
|
||||
elem.firstChild === document.getElementById('modernizr2'); // true
|
||||
|
||||
@@ -6,12 +6,12 @@ const addr: string = "tcp://127.0.0.1:7789";
|
||||
pub.bind(addr);
|
||||
sub.connect(addr);
|
||||
|
||||
sub.on('data', function (buf) {
|
||||
sub.on('data', buf => {
|
||||
console.log(String(buf));
|
||||
pub.close();
|
||||
sub.close();
|
||||
});
|
||||
|
||||
setTimeout(function () {
|
||||
setTimeout(() => {
|
||||
pub.send("Hello from nanomsg!");
|
||||
}, 100);
|
||||
|
||||
@@ -8,11 +8,9 @@ var stateNavigator = new StateNavigator([
|
||||
]);
|
||||
|
||||
// Refresh Link
|
||||
var RefreshLinkTest = function() {
|
||||
return <RefreshLink>People</RefreshLink>;
|
||||
}
|
||||
var RefreshLinkTest = () => <RefreshLink>People</RefreshLink>;
|
||||
|
||||
RefreshLinkTest = function() {
|
||||
RefreshLinkTest = () => {
|
||||
return (
|
||||
<RefreshLink
|
||||
navigationData={{ page: 2 }}
|
||||
@@ -22,21 +20,19 @@ RefreshLinkTest = function() {
|
||||
disableActive={true}
|
||||
lazy={false}
|
||||
historyAction="replace"
|
||||
navigating= {(e: MouseEvent, domId: string, link: string) => true}
|
||||
navigating= {(e: MouseEvent, domId: string, link: string) => true}
|
||||
stateNavigator={stateNavigator}
|
||||
target="_blank"
|
||||
aria-label="Go to the second page of people">
|
||||
People
|
||||
</RefreshLink>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// Navigation Link
|
||||
var NavigationLinkTest = function() {
|
||||
return <NavigationLink stateKey="person">Person</NavigationLink>;
|
||||
}
|
||||
var NavigationLinkTest = () => <NavigationLink stateKey="person">Person</NavigationLink>;
|
||||
|
||||
NavigationLinkTest = function() {
|
||||
NavigationLinkTest = () => {
|
||||
return (
|
||||
<NavigationLink
|
||||
stateKey="person"
|
||||
@@ -47,32 +43,29 @@ NavigationLinkTest = function() {
|
||||
disableActive={false}
|
||||
lazy={false}
|
||||
historyAction="add"
|
||||
navigating= {(e: MouseEvent, domId: string, link: string) => true}
|
||||
navigating= {(e: MouseEvent, domId: string, link: string) => true}
|
||||
stateNavigator={stateNavigator}
|
||||
target="_blank"
|
||||
aria-label="View the person's details">
|
||||
Person
|
||||
</NavigationLink>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// Navigation Back Link
|
||||
var NavigationBackLinkTest = function() {
|
||||
return <NavigationBackLink distance={1}>People</NavigationBackLink>;
|
||||
}
|
||||
var NavigationBackLinkTest = () => <NavigationBackLink distance={1}>People</NavigationBackLink>;
|
||||
|
||||
NavigationBackLinkTest = function() {
|
||||
NavigationBackLinkTest = () => {
|
||||
return (
|
||||
<NavigationBackLink
|
||||
distance={1}
|
||||
lazy={false}
|
||||
historyAction="none"
|
||||
navigating= {(e: MouseEvent, domId: string, link: string) => true}
|
||||
navigating= {(e: MouseEvent, domId: string, link: string) => true}
|
||||
stateNavigator={stateNavigator}
|
||||
target="_blank"
|
||||
aria-label="Go back to the list of people">
|
||||
People
|
||||
</NavigationBackLink>
|
||||
);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@ var device = new HID.HID("path");
|
||||
|
||||
var device = new HID.HID(12, 22);
|
||||
|
||||
device.on("data", function (data) { });
|
||||
device.on("error", function (err) { });
|
||||
device.on("data", data => {});
|
||||
device.on("error", err => {});
|
||||
|
||||
device.write([0x00, 0x01, 0x01, 0x05, 0xff, 0xff]);
|
||||
@@ -4,7 +4,7 @@ var wit = new Wit({
|
||||
accessToken: "",
|
||||
actions: {
|
||||
send(request: WitRequest, response: WitResponse) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log(response.text);
|
||||
console.log(request.entities);
|
||||
return resolve();
|
||||
|
||||
@@ -4,10 +4,10 @@ import * as zookeeper from "node-zookeeper-client";
|
||||
const client = zookeeper.createClient('localhost:2181');
|
||||
const path = process.argv[2];
|
||||
|
||||
client.once('connected', function () {
|
||||
client.once('connected', () => {
|
||||
console.log('Connected to the server.');
|
||||
|
||||
client.create(path, function (error) {
|
||||
client.create(path, error => {
|
||||
if (error) {
|
||||
console.log('Failed to create node: %s due to: %s.', path, error);
|
||||
} else {
|
||||
@@ -24,11 +24,11 @@ import * as zookeeper from "node-zookeeper-client";
|
||||
function listChildren(client: zookeeper.Client, path: string) {
|
||||
client.getChildren(
|
||||
path,
|
||||
function (event) {
|
||||
event => {
|
||||
console.log('Got watcher event: %s', event);
|
||||
listChildren(client, path);
|
||||
},
|
||||
function (error, children, stat) {
|
||||
(error, children, stat) => {
|
||||
if (error) {
|
||||
console.log(
|
||||
'Failed to list children of %s due to: %s.',
|
||||
@@ -47,7 +47,7 @@ function listChildren(client: zookeeper.Client, path: string) {
|
||||
const client = zookeeper.createClient('localhost:2181');
|
||||
const path = process.argv[2];
|
||||
|
||||
client.once('connected', function () {
|
||||
client.once('connected', () => {
|
||||
console.log('Connected to ZooKeeper.');
|
||||
listChildren(client, path);
|
||||
});
|
||||
@@ -65,7 +65,7 @@ const client = zookeeper.createClient(
|
||||
'/test/demo',
|
||||
new Buffer('data'),
|
||||
zookeeper.CreateMode.EPHEMERAL,
|
||||
function (error: Error, path) {
|
||||
(error: Error, path) => {
|
||||
if (error) {
|
||||
console.log(error.stack);
|
||||
return;
|
||||
@@ -77,7 +77,7 @@ const client = zookeeper.createClient(
|
||||
}
|
||||
|
||||
{
|
||||
client.remove('/test/demo', -1, function (error: Error) {
|
||||
client.remove('/test/demo', -1, (error: Error) => {
|
||||
if (error) {
|
||||
console.log(error.stack);
|
||||
return;
|
||||
@@ -88,7 +88,7 @@ const client = zookeeper.createClient(
|
||||
}
|
||||
|
||||
{
|
||||
client.exists('/test/demo', function (error: Error, stat) {
|
||||
client.exists('/test/demo', (error: Error, stat) => {
|
||||
if (error) {
|
||||
console.log(error.stack);
|
||||
return;
|
||||
@@ -103,7 +103,7 @@ const client = zookeeper.createClient(
|
||||
}
|
||||
|
||||
{
|
||||
client.getChildren('/test/demo', function (error: Error, children, stats) {
|
||||
client.getChildren('/test/demo', (error: Error, children, stats) => {
|
||||
if (error) {
|
||||
console.log(error.stack);
|
||||
return;
|
||||
@@ -116,10 +116,10 @@ const client = zookeeper.createClient(
|
||||
{
|
||||
client.getData(
|
||||
'/test/demo',
|
||||
function (event) {
|
||||
event => {
|
||||
console.log('Got event: %s.', event);
|
||||
},
|
||||
function (error: Error, data, stat) {
|
||||
(error: Error, data, stat) => {
|
||||
if (error) {
|
||||
console.log(error.stack);
|
||||
return;
|
||||
@@ -131,7 +131,7 @@ const client = zookeeper.createClient(
|
||||
}
|
||||
|
||||
{
|
||||
client.setData('/test/demo', null, 2, function (error: Error, stat) {
|
||||
client.setData('/test/demo', null, 2, (error: Error, stat) => {
|
||||
if (error) {
|
||||
console.log(error.stack);
|
||||
return;
|
||||
@@ -142,7 +142,7 @@ const client = zookeeper.createClient(
|
||||
}
|
||||
|
||||
{
|
||||
client.getACL('/test/demo', function (error: Error, acls, stat) {
|
||||
client.getACL('/test/demo', (error: Error, acls, stat) => {
|
||||
if (error) {
|
||||
console.log(error.stack);
|
||||
return;
|
||||
@@ -161,7 +161,7 @@ const client = zookeeper.createClient(
|
||||
new zookeeper.Id('ip', '127.0.0.1')
|
||||
)
|
||||
],
|
||||
function (error: Error, stat) {
|
||||
(error: Error, stat) => {
|
||||
if (error) {
|
||||
console.log(error.stack);
|
||||
return;
|
||||
@@ -173,7 +173,7 @@ const client = zookeeper.createClient(
|
||||
}
|
||||
|
||||
{
|
||||
client.mkdirp('/test/demo/1/2/3', function (error: Error, path) {
|
||||
client.mkdirp('/test/demo/1/2/3', (error: Error, path) => {
|
||||
if (error) {
|
||||
console.log(error.stack);
|
||||
return;
|
||||
@@ -201,10 +201,10 @@ const client = zookeeper.createClient(
|
||||
client.getSessionPassword();
|
||||
client.getSessionTimeout();
|
||||
|
||||
client.on('connected', function () {
|
||||
client.on('connected', () => {
|
||||
console.log('Client state is changed to connected.');
|
||||
});
|
||||
client.on('state', function (state) {
|
||||
client.on('state', state => {
|
||||
if (state === zookeeper.State.SYNC_CONNECTED) {
|
||||
console.log('Client state is changed to connected.');
|
||||
}
|
||||
@@ -212,7 +212,7 @@ const client = zookeeper.createClient(
|
||||
}
|
||||
|
||||
{
|
||||
client.once('connected', function () {
|
||||
client.once('connected', () => {
|
||||
client.transaction().
|
||||
create('/txn').
|
||||
create('/txn/1', new Buffer('transaction')).
|
||||
@@ -220,7 +220,7 @@ const client = zookeeper.createClient(
|
||||
check('/txn/1').
|
||||
remove('/txn/1', -1).
|
||||
remove('/txn').
|
||||
commit(function (error, results) {
|
||||
commit((error, results) => {
|
||||
if (error) {
|
||||
console.log(
|
||||
'Failed to execute the transaction: %s, results: %j',
|
||||
@@ -238,7 +238,7 @@ const client = zookeeper.createClient(
|
||||
}
|
||||
|
||||
{
|
||||
client.create('/test/demo', function (error, path) {
|
||||
client.create('/test/demo', (error, path) => {
|
||||
if (error) {
|
||||
if ((error as zookeeper.Exception).getCode() === zookeeper.Exception.NODE_EXISTS) {
|
||||
console.log('Node exists.');
|
||||
|
||||
+82
-82
@@ -13,10 +13,10 @@
|
||||
defaultLeft: 300,
|
||||
autoShow: true
|
||||
}
|
||||
}, function (successObj) {
|
||||
}, successObj => {
|
||||
console.log("Application successfully created, HTTP response code:", successObj);
|
||||
application.run();
|
||||
}, function (error) {
|
||||
}, error => {
|
||||
console.log("Error creating application:", error);
|
||||
});
|
||||
// getCurrent
|
||||
@@ -26,51 +26,51 @@
|
||||
// getWindow
|
||||
application.getWindow();
|
||||
// addEventListener
|
||||
application.addEventListener("closed", function (event) {
|
||||
application.addEventListener("closed", event => {
|
||||
console.log("The application has closed");
|
||||
}, () => {
|
||||
console.log("The registration was successful");
|
||||
}, function (reason) {
|
||||
}, reason => {
|
||||
console.log("failure: " + reason);
|
||||
});
|
||||
// close
|
||||
application.close();
|
||||
// getChildWindows
|
||||
application.getChildWindows(function (children) {
|
||||
children.forEach(function (childWindow) {
|
||||
application.getChildWindows(children => {
|
||||
children.forEach(childWindow => {
|
||||
console.log("Showing child: " + childWindow.name);
|
||||
childWindow.show();
|
||||
});
|
||||
});
|
||||
// getGroups
|
||||
application.getGroups(function (allGroups) {
|
||||
application.getGroups(allGroups => {
|
||||
console.log("There are a total of " + allGroups.length + " groups.");
|
||||
|
||||
var groupCounter = 1;
|
||||
allGroups.forEach(function (windowGroup) {
|
||||
allGroups.forEach(windowGroup => {
|
||||
console.log("Group " + groupCounter + " contains " +
|
||||
windowGroup.length + " windows.");
|
||||
++groupCounter;
|
||||
});
|
||||
});
|
||||
// getManifest
|
||||
application.getManifest(function (manifest) {
|
||||
application.getManifest(manifest => {
|
||||
console.log("Application manifest:");
|
||||
console.log(manifest);
|
||||
});
|
||||
// getParentUuid
|
||||
application.getParentUuid(function (parentUuid) {
|
||||
application.getParentUuid(parentUuid => {
|
||||
console.log("UUID of parent application:");
|
||||
console.log(parentUuid);
|
||||
});
|
||||
// getShortcuts
|
||||
application.getShortcuts(function (config) {
|
||||
application.getShortcuts(config => {
|
||||
console.log("Desktop shortcut is enabled: ", config.desktop);
|
||||
console.log("Start Menu shortcut is enabled: ", config.startMenu);
|
||||
console.log("System Startup shortcut is enabled: ", config.systemStartup);
|
||||
});
|
||||
// isRunning
|
||||
application.isRunning(function (running) {
|
||||
application.isRunning(running => {
|
||||
console.log("the application is", running ? "running" : "not running");
|
||||
});
|
||||
// registerCustomData
|
||||
@@ -78,32 +78,32 @@
|
||||
someData: "this is custom"
|
||||
}, () => {
|
||||
console.log("You will not read this.");
|
||||
}, function (err) {
|
||||
}, err => {
|
||||
console.log("failure:", err);
|
||||
});
|
||||
// removeEventListener
|
||||
let previousCallback = function (event: fin.WindowEvent) { };
|
||||
let previousCallback = (event: fin.WindowEvent) => { };
|
||||
application.removeEventListener("closed", previousCallback, () => {
|
||||
console.log("The unregistration was successful");
|
||||
}, function (err) {
|
||||
}, err => {
|
||||
console.log("failure:", err);
|
||||
});
|
||||
// removeTrayIcon
|
||||
application.removeTrayIcon(() => {
|
||||
console.log("Removed the tray icon.");
|
||||
}, function (err) {
|
||||
}, err => {
|
||||
console.log("failure:", err);
|
||||
});
|
||||
// restart
|
||||
application.restart(() => {
|
||||
console.log("You will not read this.");
|
||||
}, function (err) {
|
||||
}, err => {
|
||||
console.log("failure:", err);
|
||||
});
|
||||
// schedule restart
|
||||
application.scheduleRestart(() => {
|
||||
console.log("You will not read this.");
|
||||
}, function (err) {
|
||||
}, err => {
|
||||
console.log("failure:", err);
|
||||
});
|
||||
// setShortcuts
|
||||
@@ -113,11 +113,11 @@
|
||||
systemStartup: true
|
||||
}, () => {
|
||||
console.log("Successfully set new shortcut states");
|
||||
}, function (error) {
|
||||
}, error => {
|
||||
console.log("Failed to set new shortcut states. Error: ", error);
|
||||
});
|
||||
// setTrayIcon
|
||||
application.setTrayIcon("https://developer.openf.in/download/openfin.png", function (clickInfo) {
|
||||
application.setTrayIcon("https://developer.openf.in/download/openfin.png", clickInfo => {
|
||||
console.log("The mouse has clicked at (" + clickInfo.x + "," + clickInfo.y + ")");
|
||||
});
|
||||
// terminate
|
||||
@@ -152,15 +152,15 @@ function test_external_application() {
|
||||
|
||||
function test_inter_application_bus() {
|
||||
// addSubscribeListener
|
||||
fin.desktop.InterApplicationBus.addSubscribeListener(function (uuid, topic, name) {
|
||||
fin.desktop.InterApplicationBus.addSubscribeListener((uuid, topic, name) => {
|
||||
console.log("The application " + uuid + " has subscribed to " + topic);
|
||||
});
|
||||
// addUnsubscribeListener
|
||||
fin.desktop.InterApplicationBus.addUnsubscribeListener(function (uuid, topic, name) {
|
||||
fin.desktop.InterApplicationBus.addUnsubscribeListener((uuid, topic, name) => {
|
||||
console.log("The application " + uuid + " has unsubscribed to " + topic);
|
||||
});
|
||||
// removeSubscribeListener
|
||||
let aRegisteredListener = function (uuid: string, topic: string, name: string) { };
|
||||
let aRegisteredListener = (uuid: string, topic: string, name: string) => { };
|
||||
fin.desktop.InterApplicationBus.removeSubscribeListener(aRegisteredListener);
|
||||
// removeUnsubscribeListener
|
||||
fin.desktop.InterApplicationBus.removeUnsubscribeListener(aRegisteredListener);
|
||||
@@ -175,11 +175,11 @@ function test_inter_application_bus() {
|
||||
field2: "value2"
|
||||
});
|
||||
// subscribe
|
||||
fin.desktop.InterApplicationBus.subscribe("*", "a topic", function (message, uuid, name) {
|
||||
fin.desktop.InterApplicationBus.subscribe("*", "a topic", (message, uuid, name) => {
|
||||
console.log("The application " + uuid + " sent this message: " + message);
|
||||
});
|
||||
// unsubscribe
|
||||
let aRegisteredMessageListener = function (message: any, senderUuid: string) {
|
||||
let aRegisteredMessageListener = (message: any, senderUuid: string) => {
|
||||
console.log(message, senderUuid);
|
||||
};
|
||||
fin.desktop.InterApplicationBus.unsubscribe("*", "a topic", aRegisteredMessageListener);
|
||||
@@ -209,11 +209,11 @@ function test_notification() {
|
||||
|
||||
function test_system() {
|
||||
// addEventListener
|
||||
fin.desktop.System.addEventListener('monitor-info-changed', function (event) {
|
||||
fin.desktop.System.addEventListener('monitor-info-changed', event => {
|
||||
console.log("The monitor information has changed to: ", event);
|
||||
}, () => {
|
||||
console.log("The registration was successful");
|
||||
}, function (err) {
|
||||
}, err => {
|
||||
console.log("failure: " + err);
|
||||
});
|
||||
// clearCache
|
||||
@@ -227,7 +227,7 @@ function test_system() {
|
||||
// deleteCacheOnExit
|
||||
fin.desktop.System.deleteCacheOnExit(() => {
|
||||
console.log("successful");
|
||||
}, function (err) {
|
||||
}, err => {
|
||||
console.log("failure: " + err);
|
||||
});
|
||||
// downloadAsset
|
||||
@@ -251,12 +251,12 @@ function test_system() {
|
||||
// exit
|
||||
fin.desktop.System.exit(() => {
|
||||
console.log("successful");
|
||||
}, function (err) {
|
||||
}, err => {
|
||||
console.log("failure: " + err);
|
||||
});
|
||||
// getAllApplications
|
||||
fin.desktop.System.getAllApplications(function (applicationInfoList) {
|
||||
applicationInfoList.forEach(function (applicationInfo) {
|
||||
fin.desktop.System.getAllApplications(applicationInfoList => {
|
||||
applicationInfoList.forEach(applicationInfo => {
|
||||
console.log("Showing information for application with uuid: "
|
||||
+ applicationInfo.uuid);
|
||||
console.log("isRunning: ", applicationInfo.isRunning);
|
||||
@@ -269,38 +269,38 @@ function test_system() {
|
||||
});
|
||||
});
|
||||
// getAllWindows
|
||||
fin.desktop.System.getAllWindows(function (windowInfoList) {
|
||||
windowInfoList.forEach(function (windowInfo) {
|
||||
fin.desktop.System.getAllWindows(windowInfoList => {
|
||||
windowInfoList.forEach(windowInfo => {
|
||||
console.log("Showing information for application with uuid: ", windowInfo.uuid);
|
||||
console.log("Main window: ", windowInfo.mainWindow);
|
||||
console.log("Child windows: ", windowInfo.childWindows);
|
||||
});
|
||||
});
|
||||
// getCommandLineArguments
|
||||
fin.desktop.System.getCommandLineArguments(function (args) {
|
||||
fin.desktop.System.getCommandLineArguments(args => {
|
||||
console.log("The command line arguments are " + args);
|
||||
});
|
||||
// getDeviceId
|
||||
fin.desktop.System.getDeviceId(function (id) {
|
||||
fin.desktop.System.getDeviceId(id => {
|
||||
console.log("The id of the device is: " + id);
|
||||
});
|
||||
// getEnvironmentVariable
|
||||
fin.desktop.System.getEnvironmentVariable("APPDATA", function (variable) {
|
||||
fin.desktop.System.getEnvironmentVariable("APPDATA", variable => {
|
||||
console.log("this is the APPDATA value", variable);
|
||||
});
|
||||
// getHostSpecs
|
||||
fin.desktop.System.getHostSpecs(function (info) {
|
||||
fin.desktop.System.getHostSpecs(info => {
|
||||
console.log(info);
|
||||
}, function (error) {
|
||||
}, error => {
|
||||
console.log('There was an error:', error);
|
||||
});
|
||||
// getLog
|
||||
fin.desktop.System.getLog('debug-2015-01-08-22-27-53.log', function (log) {
|
||||
fin.desktop.System.getLog('debug-2015-01-08-22-27-53.log', log => {
|
||||
console.log(log);
|
||||
});
|
||||
// getLogList
|
||||
fin.desktop.System.getLogList(function (logList) {
|
||||
logList.forEach(function (logInfo) {
|
||||
fin.desktop.System.getLogList(logList => {
|
||||
logList.forEach(logInfo => {
|
||||
console.log("The filename of the log is " +
|
||||
logInfo.name + ", the size is " +
|
||||
logInfo.size + ", and the date of creation is " +
|
||||
@@ -308,44 +308,44 @@ function test_system() {
|
||||
});
|
||||
});
|
||||
// getMonitorInfo
|
||||
fin.desktop.System.getMonitorInfo(function (monitorInfo) {
|
||||
fin.desktop.System.getMonitorInfo(monitorInfo => {
|
||||
console.log("This object contains information about all monitors: ", monitorInfo);
|
||||
});
|
||||
// getMousePosition
|
||||
fin.desktop.System.getMousePosition(function (mousePosition) {
|
||||
fin.desktop.System.getMousePosition(mousePosition => {
|
||||
console.log("The mouse is located at left: " + mousePosition.left + ", top: " + mousePosition.top);
|
||||
});
|
||||
// getProcessList
|
||||
fin.desktop.System.getProcessList(function (list) {
|
||||
list.forEach(function (process) {
|
||||
fin.desktop.System.getProcessList(list => {
|
||||
list.forEach(process => {
|
||||
console.log("UUID: " + process.uuid + ", Application Name: " + process.name);
|
||||
});
|
||||
});
|
||||
// getProxySettings
|
||||
fin.desktop.System.getProxySettings(function (proxy) {
|
||||
fin.desktop.System.getProxySettings(proxy => {
|
||||
console.log(proxy);
|
||||
});
|
||||
// getRvmInfo
|
||||
fin.desktop.System.getRvmInfo(function (rvmInfoObject) {
|
||||
fin.desktop.System.getRvmInfo(rvmInfoObject => {
|
||||
console.log("RVM version:", rvmInfoObject.version);
|
||||
console.log("RVM has been running since:", rvmInfoObject["start-time"]);
|
||||
}, function (err) {
|
||||
}, err => {
|
||||
console.log("Failed to get rvm info, error message:", err);
|
||||
});
|
||||
// getVersion
|
||||
fin.desktop.System.getVersion(function (version) {
|
||||
fin.desktop.System.getVersion(version => {
|
||||
console.log("The version is " + version);
|
||||
});
|
||||
// launchExternalProcess
|
||||
fin.desktop.System.launchExternalProcess({
|
||||
path: "notepad",
|
||||
arguments: "",
|
||||
listener: function (result) {
|
||||
listener(result) {
|
||||
console.log('the exit code', result.exitCode);
|
||||
}
|
||||
}, function (payload) {
|
||||
}, payload => {
|
||||
console.log('Success:', payload.uuid);
|
||||
}, function (error) {
|
||||
}, error => {
|
||||
console.log('Error:', error);
|
||||
});
|
||||
//
|
||||
@@ -354,24 +354,24 @@ function test_system() {
|
||||
//will default to the one mentioned by appAssets.target
|
||||
//If the the path below refers to a specific path it will override this default
|
||||
alias: "myApp",
|
||||
listener: function (result) {
|
||||
listener(result) {
|
||||
console.log('the exit code', result.exitCode);
|
||||
}
|
||||
}, function (payload) {
|
||||
}, payload => {
|
||||
console.log('Success:', payload.uuid);
|
||||
}, function (error) {
|
||||
}, error => {
|
||||
console.log('Error:', error);
|
||||
});
|
||||
//
|
||||
fin.desktop.System.launchExternalProcess({
|
||||
alias: "myApp",
|
||||
arguments: "e f g",
|
||||
listener: function (result) {
|
||||
listener(result) {
|
||||
console.log('the exit code', result.exitCode);
|
||||
}
|
||||
}, function (payload) {
|
||||
}, payload => {
|
||||
console.log('Success:', payload.uuid);
|
||||
}, function (error) {
|
||||
}, error => {
|
||||
console.log('Error:', error);
|
||||
});
|
||||
//
|
||||
@@ -383,55 +383,55 @@ function test_system() {
|
||||
subject: 'O=OpenFin INC., L=New York, S=NY, C=US',
|
||||
thumbprint: '3c a5 28 19 83 05 fe 69 88 e6 8f 4b 3a af c5 c5 1b 07 80 5b'
|
||||
},
|
||||
listener: function (result) {
|
||||
listener(result) {
|
||||
console.log('the exit code', result.exitCode);
|
||||
}
|
||||
}, function (payload) {
|
||||
}, payload => {
|
||||
console.log('Success:', payload.uuid);
|
||||
}, function (error) {
|
||||
}, error => {
|
||||
console.log('Error:', error);
|
||||
});
|
||||
// log
|
||||
fin.desktop.System.log("info", "An example log message", () => {
|
||||
console.log("message successfully logged");
|
||||
}, function (err) {
|
||||
}, err => {
|
||||
console.log(err);
|
||||
});
|
||||
// monitorExternalProcess
|
||||
fin.desktop.System.monitorExternalProcess({
|
||||
pid: 2508,
|
||||
listener: function (result) {
|
||||
listener(result) {
|
||||
console.log('the exit code', result.exitCode);
|
||||
}
|
||||
}, function (payload) {
|
||||
}, payload => {
|
||||
console.log("The process is now being monitored: ", payload.uuid);
|
||||
}, function (error) {
|
||||
}, error => {
|
||||
console.log("Error:", error);
|
||||
});
|
||||
// openUrlWithBrowser
|
||||
fin.desktop.System.openUrlWithBrowser("https://developer.openf.in/", () => {
|
||||
console.log("successful");
|
||||
}, function (err) {
|
||||
}, err => {
|
||||
console.log("failure: " + err);
|
||||
});
|
||||
// registerExternalConnection
|
||||
fin.desktop.System.registerExternalConnection("remote-connection-uuid", function() {
|
||||
console.log(arguments);
|
||||
fin.desktop.System.registerExternalConnection("remote-connection-uuid", (...args: any[]) => {
|
||||
console.log(args);
|
||||
});
|
||||
// releaseExternalProcess
|
||||
fin.desktop.System.launchExternalProcess({
|
||||
path: "notepad",
|
||||
arguments: "",
|
||||
listener: function (result) {
|
||||
listener(result) {
|
||||
console.log("The exit code", result.exitCode);
|
||||
}
|
||||
}, function (result) {
|
||||
}, result => {
|
||||
console.log("Result UUID is " + result.uuid);
|
||||
|
||||
//release it.
|
||||
fin.desktop.System.releaseExternalProcess(result.uuid, () => {
|
||||
console.log("Process has been unmapped!");
|
||||
}, function (reason) {
|
||||
}, reason => {
|
||||
console.log("failure: " + reason);
|
||||
});
|
||||
});
|
||||
@@ -439,13 +439,13 @@ function test_system() {
|
||||
let aRegisteredListener = (event: fin.SystemBaseEvent) => { };
|
||||
fin.desktop.System.removeEventListener("monitor-info-changed", aRegisteredListener, () => {
|
||||
console.log("successful");
|
||||
}, function (err) {
|
||||
}, err => {
|
||||
console.log("failure: " + err);
|
||||
});
|
||||
// showDeveloperTools
|
||||
fin.desktop.System.showDeveloperTools("uuid", "name", () => {
|
||||
console.log("successful");
|
||||
}, function (err) {
|
||||
}, err => {
|
||||
console.log("failure: " + err);
|
||||
});
|
||||
// terminateExternalProcess
|
||||
@@ -453,24 +453,24 @@ function test_system() {
|
||||
// notepad is in the system’s PATH
|
||||
path: "notepad",
|
||||
arguments: "",
|
||||
listener: function (result) {
|
||||
listener(result) {
|
||||
console.log("The exit code", result.exitCode);
|
||||
}
|
||||
}, function (result) {
|
||||
}, result => {
|
||||
console.log("Result UUID is " + result.uuid);
|
||||
|
||||
// Attempt to close the process. Terminate after 4 seconds if it
|
||||
// has not done so.
|
||||
fin.desktop.System.terminateExternalProcess(result.uuid, 4000, function (info) {
|
||||
fin.desktop.System.terminateExternalProcess(result.uuid, 4000, info => {
|
||||
console.log("Termination result " + info.result);
|
||||
}, function (reason) {
|
||||
}, reason => {
|
||||
console.log("failure: " + reason);
|
||||
});
|
||||
});
|
||||
// updateProxySettings
|
||||
fin.desktop.System.updateProxySettings("type", "proxyAddress", 8080, () => {
|
||||
console.log('success');
|
||||
}, function (err) {
|
||||
}, err => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
@@ -546,7 +546,7 @@ function test_window() {
|
||||
}, () => {
|
||||
var _win = finWindow.getNativeWindow();
|
||||
_win.addEventListener("DOMContentLoaded", () => { finWindow.show(); });
|
||||
}, function (error) {
|
||||
}, error => {
|
||||
console.log("Error creating window:", error);
|
||||
});
|
||||
// getCurrent
|
||||
@@ -563,11 +563,11 @@ function test_window() {
|
||||
// wrap
|
||||
finWindow = fin.desktop.Window.wrap("uuid", "name");
|
||||
// addEventListener
|
||||
finWindow.addEventListener("bounds-changed", function (event) {
|
||||
finWindow.addEventListener("bounds-changed", event => {
|
||||
console.log("The window has been moved or resized");
|
||||
}, () => {
|
||||
console.log("The registration was successful");
|
||||
}, function (reason) {
|
||||
}, reason => {
|
||||
console.log("failure:" + reason);
|
||||
});
|
||||
// animate
|
||||
@@ -583,7 +583,7 @@ function test_window() {
|
||||
}
|
||||
}, {
|
||||
interrupt: false
|
||||
}, function (evt) {
|
||||
}, evt => {
|
||||
// Callback will only fire after both "opacity" and "position" have finished animating.
|
||||
});
|
||||
// authenticate
|
||||
|
||||
+2
-2
@@ -514,7 +514,7 @@ const tests = {
|
||||
selfSigned: true
|
||||
}, (error: any, csr: any) => {
|
||||
|
||||
pem.createPkcs12(csr.clientKey, csr.certificate, 'mypassword', function(err: any, pkcs12: any){
|
||||
pem.createPkcs12(csr.clientKey, csr.certificate, 'mypassword', (err: any, pkcs12: any) => {
|
||||
test.ifError(err);
|
||||
test.ok(pkcs12);
|
||||
|
||||
@@ -533,7 +533,7 @@ const tests = {
|
||||
selfSigned: true
|
||||
}, (error: any, csr: any) => {
|
||||
|
||||
pem.createPkcs12(csr.clientKey, csr.certificate, 'mypassword', {cipher: 'aes256', clientKeyPassword: 'xxx'}, function(err: any, pkcs12: any){
|
||||
pem.createPkcs12(csr.clientKey, csr.certificate, 'mypassword', {cipher: 'aes256', clientKeyPassword: 'xxx'}, (err: any, pkcs12: any) => {
|
||||
test.ifError(err);
|
||||
test.ok(pkcs12);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ new Pikaday({field: $('#datepicker')[0]});
|
||||
(() => {
|
||||
var field: HTMLInputElement = <HTMLInputElement> document.getElementById('datepicker');
|
||||
var picker = new Pikaday({
|
||||
onSelect: function (date: Date) {
|
||||
onSelect(date: Date) {
|
||||
field.value = picker.toString();
|
||||
console.log(date.toISOString());
|
||||
}
|
||||
@@ -21,7 +21,7 @@ new Pikaday({field: $('#datepicker')[0]});
|
||||
var picker = new Pikaday({
|
||||
field: document.getElementById('datepicker'),
|
||||
format: 'D MMM YYYY',
|
||||
onSelect: function () {
|
||||
onSelect() {
|
||||
console.log(this.getMoment().format('Do MMMM YYYY'));
|
||||
}
|
||||
});
|
||||
|
||||
Vendored
+2881
-2889
File diff suppressed because it is too large
Load Diff
+30
-64
@@ -126,17 +126,13 @@ namespace basics {
|
||||
this.stage.addChild(this.container);
|
||||
|
||||
for (var j = 0; j < 5; j++) {
|
||||
|
||||
for (var i = 0; i < 5; i++) {
|
||||
|
||||
var bunny: PIXI.Sprite = PIXI.Sprite.fromImage('../../_assets/basics/bunny.png');
|
||||
bunny.x = 40 * i;
|
||||
bunny.y = 40 * j;
|
||||
this.container.addChild(bunny);
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* All the bunnies are added to the container with the addChild method
|
||||
@@ -226,7 +222,7 @@ namespace basics {
|
||||
type: '1f',
|
||||
value: 0
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -324,18 +320,14 @@ namespace basics {
|
||||
this.stage.addChild(this.container);
|
||||
|
||||
for (var j = 0; j < 5; j++) {
|
||||
|
||||
for (var i = 0; i < 5; i++) {
|
||||
|
||||
var bunny: PIXI.Sprite = PIXI.Sprite.fromImage('../../_assets/basics/bunny.png');
|
||||
bunny.x = 40 * i;
|
||||
bunny.y = 40 * j;
|
||||
bunny.rotation = Math.random() * (Math.PI * 2);
|
||||
this.container.addChild(bunny);
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
this.renderTexture = PIXI.RenderTexture.create(300, 200, PIXI.SCALE_MODES.LINEAR, 0.1);
|
||||
|
||||
@@ -354,7 +346,7 @@ namespace basics {
|
||||
|
||||
private animate = (): void => {
|
||||
|
||||
this.renderer.render(this.container, this.renderTexture)
|
||||
this.renderer.render(this.container, this.renderTexture);
|
||||
|
||||
requestAnimationFrame(this.animate);
|
||||
|
||||
@@ -533,7 +525,7 @@ namespace basics {
|
||||
|
||||
for (var i = 0; i < 25; i++) {
|
||||
this.points.push(new PIXI.Point(i * this.ropeLength, 0));
|
||||
};
|
||||
}
|
||||
|
||||
this.strip = new PIXI.mesh.Rope(PIXI.Texture.fromImage('../../_assets/snake.png'), this.points);
|
||||
this.strip.position.x = -40;
|
||||
@@ -556,12 +548,9 @@ namespace basics {
|
||||
|
||||
//make the snake
|
||||
for (var i = 0; i < this.points.length; i++) {
|
||||
|
||||
this.points[i].y = Math.sin((i * 0.5) + this.count) * 30;
|
||||
|
||||
this.points[i].x = i * this.ropeLength + Math.cos((i * 0.3) + this.count) * 20;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
//render the stage
|
||||
this.renderer.render(this.stage);
|
||||
@@ -573,7 +562,6 @@ namespace basics {
|
||||
}
|
||||
|
||||
private renderPoints(): void {
|
||||
|
||||
this.graphics.clear();
|
||||
|
||||
this.graphics.lineStyle(2, 0xffc2c2);
|
||||
@@ -581,14 +569,13 @@ namespace basics {
|
||||
|
||||
for (var i = 1; i < this.points.length; i++) {
|
||||
this.graphics.lineTo(this.points[i].x, this.points[i].y);
|
||||
};
|
||||
}
|
||||
|
||||
for (var i = 1; i < this.points.length; i++) {
|
||||
this.graphics.beginFill(0xff0022);
|
||||
this.graphics.drawCircle(this.points[i].x, this.points[i].y, 10);
|
||||
this.graphics.endFill();
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -872,9 +859,7 @@ namespace demos {
|
||||
private animate = (): void => {
|
||||
|
||||
// iterate through the sprites and update their position
|
||||
for (var i = 0; i < this.maggots.length; i++) {
|
||||
|
||||
var dude = this.maggots[i];
|
||||
for (const dude of this.maggots) {
|
||||
dude.scale.y = 0.95 + Math.sin(this.tick + dude.offset) * 0.05;
|
||||
dude.direction += dude.turningSpeed * 0.01;
|
||||
dude.position.x += Math.sin(dude.direction) * (dude.speed * dude.scale.y);
|
||||
@@ -884,15 +869,13 @@ namespace demos {
|
||||
// wrap the maggots
|
||||
if (dude.position.x < this.dudeBounds.x) {
|
||||
dude.position.x += this.dudeBounds.width;
|
||||
}
|
||||
else if (dude.position.x > this.dudeBounds.x + this.dudeBounds.width) {
|
||||
} else if (dude.position.x > this.dudeBounds.x + this.dudeBounds.width) {
|
||||
dude.position.x -= this.dudeBounds.width;
|
||||
}
|
||||
|
||||
if (dude.position.y < this.dudeBounds.y) {
|
||||
dude.position.y += this.dudeBounds.height;
|
||||
}
|
||||
else if (dude.position.y > this.dudeBounds.y + this.dudeBounds.height) {
|
||||
} else if (dude.position.y > this.dudeBounds.y + this.dudeBounds.height) {
|
||||
dude.position.y -= this.dudeBounds.height;
|
||||
}
|
||||
}
|
||||
@@ -1012,9 +995,7 @@ namespace demos {
|
||||
private animate = (): void => {
|
||||
|
||||
// iterate through the dudes and update the positions
|
||||
for (var i = 0; i < this.dudeArray.length; i++) {
|
||||
|
||||
var dude = this.dudeArray[i];
|
||||
for (const dude of this.dudeArray) {
|
||||
dude.direction += dude.turningSpeed * 0.01;
|
||||
dude.position.x += Math.sin(dude.direction) * dude.speed;
|
||||
dude.position.y += Math.cos(dude.direction) * dude.speed;
|
||||
@@ -1023,15 +1004,13 @@ namespace demos {
|
||||
// wrap the dudes by testing their bounds...
|
||||
if (dude.position.x < this.dudeBounds.x) {
|
||||
dude.position.x += this.dudeBounds.width;
|
||||
}
|
||||
else if (dude.position.x > this.dudeBounds.x + this.dudeBounds.width) {
|
||||
} else if (dude.position.x > this.dudeBounds.x + this.dudeBounds.width) {
|
||||
dude.position.x -= this.dudeBounds.width;
|
||||
}
|
||||
|
||||
if (dude.position.y < this.dudeBounds.y) {
|
||||
dude.position.y += this.dudeBounds.height;
|
||||
}
|
||||
else if (dude.position.y > this.dudeBounds.y + this.dudeBounds.height) {
|
||||
} else if (dude.position.y > this.dudeBounds.y + this.dudeBounds.height) {
|
||||
dude.position.y -= this.dudeBounds.height;
|
||||
}
|
||||
}
|
||||
@@ -1567,7 +1546,7 @@ namespace demos {
|
||||
.on('mouseover', this.onButtonOver)
|
||||
|
||||
// set the mouseout callback...
|
||||
.on('mouseout', this.onButtonOut)
|
||||
.on('mouseout', this.onButtonOut);
|
||||
|
||||
// you can also listen to click and tap events :
|
||||
//.on('click', this.noop)
|
||||
@@ -1588,8 +1567,7 @@ namespace demos {
|
||||
|
||||
if (this.isOver) {
|
||||
this.texture = this.textureButtonOver;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.texture = this.textureButton;
|
||||
}
|
||||
}
|
||||
@@ -1754,8 +1732,7 @@ namespace demos {
|
||||
|
||||
if (!this.container.mask) {
|
||||
this.container.mask = this.thing;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.container.mask = null;
|
||||
}
|
||||
}
|
||||
@@ -1927,9 +1904,8 @@ namespace demos {
|
||||
|
||||
private animate = (): void => {
|
||||
|
||||
for (var i = 0; i < this.items.length; i++) {
|
||||
for (const item of this.items) {
|
||||
// rotate each item
|
||||
var item = this.items[i];
|
||||
item.rotation += 0.1;
|
||||
}
|
||||
|
||||
@@ -2187,8 +2163,7 @@ namespace demos {
|
||||
|
||||
if (this.bol) {
|
||||
this.dude.texture = this.secondTexture;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.dude.texture = this.texture;
|
||||
}
|
||||
});
|
||||
@@ -2290,9 +2265,7 @@ namespace demos {
|
||||
private animate = (): void => {
|
||||
|
||||
// iterate through the dudes and update their position
|
||||
for (var i = 0; i < this.aliens.length; i++) {
|
||||
|
||||
var dude = this.aliens[i];
|
||||
for (const dude of this.aliens) {
|
||||
dude.direction += dude.turningSpeed * 0.01;
|
||||
dude.position.x += Math.sin(dude.direction) * dude.speed;
|
||||
dude.position.y += Math.cos(dude.direction) * dude.speed;
|
||||
@@ -2301,15 +2274,13 @@ namespace demos {
|
||||
// wrap the dudes by testing their bounds...
|
||||
if (dude.position.x < this.dudeBounds.x) {
|
||||
dude.position.x += this.dudeBounds.width;
|
||||
}
|
||||
else if (dude.position.x > this.dudeBounds.x + this.dudeBounds.width) {
|
||||
} else if (dude.position.x > this.dudeBounds.x + this.dudeBounds.width) {
|
||||
dude.position.x -= this.dudeBounds.width;
|
||||
}
|
||||
|
||||
if (dude.position.y < this.dudeBounds.y) {
|
||||
dude.position.y += this.dudeBounds.height;
|
||||
}
|
||||
else if (dude.position.y > this.dudeBounds.y + this.dudeBounds.height) {
|
||||
} else if (dude.position.y > this.dudeBounds.y + this.dudeBounds.height) {
|
||||
dude.position.y -= this.dudeBounds.height;
|
||||
}
|
||||
|
||||
@@ -2572,15 +2543,13 @@ namespace filters {
|
||||
this.ring.position.x = eventData.data.global.x - 25;
|
||||
this.ring.position.y = eventData.data.global.y;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
private animate = (): void => {
|
||||
|
||||
this.count += 0.05;
|
||||
|
||||
for (var i = 0; i < this.maggots.length; i++) {
|
||||
var maggot = this.maggots[i];
|
||||
|
||||
for (const maggot of this.maggots) {
|
||||
maggot.direction += maggot.turnSpeed * 0.01;
|
||||
maggot.position.x += Math.sin(maggot.direction) * maggot.speed;
|
||||
maggot.position.y += Math.cos(maggot.direction) * maggot.speed;
|
||||
@@ -2592,15 +2561,13 @@ namespace filters {
|
||||
// wrap the maggots around as the crawl
|
||||
if (maggot.position.x < this.bounds.x) {
|
||||
maggot.position.x += this.bounds.width;
|
||||
}
|
||||
else if (maggot.position.x > this.bounds.x + this.bounds.width) {
|
||||
} else if (maggot.position.x > this.bounds.x + this.bounds.width) {
|
||||
maggot.position.x -= this.bounds.width;
|
||||
}
|
||||
|
||||
if (maggot.position.y < this.bounds.y) {
|
||||
maggot.position.y += this.bounds.height;
|
||||
}
|
||||
else if (maggot.position.y > this.bounds.y + this.bounds.height) {
|
||||
} else if (maggot.position.y > this.bounds.y + this.bounds.height) {
|
||||
maggot.position.y -= this.bounds.height;
|
||||
}
|
||||
}
|
||||
@@ -2609,7 +2576,7 @@ namespace filters {
|
||||
|
||||
requestAnimationFrame(this.animate);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2724,8 +2691,7 @@ namespace filters {
|
||||
|
||||
if (!this.switchy) {
|
||||
this.stage.filters = [this.filter];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.stage.filters = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false,
|
||||
"interface-name": false,
|
||||
"no-empty-interface": false,
|
||||
"unified-signatures": false
|
||||
}
|
||||
}
|
||||
@@ -3,16 +3,16 @@ import PlugAPI = require("plugapi");
|
||||
new PlugAPI({
|
||||
email: "",
|
||||
password: ""
|
||||
}, function (err, bot) {
|
||||
}, (err, bot) => {
|
||||
if (!err) {
|
||||
const ROOM = "roomslug";
|
||||
bot.connect(ROOM); // The part after https://plug.dj
|
||||
|
||||
bot.on(PlugAPI.events.ROOM_JOIN, function (room) {
|
||||
bot.on(PlugAPI.events.ROOM_JOIN, room => {
|
||||
console.log("Joined " + room);
|
||||
});
|
||||
|
||||
bot.on("chat", function (data) {
|
||||
bot.on("chat", data => {
|
||||
if (data.type === "emote") {
|
||||
console.log(data.from + data.message);
|
||||
} else {
|
||||
@@ -20,7 +20,7 @@ new PlugAPI({
|
||||
}
|
||||
});
|
||||
|
||||
bot.on("error", function () {
|
||||
bot.on("error", () => {
|
||||
bot.connect(ROOM);
|
||||
});
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ function escapeRegexCharacters(str: string): string {
|
||||
|
||||
export class ReactAutosuggestBasicTest extends React.Component<any, any> {
|
||||
//region Fields
|
||||
public static languages: Language[] = [
|
||||
static languages: Language[] = [
|
||||
{name: 'C', year: 1972},
|
||||
{name: 'C#', year: 2000},
|
||||
{name: 'C++', year: 1983},
|
||||
@@ -47,7 +47,7 @@ export class ReactAutosuggestBasicTest extends React.Component<any, any> {
|
||||
//endregion
|
||||
|
||||
//region Rendering methods
|
||||
public render(): JSX.Element {
|
||||
render(): JSX.Element {
|
||||
const {value, suggestions} = this.state;
|
||||
const inputProps = {
|
||||
placeholder: `Type 'c'`,
|
||||
@@ -59,7 +59,7 @@ export class ReactAutosuggestBasicTest extends React.Component<any, any> {
|
||||
input: 'themed-input-class',
|
||||
container: 'themed-container-class',
|
||||
suggestionFocused: 'active'
|
||||
}
|
||||
};
|
||||
|
||||
return <Autosuggest suggestions={suggestions}
|
||||
onSuggestionsFetchRequested={this.onSuggestionsFetchRequested.bind(this)}
|
||||
@@ -123,7 +123,7 @@ interface LanguageGroup {
|
||||
|
||||
export class ReactAutosuggestMultipleTest extends React.Component<any, any> {
|
||||
//region Fields
|
||||
public static languages: LanguageGroup[] = [
|
||||
static languages: LanguageGroup[] = [
|
||||
{
|
||||
title: '1970s',
|
||||
languages: [
|
||||
@@ -178,7 +178,7 @@ export class ReactAutosuggestMultipleTest extends React.Component<any, any> {
|
||||
//endregion
|
||||
|
||||
//region Rendering methods
|
||||
public render(): JSX.Element {
|
||||
render(): JSX.Element {
|
||||
const { value, suggestions } = this.state;
|
||||
const inputProps = {
|
||||
placeholder: `Type 'c'`,
|
||||
@@ -258,7 +258,7 @@ export class ReactAutosuggestMultipleTest extends React.Component<any, any> {
|
||||
|
||||
ReactDOM.render(<ReactAutosuggestMultipleTest />, document.getElementById('app'));
|
||||
|
||||
interface IPerson {
|
||||
interface Person {
|
||||
first: string;
|
||||
last: string;
|
||||
twitter: string;
|
||||
@@ -266,7 +266,7 @@ interface IPerson {
|
||||
|
||||
export class ReactAutosuggestCustomTest extends React.Component<any, any> {
|
||||
//region Fields
|
||||
public static people: IPerson[] = [
|
||||
static people: Person[] = [
|
||||
{first: 'Charlie', last: 'Brown', twitter: 'dancounsell'},
|
||||
{first: 'Charlotte', last: 'White', twitter: 'mtnmissy'},
|
||||
{first: 'Chloe', last: 'Jones', twitter: 'ladylexy'},
|
||||
@@ -286,7 +286,7 @@ export class ReactAutosuggestCustomTest extends React.Component<any, any> {
|
||||
//endregion
|
||||
|
||||
//region Rendering methods
|
||||
public render(): JSX.Element {
|
||||
render(): JSX.Element {
|
||||
const { value, suggestions } = this.state;
|
||||
const inputProps = {
|
||||
placeholder: "Type 'c'",
|
||||
@@ -301,14 +301,14 @@ export class ReactAutosuggestCustomTest extends React.Component<any, any> {
|
||||
inputProps={inputProps} />;
|
||||
}
|
||||
|
||||
protected renderSuggestion(suggestion: IPerson, { value, valueBeforeUpDown }: any): JSX.Element {
|
||||
protected renderSuggestion(suggestion: Person, { value, valueBeforeUpDown }: any): JSX.Element {
|
||||
const suggestionText = `${suggestion.first} ${suggestion.last}`;
|
||||
const query = (valueBeforeUpDown || value).trim();
|
||||
const parts = suggestionText.split(' ').map((part: string) => {
|
||||
return {
|
||||
highlight: (Math.ceil(Math.random() * 10)) % 2,
|
||||
text: part
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
return <span className={'suggestion-content ' + suggestion.twitter}>
|
||||
@@ -340,7 +340,7 @@ export class ReactAutosuggestCustomTest extends React.Component<any, any> {
|
||||
//endregion
|
||||
|
||||
//region Helper methods
|
||||
protected getSuggestions(value: string): IPerson[] {
|
||||
protected getSuggestions(value: string): Person[] {
|
||||
const escapedValue = escapeRegexCharacters(value.trim());
|
||||
|
||||
if (escapedValue === '') {
|
||||
@@ -352,7 +352,7 @@ export class ReactAutosuggestCustomTest extends React.Component<any, any> {
|
||||
return ReactAutosuggestCustomTest.people.filter(person => regex.test(this.getSuggestionValue(person)));
|
||||
}
|
||||
|
||||
protected getSuggestionValue(suggestion: IPerson): string {
|
||||
protected getSuggestionValue(suggestion: Person): string {
|
||||
return `${suggestion.first} ${suggestion.last}`;
|
||||
}
|
||||
//endregion
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import * as React from "react"
|
||||
import { DropdownMenu } from "react-bootstrap"
|
||||
import * as DatePicker from "react-bootstrap-date-picker"
|
||||
import * as React from "react";
|
||||
import { DropdownMenu } from "react-bootstrap";
|
||||
import * as DatePicker from "react-bootstrap-date-picker";
|
||||
|
||||
const Custom: React.StatelessComponent<{}> = () => {
|
||||
return (<div />);
|
||||
}
|
||||
};
|
||||
|
||||
class Test extends React.Component<{}, {}> {
|
||||
|
||||
public render () {
|
||||
render() {
|
||||
return (
|
||||
<DatePicker autoFocus={ false }
|
||||
onChange={ (value: string, c: string) => {} }
|
||||
@@ -26,7 +25,6 @@ class Test extends React.Component<{}, {}> {
|
||||
showTodayButton={ true }
|
||||
todayButtonLabel="Today"
|
||||
customControl={ Custom } />
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@ import EventListener, { withOptions } from "react-event-listener";
|
||||
|
||||
<EventListener target={document} onBeforeUnload={ev => { }} />;
|
||||
<EventListener target={window} onResize={withOptions((ev: UIEvent) => { }, { passive: true, capture: true })} />;
|
||||
<EventListener target="window" onResize={() => { }}/>
|
||||
<EventListener target="window" onResize={() => { }}/>;
|
||||
|
||||
@@ -93,7 +93,7 @@ class MyComponent2 extends React.Component<any, any> {
|
||||
fields="name,email,picture"
|
||||
callback={responseFacebook}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as React from "react";
|
||||
import * as Gravatar from "react-gravatar";
|
||||
|
||||
class GravatarEmailTest extends React.Component<void, void> {
|
||||
public render() {
|
||||
render() {
|
||||
return (
|
||||
<Gravatar
|
||||
email="test@example.com"
|
||||
@@ -18,7 +18,7 @@ class GravatarEmailTest extends React.Component<void, void> {
|
||||
}
|
||||
|
||||
class GravatarHashTest extends React.Component<void, void> {
|
||||
public render() {
|
||||
render() {
|
||||
return (
|
||||
<Gravatar
|
||||
md5="55502f40dc8b7c769880b10874abc9d0"
|
||||
@@ -34,7 +34,7 @@ class GravatarHashTest extends React.Component<void, void> {
|
||||
}
|
||||
|
||||
class GravatarMinimalTest extends React.Component<void, void> {
|
||||
public render() {
|
||||
render() {
|
||||
return <Gravatar email="test@example.com" />;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
import React = require("react");
|
||||
import Highlighter = require("react-highlight-words");
|
||||
|
||||
|
||||
<Highlighter
|
||||
highlightClassName='YourHighlightClass'
|
||||
searchWords={['and', 'or', 'the']}
|
||||
textToHighlight="The dog is chasing the cat. Or perhaps they're just playing?"
|
||||
/>
|
||||
/>;
|
||||
|
||||
@@ -7,4 +7,4 @@ import * as React from 'react';
|
||||
<ReactInputMask mask="99-99-9999" defaultValue= "13-00-2017" />
|
||||
<ReactInputMask mask="99/99/9999" placeholder= "Enter birthdate" />
|
||||
<ReactInputMask mask="+7 (999) 999-99-99" />
|
||||
</div>
|
||||
</div>;
|
||||
|
||||
@@ -49,7 +49,7 @@ class NewComponent extends React.Component<undefined, undefined> {
|
||||
},
|
||||
name: "my-name",
|
||||
parent: "MyParent"
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ export class Test extends React.Component<any, any> {
|
||||
render() {
|
||||
const json = {
|
||||
foo: "bar"
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user