source: branches/new-datamodel/src/ajax/javascripts/navi.js

Last change on this file was 50, checked in by lgiessmann, 15 years ago

ajax-client: fixed the following bugs: (1) by requesting all needed topicStubs now there will be requested the instanceOf-topics, too. (2) by showing the "loading"-.GIF and changing the sub-page at the same time - the .Gif will be first set to the initial state, so it won't be removed accidentally anymore. (3) the fragment will be REALLY sent to the server - the "onSuccessFun" will be executed after a succeeded validation. (4) after a bad validation there appears an alert-window with a corresponding message, the same behaviour occurrs by sending the data to the server

File size: 2.4 KB
Line 
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
14function 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".
28function 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
39function 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
68document.observe("dom:loaded", addHandlersToNavi);
Note: See TracBrowser for help on using the repository browser.