forked from basecamp/wysihat
/
align_selection.html
93 lines (76 loc) · 2.5 KB
/
align_selection.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>WYSIWYG</title>
<style type="text/css" media="screen">
iframe {
width: 100%;
height: 150px;
border: 1px solid #999;
}
.editor_toolbar .button {
float: left;
margin: 2px 5px;
}
.editor_toolbar .selected {
color: red !important;
}
#error {
font: 18px helvetica, arial, sans-serif;
color: red;
}
</style>
<script type="text/javascript" src="../dist/prototype.js"></script>
<script type="text/javascript" src="../dist/wysihat.js"></script>
<script type="text/javascript" charset="utf-8">
Event.observe(window, 'load', function() {
var editor = WysiHat.Editor.attach('content');
var toolbar = new WysiHat.Toolbar(editor);
toolbar.addButton({
label: "JustifyLeft"
});
toolbar.addButton({
label: "JustifyCenter"
});
toolbar.addButton({
label: "JustifyRight"
});
// Hide our error message if the editor loads fine
$('error').hide();
});
</script>
</head>
<body>
<p id="error">Oops, you need to build the package before running this example. It's easy: just run <code>rake</code> in the project's directory.</p>
<p>This example shows you how to create a simple UI for aligning text.</p>
<code><pre>
Event.observe(window, 'load', function() {
var editor = WysiHat.Editor.attach('content');
var toolbar = new WysiHat.Toolbar(editor);
toolbar.addButton({
label: "Align left",
handler: function(editor) { return editor.alignSelection('left'); }
});
toolbar.addButton({
label: "Align center",
handler: function(editor) { return editor.alignSelection('center'); }
});
toolbar.addButton({
label: "Align right",
handler: function(editor) { return editor.alignSelection('right'); }
});
});
</pre></code>
<form action="#" method="post" style="width: 500px;">
<!-- This HTML will be automatically generated for you by the toolbar class
<div class="editor_toolbar">
<a class="button align left" href="#"><span>Align left</span></a>
<a class="button align center" href="#"><span>Align center</span></a>
<a class="button align right" href="#"><span>Align right</span></a>
</div>
<iframe id="content_editor" style="display: none;"> -->
<textarea id="content"></textarea>
</form>
</body>
</html>