Skip to content

Commit

Permalink
Fix #9 and a little tidy-up
Browse files Browse the repository at this point in the history
  • Loading branch information
andykirk committed Sep 30, 2014
1 parent ed96f31 commit eac2949
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions footnotes/dialogs/footnotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,22 @@ CKEDITOR.dialog.add( 'footnotesDialog', function( editor ) {
CKEDITOR.on( 'instanceLoaded', function( evt ) {
dialog.editor_name = evt.editor.name;
} );



var current_editor_id = dialog.getParentEditor().id;

CKEDITOR.replaceAll( function( textarea, config ) {
// Make sure the textarea has the correct class:
if (!textarea.className.match(/footnote_text/)) {
return false;
}

// Make sure we only instantiate the relevant editor:
var el = textarea;
while ((el = el.parentElement) && !el.classList.contains(current_editor_id));
if (!el) {
return false;
}
console.log(el);
config.toolbarGroups = [
{ name: 'editing', groups: [ 'undo', 'find', 'selection', 'spellchecker' ] },
{ name: 'clipboard', groups: [ 'clipboard' ] },
Expand Down Expand Up @@ -125,14 +134,11 @@ CKEDITOR.dialog.add( 'footnotesDialog', function( editor ) {
// This method is invoked once a user clicks the OK button, confirming the dialog.
onOk: function() {
var dialog = this;

var footnote_editor = CKEDITOR.instances[dialog.editor_name];
var footnote_id = dialog.getValueOf('tab-basic', 'footnote_id');
var footnote_data = footnote_editor.getData();
footnote_editor.destroy();

//editor.fire('saveSnapshot');

if (footnote_id == '') {
// No existing id selected, check for new footnote:
if (footnote_data == '') {
Expand Down

0 comments on commit eac2949

Please sign in to comment.