1 | ;
|
2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5 | 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;
|
6 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7 | };
|
8 | var plugin_1 = require('./plugin');
|
9 | var Observable_1 = require('rxjs/Observable');
|
10 | /**
|
11 | * @name ThemeableBrowser
|
12 | * @description
|
13 | * In-app browser that allows styling.
|
14 | *
|
15 | * @usage
|
16 | * ```
|
17 | * import { ThemeableBrowser } from 'ionic-native';
|
18 | *
|
19 | * // can add options from the original InAppBrowser in a JavaScript object form (not string)
|
20 | * // This options object also takes additional parameters introduced by the ThemeableBrowser plugin
|
21 | * // This example only shows the additional parameters for ThemeableBrowser
|
22 | * // Note that that `image` and `imagePressed` values refer to resources that are stored in your app
|
23 | * let options = {
|
24 | * statusbar: {
|
25 | * color: '#ffffffff'
|
26 | * },
|
27 | * toolbar: {
|
28 | * height: 44,
|
29 | * color: '#f0f0f0ff'
|
30 | * },
|
31 | * title: {
|
32 | * color: '#003264ff',
|
33 | * showPageTitle: true
|
34 | * },
|
35 | * backButton: {
|
36 | * image: 'back',
|
37 | * imagePressed: 'back_pressed',
|
38 | * align: 'left',
|
39 | * event: 'backPressed'
|
40 | * },
|
41 | * forwardButton: {
|
42 | * image: 'forward',
|
43 | * imagePressed: 'forward_pressed',
|
44 | * align: 'left',
|
45 | * event: 'forwardPressed'
|
46 | * },
|
47 | * closeButton: {
|
48 | * image: 'close',
|
49 | * imagePressed: 'close_pressed',
|
50 | * align: 'left',
|
51 | * event: 'closePressed'
|
52 | * },
|
53 | * customButtons: [
|
54 | * {
|
55 | * image: 'share',
|
56 | * imagePressed: 'share_pressed',
|
57 | * align: 'right',
|
58 | * event: 'sharePressed'
|
59 | * }
|
60 | * ],
|
61 | * menu: {
|
62 | * image: 'menu',
|
63 | * imagePressed: 'menu_pressed',
|
64 | * title: 'Test',
|
65 | * cancel: 'Cancel',
|
66 | * align: 'right',
|
67 | * items: [
|
68 | * {
|
69 | * event: 'helloPressed',
|
70 | * label: 'Hello World!'
|
71 | * },
|
72 | * {
|
73 | * event: 'testPressed',
|
74 | * label: 'Test!'
|
75 | * }
|
76 | * ]
|
77 | * },
|
78 | * backButtonCanClose: true
|
79 | * };
|
80 | *
|
81 | * let browser = new ThemeableBrowser('https://ionic.io', '_blank', options);
|
82 | *
|
83 | * ```
|
84 | * We suggest that you refer to the plugin's repository for additional information on usage that may not be covered here.
|
85 | * @interfaces
|
86 | * ThemeableBrowserButton
|
87 | * ThemeableBrowserOptions
|
88 | */
|
89 | var ThemeableBrowser = (function () {
|
90 | function ThemeableBrowser(url, target, styleOptions) {
|
91 | try {
|
92 | this._objectInstance = cordova.ThemeableBrowser.open(url, target, styleOptions);
|
93 | }
|
94 | catch (e) {
|
95 | window.open(url);
|
96 | console.warn('Native: ThemeableBrowser is not installed or you are running on a browser. Falling back to window.open, all instance methods will NOT work.');
|
97 | }
|
98 | }
|
99 | /**
|
100 | * Displays an browser window that was opened hidden. Calling this has no effect
|
101 | * if the browser was already visible.
|
102 | */
|
103 | ThemeableBrowser.prototype.show = function () { };
|
104 | /**
|
105 | * Closes the browser window.
|
106 | */
|
107 | ThemeableBrowser.prototype.close = function () { };
|
108 | /**
|
109 | * Reloads the current page
|
110 | */
|
111 | ThemeableBrowser.prototype.reload = function () { };
|
112 | /**
|
113 | * Injects JavaScript code into the browser window.
|
114 | * @param script Details of the script to run, specifying either a file or code key.
|
115 | * @returns {Promise<any>}
|
116 | */
|
117 | ThemeableBrowser.prototype.executeScript = function (script) { return; };
|
118 | /**
|
119 | * Injects CSS into the browser window.
|
120 | * @param css Details of the script to run, specifying either a file or code key.
|
121 | * @returns {Promise<any>}
|
122 | */
|
123 | ThemeableBrowser.prototype.insertCss = function (css) { return; };
|
124 | /**
|
125 | * A method that allows you to listen to events happening in the browser.
|
126 | * Available events are: `ThemeableBrowserError`, `ThemeableBrowserWarning`, `critical`, `loadfail`, `unexpected`, `undefined`
|
127 | * @param event Event name
|
128 | * @returns {Observable<InAppBrowserEvent>} Returns back an observable that will listen to the event on subscribe, and will stop listening to the event on unsubscribe.
|
129 | */
|
130 | ThemeableBrowser.prototype.on = function (event) {
|
131 | var _this = this;
|
132 | return new Observable_1.Observable(function (observer) {
|
133 | _this._objectInstance.addEventListener(event, observer.next.bind(observer));
|
134 | return function () { return _this._objectInstance.removeEventListener(event, observer.next.bind(observer)); };
|
135 | });
|
136 | };
|
137 | __decorate([
|
138 | plugin_1.CordovaInstance({ sync: true })
|
139 | ], ThemeableBrowser.prototype, "show", null);
|
140 | __decorate([
|
141 | plugin_1.CordovaInstance({ sync: true })
|
142 | ], ThemeableBrowser.prototype, "close", null);
|
143 | __decorate([
|
144 | plugin_1.CordovaInstance({ sync: true })
|
145 | ], ThemeableBrowser.prototype, "reload", null);
|
146 | __decorate([
|
147 | plugin_1.CordovaInstance()
|
148 | ], ThemeableBrowser.prototype, "executeScript", null);
|
149 | __decorate([
|
150 | plugin_1.CordovaInstance()
|
151 | ], ThemeableBrowser.prototype, "insertCss", null);
|
152 | ThemeableBrowser = __decorate([
|
153 | plugin_1.Plugin({
|
154 | pluginName: 'ThemeableBrowser',
|
155 | plugin: 'cordova-plugin-themeablebrowser',
|
156 | pluginRef: 'cordova.ThemeableBrowser',
|
157 | repo: 'https://github.com/initialxy/cordova-plugin-themeablebrowser'
|
158 | })
|
159 | ], ThemeableBrowser);
|
160 | return ThemeableBrowser;
|
161 | }());
|
162 | exports.ThemeableBrowser = ThemeableBrowser;
|
163 | //# sourceMappingURL=themeable-browser.js.map |
\ | No newline at end of file |