Changeset 2792
- Timestamp:
- 08/20/07 11:57:17 (1 year ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/thickbox_reloaded/jquery.thickbox.js
r2631 r2792 90 90 // reveal stuff 91 91 dim.unbind('click').one('click', hide); // unbind should be unnecessary - WTF? 92 if (dim.is(':visible')) { 93 loading.show(); 94 builder(); // build specific type 95 } else { 96 //dim.fadeIn('fast', function() { 97 dim.show(); 98 loading.show(); 99 builder(); // build specific type 100 //}); 101 } 92 if (!dim.is(':visible')) { 93 dim.show(); 94 } 95 loading.show(); 96 builder(); // build specific type 97 102 98 // attach keyboard event handler 103 99 $(document).bind('keydown', keydown).bind('keypress', blockKeys); … … 138 134 function hide(callback) { 139 135 136 // abort pending xhr request 140 137 if (request) { 141 138 request.abort(); … … 153 150 $(document).unbind('keydown', keydown).unbind('keypress', blockKeys); 154 151 $(window).unbind('scroll', blockScroll); 152 next = previous = function() {}; 155 153 return false; 156 154 } … … 171 169 } 172 170 171 var next = function() {}, previous = next; 173 172 function keydown(e) { 174 173 var key = e.which || e.keyCode || -1; 175 if (key == 27) { 176 hide(); 177 } else { 178 blockKeys(e); 174 switch (key) { 175 case 27: // esc 176 hide(); 177 break; 178 case 37: // arrow left 179 previous(); 180 break; 181 case 39: // arrow right 182 next(); 183 break; 184 default: 185 blockKeys(e); 179 186 } 180 187 } … … 251 258 }; 252 259 253 var next = '<strong id="' + TB_ID.NEXT + '"><a href="#" title="' + defaultValues.i18n.next.title + '">' + defaultValues.i18n.next.text + '</a></strong>'; 254 var showNext = buildShowFunc(group[i + 1] || group[0]); 255 256 var prev = '<strong id="' + TB_ID.PREV + '"><a href="#" title="' + defaultValues.i18n.prev.title + '">' + defaultValues.i18n.prev.text + '</a></strong>'; 257 var showPrev = buildShowFunc(group[i - 1] || group[size - 1]); 258 259 // overwrite keydown handler 260 keydown = function(e) { 261 var key = e.which || e.keyCode || -1; 262 // IE requires "timeout", I assume somehow due to this being added on 263 // the existing keydown handler, that's ugly, find a way to avoid 264 // duplicate code 265 // WARNING: without timeout IE freezes occasionally when using keyboard arrows 266 setTimeout(function() { 267 switch (key) { 268 case 27: // esc 269 hide(); 270 break; 271 case 37: // arrow left 272 showPrev(); 273 break; 274 case 39: // arrow right 275 showNext(); 276 break; 277 default: 278 blockKeys(e); 279 } 280 }, 0); 281 }; 282 $(document).unbind('keydown').bind('keydown', keydown); 260 var nextHtml = '<strong id="' + TB_ID.NEXT + '"><a href="#" title="' + defaultValues.i18n.next.title + '">' + defaultValues.i18n.next.text + '</a></strong>'; 261 next = buildShowFunc(group[i + 1] || group[0]); 262 263 var previousHtml = '<strong id="' + TB_ID.PREV + '"><a href="#" title="' + defaultValues.i18n.prev.title + '">' + defaultValues.i18n.prev.text + '</a></strong>'; 264 previous = buildShowFunc(group[i - 1] || group[size - 1]); 283 265 284 266 } … … 318 300 $('<img src="' + $$.attr('href') + '" alt="Image" width="' + imgWidth + '" height="' + imgHeight + '" title="' + title + '" />').appendTo(content); 319 301 if (rel) { 320 $(['<p id="' + TB_ID.BROWSE + '">', (prev || ''), (next|| ''), count, '</p>'].join('')).appendTo(content);302 $(['<p id="' + TB_ID.BROWSE + '">', (previousHtml || ''), (nextHtml || ''), count, '</p>'].join('')).appendTo(content); 321 303 if (size > 1) { 322 $('#' + TB_ID.NEXT + ' a').bind('click', showNext);323 $('#' + TB_ID.PREV + ' a').bind('click', showPrev);304 $('#' + TB_ID.NEXT + ' a').bind('click', next); 305 $('#' + TB_ID.PREV + ' a').bind('click', previous); 324 306 } 325 307 }
