~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

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

  • Committer: Martin Albisetti
  • Date: 2008-07-17 04:20:22 UTC
  • mfrom: (128.10.33 loggerhead.search)
  • Revision ID: argentina@gmail.com-20080717042022-x0fw8v2jl5fq8hcr
Merge bzr-search integration

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
{
64
64
    hide_div = setTimeout("$('search_terms').setStyle('display','none')", 300);
65
65
}
66
 
var Colapsable = new Class({
67
 
    initialize: function(item,expand_icon,open_content,close_content,is_open)
68
 
    {
69
 
        this.is_open = false;
70
 
        if ($defined(is_open))
71
 
        {
72
 
            this.is_open = is_open;
73
 
        }
74
 
        this.item = item;
75
 
        item.set('colapsable',this);
76
 
        this.open_content  = open_content;
77
 
        this.close_content = close_content;
78
 
        this.expand_icon   = expand_icon;
79
 
 
80
 
        var expander = new Fx.Slide(this.item, { duration: 200 } );
81
 
        if (!this.is_open)
82
 
        {
83
 
            expander.hide();
84
 
            if ($defined(this.expand_icon))
85
 
            {
86
 
                this.expand_icon.set('src',this.expand_icon.title);
87
 
            }
88
 
        }
89
 
        else
90
 
        {
91
 
            if ($defined(this.expand_icon))
92
 
            {
93
 
                this.expand_icon.set('src',this.expand_icon.alt);
94
 
            }
95
 
        }
96
 
    },
97
 
 
98
 
    open: function()
99
 
    {
100
 
        this.item.setStyle('display', 'block');
101
 
        var expander = this.item.get('slide');
102
 
        expander.slideIn();
103
 
        if ($defined(this.open_content))
104
 
        {
105
 
            for (var i=0;i<this.open_content.length;++i)
106
 
            {
107
 
                this.open_content[i].setStyle('display','block');
108
 
            }
109
 
                }
110
 
                
111
 
        if ($defined(this.close_content))
112
 
        {
113
 
            for (var i=0;i<this.close_content.length;++i)
114
 
            {
115
 
                this.close_content[i].setStyle('display','none');
116
 
            }
117
 
        }
118
 
 
119
 
        if ($defined(this.expand_icon))
120
 
        {
121
 
            this.expand_icon.set('src',this.expand_icon.alt);
122
 
        }
123
 
        this.is_open = true;
124
 
    },
125
 
 
126
 
    close: function()
127
 
    {
128
 
        var expander = this.item.get('slide');
129
 
        expander.slideOut();
130
 
        if ($defined(this.open_content))
131
 
        {
132
 
            for (var i=0;i<this.open_content.length;++i)
133
 
            {
134
 
                this.open_content[i].setStyle('display','none');
135
 
            }
136
 
        }
137
 
 
138
 
        if ($defined(this.close_content))
139
 
        {
140
 
            for (var i=0;i<this.close_content.length;++i)
141
 
            {
142
 
                this.close_content[i].setStyle('display','block');
143
 
            }
144
 
        }
145
 
        if ($defined(this.expand_icon))
146
 
        {
147
 
            this.expand_icon.set('src',this.expand_icon.title);
148
 
        }
149
 
        this.is_open = false;
150
 
    },
151
 
 
152
 
    isOpen : function()
153
 
    {
154
 
        return this.is_open;
155
 
    },
156
 
 
157
 
    toggle: function()
158
 
    {
159
 
        if (this.isOpen())
160
 
        {
161
 
            this.close();
162
 
        }
163
 
        else
164
 
        {
165
 
            this.open();
166
 
        }
167
 
    }
168
 
    });
169
 
 
170
 
 
171
 
window.addEvent('domready', function()
172
 
{
173
 
    $$('.revision_log').each(function(item, i)
174
 
    {
175
 
        var item_slide = item.getElement('.revisioninfo');
176
 
        var open_content  = new Array();
177
 
        var close_content = new Array();
178
 
        open_content.push(item.getElement('.long_description'));
179
 
        close_content.push(item.getElement('.short_description'));
180
 
        var expand_icon = item.getElement('.expand_icon');
181
 
        var colapsable = new Colapsable(item_slide,expand_icon,open_content,close_content);
182
 
        
183
 
        item.getElement('.expand_revisioninfo').addEvent('click',function(){colapsable.toggle();});
184
 
        item.colapsable = colapsable;
185
 
    });
186
 
 
187
 
    $$('.diffBox').each(function(item, i)
188
 
    {
189
 
        var item_slide = item.getNext('.diffinfo');
190
 
        var expand_icon = item.getElement( '.expand_diff' );
191
 
        var colapsable = new Colapsable(item_slide,expand_icon,null,null,true);
192
 
        item.getElement( '.expand_diff' ).addEvent( 'click', function(){colapsable.toggle();});
193
 
        item.colapsable=colapsable;
194
 
    });
195
 
});
196
 
 
197
 
function toggle_expand_all(action)
198
 
{
199
 
    $$('.revision_log').each(function(item, i)
200
 
    {
201
 
        var colapsable = item.colapsable;
202
 
        if(action == 'close')
203
 
        {
204
 
            $('expand_all').setStyle('display','block');
205
 
            $('collapse_all').setStyle('display','none');
206
 
            colapsable.close();
207
 
        }
208
 
        else if(action == 'open')
209
 
        {
210
 
            $('expand_all').setStyle('display','none');
211
 
            $('collapse_all').setStyle('display','block');
212
 
            colapsable.open();
213
 
        }
214
 
    });
215
 
}
216
 
 
217
 
function toggle_expand_all_revisionview(action)
218
 
{
219
 
    $$('.diffBox').each(function(item, i)
220
 
    {
221
 
        var colapsable = item.colapsable;
222
 
        if(action == 'close')
223
 
        {
224
 
            $('expand_all').setStyle('display','block');
225
 
            $('collapse_all').setStyle('display','none');
226
 
            colapsable.close();
227
 
        }
228
 
        else if(action == 'open')
229
 
        {
230
 
            $('expand_all').setStyle('display','none');
231
 
            $('collapse_all').setStyle('display','block');
232
 
            colapsable.open();
233
 
        }
234
 
    });
235
 
}
236