| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 2 Drupal.behaviors.data_node = function(context) { 3 // Link AHAH 4 $('a.data-node-remove:not(.processed), a.data-node-add:not(.processed), .data-node-label a.remove-link:not(.processed)').each(function() { 5 $(this).addClass('processed'); 6 $(this).click(function() { 7 var url = $(this).attr('href'); 8 $.getJSON(url, {'ajax': 1}, function(data) { 9 if (data['status']) { 10 // Generate selectors 11 var labels = 'data_node_labels-' + data['table'] + '-' + data['id']; 12 var link = 'data_node_link-' + data['table'] + '-' + data['id'] + '-' + data['nid']; 13 14 // Labels are straightforward to replace. 15 $('.' + labels).replaceWith(data['labels']); 16 17 // Target links first, so we don't write over our own work in immediate succession. 18 $('.' + link).addClass('targeted'); 19 $('.' + link + '.targeted.data-node-remove').replaceWith(data['remove_link']); 20 $('.' + link + '.targeted.data-node-add').replaceWith(data['add_link']); 21 22 // Reattach behaviors 23 Drupal.attachBehaviors('a.data-node-remove:not(.processed), a.data-node-add:not(.processed), .data-node-label a.remove-link:not(.processed)'); 24 } 25 }); 26 return false; 27 }); 28 }); 29 30 // Active node 31 $('form.data-node-active-form:not(.processed)').each(function() { 32 $(this).addClass('processed'); 33 $('select', this).change(function() { 34 var form = $(this).parents('form'); 35 var value = $(this).val(); 36 if (value == 'new') { 37 $('.new-node', form).show(); 38 } 39 else { 40 $('.new-node', form).hide(); 41 if (value != 0) { 42 var stale_nid = 0; 43 var stale = []; 44 var ajax_url = $('.data-node-ajax-url', form).val() + '/' + value; 45 var add_url = $('.data-node-add-url', form).val() + '/'; 46 var remove_url = $('.data-node-remove-url', form).val() + '/'; 47 48 $('a.data-node-add, a.data-node-remove').each(function() { 49 // Manipulate the URL to retrieve stale IDs and the current stale nid 50 var url = $(this).attr('href').replace(add_url, '').replace(remove_url, '').split('/'); 51 stale.push(url[0]); 52 if (stale_nid == 0) { 53 stale_nid = url[1]; 54 } 55 }); 56 57 $('span.data-node-placeholder').each(function() { 58 var classes = $(this).attr('class').split(' '); 59 for (var key in classes) { 60 if (classes[key].indexOf('data_node_link') === 0) { 61 // 0: table, 1: id, 2: nid 62 var split = classes[key].replace('data_node_link-', '').split('-'); 63 stale.push(split[1]); 64 break; 65 } 66 } 67 }); 68 69 $.getJSON(ajax_url, {'ajax': 1, 'stale': stale.join('-')}, function(data) { 70 if (data['status']) { 71 for (var id in data['refresh']) { 72 var link = 'data_node_link-' + data['table'] + '-' + id + '-' + stale_nid; 73 $('.' + link).replaceWith(data['refresh'][id]); 74 } 75 // Reattach behaviors 76 Drupal.attachBehaviors('a.data-node-remove:not(.processed), a.data-node-add:not(.processed)'); 77 } 78 }); 79 } 80 } 81 }); 82 $('input#edit-submit', this).hide(); 83 }); 84 }
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 |