Commit e6d89778 authored by Sven Franck's avatar Sven Franck

switched to using addGadget() in filecontent.js

parent 5e269eda
...@@ -88,17 +88,6 @@ ...@@ -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 @@ ...@@ -8,19 +8,6 @@
sessionStorage.setItem("cous", "cous"); sessionStorage.setItem("cous", "cous");
sessionStorage.setItem("schnick", "schnack"); 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 () { var setup = function () {
// this will have to run automatically should renderJs have an easy API // this will have to run automatically should renderJs have an easy API
var instance1 = "data://application/hal+json;base64," + var instance1 = "data://application/hal+json;base64," +
...@@ -42,23 +29,15 @@ ...@@ -42,23 +29,15 @@
call: {href: ''} call: {href: ''}
}})); }}));
$("body").append( $("body").addGadget({
'<iframe src="' + "src": "filebrowser_and_preview.html?file=" + instance1,
// XXX Hardcoded gadget to load "iframe": "true"
'filebrowser_and_preview.html' + "?file=" + instance1 + });
'" id="' + generateUuid() +
'">' +
'<p>Your browser does not support iframes.</p>' +
'</iframe">');
$("body").append( $("body").addGadget({
'<iframe src="' + "src": "filebrowser_and_preview.html?file=" + instance2,
// XXX Hardcoded gadget to load "iframe": "true"
'filebrowser_and_preview.html' + "?file=" + instance2 + });
'" id="' + generateUuid() +
'">' +
'<p>Your browser does not support iframes.</p>' +
'</iframe">');
}; };
$(document).ready(function () { $(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 */ /*global document, jQuery */
"use strict"; "use strict";
(function (document, $) { (function (document, $) {
......
...@@ -914,15 +914,13 @@ ...@@ -914,15 +914,13 @@
// find recursive services // find recursive services
$(newParentElement).findService(); $(newParentElement).findService();
} else { } else {
// IFRAME handler // =============== IFRAME ==================
newHTML = document.createElement("iframe"); newHTML = document.createElement("iframe");
newHTML.setAttribute( newHTML.setAttribute("src", options.src);
"src",
options.src + "?base=" + priv.encodeURI(options.directory.root)
);
newHTML.setAttribute("frameborder", 0); newHTML.setAttribute("frameborder", 0);
newHTML.setAttribute("seamless", "seamless"); newHTML.setAttribute("seamless", "seamless");
newHTML.setAttribute("id", options.id); newHTML.setAttribute("id", options.id);
newHTML.innerHTML = '<p>Your browser does not support iframes.</p>'
// append or replace // append or replace
if (options.wrapper) { if (options.wrapper) {
...@@ -988,15 +986,15 @@ ...@@ -988,15 +986,15 @@
// => publish a service to this instance (and root instance) // => publish a service to this instance (and root instance)
that.addService = $.fn.addService = function (options) { that.addService = $.fn.addService = function (options) {
var adressArray = window.location.href.split("?"), targetUrl; var addressArray = window.location.href.split("?"), targetUrl;
options.src = options.src || adressArray[0]; options.src = options.src || addressArray[0];
// posts to URL passed (need for CORS?) // posts to URL passed (need for CORS?)
// otherwise window.top.location.href) would also work // otherwise window.top.location.href) would also work
if (adressArray.length === 1) { if (addressArray.length === 1) {
targetUrl = priv.decodeURI(adressArray[0]); targetUrl = priv.decodeURI(addressArray[0]);
} else { } else {
targetUrl = priv.decodeURI(adressArray[1].split("=")[1]); targetUrl = priv.decodeURI(addressArray[1].split("=")[1]);
} }
window.top.postMessage(options, targetUrl); window.top.postMessage(options, targetUrl);
}; };
...@@ -1029,10 +1027,11 @@ ...@@ -1029,10 +1027,11 @@
// => load gadget // => load gadget
that.addGadget = $.fn.addGadget = function (options) { that.addGadget = $.fn.addGadget = function (options) {
var adressArray = window.location.href.split("?"); var addressArray = window.location.href.split("?"),
element = this[0];
// set parent // set parent
if (this[0] === document || this[0] === window) { if (element === document || element === window || element === document.body) {
options.parent = document.body; options.parent = document.body;
options.replaceParent = false; options.replaceParent = false;
} else { } else {
...@@ -1046,9 +1045,9 @@ ...@@ -1046,9 +1045,9 @@
// set directory (root) // set directory (root)
// if no ?-param is available, we can only set to href // if no ?-param is available, we can only set to href
if (options.directory === undefined) { if (options.directory === undefined) {
if (adressArray.length > 1) { if (addressArray.length > 1) {
options.directory = { options.directory = {
"root": priv.decodeURI(adressArray[1].split("=")[1]) "root": priv.decodeURI(addressArray[1].split("=")[1])
}; };
} else { } else {
options.directory = { 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