[Mathcast-checkin] SF.net SVN: mathcast:[180] trunk/chrome/content
Brought to you by:
timothylee,
tom_chekam
|
From: <tim...@us...> - 2014-09-01 02:35:45
|
Revision: 180
http://sourceforge.net/p/mathcast/code/180
Author: timothylee
Date: 2014-09-01 02:35:42 +0000 (Mon, 01 Sep 2014)
Log Message:
-----------
- Ensure the equation name in always shown on status bar
- Use MutationObserver in favour of deprecated Mutation Events
Modified Paths:
--------------
trunk/chrome/content/bindings/equationlist.xml
trunk/chrome/content/file.js
Modified: trunk/chrome/content/bindings/equationlist.xml
===================================================================
--- trunk/chrome/content/bindings/equationlist.xml 2014-09-01 01:03:05 UTC (rev 179)
+++ trunk/chrome/content/bindings/equationlist.xml 2014-09-01 02:35:42 UTC (rev 180)
@@ -40,7 +40,7 @@
<implementation>
<!-- Label contains raw MathML -->
- <field name="_label"/>
+ <field name="_label">new String()</field>
<property name="label" readonly="true">
<getter>
<![CDATA[
@@ -119,24 +119,6 @@
]]>
</handler>
- <handler event="DOMSubtreeModified">
- <![CDATA[
- // Update the index of all richlistitems
- var idx = 0;
- for (var child = this.firstChild; child; child = child.nextSibling)
- {
- if (child.nodeName != "richlistitem") continue;
- var mml = child.firstChild;
- var name = "";
- if (mml && mml.hasAttribute("id"))
- name = mml.getAttribute("id");
- child.setAttribute("tooltiptext", name);
- child.setAttribute("index", idx);
- ++idx;
- }
- ]]>
- </handler>
-
</handlers>
<implementation implements="nsIXBLAccessible">
@@ -300,6 +282,9 @@
]]>
</field>
+ <!-- Observer for child list modification -->
+ <field name="_mutationObserver"/>
+
<property name="selectedIndices" readonly="true">
<!-- Setter purposely not implemented; the getter returns an
array selected index sorted in increasing order -->
@@ -319,11 +304,18 @@
<![CDATA[
this.selType = "multiple";
window.controllers.insertControllerAt(0, this._controller);
+
+ // Observe changes in rich item list
+ var _outer = this;
+ this._mutationObserver = new MutationObserver(
+ function(mutations) { _outer._onChildListModified(); })
+ this._mutationObserver.observe(this, {childList:true, subtree:true});
]]>
</constructor>
<destructor>
<![CDATA[
+ this._mutationObserver.disconnect();
window.controllers.removeControllerAt(this._controller);
]]>
</destructor>
@@ -345,6 +337,27 @@
</body>
</method>
+ <method name="_onChildListModified">
+ <parameter name="mutations"/>
+ <body>
+ <![CDATA[
+ // Update the index of all richlistitems
+ var idx = 0;
+ for (var child = this.firstChild; child; child = child.nextSibling)
+ {
+ if (child.nodeName != "richlistitem") continue;
+ var mml = child.firstChild;
+ var name = "";
+ if (mml && mml.hasAttribute("id"))
+ name = mml.getAttribute("id");
+ child.setAttribute("tooltiptext", name);
+ child.setAttribute("index", idx);
+ ++idx;
+ }
+ ]]>
+ </body>
+ </method>
+
<method name="_wrapInHTML">
<parameter name="content"/>
<body>
@@ -1291,6 +1304,9 @@
<parameter name="list"/>
<body>
<![CDATA[
+ // Clear existing selection
+ this.clearSelection();
+
// Remove all equations before insertion
for (var n = this.itemCount; n--; ) this.removeItemAt(n);
this._insertListAt(list, 0, false);
Modified: trunk/chrome/content/file.js
===================================================================
--- trunk/chrome/content/file.js 2014-09-01 01:03:05 UTC (rev 179)
+++ trunk/chrome/content/file.js 2014-09-01 02:35:42 UTC (rev 180)
@@ -99,12 +99,11 @@
{
var panel = document.getElementById("statusbar-eq-name");
if (!panel) return;
+ var label = "";
var eq = document.getElementById("equationlist");
- if (!eq) return;
- if (eq.selectedItems.length > 1)
- panel.label = "";
- else
- panel.label = eq.getName();
+ if (eq && (eq.selectedItems.length == 1))
+ label = eq.getName();
+ panel.label = label;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|