Author: jablko
Date: Wed Oct 20 11:02:46 2010
New Revision: 8330

Log:
Don't declare QubitDialog in anonymous function, fixes issue 1816

Modified:
   trunk/js/dialog.js
   trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/templates/_event.php

Modified: trunk/js/dialog.js
==============================================================================
--- trunk/js/dialog.js  Wed Oct 20 10:21:22 2010        (r8329)
+++ trunk/js/dialog.js  Wed Oct 20 11:02:46 2010        (r8330)
@@ -2,621 +2,621 @@
 
 (function ($)
   {
-    function QubitDialog(table, options)
-    {
-      this.table = document.getElementById(table);
-      this.form = $(this.table).closest('form')[0]; // Parent form
-      this.instances = 0; // Counter
-      this.label = $('caption', this.table).remove().text();
-      this.fields = [];
-      this.initialValues = [];
-      this.data = {};
-      this.deletes = [];
-      this.options = options;
-      this.fieldNameFilter = /(\w+)\[(\w+)\]/;
-      this.fieldPrefix = null;
-      this.iframes = [];
-      this.count = 0;
-
-      var thisDialog = this;
-
-      /*
-       * Initialize
-       */
-
-      // Find field prefix (if there is one)
-      var matches = $(':input[name]', 
$(thisDialog.table)).eq(0).attr('name').match(this.fieldNameFilter);
-      if (null != matches)
+    QubitDialog = function (table, options)
       {
-        this.fieldPrefix = matches[1];
-      }
-
-      // Build an internal representation of HTML table elements
-      $(':input', thisDialog.table).each(function ()
-        {
-          if ('' == this.name || undefined != thisDialog.fields[this.name])
-          {
-            return;
-          }
+        this.table = document.getElementById(table);
+        this.form = $(this.table).closest('form')[0]; // Parent form
+        this.instances = 0; // Counter
+        this.label = $('caption', this.table).remove().text();
+        this.fields = [];
+        this.initialValues = [];
+        this.data = {};
+        this.deletes = [];
+        this.options = options;
+        this.fieldNameFilter = /(\w+)\[(\w+)\]/;
+        this.fieldPrefix = null;
+        this.iframes = [];
+        this.count = 0;
+
+        var thisDialog = this;
+
+        /*
+         * Initialize
+         */
+
+        // Find field prefix (if there is one)
+        var matches = $(':input[name]', 
$(thisDialog.table)).eq(0).attr('name').match(this.fieldNameFilter);
+        if (null != matches)
+        {
+          this.fieldPrefix = matches[1];
+        }
 
-          // Store initialValue of element
-          switch (this.type)
+        // Build an internal representation of HTML table elements
+        $(':input', thisDialog.table).each(function ()
           {
-            case 'radio':
-            case 'checkbox':
-              var input = $('input[name=' + this.name + ']', thisDialog.table);
-              thisDialog.fields[this.name] = new Array();
-              input.each(function ()
-                {
-                  thisDialog.fields[this.name].push(this);
-                });
-
-              thisDialog.initialValues[this.name] = 
input.filter(':checked').val();
-              break;
-
-            default:
-              thisDialog.fields[this.name] = this;
-              thisDialog.initialValues[this.name] = this.value;
-          }
-        });
-
-      // Create YUI container for dialog
-      var $yuiDialogWrapper = $('<div class="yui-skin-sam">'
-        + '  <div id="' + this.table.id + '">'
-        + '    <div class="hd">'
-        + '      ' + this.label
-        + '    </div><div class="bd">'
-        + '      <form action="" method="post" style="border: none"></form>'
-        + '    </div>'
-        + '  </div>'
-        + '</div>');
+            if ('' == this.name || undefined != thisDialog.fields[this.name])
+            {
+              return;
+            }
 
-      // Bind onClick event to "Add" link
-      var $addLink = $('<a href="#">Add new</a>').click(function (event)
-        {
-          // Prevent default action, "go to top of page"
-          event.preventDefault();
+            // Store initialValue of element
+            switch (this.type)
+            {
+              case 'radio':
+              case 'checkbox':
+                var input = $('input[name=' + this.name + ']', 
thisDialog.table);
+                thisDialog.fields[this.name] = new Array();
+                input.each(function ()
+                  {
+                    thisDialog.fields[this.name].push(this);
+                  });
 
-          thisDialog.open();
-        });
+                thisDialog.initialValues[this.name] = 
input.filter(':checked').val();
+                break;
 
-      // Replace dialog table with "Add" link and move into dialog wrapper
-      $(this.table)
-        .replaceWith($addLink)
-        .appendTo($yuiDialogWrapper.find('form'));
-
-      // Tooltips
-      // TODO Move to description.js?
-      $yuiDialogWrapper.find('.description')
-        .addClass('description-right')
-        .hide();
-
-      $yuiDialogWrapper.find('td:has(.description)')
-        .focusin(function ()
-          {
-            $yuiDialogWrapper.find('.description').hide();
-            $('.description', this).show();
-          })
-        .focusout(function ()
-          {
-            $yuiDialogWrapper.find('.description').hide();
+              default:
+                thisDialog.fields[this.name] = this;
+                thisDialog.initialValues[this.name] = this.value;
+            }
           });
 
-      // Prepend $yuiDialogWrapper to document body
-      $('body').prepend($yuiDialogWrapper);
-
-      // Submit dialog data
-      var handleYuiSubmit = function ()
-        {
-          this.hide(); // Hide dialog
-          thisDialog.submit(this.getData()); // Save dialog data
-        };
+        // Create YUI container for dialog
+        var $yuiDialogWrapper = $('<div class="yui-skin-sam">'
+          + '  <div id="' + this.table.id + '">'
+          + '    <div class="hd">'
+          + '      ' + this.label
+          + '    </div><div class="bd">'
+          + '      <form action="" method="post" style="border: none"></form>'
+          + '    </div>'
+          + '  </div>'
+          + '</div>');
 
-      var handleYuiCancel = function ()
-        {
-          this.cancel(); // Cancel YUI submit
-          thisDialog.clear(); // Clear dialog fields
-        };
-
-      this.yuiDialog = new YAHOO.widget.Dialog(this.table.id, {
-        width: '480px',
-        zIndex: '100',
-        fixedcenter: true,
-        draggable: true,
-        visible: false,
-        modal: true,
-        constraintoviewport: true,
-        postmethod: 'none',
-        buttons: [{ text: 'Submit', handler: handleYuiSubmit, isDefault: true 
},
-          { text: 'Cancel', handler: handleYuiCancel }] });
-
-      var keyListener_Esc = new YAHOO.util.KeyListener(document, { keys: 27 }, 
{
-        fn: handleYuiCancel,
-        scope: this.yuiDialog,
-        correctScope: true });
-
-      var keyListener_Enter = new YAHOO.util.KeyListener(document, { keys: 13 
}, {
-        fn: handleYuiSubmit,
-        scope: this.yuiDialog,
-        correctScope: true });
-
-      this.yuiDialog.cfg.queueProperty('keylisteners', 
keyListener_Enter.enable());
-      this.yuiDialog.cfg.queueProperty('keylisteners', 
keyListener_Esc.enable());
+        // Bind onClick event to "Add" link
+        var $addLink = $('<a href="#">Add new</a>').click(function (event)
+          {
+            // Prevent default action, "go to top of page"
+            event.preventDefault();
 
-      this.yuiDialog.render();
+            thisDialog.open();
+          });
 
-      // Remove all showEvent listeners to prevent default "focusFirst" 
behaviour
-      this.yuiDialog.showEvent.unsubscribeAll();
+        // Replace dialog table with "Add" link and move into dialog wrapper
+        $(this.table)
+          .replaceWith($addLink)
+          .appendTo($yuiDialogWrapper.find('form'));
+
+        // Tooltips
+        // TODO Move to description.js?
+        $yuiDialogWrapper.find('.description')
+          .addClass('description-right')
+          .hide();
+
+        $yuiDialogWrapper.find('td:has(.description)')
+          .focusin(function ()
+            {
+              $yuiDialogWrapper.find('.description').hide();
+              $('.description', this).show();
+            })
+          .focusout(function ()
+            {
+              $yuiDialogWrapper.find('.description').hide();
+            });
 
-      // Append hidden fields to form on submit
-      this.onSubmit = function (event)
-      {
-        event.preventDefault();
+        // Prepend $yuiDialogWrapper to document body
+        $('body').prepend($yuiDialogWrapper);
 
-        thisDialog.appendHiddenFields();
+        // Submit dialog data
+        var handleYuiSubmit = function ()
+          {
+            this.hide(); // Hide dialog
+            thisDialog.submit(this.getData()); // Save dialog data
+          };
+
+        var handleYuiCancel = function ()
+          {
+            this.cancel(); // Cancel YUI submit
+            thisDialog.clear(); // Clear dialog fields
+          };
+
+        this.yuiDialog = new YAHOO.widget.Dialog(this.table.id, {
+          width: '480px',
+          zIndex: '100',
+          fixedcenter: true,
+          draggable: true,
+          visible: false,
+          modal: true,
+          constraintoviewport: true,
+          postmethod: 'none',
+          buttons: [{ text: 'Submit', handler: handleYuiSubmit, isDefault: 
true },
+            { text: 'Cancel', handler: handleYuiCancel }] });
+
+        var keyListener_Esc = new YAHOO.util.KeyListener(document, { keys: 27 
}, {
+          fn: handleYuiCancel,
+          scope: this.yuiDialog,
+          correctScope: true });
+
+        var keyListener_Enter = new YAHOO.util.KeyListener(document, { keys: 
13 }, {
+          fn: handleYuiSubmit,
+          scope: this.yuiDialog,
+          correctScope: true });
+
+        this.yuiDialog.cfg.queueProperty('keylisteners', 
keyListener_Enter.enable());
+        this.yuiDialog.cfg.queueProperty('keylisteners', 
keyListener_Esc.enable());
 
-        // Apply selector to <iframe/> contents, update value of selected 
element
-        // with value of the autocomplete <input/>, and submit selected 
element's
-        // form
-        var iframe;
-        while (iframe = thisDialog.iframes.shift())
-        {
-          thisDialog.count++;
+        this.yuiDialog.render();
 
-          $($(iframe.selector, 
iframe.iframe[0].contentWindow.document).val(iframe.value)[0].form).submit();
-        }
+        // Remove all showEvent listeners to prevent default "focusFirst" 
behaviour
+        this.yuiDialog.showEvent.unsubscribeAll();
 
-        // If no iframes, just submit
-        if (0 == thisDialog.count)
+        // Append hidden fields to form on submit
+        this.onSubmit = function (event)
         {
-          thisDialog.done();
-        }
-      }
+          event.preventDefault();
 
-      // Bind onSubmit method
-      $(this.form).submit(this.onSubmit);
+          thisDialog.appendHiddenFields();
 
-      // Wait for all iframes to finish before submitting main form
-      this.done = function ()
-        {
-          // Decrement count of listeners and submit if all done
-          if (1 > --this.count)
+          // Apply selector to <iframe/> contents, update value of selected 
element
+          // with value of the autocomplete <input/>, and submit selected 
element's
+          // form
+          var iframe;
+          while (iframe = thisDialog.iframes.shift())
           {
-            $(thisDialog.form)
-
-              // Unbind submit listeners to avoid triggering again
-              .unbind('submit', this.onSubmit)
+            thisDialog.count++;
 
-              .submit();
+            $($(iframe.selector, 
iframe.iframe[0].contentWindow.document).val(iframe.value)[0].form).submit();
           }
-        }
 
-      /*
-       * Methods
-       */
-      this.renderField = function (fname)
-        {
-          if ($(this.fields[fname]).next().hasClass('form-autocomplete'))
-          {
-            // Autocomplete text
-            return $(this.fields[fname]).next().val();
-          }
-          else if ('select-one' == this.fields[fname].type || 'select-multi' 
== this.fields[fname].type)
-          {
-            // Select box text
-            return $(this.fields[fname]).children(':selected').text();
-          }
-          else if ('radio' == this.fields[fname].type)
+          // If no iframes, just submit
+          if (0 == thisDialog.count)
           {
-            return $('input[name=' + fname + ']:checked', 
thisDialog.table).val();
+            thisDialog.done();
           }
-          else if (undefined != this.fields[fname].value)
-          {
-            return this.fields[fname].value;
-          }
-
-          return '';
         }
 
-      /**
-       * Helper to get a field that has a prefix (e.g. formname[myField]) 
without
-       * specifying the prefix name
-       */
-      this.getField = function (fname)
-        {
-          if (null != this.fieldPrefix && null == 
fname.match(this.fieldNameFilter))
-          {
-            var fullname = this.fieldPrefix + '[' + fname + ']';
+        // Bind onSubmit method
+        $(this.form).submit(this.onSubmit);
 
-            return this.fields[fullname];
-          }
+        // Wait for all iframes to finish before submitting main form
+        this.done = function ()
+          {
+            // Decrement count of listeners and submit if all done
+            if (1 > --this.count)
+            {
+              $(thisDialog.form)
 
-          return this.fields[fname];
-        }
+                // Unbind submit listeners to avoid triggering again
+                .unbind('submit', this.onSubmit)
 
-      this.open = function ()
-        {
-          if (undefined == arguments[0])
-          {
-            // If no "id" passed as argument then create unique id and skip the
-            // data load
-            this.id = 'new' + this.instances++;
-          }
-          else
-          {
-            this.id = arguments[0];
+                .submit();
+            }
           }
 
-          if (!arguments.length)
+        /*
+         * Methods
+         */
+        this.renderField = function (fname)
           {
-            this.yuiDialog.show();
-            this.yuiDialog.focusFirst();
+            if ($(this.fields[fname]).next().hasClass('form-autocomplete'))
+            {
+              // Autocomplete text
+              return $(this.fields[fname]).next().val();
+            }
+            else if ('select-one' == this.fields[fname].type || 'select-multi' 
== this.fields[fname].type)
+            {
+              // Select box text
+              return $(this.fields[fname]).children(':selected').text();
+            }
+            else if ('radio' == this.fields[fname].type)
+            {
+              return $('input[name=' + fname + ']:checked', 
thisDialog.table).val();
+            }
+            else if (undefined != this.fields[fname].value)
+            {
+              return this.fields[fname].value;
+            }
+
+            return '';
           }
-          else
+
+        /**
+         * Helper to get a field that has a prefix (e.g. formname[myField]) 
without
+         * specifying the prefix name
+         */
+        this.getField = function (fname)
           {
-            this.loadData(this.id, function ()
-              {
-                thisDialog.yuiDialog.show();
-              });
+            if (null != this.fieldPrefix && null == 
fname.match(this.fieldNameFilter))
+            {
+              var fullname = this.fieldPrefix + '[' + fname + ']';
+
+              return this.fields[fullname];
+            }
+
+            return this.fields[fname];
           }
-        }
 
-      this.loadData = function (id, callback)
-        {
-          if (undefined != this.data[id])
+        this.open = function ()
           {
-            this.updateDialog(id, this.data[id], callback)
+            if (undefined == arguments[0])
+            {
+              // If no "id" passed as argument then create unique id and skip 
the
+              // data load
+              this.id = 'new' + this.instances++;
+            }
+            else
+            {
+              this.id = arguments[0];
+            }
+
+            if (!arguments.length)
+            {
+              this.yuiDialog.show();
+              this.yuiDialog.focusFirst();
+            }
+            else
+            {
+              this.loadData(this.id, function ()
+                {
+                  thisDialog.yuiDialog.show();
+                });
+            }
           }
-          else
+
+        this.loadData = function (id, callback)
           {
-            // TODO Ajax call to get relation data from database
-            var dataSource = new YAHOO.util.XHRDataSource(id);
-            dataSource.responseType = YAHOO.util.DataSourceBase.TYPE_JSON;
-            dataSource.parseJSONData = function (request, response)
-              {
-                if (undefined != thisDialog.options.relationTableMap)
-                {
-                  return { results: 
[thisDialog.options.relationTableMap(response)] };
-                }
-                else
+            if (undefined != this.data[id])
+            {
+              this.updateDialog(id, this.data[id], callback)
+            }
+            else
+            {
+              // TODO Ajax call to get relation data from database
+              var dataSource = new YAHOO.util.XHRDataSource(id);
+              dataSource.responseType = YAHOO.util.DataSourceBase.TYPE_JSON;
+              dataSource.parseJSONData = function (request, response)
                 {
-                  var dataMap = function (response)
-                    {
-                      for (name in response)
+                  if (undefined != thisDialog.options.relationTableMap)
+                  {
+                    return { results: 
[thisDialog.options.relationTableMap(response)] };
+                  }
+                  else
+                  {
+                    var dataMap = function (response)
                       {
-                        this[thisDialog.fieldPrefix + '[' + name + ']'] = 
response[name];
+                        for (name in response)
+                        {
+                          this[thisDialog.fieldPrefix + '[' + name + ']'] = 
response[name];
+                        }
                       }
-                    }
 
-                  return { results: [new dataMap(response)] };
+                    return { results: [new dataMap(response)] };
+                  }
                 }
-              }
-
-            dataSource.sendRequest(null, {
-              success: function (request, response)
-                {
-                  thisDialog.updateDialog(id, response.results[0], callback);
-                } });
-          }
-        }
 
-      this.updateDialog = function (thisId, thisData, callback)
-        {
-          if (undefined == this.data[thisId])
-          {
-            this.data[thisId] = thisData;
+              dataSource.sendRequest(null, {
+                success: function (request, response)
+                  {
+                    thisDialog.updateDialog(id, response.results[0], callback);
+                  } });
+            }
           }
 
-          for (fieldname in this.fields)
+        this.updateDialog = function (thisId, thisData, callback)
           {
-            if (null == thisData[fieldname])
+            if (undefined == this.data[thisId])
             {
-              continue;
+              this.data[thisId] = thisData;
             }
 
-            this.fields[fieldname].value = thisData[fieldname];
-
-            // Get display value for autocompletes
-            if ($(this.fields[fieldname])
-                .next('input')
-                .hasClass('form-autocomplete'))
+            for (fieldname in this.fields)
             {
-              var hiddenInput = this.fields[fieldname];
-
-              // First check if a "Display" value is include in "thisData"
-              var displayField = fieldname.substr(0, fieldname.length - 1) + 
'Display]';
-              if (undefined != thisData[displayField])
+              if (null == thisData[fieldname])
               {
-                
$(hiddenInput).next('input').val(jQuery.trim(thisData[displayField]));
+                continue;
               }
-              else if (0 < hiddenInput.value.length)
+
+              this.fields[fieldname].value = thisData[fieldname];
+
+              // Get display value for autocompletes
+              if ($(this.fields[fieldname])
+                  .next('input')
+                  .hasClass('form-autocomplete'))
               {
-                // If necessary, get name via Ajax request to show page
-                var dataSource = new 
YAHOO.util.XHRDataSource(hiddenInput.value);
-                dataSource.responseType = YAHOO.util.DataSourceBase.TYPE_TEXT;
-                dataSource.parseTextData = function (request, response)
-                  {
-                    return { 'results': [$('.label', response).text()] };
-                  };
+                var hiddenInput = this.fields[fieldname];
 
-                // Set visible input field of yui-autocomplete
-                dataSource.sendRequest(null, {
-                  success: function (request, response)
+                // First check if a "Display" value is include in "thisData"
+                var displayField = fieldname.substr(0, fieldname.length - 1) + 
'Display]';
+                if (undefined != thisData[displayField])
+                {
+                  
$(hiddenInput).next('input').val(jQuery.trim(thisData[displayField]));
+                }
+                else if (0 < hiddenInput.value.length)
+                {
+                  // If necessary, get name via Ajax request to show page
+                  var dataSource = new 
YAHOO.util.XHRDataSource(hiddenInput.value);
+                  dataSource.responseType = 
YAHOO.util.DataSourceBase.TYPE_TEXT;
+                  dataSource.parseTextData = function (request, response)
                     {
-                      $(hiddenInput)
-                        .next('.form-autocomplete')
-                        .val(response.results[0]);
-                    } });
+                      return { 'results': [$('.label', response).text()] };
+                    };
+
+                  // Set visible input field of yui-autocomplete
+                  dataSource.sendRequest(null, {
+                    success: function (request, response)
+                      {
+                        $(hiddenInput)
+                          .next('.form-autocomplete')
+                          .val(response.results[0]);
+                      } });
+                }
               }
             }
-          }
-
-          if (undefined != callback)
-          {
-            callback();
-          }
-        }
 
-      this.save = function (yuiDialogData)
-        {
-          $('input.form-autocomplete', thisDialog.table).each(function ()
+            if (undefined != callback)
             {
-              $hidden = $(this).prev('input:hidden');
+              callback();
+            }
+          }
 
-              // Test for existing <iframe/>
-              for (var i in thisDialog.iframes)
+        this.save = function (yuiDialogData)
+          {
+            $('input.form-autocomplete', thisDialog.table).each(function ()
               {
-                if (thisDialog.id == thisDialog.iframes[i].dialogId && 
$hidden.attr('name') == thisDialog.iframes[i].inputName)
+                $hidden = $(this).prev('input:hidden');
+
+                // Test for existing <iframe/>
+                for (var i in thisDialog.iframes)
                 {
-                  var index = i;
+                  if (thisDialog.id == thisDialog.iframes[i].dialogId && 
$hidden.attr('name') == thisDialog.iframes[i].inputName)
+                  {
+                    var index = i;
+                  }
                 }
-              }
 
-              // Test if autocomplete has a value
-              if (0 < this.value.length)
-              {
-                // If no URI is set, then selecting unmatched value
-                if (0 == $hidden.val().length)
+                // Test if autocomplete has a value
+                if (0 < this.value.length)
                 {
-                  // Allowing adding new values via iframe
-                  var value = $('~ .add', this).val();
-                  if (value)
+                  // If no URI is set, then selecting unmatched value
+                  if (0 == $hidden.val().length)
                   {
-                    var components = value.split(' ', 2);
-
-                    if (undefined == index)
-                    {
-                      // Add hidden <iframe/> for each new choice
-                      $iframe = $('<iframe src="' + components[0] + '"/>')
-                        .width(0)
-                        .height(0)
-                        .css('border', 0)
-                        .appendTo('body');
-
-                      thisDialog.iframes.push({
-                        'dialogId': thisDialog.id,
-                        'inputName': $(this).prev('input:hidden').attr('name'),
-                        'iframe': $iframe,
-                        'selector': components[1],
-                        'value': this.value });
-                    }
-                    else
+                    // Allowing adding new values via iframe
+                    var value = $('~ .add', this).val();
+                    if (value)
                     {
-                      // Update existing <iframe/>
-                      thisDialog.iframes[index].value = this.value;
+                      var components = value.split(' ', 2);
+
+                      if (undefined == index)
+                      {
+                        // Add hidden <iframe/> for each new choice
+                        $iframe = $('<iframe src="' + components[0] + '"/>')
+                          .width(0)
+                          .height(0)
+                          .css('border', 0)
+                          .appendTo('body');
+
+                        thisDialog.iframes.push({
+                          'dialogId': thisDialog.id,
+                          'inputName': 
$(this).prev('input:hidden').attr('name'),
+                          'iframe': $iframe,
+                          'selector': components[1],
+                          'value': this.value });
+                      }
+                      else
+                      {
+                        // Update existing <iframe/>
+                        thisDialog.iframes[index].value = this.value;
+                      }
                     }
                   }
-                }
 
-                // Remove <iframe/> if selecting a pre-existing value
-                else if (undefined != index && this.value != 
thisDialog.iframes[index].iframe.value)
-                {
-                  delete thisDialog.iframes[index];
+                  // Remove <iframe/> if selecting a pre-existing value
+                  else if (undefined != index && this.value != 
thisDialog.iframes[index].iframe.value)
+                  {
+                    delete thisDialog.iframes[index];
+                  }
                 }
-              }
-            });
-
-          this.data[this.id] = yuiDialogData;
+              });
 
-          return this;
-        }
+            this.data[this.id] = yuiDialogData;
 
-      this.clear = function ()
-        {
-          // Remove "id" field
-          $('input[name=id]', this.table).remove();
+            return this;
+          }
 
-          // Clear fields
-          for (fname in this.fields)
+        this.clear = function ()
           {
-            // Radio and checkbox inputs have a length > 0
-            if (0 < this.fields[fname].length)
+            // Remove "id" field
+            $('input[name=id]', this.table).remove();
+
+            // Clear fields
+            for (fname in this.fields)
             {
-              var initVal = this.initialValues[fname];
-              if ('string' == typeof initVal)
+              // Radio and checkbox inputs have a length > 0
+              if (0 < this.fields[fname].length)
               {
-                initVal = [initVal]; // Cast as array
-              }
+                var initVal = this.initialValues[fname];
+                if ('string' == typeof initVal)
+                {
+                  initVal = [initVal]; // Cast as array
+                }
 
-              $(this.fields[fname]).val(initVal);
-            }
-            else if ('select-one' == this.fields[fname].type)
-            {
-              // Select first option in single option select controls
-              this.fields[fname].options[0].selected = true;
-            }
-            else
-            {
-              $(this.fields[fname]).val(this.initialValues[fname]);
+                $(this.fields[fname]).val(initVal);
+              }
+              else if ('select-one' == this.fields[fname].type)
+              {
+                // Select first option in single option select controls
+                this.fields[fname].options[0].selected = true;
+              }
+              else
+              {
+                $(this.fields[fname]).val(this.initialValues[fname]);
+              }
             }
-          }
-
-          // Clear autocomplete fields
-          $('input.form-autocomplete', $(this.table)).val('');
 
-          return this;
-        }
+            // Clear autocomplete fields
+            $('input.form-autocomplete', $(this.table)).val('');
 
-      this.remove = function (thisId)
-        {
-          if (undefined == this.data[thisId])
-          {
-            return;
+            return this;
           }
 
-          var tr = $('#' + this.options.displayTable + ' tr[id=' + thisId + 
']');
-
-          // Wrap <td/> contents in <div/> so the row hides nicely then hide 
and
-          // remove row
-          tr.find('> td').wrapInner('<div/>')
-            .find('> div').hide('normal', function ()
-              {
-                tr.remove();
-              });
-
-          // If this is an existing relationship, then store id for deletion
-          if ('new' != thisId.substr(0, 3))
+        this.remove = function (thisId)
           {
-            this.deletes.push(thisId.match(/\d+$/));
-          }
+            if (undefined == this.data[thisId])
+            {
+              return;
+            }
 
-          // Remove data for relation
-          delete this.data[thisId];
-        }
+            var tr = $('#' + this.options.displayTable + ' tr[id=' + thisId + 
']');
 
-      this.appendDisplayRow = function ()
-        {
-          var displayTable = 
document.getElementById(this.options.displayTable);
-          var newRowTemplate = this.options.newRowTemplate;
+            // Wrap <td/> contents in <div/> so the row hides nicely then hide 
and
+            // remove row
+            tr.find('> td').wrapInner('<div/>')
+              .find('> div').hide('normal', function ()
+                {
+                  tr.remove();
+                });
 
-          if (undefined == displayTable || undefined == newRowTemplate)
-          {
-            return;
-          }
+            // If this is an existing relationship, then store id for deletion
+            if ('new' != thisId.substr(0, 3))
+            {
+              this.deletes.push(thisId.match(/\d+$/));
+            }
 
-          // Check for special field render handler
-          if (undefined != this.options.handleFieldRender)
-          {
-            var render = function (fname)
-              {
-                return thisDialog.options.handleFieldRender(thisDialog, fname);
-              }
-          }
-          else
-          {
-            var render = function (fname)
-              {
-                return thisDialog.renderField(fname);
-              }
+            // Remove data for relation
+            delete this.data[thisId];
           }
 
-          tr = newRowTemplate.replace('{' + this.fieldPrefix + '[id]}', 
this.id);
-          for (fname in this.fields)
+        this.appendDisplayRow = function ()
           {
-            if (0 < fname.length)
+            var displayTable = 
document.getElementById(this.options.displayTable);
+            var newRowTemplate = this.options.newRowTemplate;
+
+            if (undefined == displayTable || undefined == newRowTemplate)
             {
-              tr = tr.replace('{' + fname + '}', render(fname));
+              return;
             }
-          }
 
-          // http://bugs.jquery.com/ticket/7246
-          if (!$('tr[id=' + this.id + ']', displayTable).length)
-          {
-            var $tr = $(tr).appendTo(displayTable);
-          }
-          else
-          {
-            var $tr = $(tr).replaceAll($('tr[id=' + this.id + ']', 
displayTable));
-          }
+            // Check for special field render handler
+            if (undefined != this.options.handleFieldRender)
+            {
+              var render = function (fname)
+                {
+                  return thisDialog.options.handleFieldRender(thisDialog, 
fname);
+                }
+            }
+            else
+            {
+              var render = function (fname)
+                {
+                  return thisDialog.renderField(fname);
+                }
+            }
 
-          // Bind events
-          $tr.find('img[alt=edit]').click(function ()
+            tr = newRowTemplate.replace('{' + this.fieldPrefix + '[id]}', 
this.id);
+            for (fname in this.fields)
             {
-              thisDialog.open($(this).closest('tr').attr('id'));
-            });
+              if (0 < fname.length)
+              {
+                tr = tr.replace('{' + fname + '}', render(fname));
+              }
+            }
 
