1 | //+----------------------------------------------------------------------------- |
---|
2 | //+ Isidorus |
---|
3 | //+ (c) 2008-2009 Marc Kuester, Christoph Ludwig, Lukas Giessmann |
---|
4 | //+ |
---|
5 | //+ Isidorus is freely distributable under the LGPL license. |
---|
6 | //+ This ajax module uses the frameworks PrototypeJs and Scriptaculous, both |
---|
7 | //+ are distributed under the MIT license. |
---|
8 | //+ You can find a detailed description in trunk/docs/LGPL-LICENSE.txt and |
---|
9 | //+ in trunk/src/ajax/javascripts/external/MIT-LICENSE.txt |
---|
10 | //+----------------------------------------------------------------------------- |
---|
11 | |
---|
12 | |
---|
13 | // --- adds some event handlers to the navigation elements |
---|
14 | function addHandlersToNavi() |
---|
15 | { |
---|
16 | $(PAGES.home).observe("click", function(event){ setNaviClasses(event.element()); makePage(PAGES.home, ""); }); |
---|
17 | $(PAGES.search).observe("click", function(event){ setNaviClasses(event.element()); makePage(PAGES.search, ""); }); |
---|
18 | $(PAGES.edit).observe("click", function(event){ setNaviClasses(event.element()); makePage(PAGES.edit, ""); }); |
---|
19 | $(PAGES.create).observe("click", function(event){ setNaviClasses(event.element()); makePage(PAGES.create, ""); }); |
---|
20 | |
---|
21 | // --- necessary for the first call of the page |
---|
22 | makePage(PAGES.home, ""); |
---|
23 | } |
---|
24 | |
---|
25 | |
---|
26 | // --- Sets the classes of all navi-elements to the default class. |
---|
27 | // --- The currently clicked element is set to "isActive". |
---|
28 | function setNaviClasses(activeNaviElement) |
---|
29 | { |
---|
30 | $(PAGES.home).writeAttribute({"class" : "clickableButton"}); |
---|
31 | $(PAGES.search).writeAttribute({"class" : "clickableButton"}); |
---|
32 | $(PAGES.edit).writeAttribute({"class" : "clickableButton"}); |
---|
33 | $(PAGES.create).writeAttribute({"class" : "clickableButton"}); |
---|
34 | activeNaviElement.writeAttribute({"class" : "isActive"}); |
---|
35 | } |
---|
36 | |
---|
37 | |
---|
38 | // --- generates the current page depending on the variable __currentPage |
---|
39 | function makePage(newPage, psi) |
---|
40 | { |
---|
41 | // --- if there is called the subpage which is already displayed |
---|
42 | // --- there will be done nothing! |
---|
43 | if(newPage === PAGES.current) return; |
---|
44 | PAGES.current = newPage; |
---|
45 | |
---|
46 | // --- removes the old content |
---|
47 | hideLoad(); // to prevent the load-gif of beeing removed when it is used in the error-div |
---|
48 | $(CLASSES.subPage()).update(); |
---|
49 | |
---|
50 | // --- creates the new content |
---|
51 | switch(newPage){ |
---|
52 | case PAGES.home: |
---|
53 | makeHome(); |
---|
54 | break; |
---|
55 | case PAGES.search: |
---|
56 | makeSearch(psi); |
---|
57 | break; |
---|
58 | case PAGES.edit: |
---|
59 | makeEdit(psi) |
---|
60 | break; |
---|
61 | case PAGES.create: |
---|
62 | makeCreate(psi); |
---|
63 | break; |
---|
64 | } |
---|
65 | } |
---|
66 | |
---|
67 | |
---|
68 | document.observe("dom:loaded", addHandlersToNavi); |
---|