forked from alohaeditor/Aloha-Editor
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathindex.html
More file actions
384 lines (352 loc) · 23.5 KB
/
index.html
File metadata and controls
384 lines (352 loc) · 23.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Oerpub Editor</title>
<metal:css_macro define-macro="css">
<link rel="stylesheet" type="text/css" href="/Aloha-Editor/src/css/aloha.css"
tal:attributes="href string:${request.application_url}/aloha/src/css/aloha.css"> <!-- xhtml workaround --></link>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css"
tal:attributes="href string:${request.application_url}/bootstrap/docs/assets/css/bootstrap.css" type="text/css"> <!-- xhtml workaround --></link>
<link rel="stylesheet" href=""
tal:attributes="href string:${request.application_url}/bootstrap/docs/assets/css/bootstrap-responsive.css" type="text/css"> <!-- xhtml workaround --></link>
<link rel="stylesheet" type="text/css" href="/Aloha-Editor/oerpub/css/bootstrap.css"
tal:attributes="href string:${request.application_url}/aloha/oerpub/css/bootstrap.css"> <!-- xhtml workaround --></link>
<link rel="stylesheet" type="text/css" href="/Aloha-Editor/oerpub/css/aloha.css"
tal:attributes="href string:${request.application_url}/aloha/oerpub/css/aloha.css"> <!-- xhtml workaround --></link>
<link rel="stylesheet" type="text/css" href="/Aloha-Editor/oerpub/css/html5_metacontent.css"
tal:attributes="href string:${request.application_url}/aloha/oerpub/css/html5_metacontent.css"> <!-- xhtml workaround --></link>
<link rel="stylesheet" type="text/css" href="/Aloha-Editor/oerpub/css/html5_content_in_oerpub.css"
tal:attributes="href string:${request.application_url}/aloha/oerpub/css/html5_content_in_oerpub.css"> <!-- xhtml workaround --></link>
<link rel="stylesheet" type="text/css" href="/Aloha-Editor/oerpub/css/style.css"
tal:attributes="href string:${request.application_url}/aloha/oerpub/css/style.css"> <!-- xhtml --></link>
<link rel="stylesheet" type="text/css" href="/Aloha-Editor/oerpub/css/toolbar.css"
tal:attributes="href string:${request.application_url}/aloha/oerpub/css/toolbar.css"> <!-- xhtml --></link>
</metal:css_macro>
<metal:js_macro define-macro="javascript">
<base href="/Aloha-Editor/oerpub/sandbox/"
tal:attributes="href body_base"/>
<script src="/Aloha-Editor/oerpub/js/jquery-1.7.1.min.js"
tal:replace="nothing"> <!-- xhtml --></script>
<script src="/Aloha-Editor/oerpub/js/jquery.center.js"
tal:replace="nothing"> <!-- xhtml --></script>
<!-- Aloha editor -->
<script type="text/javascript" src="/Aloha-Editor/src/lib/require.js"
tal:attributes="src string:${request.application_url}/aloha/src/lib/require.js"> <!-- xhtml workaround --></script>
<!-- Mathjax -->
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/2.0-latest/MathJax.js?config=TeX-MML-AM_HTMLorMML-full&delayStartupUntil=configured"
tal:attributes="src string:${request.application_url}/mathjax/MathJax.js?config=TeX-MML-AM_HTMLorMML-full&delayStartupUntil=configured"> <!-- xhtml --></script>
<script type="text/x-mathjax-config">MathJax.Hub.Config({
jax: ["input/MathML", "input/TeX", "input/AsciiMath", "output/NativeMML", "output/HTML-CSS"],
extensions: ["asciimath2jax.js","tex2jax.js","mml2jax.js","MathMenu.js","MathZoom.js","MathEvents.js","toMathML.js"],
tex2jax: { inlineMath: [["[TEX_START]","[TEX_END]"], ["\\(", "\\)"]] },
// Apparently we can't change the escape sequence for ASCIIMath (MathJax doesn't find it)
// asciimath2jax: { inlineMath: [["[ASCIIMATH_START]", "[ASCIIMATH_END]"]], },
TeX: {
extensions: ["AMSmath.js","AMSsymbols.js","noErrors.js","noUndefined.js"], noErrors: { disabled: true }
},
AsciiMath: { noErrors: { disabled: true } }
});</script>
<script type="text/javascript" src="/Aloha-Editor/oerpub/js/aloha-settings.js"
tal:attributes="src string:${request.static_url('oerpub.rhaptoslabs.swordpushweb:static/aloha-settings.js')}"> <!-- xhtml workaround --></script>
<script type="text/javascript" src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js"
tal:attributes="src string:${request.application_url}/bootstrap/docs/assets/js/bootstrap.js"> <!-- xhtml workaround --></script>
<script type="text/javascript" src="/Aloha-Editor/src/lib/aloha.js"
tal:attributes="src string:${request.application_url}/aloha/src/lib/aloha.js"
data-aloha-plugins="common/ui,
oer/toolbar,
oer/popover,
oer/format,
common/contenthandler,
common/paste,
common/block,
common/list,
oer/table,
oer/math,
extra/draganddropfiles,
common/image,
oer/assorted,
oer/title,
common/undo,
oer/undobutton,
oer/genericbutton"> <!-- xhtml workaround --></script>
<script type="text/javascript"
tal:content="string:var body_url = '${body_url}';">
var body_url = '/Aloha-Editor/oerpub/sandbox/index.html';</script>
<script type="text/javascript"
tal:content="string:var save_url = '${request.route_url('preview_save')}';">
var save_url = null;</script>
<!--Google Picker Includes -->
<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="/Aloha-Editor/src/plugins/oer/assorted/lib/image-dialog.js" tal:attributes="src string:${request.application_url}/aloha/src/plugins/oer/assorted/lib/image-dialog.js"></script>
<script type="text/javascript" src="/Aloha-Editor/src/plugins/oer/assorted/lib/aloha-helper.js" tal:attributes="src string:${request.application_url}/aloha/src/plugins/oer/assorted/lib/aloha-helper.js"></script>
<!--<script type="text/javascript" src="/Aloha-Editor/src/plugins/oer/assorted/lib/gpickerdialog.js"></script>-->
<script type="text/javascript">
// HTML elements which are the options in the heading drop down
var headingChoices = null;
// Element tags which are generated as headings
var possibleHeadings = new Array();
// Search through parent links in the DOM until we find an element whose enclosing tag
// is one of the section heading tags
function getClosestHeadingParent(ele) {
while(ele != null) {
if(ele.tagName && possibleHeadings.indexOf(ele.tagName.toUpperCase()) != -1) {
break;
}
if(ele.classList && ele.classList[0] === 'title-editor') {
break;
}
ele = ele.parentNode;
}
return ele;
}
// Find the English heading name for a certain tag name (for instance, pre -> Code)
function getCorrectNewHeadingName(ele) {
newName = 'Normal Text'; // Default heading display
for(var i = 0; i < headingChoices.length; i++) {
var checking = Aloha.jQuery(headingChoices[i]).attr('data-tagname').toUpperCase()
if(ele.tagName == checking) {
newName = headingChoices[i].innerHTML;
break;
}
}
return newName;
}
function headingFuncHelper(ele) {
var button = Aloha.jQuery('#headingbutton')[0];
if(!ele) {
button.disabled = true;
Aloha.jQuery('.currentHeading')[0].innerHTML = 'Unknown';
} else if(ele.classList[0] === 'title-editor') {
button.disabled=true;
Aloha.jQuery('.currentHeading')[0].innerHTML = 'Title';
} else {
button.disabled=false;
var newName = getCorrectNewHeadingName(ele);
Aloha.jQuery('.currentHeading')[0].innerHTML = newName;
}
}
// Binds Update function to all headings. Update function updates the current heading being displayed
function headingFunc(event, data) {
var ele = this;
headingFuncHelper(ele);
}
function recursiveHeadingFunc(event, data) {
var selection = Aloha.getSelection();
var ele = getClosestHeadingParent(selection._nativeSelection.anchorNode);
headingFuncHelper(ele);
}
Aloha.ready(function(){
headingChoices = Aloha.jQuery('.changeHeading');
for(var i = 0; i < headingChoices.length; i++) {
possibleHeadings[possibleHeadings.length] = Aloha.jQuery(headingChoices[i]).attr('data-tagname').toUpperCase();
}
Aloha.require(['PubSub', 'genericbutton/genericbutton-plugin'],
function(PubSub, GenericButton){
// Save button is disabled until something is changed
GenericButton.getButtons()["save"].enable(false);
$('.btn.save').html('Saved');
function savePreview(callback_function){
var editor = Aloha.getEditableById('canvas');
if(editor.isModified()){
// setUnmodified, to avoid another concurrent save from
// firing while this one is still ongoing.
editor.setUnmodified();
var $html = $('<html />');
$html.attr('xmlns', 'http://www.w3.org/1999/xhtml');
$html.attr('xmlns:c', 'http://cnx.rice.edu/cnxml');
$html.attr('xmlns:md', 'http://cnx.rice.edu/mdml/0.4');
$html.attr('xmlns:qml', 'http://cnx.rice.edu/qml/1.0');
$html.attr('xmlns:mod', 'http://cnx.rice.edu/#moduleIds' );
$html.attr('xmlns:bib', 'http://bibtexml.sf.net/');
$html.attr('xmlns:data', 'http://dev.w3.org/html5/spec/#custom');
// Build simple header with title.
var $head = $('<head />'),
title = editor.obj.find('>div.title').text();
$('<title/>').text(title).appendTo($head);
$html.append($head);
var $body = $('<body />');
$body.attr('class', 'content');
$body.append(editor.getContents());
// This is going to break in IE. Which is fine, because
// we don't support that right now. Hint to poor person
// who has to develop that: ActiveXObject
// Microsoft.XMLDOM
var html = (new XMLSerializer()).serializeToString(
$html.append($body).get(0));
if(save_url !== null){
$.post(save_url,
{html: html}, function(data, statustext){
if(data.error){
$('#statusmessage').data('message')(data.error, 'error', 0);
} else {
$('#statusmessage').data('message')('Saved');
GenericButton.getButtons()["save"].enable(false);
$('.btn.save').html('Saved');
if (callback_function) {
callback_function();
}
}
PubSub.pub('swordpushweb.saved');
});
}
}
}
// Attach save handler to Save button
PubSub.sub('swordpushweb.save', function(data){
savePreview();
if(data && data.callback){
data.callback();
}
});
// Set up status message area
var statusarea = $('#statusmessage');
statusarea.data('message', function(message, type, delay) {
type = type || 'info';
if(delay === undefined){
delay = 1500;
}
var ob = $("<div />",
{'class': type, text: message}).hide()
.appendTo(statusarea).center().fadeIn(700);
if(delay>0){
ob.delay(delay).fadeOut(800, function() { $(this).remove(); });
} else {
ob.addClass('persistent-error');
var close = $('<i> </i>');
ob.append(close);
close.on('click', function(e){
$(e.target).off('click');
ob.remove();
});
}
});
// Fetch the preview
$('#statusmessage').data('message')('Loading preview...');
Aloha.jQuery.get(body_url, function(data){
var $d = Aloha.jQuery('<div />').html(data);
var $editable = Aloha.jQuery('#canvas').html(
$d.find('> *'));
// Remove the pyramid debug toolbar from the preview
// if it exists. This code should do nothing in production
$editable.find('#pDebug').remove();
$editable.aloha().focus();
MathJax.Hub.Configured();
// Auto-save periodically. This only does anything if
// editor.isModified().
window.setInterval(savePreview, 30000);
// Bind a handler for the changed event
var editor = Aloha.getEditableById('canvas');
Aloha.bind('aloha-smart-content-changed', function(){
if(editor.isModified()){
$('.btn.save').html('Save');
GenericButton.getButtons()["save"].enable(true);
}
});
// Binds the function to all headers, paragraphs, and pre tags
Aloha.jQuery(":header, p, pre").bind('click', headingFunc);
Aloha.jQuery('#canvas').bind('keyup', recursiveHeadingFunc);
Aloha.jQuery('#canvas').bind('click', recursiveHeadingFunc);
Aloha.jQuery(".title-editor").bind('click', headingFunc);
Aloha.jQuery('#statusmessage').data('message')('Preview loaded');
});
});
var button = Aloha.jQuery('#headingbutton')[0];
button.disabled=true;
Aloha.jQuery('.currentHeading')[0].innerHTML = 'Title';
});
</script>
</metal:js_macro>
</head>
<body>
<div id="ie6-container-wrap">
<div id="container">
<!-- ================= -->
<!-- Toolbar Buttons -->
<!-- ================= -->
<metal:toolbar define-macro="toolbar">
<div class="toolbar aloha-dialog">
<div class="btn-toolbar">
<div class="btn-group">
<button class="btn action save" rel="tooltip" title="Save">Save</button>
</div>
<span class="separator"> </span>
<div class="btn-group">
<button class="btn action undo" rel="tooltip" title="Undo"><i class="icon-undo"></i></button>
<button class="btn action redo" rel="tooltip" title="Redo"><i class="icon-redo"></i></button>
</div>
<span class="separator"> </span>
<div class="btn-group headings">
<button class="btn heading dropdown-toggle" data-toggle="dropdown" rel="tooltip" title="Text Heading" id="headingbutton">
<span class="currentHeading">Nothing</span>
<span class="caret"></span></button>
<ul class="dropdown-menu">
<!-- "changeHeading" is important so a click can be attached and
data-tagname is used both to identify if the cursor is in one of these and
is used to change one heading to another
-->
<li><a href="#" class="action changeHeading" data-tagname="p">Normal Text</a></li>
<li><a href="#" class="action changeHeading" data-tagname="h1">Heading</a></li>
<li><a href="#" class="action changeHeading" data-tagname="h2">Subheading</a></li>
<li><a href="#" class="action changeHeading" data-tagname="h3">SubSubHeading</a></li>
<li><a href="#" class="action changeHeading" data-tagname="pre">Code</a></li>
</ul>
</div>
<span class="separator"> </span>
<div class="btn-group">
<button class="btn action strong" rel="tooltip" title="Bold"><i class="icon-bold"></i></button>
<button class="btn action emphasis" rel="tooltip" title="Italics"><i class="icon-italic"></i></button>
<button class="btn action underline" rel="tooltip" title="Underline"><i class="icon-underline"></i></button>
<button class="btn action superscript" rel="tooltip" title="Superscript"><i class="icon-superscript"></i></button>
<button class="btn action subscript" rel="tooltip" title="Subscript"><i class="icon-subscript"></i></button>
</div>
<span class="separator"> </span>
<div class="btn-group">
<button class="btn action insertLink" rel="tooltip" title="Insert Link"><i class="icon-link-insert"></i></button>
<!-- <button class="btn action changeHeading" data-tagname="pre" rel="tooltip" title="Code">Code</button> -->
</div>
<span class="separator"> </span>
<div class="btn-group">
<button class="btn action unorderedList" rel="tooltip" title="Insert Unordered List"><i class="icon-unordered-list"></i></button>
<button class="btn action orderedList" rel="tooltip" title="Insert Ordered List"><i class="icon-ordered-list"></i></button>
<button class="btn action indentList" rel="tooltip" title="Indent list item (move right)"><i class="icon-indent-list"></i></button>
<button class="btn action outdentList" rel="tooltip" title="Unindent list item (move left)"><i class="icon-outdent-list"></i></button>
</div>
<span class="separator"> </span>
<div class="btn-group">
<button class="btn action insertImage-oer" rel="tooltip" title="Insert Image"><i class="icon-image-insert"></i></button>
<button class="btn action insertVideo-oer" rel="tooltip" title="Insert Video"><i class="icon-video-insert"></i></button>
<button class="btn action createTable" rel="tooltip" title="Create Table"><i class="icon-table-insert"></i></button>
<button class="btn dropdown-toggle" data-toggle="dropdown" rel="tooltip" title="Table Operations">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="#" class="action addrowbefore">Add Row Before</a></li>
<li><a href="#" class="action addrowafter">Add Row After</a></li>
<li><a href="#" class="action addcolumnbefore">Add Column Before</a></li>
<li><a href="#" class="action addcolumnafter">Add Column After</a></li>
<li><a href="#" class="action addheaderrow">Add Header Row</a></li>
<li><a href="#" class="action deleterow">Delete Row</a></li>
<li><a href="#" class="action deletecolumn">Delete Column</a></li>
<li><a href="#" class="action deletetable">Delete Table</a></li>
</ul>
<button class="btn action insertMath" rel="tooltip" title="Insert Math"><i class="icon-math-insert"></i></button>
</div>
</div>
</div><!-- / ".toolbar" -->
</metal:toolbar>
<div id="content">
<div id="artboard">
<metal:editor define-macro="editor">
<div id="statusmessage"></div>
<div id="editor">
<div id="canvas">
</div>
</div>
</metal:editor>
</div>
</div>
</div>
</div>
</body>
</html>