/** * Starts the dialog and its configuration * @param string $id dialog Id * @param array() $configurations Array. See the options and events in * http://jqueryui.com/demos/dialog/#options * http://jqueryui.com/demos/dialog/#events * @param string $html_attributes Additional options parameter (html attributes) */ function ui_dialog_init($id, $configurations = array(), $html_attributes = null) { $configurations = get_default_widget_configuration('app_ys_jquery_ui_dialog_defaults', $configurations); $pattern = _ui_dialog_pattern($configurations); init_ui_widget('dialog', $pattern, $id, $configurations); if (isset($configurations['listener'])) { $listener = $configurations['listener']; if ((isset($listener['event']) || isset($listener['oneEvent'])) && isset($listener['selector'])) { $dialogId = '#' . $id; $event = isset($listener['oneEvent']) ? $listener['oneEvent'] : $listener['event']; echo jquery_execute(ui_dialog_open($dialogId), $listener['selector'], $event); } } echo '<div id="' . $id . '" ' . $html_attributes . '>'; }
/** * Adds autocomplete support * @param string $selector A jQuery Selector * @param array $configuration Array options for the autocomplete function * @param boolean $isInternal If this function is inner a javascript body */ function jquery_autocomplete_support_to($selector, $configuration = array(), $isInternal = false) { if (isset($configuration['focus']) && $configuration['focus'] == true) { echo jquery_execute(jquery_support($selector, 'focus')); } $configuration = merge_plugin_defaults_options('auto_complete', $configuration); $urlOrData = '{}'; $urlOrData = isset($configuration['data']) ? $configuration['data'] : $urlOrData; $urlOrData = isset($configuration['url']) ? sprintf("'%s'", $configuration['url']) : $urlOrData; //unset($configuration['data'],$configuration['url']); $pattern = _ui_autocomplete_pattern($configuration); $jquerySintax = trim($pattern) == '' ? $urlOrData : $urlOrData . ',' . $pattern; if ($isInternal) { return jquery_support($selector, 'autocomplete', $jquerySintax); } else { return add_jquery_support($selector, 'autocomplete', $jquerySintax); } }
<div id="concept<?php echo $num; ?> "> <?php echo $form["Concepts{$num}"]; ?> <img src='/images/icons/24x24/delete.png' title="Quitar concepto" alt="Quitar" id="quitar<?php echo $num; ?> " style="cursor: pointer;"/> <?php echo jquery_execute("\n \$('#invoice_Concepts" . $num . "_total').keypress(function(){\n return false;\n });\n \$('#quitar" . $num . "').click(function(){\n \$('#invoice_Concepts" . $num . "_quantity').val('');\n \$('#invoice_Concepts" . $num . "_price').val('');\n \$('#invoice_Concepts" . $num . "_total').val('');\n concept--;\n \$('#concept" . $num . "').css('display','none');\n });\n \$('#invoice_Concepts" . $num . "_discount').keyup(function(){\n var num_q = \$('#invoice_Concepts" . $num . "_quantity').val();\n var num_p = \$('#invoice_Concepts" . $num . "_price').val();\n discount = parseFloat(\$('#invoice_Concepts" . $num . "_discount').val());\n num_p = num_p - (num_p * (discount / 100));\n var tasa = " . sfConfig::get('app_sat_tasa') . ";\n aSub[{$num}] = num_q * num_p;\n aIva[{$num}] = (num_q * num_p) * (tasa / 100);\n var total = (num_q * num_p);\n iva = parseFloat(0);\n for(i=0;i<=numconcepts;i++){\n if(aIva[i]){\n iva = parseFloat(iva) + parseFloat(aIva[i]);\n }\n }\n sub = parseFloat(0);\n for(i=0;i<=numconcepts;i++){\n if(aSub[i]){\n sub = parseFloat(sub) + parseFloat(aSub[i]);\n }\n }\n \$('#invoice_subtotal').val(sub);\n \$('#invoice_iva').val(iva);\n \$('#invoice_Concepts" . $num . "_total').val(total);\n aTot[{$num}] = total;\n tot = parseFloat(0);\n for(i=0;i<=numconcepts;i++){\n if(aIva[i]){\n tot = parseFloat(tot) + parseFloat(aTot[i]);\n }\n }\n tot2 = (\$('#invoice_subtotal').val() - (\$('#invoice_subtotal').val() * (\$('#invoice_discount').val() / 100)));\n tot2 = tot2 + (tot2 * (tasa / 100));\n \$('#invoice_total').val(tot2);\n });\n \$('#invoice_Concepts" . $num . "_quantity').keyup(function(){\n var num_q = \$('#invoice_Concepts" . $num . "_quantity').val();\n var num_p = \$('#invoice_Concepts" . $num . "_price').val();\n discount = parseFloat(\$('#invoice_Concepts" . $num . "_discount').val());\n num_p = num_p - (num_p * (discount / 100));\n var tasa = " . sfConfig::get('app_sat_tasa') . ";\n aSub[{$num}] = num_q * num_p;\n aIva[{$num}] = (num_q * num_p) * (tasa / 100);\n var total = (num_q * num_p);\n iva = parseFloat(0);\n for(i=0;i<=numconcepts;i++){\n if(aIva[i]){\n iva = parseFloat(iva) + parseFloat(aIva[i]);\n }\n }\n sub = parseFloat(0);\n for(i=0;i<=numconcepts;i++){\n if(aSub[i]){\n sub = parseFloat(sub) + parseFloat(aSub[i]);\n }\n }\n \$('#invoice_subtotal').val(sub);\n \$('#invoice_iva').val(iva);\n \$('#invoice_Concepts" . $num . "_total').val(total);\n aTot[{$num}] = total;\n tot = parseFloat(0);\n for(i=0;i<=numconcepts;i++){\n if(aIva[i]){\n tot = parseFloat(tot) + parseFloat(aTot[i]);\n }\n }\n tot2 = (\$('#invoice_subtotal').val() - (\$('#invoice_subtotal').val() * (\$('#invoice_discount').val() / 100)));\n tot2 = tot2 + (tot2 * (tasa / 100));\n \$('#invoice_total').val(tot2);\n });\n \$('#invoice_Concepts" . $num . "_price').keyup(function(){\n var num_q = \$('#invoice_Concepts" . $num . "_quantity').val();\n var num_p = \$('#invoice_Concepts" . $num . "_price').val();\n discount = parseFloat(\$('#invoice_Concepts" . $num . "_discount').val());\n num_p = num_p - (num_p * (discount / 100));\n var tasa = " . sfConfig::get('app_sat_tasa') . ";\n aSub[{$num}] = num_q * num_p;\n aIva[{$num}] = (num_q * num_p) * (tasa / 100);\n var total = (num_q * num_p);\n iva = parseFloat(0);\n for(i=0;i<=numconcepts;i++){\n if(aIva[i]){\n iva = parseFloat(iva) + parseFloat(aIva[i]);\n }\n }\n sub = parseFloat(0);\n for(i=0;i<=numconcepts;i++){\n if(aSub[i]){\n sub = parseFloat(sub) + parseFloat(aSub[i]);\n }\n }\n \$('#invoice_subtotal').val(sub);\n \$('#invoice_iva').val(iva);\n \$('#invoice_Concepts" . $num . "_total').val(total);\n aTot[{$num}] = total;\n tot = parseFloat(0);\n for(i=0;i<=numconcepts;i++){\n if(aIva[i]){\n tot = parseFloat(tot) + parseFloat(aTot[i]);\n }\n }\n tot2 = (\$('#invoice_subtotal').val() - (\$('#invoice_subtotal').val() * (\$('#invoice_discount').val() / 100)));\n tot2 = tot2 + (tot2 * (tasa / 100));\n \$('#invoice_total').val(tot2);\n });\n "); ?> </div>
<div id="content"> <p> <label>Test 1 (Local Data [Months]):</label> <input type="text" id="suggest1" /> <?php echo jquery_autocomplete_support_to('#suggest1', array('data' => 'months')); ?> <?php jquery_ajax_event('#suggest15', 'success', like_function("alert('a')")); ?> <input type="button" value="Change data" id="btnSetOptions" /> <?php echo jquery_execute(jquery_toggle_event('#btnSetOptions', array(like_function('changeToCities()'), like_function('changeToMonths()')))); ?> <br> <br> Test 2 (Local Data [Months] Multiple): <input type="text" id="suggest2" /> <?php echo jquery_autocomplete_support_to('#suggest2', array('multiple' => true, 'highlight' => false, 'data' => 'months')); ?> <br> <br> Test 3 (Local Data [emails]): <input type="text" id="suggest3" /> <?php echo jquery_autocomplete_support_to('#suggest3', array('data' => 'emails', 'formatItem' => like_function('return row.name.replace(new RegExp("(" + term + ")", "gi"), "<strong>$1</strong>") + "<br><span style=\'font-size: 80%;\'>Email: <" + row.to + "></span>"', 'row, i, max, term'), 'formatResult' => like_function('return row.to', 'row')));
'document', 'ready' , like_function( jquery_toggle_event( 'li', array( like_function('$(this).css({"list-style-type":"disc", "color":"blue"});'), like_function('$(this).css({"list-style-type":"disc", "color":"red"});'), like_function('$(this).css({"list-style-type":"", "color":"yellow"});'), )))); */ /* Now with jquery_execute*/ echo jquery_execute(jquery_toggle_event('li', array(like_function('$(this).css({"list-style-type":"disc", "color":"blue"});'), like_function('$(this).css({"list-style-type":"disc", "color":"red"});'), like_function('$(this).css({"list-style-type":"", "color":"yellow"});')))); ?> <?php echo jquery_execute(jquery_hover_event('li', array(like_function('$(this).append($("<span> ******** </span>"));'), like_function('$(this).find("span:last").remove();')))); ?> <br> <hr> <h3>Bind & Unbind - example</h3> <input type="button" value="Bind" id="btnBind"> <input type="button" value="UnBind" id="btnUnBind"> <div id="bindExample">Click me</div> <?php echo add_jquery_support('#btnBind', 'click', like_function(jquery_bind_event('#bindExample', 'click', array('foo' => 'bar'), like_function('alert(event.data.foo)', 'event')))); ?>
function ui_context_menu_enable($selector, $isInternal = true) { $response = $isInternal ? jquery_support($selector, 'enableContextMenu') : jquery_execute(jquery_support($selector, 'enableContextMenu')); return $response; }
/** * * @param string $bodyFuntion The javascript body function * @param string $arguments The javascript arguments function * @return string javascript syntax */ function return_jquery($configurations, $sintax) { $finalSintax = $sintax; if (is_array($configurations) && isset($configurations['listener'])) { $listener = $configurations['listener']; if ((isset($listener['event']) || isset($listener['oneEvent'])) && isset($listener['selector'])) { $listener['event'] = isset($listener['oneEvent']) ? $listener['oneEvent'] : $listener['event']; $finalSintax = ''; if (isset($listener['oneEvent'])) { if (isset($listener['before'])) { $finalSintax .= jquery_execute(jquery_one_event($listener['selector'], $listener['event'], $listener['before'])); } $finalSintax .= jquery_execute(jquery_one_event($listener['selector'], $listener['event'], like_function($sintax))); if (isset($listener['after'])) { $finalSintax .= jquery_execute(jquery_one_event($listener['selector'], $listener['event'], $listener['after'])); } } else { if (isset($listener['before'])) { $finalSintax .= add_jquery_support($listener['selector'], $listener['event'], $listener['before']); } $finalSintax .= add_jquery_support($listener['selector'], $listener['event'], like_function($sintax)); if (isset($listener['after'])) { $finalSintax .= add_jquery_support($listener['selector'], $listener['event'], $listener['after']); } } } } return $finalSintax; }