[Mozile] Rng and command question
James A. Overton
james at overton.ca
Sun Jan 7 08:48:21 PST 2007
Hi Dirk,
To do what you want to do, don't worry about the RNG. Instead make
use of Command.isAvailable() methods. When isAvailable() returns
false the command's button will be greyed out and the command will be
disabled. So for the custom commands you write, add a custom
isAvailable(event) method which only returns true when the cursor is
inside the <p class="catlinks"> element. Try something like this:
this.isAvailable = function(event) {
var node = mozile.edit._getNode(event);
if(!node) return false;
while(node) {
if(node.nodeType == mozile.dom.ELEMENT_NODE &&
mozile.dom.getClass(node) == "catlinks")
return true;
node = node.parentNode;
}
return false;
}
James
On 2007-01-07, at 5:42 AM, Dirk Westfal wrote:
> Hi,
> i`m trying to get a understanding of the mozile code and have a
> question:
>
> Mediawiki renders as 'category' - link as group of html elements like:
>
> <div id="catlinks"><p class='catlinks'>some text </p></div>
>
> Now I`m looking for a way to create an edit command for this.
>
> Is there a way to create a command that is bound to the 'div' element
> depending on the value of div.id ?
>
> With an rng definition eg. like this:
>
> <define name="div">
> <element name="div">
> <optional>
> <attribute name="id">
> <choice>
> <value>catlinks</value>
> </choice>
> </optional>
> </element>
> </define>
>
> The other problem i see is that 'div' is already defined. When an
> element definition is checked, does the check stop at the first match?
> If so, can the " <ref name="Common.attrib"/>" reference still be
> included in the above definition to not break other div - related
> operations?
>
> How the commands are bound is still somewhat unclear to me.
>
> many thanks in advance,
> Dirk
> _______________________________________________
> Mozile mailing list
> Mozile at mozdev.org
> http://mozdev.org/mailman/listinfo/mozile
More information about the Mozile
mailing list