colorbox_inline.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. (function ($) {
  2. Drupal.behaviors.initColorboxInline = {
  3. attach: function (context, settings) {
  4. if (!$.isFunction($.colorbox)) {
  5. return;
  6. }
  7. $.urlParam = function(name, url){
  8. if (name == 'fragment') {
  9. var results = new RegExp('(#[^&#]*)').exec(url);
  10. }
  11. else {
  12. var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(url);
  13. }
  14. if (!results) { return ''; }
  15. return results[1] || '';
  16. };
  17. $('.colorbox-inline', context).once('init-colorbox-inline').colorbox({
  18. transition:settings.colorbox.transition,
  19. speed:settings.colorbox.speed,
  20. opacity:settings.colorbox.opacity,
  21. slideshow:settings.colorbox.slideshow,
  22. slideshowAuto:settings.colorbox.slideshowAuto,
  23. slideshowSpeed:settings.colorbox.slideshowSpeed,
  24. slideshowStart:settings.colorbox.slideshowStart,
  25. slideshowStop:settings.colorbox.slideshowStop,
  26. current:settings.colorbox.current,
  27. previous:settings.colorbox.previous,
  28. next:settings.colorbox.next,
  29. close:settings.colorbox.close,
  30. overlayClose:settings.colorbox.overlayClose,
  31. maxWidth:settings.colorbox.maxWidth,
  32. maxHeight:settings.colorbox.maxHeight,
  33. innerWidth:function(){
  34. return $.urlParam('width', $(this).attr('href'));
  35. },
  36. innerHeight:function(){
  37. return $.urlParam('height', $(this).attr('href'));
  38. },
  39. title:function(){
  40. return decodeURIComponent($.urlParam('title', $(this).attr('href')));
  41. },
  42. iframe:function(){
  43. return $.urlParam('iframe', $(this).attr('href'));
  44. },
  45. inline:function(){
  46. return $.urlParam('inline', $(this).attr('href'));
  47. },
  48. href:function(){
  49. return $.urlParam('fragment', $(this).attr('href'));
  50. }
  51. });
  52. }
  53. };
  54. })(jQuery);