|
From: <gem...@li...> - 2011-09-15 10:47:23
|
Revision: 16
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=16&view=rev
Author: mennodekker
Date: 2011-09-15 10:47:16 +0000 (Thu, 15 Sep 2011)
Log Message:
-----------
fixed #1: Create a toggle element in forms
Added Paths:
-----------
trunk/library/classes/Gems/JQuery/Form/Element/
trunk/library/classes/Gems/JQuery/Form/Element/ToggleCheckboxes.php
trunk/library/classes/Gems/JQuery/View/Helper/ToggleCheckboxes.php
Added: trunk/library/classes/Gems/JQuery/Form/Element/ToggleCheckboxes.php
===================================================================
--- trunk/library/classes/Gems/JQuery/Form/Element/ToggleCheckboxes.php (rev 0)
+++ trunk/library/classes/Gems/JQuery/Form/Element/ToggleCheckboxes.php 2011-09-15 10:47:16 UTC (rev 16)
@@ -0,0 +1,94 @@
+<?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.
+ *
+ * Short description of file
+ *
+ * @package Gems
+ * @subpackage JQuery
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $
+ */
+
+/**
+ * Short description for ToggleCheckboxes
+ *
+ * Long description for class ToggleCheckboxes (if any)...
+ *
+ * @package Gems
+ * @subpackage JQuery
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @since Class available since version 1.5
+ */
+class Gems_JQuery_Form_Element_ToggleCheckboxes extends Zend_Form_Element_Button
+{
+ /**
+ * Use toggleCheckboxes view helper by default
+ * @var string
+ */
+ public $helper = 'toggleCheckboxes';
+
+ /**
+ * Create a button to toggle all cyhackboxes found by a given jQuery selector
+ *
+ * Specify the 'selector' in the options http://api.jquery.com/category/selectors/
+ *
+ * Usage:
+ * $element = new Gems_JQuery_Form_Element_ToggleCheckboxes('name', array('selector'=>'input[name^=oid]')
+ *
+ * @param type $spec
+ * @param type $options
+ */
+ public function __construct($spec, $options = null)
+ {
+ parent::__construct($spec, $options);
+ }
+
+ /**
+ * Set the view object
+ *
+ * Ensures that the view object has the Gems_jQuery view helper path set.
+ *
+ * @param Zend_View_Interface $view
+ * @return Gems_JQuery_Form_Element_ToggleCheckboxes
+ */
+ public function setView(Zend_View_Interface $view = null)
+ {
+ 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);
+ $z = new ZendX_JQuery_Form_Element_AutoComplete();
+ $z = new ZendX_JQuery_Form_Decorator_UiWidgetElement();
+ }
+}
\ No newline at end of file
Added: trunk/library/classes/Gems/JQuery/View/Helper/ToggleCheckboxes.php
===================================================================
--- trunk/library/classes/Gems/JQuery/View/Helper/ToggleCheckboxes.php (rev 0)
+++ trunk/library/classes/Gems/JQuery/View/Helper/ToggleCheckboxes.php 2011-09-15 10:47:16 UTC (rev 16)
@@ -0,0 +1,68 @@
+<?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.
+ *
+ * Short description of file
+ *
+ * @package Gems
+ * @subpackage JQuery
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @version $Id: Sample.php 215 2011-07-12 08:52:54Z michiel $
+ */
+
+/**
+ * Short description for ToggleCheckboxes
+ *
+ * Long description for class ToggleCheckboxes (if any)...
+ *
+ * @package Gems
+ * @subpackage JQuery
+ * @copyright Copyright (c) 2011 Erasmus MC
+ * @license New BSD License
+ * @since Class available since version 1.5
+ */
+class Gems_JQuery_View_Helper_ToggleCheckboxes extends ZendX_JQuery_View_Helper_UiWidget
+{
+ //put your code here
+ public function toggleCheckboxes($id, $value = null, array $params = array())
+ {
+
+ $js = sprintf('%1$s("#%2$s").click(function(){
+ $("%3$s").attr("checked", !$("%3$s").attr("checked"));
+});',
+ ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(),
+ $id,
+ $params['selector']
+ );
+ unset($params['selector']);
+
+ $this->jquery->addOnLoad($js);
+
+ //Now do something to add the jquery stuff
+ return $this->view->formButton($id, $value, $params);
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|