Changeset 28533
- Timestamp:
- 03/15/10 18:13:11 (3 years ago)
- Files:
-
- plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/data/generator/sfDoctrineModule/javascript/template/templates/_form.php (modified) (1 diff)
- plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/data/generator/sfDoctrineModule/javascript/template/templates/_form_field.php (modified) (1 diff)
- plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/lib/helper/JavascriptAdminHelper.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/data/generator/sfDoctrineModule/javascript/template/templates/_form.php
r28432 r28533 1 [?php use_helper('Javascript Admin'); ?]1 [?php use_helper('JavascriptBase', 'JavascriptAdmin'); ?] 2 2 [?php form_event_handlers($form); ?] 3 3 [?php use_stylesheets_for_form($form) ?] plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/data/generator/sfDoctrineModule/javascript/template/templates/_form_field.php
r28432 r28533 1 [?php if ($field->isPartial()): ?] 1 [?php $force_show = isset($force_show); ?] 2 [?php if (!$force_show && $field->isPartial()): ?] 2 3 [?php include_partial('<?php echo $this->getModuleName() ?>/'.$name, array('form' => $form, 'attributes' => $attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes)) ?] 3 [?php elseif ( $field->isComponent()): ?]4 [?php elseif (!$force_show && $field->isComponent()): ?] 4 5 [?php include_component('<?php echo $this->getModuleName() ?>', $name, array('form' => $form, 'attributes' => $attributes instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes)) ?] 6 [?php elseif (!$force_show && !$field->isReal() && (get_class($form[$name]) == 'sfFormFieldSchema')): ?] 7 [?php echo $form[$name]->renderHiddenFields(); ?] 8 [?php $eform = $form[$name]; ?] 9 [?php foreach ($eform as $ename => $efield): ?] 10 [?php if ((isset($eform[$ename]) && $eform[$ename]->isHidden()) || (!isset($eform[$ename]) && $efield->isReal())) continue ?] 11 [?php include_partial('<?php echo $this->getModuleName() ?>/form_field', array( 12 'name' => $ename, 13 'attributes' => array(), 14 'label' => '', 15 'help' => '', 16 'form' => $eform, 17 'field' => $efield, 18 'force_show' => true, 19 'class' => 'sf_admin_form_row sf_admin_'.strtolower($efield->getWidget()->getOption('type')).' sf_admin_form_field_'.$ename, 20 )) ?] 21 [?php endforeach; ?] 5 22 [?php else: ?] 6 23 <div class="[?php echo $class ?][?php $form[$name]->hasError() and print ' errors' ?]"> plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/lib/helper/JavascriptAdminHelper.php
r28432 r28533 1 1 <?php 2 2 function getDefaultHint() { 3 return __(sfConfig::get('app_default_hint', '<em>Clique aqui para definir um valor</em>'));3 return '<em>'.__(sfConfig::get('app_default_hint', 'Clique aqui para definir um valor')).'</em>'; 4 4 } 5 5 … … 21 21 include_jquery(); 22 22 $command = 'jQuery(document).ready(function () {'."\r\n"; 23 foreach($form as $fieldName => $field) { 24 if($field->isHidden()) 25 continue; 26 $command .= ' if(document.getElementById("'.$field->renderId().'_temp")) {' . "\r\n"; 27 $command .= ' jQuery("#'.$field->renderId().'_temp").change( function() { reset_function(); update_values("'.$field->renderId().'") } );' . "\r\n"; 28 $command .= ' } else {' . "\r\n"; 29 $command .= ' jQuery("#'.$field->renderId().'").blur( function() { reset_function(); update_values("'.$field->renderId().'") } );' . "\r\n"; 30 $command .= ' }' . "\r\n"; 31 $command .= ' jQuery("#'.$field->renderId().'_view").click( function() { switch_field("'.$field->renderId().'") } );' . "\r\n"; 32 } 23 $command .= _process_form($form); 33 24 $command .= ' reset_function();'."\r\n"; 34 25 $command .= '});'."\r\n"; … … 38 29 $command .= _form_switch_function(); 39 30 $command .= _form_update_values_function(); 31 40 32 echo javascript_tag($command); 33 } 34 function _process_form($form) { 35 $command = ''; 36 foreach($form as $fieldName => $field) { 37 if($field->isHidden()) 38 continue; 39 if(get_class($field) == 'sfFormFieldSchema') { 40 $command .= _process_form($field); 41 } else { 42 $command .= _generate_functions_for_field($fieldName, $field); 43 } 44 } 45 return $command; 46 } 47 function _generate_functions_for_field($fieldName, $field) { 48 $command = ''; 49 $command .= ' if(document.getElementById("'.$field->renderId().'_temp")) {' . "\r\n"; 50 $command .= ' jQuery("#'.$field->renderId().'_temp").change( function() { reset_function(); update_values("'.$field->renderId().'") } );' . "\r\n"; 51 $command .= ' } else {' . "\r\n"; 52 $command .= ' jQuery("#'.$field->renderId().'").blur( function() { reset_function(); update_values("'.$field->renderId().'") } );' . "\r\n"; 53 $command .= ' }' . "\r\n"; 54 $command .= ' jQuery("#'.$field->renderId().'_view").click( function() { switch_field("'.$field->renderId().'") } );' . "\r\n"; 55 return $command; 41 56 } 42 57 function _form_hide_fields_function() { … … 73 88 newValue = jQuery("#"+fieldName).val(); 74 89 } 75 if(newValue == "") {90 if(newValue == null) { 76 91 newValue = jQuery("#"+fieldName+"_edit > .help").html(); 77 92 } … … 80 95 }'."\r\n"; 81 96 } 97 /*if(!function_exists('javascript_tag')) { 82 98 function javascript_tag($content) 83 99 { 84 100 return content_tag('script', javascript_cdata_section($content), array('type' => 'text/javascript')); 85 101 } 86 102 } 103 if(!function_exists('javascript_cdata_section')) { 87 104 function javascript_cdata_section($content) 88 105 { 89 106 return "\n//".cdata_section("\n$content\n//")."\n"; 90 107 } 108 }*/ 91 109 function include_jquery() { 92 110 $jquery = sfConfig::get('app_jquery_path', '/jquery.js');