-
Notifications
You must be signed in to change notification settings - Fork 95
/
demo.html
153 lines (118 loc) · 3.73 KB
/
demo.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
<!doctype html>
<html>
<head>
<title>jrvis - Trunk8</title>
<style>
.wrapper {
border: 2px solid #000;
line-height: 20px;
width: 676px;
}
.trunk8-fill {
color: #f00;
font-weight: bold;
}
</style>
</head>
<body>
<div class="wrapper">
<span id="txt">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</span>
</div>
<div>
<button id="widen">Widen</button>
<button id="shorten">Shorten</button>
</div>
<div>
<button id="addline">Add Line</button>
<button id="removeline">Remove Line</button>
</div>
<div>
<button id="retrunk8">Retrunk8</button>
</div>
<div>
<label>Left <input type="radio" name="trunk8side" value="left"/></label>
<label>Center <input type="radio" name="trunk8side" value="center"/></label>
<label>Right <input type="radio" name="trunk8side" value="right" checked/></label>
</div>
<div>
<label>
Fill
<select id="fill">
<option value="&hellip;" selected>…</option>
<option value="[snip]">[snip]</option>
<option value="<span class="trunk8-fill">snip</span>"><span class="trunk8-fill">snip</span></option>
<option value="&nbsp;<a href="#">read more</a>"> <a href="#">read more</a></option>
</select>
</label>
</div>
<div>
<pre id="settings"></pre>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="trunk8.js"></script>
<script>
$(document).ready(function () {
function updateSettings(settings) {
var props = [],
prop;
for (prop in settings) {
props.push(' '+prop+': '+settings[prop]);
}
$('#settings').html('settings = {<br/>' + props.join(',<br/>') + '<br/>}');
}
$('#txt').trunk8();
updateSettings($('#txt').trunk8('getSettings'));
$('#widen').click(function () {
$('.wrapper').css({
width: function () {
/* Increment by 25. */
return $(this).width() + 25;
}
});
$('#txt').trunk8('update');
});
$('#shorten').click(function () {
$('.wrapper').css({
width: function () {
/* Decrement by 25, but do not exceed 75. */
return Math.max(75, $(this).width() - 25);
}
});
$('#txt').trunk8('update');
});
$('#retrunk8').click(function () {
$('#txt').trunk8('update');
updateSettings($('#txt').trunk8('getSettings'));
});
$('#addline').click(function () {
/* Get current settings. */
var settings = $('#txt').trunk8('getSettings');
/* Increment the line count. */
settings.lines += 1;
/* Save the new setting. */
$('#txt').trunk8({lines: settings.lines});
/* Update the UI. */
updateSettings(settings);
});
$('#removeline').click(function () {
/* Get current settings. */
var settings = $('#txt').trunk8('getSettings');
/* Decrement the line count no lower than 1. */
settings.lines = (settings.lines - 1) || 1;
/* Save the new setting. */
$('#txt').trunk8({lines: settings.lines});
/* Update the UI. */
updateSettings(settings);
});
$('input[name=trunk8side]:radio').change(function () {
$('#txt').trunk8({side: this.value});
updateSettings($('#txt').trunk8('getSettings'));
});
$('#fill').change(function () {
$('#txt').trunk8({fill: this.value});
updateSettings($('#txt').trunk8('getSettings'));
});
});
</script>
</body>
</html>