mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
got to layouts
This commit is contained in:
@@ -2,9 +2,8 @@ import { WebView as WebViewDefinition, LoadEventData } from "ui/web-view";
|
||||
import { View, Property, EventData } from "ui/core/view";
|
||||
import { isFileOrResourcePath } from "utils/utils";
|
||||
import { File, knownFolders, path } from "file-system";
|
||||
import * as trace from "trace";
|
||||
|
||||
export { trace, File, knownFolders, path };
|
||||
export { File, knownFolders, path };
|
||||
export * from "ui/core/view";
|
||||
|
||||
export abstract class WebViewBase extends View implements WebViewDefinition {
|
||||
@@ -86,10 +85,6 @@ export abstract class WebViewBase extends View implements WebViewDefinition {
|
||||
|
||||
this.stopLoading();
|
||||
|
||||
if (trace.enabled) {
|
||||
trace.write("WebView._loadSrc(" + src + ")", trace.categories.Debug);
|
||||
}
|
||||
|
||||
if (isFileOrResourcePath(src)) {
|
||||
if (src.indexOf("~/") === 0) {
|
||||
src = path.join(knownFolders.currentApp().path, src.replace("~/", ""));
|
||||
@@ -108,5 +103,5 @@ export abstract class WebViewBase extends View implements WebViewDefinition {
|
||||
}
|
||||
}
|
||||
|
||||
export let srcProperty = new Property<WebViewBase, string>({ name: "url" });
|
||||
export const srcProperty = new Property<WebViewBase, string>({ name: "url" });
|
||||
srcProperty.register(WebViewBase);
|
||||
@@ -1,4 +1,4 @@
|
||||
import { WebViewBase, File, knownFolders, path, trace } from "./web-view-common";
|
||||
import { WebViewBase, File, knownFolders, path, traceEnabled, traceWrite, traceCategories } from "./web-view-common";
|
||||
|
||||
export * from "./web-view-common";
|
||||
|
||||
@@ -19,8 +19,8 @@ function ensureWebViewClientClass() {
|
||||
}
|
||||
|
||||
public shouldOverrideUrlLoading(view: android.webkit.WebView, url: string) {
|
||||
if (trace.enabled) {
|
||||
trace.write("WebViewClientClass.shouldOverrideUrlLoading(" + url + ")", trace.categories.Debug);
|
||||
if (traceEnabled) {
|
||||
traceWrite("WebViewClientClass.shouldOverrideUrlLoading(" + url + ")", traceCategories.Debug);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -29,8 +29,8 @@ function ensureWebViewClientClass() {
|
||||
super.onPageStarted(view, url, favicon);
|
||||
|
||||
if (this._view) {
|
||||
if (trace.enabled) {
|
||||
trace.write("WebViewClientClass.onPageStarted(" + url + ", " + favicon + ")", trace.categories.Debug);
|
||||
if (traceEnabled) {
|
||||
traceWrite("WebViewClientClass.onPageStarted(" + url + ", " + favicon + ")", traceCategories.Debug);
|
||||
}
|
||||
this._view._onLoadStarted(url, WebViewBase.navigationTypes[WebViewBase.navigationTypes.indexOf("linkClicked")]);
|
||||
}
|
||||
@@ -40,8 +40,8 @@ function ensureWebViewClientClass() {
|
||||
super.onPageFinished(view, url);
|
||||
|
||||
if (this._view) {
|
||||
if (trace.enabled) {
|
||||
trace.write("WebViewClientClass.onPageFinished(" + url + ")", trace.categories.Debug);
|
||||
if (traceEnabled) {
|
||||
traceWrite("WebViewClientClass.onPageFinished(" + url + ")", traceCategories.Debug);
|
||||
}
|
||||
this._view._onLoadFinished(url, undefined);
|
||||
}
|
||||
@@ -58,8 +58,8 @@ function ensureWebViewClientClass() {
|
||||
super.onReceivedError(view, errorCode, description, failingUrl);
|
||||
|
||||
if (this._view) {
|
||||
if (trace.enabled) {
|
||||
trace.write("WebViewClientClass.onReceivedError(" + errorCode + ", " + description + ", " + failingUrl + ")", trace.categories.Debug);
|
||||
if (traceEnabled) {
|
||||
traceWrite("WebViewClientClass.onReceivedError(" + errorCode + ", " + description + ", " + failingUrl + ")", traceCategories.Debug);
|
||||
}
|
||||
this._view._onLoadFinished(failingUrl, description + "(" + errorCode + ")");
|
||||
}
|
||||
@@ -70,8 +70,8 @@ function ensureWebViewClientClass() {
|
||||
super.onReceivedError(view, request, error);
|
||||
|
||||
if (this._view) {
|
||||
if (trace.enabled) {
|
||||
trace.write("WebViewClientClass.onReceivedError(" + error.getErrorCode() + ", " + error.getDescription() + ", " + (error.getUrl && error.getUrl()) + ")", trace.categories.Debug);
|
||||
if (traceEnabled) {
|
||||
traceWrite("WebViewClientClass.onReceivedError(" + error.getErrorCode() + ", " + error.getDescription() + ", " + (error.getUrl && error.getUrl()) + ")", traceCategories.Debug);
|
||||
}
|
||||
this._view._onLoadFinished(error.getUrl && error.getUrl(), error.getDescription() + "(" + error.getErrorCode() + ")");
|
||||
}
|
||||
@@ -116,8 +116,8 @@ export class WebView extends WebViewBase {
|
||||
return;
|
||||
}
|
||||
|
||||
if (trace.enabled) {
|
||||
trace.write("WebView._loadUrl(" + url + ")", trace.categories.Debug);
|
||||
if (traceEnabled) {
|
||||
traceWrite("WebView._loadUrl(" + url + ")", traceCategories.Debug);
|
||||
}
|
||||
this._android.stopLoading();
|
||||
this._android.loadUrl(url);
|
||||
|
||||
2
tns-core-modules/ui/web-view/web-view.d.ts
vendored
2
tns-core-modules/ui/web-view/web-view.d.ts
vendored
@@ -7,7 +7,7 @@ declare module "ui/web-view" {
|
||||
/**
|
||||
* Represents the observable property backing the Url property of each WebView instance.
|
||||
*/
|
||||
export let urlProperty: Property<WebView, string>;
|
||||
export const urlProperty: Property<WebView, string>;
|
||||
|
||||
/**
|
||||
* Represents a standard WebView widget.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { WebViewBase, File, knownFolders, path, trace } from "./web-view-common";
|
||||
import { WebViewBase, File, knownFolders, path, traceWrite, traceEnabled, traceCategories } from "./web-view-common";
|
||||
|
||||
export * from "./web-view-common";
|
||||
|
||||
@@ -37,8 +37,8 @@ class UIWebViewDelegateImpl extends NSObject implements UIWebViewDelegate {
|
||||
break;
|
||||
}
|
||||
|
||||
if (trace.enabled) {
|
||||
trace.write("UIWebViewDelegateClass.webViewShouldStartLoadWithRequestNavigationType(" + request.URL.absoluteString + ", " + navigationType + ")", trace.categories.Debug);
|
||||
if (traceEnabled) {
|
||||
traceWrite("UIWebViewDelegateClass.webViewShouldStartLoadWithRequestNavigationType(" + request.URL.absoluteString + ", " + navigationType + ")", traceCategories.Debug);
|
||||
}
|
||||
owner._onLoadStarted(request.URL.absoluteString, WebViewBase.navigationTypes[navTypeIndex]);
|
||||
}
|
||||
@@ -47,14 +47,14 @@ class UIWebViewDelegateImpl extends NSObject implements UIWebViewDelegate {
|
||||
}
|
||||
|
||||
public webViewDidStartLoad(webView: UIWebView) {
|
||||
if (trace.enabled) {
|
||||
trace.write("UIWebViewDelegateClass.webViewDidStartLoad(" + webView.request.URL + ")", trace.categories.Debug);
|
||||
if (traceEnabled) {
|
||||
traceWrite("UIWebViewDelegateClass.webViewDidStartLoad(" + webView.request.URL + ")", traceCategories.Debug);
|
||||
}
|
||||
}
|
||||
|
||||
public webViewDidFinishLoad(webView: UIWebView) {
|
||||
if (trace.enabled) {
|
||||
trace.write("UIWebViewDelegateClass.webViewDidFinishLoad(" + webView.request.URL + ")", trace.categories.Debug);
|
||||
if (traceEnabled) {
|
||||
traceWrite("UIWebViewDelegateClass.webViewDidFinishLoad(" + webView.request.URL + ")", traceCategories.Debug);
|
||||
}
|
||||
let owner = this._owner.get();
|
||||
if (owner) {
|
||||
@@ -70,8 +70,8 @@ class UIWebViewDelegateImpl extends NSObject implements UIWebViewDelegate {
|
||||
src = webView.request.URL.absoluteString;
|
||||
}
|
||||
|
||||
if (trace.enabled) {
|
||||
trace.write("UIWebViewDelegateClass.webViewDidFailLoadWithError(" + error.localizedDescription + ")", trace.categories.Debug);
|
||||
if (traceEnabled) {
|
||||
traceWrite("UIWebViewDelegateClass.webViewDidFailLoadWithError(" + error.localizedDescription + ")", traceCategories.Debug);
|
||||
}
|
||||
if (owner) {
|
||||
owner._onLoadFinished(src, error.localizedDescription);
|
||||
@@ -110,8 +110,8 @@ export class WebView extends WebViewBase {
|
||||
}
|
||||
|
||||
public _loadUrl(url: string) {
|
||||
if (trace.enabled) {
|
||||
trace.write("WebView._loadUrl(" + url + ")", trace.categories.Debug);
|
||||
if (traceEnabled) {
|
||||
traceWrite("WebView._loadUrl(" + url + ")", traceCategories.Debug);
|
||||
}
|
||||
|
||||
if (this._ios.loading) {
|
||||
@@ -130,7 +130,7 @@ export class WebView extends WebViewBase {
|
||||
}
|
||||
|
||||
public _loadData(content: string) {
|
||||
this._ios.loadHTMLStringBaseURL(content, NSURL.alloc().initWithString(`file:///${fs.knownFolders.currentApp().path}/`));
|
||||
this._ios.loadHTMLStringBaseURL(content, NSURL.alloc().initWithString(`file:///${knownFolders.currentApp().path}/`));
|
||||
}
|
||||
|
||||
get canGoBack(): boolean {
|
||||
|
||||
Reference in New Issue
Block a user