mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
add types for angular-block-ui
This commit is contained in:
41
types/angular-block-ui/angular-block-ui-tests.ts
Normal file
41
types/angular-block-ui/angular-block-ui-tests.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
var app: angular.IModule = angular.module('at', ['blockUI']);
|
||||
|
||||
app.config((blockUIConfig: angular.blockUI.IBlockUIConfig) => {
|
||||
blockUIConfig.message = 'Please stop clicking!';
|
||||
blockUIConfig.delay = 100;
|
||||
blockUIConfig.template = '<pre><code>{{ state | json }}</code></pre>';
|
||||
blockUIConfig.templateUrl = 'my-templates/block-ui-overlay.html';
|
||||
blockUIConfig.autoBlock = false;
|
||||
blockUIConfig.resetOnException = false;
|
||||
blockUIConfig.autoInjectBodyBlock = false;
|
||||
blockUIConfig.cssClass = 'block-ui my-custom-class';
|
||||
blockUIConfig.blockBrowserNavigation = true;
|
||||
|
||||
blockUIConfig.requestFilter = function (config) {
|
||||
if (config.url.match(/^\/api\/quote($|\/).*/)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
blockUIConfig.requestFilter = function (config) {
|
||||
if (config.url.match(/^\/api\/quote($|\/).*/)) {
|
||||
return 'Hello World';
|
||||
}
|
||||
return 'Loading...';
|
||||
};
|
||||
});
|
||||
|
||||
app.controller('Ctrl', ($scope: ng.IScope, blockUI: angular.blockUI.IBlockUIService) => {
|
||||
blockUI.start();
|
||||
blockUI.start('Hello');
|
||||
blockUI.start({});
|
||||
blockUI.start({message: 'World'});
|
||||
blockUI.start({delay: 100});
|
||||
|
||||
blockUI.stop();
|
||||
blockUI.reset();
|
||||
blockUI.message("Hello Types");
|
||||
blockUI.done();
|
||||
let b: boolean = blockUI.isBlocking();
|
||||
});
|
||||
171
types/angular-block-ui/index.d.ts
vendored
Normal file
171
types/angular-block-ui/index.d.ts
vendored
Normal file
@@ -0,0 +1,171 @@
|
||||
// Type definitions for angular-block-ui v0.2.2
|
||||
// Project: https://github.com/McNull/angular-block-ui
|
||||
// Definitions by: Lasse Nørregaard <https://github.com/lassebn>, Stephan Classen <https://github.com/sclassen>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="angular" />
|
||||
|
||||
import * as angular from 'angular';
|
||||
|
||||
declare module 'angular' {
|
||||
export namespace blockUI {
|
||||
|
||||
interface IBlockUIConfig {
|
||||
/**
|
||||
* Changes the default message to be used when no message
|
||||
* has been provided to the start method of the service.
|
||||
*
|
||||
* Default value is 'Loading ...'.
|
||||
*/
|
||||
message?: string;
|
||||
|
||||
/**
|
||||
* Specifies the amount in milliseconds before the block
|
||||
* is visible to the user. By delaying a visible block your
|
||||
* application will appear more responsive.
|
||||
*
|
||||
* The default value is 250.
|
||||
*/
|
||||
delay?: number;
|
||||
|
||||
/**
|
||||
* Specifies a custom template to use as the overlay.
|
||||
*/
|
||||
template?: string;
|
||||
|
||||
/**
|
||||
* Specifies a url to retrieve the template from.
|
||||
* The current release only works with pre-cached templates,
|
||||
* which means that this url should be known in the
|
||||
* $templateCache service of Angular.
|
||||
*
|
||||
* If you're using the grunt with html2js or angular-templates,
|
||||
* which I highly recommend, you're already set.
|
||||
*/
|
||||
templateUrl?: string;
|
||||
|
||||
/**
|
||||
* By default the BlockUI module will start a block whenever
|
||||
* the Angular $http service has an pending request.
|
||||
*
|
||||
* If you don't want this behaviour and want to do all the
|
||||
* blocking manually you can change this value to false.
|
||||
*/
|
||||
autoBlock?: boolean;
|
||||
|
||||
/**
|
||||
* By default the BlockUI module will reset the block count and
|
||||
* hide the overlay whenever an exception has occurred.
|
||||
*
|
||||
* You can set this value to false if you don't want this behaviour.
|
||||
*/
|
||||
resetOnException?: boolean;
|
||||
|
||||
/**
|
||||
* Allows you to specify a filter function to exclude certain ajax
|
||||
* requests from blocking the user interface.
|
||||
* The blockUI service will ignore requests when the function returns `false`.
|
||||
*
|
||||
* If the filter function returns a string it will be passed as the message
|
||||
* argument to the start method of the service.
|
||||
*
|
||||
* @param {angular.IRequestConfig} config - the Angular request config object.
|
||||
*
|
||||
*/
|
||||
requestFilter?: (config: angular.IRequestConfig) => (string | boolean);
|
||||
|
||||
/**
|
||||
* When the module is started it will inject the main block element
|
||||
* by adding the block-ui directive to the body element.
|
||||
*/
|
||||
autoInjectBodyBlock?: boolean;
|
||||
|
||||
/**
|
||||
* A string containing the default css classes, separated by spaces,
|
||||
* that should be applied to each block-ui element.
|
||||
*
|
||||
* The default value is `block-ui block-ui-anim-fade`
|
||||
*/
|
||||
cssClass?: string;
|
||||
|
||||
/**
|
||||
* Whenever a user interface block is active, because the single page
|
||||
* application is still waiting for a response from the backend server,
|
||||
* the user can still navigate away using the back and forward buttons
|
||||
* of the browser.
|
||||
*
|
||||
* Callbacks registered to handle the responses from the server will
|
||||
* be executed even if a different view/controller is currently active.
|
||||
* By setting the blockBrowserNavigation property to true the
|
||||
* angular-block-ui module will prevent navigation while a fullscreen
|
||||
* block is active.
|
||||
*
|
||||
* Programatic location changes via the $location service are still
|
||||
* allowed however.
|
||||
* The navigation block is disabled by default.
|
||||
*/
|
||||
blockBrowserNavigation?: boolean;
|
||||
}
|
||||
|
||||
interface IBlockUIService {
|
||||
/**
|
||||
* The start method will start the user interface block.
|
||||
* Because multiple user interface elements can request
|
||||
* a user interface block at the same time, the service
|
||||
* keeps track of the number of start calls.
|
||||
*
|
||||
* Each call to start() will increase the count and every
|
||||
* call to stop() will decrease the value.
|
||||
* Whenever the count reaches 0 the block will end.
|
||||
*
|
||||
* Note: By default the block is immediately active after
|
||||
* calling this method, but to prevent trashing the user
|
||||
* interface each time a button is pressed, the block is
|
||||
* visible after a short delay.
|
||||
*
|
||||
* This behaviour can be modified in the configuration.
|
||||
*
|
||||
* @param {string|IBlockUIConfig} messageOrOptions -
|
||||
* Either supply the message (string) to be show in the
|
||||
* overlay or specify an IBlockUIConfig object that will be
|
||||
* merged/extended into the block ui instance state.
|
||||
* If no argument is specified the default text message
|
||||
* from the configuration is used.
|
||||
*/
|
||||
start: (messageOrOptions?: (string | IBlockUIConfig)) => void;
|
||||
|
||||
/**
|
||||
* This will decrease the block count.
|
||||
*
|
||||
* The block will end if the count is 0.
|
||||
*/
|
||||
stop: () => void;
|
||||
|
||||
/**
|
||||
* The reset will force an unblock by setting the block count to 0.
|
||||
*/
|
||||
reset: () => void;
|
||||
|
||||
/**
|
||||
* Queues a callback function to be called when the block has finished.
|
||||
*
|
||||
* This can be useful whenever you wish to redirect the user
|
||||
* to a different location while there are still pending AJAX requests.
|
||||
*/
|
||||
done: () => void;
|
||||
|
||||
/**
|
||||
* Allows the message shown in the overlay to be updated
|
||||
* while to block is active.
|
||||
*
|
||||
* @param {string} message - The message to show in the overlay.
|
||||
*/
|
||||
message: (message: string) => void;
|
||||
|
||||
/**
|
||||
* Returns whether currently a block is shown for the instance or not.
|
||||
*/
|
||||
isBlocking: () => boolean;
|
||||
}
|
||||
}
|
||||
}
|
||||
23
types/angular-block-ui/tsconfig.json
Normal file
23
types/angular-block-ui/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"angular-block-ui-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/angular-block-ui/tslint.json
Normal file
1
types/angular-block-ui/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user