created typings for angular-media-queries module

This commit is contained in:
jpmnteiro
2016-03-29 13:20:38 +01:00
parent 4bd9b47f0e
commit 8527f0915c
2 changed files with 82 additions and 0 deletions
@@ -0,0 +1,55 @@
/// <reference path="match-media.d.ts" />
var myApp = angular.module('testModule', ['matchMedia']);
myApp.controller('TestController', ($log: angular.ILogService,
$scope: angular.IScope,
screenSize: angular.matchmedia.IScreenSize) => {
var fnCallback = (result: boolean) => {
$log.info(`Result: ${result}`);
}
// '.is(...)' examples
var res = screenSize.is(["xs", "sm"]);
fnCallback(res);
res = screenSize.is("xs, lg")
fnCallback(res);
// '.on(...)' examples
res = screenSize.on(["xs", "sm"], fnCallback);
fnCallback(res);
res = screenSize.on("xs, lg", fnCallback);
fnCallback(res);
res = screenSize.on(["xs", "sm"], fnCallback, $scope);
fnCallback(res);
res = screenSize.on("xs, lg", fnCallback, $scope);
fnCallback(res);
// '.onChange(...)' examples
res = screenSize.onChange($scope, ["xs", "sm"], fnCallback);
fnCallback(res);
res = screenSize.onChange($scope, "xs, lg", fnCallback);
fnCallback(res);
// '.when(...)' examples
res = screenSize.when(["xs", "sm"], fnCallback);
fnCallback(res);
res = screenSize.when("xs, lg", fnCallback);
fnCallback(res);
res = screenSize.when(["xs", "sm"], fnCallback, $scope);
fnCallback(res);
res = screenSize.when("xs, lg", fnCallback, $scope);
fnCallback(res);
});
+27
View File
@@ -0,0 +1,27 @@
// Type definitions for Angular matchMedia 0.6.0 (angular.matchMedia module)
// Project: https://github.com/jacopotarantino/angular-match-media
// Definitions by: Joao Monteiro <https://github.com/jpmnteiro>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare namespace angular.matchmedia {
interface IScreenSize {
is(list: Array<string> | string): boolean;
// Executes the callback function on window resize with the match truthiness as the first argument.
// Returns the current match truthiness.
// The 'scope' parameter is optional. If it's not passed in, '$rootScope' is used.
on(list: Array<string> | string, callback: (result: boolean) => void, scope?: angular.IScope): boolean;
// Executes the callback function ONLY when the match differs from previous match.
// Returns the current match truthiness.
// The 'scope' parameter is required for cleanup reasons (destroy event).
onChange(scope: angular.IScope, list: Array<string> | string, callback: (result: boolean) => void): boolean;
// Executes the callback only when inside of the particular screensize.
// The 'scope' parameter is optional. If it's not passed in, '$rootScope' is used.
when(list: Array<string> | string, callback: (result: boolean) => void, scope?: angular.IScope): boolean;
}
}