Commit e6d89778 authored by Sven Franck's avatar Sven Franck

switched to using addGadget() in filecontent.js

parent 5e269eda
......@@ -88,17 +88,6 @@
});
}
});
// var frames = document.getElementsByTagName("iframe"), frame, i;
// for (i = 0; i < frames.length; i += 1) {
// frame = frames[i];
// if (myIndexOf(
// event.source.location.pathname,
// frame.getAttribute("src").split("?")[0]
// ) < 0) {
// frame.contentWindow.postMessage(event.data, "*");
// }
// }
}
};
......
......@@ -8,19 +8,6 @@
sessionStorage.setItem("cous", "cous");
sessionStorage.setItem("schnick", "schnack");
var generateUuid = function () {
var S4 = function () {
var i, string = Math.floor(
Math.random() * 0x10000
).toString(16);
for (i = string.length; i < 4; i += 1) {
string = "0" + string;
}
return string;
};
return S4() + S4();
};
var setup = function () {
// this will have to run automatically should renderJs have an easy API
var instance1 = "data://application/hal+json;base64," +
......@@ -42,23 +29,15 @@
call: {href: ''}
}}));
$("body").append(
'<iframe src="' +
// XXX Hardcoded gadget to load
'filebrowser_and_preview.html' + "?file=" + instance1 +
'" id="' + generateUuid() +
'">' +
'<p>Your browser does not support iframes.</p>' +
'</iframe">');
$("body").addGadget({
"src": "filebrowser_and_preview.html?file=" + instance1,
"iframe": "true"
});
$("body").append(
'<iframe src="' +
// XXX Hardcoded gadget to load
'filebrowser_and_preview.html' + "?file=" + instance2 +
'" id="' + generateUuid() +
'">' +
'<p>Your browser does not support iframes.</p>' +
'</iframe">');
$("body").addGadget({
"src": "filebrowser_and_preview.html?file=" + instance2,
"iframe": "true"
});
};
$(document).ready(function () {
......
// > grab URL with parameters of file to open
// > call addGadget with those parameters?
// > display a file from some storage (local/session)
// > storage type will also be a parameter in the url?
// return "browser://localstorage/foo"
// file=browser%3A%2F%2Flocalstorage%2Ffoo
/*global document, jQuery */
"use strict";
(function (document, $) {
......
......@@ -914,15 +914,13 @@
// find recursive services
$(newParentElement).findService();
} else {
// IFRAME handler
// =============== IFRAME ==================
newHTML = document.createElement("iframe");
newHTML.setAttribute(
"src",
options.src + "?base=" + priv.encodeURI(options.directory.root)
);
newHTML.setAttribute("src", options.src);
newHTML.setAttribute("frameborder", 0);
newHTML.setAttribute("seamless", "seamless");
newHTML.setAttribute("id", options.id);
newHTML.innerHTML = '<p>Your browser does not support iframes.</p>'
// append or replace
if (options.wrapper) {
......@@ -988,15 +986,15 @@
// => publish a service to this instance (and root instance)
that.addService = $.fn.addService = function (options) {
var adressArray = window.location.href.split("?"), targetUrl;
options.src = options.src || adressArray[0];
var addressArray = window.location.href.split("?"), targetUrl;
options.src = options.src || addressArray[0];
// posts to URL passed (need for CORS?)
// otherwise window.top.location.href) would also work
if (adressArray.length === 1) {
targetUrl = priv.decodeURI(adressArray[0]);
if (addressArray.length === 1) {
targetUrl = priv.decodeURI(addressArray[0]);
} else {
targetUrl = priv.decodeURI(adressArray[1].split("=")[1]);
targetUrl = priv.decodeURI(addressArray[1].split("=")[1]);
}
window.top.postMessage(options, targetUrl);
};
......@@ -1029,10 +1027,11 @@
// => load gadget
that.addGadget = $.fn.addGadget = function (options) {
var adressArray = window.location.href.split("?");
var addressArray = window.location.href.split("?"),
element = this[0];
// set parent
if (this[0] === document || this[0] === window) {
if (element === document || element === window || element === document.body) {
options.parent = document.body;
options.replaceParent = false;
} else {
......@@ -1046,9 +1045,9 @@
// set directory (root)
// if no ?-param is available, we can only set to href
if (options.directory === undefined) {
if (adressArray.length > 1) {
if (addressArray.length > 1) {
options.directory = {
"root": priv.decodeURI(adressArray[1].split("=")[1])
"root": priv.decodeURI(addressArray[1].split("=")[1])
};
} else {
options.directory = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment