/[drupal]/contributions/modules/webforms2/webforms2_repetition/webforms2_repetition.js
ViewVC logotype

Diff of /contributions/modules/webforms2/webforms2_repetition/webforms2_repetition.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Tue Jul 15 21:39:15 2008 UTC revision 1.2, Tue Jul 15 21:47:46 2008 UTC
# Line 1  Line 1 
1  /**  /**
2  * webforms2_repetition.js   * webforms2_repetition.js
3  */   */
4    
5  Drupal.webforms2Repetition = {  Drupal.webforms2Repetition = {
6    activeButton: null,   // Used to track which "add" button was last clicked    activeButton: null,   // Used to track which "add" button was last clicked
# Line 9  Drupal.webforms2Repetition = { Line 9  Drupal.webforms2Repetition = {
9  };  };
10    
11  /**  /**
12  * Tracking which button was last clicked is difficult, because the webforms2   * Tracking which button was last clicked is difficult, because the webforms2
13  * library has its own way of managing events, rather than using the jquery framework.   * library has its own way of managing events, rather than using the jquery framework.
14  * Furthermore, it explicitly does things to the "onclick" event, in a custom way.   * Furthermore, it explicitly does things to the "onclick" event, in a custom way.
15  * The only solution I found that seems to work reliably is to have the PHP   * The only solution I found that seems to work reliably is to have the PHP
16  * code set the "onclick" attribute on the button directly in the html.   * code set the "onclick" attribute on the button directly in the html.
17  */   */
18  Drupal.webforms2Repetition.onButtonClicked = function(e) {  Drupal.webforms2Repetition.onButtonClicked = function(e) {
19    var oTarget = e.target ? e.target : e.srcElement;    var oTarget = e.target ? e.target : e.srcElement;
20    if (oTarget && oTarget != Drupal.webforms2Repetition.activeButton) {    if (oTarget && oTarget != Drupal.webforms2Repetition.activeButton) {
# Line 32  Drupal.webforms2Repetition.onButtonClick Line 32  Drupal.webforms2Repetition.onButtonClick
32  }  }
33    
34  /**  /**
35  * Event handler called on the repetition template, when a new block is added.   * Event handler called on the repetition template, when a new block is added.
36  */   */
37  Drupal.webforms2Repetition.onBlockAdded = function(e) {  Drupal.webforms2Repetition.onBlockAdded = function(e) {
38    var oNewBlock;    var oNewBlock;
39    
# Line 63  Drupal.webforms2Repetition.onBlockAdded Line 63  Drupal.webforms2Repetition.onBlockAdded
63  }  }
64    
65  /**  /**
66  * Event handler called on the repetition template, when a block is moved.   * Event handler called on the repetition template, when a block is moved.
67  */   */
68  Drupal.webforms2Repetition.onBlockMoved = function(e) {  Drupal.webforms2Repetition.onBlockMoved = function(e) {
69    if (Drupal.webforms2Repetition.activeButton) {    if (Drupal.webforms2Repetition.activeButton) {
70      var sButtonType = $(Drupal.webforms2Repetition.activeButton).attr('type').toLowerCase();      var sButtonType = $(Drupal.webforms2Repetition.activeButton).attr('type').toLowerCase();
# Line 76  Drupal.webforms2Repetition.onBlockMoved Line 76  Drupal.webforms2Repetition.onBlockMoved
76  }  }
77    
78  /**  /**
79  * Event handler called on the repetition template, when a block is removed.   * Event handler called on the repetition template, when a block is removed.
80  */   */
81  Drupal.webforms2Repetition.onBlockRemoved = function(e) {  Drupal.webforms2Repetition.onBlockRemoved = function(e) {
82    Drupal.webforms2Repetition.activeButton = null;    Drupal.webforms2Repetition.activeButton = null;
83  }  }
84    
85  /**  /**
86  * Let interested objects subscribe to events   * Let interested objects subscribe to events
87  */   */
88  Drupal.webforms2Repetition.subscribe = function(oSubscriber) {  Drupal.webforms2Repetition.subscribe = function(oSubscriber) {
89          Drupal.webforms2Repetition.subscribers.push(oSubscriber);          Drupal.webforms2Repetition.subscribers.push(oSubscriber);
90  }  }
91    
92  /**  /**
93  * Notify subscribers of anything interesting that happens   * Notify subscribers of anything interesting that happens
94  */   */
95  Drupal.webforms2Repetition.notifySubscribers = function(sEvent, oBlock) {  Drupal.webforms2Repetition.notifySubscribers = function(sEvent, oBlock) {
96    //alert(sEvent + "\n" + oBlock.innerHTML);    //alert(sEvent + "\n" + oBlock.innerHTML);
97          var i, o;          var i, o;
# Line 102  Drupal.webforms2Repetition.notifySubscri Line 102  Drupal.webforms2Repetition.notifySubscri
102  }  }
103    
104  /**  /**
105  * Document Ready   * Document Ready
106  */   */
107  $(function() {  $(function() {
108    // For each repetition template    // For each repetition template
109    $(".webforms2_repetition_template").each(function() {    $(".webforms2_repetition_template").each(function() {

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2