-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create XBL binding to simulate application windows
- Loading branch information
Jason Johnston
committed
Dec 28, 2005
1 parent
c8f1740
commit 8891bdd
Showing
3 changed files
with
171 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
.window { | ||
-moz-binding:url(Window.xml#Window); | ||
position:absolute; | ||
z-index:1; | ||
width:200px; | ||
height:200px; | ||
border:2px outset #FFF; | ||
background:#EEE; | ||
} | ||
|
||
.window-title-bar { | ||
-moz-binding:url(Window.xml#WindowTitleBar); | ||
margin:0; | ||
height:1.3em; | ||
padding:0 1em; | ||
background:#009; | ||
color:#FFF; | ||
font-weight:bold; | ||
cursor:default; | ||
white-space:nowrap; | ||
-moz-user-select:none; | ||
} | ||
|
||
.window-content { | ||
border:2px inset #FFF; | ||
overflow:auto; | ||
padding-left:4px; | ||
position:absolute; | ||
top:1.3em; | ||
left:0; | ||
right:0; | ||
bottom:0; | ||
z-index:2; | ||
} | ||
|
||
.window-resizer { | ||
-moz-binding:url(Window.xml#WindowResizer); | ||
position:absolute; | ||
right:-5px; | ||
bottom:-5px; | ||
width:16px; | ||
height:16px; | ||
z-index:1; | ||
border:solid #666; | ||
border-width:0 1px 1px 0; | ||
cursor:se-resize; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?xml version="1.0"?> | ||
<bindings xmlns="http://www.mozilla.org/xbl" | ||
xmlns:xbl="http://www.mozilla.org/xbl" | ||
xmlns:html="http://www.w3.org/1999/xhtml"> | ||
|
||
<binding id="Window"> | ||
<handlers> | ||
<handler event="mousedown"> | ||
// make z-index the highest by using the current time: | ||
this.style.zIndex = new Date().getTime(); | ||
</handler> | ||
</handlers> | ||
|
||
<content> | ||
<html:div class="window-title-bar" xbl:inherits="xbl:text=title"></html:div> | ||
<html:div class="window-resizer" /> | ||
<html:div class="window-content"> | ||
<children /> | ||
</html:div> | ||
</content> | ||
</binding> | ||
|
||
<binding id="WindowTitleBar"> | ||
<implementation> | ||
<field name="dragging">false</field> | ||
<field name="xOffset">0</field> | ||
<field name="yOffset">0</field> | ||
|
||
<method name="updatePosition"> | ||
<parameter name="event" /> | ||
<body><![CDATA[ | ||
var win = this.parentNode; | ||
win.style.left = (event.clientX + document.body.scrollLeft - this.xOffset) + "px"; | ||
win.style.top = (event.clientY + document.body.scrollTop - this.yOffset) + "px"; | ||
]]></body> | ||
</method> | ||
</implementation> | ||
<handlers> | ||
<handler event="mousedown"> | ||
this.xOffset = event.clientX + document.body.scrollLeft - parseFloat(getComputedStyle(this.parentNode, null).getPropertyValue("left")); | ||
this.yOffset = event.clientY + document.body.scrollTop - parseFloat(getComputedStyle(this.parentNode, null).getPropertyValue("top")); | ||
|
||
var thisRef = this; | ||
var moveListener = function(event) { | ||
thisRef.updatePosition(event); | ||
}; | ||
var clearListener = function() { | ||
window.removeEventListener("mousemove", moveListener, true); | ||
window.removeEventListener("mouseup", clearListener, true); | ||
}; | ||
window.addEventListener("mousemove", moveListener, true); | ||
window.addEventListener("mouseup", clearListener, true); | ||
</handler> | ||
</handlers> | ||
</binding> | ||
|
||
<binding id="WindowResizer"> | ||
<implementation> | ||
<field name="xStart">0</field> | ||
<field name="yStart">0</field> | ||
|
||
<method name="updateSize"> | ||
<parameter name="event" /> | ||
<body><![CDATA[ | ||
var winX = parseFloat(getComputedStyle(this.parentNode, null).getPropertyValue("left")); | ||
var winY = parseFloat(getComputedStyle(this.parentNode, null).getPropertyValue("top")); | ||
this.parentNode.style.width = (event.clientX + document.body.scrollLeft - winX) + "px"; | ||
this.parentNode.style.height = (event.clientY + document.body.scrollTop - winY) + "px"; | ||
]]></body> | ||
</method> | ||
</implementation> | ||
|
||
<handlers> | ||
<handler event="mousedown"> | ||
var thisRef = this; | ||
var moveListener = function(event) { | ||
thisRef.updateSize(event); | ||
}; | ||
var clearListener = function() { | ||
window.removeEventListener("mousemove", moveListener, true); | ||
window.removeEventListener("mouseup", clearListener, true); | ||
}; | ||
window.addEventListener("mousemove", moveListener, true); | ||
window.addEventListener("mouseup", clearListener, true); | ||
</handler> | ||
</handlers> | ||
</binding> | ||
|
||
</bindings> |