2 +--------------------------------------------------------------------+
3 | Copyright CiviCRM LLC. All rights reserved. |
5 | This work is published under the GNU AGPLv3 license with some |
6 | permitted exceptions and without any warranty. For full license |
7 | and copyright information, see https://civicrm.org/licensing |
8 +--------------------------------------------------------------------+
11 {if $priceSet && $allowGroupOnWaitlist}
13 <script type="text/javascript">
14 var isAdditionalParticipants = false;
16 var pPartiRef = Array( );
20 pricesetParticipantCount( );
21 allowGroupOnWaitlist(0, pPartiCount);
24 function pricesetParticipantCount( ) {
26 cj("input,#priceset select,#priceset").each(function () {
28 if ( cj(this).attr('price') ) {
29 switch( cj(this).attr('type') ) {
31 eval( 'var option = ' + cj(this).attr('price') ) ;
33 optionPart = option[1].split(optionSep);
36 if ( optionPart[1] ) {
37 addCount = parseInt(optionPart[1]);
40 if( cj(this).prop('checked') ) {
41 pPartiCount += addCount;
42 pPartiRef[ele] += addCount;
45 cj(this).click( function(){
46 if( cj(this).prop('checked') ) {
47 pPartiCount += addCount;
48 pPartiRef[ele] += addCount;
50 pPartiCount -= addCount;
51 pPartiRef[ele] -= addCount;
53 updateWaitingStatus( pPartiCount );
58 //default calcution of element.
59 eval( 'var option = ' + cj(this).attr('price') );
61 optionPart = option[1].split(optionSep);
64 if ( optionPart[1] ) {
65 addCount = parseInt(optionPart[1]);
67 if ( ! pPartiRef[ele] ) {
71 if( cj(this).prop('checked') ) {
72 pPartiCount = parseInt(pPartiCount) + addCount - parseInt(pPartiRef[ele]);
73 pPartiRef[ele] = addCount;
76 cj(this).click( function(){
77 pPartiCount = parseInt(pPartiCount) + addCount - parseInt(pPartiRef[ele]);
78 pPartiRef[ele] = addCount;
79 updateWaitingStatus( pPartiCount );
85 // default calcution of element.
86 var textval = parseFloat( cj(this).val() );
89 eval( 'var option = '+ cj(this).attr('price') );
91 if ( ! pPartiRef[ele] ) {
94 optionPart = option[1].split(optionSep);
95 if ( optionPart[1] ) {
96 addCount = parseInt( optionPart[1] );
97 var curval = textval * addCount;
99 pPartiCount = parseInt(pPartiCount) + curval - parseInt(pPartiRef[ele]);
100 pPartiRef[ele] = curval;
105 //event driven calculation of element.
106 cj(this).bind( 'keyup', function() { calculateTextCount( this );
107 }).bind( 'blur' , function() { calculateTextCount( this );
114 //default calcution of element.
115 var ele = cj(this).attr('id');
116 if ( ! pPartiRef[ele] ) {
120 eval( 'var selectedText = ' + cj(this).attr('price') );
121 if ( cj(this).val( ) ) {
122 optionPart = selectedText[cj(this).val( )].split(optionSep);
123 if ( optionPart[1] ) {
124 addcount = parseInt( optionPart[1] );
129 pPartiCount = parseInt(pPartiCount) + addcount - parseInt(pPartiRef[ele]);
130 pPartiRef[ele] = addcount;
133 //event driven calculation of element.
134 cj(this).change( function() {
135 var ele = cj(this).attr('id');
136 if ( ! pPartiRef[ele] ) {
139 eval( 'var selectedText = ' + cj(this).attr('price') );
142 if ( cj(this).val( ) ) {
143 var optionPart = selectedText[cj(this).val( )].split(optionSep);
144 if ( optionPart[1] ) {
145 addcount = parseInt( optionPart[1] );
150 pPartiCount = parseInt(pPartiCount) + addcount - parseInt(pPartiRef[ele]);
151 pPartiRef[ele] = addcount;
153 pPartiCount = parseInt(pPartiCount) - parseInt(pPartiRef[ele]);
156 updateWaitingStatus( pPartiCount );
164 function calculateTextCount( object ) {
165 eval( 'var option = ' + cj(object).attr('price') );
167 if ( ! pPartiRef[ele] ) {
170 var optionPart = option[1].split(optionSep);
171 if ( optionPart[1] ) {
172 addCount = parseInt( optionPart[1] );
173 var textval = parseInt( cj(object).attr('value') );
174 var curval = textval * addCount;
175 if ( textval >= 0 ) {
176 pPartiCount = pPartiCount + curval - parseInt(pPartiRef[ele]);
177 pPartiRef[ele] = curval;
179 pPartiCount = pPartiCount - parseInt(pPartiRef[ele]);
182 updateWaitingStatus( pPartiCount );
186 function updateWaitingStatus( pricesetParticipantCount ) {
187 allowGroupOnWaitlist( 0, pricesetParticipantCount );