|
| 1 | +/// <reference path="./ionic.d.ts" /> |
| 2 | + |
| 3 | +var testIonic = angular.module('testIonic', ['ionic']); |
| 4 | + |
| 5 | +testIonic.config(['$ionicConfigProvider', ($ionicConfigProvider: ionic.utility.IonicConfigProvider)=>{ |
| 6 | + var transition: string = $ionicConfigProvider.views.transition(); |
| 7 | + $ionicConfigProvider.views.transition("transition"); |
| 8 | + var maxCache: number = $ionicConfigProvider.views.maxCache(); |
| 9 | + $ionicConfigProvider.views.maxCache(10); |
| 10 | + var forwardCache: boolean = $ionicConfigProvider.views.forwardCache(); |
| 11 | + $ionicConfigProvider.views.forwardCache(true); |
| 12 | + |
| 13 | + var jsScrolling: boolean = $ionicConfigProvider.scrolling.jsScrolling(); |
| 14 | + $ionicConfigProvider.scrolling.jsScrolling(true); |
| 15 | + |
| 16 | + var backButtonIcon: string = $ionicConfigProvider.backButton.icon(); |
| 17 | + $ionicConfigProvider.backButton.icon("icon"); |
| 18 | + var backButtonText: string = $ionicConfigProvider.backButton.text(); |
| 19 | + $ionicConfigProvider.backButton.text("back"); |
| 20 | + var usePreviousTitleText: boolean = $ionicConfigProvider.backButton.previousTitleText(); |
| 21 | + $ionicConfigProvider.backButton.previousTitleText(false); |
| 22 | + |
| 23 | + var checkbox: string = $ionicConfigProvider.form.checkbox(); |
| 24 | + $ionicConfigProvider.form.checkbox("square"); |
| 25 | + var toggle: string = $ionicConfigProvider.form.toggle(); |
| 26 | + $ionicConfigProvider.form.toggle("small"); |
| 27 | + |
| 28 | + var spinnerIcon: string = $ionicConfigProvider.spinner.icon(); |
| 29 | + $ionicConfigProvider.spinner.icon("spiral"); |
| 30 | + |
| 31 | + var tabsStyle: string = $ionicConfigProvider.tabs.style(); |
| 32 | + $ionicConfigProvider.tabs.style("standard"); |
| 33 | + var tabsPosition: string = $ionicConfigProvider.tabs.position(); |
| 34 | + $ionicConfigProvider.tabs.position("bottom"); |
| 35 | + |
| 36 | + var maxPrefetch: number = $ionicConfigProvider.templates.maxPrefetch(); |
| 37 | + $ionicConfigProvider.templates.maxPrefetch(10); |
| 38 | + |
| 39 | + var alignTitle: string = $ionicConfigProvider.navBar.alignTitle(); |
| 40 | + $ionicConfigProvider.navBar.alignTitle("platform"); |
| 41 | + var positionPrimaryButtons: string = $ionicConfigProvider.navBar.positionPrimaryButtons(); |
| 42 | + $ionicConfigProvider.navBar.positionPrimaryButtons("platform"); |
| 43 | + var positionSecondaryButtons: string = $ionicConfigProvider.navBar.positionSecondaryButtons(); |
| 44 | + $ionicConfigProvider.navBar.positionSecondaryButtons("platform"); |
| 45 | +}]) |
| 46 | + |
| 47 | +class IonicTestController { |
| 48 | + public static $inject = [ |
| 49 | + '$ionicActionSheet', |
| 50 | + '$ionicBackdrop', |
| 51 | + '$ionicGesture', |
| 52 | + '$ionicListDelegate', |
| 53 | + '$ionicLoading', |
| 54 | + '$ionicModal', |
| 55 | + '$ionicNavBarDelegate', |
| 56 | + '$ionicHistory', |
| 57 | + '$ionicPlatform', |
| 58 | + '$ionicPopover', |
| 59 | + '$ionicPopup', |
| 60 | + '$ionicScrollDelegate', |
| 61 | + '$ionicSideMenuDelegate', |
| 62 | + '$ionicSlideBoxDelegate', |
| 63 | + '$ionicTabsDelegate', |
| 64 | + '$ionicPosition' |
| 65 | + ]; |
| 66 | + constructor( |
| 67 | + private $ionicActionSheet: ionic.actionSheet.IonicActionSheetService, |
| 68 | + private $ionicBackdrop: ionic.backdrop.IonicBackdropService, |
| 69 | + private $ionicGesture: ionic.gestures.IonicGestureService, |
| 70 | + private $ionicListDelegate: ionic.list.IonicListDelegate, |
| 71 | + private $ionicLoading: ionic.loading.IonicLoadingService, |
| 72 | + private $ionicModal: ionic.modal.IonicModalService, |
| 73 | + private $ionicNavBarDelegate: ionic.navigation.IonicNavBarDelegate, |
| 74 | + private $ionicHistory: ionic.navigation.IonicHistoryService, |
| 75 | + private $ionicPlatform: ionic.platform.IonicPlatformService, |
| 76 | + private $ionicPopover: ionic.popover.IonicPopoverService, |
| 77 | + private $ionicPopup: ionic.popup.IonicPopupService, |
| 78 | + private $ionicScrollDelegate: ionic.scroll.IonicScrollDelegate, |
| 79 | + private $ionicSideMenuDelegate: ionic.sideMenu.IonicSideMenuDelegate, |
| 80 | + private $ionicSlideBoxDelegate: ionic.slideBox.IonicSlideBoxDelegate, |
| 81 | + private $ionicTabsDelegate: ionic.tabs.IonicTabsDelegate, |
| 82 | + private $ionicPositionService: ionic.utility.IonicPositionService |
| 83 | + ){} |
| 84 | + |
| 85 | + private testActionSheet(): void { |
| 86 | + var closeActionSheetFn: ()=>void = this.$ionicActionSheet.show({ |
| 87 | + buttons: [], |
| 88 | + titleText: "titleText", |
| 89 | + cancelText: "cancelText", |
| 90 | + destructiveText: "destructiveText", |
| 91 | + cancel: ()=>{ console.log("cancel"); }, |
| 92 | + buttonClicked: ()=>{ console.log("buttonClicked"); }, |
| 93 | + destructiveButtonClicked: ()=>{ console.log("destructiveButtonClicked"); }, |
| 94 | + cancelOnStateChange: true, |
| 95 | + cssClass: "cssClass" |
| 96 | + }); |
| 97 | + closeActionSheetFn(); |
| 98 | + } |
| 99 | + private testBackdrop(): void { |
| 100 | + this.$ionicBackdrop.retain(); |
| 101 | + this.$ionicBackdrop.release(); |
| 102 | + } |
| 103 | + private testGesture(): void { |
| 104 | + var gesture: ionic.gestures.IonicGesture = this.$ionicGesture.on( |
| 105 | + 'eventType', |
| 106 | + (e)=>{ return e; }, |
| 107 | + angular.element("body"), |
| 108 | + {} |
| 109 | + ); |
| 110 | + this.$ionicGesture.off(gesture, "eventType", (e) => { return e; }); |
| 111 | + } |
| 112 | + private testList(): void { |
| 113 | + this.$ionicListDelegate.showReorder(true); |
| 114 | + var showReorder: boolean = this.$ionicListDelegate.showReorder(); |
| 115 | + this.$ionicListDelegate.showDelete(true); |
| 116 | + var showDelete: boolean = this.$ionicListDelegate.showDelete(); |
| 117 | + this.$ionicListDelegate.canSwipeItems(true); |
| 118 | + var canSwipeItems: boolean = this.$ionicListDelegate.canSwipeItems(); |
| 119 | + this.$ionicListDelegate.closeOptionButtons(); |
| 120 | + var foo: ionic.list.IonicListDelegate = this.$ionicListDelegate.$getByHandle("handle"); |
| 121 | + } |
| 122 | + private testLoading(): void { |
| 123 | + this.$ionicLoading.show({ |
| 124 | + template: "template", |
| 125 | + templateUrl: "templateUrl", |
| 126 | + scope: {}, |
| 127 | + noBackdrop: false, |
| 128 | + hideOnStateChange: true, |
| 129 | + delay: 500, |
| 130 | + duration: 8000 |
| 131 | + }); |
| 132 | + this.$ionicLoading.hide(); |
| 133 | + } |
| 134 | + private testModal(): void { |
| 135 | + var modalOptions: ionic.modal.IonicModalOptions = { |
| 136 | + scope: {}, |
| 137 | + animation: "animation", |
| 138 | + focusFirstInput: true, |
| 139 | + backdropClickToClose: false, |
| 140 | + hardwareBackButtonClose: true |
| 141 | + }; |
| 142 | + var ionicModalController: ionic.modal.IonicModalController = this.$ionicModal.fromTemplate("template", modalOptions); |
| 143 | + ionicModalController.initialize(modalOptions); |
| 144 | + ionicModalController.show().then(() => console.log("shown modal")) |
| 145 | + ionicModalController.hide().then(() => console.log("hid modal")) |
| 146 | + var isShown: boolean = ionicModalController.isShown(); |
| 147 | + |
| 148 | + this.$ionicModal.fromTemplateUrl("templateUrl", modalOptions) |
| 149 | + .then(modalCtrl => ionicModalController = modalCtrl); |
| 150 | + } |
| 151 | + private testNavigation(): void { |
| 152 | + this.$ionicNavBarDelegate.align("right"); |
| 153 | + this.$ionicNavBarDelegate.showBackButton(true); |
| 154 | + var isBackButtonShown: boolean = this.$ionicNavBarDelegate.showBackButton(); |
| 155 | + this.$ionicNavBarDelegate.showBar(true); |
| 156 | + var isBarShown: boolean = this.$ionicNavBarDelegate.showBar(); |
| 157 | + this.$ionicNavBarDelegate.title("title"); |
| 158 | + |
| 159 | + var viewHistory = this.$ionicHistory.viewHistory(); |
| 160 | + var currentView = this.$ionicHistory.currentView(); |
| 161 | + var currentHistoryId: string = this.$ionicHistory.currentHistoryId(); |
| 162 | + this.$ionicHistory.currentTitle("currentTitle"); |
| 163 | + var currentTitle: string = this.$ionicHistory.currentTitle(); |
| 164 | + var backView = this.$ionicHistory.backView(); |
| 165 | + var backTitle: string = this.$ionicHistory.backTitle(); |
| 166 | + var forwardView = this.$ionicHistory.forwardView(); |
| 167 | + var currentStateName: string = this.$ionicHistory.currentStateName(); |
| 168 | + |
| 169 | + this.$ionicHistory.goBack(5); |
| 170 | + this.$ionicHistory.clearHistory(); |
| 171 | + this.$ionicHistory.clearCache().then(() => console.log("done clearing cache!")); |
| 172 | + this.$ionicHistory.nextViewOptions({ |
| 173 | + disableAnimate: true, |
| 174 | + disableBack: true, |
| 175 | + historyRoot: true |
| 176 | + }); |
| 177 | + } |
| 178 | + private testPlatform(): void { |
| 179 | + var callback: Function = () => console.log("on!"); |
| 180 | + this.$ionicPlatform.onHardwareBackButton(callback); |
| 181 | + this.$ionicPlatform.offHardwareBackButton(callback); |
| 182 | + this.$ionicPlatform.registerBackButtonAction(callback, 1, "actionId"); |
| 183 | + this.$ionicPlatform.on("type", callback); |
| 184 | + this.$ionicPlatform.ready(callback); |
| 185 | + this.$ionicPlatform.ready().then(() => console.log("ready!")); |
| 186 | + } |
| 187 | + private testPopover(): void { |
| 188 | + var popoverOptions: ionic.popover.IonicPopoverOptions = { |
| 189 | + scope: {}, |
| 190 | + focusFirstInput: true, |
| 191 | + backdropClickToClose: false, |
| 192 | + hardwareBackButtonClose: true |
| 193 | + }; |
| 194 | + var ionicPopoverController: ionic.popover.IonicPopoverController = this.$ionicPopover.fromTemplate("template", popoverOptions); |
| 195 | + ionicPopoverController.initialize(popoverOptions); |
| 196 | + ionicPopoverController.show(angular.element("body")).then(() => console.log("shown popover")) |
| 197 | + ionicPopoverController.hide().then(() => console.log("hid popover")) |
| 198 | + var isShown: boolean = ionicPopoverController.isShown(); |
| 199 | + |
| 200 | + this.$ionicPopover.fromTemplateUrl("templateUrl", popoverOptions) |
| 201 | + .then(popoverCtrl => ionicPopoverController = popoverCtrl); |
| 202 | + } |
| 203 | + private testPopup(): void { |
| 204 | + this.$ionicPopup.show({ |
| 205 | + title: "title", |
| 206 | + subTitle: "subTitle", |
| 207 | + cssClass: "cssClass", |
| 208 | + template: "template", |
| 209 | + templateUrl: "templateUrl", |
| 210 | + scope: {}, |
| 211 | + buttons: [{text: "text", type: "type", onTap: (e) => {console.log(e)}}] |
| 212 | + }).then(() => console.log("popover shown")); |
| 213 | + this.$ionicPopup.show({ |
| 214 | + title: "title", |
| 215 | + subTitle: "subTitle", |
| 216 | + cssClass: "cssClass", |
| 217 | + template: "template", |
| 218 | + templateUrl: "templateUrl", |
| 219 | + scope: {}, |
| 220 | + buttons: [{text: "text", type: "type", onTap: (e) => {console.log(e)}}] |
| 221 | + }).close("done"); |
| 222 | + |
| 223 | + this.$ionicPopup.alert({ |
| 224 | + title: "title", |
| 225 | + subTitle: "subTitle", |
| 226 | + cssClass: "cssClass", |
| 227 | + template: "template", |
| 228 | + templateUrl: "templateUrl", |
| 229 | + okText: "OK", |
| 230 | + okType: "okType" |
| 231 | + }).then(() => console.log("popover shown")) |
| 232 | + this.$ionicPopup.alert({ |
| 233 | + title: "title", |
| 234 | + subTitle: "subTitle", |
| 235 | + cssClass: "cssClass", |
| 236 | + template: "template", |
| 237 | + templateUrl: "templateUrl", |
| 238 | + okText: "OK", |
| 239 | + okType: "okType" |
| 240 | + }).close(); |
| 241 | + |
| 242 | + this.$ionicPopup.confirm({ |
| 243 | + title: "title", |
| 244 | + subTitle: "subTitle", |
| 245 | + cssClass: "cssClass", |
| 246 | + template: "template", |
| 247 | + templateUrl: "templateUrl", |
| 248 | + okText: "OK", |
| 249 | + okType: "okType", |
| 250 | + cancelText: "Cancel", |
| 251 | + cancelType: "cancelType" |
| 252 | + }).then(() => console.log("popover shown")) |
| 253 | + this.$ionicPopup.confirm({ |
| 254 | + title: "title", |
| 255 | + subTitle: "subTitle", |
| 256 | + cssClass: "cssClass", |
| 257 | + template: "template", |
| 258 | + templateUrl: "templateUrl", |
| 259 | + okText: "OK", |
| 260 | + okType: "okType", |
| 261 | + cancelText: "Cancel", |
| 262 | + cancelType: "cancelType" |
| 263 | + }).close(); |
| 264 | + |
| 265 | + this.$ionicPopup.prompt({ |
| 266 | + title: "title", |
| 267 | + subTitle: "subTitle", |
| 268 | + cssClass: "cssClass", |
| 269 | + template: "template", |
| 270 | + templateUrl: "templateUrl", |
| 271 | + okText: "OK", |
| 272 | + okType: "okType", |
| 273 | + cancelText: "Cancel", |
| 274 | + cancelType: "cancelType", |
| 275 | + inputType: "text", |
| 276 | + inputPlaceholder: "Type some text..." |
| 277 | + }).then(() => console.log("popover shown")) |
| 278 | + this.$ionicPopup.prompt({ |
| 279 | + title: "title", |
| 280 | + subTitle: "subTitle", |
| 281 | + cssClass: "cssClass", |
| 282 | + template: "template", |
| 283 | + templateUrl: "templateUrl", |
| 284 | + okText: "OK", |
| 285 | + okType: "okType", |
| 286 | + cancelText: "Cancel", |
| 287 | + cancelType: "cancelType", |
| 288 | + inputType: "text", |
| 289 | + inputPlaceholder: "Type some text..." |
| 290 | + }).close(); |
| 291 | + } |
| 292 | + |
| 293 | + private testScroll(): void { |
| 294 | + this.$ionicScrollDelegate.resize(); |
| 295 | + this.$ionicScrollDelegate.scrollTop(); |
| 296 | + this.$ionicScrollDelegate.scrollTop(true); |
| 297 | + this.$ionicScrollDelegate.scrollBottom(); |
| 298 | + this.$ionicScrollDelegate.scrollBottom(true); |
| 299 | + this.$ionicScrollDelegate.scrollTo(0, 0); |
| 300 | + this.$ionicScrollDelegate.scrollTo(0, 0, true); |
| 301 | + this.$ionicScrollDelegate.scrollBy(0, 0); |
| 302 | + this.$ionicScrollDelegate.scrollBy(0, 0, true); |
| 303 | + this.$ionicScrollDelegate.zoomTo(1); |
| 304 | + this.$ionicScrollDelegate.zoomTo(1, true); |
| 305 | + this.$ionicScrollDelegate.zoomTo(1, true, 0); |
| 306 | + this.$ionicScrollDelegate.zoomTo(1, true, 0, 0); |
| 307 | + this.$ionicScrollDelegate.zoomBy(0.5); |
| 308 | + this.$ionicScrollDelegate.zoomBy(0.5, true); |
| 309 | + this.$ionicScrollDelegate.zoomBy(0.5, true, 50); |
| 310 | + this.$ionicScrollDelegate.zoomBy(0.5, true, 50, 50); |
| 311 | + var {top: number, left: number} = this.$ionicScrollDelegate.getScrollPosition(); |
| 312 | + this.$ionicScrollDelegate.anchorScroll(); |
| 313 | + this.$ionicScrollDelegate.anchorScroll(true); |
| 314 | + var isScrollFrozen: boolean = this.$ionicScrollDelegate.freezeScroll(); |
| 315 | + this.$ionicScrollDelegate.freezeScroll(false); |
| 316 | + var areAllScrollsFrozen: boolean = this.$ionicScrollDelegate.freezeAllScrolls(); |
| 317 | + this.$ionicScrollDelegate.freezeAllScrolls(false); |
| 318 | + var scrollView: any = this.$ionicScrollDelegate.getScrollView(); |
| 319 | + var scrollDelegate: ionic.scroll.IonicScrollDelegate = this.$ionicScrollDelegate.$getByHandle("handle"); |
| 320 | + } |
| 321 | + private testSideMenu(): void { |
| 322 | + this.$ionicSideMenuDelegate.toggleLeft(); |
| 323 | + this.$ionicSideMenuDelegate.toggleLeft(true); |
| 324 | + this.$ionicSideMenuDelegate.toggleRight(); |
| 325 | + this.$ionicSideMenuDelegate.toggleRight(true); |
| 326 | + var openRatio: number = this.$ionicSideMenuDelegate.getOpenRatio(); |
| 327 | + var isOpen: boolean = this.$ionicSideMenuDelegate.isOpen(); |
| 328 | + var isOpenLeft: boolean = this.$ionicSideMenuDelegate.isOpenLeft(); |
| 329 | + var isOpenRight: boolean = this.$ionicSideMenuDelegate.isOpenRight(); |
| 330 | + var canDragContent: boolean = this.$ionicSideMenuDelegate.canDragContent(); |
| 331 | + this.$ionicSideMenuDelegate.canDragContent(false); |
| 332 | + var edgeDragThreshold: boolean = this.$ionicSideMenuDelegate.edgeDragThreshold(); |
| 333 | + this.$ionicSideMenuDelegate.edgeDragThreshold(true); |
| 334 | + this.$ionicSideMenuDelegate.edgeDragThreshold(500); |
| 335 | + var sideMenuDelegate: ionic.sideMenu.IonicSideMenuDelegate = this.$ionicSideMenuDelegate.$getByHandle("handle"); |
| 336 | + } |
| 337 | + private testSlideBox(): void { |
| 338 | + this.$ionicSlideBoxDelegate.update(); |
| 339 | + this.$ionicSlideBoxDelegate.slide(1); |
| 340 | + this.$ionicSlideBoxDelegate.slide(1, 500); |
| 341 | + var isSlideEnabled: boolean = this.$ionicSlideBoxDelegate.enableSlide(); |
| 342 | + this.$ionicSlideBoxDelegate.enableSlide(true); |
| 343 | + this.$ionicSlideBoxDelegate.previous(); |
| 344 | + this.$ionicSlideBoxDelegate.previous(500); |
| 345 | + this.$ionicSlideBoxDelegate.next(); |
| 346 | + this.$ionicSlideBoxDelegate.next(500); |
| 347 | + this.$ionicSlideBoxDelegate.stop(); |
| 348 | + this.$ionicSlideBoxDelegate.start(); |
| 349 | + var currentIndex: number = this.$ionicSlideBoxDelegate.currentIndex(); |
| 350 | + var slidesCount: number = this.$ionicSlideBoxDelegate.slidesCount(); |
| 351 | + var slideBoxDelegate: ionic.slideBox.IonicSlideBoxDelegate = this.$ionicSlideBoxDelegate.$getByHandle("handle"); |
| 352 | + } |
| 353 | + private testTabs(): void { |
| 354 | + this.$ionicTabsDelegate.select(1); |
| 355 | + var selectedIndex: number = this.$ionicTabsDelegate.selectedIndex(); |
| 356 | + var ionicTabsDelegate: ionic.tabs.IonicTabsDelegate = this.$ionicTabsDelegate.$getByHandle("handle"); |
| 357 | + } |
| 358 | + private testUtility(): void { |
| 359 | + var {top: number, left: number, width: number, height: number} = this.$ionicPositionService.position(angular.element("body")); |
| 360 | + var {top: number, left: number, width: number, height: number} = this.$ionicPositionService.offset(angular.element("body")); |
| 361 | + } |
| 362 | +} |
| 363 | + |
| 364 | +testIonic.controller('ionicTestController', IonicTestController); |
| 365 | + |
0 commit comments