forked from pydanny/django-wysiwyg
/
includes.html
185 lines (171 loc) · 6.19 KB
/
includes.html
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
{% load i18n %}
{% comment %}
This is hosted using the Yahoo CDN. You can override this if you prefer to host locally.
To include other parts of YUI, visit the configurator here:
http://developer.yahoo.com/yui/articles/hosting/?editor&MIN
{% endcomment %}
{% comment %}
TODO: YUI values should be superseded by DJANGO_WYSWYG_MEDIA_URL - should we just hardcode the name combo.js / combo.css or do something more configurable?
{% endcomment %}
<!-- Combo-handled YUI CSS files: -->
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?2.8.2r1/build/assets/skins/sam/skin.css">
<!-- Combo-handled YUI JS files: -->
<script type="text/javascript" src="http://yui.yahooapis.com/combo?2.8.2r1/build/yahoo-dom-event/yahoo-dom-event.js&2.8.2r1/build/container/container_core-min.js&2.8.2r1/build/menu/menu-min.js&2.8.2r1/build/element/element-min.js&2.8.2r1/build/button/button-min.js&2.8.2r1/build/editor/editor-min.js"></script>
<script type="text/javascript" charset="utf-8">
"use strict";
// This is required for Yahoo's skins:
YAHOO.util.Event.onDOMReady(function() { YAHOO.util.Dom.addClass(document.body, 'yui-skin-sam'); });
/*
This config is used for our standard rich editor on the site and in the
Django admin area if you've modified the change_form.html to enable
rich editing.
See Yahoo's documentation for customization options:
http://developer.yahoo.com/yui/editor/
*/
var django_wysiwyg_editor_configs = []; // allow custom settings per editor ID
var django_wysiwyg_editor_config = {
height: "400px",
width: "624px",
animate: true,
autoHeight: true,
// BUG: handleSubmit breaks contrib.admin's save-and-continue-editing feature - we can avoid by listening for blur events
// This will cause the rich editor to update the original textarea's value when the containing form submit event fires
handleSubmit: true,
focusAtStart: false,
toolbar: {
//collapse: true,
//titlebar: 'Body',
draggable: false,
buttons: [
{
group: 'fontstyle',
label: '{% trans "Font Name and Size" %}',
buttons: [
{
type: 'select',
label: 'Arial',
value: 'fontname',
disabled: true,
menu: [
{ text: 'Arial', checked: true },
{ text: 'Arial Black' },
{ text: 'Comic Sans MS' },
{ text: 'Courier New' },
{ text: 'Georgia' },
{ text: 'Impact' },
{ text: 'Lucida Console' },
{ text: 'Tahoma' },
{ text: 'Times New Roman' },
{ text: 'Trebuchet MS' },
{ text: 'Verdana' }
]
},
{
type: 'spin',
label: '13',
value: 'fontsize',
range: [9, 75],
disabled: true
}
]
},
{
type: 'separator'
},
{
group: 'textstyle',
label: '{% trans "Font Style" %}',
buttons: [
{
type: 'push',
label: '{% trans "Bold CTRL + SHIFT + B" %}',
value: 'bold'
},
{
type: 'push',
label: '{% trans "Italic CTRL + SHIFT + I" %}',
value: 'italic'
},
{
type: 'push',
label: '{% trans "Underline CTRL + SHIFT + U" %}',
value: 'underline'
},
{
type: 'separator'
},
{
type: 'color',
label: '{% trans "Font Color" %}',
value: 'forecolor',
disabled: true
},
{
type: 'color',
label: '{% trans "Background Color" %}',
value: 'backcolor',
disabled: true
}
]
},
{
type: 'separator'
},
{
group: 'indentlist',
label: '{% trans "Lists" %}',
buttons: [
{
type: 'push',
label: '{% trans "Create an Unordered List" %}',
value: 'insertunorderedlist'
},
{
type: 'push',
label: '{% trans "Create an Ordered List" %}',
value: 'insertorderedlist'
}
]
},
{
type: 'separator'
},
{
group: 'insertitem',
label: '{% trans "Insert Item" %}',
buttons: [
{
type: 'push',
label: '{% trans "HTML Link CTRL + SHIFT + L" %}',
value: 'createlink',
disabled: true
},
{
type: 'push',
label: '{% trans "Insert Image" %}',
value: 'insertimage'
}
]
}
]
}
};
function django_wysiwyg_enable(editor_name, field_id, config)
{
if(!config) {
config = django_wysiwyg_editor_configs[field_id] || django_wysiwyg_editor_config;
}
window[editor_name] = new YAHOO.widget.Editor(field_id, config);
window[editor_name].render();
}
function django_wysiwyg_disable(editor_name)
{
var editor = window[editor_name];
if(editor)
{
editor.saveHTML();
editor.destroy();
window[editor_name] = null;
}
}
</script>