// Chrome tends to insert pointless <span> elements in contenteditable areas
// see http://www.neotericdesign.com/blog/2013/3/working-around-chrome-s-contenteditable-span-bug
this.$editor.on('DOMNodeInserted.redactor', (function(e) {
- if (e.target.tagName === 'SPAN') {
+ if (e.target.tagName === 'SPAN' && e.target.attributes.length === 1 && e.target.attributes[0].name === 'style') {
var $helper = $('<b>helper</b>');
$(e.target).before($helper);
$.each($fonts, function(title, fontFamily) {
var $listItem = $('<li><a href="#">' + title + '</a></li>').appendTo(dropdown);
var $item = $listItem.children('a').data('fontFamily', fontFamily).css('font-family', fontFamily);
- $item.click(function() {
+ $item.click(function(event) {
event.preventDefault();
self.inline.format('span', 'style', 'font-family: ' + $(this).data('fontFamily') + ';');
$('<li class="dropdownDivider" />').appendTo(dropdown);
var $listItem = $('<li><a href="#">None</a></li>').appendTo(dropdown);
- $listItem.children('a').click(function() {
+ $listItem.children('a').click(function(event) {
event.preventDefault();
self.inline.removeStyleRule('font-family');
$item.css('line-height', '1em');
}
- $item.click(function() {
+ $item.click(function(event) {
event.preventDefault();
self.inline.format('span', 'style', 'font-size: ' + $(this).data('fontSize') + 'pt;');
$('<li class="dropdownDivider" />').appendTo(dropdown);
var $listItem = $('<li><a href="#">None</a></li>').appendTo(dropdown);
- $listItem.children('a').click(function() {
+ $listItem.children('a').click(function(event) {
event.preventDefault();
self.inline.removeStyleRule('font-size');
/**
* Displays the style chooser dialog.
+ *
+ * @param object event
*/
- _showDialog: function() {
- event.preventDefault();
+ _showDialog: function(event) {
+ if (event !== null) {
+ event.preventDefault();
+ }
if (this._dialog === null) {
this._dialog = $('<div id="styleChooser" />').hide().appendTo(document.body);
this._dialog.html(data.returnValues.template);
this._dialog.find('li').addClass('pointer').click($.proxy(this._click, this));
- this._showDialog();
+ this._showDialog(null);
},
/**