Bugfix : la connexion Solr peut se volatiliser plus vite que le hook de transaction…
[Plinn.git] / skins / ajax_scripts / palette.js
1 // (c) Benoît PIN 2006
2 // http://plinn.org
3 // Licence GPL
4 //
5 //
6
7
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';};
18
19 toggleButton.onclick = function(evt) {
20 if (thisInspector.expanded)
21 thisInspector.collapse();
22 else
23 thisInspector.expand();
24 disableDefault(evt);
25 disablePropagation(evt);
26 toggleButton.parentNode.blur();
27 };
28 }
29
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++) {
33 img = new Image();
34 img.src = this.baseUrl + '/' + images[i];
35 }
36 }
37
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);
44 this.onExpand(this);
45 this.expanded = true;
46 }
47
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;
56 }