File: form_sections.js

package info (click to toggle)
php-horde 5.2.1%2Bdebian0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 12,196 kB
  • sloc: php: 11,089; xml: 6,460; sh: 96; makefile: 33; sql: 1
file content (58 lines) | stat: -rw-r--r-- 1,725 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
 * Provides the javascript class for handling tabbed sections in Horde Forms.
 *
 * @author     Marko Djukic <marko@oblo.com>
 * @copyright  2003-2014 Horde LLC
 * @license    LGPL-2 (http://www.horde.org/licenses/lgpl)
 */

function Horde_Form_Sections(instanceName, openSection)
{
    /* Set up this class instance for function calls from the page. */
    this._instanceName = instanceName;

    /* The currently showed section. */
    var _openSection, s;

    this.toggle = function(sectionId)
    {
        if (!document.getElementById) {
            return false;
        }

        /* Get the currently open section object. */
        openSectionId = this._get();
        s = document.getElementById(this._instanceName + '_section_' + openSectionId);
        if (s) {
            s.style.display = 'none';
            document.getElementById(this._instanceName + '_tab_' + openSectionId).className = null;
        }

        /* Get the newly opened section object. */
        s = document.getElementById(this._instanceName + '_section_' + sectionId);
        if (s) {
            s.style.display = '';
            document.getElementById(this._instanceName + '_tab_' + sectionId).className = 'horde-active';
        }

        /* Store the newly opened section. */
        this._set(sectionId);
    };

    this._get = function()
    {
        return this._openSection;
    };

    this._set = function(sectionId)
    {
        var form = document.getElementById(this._instanceName);
        if (form !== null &&
            typeof form.__formOpenSection != 'undefined') {
            form.__formOpenSection.value = sectionId;
        }
        this._openSection = sectionId;
    };

    this._set(openSection);
}