src property added

This commit is contained in:
Vladimir Enchev
2015-05-18 17:19:17 +03:00
parent 6b71ea07b4
commit 1dc3de774c
4 changed files with 95 additions and 4 deletions

View File

@ -1,5 +1,7 @@
import common = require("ui/web-view/web-view-common");
import trace = require("trace");
import utils = require("utils/utils");
import fs = require("file-system");
declare var exports;
require("utils/module-merge").merge(common, exports);
@ -74,6 +76,30 @@ export class WebView extends common.WebView {
this._android.loadUrl(url);
}
public _loadSrc(src: string) {
trace.write("WebView._loadSrc(" + src + ")", trace.categories.Debug);
this._android.stopLoading();
if (utils.isFileOrResourcePath(src)) {
if (src.indexOf("~/") === 0) {
src = fs.path.join(fs.knownFolders.currentApp().path, src.replace("~/", ""));
}
var file = fs.File.fromPath(src);
if (file) {
file.readText().then((r) => {
this._android.loadData(r, "text/html", null);
});
}
} else if (src.indexOf("http://") === 0 || src.indexOf("https://") === 0) {
this._android.loadUrl(src);
} else {
this._android.loadData(src, "text/html", null);
}
}
get canGoBack(): boolean {
return this._android.canGoBack();
}