~ubuntu-branches/ubuntu/saucy/horde3/saucy

« back to all changes in this revision

Viewing changes to templates/javascript/form_sections.js

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2005-05-04 23:08:08 UTC
  • Revision ID: james.westby@ubuntu.com-20050504230808-p4hf3hk28o3v7wir
Tags: upstream-3.0.4
ImportĀ upstreamĀ versionĀ 3.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Horde Form Sections Javascript Class
 
3
 *
 
4
 * Provides the javascript class for handling tabbed sections in Horde Forms.
 
5
 *
 
6
 * Copyright 2003-2005 Marko Djukic <marko@oblo.com>
 
7
 *
 
8
 * See the enclosed file COPYING for license information (LGPL). If you did not
 
9
 * receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 
10
 *
 
11
 * $Horde: horde/templates/javascript/form_sections.js,v 1.11.4.1 2005/01/03 12:25:46 jan Exp $
 
12
 *
 
13
 * @author  Marko Djukic <marko@oblo.com>
 
14
 * @version $Revision: 1.11.4.1 $
 
15
 * @package Horde_Form
 
16
 */
 
17
function Horde_Form_Sections(instanceName, openSection)
 
18
{
 
19
    /* Set up this class instance for function calls from the page. */
 
20
    this._instanceName = instanceName;
 
21
 
 
22
    /* The currently showed section. */
 
23
    var _openSection;
 
24
 
 
25
    this.toggle = function(sectionId)
 
26
    {
 
27
        /* Get the currently open section object. */
 
28
        openSectionId = this._get();
 
29
        if (document.getElementById('_section_' + openSectionId)) {
 
30
            document.getElementById('_section_' + openSectionId).style.display = 'none';
 
31
            document.getElementById('_tab_' + openSectionId).className = null;
 
32
        }
 
33
 
 
34
        /* Get the newly opened section object. */
 
35
        if (document.getElementById('_section_' + sectionId)) {
 
36
            document.getElementById('_section_' + sectionId).style.display = 'block';
 
37
            document.getElementById('_tab_' + sectionId).className = 'activeTab';
 
38
        }
 
39
 
 
40
        /* Store the newly opened section. */
 
41
        this._set(sectionId);
 
42
    }
 
43
 
 
44
    this._get = function()
 
45
    {
 
46
        return this._openSection;
 
47
    }
 
48
 
 
49
    this._set = function(sectionId)
 
50
    {
 
51
        var form = eval('document.' + this._instanceName);
 
52
        if (typeof form != 'undefined') {
 
53
            form.__formOpenSection.value = escape(sectionId);
 
54
        }
 
55
        this._openSection = sectionId;
 
56
    }
 
57
 
 
58
    this._set(openSection);
 
59
}