1 // (c) BenoƮt PIN 2006
4 // $Id: palette.js 1548 2010-01-09 09:28:53Z pin $
5 // $URL: http://svn.cri.ensmp.fr/svn/Plinn/branches/CMF-2.1/skins/ajax_scripts/palette.js $
8 function InspectorPalette(baseUrl
, toggleButton
, contentNode
, onExpand
, onCollapse
) {
9 var thisInspector
= this;
10 this._preloadImages();
11 this.baseUrl
= baseUrl
;
12 this.toggleButton
= toggleButton
;
13 this.toggleButton
.src
= baseUrl
+ '/collapsedPalette.gif';
14 this.contentNode
= contentNode
;
15 this.expanded
= false;
16 this.onExpand
= onExpand
? onExpand : function(){thisInspector
.contentNode
.innerHTML
='expanded';};
17 this.onCollapse
= onCollapse
? onCollapse : function(){thisInspector
.contentNode
.innerHTML
='collapsed';};
19 toggleButton
.onclick = function(evt
) {
20 if (thisInspector
.expanded
)
21 thisInspector
.collapse();
23 thisInspector
.expand();
25 disablePropagation(evt
);
26 toggleButton
.parentNode
.blur();
30 InspectorPalette
.prototype._preloadImages = function() {
31 var images
= ['expandPalette.gif', 'collapsePalette.gif', 'expandedPalette.gif', 'collapsedPalette.gif' ], img
;
32 for (var i
=0 ; i
<images
.lenght
; i
++) {
34 img
.src
= this.baseUrl
+ '/' + images
[i
];
38 InspectorPalette
.prototype.expand = function() {
39 var toggleButton
= this.toggleButton
;
40 if (toggleButton
.blur
) toggleButton
.blur();
41 toggleButton
.src
= this.baseUrl
+ '/expandPalette.gif';
42 var staticButtonSrc
= this.baseUrl
+ '/expandedPalette.gif';
43 window
.setTimeout(function(){toggleButton
.src
= staticButtonSrc
;}, 500);
48 InspectorPalette
.prototype.collapse = function() {
49 var toggleButton
= this.toggleButton
;
50 if (toggleButton
.blur
) toggleButton
.blur();
51 toggleButton
.src
= this.baseUrl
+ '/collapsePalette.gif';
52 var staticButtonSrc
= this.baseUrl
+ '/collapsedPalette.gif';
53 window
.setTimeout(function(){toggleButton
.src
= staticButtonSrc
;}, 500);
54 this.onCollapse(this);
55 this.expanded
= false;