// Shortcut-function (until we update to Prototye v1.5) if(typeof $$ != "Function") $$ = document.getElementsBySelector; GB_OpenerObj = {}; GB_RefreshLink = ""; ComplexTableField = Class.create(); ComplexTableField.prototype = { // These are defaults used if setPopupSize encounters errors defaultPopupWidth: 560, defaultPopupHeight: 390, initialize: function() { var rules = {}; rules['#'+this.id+' table.data a.popuplink'] = {onclick: this.openPopup.bind(this)}; // Assume that the delete link uses the deleteRecord method rules['#'+this.id+' table.data a.deletelink'] = {onclick: this.deleteRecord.bind(this)}; // invoke row action-link based on default-action set in classname var defaultAction = this.getDefaultAction(); if(defaultAction) { rules['#'+this.id+' table.data tbody td'] = { onclick: function(e) { var elt = Event.element(e); // Check the tag, as otherwise this // function can take over checkbox // click actions etc. See ticket #4737 if (elt.tagName != 'TD' && elt.tagName != 'TR') { return; } var link = $$('.'+defaultAction, Event.element(e).parentNode)[0].href; this.openPopup(null, link); return false; }.bind(this) }; } Behaviour.register('ComplexTableField_'+this.id,rules); this.setPopupSize(); // HACK If already in a popup, we can't allow add (doesn't save existing relation correctly) if(window != top) $$('#'+this.id+' table.data a.addlink').each(function(el) {Element.hide(el);}); }, setPopupSize: function() { try { this.popupHeight = parseInt(document.getElementById(this.id + '_PopupHeight').value); this.popupWidth = parseInt(document.getElementById(this.id + '_PopupWidth').value); } catch (ex) { this.popupHeight = this.defaultPopupHeight; this.popupWidth = this.defaultPopupWidth; } }, getDefaultAction: function() { // try to get link class from