-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Image deletion in HTML compose mode no longer requires polling
- Loading branch information
Showing
6 changed files
with
79 additions
and
71 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* CKEditor 3 doesn't support onchange event for content body. | ||
* Instead, need to track attached images to detect deletions, since this may | ||
* influence attachment limits. | ||
* | ||
* @author Michael Slusarz <slusarz@horde.org> | ||
* @copyright 2014 Horde LLC | ||
* @license GPL-2 (http://www.horde.org/licenses/gpl) | ||
*/ | ||
|
||
var ImpCkeditorImgs = {}; | ||
// 'related_attr' property set in IMP_Script_Package_ComposeBase | ||
|
||
(function (ob) { | ||
var active = []; | ||
|
||
function checkRemove(ev) | ||
{ | ||
var del = [], | ||
n = ev.editor.name; | ||
|
||
active[n].each(function(a) { | ||
if (!a.parentNode) { | ||
del.push(a); | ||
} | ||
}); | ||
|
||
ob.remove(ev.editor, del); | ||
}; | ||
|
||
ob.add = function(editor, elt) | ||
{ | ||
var n = editor.name; | ||
|
||
if (!active[n]) { | ||
active[n] = []; | ||
editor.on('afterUndoImage', checkRemove); | ||
} | ||
|
||
active[n].push(elt); | ||
}; | ||
|
||
ob.remove = function(editor, elts) | ||
{ | ||
var ids = [], | ||
n = editor.name; | ||
|
||
if (!elts.size()) { | ||
return; | ||
} | ||
|
||
elts.invoke('getAttribute', ob.related_attr).compact().each(function(r) { | ||
var s = r.split(';', 2); | ||
ids.push(s[1]); | ||
}); | ||
|
||
ImpCompose.attachlist.removeAttach(ids, true); | ||
|
||
// Array.without() doesn't support array input. | ||
active[n] = active[n].findAll(function(v) { | ||
return !elts.include(v); | ||
}); | ||
|
||
if (!active[n].size()) { | ||
delete active[n]; | ||
editor.removeListener('afterUndoImage', checkRemove); | ||
} | ||
}; | ||
|
||
}(ImpCkeditorImgs)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters