Project

General

Profile

Download (1.67 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Expected dom structure:
3
 *  '<div class="ahah-content" rel="'.$cdm_proxy_url.'"><span class="loading">Loading ....</span></div>';
4
 */
5

    
6
(Drupal.ahahContentAutoAttach = (function ($) {
7

    
8
	// firebug console stub (avoids errors if firebug is not active)
9
	if(typeof console === "undefined") {
10
	    console = { log: function() { } };
11
	}
12

    
13
  // register with all elements .ahah-content
14
    $(".ahah-content").each(function(index, element) {
15
      var ahahContent = $(element);
16
      url = ahahContent.attr("rel");
17
      console.log("ahah-content url:" + url);
18
      if(url !== undefined && url.length > 1){
19
//        ahahContent.removeAttr('rel').find('.loading').css('display', 'block');
20
        ahahContent.find('.loading').css('display', 'block');
21
        $.get(url, function(html){
22
          ahahContent.find('.loading').remove();
23
          ahahContent.append(html);
24
          });
25
        }
26
      });
27

    
28
      // register with lightbox etc ...
29
      $('body').bind('overflow', function(event){
30

    
31
        var ahah_content_set = $(event.target).find('.ahah-content');
32
        if(ahah_content_set !== undefined){
33
          $(ahah_content_set).each(function(i){
34
            var ahah_content = $(this);
35
            var url = ahah_content.attr('rel');
36
            console.log("ahah-content on 'overflow' url:" + url);
37
            if(url !== undefined && url.length > 1){
38
              ahah_content.removeAttr('rel').find('.loading').css('display', 'block');
39
              $.get(url, function(html){
40
                ahah_content.find('.loading').remove().end().append(html);
41
                });
42
            }
43
          });
44

    
45
        }
46
      });
47

    
48
    }))(jQuery);
49

    
50

    
51

    
52
jQuery(document).ready(Drupal.ahahContentAutoAttach);
(1-1/11)