Skip to content

Commit 9e9e18c

Browse files
committed
Enable tinyMCE for fixed html pages
1 parent c4ff70e commit 9e9e18c

File tree

3 files changed

+59
-11
lines changed

3 files changed

+59
-11
lines changed

webapp/src/main/webapp/js/edit/initTinyMce.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,23 @@
22

33
var initTinyMCE = {
44
// Initial page setup
5-
onLoad: function() {
5+
onLoad: function(textareas) {
66
this.mergeFromTemplate();
7-
this.initObjects();
8-
this.initEditor();
9-
7+
this.initEditor(textareas);
108
},
119

1210
// Add variables from menupage template
1311
mergeFromTemplate: function() {
1412
$.extend(this, customFormData);
1513
},
16-
initObjects: function() {
17-
this.wsywigFields = $(".useTinyMce");
18-
},
1914
// Create references to frequently used elements for convenience
20-
initEditor: function() {
21-
initTinyMCE.wsywigFields.tinymce(initTinyMCE.tinyMCEData);
15+
initEditor: function(textareas) {
16+
textareas.tinymce(initTinyMCE.tinyMCEData);
2217

2318
}
2419
};
2520

2621
$(document).ready(function() {
27-
initTinyMCE.onLoad();
22+
initTinyMCE.onLoad($(".useTinyMce"));
2823
});
2924

webapp/src/main/webapp/js/menupage/processFixedHTMLDataGetterContent.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var processFixedHTMLDataGetterContent = {
2828
//Now find and set value
2929
pageContentSection.find("input[name='saveToVar']").val(saveToVarValue);
3030
pageContentSection.find("textarea[name='htmlValue']").val(htmlValue);
31+
initTinyMCE.initEditor(pageContentSection.find("textarea[name='htmlValue']"));
3132
},
3233
//For the label of the content section for editing, need to add additional value
3334
retrieveContentLabel:function() {

webapp/src/main/webapp/templates/freemarker/edit/forms/pageManagement--customDataScript.ftl

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,26 @@
33
file to ensure this script is always loaded first. Can also make sure placed first in
44
scripts list.-->
55

6+
<#assign defaultHeight="200" />
7+
<#assign defaultWidth="75%" />
8+
<#assign defaultButton="bold,italic,underline,separator,link,bullist,numlist,separator,sub,sup,charmap,separator,undo,redo,separator,code"/>
9+
<#assign defaultToolbarLocation = "top" />
10+
<#if !height?has_content>
11+
<#assign height=defaultHeight/>
12+
</#if>
13+
14+
<#if !width?has_content>
15+
<#assign width=defaultWidth />
16+
</#if>
17+
18+
<#if !buttons?has_content>
19+
<#assign buttons = defaultButton />
20+
</#if>
21+
22+
<#if !toolbarLocation?has_content>
23+
<#assign toolbarLocation = defaultToolbarLocation />
24+
</#if>
25+
626
<script type="text/javascript">
727
var customFormData = {
828
menuAction:"${menuAction}",
@@ -14,6 +34,38 @@ scripts list.-->
1434
"sparqlQuery":"java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter",
1535
"fixedHtml":"java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.FixedHTMLDataGetter",
1636
"searchIndividuals":"java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SearchIndividualsDataGetter"
17-
}
37+
},
38+
tinyMCEData : {
39+
theme : "advanced",
40+
mode : "textareas",
41+
theme_advanced_buttons1 : "${buttons}",
42+
theme_advanced_buttons2 : "",
43+
theme_advanced_buttons3 : "",
44+
theme_advanced_toolbar_location : "${toolbarLocation}",
45+
theme_advanced_toolbar_align : "left",
46+
theme_advanced_statusbar_location : "bottom",
47+
theme_advanced_path : false,
48+
theme_advanced_resizing : true,
49+
height : "${height}",
50+
width : "${width}",
51+
valid_elements : "tr[*],td[*],tbody[*],table[*],a[href|name|title|style],br,p[style],i,em,cite,strong/b,u,sub,sup,ul,ol,li,h1[dir|style|id],h2[dir|style|id],h3[dir|style|id],h4,h5,h6,div[style|class],span[dir|style|class]",
52+
fix_list_elements : true,
53+
fix_nesting : true,
54+
cleanup_on_startup : true,
55+
gecko_spellcheck : true,
56+
forced_root_block: false,
57+
plugins : "paste",
58+
paste_use_dialog : false,
59+
paste_auto_cleanup_on_paste : true,
60+
paste_convert_headers_to_strong : true,
61+
paste_strip_class_attributes : "mso",
62+
paste_remove_spans : true,
63+
paste_remove_styles : true,
64+
paste_retain_style_properties : ""
65+
}
1866
};
1967
</script>
68+
69+
${scripts.add('<script type="text/javascript" src="${urls.base}/js/tiny_mce/tiny_mce.js"></script>',
70+
'<script type="text/javascript" src="${urls.base}/js/tiny_mce/jquery.tinymce.js"></script>',
71+
'<script type="text/javascript" src="${urls.base}/js/edit/initTinyMce.js"></script>')}

0 commit comments

Comments
 (0)