@qooxdoo/framework
Version:
The JS Framework for Coders
112 lines (82 loc) • 2.25 kB
JavaScript
/* ************************************************************************
qooxdoo - the new era of web development
http://qooxdoo.org
Copyright:
2004-2008 1&1 Internet AG, Germany, http://www.1und1.de
License:
MIT: https://opensource.org/licenses/MIT
See the LICENSE file in the project's top-level directory for details.
Authors:
* Fabian Jakobs (fjakobs)
************************************************************************ */
/**
* The small folder open/close button
*/
qx.Class.define("qx.ui.tree.core.FolderOpenButton",
{
extend : qx.ui.basic.Image,
include : qx.ui.core.MExecutable,
/*
*****************************************************************************
CONSTRUCTOR
*****************************************************************************
*/
construct : function()
{
this.base(arguments);
this.initOpen();
this.addListener("tap", this._onTap);
this.addListener("pointerdown", this._stopPropagation, this);
this.addListener("pointerup", this._stopPropagation, this);
},
/*
*****************************************************************************
PROPERTIES
*****************************************************************************
*/
properties :
{
/**
* Whether the button state is "open"
*/
open :
{
check : "Boolean",
init : false,
event : "changeOpen",
apply : "_applyOpen"
}
},
/*
*****************************************************************************
MEMBERS
*****************************************************************************
*/
members :
{
// property apply
_applyOpen : function(value, old)
{
value ? this.addState("opened") : this.removeState("opened");
this.execute();
},
/**
* Stop tap event propagation
*
* @param e {qx.event.type.Event} The event object
*/
_stopPropagation : function(e) {
e.stopPropagation();
},
/**
* Pointer tap event listener
*
* @param e {qx.event.type.Pointer} Pointer event
*/
_onTap : function(e)
{
this.toggleOpen();
e.stopPropagation();
}
}
});