Fix sidebar item editor icon recycling.

Fixes #410.
This commit is contained in:
Oliver Hamlet
2015-02-13 20:31:55 +00:00
parent f286cb974d
commit d952d750bc
2 changed files with 11 additions and 11 deletions
+11 -1
View File
@@ -141,13 +141,15 @@
observe: {
'data.userlist': 'onUserlistChange',
'data.modPriority': 'onPriorityChange',
'data.isGlobalPriority': 'onPriorityIsGlobalChange'
'data.isGlobalPriority': 'onPriorityIsGlobalChange',
'data.isEditorOpen': 'onEditorStateChange',
},
dataChanged: function(oldValue, newValue) {
this.onUserlistChange();
this.onPriorityChange();
this.onPriorityIsGlobalChange();
this.onEditorStateChange();
},
onUserlistChange: function(oldValue, newValue) {
@@ -178,6 +180,14 @@
}
},
onEditorStateChange: function(oldValue, newValue) {
if (this.data && this.data.isEditorOpen) {
this.setAttribute('data-editor-open', true);
} else {
this.removeAttribute('data-editor-open');
}
},
getName: function() {
return this.textContent.trim();
},
-10
View File
@@ -374,11 +374,6 @@ function onEditorOpen(evt) {
for (var i = 0; i < elements.length; ++i) {
elements[i].draggable = true;
elements[i].addEventListener('dragstart', elements[i].onDragStart, false);
/* Also add data-editor-is-open attribute to the plugin's item. */
if (elements[i].getAttribute('data-id') == evt.target.id) {
elements[i].setAttribute('data-editor-open', true);
}
}
/* Now show editor. */
@@ -450,11 +445,6 @@ function onEditorClose(evt) {
for (var i = 0; i < elements.length; ++i) {
elements[i].removeAttribute('draggable');
elements[i].removeEventListener('dragstart', elements[i].onDragStart, false);
/* Also remove data-editor-is-open attribute from the plugin's item. */
if (elements[i].getAttribute('data-id') == evt.target.id) {
elements[i].removeAttribute('data-editor-open');
}
}
/* Disable priority hover in plugins list and enable header