Skip to content

Commit

Permalink
Fix ol/ul bug under firefox.
Browse files Browse the repository at this point in the history
  • Loading branch information
kenshin54 committed Sep 5, 2014
1 parent b808db1 commit c0f62ea
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions scripts/plugins/jquery.popline.list.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,53 @@
*/
;(function($) {

var firefoxCleanupCheck = function(tag) {
var focusNode = $.popline.utils.selection().focusNode();
var node = $.popline.utils.findNodeWithTags(focusNode, tag);
return node ? true : false;
}

var firefoxCleanup = function(addPTag) {
$.popline.current.target.find("br[type=_moz]").parent().remove();
if (addPTag) {
document.execCommand("formatblock", false, "P");
var selection = $.popline.utils.selection().obj();
if (selection.anchorNode && (node = selection.anchorNode.parentNode.previousSibling) && node.tagName === "BR") {
node.remove();
}
if (selection.focusNode && (node = selection.focusNode.parentNode.nextSibling) && node.tagName === "BR") {
node.remove();
}
addPTag = null;
}
}

$.popline.addButton({
orderedList: {
iconClass: "fa fa-list-ol",
mode: "edit",
action: function(event) {
if ($.popline.utils.browser.firefox) {
var addPTag = firefoxCleanupCheck('OL');
}
document.execCommand("InsertOrderedList");
if ($.popline.utils.browser.firefox) {
firefoxCleanup(addPTag);
}
}
},

unOrderedList: {
iconClass: "fa fa-list-ul",
mode: "edit",
action: function(event) {
if ($.popline.utils.browser.firefox) {
var addPTag = firefoxCleanupCheck('UL');
}
document.execCommand("InsertUnorderedList");
if ($.popline.utils.browser.firefox) {
firefoxCleanup(addPTag);
}
}
}
});
Expand Down

0 comments on commit c0f62ea

Please sign in to comment.