4 // $Id: palette.js 1315 2008-07-29 15:36:15Z 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
);
29 InspectorPalette
.prototype._preloadImages = function() {
30 var images
= ['expandPalette.gif', 'collapsePalette.gif', 'expandedPalette.gif', 'collapsedPalette.gif' ], img
;
31 for (var i
=0 ; i
<images
.lenght
; i
++) {
33 img
.src
= this.baseUrl
+ '/' + images
[i
];
37 InspectorPalette
.prototype.expand = function() {
38 var toggleButton
= this.toggleButton
;
39 if (toggleButton
.blur
) toggleButton
.blur();
40 toggleButton
.src
= this.baseUrl
+ '/expandPalette.gif';
41 var staticButtonSrc
= this.baseUrl
+ '/expandedPalette.gif';
42 window
.setTimeout(function(){toggleButton
.src
= staticButtonSrc
;}, 500);
47 InspectorPalette
.prototype.collapse = function() {
48 var toggleButton
= this.toggleButton
;
49 if (toggleButton
.blur
) toggleButton
.blur();
50 toggleButton
.src
= this.baseUrl
+ '/collapsePalette.gif';
51 var staticButtonSrc
= this.baseUrl
+ '/collapsedPalette.gif';
52 window
.setTimeout(function(){toggleButton
.src
= staticButtonSrc
;}, 500);
53 this.onCollapse(this);
54 this.expanded
= false;