source: Dev/trunk/src/client/dojox/widget/FisheyeListItem.js

Last change on this file was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 3.3 KB
Line 
1define(["dojo/_base/declare", "dojo/_base/sniff", "dojo/dom", "dojo/dom-attr", "dojo/dom-class", "dojo/dom-style", "dojo/dom-construct", "dojo/_base/window", "dijit/_WidgetBase", "dijit/_TemplatedMixin", "dijit/_Contained"],
2        function(declare, has, dom, attr, domClass, style, construct, winUtil, _WidgetBase, _TemplatedMixin, _Contained){
3
4        return declare("dojox.widget.FisheyeListItem",
5                [_WidgetBase, _TemplatedMixin, _Contained], {
6                // summary:
7                //              Menu item inside of a FisheyeList.
8                //              See FisheyeList documentation for details on usage.
9
10                // iconSrc: String
11                //              pathname to image file (jpg, gif, png, etc.) of icon for this menu item
12                iconSrc: "",
13
14                // label: String
15                //              label to print next to the icon, when it is moused-over
16                label: "",
17
18                // id: String
19                //              will be set to the id of the orginal div element
20                id: "",
21
22                templateString:
23                        '<div class="dojoxFisheyeListItem">' +
24                        '  <img class="dojoxFisheyeListItemImage" data-dojo-attach-point="imgNode" data-dojo-attach-event="onmouseover:onMouseOver,onmouseout:onMouseOut,onclick:onClick">' +
25                        '  <div class="dojoxFisheyeListItemLabel" data-dojo-attach-point="lblNode"></div>' +
26                        '</div>',
27
28                _isNode: function(/* object */wh){
29                        // summary:
30                        //              checks to see if wh is actually a node.
31                        if(typeof Element == "function"){
32                                try{
33                                        return wh instanceof Element;   // Boolean
34                                }catch(e){}
35                        }else{
36                                // best-guess
37                                return wh && !isNaN(wh.nodeType);   // Boolean
38                        }
39                        return false;
40                },
41
42                _hasParent: function(/*Node*/ node){
43                        // summary:
44                        //              returns whether or not node is a child of another node.
45                        return Boolean(node && node.parentNode && this._isNode(node.parentNode));   // Boolean
46                },
47
48                postCreate: function(){
49
50                        // set image
51                        var parent;
52                        if((this.iconSrc.toLowerCase().substring(this.iconSrc.length-4)==".png") && has("ie") < 7){
53                                /* we set the id of the new fisheyeListItem to the id of the div defined in the HTML */
54                                if(this._hasParent(this.imgNode) && this.id != ""){
55                                        parent = this.imgNode.parentNode;
56                                        attr.set(parent, "id", this.id);
57                                }
58                                style.set(this.imgNode, "filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.iconSrc+"', sizingMethod='scale')");
59                                this.imgNode.src = this._blankGif.toString();
60                        }else{
61                                if(this._hasParent(this.imgNode) && this.id != ""){
62                                        parent = this.imgNode.parentNode;
63                                        attr.set(parent, "id", this.id);
64                                }
65                                this.imgNode.src = this.iconSrc;
66                        }
67
68                        // Label
69                        if(this.lblNode){
70                                construct.place(winUtil.doc.createTextNode(this.label), this.lblNode);
71                        }
72                        dom.setSelectable(this.domNode, false);
73                        this.startup();
74                },
75
76                startup: function(){
77                        this.parent = this.getParent();
78                },
79
80                onMouseOver: function(/*Event*/ e){
81                        // summary:
82                        //              callback when user moves mouse over this menu item
83                        //              in conservative mode, don't activate the menu until user mouses over an icon
84                        if(!this.parent.isOver){
85                                this.parent._setActive(e);
86                        }
87                        if(this.label != "" ){
88                                domClass.add(this.lblNode, "dojoxFishSelected");
89                                this.parent._positionLabel(this);
90                        }
91                },
92
93                onMouseOut: function(/*Event*/ e){
94                        // summary:
95                        //              callback when user moves mouse off of this menu item
96                        domClass.remove(this.lblNode, "dojoxFishSelected");
97                },
98
99                onClick: function(/*Event*/ e){
100                        // summary:
101                        //              user overridable callback when user clicks this menu item
102                }
103        });
104});
Note: See TracBrowser for help on using the repository browser.