Permalink
Browse files

Cleanup to sample, DOMNodeRemoved for iframes, and detaching with the…

… require("web-content")'s ProgressMonitor. Removed the new, and go=new. No way to change URL for the loaded tab. Simplified demo.
  • Loading branch information...
1 parent 7fea240 commit 475a63611cee539950d06fd59cdfafcb53646330 @taboca taboca committed May 3, 2011
Showing with 22 additions and 14 deletions.
  1. +22 −14 examples/thumbnails/index.html
@@ -135,7 +135,7 @@
<form>
<input id="awesomeBox" type="text" value="http://www.google.com" />
<input type="submit" id="buttonGo" value="go"></input>
- <button id="buttonNew" >New</button>
+ <button id="buttonClose" >Close</button>
<button id="buttonPersist" >All</button>
<button id="buttonFull" >Full</button>
</form>
@@ -183,14 +183,20 @@
evt.strength = e.state;
iframeElement.dispatchEvent(evt);
});
+ var currentIframeElementId = iframeElement.getAttribute("id");
+ document.getElementById("browserContentArea").addEventListener("DOMNodeRemoved", function(e){
+ if(e.target.getAttribute("id") == currentIframeElementId) {
+ console.log("It's me!, detaching ");
+ pm.detach();
+ }
+ }, false);
}
const fullscreen = require("fullscreen");
const url = require("url");
-var currentBrowser = null;
+//var currentBrowser = null;
var currSelected = null;
-var browserTabs = new Array();
function makeBrowser() {
var browser = document.createElement("iframe");
@@ -203,13 +209,6 @@
$(".browser").addClass("browser_hidden");
$(browserRef).removeClass("browser_hidden");
$(browserRef).addClass("browser_selected");
- var refBrowserId = $(browserRef).attr("id");
- var uniqueId = refBrowserId.split("browser_unique_")[1];
- if(currSelected) {
- document.getElementById("thumb_unique_"+currSelected).setAttribute("class","thumb");
- }
- document.getElementById("thumb_unique_"+uniqueId).setAttribute("class","thumb thumb_selected");
- currSelected = uniqueId;
}
function canvasShot(browserRef, thumbImageRef) {
@@ -228,7 +227,6 @@
var uniqueId = Math.random();
var browserUnique = "browser_unique_"+uniqueId;
- browserTabs.push(newBrowser);
newBrowser.setAttribute("id",browserUnique);
// Update thumbnails of the iframe when DOM is setup, and
@@ -261,7 +259,6 @@
document.getElementById("browserContentArea").appendChild(newBrowser);
fixUpIframe(newBrowser);
selectBrowser(newBrowser);
- currentBrowser = newBrowser;
}
function syncTabs(refBrowserId) {
@@ -272,11 +269,10 @@
$(document).ready(function() {
$("#browserHeader form").submit(function(e) {
- if(browserTabs.length<1) newTab();
+ newTab();
browserUniqueId = $(".browser_selected").attr("id");
var fragment = $.trim($("#awesomeBox").val());
$(".browser_selected").attr("src", url.guess(fragment));
-
return false;
});
$("#browserHeader #buttonNew").click(function(e) {
@@ -285,6 +281,18 @@
$("#awesomeBox").focus();
return false;
});
+ $("#browserHeader #buttonClose").click(function(e) {
+ var strId = $(".browser_selected").attr("id");
+ var uniqueId = strId.split("browser_unique_")[1];
+ var thumbId = "thumb_unique_"+uniqueId;
+
+ document.getElementById(thumbId).parentNode.removeChild(document.getElementById(thumbId));
+ //$(thumbId).remove(); // Somehow this failed.
+
+
+ $(".browser_selected").remove();
+ return false;
+ });
$("#browserHeader #buttonPersist").click(function(e) {
$(".browser").removeClass("browser_hidden");
return false;

0 comments on commit 475a636

Please sign in to comment.