wysiwyg.html
5.39 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Wysiwyg Example</title>
<link rel="stylesheet" href="../assets/css/bootstrap.css" />
<link rel="stylesheet" href="../assets/css/font-awesome.css" />
<!-- fonts -->
<link rel="stylesheet" href="../assets/css/ace-fonts.css" />
<link rel="stylesheet" href="../assets/css/ace.css" />
<!--[if lte IE 9]>
<link rel="stylesheet" href="../assets/css/ace-ie.css" />
<![endif]-->
</head>
<body>
<div class="main-container">
<div class="page-content">
<div class="row">
<div class="col-xs-12 col-sm-8 col-sm-offset-2">
<h3 class="header blue lighter">
Customizing wysiwyg buttons and submitting the form
</h3>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-8 col-sm-offset-2">
<!-- the wysiwyg form -->
<form method="POST" id="myform" action="wysiwyg.php">
<div id="editor" class="wysiwyg-editor"></div>
<input type="hidden" name="wysiwyg-value" />
<div class="form-actions align-right clearfix">
<button type="reset" class="pull-left btn">
<i class="ace-icon fa fa-retweet bigger-110"></i>
Reset
</button>
<button type="submit" class="btn btn-primary pull-right">
<i class="ace-icon fa fa-check bigger-110"></i>
Submit
</button>
</div>
</form>
</div>
</div>
<div id="modal-wysiwyg-editor" class="modal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="blue bigger">Wysiwyg editor's HTML content</h4>
</div>
<div class="modal-body">
<div class="row-fluid">
Content can be put inside a hidden input and sent to server
</div>
<div class="space-6"></div>
<div class="row-fluid">
<textarea spellcheck="false" id="wysiwyg-editor-value"></textarea>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-sm" data-dismiss="modal"><i class="ace-icon fa fa-times"></i> Cancel</button>
<button class="btn btn-sm btn-primary"><i class="ace-icon fa fa-check"></i> OK</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- basic scripts -->
<!--[if !IE]> -->
<script type="text/javascript">
window.jQuery || document.write("<script src='../assets/js/jquery.js'>"+"<"+"/script>");
</script>
<!-- <![endif]-->
<!--[if IE]>
<script type="text/javascript">
window.jQuery || document.write("<script src='../assets/js/jquery1x.js'>"+"<"+"/script>");
</script>
<![endif]-->
<script src="../assets/js/bootstrap.js"></script>
<script src="../assets/js/bootstrap-wysiwyg.js"></script>
<!-- ace scripts -->
<script src="../assets/js/ace-elements.js"></script>
<script src="../assets/js/ace.js"></script>
<script type="text/javascript">
jQuery(function($) {
$('#editor').ace_wysiwyg({
toolbar:
[
{
name:'font',
title:'Custom tooltip',
values:['Some Font!','Arial','Verdana','Comic Sans MS','Custom Font!']
},
null,
{
name:'fontSize',
title:'Custom tooltip',
values:{1 : 'Size#1 Text' , 2 : 'Size#1 Text' , 3 : 'Size#3 Text' , 4 : 'Size#4 Text' , 5 : 'Size#5 Text'}
},
null,
{name:'bold', title:'Custom tooltip'},
{name:'italic', title:'Custom tooltip'},
{name:'strikethrough', title:'Custom tooltip'},
{name:'underline', title:'Custom tooltip'},
null,
'insertunorderedlist',
'insertorderedlist',
'outdent',
'indent',
null,
{name:'justifyleft'},
{name:'justifycenter'},
{name:'justifyright'},
{name:'justifyfull'},
null,
{
name:'createLink',
placeholder:'Custom PlaceHolder Text',
button_class:'btn-purple',
button_text:'Custom TEXT'
},
{name:'unlink'},
null,
{
name:'insertImage',
placeholder:'Custom PlaceHolder Text',
button_class:'btn-inverse',
//choose_file:false,//hide choose file button
button_text:'Set choose_file:false to hide this',
button_insert_class:'btn-pink',
button_insert:'Insert Image'
},
null,
{
name:'foreColor',
title:'Custom Colors',
values:['red','green','blue','navy','orange'],
/**
You change colors as well
*/
},
/**null,
{
name:'backColor'
},*/
null,
{name:'undo'},
{name:'redo'},
null,
'viewSource'
],
//speech_button:false,//hide speech button on chrome
'wysiwyg': {
hotKeys : {} //disable hotkeys
}
}).prev().addClass('wysiwyg-style2');
//handle form onsubmit event to send the wysiwyg's content to server
$('#myform').on('submit', function(){
//put the editor's html content inside the hidden input to be sent to server
//$('input[name=wysiwyg-value]' , this).val($('#editor').html());
//but for now we will show it inside a modal box
$('#modal-wysiwyg-editor').modal('show');
$('#wysiwyg-editor-value').css({'width':'99%', 'height':'200px'}).val($('#editor').html());
return false;
});
$('#myform').on('reset', function() {
$('#editor').empty();
});
});
</script>
</body>
</html>