~malept/loggerhead/standalone-auth

« back to all changes in this revision

Viewing changes to loggerhead/static/javascript/custom.js

  • Committer: Martin Albisetti
  • Date: 2008-07-22 00:40:03 UTC
  • mfrom: (182 loggerhead.search_integration)
  • mto: This revision was merged to the branch mainline in revision 187.
  • Revision ID: argentina@gmail.com-20080722004003-lx1fp0tthpp6kl92
Merged from trunk, resolved billions of conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
var Colapsable = new Class({
2
 
    initialize: function(item,expand_icon,open_content,close_content,is_open)
3
 
    {
4
 
        this.is_open = false;
5
 
        if ($defined(is_open))
6
 
        {
7
 
            this.is_open = is_open;
8
 
        }
9
 
        this.item = item;
10
 
        item.set('colapsable',this);
11
 
        this.open_content  = open_content;
12
 
        this.close_content = close_content;
13
 
        this.expand_icon   = expand_icon;
14
 
 
15
 
        var expander = new Fx.Slide(this.item, { duration: 200 } );
16
 
        if (!this.is_open)
17
 
        {
18
 
            expander.hide();
19
 
            if ($defined(this.expand_icon))
20
 
            {
21
 
                this.expand_icon.set('src',this.expand_icon.title);
22
 
            }
23
 
        }
24
 
        else
25
 
        {
26
 
            if ($defined(this.expand_icon))
27
 
            {
28
 
                this.expand_icon.set('src',this.expand_icon.alt);
29
 
            }
30
 
        }
31
 
    },
32
 
 
33
 
    open: function()
34
 
    {
35
 
        this.item.setStyle('display', 'block');
36
 
        var expander = this.item.get('slide');
37
 
        expander.slideIn();
38
 
        if ($defined(this.open_content))
39
 
        {
40
 
            for (var i=0;i<this.open_content.length;++i)
41
 
            {
42
 
                this.open_content[i].setStyle('display','block');
43
 
            }
44
 
                }
45
 
                
46
 
        if ($defined(this.close_content))
47
 
        {
48
 
            for (var i=0;i<this.close_content.length;++i)
49
 
            {
50
 
                this.close_content[i].setStyle('display','none');
51
 
            }
52
 
        }
53
 
 
54
 
        if ($defined(this.expand_icon))
55
 
        {
56
 
            this.expand_icon.set('src',this.expand_icon.alt);
57
 
        }
58
 
        this.is_open = true;
59
 
    },
60
 
 
61
 
    close: function()
62
 
    {
63
 
        var expander = this.item.get('slide');
64
 
        expander.slideOut();
65
 
        if ($defined(this.open_content))
66
 
        {
67
 
            for (var i=0;i<this.open_content.length;++i)
68
 
            {
69
 
                this.open_content[i].setStyle('display','none');
70
 
            }
71
 
        }
72
 
 
73
 
        if ($defined(this.close_content))
74
 
        {
75
 
            for (var i=0;i<this.close_content.length;++i)
76
 
            {
77
 
                this.close_content[i].setStyle('display','block');
78
 
            }
79
 
        }
80
 
        if ($defined(this.expand_icon))
81
 
        {
82
 
            this.expand_icon.set('src',this.expand_icon.title);
83
 
        }
84
 
        this.is_open = false;
85
 
    },
86
 
 
87
 
    isOpen : function()
88
 
    {
89
 
        return this.is_open;
90
 
    },
91
 
 
92
 
    toggle: function()
93
 
    {
94
 
        if (this.isOpen())
95
 
        {
96
 
            this.close();
97
 
        }
98
 
        else
99
 
        {
100
 
            this.open();
101
 
        }
102
 
    }
103
 
    });
104
 
 
105
 
 
106
 
window.addEvent('domready', function()
107
 
{
108
 
    $$('.revision_log').each(function(item, i)
109
 
    {
110
 
        var item_slide = item.getElement('.revisioninfo');
111
 
        var open_content  = new Array();
112
 
        var close_content = new Array();
113
 
        open_content.push(item.getElement('.long_description'));
114
 
        close_content.push(item.getElement('.short_description'));
115
 
        var expand_icon = item.getElement('.expand_icon');
116
 
        var colapsable = new Colapsable(item_slide,expand_icon,open_content,close_content);
117
 
        
118
 
        item.getElement('.expand_revisioninfo').addEvent('click',function(){colapsable.toggle();});
119
 
        item.colapsable = colapsable;
120
 
    });
121
 
 
122
 
    $$('.diffBox').each(function(item, i)
123
 
    {
124
 
        var item_slide = item.getNext('.diffinfo');
125
 
        var expand_icon = item.getElement( '.expand_diff' );
126
 
        var colapsable = new Colapsable(item_slide,expand_icon,null,null,true);
127
 
        item.getElement( '.expand_diff' ).addEvent( 'click', function(){colapsable.toggle();});
128
 
        item.colapsable=colapsable;
129
 
    });
130
 
});
131
 
 
132
 
function toggle_expand_all(action)
133
 
{
134
 
    $$('.revision_log').each(function(item, i)
135
 
    {
136
 
        var colapsable = item.colapsable;
137
 
        if(action == 'close')
138
 
        {
139
 
            $('expand_all').setStyle('display','block');
140
 
            $('collapse_all').setStyle('display','none');
141
 
            colapsable.close();
142
 
        }
143
 
        else if(action == 'open')
144
 
        {
145
 
            $('expand_all').setStyle('display','none');
146
 
            $('collapse_all').setStyle('display','block');
147
 
            colapsable.open();
148
 
        }
149
 
    });
150
 
}
151
 
 
152
 
function toggle_expand_all_revisionview(action)
153
 
{
154
 
    $$('.diffBox').each(function(item, i)
155
 
    {
156
 
        var colapsable = item.colapsable;
157
 
        if(action == 'close')
158
 
        {
159
 
            $('expand_all').setStyle('display','block');
160
 
            $('collapse_all').setStyle('display','none');
161
 
            colapsable.close();
162
 
        }
163
 
        else if(action == 'open')
164
 
        {
165
 
            $('expand_all').setStyle('display','none');
166
 
            $('collapse_all').setStyle('display','block');
167
 
            colapsable.open();
168
 
        }
169
 
    });
170
 
}
171