Skip to content

Commit 1d65718

Browse files
authored
Merge pull request #7 from DigitalCarleton/alvin-updates
Alvin updates to fix issue #1 on simple pages and clean up code and documentation
2 parents 5dcb846 + af43c8b commit 1d65718

File tree

3 files changed

+93
-85
lines changed

3 files changed

+93
-85
lines changed

OmekaFootnotesJSPlugin.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function hookAdminHead()
1717
$Record = "";
1818
$view = get_view();
1919

20-
if(isset($view->exhibit_page) || isset($view->simple_page)) {
20+
if(isset($view->exhibit_page) || isset($view->simple_pages_page)) {
2121
$Record = 'Y';
2222
}
2323

@@ -26,15 +26,14 @@ public function hookAdminHead()
2626
queue_js_file('OmekaFootnotes');
2727
}
2828
}
29-
3029

3130
public function hookPublicHead() {
3231

3332
queue_css_file('bigfoot-default');
3433
queue_css_file('bigfoot-number');
3534

3635
queue_js_file('bigfoot');
37-
queue_js_string('var bigfoot = jQuery.bigfoot({activateOnHover:true,deleteOnUnhover:true,});');
36+
queue_js_string('var bigfoot = jQuery.bigfoot({activateOnHover:false,deleteOnUnhover:false,});');
3837

3938
}
4039

plugin.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[info]
22
name = "Omeka Footnotes JS"
3-
author = "Austin Mason, Alec Wang, Shiyue Zhang, Chris Padilla"
4-
version = "1.0"
3+
author = "Austin Mason, Alec Wang, Shiyue Zhang, Chris Padilla, Alvin Bierley"
4+
version = "1.1"
55
omeka_minimum_version="2.6"
66
description = "A plugin to add bigfoot.js footnote functionality to the WYSIWYG on simple or exhibit pages."
77
required_plugins = "ExhibitBuilder,SimplePages"

views/admin/javascripts/OmekaFootnotes.js

Lines changed: 89 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,102 @@
11
jQuery(document).ready(function() {
2-
Omeka.wysiwyg(params);
3-
updateFootnotes();
2+
displayFootnotes();
43
});
54

65
jQuery(window).load(function() {
7-
Omeka.wysiwyg(params);
8-
updateFootnotes();
6+
displayFootnotes();
97
});
108

