Author: sid.gbf
Date: 2010-04-07 22:07:15 +0200 (Wed, 07 Apr 2010)
New Revision: 29038
Modified:
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/data/generator/sfDoctrineModule/javascript/template/templates/_form_field.php
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/lib/helper/JavascriptAdminHelper.php
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/lib/widget/sfWidgetFormjQueryDatePicker.class.php
Log:
Modified:
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/data/generator/sfDoctrineModule/javascript/template/templates/_form_field.php
===================================================================
---
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/data/generator/sfDoctrineModule/javascript/template/templates/_form_field.php
2010-04-07 19:29:54 UTC (rev 29037)
+++
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/data/generator/sfDoctrineModule/javascript/template/templates/_form_field.php
2010-04-07 20:07:15 UTC (rev 29038)
@@ -22,26 +22,37 @@
[?php endforeach; ?]
[?php else: ?]
<div class="[?php echo $class ?][?php $form[$name]->hasError() and print '
errors' ?]">
- [?php echo $form[$name]->renderError() ?]
- [?php if (!$help || is_null($help)): ?]
+ [?php $placeholder =
$form[$name]->getWidget()->getAttribute('placeholder'); ?]
+ [?php $help = $form[$name]->getWidget()->getAttribute('help', false); ?]
+ [?php if (!$help): ?]
[?php if ($form[$name]->renderHelp()): ?]
- [?php $help = $form[$name]->renderHelp(); ?]
+ [?php $help = fix_help($form[$name]->renderHelp()); ?]
[?php else: ?]
[?php $help = getDefaultHint(); ?]
[?php endif; ?]
+ [?php else: ?]
+ [?php $help = __($help); ?]
[?php endif; ?]
+ [?php if(!$placeholder): ?]
+ [?php $placeholder = $help; ?]
+ [?php else: ?]
+ [?php $placeholder = __($placeholder); ?]
+ [?php endif; ?]
+ [?php $placeholder = '<em>' . $placeholder . '</em>'; ?]
<div>
[?php echo $form[$name]->renderLabel($label) ?]
+ <input type="hidden" readonly="readonly" disabled="disabled"
value='[?php echo $placeholder; ?]' id="[?php echo $form[$name]->renderId();
?]_placeholder" />
+ <input type="hidden" readonly="readonly" disabled="disabled"
value="[?php echo $help ?]" id="[?php echo $form[$name]->renderId(); ?]_help" />
<div class="content content_view" id="[?php echo
$form[$name]->renderId(); ?]_view" style="display: none;">
[?php echo content_tag('a',
image_tag('../sf/sf_admin/images/edit.png', array('align' => 'right')),
array('id' => $form[$name]->renderId().'_open', 'href' => '')); ?]
- <div>[?php echo content_to_view($form[$name], ($attributes instanceof
sfOutputEscaper ? $attributes->getRawValue() : $attributes),
$form[$name]->getWidget()->getOption('tip', '')) ?] </div>
+ <div>[?php echo content_to_view($form[$name], ($attributes instanceof
sfOutputEscaper ? $attributes->getRawValue() : $attributes), $placeholder)
?] </div>
</div>
<div class="content content_edit" id="[?php echo
$form[$name]->renderId(); ?]_edit">
[?php echo content_tag('a',
image_tag('../sf/sf_admin/images/ok.png', array('align' => 'right')),
array('id' => $form[$name]->renderId().'_close', 'href' => '')); ?]
- <div class="contents">[?php echo $form[$name]->render($attributes
instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes) ?]</div>
+ <div class="contents">[?php echo $form[$name]->render($attributes
instanceof sfOutputEscaper ? $attributes->getRawValue() : $attributes,
$placeholder) ?]</div>
[?php if ($help): ?]
- <div class="help">[?php echo fix_help($help) ?]</div>
+ <div class="help"><em>[?php echo $help ?]</em></div>
[?php endif; ?]
</div>
</div>
Modified:
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/lib/helper/JavascriptAdminHelper.php
===================================================================
---
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/lib/helper/JavascriptAdminHelper.php
2010-04-07 19:29:54 UTC (rev 29037)
+++
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/lib/helper/JavascriptAdminHelper.php
2010-04-07 20:07:15 UTC (rev 29038)
@@ -1,17 +1,17 @@
<?php
function getDefaultHint() {
- return '<em>'.__(sfConfig::get('app_default_hint', 'Clique aqui para
definir um valor')).'</em>';
+ return '<em>'.__(sfConfig::get('app_default_hint', 'Clique a direita para
editar')).'</em>';
}
- function content_to_view(sfFormField $field, $attributes, $help) {
+ function content_to_view(sfFormField $field, $attributes, $placeholder) {
$value = '';
if($field->getWidget()->hasOption('choices') && $field->getValue()) {
$class = $field->getWidget()->getOption('model');
if($class)
- $value = Doctrine::getTable($class)->findOneBy('id',
$field->getValue());
+ $value = Doctrine::getTable($class)->findOneBy('id',
$field->getValue())->__toString();
} else if($field->getWidget()->getOption('type') == 'file') {
- $value = $help;
+ $value = $field->renderHelp();
} else if($field->getWidget()->getOption('type') == 'checkbox') {
$value = ($field->getValue())?__('Sim'):__('Não');
} else if($field->getValue()) {
@@ -22,11 +22,14 @@
}
}
- } else if($help) {
+ } /*else if($help) {
$value = $help;
+ }*/
+ if(!$value) {
+ $value = $placeholder;
}
- return $value;
+ return fix_help($value);
}
function fix_help($value) {
if(is_object($value))
@@ -116,9 +119,9 @@
newValue = jQuery(fieldName).val();
}
}
-/* if(newValue == null || newValue == "") {
- newValue = jQuery(fieldName+"_edit > div").html();
- }*/
+ if(newValue == null || newValue == "") {
+ newValue = jQuery(fieldName+"_placeholder").val();
+ }
jQuery(updateId+"_view > div").html(newValue);
Modified:
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/lib/widget/sfWidgetFormjQueryDatePicker.class.php
===================================================================
---
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/lib/widget/sfWidgetFormjQueryDatePicker.class.php
2010-04-07 19:29:54 UTC (rev 29037)
+++
plugins/sfjQueryDoctrineAdminPlugin/tag/0.1/lib/widget/sfWidgetFormjQueryDatePicker.class.php
2010-04-07 20:07:15 UTC (rev 29038)
@@ -9,50 +9,10 @@
* @author SidGBF <[email protected]>
* @copyright Based on sfWidgetFormjQueryDate
*/
-class sfWidgetFormjQueryDatePicker extends sfWidgetForm
+class sfWidgetFormjQueryDatePicker extends sfWidgetFormJQueryDate
{
- /**
- * Configures the current widget.
- *
- * Available options:
- *
- * * image: The image path to represent the widget (false by default)
- * * config: A JavaScript array that configures the JQuery date widget
- * * culture: The user culture
- * * date_widget: The date widget instance to use as a "base" class
- *
- * @param array $options An array of options
- * @param array $attributes An array of default HTML attributes
- *
- * @see sfWidgetForm
- */
- protected function configure($options = array(), $attributes = array())
- {
- $this->addOption('image', false);
- $this->addOption('config', '{}');
- $this->addOption('culture', '');
- $this->addOption('date_widget', new sfWidgetFormDate());
- $this->getJavaScripts();
- parent::configure($options, $attributes);
-
- if ('en' == $this->getOption('culture'))
- {
- $this->setOption('culture', 'en');
- }
- }
-
- /**
- * @param string $name The element name
- * @param string $value The date displayed in this widget
- * @param array $attributes An array of HTML attributes to be merged with
the default HTML attributes
- * @param array $errors An array of errors for the field
- *
- * @return string An HTML tag string
- *
- * @see sfWidgetForm
- */
- public function render($name, $value = null, $attributes = array(), $errors
= array())
+ public function rendero($name, $value = null, $attributes = array(), $errors
= array())
{
$_output = '';
$prefix = $this->generateId($name);
@@ -79,9 +39,12 @@
{ onSelect: wfd_'.$prefix.'_update_linked,
dateFormat: "yy-mm-dd",
altField: "#'.$prefix.'_temp",
- altFormat: "DD, d MM, yy"
+ altFormat: "DD, d MM, yy",
+ gotoCurrent: true,
+ defaultDate: +1
}
);
+
var tempDate = jQuery.datepicker.formatDate(\'yy-mm-dd\', new
Date('.$date[0].', '.$date[1].' - 1, '.$date[2].'));
jQuery(\'#'.$prefix.'_div_datepicker\').datepicker(\'setDate\', tempDate);
wfd_'.$prefix.'_update_linked(tempDate);
@@ -93,8 +56,20 @@
$_output .= '</div>';
return $_output;
}
-/*
- return $this->getOption('date_widget')->render($name, $value, $attributes,
$errors).
+
+ public function render($name, $value = null, $attributes = array(), $errors
= array())
+ {
+ $prefix = $this->generateId($name);
+
+ $image = '';
+ if (false !== $this->getOption('image'))
+ {
+ $image = sprintf(', buttonImage: "%s", buttonImageOnly: true',
$this->getOption('image'));
+ }
+
+ return '<div
id="'.$this->generateId($name).'_jquery_control_widget"></div>'.
+ '<input type="hidden" id="'.$this->generateId($name).'_temp"
onchange="jQuery(\'#'.$this->generateId($name).'_view >
div\').html(jQuery(\'#'.$this->generateId($name).'_temp\').val())" />'.
+ '<div id="'.$this->generateId($name).'_hidden" style="display:
none;">'.$this->getOption('date_widget')->render($name, $value, $attributes,
$errors).'</div>'.
$this->renderTag('input', array('type' => 'hidden', 'size' => 10,
'id' => $id = $this->generateId($name).'_jquery_control', 'disabled' =>
'disabled')).
sprintf(<<<EOF
<script type="text/javascript">
@@ -125,14 +100,17 @@
}
jQuery(document).ready(function() {
- jQuery("#%s").datepicker(jQuery.extend({}, {
+ jQuery("#%s_widget").datepicker(jQuery.extend({}, {
minDate: new Date(%s, 1 - 1, 1),
maxDate: new Date(%s, 12 - 1, 31),
beforeShow: wfd_%s_read_linked,
onSelect: wfd_%s_update_linked,
- showOn: "button"
+ altField: "#%s_temp",
+ altFormat: "DD, d MM, yy",
+ showOne: "button"
%s
}, jQuery.datepicker.regional["%s"], %s, {dateFormat: "yy-mm-dd"}));
+ jQuery('#%s_temp').change()
});
jQuery("#%s, #%s, #%s").change(wfd_%s_check_linked_days);
@@ -150,36 +128,17 @@
$this->generateId($name.'[day]'), $this->generateId($name.'[day]'),
$id,
min($this->getOption('date_widget')->getOption('years')),
max($this->getOption('date_widget')->getOption('years')),
- $prefix, $prefix, $image, $this->getOption('culture'),
$this->getOption('config'),
+ $prefix, $prefix, $prefix,
+ $image, $this->getOption('culture'), $this->getOption('config'), $prefix,
$this->generateId($name.'[day]'), $this->generateId($name.'[month]'),
$this->generateId($name.'[year]'),
$prefix
- );*/
- public function jsOnSelect($name) {
-
-return sprintf(' function wfd_%s_update_linked(date)
- {
- date = date+"";
- var splittedDate = date.split("-");
- jQuery("#%s").val(parseInt(date.substring(0, 4)));
-
- if(splittedDate[1][0] == 0) {
- splittedDate[1] = splittedDate[1][1];
- }
- jQuery("#%s").val(splittedDate[1]);
-
- if(splittedDate[2][0] == 0) {
- splittedDate[2] = splittedDate[2][1];
- }
- jQuery("#%s").val(splittedDate[2]);
-
- jQuery("#%s").blur();
- jQuery("#%s").change();
- }', $name, $name.'_year', $name.'_month', $name.'_day', $name,
$name.'_temp');
-
- }
+ );
+ }
public function getJavaScripts() {
$array = parent::getJavaScripts();
+ $array[] = '../sfJqueryReloadedPlugin/js/ui/ui.datepicker.min.js';
$array[] =
'../sfJqueryReloadedPlugin/js/i18n/ui.datepicker-'.$this->getOption('culture').'.js';
+
return $array;
}
public function getStylesheets() {
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.