~ubuntu-branches/ubuntu/hardy/gallery2/hardy-security

« back to all changes in this revision

Viewing changes to themes/hybrid/hybrid.js

  • Committer: Bazaar Package Importer
  • Author(s): Michael C. Schultheiss
  • Date: 2006-04-16 16:42:35 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060416164235-8uy0u4bfjdxpge2o
Tags: 2.1.1-1
* New upstream release (Closes: #362936)
  + Bugfixes for Postgres7 (Closes: #359000, #362152)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/****************************
2
2
 * Hybrid theme for Gallery2
3
3
 * @author Alan Harder <alan.harder@sun.com>
4
 
 * $Revision: 1.3 $ $Date: 2005/08/17 14:46:14 $
 
4
 * $Revision: 1.10 $ $Date: 2005/10/14 18:29:18 $
5
5
 */
6
6
 
7
7
//Class app
23
23
  app_body = document.getElementById('hybridMain');
24
24
  while (app_body && app_body.tagName != 'BODY') app_body = app_body.parentNode;
25
25
  if (app_is_ie) app_body = app_body.parentNode;
26
 
  app_onresize();
27
26
  imagearea = document.getElementById('imagearea');
28
27
  imagediv = document.getElementById('imagediv');
29
28
  textdiv = document.getElementById('textdiv');
30
29
 
 
30
  // Replace <object> (XHTML compliant) with <iframe>
 
31
  // Currently <object> works only with Mozilla and Opera.  IE doesn't accept
 
32
  // any object.data changes, Safari only accepts new data src when object is
 
33
  // visible, Firefox only when object is invisible.  Easier to just use iframe.
 
34
  var popup = document.getElementById('popup_details'), iframe = document.createElement('iframe');
 
35
  iframe.frameBorder = 0;
 
36
  popup.replaceChild(iframe, popup.firstChild);
 
37
 
31
38
  document.onkeypress = app_onkeypress;
32
39
  if (window.attachEvent) window.attachEvent("onresize", app_onresize);
33
40
  else if (window.addEventListener) window.addEventListener("resize", app_onresize, false);
35
42
  if (app_is_ie) {
36
43
    document.onkeydown = app_onkeydown;
37
44
    document.getElementById('imageview').style.position = 'absolute';
38
 
    document.getElementById('popup_details').style.position = 'absolute';
 
45
    popup.style.position = 'absolute';
39
46
    document.getElementById('popup_titlebar').style.position = 'absolute';
40
47
  } else if (app_is_safari) {
41
48
    document.getElementById('tools_right').style.paddingRight = '8px';
42
49
  }
43
50
 
 
51
  app_onresize();
44
52
  var i = app_getcookie();
45
53
  if (i >= 0) image_show(i);
46
54
}
69
77
  var d = new Date(), c = slide_order + ';' + (slide_delay/1000) + ';' + sidebar_on + ';' +
70
78
    album_detailson + ';' + album_itemlinkson + ';' + text_on + ';';
71
79
  d.setTime(d.getTime() + 90*24*60*60*1000); // 90 day cookie
72
 
  document.cookie = 'G2_hybrid=' + escape(c) + ';expires=' + d.toUTCString();
 
80
  document.cookie = 'G2_hybrid=' + escape(c) + ';path=' + cookie_path + ';expires=' + d.toUTCString();
73
81
}
74
82
function app_getcookie() {
75
83
  var c = getcookie('G2_hybrid'), i,j,v,n,it=1,r=-1;
80
88
      switch (it++) {
81
89
        case 1: ui_select('slide_order', n); slide_setorder(n); break;
82
90
        case 2: ui_select('slide_delay', n); slide_setdelay(n); break;
83
 
        case 3: if (!n) sidebar_onoff(); break;
 
91
        case 3: if (n) sidebar_onoff(); break;
84
92
        case 4: if (!n) album_detailsonoff(); break;
85
 
        case 5: if (!n) album_itemlinksonoff(); break;
 
93
        case 5: if (n) album_itemlinksonoff(); break;
86
94
        case 6: if (n) text_onoff(); break;
87
95
      }
88
96
    }
105
113
    case 63235: keyCode=39; break;  case 63277: keyCode=34; break;
106
114
  }
107
115
  /* Album view: space = start slideshow
 
116
   *             ctrl-right/left = show/hide sidebar
 
117
   *             ctrl-up/down = show/hide item links
108
118
   * Image view: space = start/pause slideshow
109
119
   *             escape = return to album view
110
120
   *             left/right = next/prev image
116
126
   */
117
127
  if (keyCode==32) slide_onoff();
118
128
  else if (keyCode==27) { if (popup_on) popup_vis(0); else if (image_on) image_vis(0); }
119
 
  if (!image_on || keyCode < 33 || keyCode > 40) return;
 
129
  if (keyCode < 33 || keyCode > 40) return;
120
130
  if (event.shiftKey) keyCode += 100;
121
131
  if (event.ctrlKey) keyCode += 200;
