UNPKG

ferngully-aurelia-tools

Version:

Ferngully Tools for Aurelia

78 lines 3.11 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { autoinject } from "aurelia-framework"; import { DialogService } from "aurelia-dialog"; import { BrowserService } from "./browser-service"; import { PLATFORM } from 'aurelia-framework'; let CommonDialogs = class CommonDialogs { constructor(dialogService, browserService) { this.dialogService = dialogService; this.browserService = browserService; } prompt(options, settings) { if (typeof options === "string") { options = { text: options, ok: true }; } let defaultSettings = { keyboard: ["Escape"] }; if (!settings) { settings = defaultSettings; } else { Object.apply(defaultSettings, settings); } settings.viewModel = PLATFORM.moduleName('ferngully-aurelia-tools/resources/commonDialogs/prompt'); settings.model = options; this.adjustScroll(); return this.dialogService.open(settings) .whenClosed((result) => { return Promise.resolve({ wasCancelled: result.wasCancelled }); }); } ; askForText(options, settings) { if (typeof options === "string") { options = { text: options, ok: true, cancel: true }; } let defaultSettings = { keyboard: ["Escape"] }; if (!settings) { settings = defaultSettings; } else { Object.apply(defaultSettings, settings); } settings.viewModel = PLATFORM.moduleName('ferngully-aurelia-tools/resources/commonDialogs/askForText'); settings.model = options; this.adjustScroll(); return this.dialogService.open(settings) .whenClosed((result) => { return result.wasCancelled ? null : result.output; }); } ; adjustScroll() { if (this.browserService.verticalScrollBarIsShowing()) { $('body').addClass("showVerticalScroll"); } else { $('body').removeClass("showVerticalScroll"); } } }; CommonDialogs = __decorate([ autoinject, __metadata("design:paramtypes", [DialogService, BrowserService]) ], CommonDialogs); export { CommonDialogs }; //# sourceMappingURL=dialog-service.js.map