2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.4 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2013 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
27 {if $priceSet && $allowGroupOnWaitlist}
29 <script type="text/javascript">
30 var isAdditionalParticipants = false;
32 var pPartiRef = Array( );
35 cj(document).ready( function( ) {
36 pricesetParticipantCount( );
37 allowGroupOnWaitlist(0, pPartiCount);
40 function pricesetParticipantCount( ) {
42 cj("input,#priceset select,#priceset").each(function () {
44 if ( cj(this).attr('price') ) {
45 switch( cj(this).attr('type') ) {
47 eval( 'var option = ' + cj(this).attr('price') ) ;
49 optionPart = option[1].split(optionSep);
52 if ( optionPart[1] ) {
53 addCount = parseInt(optionPart[1]);
56 if( cj(this).prop('checked') ) {
57 pPartiCount += addCount;
58 pPartiRef[ele] += addCount;
61 cj(this).click( function(){
62 if( cj(this).prop('checked') ) {
63 pPartiCount += addCount;
64 pPartiRef[ele] += addCount;
66 pPartiCount -= addCount;
67 pPartiRef[ele] -= addCount;
69 updateWaitingStatus( pPartiCount );
74 //default calcution of element.
75 eval( 'var option = ' + cj(this).attr('price') );
77 optionPart = option[1].split(optionSep);
80 if ( optionPart[1] ) {
81 addCount = parseInt(optionPart[1]);
83 if ( ! pPartiRef[ele] ) {
87 if( cj(this).prop('checked') ) {
88 pPartiCount = parseInt(pPartiCount) + addCount - parseInt(pPartiRef[ele]);
89 pPartiRef[ele] = addCount;
92 cj(this).click( function(){
93 pPartiCount = parseInt(pPartiCount) + addCount - parseInt(pPartiRef[ele]);
94 pPartiRef[ele] = addCount;
95 updateWaitingStatus( pPartiCount );
101 // default calcution of element.
102 var textval = parseFloat( cj(this).val() );
105 eval( 'var option = '+ cj(this).attr('price') );
107 if ( ! pPartiRef[ele] ) {
110 optionPart = option[1].split(optionSep);
111 if ( optionPart[1] ) {
112 addCount = parseInt( optionPart[1] );
113 var curval = textval * addCount;
114 if ( textval >= 0 ) {
115 pPartiCount = parseInt(pPartiCount) + curval - parseInt(pPartiRef[ele]);
116 pPartiRef[ele] = curval;
121 //event driven calculation of element.
122 cj(this).bind( 'keyup', function() { calculateTextCount( this );
123 }).bind( 'blur' , function() { calculateTextCount( this );
130 //default calcution of element.
131 var ele = cj(this).attr('id');
132 if ( ! pPartiRef[ele] ) {
136 eval( 'var selectedText = ' + cj(this).attr('price') );
137 if ( cj(this).val( ) ) {
138 optionPart = selectedText[cj(this).val( )].split(optionSep);
139 if ( optionPart[1] ) {
140 addcount = parseInt( optionPart[1] );
145 pPartiCount = parseInt(pPartiCount) + addcount - parseInt(pPartiRef[ele]);
146 pPartiRef[ele] = addcount;
149 //event driven calculation of element.
150 cj(this).change( function() {
151 var ele = cj(this).attr('id');
152 if ( ! pPartiRef[ele] ) {
155 eval( 'var selectedText = ' + cj(this).attr('price') );
158 if ( cj(this).val( ) ) {
159 var optionPart = selectedText[cj(this).val( )].split(optionSep);
160 if ( optionPart[1] ) {
161 addcount = parseInt( optionPart[1] );
166 pPartiCount = parseInt(pPartiCount) + addcount - parseInt(pPartiRef[ele]);
167 pPartiRef[ele] = addcount;
169 pPartiCount = parseInt(pPartiCount) - parseInt(pPartiRef[ele]);
172 updateWaitingStatus( pPartiCount );
180 function calculateTextCount( object ) {
181 eval( 'var option = ' + cj(object).attr('price') );
183 if ( ! pPartiRef[ele] ) {
186 var optionPart = option[1].split(optionSep);
187 if ( optionPart[1] ) {
188 addCount = parseInt( optionPart[1] );
189 var textval = parseInt( cj(object).attr('value') );
190 var curval = textval * addCount;
191 if ( textval >= 0 ) {
192 pPartiCount = pPartiCount + curval - parseInt(pPartiRef[ele]);
193 pPartiRef[ele] = curval;
195 pPartiCount = pPartiCount - parseInt(pPartiRef[ele]);
198 updateWaitingStatus( pPartiCount );
202 function updateWaitingStatus( pricesetParticipantCount ) {
203 allowGroupOnWaitlist( 0, pricesetParticipantCount );