-          $tr.find('button[name=delete]').click(function ()
+            // http://bugs.jquery.com/ticket/7246
+            if (!$('tr[id=' + this.id + ']', displayTable).length)
             {
-              thisDialog.remove($(this).closest('tr').attr('id'));
-            });
-        }
+              var $tr = $(tr).appendTo(displayTable);
+            }
+            else
+            {
+              var $tr = $(tr).replaceAll($('tr[id=' + this.id + ']', 
displayTable));
+            }
 
-      // Submit dialog
-      this.submit = function (yuiDialogData)
-        {
-          this.save(yuiDialogData);
-          this.appendDisplayRow();
-          this.clear();
-        }
+            // Bind events
+            $tr.find('img[alt=edit]').click(function ()
+              {
+                thisDialog.open($(this).closest('tr').attr('id'));
+              });
 
-      // Append all cached data to form
-      this.appendHiddenFields = function ()
-        {
-          // Build hidden form input fields
-          var i = 0;
-          if (null != this.fieldPrefix)
-          {
-            // Append "s" to old prefix to indicate multiple nature
-            var outputPrefix = this.fieldPrefix + 's';
+            $tr.find('button[name=delete]').click(function ()
+              {
+                thisDialog.remove($(this).closest('tr').attr('id'));
+              });
           }
-          else
+
+        // Submit dialog
+        this.submit = function (yuiDialogData)
           {
-            var outputPrefix = 'dialog';
+            this.save(yuiDialogData);
+            this.appendDisplayRow();
+            this.clear();
           }
 
-          for (var id in this.data)
+        // Append all cached data to form
+        this.appendHiddenFields = function ()
           {
-            var thisData = this.data[id];
-
-            // Don't include "id" if it's a "new" object
-            if (null != id && 'new' != id.substr(0,3))
+            // Build hidden form input fields
+            var i = 0;
+            if (null != this.fieldPrefix)
+            {
+              // Append "s" to old prefix to indicate multiple nature
+              var outputPrefix = this.fieldPrefix + 's';
+            }
+            else
             {
-              var name = outputPrefix + '[' + i + '][id]';
-              $(this.form).append('<input type="hidden" name="' + name + '" 
value="' + id + '"/>');
+              var outputPrefix = 'dialog';
             }
 
-            // Convert all event data into hidden input fields
-            for (var j in thisData)
+            for (var id in this.data)
             {
-              // Format name according to input and output name formats
-              var matches = j.match(this.fieldNameFilter);
-              if (null != matches)
+              var thisData = this.data[id];
+
+              // Don't include "id" if it's a "new" object
+              if (null != id && 'new' != id.substr(0,3))
               {
-                name = outputPrefix + '[' + i + '][' + matches[2] + ']';
+                var name = outputPrefix + '[' + i + '][id]';
+                $(this.form).append('<input type="hidden" name="' + name + '" 
value="' + id + '"/>');
               }
-              else
+
+              // Convert all event data into hidden input fields
+              for (var j in thisData)
               {
-                name = outputPrefix + '[' + i + '][' + name + ']';
-              }
+                // Format name according to input and output name formats
+                var matches = j.match(this.fieldNameFilter);
+                if (null != matches)
+                {
+                  name = outputPrefix + '[' + i + '][' + matches[2] + ']';
+                }
+                else
+                {
+                  name = outputPrefix + '[' + i + '][' + name + ']';
+                }
 
-              var $hidden = $('<input type="hidden" name="' + name + '" 
value="' + thisData[j] + '"/>');
-              $hidden.appendTo(this.form);
+                var $hidden = $('<input type="hidden" name="' + name + '" 
value="' + thisData[j] + '"/>');
+                $hidden.appendTo(this.form);
 
-              // Update this value from iframe
-              for (var k in this.iframes)
-              {
-                if (id == this.iframes[k].dialogId && j == 
this.iframes[k].inputName)
+                // Update this value from iframe
+                for (var k in this.iframes)
                 {
-                  this.iframes[k].iframe.one('load', { 'hdn': $hidden }, 
function (e)
-                    {
-                      // Update value of hidden input with URI of new resource
-                      e.data.hdn.val(this.contentWindow.document.location);
+                  if (id == this.iframes[k].dialogId && j == 
this.iframes[k].inputName)
+                  {
+                    this.iframes[k].iframe.one('load', { 'hdn': $hidden }, 
function (e)
+                      {
+                        // Update value of hidden input with URI of new 
resource
+                        e.data.hdn.val(this.contentWindow.document.location);
 
-                      // Decrement count of listeners and submit if all done
-                      thisDialog.done();
-                    });
+                        // Decrement count of listeners and submit if all done
+                        thisDialog.done();
+                      });
+                  }
                 }
               }
-            }
 
-            i++;
-          }
+              i++;
+            }
 
-          // Delete relations that have been removed
-          for (var k=0; k < this.deletes.length; k++)
-          {
-            $(this.form).append('<input type="hidden" name="deleteRelations[' 
+ this.deletes[k] + ']" value="delete"/>');
+            // Delete relations that have been removed
+            for (var k=0; k < this.deletes.length; k++)
+            {
+              $(this.form).append('<input type="hidden" 
name="deleteRelations[' + this.deletes[k] + ']" value="delete"/>');
+            }
           }
-        }
-    }
+      }
   })(jQuery);

Modified: trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/templates/_event.php
==============================================================================
--- trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/templates/_event.php        
Wed Oct 20 10:21:22 2010        (r8329)
+++ trunk/plugins/sfIsadPlugin/modules/sfIsadPlugin/templates/_event.php        
Wed Oct 20 11:02:46 2010        (r8330)
@@ -26,7 +26,7 @@
         <tr class="related_obj_<?php echo $item->id ?>">
           <td>
             <div class="animateNicely">
-              <input name="<?php $form->getWidgetSchema()->generateName('id') 
?>" type="hidden" value="<?php echo $item->id ?>"/>
+              <input name="<?php echo 
$form->getWidgetSchema()->generateName('id') ?>" type="hidden" value="<?php 
echo $item->id ?>"/>
               <?php echo $form->getWidgetSchema()->renderField('type', 
url_for(array($item->type, 'module' => 'term'))) ?>
             </div>
           </td><td>

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to