blueshoes php application framework and cms            javascript_components
[ class tree: javascript_components ] [ index: javascript_components ] [ all elements ]

Class: Bs_TreeElement

Source Location: /components/tree/Bs_TreeElement.class.js.php

Class Overview


Bs_TreeElement class.


Author(s):

Copyright:

  • blueshoes.org

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 22]
Bs_TreeElement class.

an instance of this class represents a folder/file/whatever.

note: sometimes we use long and non-compliant id's for tags. example: out += '<span id="this._tree._objectId + '_e_' + this.id + '_children">'; netscape does not like long id's and ns4 did not like underscores. a fix would be to md5() the strings to get a shorter and still unique id.

"tree element" and "tree node" are synonyms.




Tags:

copyright:  blueshoes.org
author:  andrej arn <at blueshoes dot org>


[ Top ]


Class Variables

$afterCaptionSpan =

[line 240]

html code that's put inside a span tag and displayed after the caption text.



Tags:

var:  afterCaptionSpan (html code)
see:  Bs_TreeElement::$beforeIconSpan, Bs_TreeElement::$beforeCaptionSpan
access:  public

Type:   string


[ Top ]

$beforeCaptionSpan =

[line 232]

html code that's put inside a span tag and displayed before the caption text.

could also be named afterIconSpan. it's between the icon and the caption.




Tags:

var:  beforeCaptionSpan (html code)
see:  Bs_TreeElement::$beforeIconSpan, Bs_TreeElement::$afterCaptionSpan
access:  public

Type:   string


[ Top ]

$beforeIconSpan =

[line 223]

html code that's put inside a span tag and displayed before the "folder" icon.



Tags:

var:  beforeIconSpan (html code)
see:  Bs_TreeElement::$beforeCaptionSpan, Bs_TreeElement::$afterCaptionSpan
access:  public

Type:   string


[ Top ]

$caption =

[line 55]

the visible text.

use setCaption() to modify it if it's already outrendered.




Tags:

var:  caption
see:  Bs_TreeElement::setCaption()
access:  public

Type:   string


[ Top ]

$checkboxName =

[line 138]

the name of the checkbox. not defined = don't use it.

gets set in this.initByArray().




Tags:

var:  checkboxName

Type:   string


[ Top ]

$dataContainer =

[line 261]

can be used to stick in any data.

this is useful if you want to init your tree with a data array, and on the click of a node something should happen. but then the node misses some related information.

hrm, let's give you an example: your tree looks like a directory tree, with dirs and files. when the user clicks on a file, you want to show in a div the size in kb of this file. but the tree does not know this. the tree just fires a registered function, and tells which node was clicked. but you don't have the nodeId-to-file relation. so what? well, much easier if you can stick in your data into the tree element directly, and later read that data. hrm, got the idea?




Tags:

var:  dataContainer
since:  bs4.3
access:  public

Type:   mixed


[ Top ]

$divStyle =

[line 83]

see Bs_Tree->divStyle, it's the same, you can simply overwrite it here.

then it will be used for this and everything beyond that (also see Bs_Tree->walkTree!).




Tags:

access:  public

Type:   mixed


[ Top ]

$icon =

[line 215]

if not set then the default icons will be used.

this means that both icons folderOpen.gif and folderClosed.gif have to exist in the image dir (see this.imageDir).

set to bool false if you don't want an icon.

set to a string for an image (in the same img dir as the others, see imageDir). use the file ending (.gif or so) as well. if your icon is in another dir, you can give the path also. but then it has to start with a slash / or http:// or https://.

examples: myIcon.gif myIcon.png /some/dir/myIcon.jpg http://www.blueshoes.org/_bsImages/buttons/globes/1.gif




Tags:

var:  icon
access:  public

Type:   mixed


[ Top ]

$id =

[line 33]

the unique identifier of this element.

for the built in auto-sequence (Bs_Tree.useAutoSequence) this is an int >0, but if you use your own handling it can be a string aswell.




Tags:

var:  id

Type:   mixed


[ Top ]

$imageDir =

[line 185]

see Bs_Tree->imageDir, it's the same, you can simply overwrite it here.

then it will be used for this and everything beyond that (also see Bs_Tree->walkTree!).




Tags:

access:  public

Type:   mixed


[ Top ]

$imageHeight =

[line 193]

see Bs_Tree->imageHeight, it's the same, you can simply overwrite it here.

then it will be used for this and everything beyond that (also see Bs_Tree->walkTree!).




Tags:

access:  public

Type:   mixed


[ Top ]

$isChecked =  0

[line 130]

used if the checkbox feature is used.

  1. = not checked
  2. = checked gray (part of the sub-elements are, part are not)
  3. = checked (this or everything below is checked)
now i think it's a dirty name. isChecked sounds like a function, not a var. but it's public, so i don't feel like renaming it and changing it everywhere. and checked sounds like boolean, not integer with 3 possibilities. (historic reasons when there was just true/false ...)




Tags:

var:  isChecked (default is 0)
see:  checkboxEvent(), Bs_Tree.useCheckboxSystem()
access:  public

Type:   int


[ Top ]

$isOpen =  false

[line 103]

stores if this tree node is open or not.



Tags:

var:  isOpen

Type:   bool


[ Top ]

$linkStyle =

[line 75]

see Bs_Tree->linkStyle, it's the same, you can simply overwrite it here.

then it will be used for this and everything beyond that (also see Bs_Tree->walkTree!).




Tags:

access:  public

Type:   mixed


[ Top ]

$onClick =

[line 96]

javascript code that fires on the onClick event.

can go together with an url, they don't byte each other.

special case: may use the string __this.id__ it will be replaced with the actual id. example: yourElement.onClick = "doThis(__this.id__, 'foobar');"




