I have a working example for you. The following code will allow you to
create dijit.Tooltip elements:
<?php
class My_View_Helper_Tooltip extends Zend_Dojo_View_Helper_Dijit
{
protected $_dijit = 'dijit.Tooltip';
protected $_module = 'dijit.Tooltip';
public function tooltip($id, $value = null, array $params = array(),
array $attribs = array())
{
$attribs = $this->_prepareDijit($attribs, $params, null);
$html = '<div' . $this->_htmlAttribs($attribs) . '>'
. $value
. "</div>\n";
return $html;
}
}
/* and in your view scripts */
<?php echo $this->tooltip('test', null, array(
'connectId' => 'username',
'label' => 'My Tooltip',
), array(
'id' => 'test'
)); ?>
This is far from an ideal solution but it's a good start.
Matthew and others: Any comments on how to refactor this into something
worthy?
A few concerns:
* The div markup still needs to be created even when using
programmatic otherwise the main dojo helper will not attach the
params.
* The method signature for Tooltip::tooltip can definately be
tidied. $value makes no sense for a start
* The client code in the view script currently requires
$attribs['id'] to be set. This could be tidied away in the method.
Daniel
Daniel Skinner wrote:
> Ok. Tooltip should be quite simple. Take a look at one of the current
> dijit implementations:
>
> class Zend_Dojo_View_Helper_Textarea extends Zend_Dojo_View_Helper_Dijit
> {
> protected $_dijit = 'dijit.form.Textarea';
>
> protected $_module = 'dijit.form.Textarea';
>
> public function textarea($id, $value = null, array $params =
> array(), array $attribs = array())
> {
> ...
> }
> }
>
> So, with absolutely no pre-thought to if this will actually work, I
> would start out with:
>
> class My_Dojo_View_Helper_Tooltip extends Zend_Dojo_View_Helper_Dijit
> {
> protected $_dijit = 'dijit.Tooltip';
>
> protected $_module = 'dijit.Tooltip';
>
> public function tooltip($id, $value = null, array $params =
> array(), array $attribs = array())
> {
> $attribs = $this->_prepareDijit($attribs, $params, null);
> /* Output div dojoType="dijit.Tooltip" markup here only if use
> declarative */
> }
> }
>
> Daniel
>
> Steven wrote:
>> I wasnt thinking of anything that ambitious - I don't really know
>> alot about JavaScript hence my interest in ZFs Dojo implementation.
>>
>> I was hoping to implement digit.tooltip, dojox.analytics - and maybe
>> some type of carousell.
>>
>> Steve
>>
>> On Sat, Oct 18, 2008 at 5:51 PM, Daniel Skinner
>> <skinner@destiny-denied.co.uk <mailto:skinner@destiny-denied.co.uk>>
>> wrote:
>>
>> What dijits are you looking to implement specifically?
>>
>> Take a look at Zend_Dojo_View_Helper_Dijit. This is the base
>> class you will be extending from.
>>
>> A few of us are in the early states of proposing dijit.Tree,
>> dojo(X) data stores and DnD components. Let us know if that
>> compliments your interests.
>>
>> Daniel
>>
>>
>> Steven wrote:
>>
>> Hi there,
>>
>> I'm not that familiar with Dojo but would like to implement
>> View Helpers for some of the other Dijits not currently
>> included with ZF - however the manual doesn't really outline
>> the specifics for doing so. Can anyone help me out?
>>
>> Cheers
>>
>> Steve
>>
>>
>>
没有评论:
发表评论