Skip to content

Commit

Permalink
分割されたブラウザをたたむ・ひろげる処理を書き直した
Browse files Browse the repository at this point in the history
git-svn-id: http://www.cozmixng.org/repos/piro/splitbrowser/trunk@117 599a83e7-65a4-db11-8015-0010dcdd6dc2
  • Loading branch information
piro committed Feb 1, 2007
1 parent 8e55a14 commit 784fee7
Show file tree
Hide file tree
Showing 3 changed files with 478 additions and 166 deletions.
11 changes: 10 additions & 1 deletion content/splitbrowser/splitbrowser.css
Expand Up @@ -10,7 +10,7 @@
}

#appcontent > vbox > hbox > .primary-browser-wrapper {
-moz-binding: url("./splitbrowser.xml#subbrowser-base") !important;
-moz-binding: url("./splitbrowser.xml#subbrowser-primary") !important;
}

subbrowser-container {
Expand All @@ -21,6 +21,15 @@ subbrowser {
-moz-binding: url("./splitbrowser.xml#subbrowser") !important;
}

vbox.vertical-container > hbox.horizontal-container {
-moz-binding: url("./splitbrowser.xml#horizontal-container") !important;
}

vbox.vertical-container {
-moz-binding: url("./splitbrowser.xml#vertical-container") !important;
}



/* tabbed browsing mode / simple mode */

Expand Down
156 changes: 98 additions & 58 deletions content/splitbrowser/splitbrowser.js
Expand Up @@ -46,6 +46,14 @@ var SplitBrowser = {
return document.getElementById('splitbrowser-expandAll-broadcaster');
},
updateBroadcasters : function()
{
if (this.updateBroadcastersTimer) {
window.clearTimeout(this.updateBroadcastersTimer);
this.updateBroadcastersTimer = null;
}
this.updateBroadcastersTimer = window.setTimeout('SplitBrowser.updateBroadcastersCallback();', 1);
},
updateBroadcastersCallback : function()
{
if (!this.browsers.length) {
this.removeAllBroadcaster.setAttribute('disabled', true);
Expand All @@ -66,7 +74,6 @@ var SplitBrowser = {

if (collapsed && expanded) break;
}

if (collapsed)
this.expandAllBroadcaster.removeAttribute('disabled');
else
Expand All @@ -77,6 +84,8 @@ var SplitBrowser = {
else
this.collapseAllBroadcaster.setAttribute('disabled', true);
}

this.updateBroadcastersTimer = null;
},

POSITION_LEFT : 1,
Expand Down Expand Up @@ -465,15 +474,19 @@ var SplitBrowser = {
if (cont.previousSibling &&
cont.previousSibling.localName == 'splitter') {
box = cont.previousSibling.previousSibling;
box.height = box.boxObject.height + cont.boxObject.height;
cont.previousSibling.previousSibling.removeAttribute('collapsed');
if (box) {
box.height = box.boxObject.height + cont.boxObject.height;
box.removeAttribute('collapsed');
}
container.vContainer.removeChild(cont.previousSibling);
}
else if (cont.nextSibling &&
cont.nextSibling.localName == 'splitter') {
box = cont.nextSibling.nextSibling;
box.height = box.boxObject.height + cont.boxObject.height;
cont.nextSibling.nextSibling.removeAttribute('collapsed');
if (box) {
box.height = box.boxObject.height + cont.boxObject.height;
box.removeAttribute('collapsed');
}
container.vContainer.removeChild(cont.nextSibling);
}
container.vContainer.removeChild(cont);
Expand Down Expand Up @@ -504,14 +517,18 @@ var SplitBrowser = {
var box;
if (container.previousSibling && container.previousSibling.localName == 'splitter') {
box = container.previousSibling.previousSibling;
box.width = box.boxObject.width + container.boxObject.width;
container.previousSibling.previousSibling.removeAttribute('collapsed');
if (box) {
box.width = box.boxObject.width + container.boxObject.width;
box.removeAttribute('collapsed');
}
container.parentNode.removeChild(container.previousSibling);
}
else if (container.nextSibling && container.nextSibling.localName == 'splitter') {
box = container.nextSibling.nextSibling;
box.width = box.boxObject.width + container.boxObject.width;
container.nextSibling.nextSibling.removeAttribute('collapsed');
if (box) {
box.width = box.boxObject.width + container.boxObject.width;
box.removeAttribute('collapsed');
}
container.parentNode.removeChild(container.nextSibling);
}
container.parentNode.removeChild(container);
Expand Down Expand Up @@ -553,16 +570,16 @@ var SplitBrowser = {
for (var i = 0, maxi = this.browsers.length; i < maxi; i++)
{
if (!this.browsers[i].contentCollapsed)
this.browsers[i].toggleCollapsed(this.browsers[i].FORCE_COLLAPSE);
this.browsers[i].collapse();
}
},

expandAllSubBrowsers : function()
{
for (var i = this.browsers.length -1; i > -1; i--)
for (var i = 0, maxi = this.browsers.length; i < maxi; i++)
{
if (this.browsers[i].contentCollapsed)
this.browsers[i].toggleCollapsed(this.browsers[i].FORCE_EXPAND);
this.browsers[i].expand(true);
}
},

Expand All @@ -576,9 +593,8 @@ var SplitBrowser = {

getContainerState : function(aContainer)
{
var state = {
children : []
};
var state = {};
state.children = [];

var hContainer = aContainer.hContainer;
if (hContainer) {
Expand Down Expand Up @@ -606,7 +622,9 @@ var SplitBrowser = {
};
}
else {
state.content = this.getContainerState(originalContent);
state.children.push(this.getContainerState(originalContent));
state.children[state.children.length-1].position = this.POSITION_RIGHT;
state.children[state.children.length-1].width = originalContent.boxObject.width;
}

var node = originalContent.previousSibling;
Expand Down Expand Up @@ -658,7 +676,9 @@ var SplitBrowser = {
state.content.lastHeight = aContainer.lastheight;
}
else if (!state.content) {
state.content = this.getContainerState(originalContent);
state.children.push(this.getContainerState(originalContent));
state.children[state.children.length-1].position = this.POSITION_BOTTOM;
state.children[state.children.length-1].height = originalContent.boxObject.height;
}

var node = originalContent.previousSibling;
Expand Down Expand Up @@ -819,6 +839,7 @@ var SplitBrowser = {
eval('state = '+state);
}
catch(e) {
alert(e+'\n\n'+state);
return;
}

Expand All @@ -827,41 +848,52 @@ var SplitBrowser = {

buildContent : function(aState, aContainer)
{
switch (aState.content.type)
{
case 'root':
aContainer.contentWrapper.width = aState.content.width;
aContainer.contentWrapper.height = aState.content.height;
break;

default:
case 'subbrowser':
if (aState.content.history) {
aState.content.histories = [aState.content.history];
}
var content;
if (aState.content && aState.content.type) {
switch (aState.content.type)
{
case 'root':
aContainer.contentWrapper.width = aState.content.width;
aContainer.contentWrapper.height = aState.content.height;
content = aContainer.contentWrapper;
break;

var b = this.createSubBrowser(
aState.content.histories && aState.content.histories.length ? null : aState.content.uri
);
aContainer.hContainer.appendChild(b);
aContainer.hContainer.width = aState.content.width;
aContainer.hContainer.height = aState.content.height;
case 'subbrowser':
if (aState.content.history) {
aState.content.histories = [aState.content.history];
}

this.deserializeBrowserState(b.browser, aState.content);
var b = this.createSubBrowser(
aState.content.histories && aState.content.histories.length ? null : aState.content.uri
);
aContainer.hContainer.appendChild(b);
aContainer.hContainer.width = aState.content.width;
aContainer.hContainer.height = aState.content.height;

this.deserializeBrowserState(b.browser, aState.content);

aContainer.lastwidth = aState.content.lastWidth;
aContainer.lastheight = aState.content.lastHeight;
/*
if (aState.content.collapsed) {
if (aState.position & this.POSITION_HORIZONTAL)
aContainer.setAttribute('maxwidth', 0);
else
aContainer.setAttribute('maxheight', 0);
}
*/

aContainer.lastwidth = aState.content.lastWidth;
aContainer.lastheight = aState.content.lastHeight;
/*
if (aState.content.collapsed) {
aContainer.contentCollapsed = true;
if (aState.position & this.POSITION_HORIZONTAL)
aContainer.setAttribute('maxwidth', 0);
else
aContainer.setAttribute('maxheight', 0);
}
*/
content = b;
break;

break;
default:
break;
}
}
if (!content) {
content = document.createElement('spacer');
content.setAttribute('flex', 1);
aContainer.hContainer.appendChild(content);
}

var container;
Expand All @@ -872,7 +904,7 @@ var SplitBrowser = {
container = this.addContainerTo(
aContainer,
aState.children[i].position,
null,
content,
aState.children[i].width,
aState.children[i].height
);
Expand All @@ -881,8 +913,13 @@ var SplitBrowser = {
this.buildContent(aState.children[i], container);
}

if (!aContainer.hContainer.hasChildNodes()) {
aContainer.vContainer.removeChild(aContainer.hContainer);
if (content && content.localName == 'spacer') {
if (content.nextSibling)
aContainer.hContainer.removeChild(content.nextSibling);
else if (content.previousSibling)
aContainer.hContainer.removeChild(content.previousSibling);
aContainer.hContainer.removeChild(content);
this.cleanUpContainer(aContainer);
}
},

Expand Down Expand Up @@ -1239,10 +1276,10 @@ catch(e) {
updateSplitterSideBoxes : function(aEvent, aProp)
{
var splitter = aEvent.originalTarget || aEvent.target;
this.updateSplitterSideBox(splitter.previousSibling, aEvent, aProp);
this.updateSplitterSideBox(splitter.nextSibling, aEvent, aProp);
this.updateSplitterSideBox(splitter, splitter.previousSibling, aEvent, aProp);
this.updateSplitterSideBox(splitter, splitter.nextSibling, aEvent, aProp);
},
updateSplitterSideBox : function(aNode, aEvent, aProp)
updateSplitterSideBox : function(aSplitter, aNode, aEvent, aProp)
{
if (aEvent.type == 'mousedown') {
aNode.splitterDragging = true;
Expand All @@ -1252,11 +1289,11 @@ catch(e) {
else {
aNode['tempLast'+aProp] = -1;
}
aNode.contentCollapsed = false;
aNode.removeAttribute('max'+aProp);
}
else {
if (aNode.contentCollapsed &&
var cCProp = aProp == 'width' ? 'hContentCompletelyCollapsed' : 'vContentCompletelyCollapsed' ;
if (aNode[cCProp] &&
aNode['tempLast'+aProp] !== void(0) &&
aNode['tempLast'+aProp] > -1 &&
(
Expand All @@ -1265,20 +1302,23 @@ catch(e) {
)
) {
aNode['last'+aProp] = aNode['tempLast'+aProp];
aNode.contentCollapsed = true;
aNode.setAttribute('max'+aProp, 0);
}
aNode['tempLast'+aProp] = -1;
window.setTimeout(function() {
aNode.splitterDragging = false;
}, 0);
}

for (var i = 0, maxi = aNode.childNodes.length; i < maxi; i = i+2)
{
this.updateSplitterSideBox(aSplitter, aNode.childNodes[i], aEvent, aProp);
}
},

updateSplitterContextMenu : function()
{
var c = this.getSplitterTarget(document.popupNode);
alert(c);
if (!c) return;

var popup = document.getElementById('subbrowser-splitter-contextmenu');
Expand Down

0 comments on commit 784fee7

Please sign in to comment.