Bug 876033 - Add arranged event to richgrid, event cleanup. r=mbrubeck

--HG--
extra : rebase_source : bb5b699fcdfd2024030c051f13fb13a28afd76c6
This commit is contained in:
Sam Foster 2013-07-17 11:18:09 -07:00
parent 0f39f0a252
commit 3f3bb741ce

View File

@ -55,9 +55,11 @@
this.clearSelection();
}
this._selectedItem = wasSelected ? null : anItem;
anItem.selected = !wasSelected;
this._fireOnSelectionChange();
if (wasSelected)
anItem.removeAttribute("selected");
else
anItem.setAttribute("selected", true);
this._fireEvent("selectionchange");
]]>
</body>
</method>
@ -72,13 +74,14 @@
this.clearSelection();
}
this._selectedItem = anItem;
anItem.selected = true;
if (wasSelected) {
return;
}
anItem.setAttribute("selected", true);
if (isSingleMode) {
if (!wasSelected) {
this._fireOnSelect();
}
this._fireEvent("select");
} else {
this._fireOnSelectionChange();
this._fireEvent("selectionchange");
}
]]>
</body>
@ -170,7 +173,7 @@
<property name="selectedItems">
<getter>
<![CDATA[
return this.querySelectorAll("richgriditem[selected='true']");
return this.querySelectorAll("richgriditem[selected]");
]]>
</getter>
</property>
@ -486,6 +489,7 @@
if (this._columnCount) {
gridStyle.MozColumnCount = this._columnCount;
}
this._fireEvent("arranged");
]]>
</body>
</method>
@ -632,28 +636,22 @@
</body>
</method>
<method name="_fireOnSelect">
<method name="_fireEvent">
<parameter name="aType"/>
<body>
<![CDATA[
if (this.suppressOnSelect || this._suppressOnSelect)
return;
switch (aType) {
case "select" :
case "selectionchange" :
if (this.suppressOnSelect || this._suppressOnSelect)
return;
break;
case "arranged" :
break;
}
let event = document.createEvent("Events");
event.initEvent("select", true, true);
this.dispatchEvent(event);
]]>
</body>
</method>
<method name="_fireOnSelectionChange">
<body>
<![CDATA[
// flush out selection-related cached properties so they get recalc'd next time
// fire an event?
if (this.suppressOnSelect || this._suppressOnSelect)
return;
let event = document.createEvent("Events");
event.initEvent("selectionchange", true, true);
event.initEvent(aType, true, true);
this.dispatchEvent(event);
]]>
</body>
@ -947,7 +945,10 @@
<![CDATA[
// fires for right-click, long-click and (keyboard) contextmenu input
// toggle the selected state of tiles in a grid
this.control.handleItemContextMenu(this, event);
let gridParent = this.control;
if(!this.isBound || !gridParent)
return;
gridParent.handleItemContextMenu(this, event);
]]>
</handler>
</handlers>