Changeset 530820
- Timestamp:
- 04/13/2012 10:22:36 PM (14 years ago)
- Location:
- jazzy-forms/trunk
- Files:
-
- 20 edited
-
back/ctrl-forms.php (modified) (2 diffs)
-
back/elements.js (modified) (3 diffs)
-
back/gui.css (modified) (5 diffs)
-
back/gui.js (modified) (8 diffs)
-
back/img/c.png (modified) (previous)
-
back/img/f.png (modified) (previous)
-
back/img/m.png (modified) (previous)
-
back/img/n.png (modified) (previous)
-
back/tpl-diagnostics.php (modified) (1 diff)
-
back/tpl-forms.php (modified) (7 diffs)
-
core/Graph.php (modified) (3 diffs)
-
front/ctrl-shortcode.php (modified) (3 diffs)
-
front/jazzy-forms.js (modified) (12 diffs)
-
front/themes/1.css (modified) (2 diffs)
-
front/tmpl-list.php (modified) (7 diffs)
-
generated/Basic_Model.php (modified) (5 diffs)
-
generated/drop.sql (modified) (1 diff)
-
generated/schema.sql (modified) (1 diff)
-
jazzy-forms.php (modified) (10 diffs)
-
readme.txt (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
jazzy-forms/trunk/back/ctrl-forms.php
r516626 r530820 3 3 function jzzf_ctrl_forms() { 4 4 if($_GET['diagnostics']) { 5 if($_POST['panic']) { 6 jzzf_panic(); 7 return; 8 } else { 9 $db_version = jzzf_get_version(); 10 $version = JZZF_VERSION; 11 $forms = jzzf_list_form(); 12 include('tpl-diagnostics.php'); 13 return; 14 } 5 jzzf_ctrl_diagnostics(); 6 return; 15 7 } elseif($_POST['delete']) { 8 jzzf_info("Deleting form {$_POST['delete']}"); 16 9 if(jzzf_delete_form($_POST['delete'])) { 10 jzzf_info("Success."); 17 11 $msg = "Form Deleted."; 18 12 } else { 13 jzzf_error("Error deleting form."); 19 14 $msg = "An error ocurred while deleting your form!"; 20 15 } 21 16 } elseif($_POST['form']) { 22 17 $json = stripcslashes($_POST['form']); 18 jzzf_info("Setting form"); 19 jzzf_debug($json); 23 20 $form = json_decode($json); 24 21 if($current = jzzf_set_form($form)) { 22 jzzf_info("Ok."); 25 23 $msg = "Form Saved."; 26 24 } else { 25 jzzf_error("Error setting form."); 27 26 $msg = "An error ocurred while saving your form!"; 28 27 } … … 31 30 include('tpl-forms.php'); 32 31 } 32 33 function jzzf_ctrl_diagnostics() { 34 jzzf_info("Diagnostics controller"); 35 if($_POST['panic']) { 36 jzzf_critical("PANIC!"); 37 jzzf_panic(); 38 return; 39 } elseif($_POST['tweaks']) { 40 jzzf_info("Updating tweaks."); 41 update_option('jzzf_tweak_suppress_email', $_POST['tweak_suppress_email']); 42 update_option('jzzf_log_level', $_POST['log_level']); 43 update_option('jzzf_log_file', $_POST['log_file']); 44 } 45 $db_version = jzzf_get_version(); 46 $version = JZZF_VERSION; 47 $forms = jzzf_list_form(); 48 $tweak_suppress_email = get_option('jzzf_tweak_suppress_email', false); 49 $log_level = jzzf_log_level(); 50 $log_file = jzzf_log_file(); 51 include('tpl-diagnostics.php'); 52 return; 53 } -
jazzy-forms/trunk/back/elements.js
r516626 r530820 1 function jzzf_element($ ) {1 function jzzf_element($, update_listener) { 2 2 var partials = {}; 3 3 … … 83 83 $(this).parentsUntil('#jzzf_elements_list').remove(); 84 84 } 85 update_listener(); 85 86 }); 86 87 var self = this; … … 186 187 } 187 188 188 jzzf_element.create = function(type ) {189 return new jzzf_element(jQuery );189 jzzf_element.create = function(type, listener) { 190 return new jzzf_element(jQuery, listener); 190 191 } 191 192 -
jazzy-forms/trunk/back/gui.css
r516626 r530820 134 134 } 135 135 136 .jzzf_element label { 137 vertical-align: top; 138 } 139 140 .jzzf_element_body ul li { 141 overflow: hidden; 142 height: 1%; 143 } 144 136 145 .jzzf_element_header:hover { 137 146 background-color: #e8e8e8; … … 161 170 } 162 171 163 .jzzf_element_body label, .jzzf_section > ul > li > label {172 .jzzf_element_body label, .jzzf_section > ul > li > label, .jzzf_section > div > ul > li > label { 164 173 display: inline-block; 165 174 width: 140px; … … 175 184 } 176 185 177 .jzzf_element_body fieldset ul li input[type=text], .jzzf_section > ul > li > input[type=text] { 186 .jzzf_element_body fieldset ul li input[type=text], 187 .jzzf_section > ul > li > input[type=text], 188 .jzzf_section > div > ul > li > input[type=text], 189 .jzzf_section > ul > li > textarea { 178 190 width: 280px; 179 } 180 181 #jzzf_css { 182 width: 400px; 191 display: inline-block; 192 float: none; 193 } 194 195 #jzzf_css, #jzzf_email_message { 196 width: 435px; 183 197 height: 200px; 184 198 } … … 222 236 .jzzf_type_h { background-image: url('img/h.png'); } 223 237 .jzzf_type_m { background-image: url('img/m.png'); } 238 .jzzf_type_e { background-image: url('img/e.png'); } 239 .jzzf_type_x { background-image: url('img/x.png'); } 224 240 225 241 .jzzf_arrow { … … 286 302 width: 160px; 287 303 } 304 305 #jzzf_section_email.jzzf_enabled .jzzf_email_settings { 306 display: block; 307 } 308 309 #jzzf_section_email.jzzf_disabled .jzzf_email_settings { 310 display: none; 311 } 312 313 #jzzf_section_email.jzzf_enabled .jzzf_email_disclaimer { 314 display: none; 315 } 316 317 #jzzf_section_email.jzzf_disabled .jzzf_email_disclaimer { 318 display: block; 319 } 320 321 .jzzf_help { 322 float: right; 323 width: 500px; 324 } -
jazzy-forms/trunk/back/gui.js
r516626 r530820 6 6 var text_dirty = text_unload + "\nAre you sure you want to discard them?"; 7 7 8 var email_fields = ['to', 'from', 'cc', 'bcc', 'subject', 'message', 'sending', 'ok', 'fail']; 9 8 10 function new_element(type) { 9 11 var elements = get_elements(); // need existing elements to suggest a valid name/title … … 26 28 var type = item.attr('jzzf_type'); 27 29 var obj = new_element(type); 28 var gui = jzzf_element.create(type );30 var gui = jzzf_element.create(type, adjust_email_tab); 29 31 gui.add(obj, remove ? item : null, false); 32 adjust_email_tab(); 30 33 } 31 34 … … 119 122 $('#jzzf_shortcode').val('[jazzy form="' + $('#jzzf_name').val() + '"]'); 120 123 } 124 125 function set_email(email) { 126 if(!email) { 127 email = {"to": "", "from": "", "cc": "", "bcc": "", "subject": "", "message": ""}; 128 } 129 for(var idx = 0; idx<email_fields.length; idx++) { 130 $('#jzzf_email_' + email_fields[idx]).val(email[email_fields[idx]]); 131 } 132 } 133 121 134 function set_form(form) { 122 135 if(form==null) { … … 146 159 element.add(form.elements[i], null); 147 160 } 161 adjust_email_tab(form.elements); 162 set_email(form.email); 148 163 } 149 164 update_shortcode(); … … 161 176 } 162 177 178 function has_email(elements) { 179 if(elements == null) { 180 elements = get_elements(); 181 } 182 for(var i=0; i<elements.length; i++) { 183 if(elements[i].type == 'e') { 184 return true; 185 } 186 } 187 return false; 188 } 189 190 function get_email() { 191 var result = {}; 192 for(var idx=0; idx<email_fields.length; idx++) { 193 result[email_fields[idx]] = $('#jzzf_email_' + email_fields[idx]).val(); 194 }; 195 return result; 196 } 197 163 198 function get_form() { 164 return { 199 var elements = get_elements(); 200 var form = { 165 201 "id": $('#jzzf_id').val(), 166 202 "title": $('#jzzf_title').val(), … … 169 205 "realtime": $('#jzzf_realtime').is(':checked'), 170 206 "css": $('#jzzf_css').val(), 171 "elements": get_elements() 172 }; 207 "elements": elements 208 }; 209 if(has_email(elements)) { 210 form.email = get_email(); 211 } else { 212 form.email = null; 213 } 214 return form; 173 215 } 174 216 … … 185 227 var id_helper = new jzzf_id(jzzf_forms); 186 228 var name = id_helper.suggest_name(title); 187 form = {'title': title, 'name': name, 'elements': [], 'theme': 1, 'realtime': true}; 229 form = { 230 'title': title, 231 'name': name, 232 'elements': [], 233 'theme': 1, 234 'realtime': true, 235 'email': { 236 'sending': 'Sending...', 237 'ok': "Message sent", 238 'fail': "Can't send the message" 239 } 240 }; 188 241 elements = []; 189 242 $('#jzzf_form').show(); … … 219 272 } 220 273 274 function adjust_email_tab(elements) { 275 var email = has_email(elements); 276 $('#jzzf_section_email').toggleClass('jzzf_enabled', email).toggleClass('jzzf_disabled', !email); 277 } 278 221 279 $(function() { 222 280 form_index = $('#jzzf_selector option:selected').index(); -
jazzy-forms/trunk/back/tpl-diagnostics.php
r516626 r530820 20 20 Plugins: <?php echo htmlentities(json_encode(get_plugins())); ?> 21 21 22 <form method="post"> 23 Tweaks: 24 <input type="checkbox" name="tweak_suppress_email"<?php if($tweak_suppress_email): ?> checked="checked" <?php endif ?> value="1"> Suppress email 25 Log file <input type="text" name="log_file" value="<?php esc_attr_e($log_file) ?>"> 26 Log level <input type="text" name="log_level" value="<?php esc_attr_e($log_level) ?>"> (0: off, 10-50: debug-critical) 27 <input type="submit" name="tweaks" value="Save tweaks" class="button-secondary"> 28 </form> 22 29 </pre> 23 30 <h2>Panic</h2> -
jazzy-forms/trunk/back/tpl-forms.php
r516626 r530820 194 194 {{>foot}} 195 195 </script> 196 <script id="jzzf_tmpl_x" type="text/html"> 197 {{>common}} 198 {{>foot}} 199 </script> 200 <script id="jzzf_tmpl_e" type="text/html"> 201 {{>common}} 202 <fieldset class="jzzf_div_fixed">See the Email tab for email settings.</fieldset> 203 {{>foot}} 204 </script> 196 205 <script id="jzzf_tmpl_t" type="text/html"> 197 206 {{>common_raw}} … … 200 209 <li> 201 210 <label for="jzzf_element_{{counter}}_title">Text</label> 202 < input type="text" id="jzzf_element_{{counter}}_title" class="jzzf_element_title" value="{{title}}">211 <textarea id="jzzf_element_{{counter}}_title" class="jzzf_element_title">{{title}}</textarea> 203 212 </li> 204 213 </ul> … … 224 233 <li> 225 234 <label for="jzzf_element_{{counter}}_title">HTML code</label> 226 < input type="text" id="jzzf_element_{{counter}}_title" class="jzzf_element_title" value="{{title}}">235 <textarea id="jzzf_element_{{counter}}_title" class="jzzf_element_title">{{title}}</textarea> 227 236 </li> 228 237 </ul> … … 288 297 <li jzzf_section="elements">Elements</li> 289 298 <li jzzf_section="appearance">Appearance</li> 299 <li jzzf_section="email">Email</li> 290 300 <li jzzf_section="general" >General</li> 291 301 </ul> … … 295 305 <div class="jzzf_column_heading" id="jzzf_elements_toolbox_description">Available form elements</div> 296 306 <ul id="jzzf_toolbox_input" class="jzzf_elements_toolbox_items"> 297 <li jzzf_type="n"><div class="jzzf_type jzzf_type_n"></div> Number Entry</li>307 <li jzzf_type="n"><div class="jzzf_type jzzf_type_n"></div>Input</li> 298 308 <li jzzf_type="d"><div class="jzzf_type jzzf_type_d"></div>Drop-down Menu</li> 299 309 <li jzzf_type="r"><div class="jzzf_type jzzf_type_r"></div>Radio Buttons</li> … … 303 313 <ul id="jzzf_toolbox_buttons" class="jzzf_elements_toolbox_items"> 304 314 <li jzzf_type="u"><div class="jzzf_type jzzf_type_u"></div>Update Button</li> 315 <li jzzf_type="x"><div class="jzzf_type jzzf_type_x"></div>Reset Button</li> 316 <li jzzf_type="e"><div class="jzzf_type jzzf_type_e"></div>Email Button</li> 305 317 </ul> 306 318 <ul id="jzzf_toolbox_text" class="jzzf_elements_toolbox_items"> … … 327 339 </li> 328 340 </ul> 341 </div> 342 <div class="jzzf_section" id="jzzf_section_email"> 343 <div class="jzzf_email_disclaimer"> 344 Please add an Email button to activate Email. 345 </div> 346 <div class="jzzf_email_settings"> 347 <div class="jzzf_help"> 348 You can use placeholders enclosed by double curly braces here to display user input or calculated values referenced by their IDs, or even the results of inline formulas. <br/><br/> Examples:<br/><br/> 349 <ul class="jzzf_examples"> 350 <li><pre>Hello {{name}}!</pre></li> 351 <li><pre>From: {{name}} <{{email}}></pre></li> 352 <li><pre>The sum of {{a}} and {{b}} is {{a+b}}</pre></li> 353 </ul> 354 </div> 355 <ul> 356 <li> 357 <label for="jzzf_email_to">To</label> 358 <input type="text" id="jzzf_email_to"> 359 </li> 360 <li> 361 <label for="jzzf_email_from">From</label> 362 <input type="text" id="jzzf_email_from"> 363 </li> 364 <li> 365 <label for="jzzf_email_cc">CC</label> 366 <input type="text" id="jzzf_email_cc"> 367 </li> 368 <li> 369 <label for="jzzf_email_bcc">BCC</label> 370 <input type="text" id="jzzf_email_bcc"> 371 </li> 372 <li> 373 <label for="jzzf_email_subject">Subject</label> 374 <input type="text" id="jzzf_email_subject"> 375 </li> 376 <li> 377 <label for="jzzf_email_message">Message</label><br> 378 <textarea id="jzzf_email_message"></textarea> 379 </li> 380 </ul> 381 <div class="jzzf_subsection_heading">Status messages</div> 382 <ul> 383 <li> 384 <label for="jzzf_email_sending">Sending</label> 385 <input type="text" id="jzzf_email_sending"> 386 </li> 387 <li> 388 <label for="jzzf_email_ok">Success</label> 389 <input type="text" id="jzzf_email_ok"> 390 </li> 391 <li> 392 <label for="jzzf_email_fail">Failure</label> 393 <input type="text" id="jzzf_email_fail"> 394 </li> 395 </ul> 396 </div> 329 397 </div> 330 398 <div class="jzzf_section" id="jzzf_section_general"> -
jazzy-forms/trunk/core/Graph.php
r516626 r530820 1 1 <?php 2 2 3 function jzzf_get_graph($elements) { 3 function jzzf_get_graph($form) { 4 $elements = $form->elements; 5 4 6 $data = array(); 5 7 $types = array(); … … 33 35 } 34 36 } 35 return compact('data', 'types', 'dependencies', 'formulas', 'params'); 37 $email = jzzf_get_email_formulas($form); 38 return compact('data', 'types', 'dependencies', 'formulas', 'params', 'email'); 39 } 40 41 function jzzf_get_email_formulas($form) { 42 $formulas = null; 43 if(property_exists($form, 'email') && is_object($form->email)) { 44 $email = $form->email; 45 $formulas = jzzf_formulas_from_template($email->to, 'to') + 46 jzzf_formulas_from_template($email->from, 'form') + 47 jzzf_formulas_from_template($email->cc, 'cc') + 48 jzzf_formulas_from_template($email->bcc, 'bcc') + 49 jzzf_formulas_from_template($email->subject, 'subject') + 50 jzzf_formulas_from_template($email->message, 'message'); 51 } 52 return $formulas; 36 53 } 37 54 … … 55 72 if($val = $element->value) { 56 73 $values = $val; 57 } else {58 $values = 1;59 74 } 60 75 break; -
jazzy-forms/trunk/front/ctrl-shortcode.php
r516626 r530820 53 53 $tpl->css($form->css); 54 54 } 55 $graph = jzzf_get_graph($form ->elements);55 $graph = jzzf_get_graph($form); 56 56 $tpl->graph(jzzf_form_params($form), $graph); 57 57 $tpl->script($form); … … 99 99 $tpl->html($element); 100 100 break; 101 case 'x': 102 $tpl->reset($element); 103 break; 104 case 'e': 105 $tpl->email($element); 106 break; 101 107 } 102 108 $tpl->after($element, ($ahead && $ahead->break) || ($idx==count($form->elements)-1)); … … 110 116 $params = clone $form; 111 117 unset($params->elements); 112 unset($params->css); 118 unset($params->css); 119 if(property_exists($params, 'email') && $params->email) { 120 $params->email = (object) array( 121 "sending" => $form->email->sending, 122 "ok" => $form->email->ok, 123 "fail" => $form->fail 124 ); 125 } 113 126 return $params; 114 127 -
jazzy-forms/trunk/front/jazzy-forms.js
r516626 r530820 5 5 */ 6 6 7 function jazzy_forms($, form_id, jzzf_data, jzzf_types, jzzf_dependencies, jzzf_formulas, jzzf_form, jzzf_params) {7 function jazzy_forms($, form_id, graph) { 8 8 9 9 var all_ids = []; … … 16 16 17 17 function retrieve_all_ids() { 18 for(id in jzzf_types) {18 for(id in graph.types) { 19 19 all_ids.push(id); 20 20 } … … 38 38 function bind() { 39 39 var id; 40 for(id in jzzf_types) {41 if( jzzf_form.realtime) {40 for(id in graph.types) { 41 if(graph.form.realtime) { 42 42 bind_realtime_update(id); 43 43 } 44 if(jzzf_types[id] == 'u') { 45 element(id).click(function() { 46 update(all_ids); 47 }); 48 } 49 } 50 } 51 44 switch(graph.types[id]) { 45 case 'u': 46 element(id).click(function() { 47 update(all_ids); 48 }); 49 break; 50 case 'e': 51 element(id).click(function() { 52 send_email(this); 53 }); 54 break; 55 case 'x': 56 element(id).click(function() { 57 reset_messages(); 58 }) 59 } 60 } 61 } 62 52 63 function bind_realtime_update(id) { 53 switch( jzzf_types[id]) {64 switch(graph.types[id]) { 54 65 case 'r': 55 66 element(id).find('input:radio').bind('change ready', function() { … … 75 86 } 76 87 88 function set_message(node, msg) { 89 $(node).parentsUntil('.jzzf_row').siblings('.jzzf_message').text(msg); 90 } 91 92 function reset_messages() { 93 $('.jzzf_form_' + form_id + ' .jzzf_message').text(''); 94 } 95 96 function send_email(button) { 97 set_message(button, graph.form.email.sending); 98 var values = {}; 99 for(key in graph.email) { 100 var value = evaluate_formula(graph.email[key]); 101 if(graph.email[key].length == 1) { 102 values[key] = sanitize_result(value, key); 103 } else { 104 values[key] = value; 105 } 106 } 107 $.ajax(jzzf_ajax_url, { 108 "data": { 109 "form": form_id, 110 "values": values, 111 "action": "jzzf_email" 112 }, 113 "error": function() { set_message(button, graph.form.email.fail); }, 114 "success": function() { set_message(button, graph.form.email.ok); } 115 }); 116 } 117 77 118 function sanitize_result(val, id) { 78 119 var f = parseFloat(val); … … 86 127 case 'number': 87 128 if(!isNaN(val)) { 88 val = jzzf_format(val, jzzf_params[id]);129 val = jzzf_format(val, graph.params[id]); 89 130 } 90 131 break; … … 98 139 function updating_worker(id) { 99 140 update_dependent(id); 100 if( jzzf_types[id] != 'f' || id in just_updated) {141 if(graph.types[id] != 'f' || id in just_updated) { 101 142 return; 102 143 } … … 106 147 107 148 function update_dependent(id) { 108 if(id in jzzf_dependencies) {109 var deps = jzzf_dependencies[id];149 if(id in graph.dependencies) { 150 var deps = graph.dependencies[id]; 110 151 for(var i=0; i<deps.length; i++) { 111 152 updating_worker(deps[i]); … … 116 157 function evaluate(id) { 117 158 var result; 118 if(!(id in cache) || ( jzzf_types[id] == 'f' && !(id in just_updated))) {159 if(!(id in cache) || (graph.types[id] == 'f' && !(id in just_updated))) { 119 160 result = evaluation_worker(id); 120 161 cache[id] = result; … … 126 167 127 168 function evaluation_worker(id) { 128 switch( jzzf_types[id]) {169 switch(graph.types[id]) { 129 170 case 'n': 130 return element(id).val() * jzzf_data[id]; 171 var input = element(id).val(); 172 if(id in graph.data) { 173 var factor = to_float_for_factor(graph.data[id]); 174 if(!isNaN(factor)) { 175 return input*factor; 176 } else { 177 return input; 178 } 179 } else { 180 return input; 181 } 131 182 case 'r': 132 183 var idx = element(id).find('input:checked').parent().index(); 133 184 if(idx>=0) { 134 return jzzf_data[id][idx];185 return graph.data[id][idx]; 135 186 } else { 136 187 return 0; 137 188 } 138 189 case "c": 139 return element(id).is(':checked') ? jzzf_data[id][1] : jzzf_data[id][0];190 return element(id).is(':checked') ? graph.data[id][1] : graph.data[id][0]; 140 191 case 'd': 141 192 var idx = element(id).find('option:selected').index(); 142 193 if(idx>=0) { 143 return jzzf_data[id][idx];194 return graph.data[id][idx]; 144 195 } else { 145 196 return 0; … … 150 201 return 0; 151 202 } 152 203 204 function to_float_for_calculation(val) { 205 return Number(val); 206 } 207 208 function to_float_for_factor(val) { 209 if(typeof val == 'string' && val.match(/^\s*$/)) { 210 return 1; 211 } else { 212 return Number(val); 213 } 214 } 215 153 216 function formula(id) { 154 var stack = []; 155 var f = jzzf_formulas[id]; 217 var f = graph.formulas[id]; 156 218 if(!f) { 157 219 return undefined; 158 220 } 221 return evaluate_formula(f); 222 } 223 224 function evaluate_formula(f) { 225 var stack = []; 159 226 for(var i=0; i<f.length; i++) { 160 227 switch(f[i][0]) { 161 228 case 'n': 229 case 's': 162 230 stack.push(f[i][1]); 163 231 break; … … 166 234 break; 167 235 case 'o': 168 var right = parseFloat(stack.pop());169 var left = parseFloat(stack.pop());236 var right = to_float_for_calculation(stack.pop()); 237 var left = to_float_for_calculation(stack.pop()); 170 238 var result; 171 239 switch(f[i][1]) { … … 229 297 } 230 298 299 function numarg(idx, def) { 300 return Number(arg(idx, def)); 301 } 302 231 303 var all = { 232 304 'abs': function() { 233 return Math.abs( arg(0));305 return Math.abs(numarg(0)); 234 306 }, 235 307 'round': function() { 236 var digits = arg(1, 0);308 var digits = numarg(1, 0); 237 309 var decimal = Math.pow(10, digits); 238 return Math.round( arg(0)*decimal)/decimal;310 return Math.round(numarg(0)*decimal)/decimal; 239 311 }, 240 312 'roundup': function() { 241 var digits = arg(1, 0);313 var digits = numarg(1, 0); 242 314 var decimal = Math.pow(10, digits); 243 var x = arg(0);244 return (x > 0) ? Math.ceil( arg(0)*decimal)/decimal : Math.floor(arg(0)*decimal)/decimal;315 var x = numarg(0); 316 return (x > 0) ? Math.ceil(numarg(0)*decimal)/decimal : Math.floor(numarg(0)*decimal)/decimal; 245 317 }, 246 318 'rounddown': function() { 247 var digits = arg(1, 0);319 var digits = numarg(1, 0); 248 320 var decimal = Math.pow(10, digits); 249 var x = arg(0);250 return (x > 0) ? Math.floor( arg(0)*decimal)/decimal : Math.ceil(arg(0)*decimal)/decimal;321 var x = numarg(0); 322 return (x > 0) ? Math.floor(numarg(0)*decimal)/decimal : Math.ceil(numarg(0)*decimal)/decimal; 251 323 }, 252 324 'sqrt': function() { 253 return Math.sqrt( arg(0));325 return Math.sqrt(numarg(0)); 254 326 }, 255 327 'sin': function() { 256 return Math.sin( arg(0));328 return Math.sin(numarg(0)); 257 329 }, 258 330 'cos': function() { 259 return Math.cos( arg(0));331 return Math.cos(numarg(0)); 260 332 }, 261 333 'tan': function() { 262 return Math.tan( arg(0));334 return Math.tan(numarg(0)); 263 335 }, 264 336 'asin': function() { 265 return Math.asin( arg(0));337 return Math.asin(numarg(0)); 266 338 }, 267 339 'acos': function() { 268 return Math.acos( arg(0));340 return Math.acos(numarg(0)); 269 341 }, 270 342 'atan': function() { 271 return Math.atan( arg(0));343 return Math.atan(numarg(0)); 272 344 }, 273 345 'pi': function() { -
jazzy-forms/trunk/front/themes/1.css
r516626 r530820 12 12 13 13 .jzzf_form_elements { 14 width: 420px;14 width: 530px; 15 15 } 16 16 … … 82 82 float: left; 83 83 } 84 85 .jzzf_message { 86 width: 125px; 87 float: left; 88 } -
jazzy-forms/trunk/front/tmpl-list.php
r516626 r530820 34 34 function graph($form, $graph) { extract($graph); ?> 35 35 <script type="text/javascript"> 36 jzzf_data_<?php echo $form->id ?> = <?php echo json_encode($data) ?>; 37 jzzf_types_<?php echo $form->id ?> = <?php echo json_encode($types) ?>; 38 jzzf_dependencies_<?php echo $form->id ?> = <?php echo json_encode($dependencies) ?>; 39 jzzf_formulas_<?php echo $form->id ?> = <?php echo json_encode($formulas) ?>; 40 jzzf_form_<?php echo $form->id ?> = <?php echo json_encode($form) ?>; 41 jzzf_params_<?php echo $form->id ?> = <?php echo json_encode($params) ?>; 42 jazzy_forms(jQuery, <?php echo $form->id ?>, jzzf_data_<?php echo $form->id ?>, jzzf_types_<?php echo $form->id ?>, jzzf_dependencies_<?php echo $form->id ?>, jzzf_formulas_<?php echo $form->id ?>, jzzf_form_<?php echo $form->id ?>, jzzf_params_<?php echo $form->id ?>); 36 var jzzf_graph_<?php echo $form->id ?> = { 37 "data": <?php echo json_encode($data) ?>, 38 "types": <?php echo json_encode($types) ?>, 39 "dependencies": <?php echo json_encode($dependencies) ?>, 40 "formulas": <?php echo json_encode($formulas) ?>, 41 "form": <?php echo json_encode($form) ?>, 42 "params": <?php echo json_encode($params) ?>, 43 "email": <?php echo json_encode($email) ?> 44 }; 45 var jzzf_ajax_url = "<?php esc_attr_e(admin_url('admin-ajax.php')) ?>"; 46 jazzy_forms(jQuery, <?php echo $form->id ?>, jzzf_graph_<?php echo $form->id ?>); 43 47 </script> 44 48 <?php … … 46 50 47 51 function head($form) { ?> 48 < div class="jzzf_form">52 <form class="jzzf_form jzzf_form_<?php echo $form->id ?>"> 49 53 <ul class="jzzf_form_elements"> 50 54 <?php … … 55 59 <li class="jzzf_row"> 56 60 <?php endif ?> 57 <div class="<?php echo $element->classes ?>" "<?php if($element->visible===0): ?> style="display:none;"<?php endif ?>>61 <div class="<?php echo $element->classes ?>" <?php if($element->visible===0): ?> style="display:none;"<?php endif ?>> 58 62 <?php 59 63 } … … 63 67 <?php if($last) : ?> 64 68 <div class="clear"></div> 69 <div class="jzzf_message"></div> 65 70 </li> 66 71 <?php endif ?> … … 115 120 116 121 function update($element) { ?> 117 <input type="submit" id="<?php $this->id($element) ?>" value="<?php esc_attr_e($element->title) ?>"> 122 <input type="button" id="<?php $this->id($element) ?>" value="<?php esc_attr_e($element->title) ?>"> 123 <?php 124 } 125 126 function email($element) { ?> 127 <input type="button" class="jzzf_email_button" id="<?php $this->id($element) ?>" value="<?php esc_attr_e($element->title) ?>"> 128 <?php 129 } 130 131 function reset($element) { ?> 132 <input type="reset" id="<?php $this->id($element) ?>" value="<?php esc_attr_e($element->title) ?>"> 118 133 <?php 119 134 } … … 125 140 126 141 function text($element) { ?> 127 <?php e sc_html_e($element->title) ?>142 <?php echo str_replace("\n", "<br />", esc_html($element->title)) ?> 128 143 <?php 129 144 } … … 137 152 function foot($form) { ?> 138 153 </ul> 139 </ div>154 </form> 140 155 <?php 141 156 } -
jazzy-forms/trunk/generated/Basic_Model.php
r516626 r530820 10 10 $obj->realtime = (bool) ($obj->realtime); 11 11 $obj->elements = jzzf_list_element($obj->id); 12 $obj->email = jzzf_get_email($obj->id); 12 13 } 13 14 } … … 24 25 $obj->realtime = (bool) ($obj->realtime); 25 26 $obj->elements = jzzf_list_element($obj->id); 27 $obj->email = jzzf_get_email($obj->id); 26 28 } 27 29 return $obj; … … 37 39 $obj->realtime = (bool) ($obj->realtime); 38 40 $obj->elements = jzzf_list_element($obj->id); 41 $obj->email = jzzf_get_email($obj->id); 39 42 } 40 43 return $obj; … … 77 80 } 78 81 } 82 $previous = jzzf_get_email($id); 83 if($obj->email) { 84 $obj->email->form = $id; 85 $obj->email->id = $previous ? $previous->id : 0; 86 jzzf_set_email($obj->email); 87 } else { 88 if($previous) { 89 jzzf_delete_email($previous->id); 90 } 91 } 79 92 return $id; 80 93 } … … 96 109 } 97 110 } 111 $query = "SELECT id FROM {$wpdb->prefix}jzzf_email WHERE form = %d"; 112 $sql = $wpdb->prepare($query, $id); 113 $children = $wpdb->get_col($sql); 114 if(is_array($children)) { 115 foreach($children as $child) { 116 jzzf_delete_email($child); 117 } 118 } 98 119 return true; 99 120 } 100 121 101 122 123 124 function jzzf_set_email($obj) { 125 global $wpdb; 126 if($obj->id) { 127 $query = "UPDATE {$wpdb->prefix}jzzf_email SET `form`=%d,`to`=%s,`cc`=%s,`bcc`=%s,`from`=%s,`subject`=%s,`message`=%s,`sending`=%s,`ok`=%s,`fail`=%s WHERE id=%d"; 128 $sql = $wpdb->prepare($query, $obj->form,$obj->to,$obj->cc,$obj->bcc,$obj->from,$obj->subject,$obj->message,$obj->sending,$obj->ok,$obj->fail, $obj->id); 129 $result = $wpdb->query($sql); 130 $id = $obj->id; 131 } else { 132 $query = "INSERT INTO {$wpdb->prefix}jzzf_email (`form`,`to`,`cc`,`bcc`,`from`,`subject`,`message`,`sending`,`ok`,`fail`) VALUES (%d,%s,%s,%s,%s,%s,%s,%s,%s,%s)"; 133 $sql = $wpdb->prepare($query, $obj->form,$obj->to,$obj->cc,$obj->bcc,$obj->from,$obj->subject,$obj->message,$obj->sending,$obj->ok,$obj->fail); 134 $result = $wpdb->query($sql); 135 $id = $wpdb->insert_id; 136 } 137 return false; 138 } 139 function jzzf_delete_email($id) { 140 global $wpdb; 141 $query = "DELETE FROM {$wpdb->prefix}jzzf_email WHERE id = %d"; 142 $sql = $wpdb->prepare($query, $id); 143 if(false === $wpdb->query($sql)) { 144 return false; 145 } 146 return true; 147 } 148 149 150 function jzzf_get_email($key) { 151 global $wpdb; 152 $query = "SELECT * FROM {$wpdb->prefix}jzzf_email WHERE `form`=%d"; 153 $sql = $wpdb->prepare($query, $key); 154 $obj = $wpdb->get_row($sql); 155 if($obj) { 156 $obj->id = intval($obj->id); 157 $obj->form = intval($obj->form); 158 } 159 return $obj; 160 } 102 161 function jzzf_list_element($parent) { 103 162 global $wpdb; -
jazzy-forms/trunk/generated/drop.sql
r516626 r530820 1 1 DROP TABLE IF EXISTS {{prefix}}jzzf_form; 2 2 DROP TABLE IF EXISTS {{prefix}}jzzf_element; 3 DROP TABLE IF EXISTS {{prefix}}jzzf_email; 3 4 DROP TABLE IF EXISTS {{prefix}}jzzf_option; -
jazzy-forms/trunk/generated/schema.sql
r516626 r530820 1 1 CREATE TABLE IF NOT EXISTS {{prefix}}jzzf_form ( id bigint(20) AUTO_INCREMENT, `title` TEXT NOT NULL, `name` varchar(1024) NOT NULL, `theme` int(12) NOT NULL, `css` LONGTEXT NOT NULL, `realtime` int(1) NOT NULL DEFAULT 1, PRIMARY KEY (id) ) {{charset_collate}}; 2 2 CREATE TABLE IF NOT EXISTS {{prefix}}jzzf_element ( id bigint(20) AUTO_INCREMENT, `form` bigint(20) NOT NULL, `order` int(12) NOT NULL, `type` varchar(1024) NOT NULL, `title` TEXT NOT NULL, `name` varchar(1024) NOT NULL, `formula` TEXT NOT NULL, `value` varchar(1024) NOT NULL, `value2` varchar(1024) NOT NULL, `default` varchar(1024) NOT NULL, `external` int(1) NOT NULL, `params` varchar(2048) NOT NULL, `visible` int(12) NOT NULL DEFAULT 1, `prefix` varchar(16) NOT NULL, `postfix` varchar(16) NOT NULL, `zeros` int(1) NOT NULL, `decimals` int(1) NOT NULL DEFAULT 9, `fixed` int(1) NOT NULL DEFAULT 0, `thousands` varchar(1) NOT NULL, `point` varchar(1) NOT NULL DEFAULT '.', `classes` varchar(1024) NOT NULL, `divisions` int(1) NOT NULL DEFAULT 1, `break` int(1) NOT NULL DEFAULT 1, PRIMARY KEY (id) ) {{charset_collate}}; 3 CREATE TABLE IF NOT EXISTS {{prefix}}jzzf_email ( id bigint(20) AUTO_INCREMENT, `form` bigint(20) NOT NULL, `to` TEXT NOT NULL, `cc` TEXT NOT NULL, `bcc` TEXT NOT NULL, `from` varchar(1024) NOT NULL, `subject` TEXT NOT NULL, `message` LONGTEXT NOT NULL, `sending` TEXT NOT NULL, `ok` TEXT NOT NULL, `fail` TEXT NOT NULL, PRIMARY KEY (id) ) {{charset_collate}}; 3 4 CREATE TABLE IF NOT EXISTS {{prefix}}jzzf_option ( id bigint(20) AUTO_INCREMENT, `order` int(12) NOT NULL, `element` bigint(20) NOT NULL, `default` int(1) NOT NULL, `title` varchar(1024) NOT NULL, `name` varchar(1024) NOT NULL, `value` varchar(1024) NOT NULL, PRIMARY KEY (id) ) {{charset_collate}}; -
jazzy-forms/trunk/jazzy-forms.php
r516626 r530820 4 4 Plugin URI: http://www.jazzyforms.com/ 5 5 Description: Online form builder with an emphasis on calculation 6 Version: 0.9. 56 Version: 0.9.6 7 7 Author: Igor Prochazka 8 8 Author URI: http://www.l90r.com/ … … 28 28 */ 29 29 30 define(JZZF_VERSION, 0.090 5);30 define(JZZF_VERSION, 0.0906); 31 31 define(JZZF_OPTION_VERSION, 'jzzf_version'); 32 32 … … 43 43 function jzzf_set_version($float) { 44 44 update_option(JZZF_OPTION_VERSION, JZZF_VERSION); 45 }46 47 function jzzf_delete_version() {48 delete_option(JZZF_OPTION_VERSION);49 45 } 50 46 … … 89 85 90 86 function jzzf_create_tables() { 91 jzzf_execute_sql( 'schema.sql');87 jzzf_execute_sql(JZZF_GENERATED . 'schema.sql'); 92 88 } 93 89 … … 97 93 $charset_collate = jzzf_charset_collate(); 98 94 99 $file = file( dirname(__FILE__) . '/generated/' .$filename );95 $file = file( $filename ); 100 96 foreach($file as $line) { 101 97 $sql = trim($line); … … 109 105 110 106 function jzzf_panic() { 111 jzzf_execute_sql( 'drop.sql');112 jzzf_ delete_version();107 jzzf_execute_sql(JZZF_GENERATED . 'drop.sql'); 108 jzzf_execute_sql(JZZF_ROOT . 'panic.sql'); 113 109 deactivate_plugins(JZZF_ROOT . 'jazzy-forms.php'); 114 110 } … … 138 134 139 135 function jzzf_update() { 140 jzzf_execute_sql( 'update.sql');136 jzzf_execute_sql(JZZF_GENERATED . 'update.sql'); 141 137 jzzf_set_version(JZZF_VERSION); 142 138 } … … 148 144 require_once(JZZF_CORE . 'Parser.php'); 149 145 require_once(JZZF_CORE . 'Tokenizer.php'); 146 require_once(JZZF_CORE . 'Template_Parser.php'); 150 147 return jzzf_ctrl_shortcode($attr); 151 148 } … … 190 187 return $posts; 191 188 } 189 190 function jzzf_email() { 191 require_once(JZZF_FRONT . 'ctrl-email.php'); 192 require_once(JZZF_GENERATED . 'Basic_Model.php'); 193 require_once(JZZF_CORE . 'Parser.php'); 194 require_once(JZZF_CORE . 'Tokenizer.php'); 195 require_once(JZZF_CORE . 'Template_Parser.php'); 196 require_once(JZZF_CORE . 'Mail.php'); 197 jzzf_ctrl_email(); 198 exit; 199 } 200 201 require_once(JZZF_CORE . 'Log.php'); 192 202 193 203 /* register filter hook */ … … 200 210 add_action('jzzf_enqueue', 'jzzf_enqueue'); 201 211 add_action('jzzf_form', 'jzzf_form', 2); 202 212 add_action('wp_ajax_jzzf_email', 'jzzf_email'); 213 203 214 ?> -
jazzy-forms/trunk/readme.txt
r516626 r530820 2 2 Contributors: jazzigor 3 3 Donate link: http://www.jazzyforms.com/ 4 Tags: forms, form generator, calculator, price calculator, cost estimate 4 Tags: forms, form generator, calculator, price calculator, cost estimate, quote, email 5 5 Requires at least: 3.2.1 6 6 Tested up to: 3.3.1 7 Stable tag: 0.9. 57 Stable tag: 0.9.6 8 8 9 Jazzy Forms is an online form generator that performs instant calculations. It's ideal for inter-active price calculators .9 Jazzy Forms is an online form generator that performs instant calculations. It's ideal for inter-active price calculators and for sending out cost estimates by email. 10 10 11 11 == Description == 12 12 13 Jazzy Forms is an online form generator that performs instant calculations. It's ideal for inter-active price calculators .13 Jazzy Forms is an online form generator that performs instant calculations. It's ideal for inter-active price calculators and for sending out cost estimates by email. 14 14 15 15 Features: … … 21 21 * Rich number formatting 22 22 * Flexible (vertical or side-by-side) layout 23 * Email 23 24 24 25 Form elements: … … 30 31 * Output 31 32 * Update button 33 * Reset button 34 * Email button 32 35 * Text/Heading/HTML 33 36 34 This is an early release. Features like input validation, data collection or Emailare still being worked on.37 This is an early release. Features like input validation, anti-spam measures or data collection are still being worked on. 35 38 36 39 == Installation == … … 61 64 62 65 Place the following code in the header, before a call to wp_head(), in order to queue Jazzy Forms' JavaScript scripts: 63 `<?php jzzf_ queue() ?>`66 `<?php jzzf_enqueue() ?>` 64 67 65 68 To insert a form with ID "form_id" do the following: … … 70 73 71 74 There are also corresponding WordPress actions: 72 `<?php do_action('jzzf_ queue') ?>`75 `<?php do_action('jzzf_enqueue') ?>` 73 76 `<?php do_action('jzzf_form', 'form_id') ?>` 74 77 … … 108 111 109 112 == Changelog == 113 114 = 0.9.6 = 115 * Email (using placeholders and inline formulas) 116 * Reset button 117 * Fixed IE8 compatibility issues 118 * Enhanced usability of text/heading elements (use textareas) 119 * Enhanced debugging (optional logging) 110 120 111 121 = 0.9.5 =
Note: See TracChangeset
for help on using the changeset viewer.