| 1 |
define(["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 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
iconSrc: "", |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
label: "", |
| 17 |
|
| 18 |
|
| 19 |
|
| 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(wh){ |
| 29 |
|
| 30 |
|
| 31 |
if(typeof Element == "function"){ |
| 32 |
try{ |
| 33 |
return wh instanceof Element; |
| 34 |
}catch(e){} |
| 35 |
}else{ |
| 36 |
|
| 37 |
return wh && !isNaN(wh.nodeType); |
| 38 |
} |
| 39 |
return false; |
| 40 |
}, |
| 41 |
|
| 42 |
_hasParent: function( node){ |
| 43 |
|
| 44 |
|
| 45 |
return Boolean(node && node.parentNode && this._isNode(node.parentNode)); |
| 46 |
}, |
| 47 |
|
| 48 |
postCreate: function(){ |
| 49 |
|
| 50 |
|
| 51 |
var parent; |
| 52 |
if((this.iconSrc.toLowerCase().substring(this.iconSrc.length-4)==".png") && has("ie") < 7){ |
| 53 |
|
| 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 |
|
| 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( e){ |
| 81 |
|
| 82 |
|
| 83 |
|
| 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( e){ |
| 94 |
|
| 95 |
|
| 96 |
domClass.remove(this.lblNode, "dojoxFishSelected"); |
| 97 |
}, |
| 98 |
|
| 99 |
onClick: function( e){ |
| 100 |
|
| 101 |
|
| 102 |
} |
| 103 |
}); |
| 104 |
}); |