| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 if (Drupal.jsEnabled) { 2 $(document).ready(function() { 3 // I am assuming that all of the links are refering to an internal node 4 5 // add the attribute rel=facebox to all of the links I want to have a popup 6 $('div.view-field > a').attr('class', 'popup'); 7 8 // on click of a link 9 $('a.popup').click(function(a) { 10 11 // Make sure that other stuff is closed. This seems to cause a problem in Fx2 and IE7. 12 $('div#calpopup').fadeOut(); 13 $('div#calpopup').remove(); 14 15 // create div to hold data and add it to the end of the body 16 var div = $('<div id="calpopup"><div id="popup-close"><img id="popup-close-img" src="' + Drupal.settings.jcalendar.path + '/images/cross.png" /></div><div id="calpopup-body"><img src="' + Drupal.settings.jcalendar.path + '/images/throbber.gif" id="popthrobber" /></div></div>').attr('style','display: none'); 17 div.appendTo(document.body); 18 19 // Locate Popup 20 var offset = $(this).offset(); 21 // Check position with window width. 22 var offset_left = offset.left + 5; 23 if ($(window).width() < $('#calpopup').width() + offset.left) { 24 offset_left -= $('#calpopup').width() + 5; 25 if (offset_left < 0) { 26 offset_left = 0; 27 } 28 } 29 var offset_top = offset.top + 25; 30 if ($(window).height() < $('#calpopup').height() + offset_top) { 31 offset_top -= $('#calpopup').height() + 25; 32 if (offset_top < 0) { 33 offset_top = 0; 34 } 35 } 36 $('#calpopup').css('left', offset_left); 37 $('#calpopup').css('top', offset_top); 38 39 // Show Popup 40 $('#calpopup').fadeIn('slow'); 41 42 // If sucessful call this 43 function domCallback(msg) { 44 $('#calpopup-body').html(msg); 45 } 46 47 // Get NodeID and ItemID 48 var ids = $(this).parent().parent().attr('class'); 49 var arrs = ids.split(" "); 50 var arr = arrs[0].split("."); 51 var nid = arr[1]; 52 var id = arr[4]; 53 54 // fill the div with data 55 $.ajax({ 56 type: "GET", 57 url: Drupal.settings.basePath + "?q=jcalendar/getnode/"+nid+"/"+ids, 58 success: function(msg){ 59 domCallback(msg); 60 } 61 }); 62 63 // On click of the close image 64 $('img#popup-close-img').click(function(x) { 65 $('div#calpopup').fadeOut(); 66 $('div#calpopup').remove(); 67 }); 68 69 $(document).click(function(y) { 70 var $tgt = $(y.target); 71 if (!$tgt.parents().is('div#calpopup')) { 72 $('div#calpopup').fadeOut(); 73 $('div#calpopup').remove(); 74 $(document).unbind("click"); 75 } 76 }); 77 78 // Don't Follow the real link 79 return false; 80 }); 81 }); 82 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |