Changeset 175183
- Timestamp:
- 11/19/2009 09:50:39 AM (16 years ago)
- Location:
- price-calc/trunk
- Files:
-
- 5 edited
-
ajax/front.js (modified) (22 diffs)
-
control/Front.php (modified) (1 diff)
-
price-calc.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
templates/front.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
price-calc/trunk/ajax/front.js
r174871 r175183 7 7 */ 8 8 9 var ttpc_memory ;9 var ttpc_memory = new Object; 10 10 11 11 function validate_unequal_reference( left, right, msg ) { 12 leftval = jQuery("#"+left).val();13 rightval = jQuery("#"+right).val();12 var leftval = jQuery("#"+left).val(); 13 var rightval = jQuery("#"+right).val(); 14 14 if (leftval != rightval) { 15 15 alert(msg); … … 19 19 } 20 20 function validate_unequal_value( left, right, msg ) { 21 leftval = jQuery("#"+left).val();21 var leftval = jQuery("#"+left).val(); 22 22 if (leftval != right) { 23 23 alert(msg); … … 27 27 } 28 28 function validate_greater_reference( left, right, msg ) { 29 leftval = parseFloat(jQuery("#"+left).val());30 rightval = parseFloat(jQuery("#"+right).val());29 var leftval = parseFloat(jQuery("#"+left).val()); 30 var rightval = parseFloat(jQuery("#"+right).val()); 31 31 if (leftval > rightval) { 32 32 alert(msg); … … 36 36 } 37 37 function validate_greater_value( left, right, msg ) { 38 leftval = parseFloat(jQuery("#"+left).val());38 var leftval = parseFloat(jQuery("#"+left).val()); 39 39 if (leftval > parseFloat(right)) { 40 40 alert(msg); … … 44 44 } 45 45 function validate_less_reference( left, right, msg ) { 46 leftval = parseFloat(jQuery("#"+left).val());47 rightval = parseFloat(jQuery("#"+right).val());46 var leftval = parseFloat(jQuery("#"+left).val()); 47 var rightval = parseFloat(jQuery("#"+right).val()); 48 48 if (leftval < rightval) { 49 49 alert(msg); … … 53 53 } 54 54 function validate_less_value( left, right, msg ) { 55 leftval = parseFloat(jQuery("#"+left).val());55 var leftval = parseFloat(jQuery("#"+left).val()); 56 56 if (leftval < parseFloat(right)) { 57 57 alert(msg); … … 62 62 63 63 function validate_equal_reference( left, right, msg ) { 64 leftval = jQuery("#"+left).val();65 rightval = jQuery("#"+right).val();64 var leftval = jQuery("#"+left).val(); 65 var rightval = jQuery("#"+right).val(); 66 66 if (leftval == rightval) { 67 67 alert(msg); … … 71 71 } 72 72 function validate_equal_value( left, right, msg ) { 73 leftval = jQuery("#"+left).val();73 var leftval = jQuery("#"+left).val(); 74 74 if (leftval == right) { 75 75 alert(msg); … … 143 143 144 144 function getParamMap( values ) { 145 map = new Object;146 147 for( idx in values) {145 var param, map = new Object; 146 147 for( var idx=0; idx<values.length; idx++ ) { 148 148 id = values[idx]; 149 149 obj = jQuery("[name='" + id + "']"); … … 160 160 161 161 function sendAjax() { 162 var all_with_contact = all.slice().concat(contact );162 var all_with_contact = ttpc_all.slice().concat( ttpc_contact ); 163 163 jQuery.get( "index.php", getParamMap( all_with_contact ), responseAjax ); 164 164 } 165 165 166 166 function checkForm( checkMail ) { 167 required =obligatory.slice();167 var required = ttpc_obligatory.slice(); 168 168 169 169 // if email selected, then add contact info as required … … 173 173 174 174 var ok = true; 175 for( idx in required) {175 for( var idx=0; idx<required.length; idx++ ) { 176 176 input = jQuery("[name='" + required[idx] + "']"); 177 177 if (input.length != 0) { // ignore if form element is not displayed … … 206 206 207 207 function printWindow() { 208 var all_with_contact = all.slice().concat(contact );208 var all_with_contact = ttpc_all.slice().concat( ttpc_contact ); 209 209 210 210 if( !validate_extra() ) … … 215 215 return false; 216 216 } 217 va lues='';218 for( idx in all) {219 id = all_with_contact[idx];220 va lue = jQuery("#" + id).val();217 var values=''; 218 for( var idx=0; idx<ttpc_all.length; idx++ ) { 219 var id = all_with_contact[idx]; 220 var value = jQuery("#" + id).val(); 221 221 values += "&" + encodeURI(id) + '=' + encodeURI(value); 222 222 } 223 win = window.open('index.php?price-calc-ajax=1&print=1'+values,'mywin','left=20,top=20,width=500,height=500,toolbar=1,resizable=1,location=1');223 window.open('index.php?price-calc-ajax=1&print=1'+values,'mywin','left=20,top=20,width=500,height=500,toolbar=1,resizable=1,location=1'); 224 224 } 225 225 226 226 function ttpc_updateSubtotal() { 227 var total = 0; 227 var i, id, operator, operand, valid, price, total = 0; 228 var obj, text, priceTxt, number; 228 229 229 230 ttpc_memory = []; 230 for( i in formula_ids) {231 for( var i=0; i<formula_ids.length; i++ ) { 231 232 id = formula_ids[i]; 232 233 operator = formula_operators[i]; … … 244 245 valid = !isNaN(operand); 245 246 } else { 246 switch (t ypes[id]) {247 switch (ttpc_types[id]) { 247 248 case 'select': 248 249 price = jQuery("#" + id + " option:selected").attr('price'); … … 304 305 } 305 306 306 for( id in ttpc_results ) {307 for( var id in ttpc_results ) { 307 308 variable = ttpc_results[id]; 308 309 if( variable in ttpc_memory ) { … … 311 312 } 312 313 } 314 315 var warn; 313 316 if(!checkForm( false )) { 314 317 warn = "(form incomplete)"; … … 321 324 322 325 function ttpc_nextStage(){ 323 stage = parseInt(jQuery(this).attr("stage"));326 var stage = parseInt(jQuery(this).attr("stage")); 324 327 if(!stage) 325 328 stage = 0; … … 347 350 348 351 function ttpc_previousStage() { 349 stage = parseInt(jQuery(this).attr("stage"));352 var stage = parseInt(jQuery(this).attr("stage")); 350 353 351 354 ttpc_updateStages( stage ); … … 360 363 361 364 function ttpc_updateForms( stage ) { 362 idx = stage;365 var idx = stage; 363 366 jQuery(".form-stage:eq(" + idx + ")").show(); 364 367 if (ttpc_multitab) { 365 368 jQuery(".form-stage:lt(" + idx + ")").hide(); 366 369 } else { 367 if(!(stage== 0&& jQuery('#variation').hasClass('stage-continue-direct')))370 if(!(stage==1 && jQuery('#variation').hasClass('stage-continue-direct'))) 368 371 jQuery("#form-stage-" + (stage-1) + " :input").attr("disabled", "disabled"); 369 372 jQuery("#form-stage-" + stage + " :input").removeAttr("disabled"); … … 378 381 ttpc_enterTabbing(); 379 382 } 383 384 if( stage == ttpc_stages ) { 385 jQuery("#control_form").show(); 386 } else { 387 jQuery("#control_form").hide(); 388 } 380 389 } 381 390 … … 399 408 400 409 function ttpc_loadStage( stage ) { 401 params = {410 var params = { 402 411 "price-calc-form":1, 403 412 "formstage": stage, 404 413 "variation":jQuery( "#variation" ).val(), 405 "values":JSON.stringify(getParamMap( all ))414 "values":JSON.stringify(getParamMap( ttpc_all )) 406 415 }; 416 jQuery("#form-stage-" + stage).remove(); 417 jQuery("#stage_loading").show(); 407 418 jQuery.get( "index.php", params, function( html ) { 408 419 409 420 jQuery("#main_form").append( html ); 410 jQuery("#control_form").css( "display", "block" );411 421 412 422 jQuery("#response").empty(); 413 423 ttpc_updateStages( stage ); 424 jQuery("#stage_loading").hide(); 414 425 } ); 415 jQuery("#stage_loading").hide();416 426 417 427 } … … 450 460 jQuery(document).ready( function() { 451 461 jQuery(".stage-continue").click( ttpc_nextStage ).removeAttr("disabled"); 452 jQuery("#variation.stage-continue-direct").change( ttpc_ loadStage );462 jQuery("#variation.stage-continue-direct").change( ttpc_nextStage ); 453 463 jQuery(".stage-back").click( ttpc_previousStage ); 454 464 jQuery("#company_mail").change( function() { -
price-calc/trunk/control/Front.php
r174871 r175183 23 23 $results = $opts->getResults(); 24 24 $stageNames = $opts->getStageNames(); 25 $stages = $opts->getStages(); 25 26 26 27 $fullquote = get_option( 'price-calc-fullquote' ); -
price-calc/trunk/price-calc.php
r174876 r175183 4 4 Plugin URI: http://www.thickthumb.com/open-source/price-calc/ 5 5 Description: Displays a configurable price calculator for your products 6 Version: 0.6.2 6 Version: 0.6.2.1 7 7 Author: Igor Prochazka 8 8 Author URI: http://www.thickthumb.com -
price-calc/trunk/readme.txt
r174871 r175183 5 5 Requires at least: 2.8 6 6 Tested up to: 2.8.6 7 Stable tag: 0.6.2 7 Stable tag: 0.6.2.1 8 8 9 9 "price-calc" is a WordPress plug-in that shows a nice inter-active price calculator for your product variations on any post or page. … … 78 78 * Enhanced customizing via WP hooks (PHP and JS) 79 79 * Option to force Email contact 80 81 = 0.6.2.1 = 82 * Bug-fixes 83 * Enhanced compability 84 -
price-calc/trunk/templates/front.php
r174871 r175183 10 10 11 11 <script> 12 var obligatory=<?php echo json_encode($obligatory); ?>;13 var all=<?php $all = array_keys($options); $all[] = "variation"; echo json_encode($all) ?>;14 var t ypes=<?php echo json_encode( $types ) ?>;12 var ttpc_obligatory=<?php echo json_encode($obligatory); ?>; 13 var ttpc_all=<?php $all = array_keys($options); $all[] = "variation"; echo json_encode($all) ?>; 14 var ttpc_types=<?php echo json_encode( $types ) ?>; 15 15 var ttpc_results=<?php echo json_encode($results) ?>; 16 var contact=<?php echo json_encode($contact_info) ?>;16 var ttpc_contact=<?php echo json_encode($contact_info) ?>; 17 17 var contact_obligatory=<?php echo json_encode($contact_obligatory) ?>; 18 18 var formula_ids=<?php echo json_encode($formula_ids) ?>; … … 29 29 var ttpc_preloadstages=<?php echo $preloadstages ? 'true' : 'false' ?>; 30 30 var ttpc_contact_force=<?php echo $contact == 'force' ? 'true' : 'false' ?>; 31 var ttpc_stages=<?php echo count($stages) ?>; 31 32 32 33 function validate_extra() {
Note: See TracChangeset
for help on using the changeset viewer.