Tags:

access:  public

Type:   mixed


[ Top ]

$parent =

[line 39]

reference to the parent tree element object.


Type:   object parent


[ Top ]

$radioButtonSelected =

[line 147]

if the radio button of this element should be selected by default. only one can be!



Tags:

var:  radioButtonSelected
since:  bs4.3
see:  Bs_Tree.
access:  public

Type:   bool


[ Top ]

$target =

[line 67]



Tags:

var:  target
access:  public

Type:   string


[ Top ]

$url =

[line 61]



Tags:

var:  url
access:  public

Type:   string


[ Top ]

$visible =  true

[line 111]

if set to false then the element will be set to display:none.

it's still there (loaded) so you can use its methods etc.




Tags:

var:  visible
access:  public

Type:   bool


[ Top ]

$_level =  0

[line 161]

the level this element is in. think about the identing.



Tags:

var:  _level (default is 0, but that really should be overwritten.)

Type:   int


[ Top ]

$_tree =

[line 46]

reference to the tree object.



Tags:

access:  public

Type:   object _tree


[ Top ]



Class Methods


method addChild [line 321]

void addChild( object treeElement treeElement)

adds a treeElement child to this tree element (at the bottom).



Tags:

see:  addChildByArray();
access:  public


Parameters:

object treeElement   treeElement  

[ Top ]

method addChildByArray [line 349]

treeElement addChildByArray( array elementData)

adds a tree element based on the data given.



Tags:

return:  (the new instance of Bs_TreeElement)
since:  bs4.5
see:  addChild();
access:  public


Parameters:

array   elementData   elementData

[ Top ]

method exportAsArray [line 837]

array exportAsArray( bool withChildren)

export this object as hash. reverse function of initByArray().

note that the 'onClickCaption' and 'onChangeCheckbox' events, as well as 'events' (all attached events at all) set in initByArray() are not included in the returned array. this is a "todo".




Tags:

return:  (hash)
see:  Bs_TreeElement::initByArray()
since:  bs4.4
access:  public


Parameters:

bool   withChildren   withChildren (set to true if you want to have the children too.)

[ Top ]

method getThis [line 309]

object getThis( )

returns a reference to this object.



Tags:

access:  public


[ Top ]

method initByArray [line 770]

bool initByArray( array a, object tree tree, int level)

inits this tree element with the data of the given array (etc).

the given hash may have the following keys: 'caption' => string 'url' => string, a link on the caption 'target' => string, a target for the url (eg '_blank') 'onClick' => !deprecated! string, a javascript onClick event (function or string afaik) 'isOpen' => bool, if the node should be open or not 'isChecked' => int, 0 1 or 2 telling the value of the checkbox 'visible' => bool, if the node should be visible at all (including all its kids) 'icon' => string, name of the icon if you want to overwrite it. 'imageDir' => string, path to the dir where the imges are, if you want to overwrite it. 'beforeIconSpan' => string, html code you can put in a predefined span that shows up in front of the icon. 'beforeCaptionSpan' => string, html code you can put in a predefined span that shows up in front of the caption. 'afterCaptionSpan' => string, html code you can put in a predefined span that shows up behind the caption. 'checkboxName' => string, name of the checkbox. if not specified then something will be made up. 'radioButtonSelected' => bool, if the radio button of this element should be selected by default. only one can be! 'onClickCaption' => !deprecated! string, a javascript onClick event on the caption (function or string afaik) 'onChangeCheckbox' => !deprecated! string, a javascript onChange event on the checkbox (function or string afaik) 'dataContainer' => mixed (whatever, see var this.dataContainer). 'events' => array (hash with key/value pairs, see attachEvent().)




Tags:

return:  (true on success, false and sets error on failure.)
see:  Bs_TreeElement::exportAsArray()
access:  public


Parameters:

array   a   a (hash, see above)
object tree   tree   (so we can set the reference to the tree object.)
int   level   level (the level of the tree element.)

[ Top ]

method isChild [line 365]

bool isChild( mixed elementId, bool bubble)

tells if the element specified is a child of this one.

if bubble is set to true, then not only a direct child will return true.




Tags:

since:  bs4.4
access:  public


Parameters:

mixed   elementId   elementId (int or string)
bool   bubble   bubble

[ Top ]

method render [line 408]

array render( bool omitDivTags, bool putIntoPage, int lookAhead)

renders this tree element with its sub-elements.

return value: element 0 is the html output element 1 is js code that needs to be evaluated AFTER the html has been outputted (because it depends on elements in the html code). if that element is an empty string, don't execute it.




Tags:

return:  (vector, see above)
access:  public


Parameters:

bool   omitDivTags   omitDivTags (set to true if you don't want the <div><div> tags anymore. used internally to re-render.)
bool   putIntoPage   putIntoPage (set to true if you don't want the result returned, it will be added to the page automatically. you will get bool true back. since bs4.4.)
int   lookAhead   lookAhead (how many levels to render down. default is this._tree.lookAhead. added in bs4.5)

[ Top ]

method reset [line 727]

void reset( )

resets this tree element.



Tags:

todo:  update this method so all vars get reset. what about the id? ...
access:  public


[ Top ]

method setCaption [line 383]

void setCaption( string caption)

can be used to modify the caption of the tree is already outrendered.



Tags:

see:  var caption
access:  public


Parameters:

string   caption   caption

[ Top ]

method updateObjectByArray [line 884]

void updateObjectByArray( array a)

updates the object vars from the data given in the array.

caution: code not up to date. consider merging this with initByArray() somehow.




Tags:

access:  public


Parameters:

array   a   a

[ Top ]


Documentation generated on Mon, 29 Dec 2003 22:18:35 +0100 by phpDocumentor 1.2.3