122
 
  switch (keyCode) {
 
132
  if (!image_on) switch (keyCode) {
 
133
    case 239: //Ctrl-Right
 
134
      if (!sidebar_on) sidebar_onoff();
 
135
      break;
 
136
    case 237: //Ctrl-Left
 
137
      if (sidebar_on) sidebar_onoff();
 
138
      break;
 
139
    case 238: //Ctrl-Up
 
140
      if (!album_itemlinkson) album_itemlinksonoff();
 
141
      break;
 
142
    case 240: //Ctrl-Down
 
143
      if (album_itemlinkson) album_itemlinksonoff();
 
144
      break;
 
145
  }
 
146
  else switch (keyCode) {
123
147
    case 37: //Left
124
148
      if (image_zoomon) { imagearea.scrollLeft -= 20; break; }
125
149
    case 137: //Shift-Left
163
187
 
164
188
//Class album :: gsContent(album_titlebar(album_tools,album_desc,album_info),gsAlbumContent)
165
189
var album_detailson=1, // Details are visible
166
 
    album_itemlinkson=1, // Item links are visible
 
190
    album_itemlinkson=0, // Item links are visible
167
191
    album_fixedtitle=0; // Using fixed position for album_titlebar
168
192
function album_detailsonoff() {
169
193
  ui_vis('album_info', (album_detailson = album_detailson?0:1));
176
200
  album_itemlinkson = album_itemlinkson?0:1;
177
201
  for (var i = 0; i < imgs.length; i++)
178
202
    if (imgs[i].className == 'popup_button')
179
 
      imgs[i].style.visibility = album_itemlinkson ? 'visible' : 'hidden';
 
203
      imgs[i].style.display = album_itemlinkson ? 'inline' : 'none';
180
204
  ui_sethtml('lnk_link', album_itemlinkson ? album_hidelinks : album_showlinks);
181
205
}
182
206
function album_setfixedtitle() {
194
218
}
195
219
 
196
220
//Class sidebar :: div sidebar
197
 
var sidebar_on=1; // Sidebar is visible
 
221
var sidebar_on=0; // Sidebar is visible
198
222
function sidebar_onoff() {
199
223
  ui_vis('sidebar_max', sidebar_on, 1);
200
224
  ui_vis('sidebar_min', (sidebar_on = sidebar_on?0:1), 1);
208
232
    image_cache = new Image, // For precaching an image
209
233
    image_iscached = new Array(data_count), // Track precached images
210
234
    imagearea, imagediv, textdiv, // Containers
211
 
    text_on=0; // Description text is visible
 
235
    text_on=0, // Description text is visible
 
236
    text_empty=0; // Description text is empty
212
237
function image_setsize() {
213
238
  imagearea.style.height = (app_wh - textdiv.offsetHeight) + 'px';
214
239
}
234
259
  slide_reset();
235
260
  image_index = i;
236
261
  ui_sethtml('title', document.getElementById('title_'+image_index).innerHTML);
 
262
  ui_sethtml('date', document.getElementById('date_'+image_index).innerHTML);
237
263
  image_setsize();
238
264
  if (data_iw[i] < 0) {
239
265
    imagediv.innerHTML = '<iframe style="width:100%;height:' + (imagearea.offsetHeight - 4)
292
318
  }
293
319
}
294
320
function image_loaded() {
295
 
  var i = slide_nextindex(); if (i >= 0) image_precache(i);
 
321
  var i = slide_nextindex(); if (i < 0 || image_iscached[i]) i = slide_previndex();
 
322
  if (i >= 0) image_precache(i);
296
323
  slide_go(i);
297
324
}
298
325
function image_next() {
307
334
  ui_vis('next_off', i < 0, 1);
308
335
  ui_vis('prev_img', j >= 0, 1);
309
336
  ui_vis('prev_off', j < 0, 1);
 
337
  text_empty = document.getElementById('text_'+image_index).innerHTML ?0:1;
 
338
  if (!text_on) {
 
339
    ui_vis('text_on', !text_empty, 1);
 
340
    ui_vis('text_none', text_empty, 1);
 
341
  }
310
342
}
311
343
function text_onoff() {
312
344
  if ((text_on = text_on?0:1) && data_count > 0) text_fill();
313
 
  ui_vis('text_on', !text_on, 1);
 
345
  ui_vis(text_empty ? 'text_none' : 'text_on', !text_on, 1);
314
346
  ui_vis('text_off', text_on, 1);
315
347
  ui_vis('text', text_on);
316
348
  if (image_on) { image_setsize(); image_fit(); }
366
398
  }
367
399
}
368
400
function slide_setbuttons() {
 
401
  if (!data_count) return;
369
402
  ui_vis('slide_poz', slide_on, 1);
370
403
  ui_vis('slide_fwd', (!slide_on && slide_order > 0), 1);
371
404
  ui_vis('slide__fwd', (slide_order > 0), 1);
433
466
  pop.style.visibility = 'visible';
434
467
}
435
468
function popup_info(i) {
436
 
  if (window.frames.length) {
437
 
    window.frames[0].document.location.replace(
438
 
      document.getElementById('info_' + (i >= 0 ? i : image_index)).href);
439
 
  } else { //For Safari
440
 
    document.getElementById('popup_details').firstChild.src =
441
 
      document.getElementById('info_' + (i >= 0 ? i : image_index)).href;
442
 
  }
 
469
  var o = document.getElementById('popup_details').firstChild,
 
470
      href = document.getElementById('info_' + (i >= 0 ? i : image_index)).href;
 
471
  o.src = href;  // See app_init; use o.data = href if browsers ever support object.
443
472
  popup_vis(1);
444
473
}
445
474
function popup_vis(on) {