11-
params = {
12-
toolbar: [
13-
"bold italic underline | alignleft aligncenter alignright | bullist numlist | link formatselect | code ",
14-
"addFootnoteButton | deleteFootnotesButton | updateFootnotesButton | addTranscriptionLinkButton"
15-
],
16-
setup: function (editor) {
17-
editor.addButton('addFootnoteButton', {
18-
text: 'Add Footnote',
19-
onclick: function () {
20-
// Add the new footnote link
21-
var tinymceBody = getTinyMCEDOMObject();
22-
addFootnoteLinkClassToFootnoteLinks(tinymceBody);
23-
updateFootnotes();
24-
var fnNextNum = getFnNextNum(tinymceBody);
25-
addNewFootnoteLink(editor, fnNextNum);
26-
var tinymceBody = getTinyMCEDOMObject();
27-
// Add the new footnote citation
28-
if(getNumberOfFootnoteDivs(tinymceBody) == 0){
29-
addFootnoteDiv(tinymceBody);
30-
}
31-
addFootnoteCitation(tinymceBody, fnNextNum);
32-
// Move cursor to bottom of the editor
33-
tinyMCE.activeEditor.selection.select(tinyMCE.activeEditor.getBody(), true);
34-
tinyMCE.activeEditor.selection.collapse(false);
35-
updateFootnotes();
36-
}
37-
});
38-
editor.addButton('updateFootnotesButton', {
39-
text: 'Update Footnotes',
40-
onclick: function () {
41-
var currentTinymceBody = getTinyMCEDOMObject();
42-
if(!(currentTinymceBody.getAttribute("data-id").toString().includes("block"))){
43-
alert("Click inside the box you are editing before using buttons.");
44-
} else{
9+
function displayFootnotes() {
10+
var selector;
11+
if (jQuery('#simple-pages-use-tiny-mce').is(':checked')) {
12+
selector = '#simple-pages-text';
13+
} else if (jQuery('#simple-pages-use-tiny-mce').is(":not(:checked)")) {
14+
selector = false;
15+
} else {
16+
selector = 'textarea';
17+
}
18+
params = {
19+
selector: selector,
20+
menubar: 'edit view insert format table',
21+
toolbar: [
22+
"bold italic underline | alignleft aligncenter alignright | bullist numlist | link formatselect | code ",
23+
"addFootnoteButton | deleteFootnotesButton | updateFootnotesButton"
24+
],
25+
setup: function (editor) {
26+
editor.addButton('addFootnoteButton', {
27+
text: 'Add Footnote',
28+
onclick: function () {
29+
// Add the new footnote link
30+
var tinymceBody = getTinyMCEDOMObject();
31+
addFootnoteLinkClassToFootnoteLinks(tinymceBody);
32+
updateFootnotes();
33+
var fnNextNum = getFnNextNum(tinymceBody);
34+
addNewFootnoteLink(editor, fnNextNum);
35+
var tinymceBody = getTinyMCEDOMObject();
36+
// Add the new footnote citation
37+
if(getNumberOfFootnoteDivs(tinymceBody) == 0){
38+
addFootnoteDiv(tinymceBody);
39+
}
40+
addFootnoteCitation(tinymceBody, fnNextNum);
41+
// Move cursor to bottom of the editor
42+
tinyMCE.activeEditor.selection.select(tinyMCE.activeEditor.getBody(), true);
43+
tinyMCE.activeEditor.selection.collapse(false);
4544
updateFootnotes();
4645
}
47-
}
48-
});
49-
editor.addButton('deleteFootnotesButton', {
50-
text: 'Delete Selected Footnotes',
46+
});
47+
editor.addButton('updateFootnotesButton', {
48+
text: 'Update Footnotes',
5149
onclick: function () {
5250
updateFootnotes();
53-
var tinymceBody = getTinyMCEDOMObject();
54-
node = editor.selection.getNode();
55-
parent = node.parentNode;
56-
var selectedHTML = editor.selection.getContent({format : 'html'}).toString();
57-
if(selectedHTML.length <= 1){
58-
//if the highlighted text is the single number of the footnote, the outerHTML will let us access the whole node.
59-
//Note: we can't just use the single number of innerHTML because then any time someone highlights a regular text number,
60-
// the footnote with that number will be deleted
61-
selectedHTML = editor.selection.getNode().outerHTML.toString();
62-
}
63-
var idsFootnotesToDelete = getListOfFootnotesToDelete(selectedHTML);
64-
var fnLinks = getFnLinks(tinymceBody);
65-
var fnCitations = getFnCitations(tinymceBody);
66-
for(j = 0; j < idsFootnotesToDelete.length; j++){
67-
var fnLinkIDs = getFnLinkIDs(fnLinks);
68-
var indexDel = fnLinkIDs.indexOf(idsFootnotesToDelete[j]);
69-
fnLinkToDelete = fnLinks.item(indexDel);
70-
fnLinkParent = fnLinkToDelete.parentNode;
71-
fnLinkParent.removeChild(fnLinkToDelete);
72-
if(fnCitations.length == 1){
73-
tinymceBody.removeChild(getExistingFootnoteDiv(tinymceBody));
74-
} else {
75-
fnCitToDelete = fnCitations.item(indexDel);
76-
fnCitParent = fnCitToDelete.parentNode;
77-
fnCitParent.removeChild(fnCitToDelete);
51+
}
52+
});
53+
editor.addButton('deleteFootnotesButton', {
54+
text: 'Delete Selected Footnotes',
55+
onclick: function () {
56+
updateFootnotes();
57+
var tinymceBody = getTinyMCEDOMObject();
58+
node = editor.selection.getNode();
59+
parent = node.parentNode;
60+
var selectedHTML = editor.selection.getContent({format : 'html'}).toString();
61+
if(selectedHTML.length <= 1){
62+
//if the highlighted text is the single number of the footnote, the outerHTML will let us access the whole node.
63+
//Note: we can't just use the single number of innerHTML because then any time someone highlights a regular text number,
64+
// the footnote with that number will be deleted
65+
selectedHTML = editor.selection.getNode().outerHTML.toString();
7866
}
79-
}
80-
updateFootnotes();
81-
}
82-
});
83-
editor.addButton('addTranscriptionLinkButton', {
84-
text: 'Add Transcription Link',
85-
onclick: function () {
86-
var tinymceBody = getTinyMCEDOMObject();
87-
editor.insertContent("<p><a class='show-transcription' href='#'>Show Transcription</a></p>");
88-
}
89-
});
90-
},
67+
var idsFootnotesToDelete = getListOfFootnotesToDelete(selectedHTML);
68+
var fnLinks = getFnLinks(tinymceBody);
69+
var fnCitations = getFnCitations(tinymceBody);
70+
for(j = 0; j < idsFootnotesToDelete.length; j++){
71+
var fnLinkIDs = getFnLinkIDs(fnLinks);
72+
var indexDel = fnLinkIDs.indexOf(idsFootnotesToDelete[j]);
73+
fnLinkToDelete = fnLinks.item(indexDel);
74+
fnLinkParent = fnLinkToDelete.parentNode;
75+
fnLinkParent.removeChild(fnLinkToDelete);
76+
if(fnCitations.length == 1){
77+
tinymceBody.removeChild(getExistingFootnoteDiv(tinymceBody));
78+
} else {
79+
fnCitToDelete = fnCitations.item(indexDel);
80+
fnCitParent = fnCitToDelete.parentNode;
81+
fnCitParent.removeChild(fnCitToDelete);
82+
}
83+
}
84+
updateFootnotes();
85+
}
86+
});
87+
},
88+
}
89+
if (typeof tinyMCE != "undefined") {
90+
tinyMCE.remove();
91+
}
92+
Omeka.wysiwyg(params);
93+
updateFootnotes();
94+
95+
// adds footnote functionality to new exhibit builder text blocks
96+
jQuery(document).on('exhibit-builder-refresh-wysiwyg', function () {
97+
Omeka.wysiwyg(params);
98+
updateFootnotes();
99+
});
91100
}
92101

93102
function getListOfFootnotesToDelete(selectedHTML){
@@ -243,7 +252,7 @@ function getLinkHTML(fnNextNum){
243252
var str4 = fnNextNum.toString();
244253
var str5 = '">';
245254
var str6 = fnNextNum.toString();
246-
var str7 = '</a></sup>';
255+
var str7 = '</a></sup> ';
247256
var linkHTML = str1.concat(str2).concat(str3).concat(str4).concat(str5).concat(str6).concat(str7);
248257
return linkHTML;
249258
}

0 commit comments

Comments
 (0)