Invoke webview if using local file

This commit is contained in:
aroberson 2015-04-13 15:33:03 -05:00
parent 11a2acfd7b
commit 8175122c03

View File

@ -17,13 +17,12 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
* *
*/ */
/*jslint sloppy:true */ /*jslint sloppy:true */
/*global Windows:true, require, document, setTimeout, window, module */ /*global Windows:true, require, document, setTimeout, window, module */
var cordova = require('cordova'), var cordova = require('cordova'),
channel = require('cordova/channel'); channel = require('cordova/channel');
@ -39,9 +38,9 @@ var IAB = {
}, },
show: function (win, lose) { show: function (win, lose) {
/* empty block, ran out of bacon? /* empty block, ran out of bacon?
if (browserWrap) { if (browserWrap) {
}*/ }*/
}, },
open: function (win, lose, args) { open: function (win, lose, args) {
var strUrl = args[0], var strUrl = args[0],
@ -72,20 +71,38 @@ var IAB = {
document.body.appendChild(browserWrap); document.body.appendChild(browserWrap);
} }
var localFile = (strUrl.indexOf('ms-appdata:///') > -1);
if (localFile) {
elem = document.createElement("x-ms-webview");
elem.style.width = (window.innerWidth - 80) + "px";
elem.style.height = (window.innerHeight - 80) + "px";
elem.style.borderWidth = "0px";
elem.name = "targetFrame";
elem.src = strUrl;
elem = document.createElement("iframe"); window.addEventListener("resize", function () {
elem.style.width = (window.innerWidth - 80) + "px"; if (browserWrap && elem) {
elem.style.height = (window.innerHeight - 80) + "px"; elem.style.width = (window.innerWidth - 80) + "px";
elem.style.borderWidth = "0px"; elem.style.height = (window.innerHeight - 80) + "px";
elem.name = "targetFrame"; }
elem.src = strUrl; });
window.addEventListener("resize", function () { } else {
if (browserWrap && elem) { elem = document.createElement("iframe");
elem.style.width = (window.innerWidth - 80) + "px"; elem.style.width = (window.innerWidth - 80) + "px";
elem.style.height = (window.innerHeight - 80) + "px"; elem.style.height = (window.innerHeight - 80) + "px";
} elem.style.borderWidth = "0px";
}); elem.name = "targetFrame";
elem.src = strUrl;
window.addEventListener("resize", function () {
if (browserWrap && elem) {
elem.style.width = (window.innerWidth - 80) + "px";
elem.style.height = (window.innerHeight - 80) + "px";
}
});
}
browserWrap.appendChild(elem); browserWrap.appendChild(elem);
} else { } else {