|
From: <gem...@li...> - 2011-11-17 11:46:14
|
Revision: 228
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=228&view=rev
Author: mennodekker
Date: 2011-11-17 11:46:04 +0000 (Thu, 17 Nov 2011)
Log Message:
-----------
Fixing a problem with the order of viewhelpers and moving datepicker display code to viewhelper instead of setview (result: javascript code once instead of twice in some case)
Modified Paths:
--------------
trunk/library/classes/Gems/Default/ExportAction.php
trunk/library/classes/Gems/JQuery/Form/Element/ToggleCheckboxes.php
trunk/library/classes/Gems/TabForm.php
trunk/library/classes/MUtil/Form.php
trunk/library/classes/MUtil/JQuery/Form/Element/DatePicker.php
Added Paths:
-----------
trunk/library/classes/MUtil/JQuery/View/
trunk/library/classes/MUtil/JQuery/View/Helper/
trunk/library/classes/MUtil/JQuery/View/Helper/DatePicker.php
Removed Paths:
-------------
trunk/library/classes/MUtil/View/Helper/DatePicker.php
Modified: trunk/library/classes/Gems/Default/ExportAction.php
===================================================================
--- trunk/library/classes/Gems/Default/ExportAction.php 2011-11-17 10:59:27 UTC (rev 227)
+++ trunk/library/classes/Gems/Default/ExportAction.php 2011-11-17 11:46:04 UTC (rev 228)
@@ -89,8 +89,6 @@
$div[] = $form;
} else {
Zend_Layout::resetMvcInstance();
- $this->view->addHelperPath('Gems/JQuery/View/Helper', 'Gems_JQuery_View_Helper');
- $this->view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper');
$this->html->raw($form->render($this->view));
//Now add all onload actions to make the form still work
Modified: trunk/library/classes/Gems/JQuery/Form/Element/ToggleCheckboxes.php
===================================================================
--- trunk/library/classes/Gems/JQuery/Form/Element/ToggleCheckboxes.php 2011-11-17 10:59:27 UTC (rev 227)
+++ trunk/library/classes/Gems/JQuery/Form/Element/ToggleCheckboxes.php 2011-11-17 11:46:04 UTC (rev 228)
@@ -79,14 +79,12 @@
*/
public function setView(Zend_View_Interface $view = null)
{
+ $element = parent::setView($view);
if (null !== $view) {
if (false === $view->getPluginLoader('helper')->getPaths('Gems_JQuery_View_Helper')) {
$view->addHelperPath('Gems/JQuery/View/Helper', 'Gems_JQuery_View_Helper');
}
- if (false === $view->getPluginLoader('helper')->getPaths('ZendX_JQuery_View_Helper')) {
- $view->addHelperPath('ZendX/JQuery/View/Helper', 'ZendX_JQuery_View_Helper');
- }
}
- return parent::setView($view);
+ return $element;
}
}
\ No newline at end of file
Modified: trunk/library/classes/Gems/TabForm.php
===================================================================
--- trunk/library/classes/Gems/TabForm.php 2011-11-17 10:59:27 UTC (rev 227)
+++ trunk/library/classes/Gems/TabForm.php 2011-11-17 11:46:04 UTC (rev 228)
@@ -319,10 +319,12 @@
*/
public function setView(Zend_View_Interface $view = null) {
$form = parent::setView($view);
- ZendX_JQuery::enableView($view);
-
- if (false === $view->getPluginLoader('helper')->getPaths('Gems_JQuery_View_Helper')) {
- $view->addHelperPath('Gems/JQuery/View/Helper', 'Gems_JQuery_View_Helper');
+
+ if ($view) {
+ $this->activateJQuery();
+ if (false === $view->getPluginLoader('helper')->getPaths('Gems_JQuery_View_Helper')) {
+ $view->addHelperPath('Gems/JQuery/View/Helper', 'Gems_JQuery_View_Helper');
+ }
}
return $form;
Modified: trunk/library/classes/MUtil/Form.php
===================================================================
--- trunk/library/classes/MUtil/Form.php 2011-11-17 10:59:27 UTC (rev 227)
+++ trunk/library/classes/MUtil/Form.php 2011-11-17 11:46:04 UTC (rev 228)
@@ -1,44 +1,44 @@
<?php
-
-/**
- * Copyright (c) 2011, Erasmus MC
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Erasmus MC nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+
+/**
+ * Copyright (c) 2011, Erasmus MC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Erasmus MC nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * @version $Id$
+ * @version $Id$
* @package MUtil
* @subpackage Acl
* @copyright Copyright (c) 2011 Erasmus MC
* @license New BSD License
- */
+ */
/**
* @package MUtil
* @subpackage Form
* @copyright Copyright (c) 2011 Erasmus MC
* @license New BSD License
- */
+ */
class MUtil_Form extends Zend_Form
{
protected $_displayOrder = array('element', 'errors', 'description');
@@ -96,11 +96,11 @@
return;
}
}
-
+
+ ZendX_JQuery::enableView($view);
+
if (false === $view->getPluginLoader('helper')->getPaths('MUtil_JQuery_View_Helper')) {
$view->addHelperPath('MUtil/JQuery/View/Helper', 'MUtil_JQuery_View_Helper');
-
- ZendX_JQuery::enableView($view);
}
}
Modified: trunk/library/classes/MUtil/JQuery/Form/Element/DatePicker.php
===================================================================
--- trunk/library/classes/MUtil/JQuery/Form/Element/DatePicker.php 2011-11-17 10:59:27 UTC (rev 227)
+++ trunk/library/classes/MUtil/JQuery/Form/Element/DatePicker.php 2011-11-17 11:46:04 UTC (rev 228)
@@ -213,26 +213,14 @@
}
}
- if ($format = $this->getJQueryParam('dateFormat')) {
- //*
- $js[] = '{';
- $js[] = " var datePick = $('#" . $this->getId() . "');";
- $js[] = '';
- $js[] = " datePick.blur(function() {";
- $js[] = " var dateused;";
- $js[] = " var dateformat = '" . $format . "';";
- // TODO: Why won't this work
- // $js[] = " var dateformat = datePick.datepicker('option', 'dateFormat');";
- // $js[] = " alert(dateformat);";
- $js[] = " dateused = datePick.attr('value');";
- $js[] = " dateused = $.datepicker.parseDate(dateformat, dateused);";
- $js[] = " datePick.attr('value', $.datepicker.formatDate(dateformat, dateused));";
- $js[] = " });";
- $js[] = '}';
+ $element = parent::setView($view);
- $view->inlineScript()->appendScript(implode("\n", $js)); // */
+ if (null !== $view) {
+ if (false === $view->getPluginLoader('helper')->getPaths('MUtil_JQuery_View_Helper')) {
+ $view->addHelperPath('MUtil/JQuery/View/Helper', 'MUtil_JQuery_View_Helper');
+ }
}
- return parent::setView($view);
+ return $element;
}
}
Copied: trunk/library/classes/MUtil/JQuery/View/Helper/DatePicker.php (from rev 225, trunk/library/classes/MUtil/View/Helper/DatePicker.php)
===================================================================
--- trunk/library/classes/MUtil/JQuery/View/Helper/DatePicker.php (rev 0)
+++ trunk/library/classes/MUtil/JQuery/View/Helper/DatePicker.php 2011-11-17 11:46:04 UTC (rev 228)
@@ -0,0 +1,78 @@
+<?php
+
+
+/**
+ * Copyright (c) 2011, Erasmus MC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Erasmus MC nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ *
+ * @author Matijs de Jong
+ * @since 1.0
+ * @version 1.1
+ * @package MUtil
+ * @subpackage View
+ */
+
+/**
+ *
+ * @author Matijs de Jong
+ * @package MUtil
+ * @subpackage View
+ */
+class MUtil_JQuery_View_Helper_DatePicker extends ZendX_JQuery_View_Helper_DatePicker
+{
+ public function datePicker($id, $value = null, array $params = array(), array $attribs = array()) {
+ $result = parent::datePicker($id, $value, $params, $attribs);
+ if (isset($attribs['disabled'])) {
+ $js = "$('#" . $attribs['id'] . "').datepicker('disable');";
+ $this->jquery->addOnLoad($js);
+ }
+
+ if ($format = $params['dateFormat']) {
+ //*
+ $js = array();
+ $js[] = '{';
+ $js[] = " var datePick = $('#" . $id . "');";
+ $js[] = '';
+ $js[] = " datePick.blur(function() {";
+ $js[] = " var dateused;";
+ $js[] = " var dateformat = '" . $format . "';";
+ // TODO: Why won't this work
+ // $js[] = " var dateformat = datePick.datepicker('option', 'dateFormat');";
+ // $js[] = " alert(dateformat);";
+ $js[] = " dateused = datePick.attr('value');";
+ $js[] = " dateused = $.datepicker.parseDate(dateformat, dateused);";
+ $js[] = " datePick.attr('value', $.datepicker.formatDate(dateformat, dateused));";
+ $js[] = " });";
+ $js[] = '}';
+
+ $this->view->inlineScript()->appendScript(implode("\n", $js)); // */
+ }
+ return $result;
+ }
+
+}
\ No newline at end of file
Deleted: trunk/library/classes/MUtil/View/Helper/DatePicker.php
===================================================================
--- trunk/library/classes/MUtil/View/Helper/DatePicker.php 2011-11-17 10:59:27 UTC (rev 227)
+++ trunk/library/classes/MUtil/View/Helper/DatePicker.php 2011-11-17 11:46:04 UTC (rev 228)
@@ -1,57 +0,0 @@
-<?php
-
-
-/**
- * Copyright (c) 2011, Erasmus MC
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Erasmus MC nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- *
- * @author Matijs de Jong
- * @since 1.0
- * @version 1.1
- * @package MUtil
- * @subpackage View
- */
-
-/**
- *
- * @author Matijs de Jong
- * @package MUtil
- * @subpackage View
- */
-class MUtil_View_Helper_DatePicker extends ZendX_JQuery_View_Helper_DatePicker
-{
- public function datePicker($id, $value = null, array $params = array(), array $attribs = array()) {
- $result = parent::datePicker($id, $value, $params, $attribs);
- if (isset($attribs['disabled'])) {
- $js = "$('#" . $attribs['id'] . "').datepicker('disable');";
- $this->jquery->addOnLoad($js);
- }
- return $result;
- }
-
-}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|