Merge branch 'master' of github.com:borisyankov/DefinitelyTyped

This commit is contained in:
vvakame
2015-08-18 00:00:57 +09:00
2 changed files with 655 additions and 0 deletions
+365
View File
@@ -0,0 +1,365 @@
/// <reference path="./ionic.d.ts" />
var testIonic = angular.module('testIonic', ['ionic']);
testIonic.config(['$ionicConfigProvider', ($ionicConfigProvider: ionic.utility.IonicConfigProvider)=>{
var transition: string = $ionicConfigProvider.views.transition();
$ionicConfigProvider.views.transition("transition");
var maxCache: number = $ionicConfigProvider.views.maxCache();
$ionicConfigProvider.views.maxCache(10);
var forwardCache: boolean = $ionicConfigProvider.views.forwardCache();
$ionicConfigProvider.views.forwardCache(true);
var jsScrolling: boolean = $ionicConfigProvider.scrolling.jsScrolling();
$ionicConfigProvider.scrolling.jsScrolling(true);
var backButtonIcon: string = $ionicConfigProvider.backButton.icon();
$ionicConfigProvider.backButton.icon("icon");
var backButtonText: string = $ionicConfigProvider.backButton.text();
$ionicConfigProvider.backButton.text("back");
var usePreviousTitleText: boolean = $ionicConfigProvider.backButton.previousTitleText();
$ionicConfigProvider.backButton.previousTitleText(false);
var checkbox: string = $ionicConfigProvider.form.checkbox();
$ionicConfigProvider.form.checkbox("square");
var toggle: string = $ionicConfigProvider.form.toggle();
$ionicConfigProvider.form.toggle("small");
var spinnerIcon: string = $ionicConfigProvider.spinner.icon();
$ionicConfigProvider.spinner.icon("spiral");
var tabsStyle: string = $ionicConfigProvider.tabs.style();
$ionicConfigProvider.tabs.style("standard");
var tabsPosition: string = $ionicConfigProvider.tabs.position();
$ionicConfigProvider.tabs.position("bottom");
var maxPrefetch: number = $ionicConfigProvider.templates.maxPrefetch();
$ionicConfigProvider.templates.maxPrefetch(10);
var alignTitle: string = $ionicConfigProvider.navBar.alignTitle();
$ionicConfigProvider.navBar.alignTitle("platform");
var positionPrimaryButtons: string = $ionicConfigProvider.navBar.positionPrimaryButtons();
$ionicConfigProvider.navBar.positionPrimaryButtons("platform");
var positionSecondaryButtons: string = $ionicConfigProvider.navBar.positionSecondaryButtons();
$ionicConfigProvider.navBar.positionSecondaryButtons("platform");
}])
class IonicTestController {
public static $inject = [
'$ionicActionSheet',
'$ionicBackdrop',
'$ionicGesture',
'$ionicListDelegate',
'$ionicLoading',
'$ionicModal',
'$ionicNavBarDelegate',
'$ionicHistory',
'$ionicPlatform',
'$ionicPopover',
'$ionicPopup',
'$ionicScrollDelegate',
'$ionicSideMenuDelegate',
'$ionicSlideBoxDelegate',
'$ionicTabsDelegate',
'$ionicPosition'
];
constructor(
private $ionicActionSheet: ionic.actionSheet.IonicActionSheetService,
private $ionicBackdrop: ionic.backdrop.IonicBackdropService,
private $ionicGesture: ionic.gestures.IonicGestureService,
private $ionicListDelegate: ionic.list.IonicListDelegate,
private $ionicLoading: ionic.loading.IonicLoadingService,
private $ionicModal: ionic.modal.IonicModalService,
private $ionicNavBarDelegate: ionic.navigation.IonicNavBarDelegate,
private $ionicHistory: ionic.navigation.IonicHistoryService,
private $ionicPlatform: ionic.platform.IonicPlatformService,
private $ionicPopover: ionic.popover.IonicPopoverService,
private $ionicPopup: ionic.popup.IonicPopupService,
private $ionicScrollDelegate: ionic.scroll.IonicScrollDelegate,
private $ionicSideMenuDelegate: ionic.sideMenu.IonicSideMenuDelegate,
private $ionicSlideBoxDelegate: ionic.slideBox.IonicSlideBoxDelegate,
private $ionicTabsDelegate: ionic.tabs.IonicTabsDelegate,
private $ionicPositionService: ionic.utility.IonicPositionService
){}
private testActionSheet(): void {
var closeActionSheetFn: ()=>void = this.$ionicActionSheet.show({
buttons: [],
titleText: "titleText",
cancelText: "cancelText",
destructiveText: "destructiveText",
cancel: ()=>{ console.log("cancel"); },
buttonClicked: ()=>{ console.log("buttonClicked"); },
destructiveButtonClicked: ()=>{ console.log("destructiveButtonClicked"); },
cancelOnStateChange: true,
cssClass: "cssClass"
});
closeActionSheetFn();
}
private testBackdrop(): void {
this.$ionicBackdrop.retain();
this.$ionicBackdrop.release();
}
private testGesture(): void {
var gesture: ionic.gestures.IonicGesture = this.$ionicGesture.on(
'eventType',
(e)=>{ return e; },
angular.element("body"),
{}
);
this.$ionicGesture.off(gesture, "eventType", (e) => { return e; });
}
private testList(): void {
this.$ionicListDelegate.showReorder(true);
var showReorder: boolean = this.$ionicListDelegate.showReorder();
this.$ionicListDelegate.showDelete(true);
var showDelete: boolean = this.$ionicListDelegate.showDelete();
this.$ionicListDelegate.canSwipeItems(true);
var canSwipeItems: boolean = this.$ionicListDelegate.canSwipeItems();
this.$ionicListDelegate.closeOptionButtons();
var foo: ionic.list.IonicListDelegate = this.$ionicListDelegate.$getByHandle("handle");
}
private testLoading(): void {
this.$ionicLoading.show({
template: "template",
templateUrl: "templateUrl",
scope: {},
noBackdrop: false,
hideOnStateChange: true,
delay: 500,
duration: 8000
});
this.$ionicLoading.hide();
}
private testModal(): void {
var modalOptions: ionic.modal.IonicModalOptions = {
scope: {},
animation: "animation",
focusFirstInput: true,
backdropClickToClose: false,
hardwareBackButtonClose: true
};
var ionicModalController: ionic.modal.IonicModalController = this.$ionicModal.fromTemplate("template", modalOptions);
ionicModalController.initialize(modalOptions);
ionicModalController.show().then(() => console.log("shown modal"))
ionicModalController.hide().then(() => console.log("hid modal"))
var isShown: boolean = ionicModalController.isShown();
this.$ionicModal.fromTemplateUrl("templateUrl", modalOptions)
.then(modalCtrl => ionicModalController = modalCtrl);
}
private testNavigation(): void {
this.$ionicNavBarDelegate.align("right");
this.$ionicNavBarDelegate.showBackButton(true);
var isBackButtonShown: boolean = this.$ionicNavBarDelegate.showBackButton();
this.$ionicNavBarDelegate.showBar(true);
var isBarShown: boolean = this.$ionicNavBarDelegate.showBar();
this.$ionicNavBarDelegate.title("title");
var viewHistory = this.$ionicHistory.viewHistory();
var currentView = this.$ionicHistory.currentView();
var currentHistoryId: string = this.$ionicHistory.currentHistoryId();
this.$ionicHistory.currentTitle("currentTitle");
var currentTitle: string = this.$ionicHistory.currentTitle();
var backView = this.$ionicHistory.backView();
var backTitle: string = this.$ionicHistory.backTitle();
var forwardView = this.$ionicHistory.forwardView();
var currentStateName: string = this.$ionicHistory.currentStateName();
this.$ionicHistory.goBack(5);
this.$ionicHistory.clearHistory();
this.$ionicHistory.clearCache().then(() => console.log("done clearing cache!"));
this.$ionicHistory.nextViewOptions({
disableAnimate: true,
disableBack: true,
historyRoot: true
});
}
private testPlatform(): void {
var callback: Function = () => console.log("on!");
this.$ionicPlatform.onHardwareBackButton(callback);
this.$ionicPlatform.offHardwareBackButton(callback);
this.$ionicPlatform.registerBackButtonAction(callback, 1, "actionId");
this.$ionicPlatform.on("type", callback);
this.$ionicPlatform.ready(callback);
this.$ionicPlatform.ready().then(() => console.log("ready!"));
}
private testPopover(): void {
var popoverOptions: ionic.popover.IonicPopoverOptions = {
scope: {},
focusFirstInput: true,
backdropClickToClose: false,
hardwareBackButtonClose: true
};
var ionicPopoverController: ionic.popover.IonicPopoverController = this.$ionicPopover.fromTemplate("template", popoverOptions);
ionicPopoverController.initialize(popoverOptions);
ionicPopoverController.show(angular.element("body")).then(() => console.log("shown popover"))
ionicPopoverController.hide().then(() => console.log("hid popover"))
var isShown: boolean = ionicPopoverController.isShown();
this.$ionicPopover.fromTemplateUrl("templateUrl", popoverOptions)
.then(popoverCtrl => ionicPopoverController = popoverCtrl);
}
private testPopup(): void {
this.$ionicPopup.show({
title: "title",
subTitle: "subTitle",
cssClass: "cssClass",
template: "template",
templateUrl: "templateUrl",
scope: {},
buttons: [{text: "text", type: "type", onTap: (e) => {console.log(e)}}]
}).then(() => console.log("popover shown"));
this.$ionicPopup.show({
title: "title",
subTitle: "subTitle",
cssClass: "cssClass",
template: "template",
templateUrl: "templateUrl",
scope: {},
buttons: [{text: "text", type: "type", onTap: (e) => {console.log(e)}}]
}).close("done");
this.$ionicPopup.alert({
title: "title",
subTitle: "subTitle",
cssClass: "cssClass",
template: "template",
templateUrl: "templateUrl",
okText: "OK",
okType: "okType"
}).then(() => console.log("popover shown"))
this.$ionicPopup.alert({
title: "title",
subTitle: "subTitle",
cssClass: "cssClass",
template: "template",
templateUrl: "templateUrl",
okText: "OK",
okType: "okType"
}).close();
this.$ionicPopup.confirm({
title: "title",
subTitle: "subTitle",
cssClass: "cssClass",
template: "template",
templateUrl: "templateUrl",
okText: "OK",
okType: "okType",
cancelText: "Cancel",
cancelType: "cancelType"
}).then(() => console.log("popover shown"))
this.$ionicPopup.confirm({
title: "title",
subTitle: "subTitle",
cssClass: "cssClass",
template: "template",
templateUrl: "templateUrl",
okText: "OK",
okType: "okType",
cancelText: "Cancel",
cancelType: "cancelType"
}).close();
this.$ionicPopup.prompt({
title: "title",
subTitle: "subTitle",
cssClass: "cssClass",
template: "template",
templateUrl: "templateUrl",
okText: "OK",
okType: "okType",
cancelText: "Cancel",
cancelType: "cancelType",
inputType: "text",
inputPlaceholder: "Type some text..."
}).then(() => console.log("popover shown"))
this.$ionicPopup.prompt({
title: "title",
subTitle: "subTitle",
cssClass: "cssClass",
template: "template",
templateUrl: "templateUrl",
okText: "OK",
okType: "okType",
cancelText: "Cancel",
cancelType: "cancelType",
inputType: "text",
inputPlaceholder: "Type some text..."
}).close();
}
private testScroll(): void {
this.$ionicScrollDelegate.resize();
this.$ionicScrollDelegate.scrollTop();
this.$ionicScrollDelegate.scrollTop(true);
this.$ionicScrollDelegate.scrollBottom();
this.$ionicScrollDelegate.scrollBottom(true);
this.$ionicScrollDelegate.scrollTo(0, 0);
this.$ionicScrollDelegate.scrollTo(0, 0, true);
this.$ionicScrollDelegate.scrollBy(0, 0);
this.$ionicScrollDelegate.scrollBy(0, 0, true);
this.$ionicScrollDelegate.zoomTo(1);
this.$ionicScrollDelegate.zoomTo(1, true);
this.$ionicScrollDelegate.zoomTo(1, true, 0);
this.$ionicScrollDelegate.zoomTo(1, true, 0, 0);
this.$ionicScrollDelegate.zoomBy(0.5);
this.$ionicScrollDelegate.zoomBy(0.5, true);
this.$ionicScrollDelegate.zoomBy(0.5, true, 50);
this.$ionicScrollDelegate.zoomBy(0.5, true, 50, 50);
var {top: number, left: number} = this.$ionicScrollDelegate.getScrollPosition();
this.$ionicScrollDelegate.anchorScroll();
this.$ionicScrollDelegate.anchorScroll(true);
var isScrollFrozen: boolean = this.$ionicScrollDelegate.freezeScroll();
this.$ionicScrollDelegate.freezeScroll(false);
var areAllScrollsFrozen: boolean = this.$ionicScrollDelegate.freezeAllScrolls();
this.$ionicScrollDelegate.freezeAllScrolls(false);
var scrollView: any = this.$ionicScrollDelegate.getScrollView();
var scrollDelegate: ionic.scroll.IonicScrollDelegate = this.$ionicScrollDelegate.$getByHandle("handle");
}
private testSideMenu(): void {
this.$ionicSideMenuDelegate.toggleLeft();
this.$ionicSideMenuDelegate.toggleLeft(true);
this.$ionicSideMenuDelegate.toggleRight();
this.$ionicSideMenuDelegate.toggleRight(true);
var openRatio: number = this.$ionicSideMenuDelegate.getOpenRatio();
var isOpen: boolean = this.$ionicSideMenuDelegate.isOpen();
var isOpenLeft: boolean = this.$ionicSideMenuDelegate.isOpenLeft();
var isOpenRight: boolean = this.$ionicSideMenuDelegate.isOpenRight();
var canDragContent: boolean = this.$ionicSideMenuDelegate.canDragContent();
this.$ionicSideMenuDelegate.canDragContent(false);
var edgeDragThreshold: boolean = this.$ionicSideMenuDelegate.edgeDragThreshold();
this.$ionicSideMenuDelegate.edgeDragThreshold(true);
this.$ionicSideMenuDelegate.edgeDragThreshold(500);
var sideMenuDelegate: ionic.sideMenu.IonicSideMenuDelegate = this.$ionicSideMenuDelegate.$getByHandle("handle");
}
private testSlideBox(): void {
this.$ionicSlideBoxDelegate.update();
this.$ionicSlideBoxDelegate.slide(1);
this.$ionicSlideBoxDelegate.slide(1, 500);
var isSlideEnabled: boolean = this.$ionicSlideBoxDelegate.enableSlide();
this.$ionicSlideBoxDelegate.enableSlide(true);
this.$ionicSlideBoxDelegate.previous();
this.$ionicSlideBoxDelegate.previous(500);
this.$ionicSlideBoxDelegate.next();
this.$ionicSlideBoxDelegate.next(500);
this.$ionicSlideBoxDelegate.stop();
this.$ionicSlideBoxDelegate.start();
var currentIndex: number = this.$ionicSlideBoxDelegate.currentIndex();
var slidesCount: number = this.$ionicSlideBoxDelegate.slidesCount();
var slideBoxDelegate: ionic.slideBox.IonicSlideBoxDelegate = this.$ionicSlideBoxDelegate.$getByHandle("handle");
}
private testTabs(): void {
this.$ionicTabsDelegate.select(1);
var selectedIndex: number = this.$ionicTabsDelegate.selectedIndex();
var ionicTabsDelegate: ionic.tabs.IonicTabsDelegate = this.$ionicTabsDelegate.$getByHandle("handle");
}
private testUtility(): void {
var {top: number, left: number, width: number, height: number} = this.$ionicPositionService.position(angular.element("body"));
var {top: number, left: number, width: number, height: number} = this.$ionicPositionService.offset(angular.element("body"));
}
}
testIonic.controller('ionicTestController', IonicTestController);
+290
View File
@@ -0,0 +1,290 @@
// Type definitions for Ionic
// Project: http://ionicframework.com
// Definitions by: Spencer Williams <https://github.com/spencerwi/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare module ionic {
module actionSheet {
interface IonicActionSheetService {
show(options: IonicActionSheetOptions): ()=>void;
}
interface IonicActionSheetOptions {
buttons?: Array<any>;
titleText?: string;
cancelText?: string;
destructiveText?: string;
cancel?: ()=>any;
buttonClicked?: ()=>any;
destructiveButtonClicked?: ()=>any;
cancelOnStateChange?: boolean;
cssClass?: string;
}
}
module backdrop {
interface IonicBackdropService {
retain(): void;
release(): void;
}
}
module gestures {
interface IonicGestureService {
on(eventType: string, callback: (e: any)=>any, $element: ng.IAugmentedJQuery, options: any): IonicGesture;
off(gesture: IonicGesture, eventType: string, callback: (e: any)=>any): void;
}
interface IonicGesture {
element: Element;
enabled: boolean;
options: {stop_browser_behavior: string };
on(gesture: string, handler: Function): IonicGesture;
off(gesture: string, handler: Function): IonicGesture;
trigger(gesture: string, eventData: any): IonicGesture;
enable(state: boolean): IonicGesture;
}
}
module list {
interface IonicListDelegate {
showReorder(showReorder?: boolean): boolean;
showDelete(showDelete?: boolean): boolean;
canSwipeItems(canSwipeItems?: boolean): boolean;
closeOptionButtons(): void;
$getByHandle(handle: string): IonicListDelegate;
}
}
module loading {
interface IonicLoadingService {
show(opts: IonicLoadingOptions): void;
hide(): void;
}
interface IonicLoadingOptions {
template?: string;
templateUrl?: string;
scope?: any;
noBackdrop?: boolean;
hideOnStateChange?: boolean;
delay?: number;
duration?: number;
}
}
module modal {
interface IonicModalService {
fromTemplate(templateString: string, options?: IonicModalOptions): IonicModalController;
fromTemplateUrl(templateUrl: string, options?: IonicModalOptions): ng.IPromise<IonicModalController>;
}
interface IonicModalController {
initialize(options: IonicModalOptions): void;
show(): ng.IPromise<void>;
hide(): ng.IPromise<void>;
isShown(): boolean;
}
interface IonicModalOptions {
scope?: any;
animation?: string;
focusFirstInput?: boolean;
backdropClickToClose?: boolean;
hardwareBackButtonClose?: boolean;
}
}
module navigation {
interface IonicNavBarDelegate {
align(direction?: string): void;
showBackButton(show?: boolean): boolean;
showBar(show?: boolean): boolean;
title(title: string): void;
}
interface IonicHistoryService {
viewHistory(): any;
currentView(): any;
currentHistoryId(): string;
currentTitle(val?: string): string;
backView(): any;
backTitle(): string;
forwardView(): any;
currentStateName(): string;
goBack(backCount?: number): void;
clearHistory(): void;
clearCache(): ng.IPromise<any>;
nextViewOptions(options: IonicHistoryNextViewOptions): void;
}
interface IonicHistoryNextViewOptions {
disableAnimate?: boolean;
disableBack?: boolean;
historyRoot?: boolean;
}
}
module platform {
interface IonicPlatformService {
onHardwareBackButton(callback: Function): void;
offHardwareBackButton(callback: Function): void;
registerBackButtonAction(callback: Function, priority: number, actionId?: any): Function;
on(type: string, callback: Function): Function;
ready(callback?: Function): ng.IPromise<any>;
}
}
module popover {
interface IonicPopoverService {
fromTemplate(templateString: string, options: IonicPopoverOptions): IonicPopoverController;
fromTemplateUrl(templateUrl: string, options: IonicPopoverOptions): ng.IPromise<IonicPopoverController>;
}
interface IonicPopoverController {
initialize(options: IonicPopoverOptions): void;
show($event?: any): ng.IPromise<any>;
hide(): ng.IPromise<any>;
isShown(): boolean;
}
interface IonicPopoverOptions {
scope?: any;
focusFirstInput?: boolean;
backdropClickToClose?: boolean;
hardwareBackButtonClose?: boolean;
}
}
module popup {
interface IonicPopupService {
show(options: IonicPopupFullOptions): IonicPopupPromise;
alert(options: IonicPopupAlertOptions): IonicPopupPromise;
confirm(options: IonicPopupConfirmOptions): IonicPopupPromise;
prompt(options: IonicPopupPromptOptions): IonicPopupPromise;
}
interface IonicPopupPromise extends ng.IPromise<any> {
close(value?: any): any;
}
interface IonicPopupBaseOptions {
title?: string;
cssClass?: string;
subTitle?: string;
template?: string;
templateUrl?: string;
}
interface IonicPopupFullOptions extends IonicPopupBaseOptions {
scope?: any;
buttons?: Array<IonicPopupButton>;
}
interface IonicPopupButton {
text: string;
type?: string;
onTap?(event?: any): void;
}
interface IonicPopupAlertOptions extends IonicPopupBaseOptions {
okText?: string;
okType?: string;
}
interface IonicPopupConfirmOptions extends IonicPopupBaseOptions {
cancelText?: string;
cancelType?: string;
okText?: string;
okType?: string;
}
interface IonicPopupPromptOptions extends IonicPopupBaseOptions {
inputType?: string;
inputPlaceholder?: string;
cancelText?: string;
cancelType?: string;
okText?: string;
okType?: string;
}
}
module scroll {
interface IonicScrollDelegate {
resize(): void;
scrollTop(shouldAnimate?: boolean): void;
scrollBottom(shouldAnimate?: boolean): void;
scrollTo(left: number, top: number, shouldAnimate?: boolean): void;
scrollBy(left: number, top: number, shouldAnimate?: boolean): void;
zoomTo(level: number, animate?: boolean, originLeft?: number, originTop?: number): void;
zoomBy(factor: number, animate?: boolean, originLeft?: number, originTop?: number): void;
getScrollPosition(): {left: number, top: number};
anchorScroll(shouldAnimate?: boolean): void;
freezeScroll(shouldFreeze?: boolean): boolean;
freezeAllScrolls(shouldFreeze?: boolean): boolean;
getScrollView(): any;
$getByHandle(handle: string): IonicScrollDelegate;
}
}
module sideMenu {
interface IonicSideMenuDelegate {
toggleLeft(isOpen?: boolean): void;
toggleRight(isOpen?: boolean): void;
getOpenRatio(): number;
isOpen(): boolean;
isOpenLeft(): boolean;
isOpenRight(): boolean;
canDragContent(canDrag?: boolean): boolean;
edgeDragThreshold(value?: boolean|number): boolean;
$getByHandle(handle: string): IonicSideMenuDelegate;
}
}
module slideBox {
interface IonicSlideBoxDelegate {
update(): void;
slide(to: number, speed?: number): void;
enableSlide(shouldEnable?: boolean): boolean;
previous(speed?: number): void;
next(speed?: number): void;
stop(): void;
start(): void;
currentIndex(): number;
slidesCount(): number;
$getByHandle(handle: string): IonicSlideBoxDelegate;
}
}
module tabs {
interface IonicTabsDelegate {
select(index: number): void;
selectedIndex(): number;
$getByHandle(handle: string): IonicTabsDelegate;
}
}
module utility {
interface IonicConfigProvider {
views: {
transition(transition?: string): string;
maxCache(maxNumber?: number): number;
forwardCache(value?: boolean): boolean;
};
scrolling: {
jsScrolling(value?: boolean): boolean;
};
backButton: {
icon(value?: string): string;
text(value?: string): string;
previousTitleText(value?: boolean): boolean;
};
form: {
checkbox(value?: string): string;
toggle(value?: string): string;
};
spinner: {
icon(value?: string): string;
};
tabs: {
style(value?: string): string;
position(value?: string): string;
};
templates: {
maxPrefetch(value?: number): number;
};
navBar: {
alignTitle(value?: string): string;
positionPrimaryButtons(value?: string): string;
positionSecondaryButtons(value?: string): string;
};
}
interface IonicPositionService {
position(element: any): {top: number; left: number; width: number; height: number};
offset(element: any): {top: number; left: number; width: number; height: number};
}
}
}