| 35549 |
ranu |
1 |
<style>
|
|
|
2 |
.quill-editor {
|
|
|
3 |
height: 250px;
|
|
|
4 |
}
|
|
|
5 |
|
|
|
6 |
.quill-editor .ql-editor {
|
|
|
7 |
min-height: 200px;
|
|
|
8 |
font-size: 14px;
|
|
|
9 |
}
|
|
|
10 |
|
|
|
11 |
.uploaded-file-item {
|
|
|
12 |
margin-top: 6px;
|
|
|
13 |
font-size: 13px;
|
|
|
14 |
color: #3a8bbf;
|
|
|
15 |
font-weight: 500;
|
|
|
16 |
}
|
|
|
17 |
|
|
|
18 |
.uploaded-file-item i {
|
|
|
19 |
margin-right: 6px;
|
|
|
20 |
color: #3a8bbf;
|
|
|
21 |
}
|
|
|
22 |
|
| 35587 |
ranu |
23 |
/* Emoji Picker Styles */
|
|
|
24 |
.ql-emoji {
|
|
|
25 |
font-size: 16px !important;
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
.emoji-picker-container {
|
|
|
29 |
position: absolute;
|
|
|
30 |
z-index: 1000;
|
|
|
31 |
background: #fff;
|
|
|
32 |
border: 1px solid #ccc;
|
|
|
33 |
border-radius: 8px;
|
|
|
34 |
padding: 10px;
|
|
|
35 |
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
|
36 |
display: none;
|
|
|
37 |
max-width: 320px;
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
.emoji-picker-container.show {
|
|
|
41 |
display: block;
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
.emoji-grid {
|
|
|
45 |
display: grid;
|
|
|
46 |
grid-template-columns: repeat(8, 1fr);
|
|
|
47 |
gap: 5px;
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
.emoji-item {
|
|
|
51 |
font-size: 22px;
|
|
|
52 |
cursor: pointer;
|
|
|
53 |
padding: 5px;
|
|
|
54 |
text-align: center;
|
|
|
55 |
border-radius: 4px;
|
|
|
56 |
transition: background 0.2s;
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
.emoji-item:hover {
|
|
|
60 |
background: #e8e8e8;
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
.emoji-category {
|
|
|
64 |
font-size: 12px;
|
|
|
65 |
color: #666;
|
|
|
66 |
margin: 8px 0 5px 0;
|
|
|
67 |
font-weight: bold;
|
|
|
68 |
border-bottom: 1px solid #eee;
|
|
|
69 |
padding-bottom: 3px;
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
.emoji-category:first-child {
|
|
|
73 |
margin-top: 0;
|
|
|
74 |
}
|
|
|
75 |
|
| 35549 |
ranu |
76 |
</style>
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
<section class="wrapper">
|
|
|
80 |
<div class="row">
|
|
|
81 |
<div class="col-lg-12">
|
|
|
82 |
<h3 class="page-header"><i class="icon_document_alt"></i>Post Bulletin</h3>
|
|
|
83 |
<ol class="breadcrumb">
|
|
|
84 |
<li><i class="fa fa-home"></i><a href="${rc.contextPath}/dashboard">Home</a></li>
|
|
|
85 |
<li><i class="icon_document_alt"></i>Post Bulletin</li>
|
|
|
86 |
</ol>
|
|
|
87 |
</div>
|
|
|
88 |
</div>
|
|
|
89 |
<div class="row">
|
|
|
90 |
<div class="col-lg-12">
|
|
|
91 |
<form method="post" action="${rc.contextPath}/bulletin/save">
|
|
|
92 |
|
|
|
93 |
<div class="row">
|
| 35583 |
ranu |
94 |
## <div class="col-md-8">
|
|
|
95 |
## <!-- Title -->
|
|
|
96 |
## <div class="form-group">
|
|
|
97 |
## <label>Title</label>
|
|
|
98 |
## <input type="text" id="btitle" class="form-control" required>
|
|
|
99 |
## </div>
|
|
|
100 |
## </div>
|
| 35549 |
ranu |
101 |
|
|
|
102 |
<div class="col-md-4">
|
|
|
103 |
<!-- Region -->
|
|
|
104 |
<div class="form-group">
|
|
|
105 |
<label>Region</label>
|
|
|
106 |
<select id="bregionId" class="form-control" required>
|
|
|
107 |
#foreach($region in $regionList)
|
|
|
108 |
<option value="$region.getId()">$region.getName()</option>
|
|
|
109 |
#end
|
|
|
110 |
</select>
|
|
|
111 |
</div>
|
|
|
112 |
</div>
|
|
|
113 |
</div>
|
|
|
114 |
|
|
|
115 |
<div class="row">
|
|
|
116 |
<div class="col-md-12">
|
|
|
117 |
|
|
|
118 |
<div class="form-group">
|
|
|
119 |
<img id="imgPreview" style="max-width:200px; display:none; margin-top:10px;"/>
|
|
|
120 |
</div>
|
|
|
121 |
<div class="form-group">
|
|
|
122 |
<div id="uploadedFileList"></div>
|
|
|
123 |
</div>
|
|
|
124 |
</div>
|
|
|
125 |
</div>
|
|
|
126 |
|
|
|
127 |
<!-- Description (Editor) -->
|
|
|
128 |
<div class="form-group">
|
|
|
129 |
<label>Description</label>
|
|
|
130 |
<div id="bulletinEditor" class="quill-editor"></div>
|
|
|
131 |
</div>
|
|
|
132 |
|
|
|
133 |
|
|
|
134 |
<button type="submit" class="btn btn-primary post-bulletin-button">
|
|
|
135 |
Post Bulletin
|
|
|
136 |
</button>
|
|
|
137 |
</form>
|
|
|
138 |
</div>
|
|
|
139 |
</div>
|
|
|
140 |
</section>
|
|
|
141 |
|
|
|
142 |
|
|
|
143 |
<form id="uploadForm" enctype="multipart/form-data" style="display:none">
|
|
|
144 |
<input type="file" id="uploadFileInput" name="file"
|
|
|
145 |
accept="image/*,.pdf,.csv,.xls,.xlsx">
|
|
|
146 |
</form>
|
|
|
147 |
|
|
|
148 |
<input type="hidden" id="bulletinDocumentIds"/>
|
|
|
149 |
|
| 35587 |
ranu |
150 |
<!-- Emoji Picker (populated by JavaScript) -->
|
|
|
151 |
<div id="emojiPicker" class="emoji-picker-container"></div>
|
| 35549 |
ranu |
152 |
|
|
|
153 |
<script>
|
|
|
154 |
var quill;
|
|
|
155 |
var uploadedDocumentIds = [];
|
|
|
156 |
|
| 35587 |
ranu |
157 |
// Emoji data with Unicode code points (using String.fromCodePoint for compatibility)
|
|
|
158 |
var emojiData = {
|
|
|
159 |
'Smileys': [
|
|
|
160 |
0x1F600, 0x1F603, 0x1F604, 0x1F601, 0x1F60A, 0x1F60D,
|
|
|
161 |
0x1F970, 0x1F618, 0x1F61C, 0x1F60E, 0x1F929, 0x1F607,
|
|
|
162 |
0x1F642, 0x1F609, 0x1F60B, 0x1F917
|
|
|
163 |
],
|
|
|
164 |
'Emotions': [
|
|
|
165 |
0x1F622, 0x1F62D, 0x1F624, 0x1F620, 0x1F621, 0x1F914,
|
|
|
166 |
0x1F610, 0x1F611, 0x1F62E, 0x1F631, 0x1F634, 0x1F912,
|
|
|
167 |
0x1F637, 0x1F922, 0x1F973, 0x1F92D
|
|
|
168 |
],
|
|
|
169 |
'Gestures': [
|
|
|
170 |
0x1F44D, 0x1F44E, 0x1F44F, 0x1F64C, 0x1F91D, 0x270C,
|
|
|
171 |
0x1F91E, 0x1F44C, 0x1F44B, 0x1F4AA, 0x1F64F, 0x261D,
|
|
|
172 |
0x1F446, 0x1F447, 0x1F448, 0x1F449
|
|
|
173 |
],
|
|
|
174 |
'Objects': [
|
|
|
175 |
0x2764, 0x1F4AF, 0x1F525, 0x2B50, 0x2728, 0x1F4B0,
|
|
|
176 |
0x1F4E2, 0x1F4E3, 0x1F389, 0x1F38A, 0x1F3C6, 0x1F4C8,
|
|
|
177 |
0x1F4C9, 0x2705, 0x274C, 0x26A0
|
|
|
178 |
]
|
|
|
179 |
};
|
|
|
180 |
|
|
|
181 |
// Build emoji picker HTML
|
|
|
182 |
function buildEmojiPicker() {
|
|
|
183 |
var html = '';
|
|
|
184 |
for (var category in emojiData) {
|
|
|
185 |
html += '<div class="emoji-category">' + category + '</div>';
|
|
|
186 |
html += '<div class="emoji-grid">';
|
|
|
187 |
emojiData[category].forEach(function (codePoint) {
|
|
|
188 |
var emoji = String.fromCodePoint(codePoint);
|
|
|
189 |
html += '<span class="emoji-item">' + emoji + '</span>';
|
|
|
190 |
});
|
|
|
191 |
html += '</div>';
|
|
|
192 |
}
|
|
|
193 |
document.getElementById('emojiPicker').innerHTML = html;
|
|
|
194 |
}
|
|
|
195 |
|
| 35549 |
ranu |
196 |
$(document).ready(function () {
|
| 35587 |
ranu |
197 |
// Build emoji picker
|
|
|
198 |
buildEmojiPicker();
|
|
|
199 |
|
| 35549 |
ranu |
200 |
quill = new Quill('#bulletinEditor', {
|
|
|
201 |
theme: 'snow',
|
|
|
202 |
modules: {
|
|
|
203 |
toolbar: {
|
|
|
204 |
container: [
|
|
|
205 |
[{font: []}, {size: []}],
|
|
|
206 |
['bold', 'italic', 'underline'],
|
|
|
207 |
[{color: []}, {background: []}],
|
|
|
208 |
[{header: 1}, {header: 2}],
|
|
|
209 |
[{list: 'ordered'}, {list: 'bullet'}],
|
|
|
210 |
[{align: []}],
|
| 35587 |
ranu |
211 |
['link', 'image', 'emoji'],
|
| 35549 |
ranu |
212 |
['clean']
|
|
|
213 |
],
|
|
|
214 |
handlers: {
|
| 35587 |
ranu |
215 |
image: imageHandler,
|
|
|
216 |
emoji: emojiHandler
|
| 35549 |
ranu |
217 |
}
|
|
|
218 |
}
|
|
|
219 |
}
|
|
|
220 |
});
|
| 35587 |
ranu |
221 |
|
|
|
222 |
// Add emoji icon to the toolbar button
|
|
|
223 |
var emojiButton = document.querySelector('.ql-emoji');
|
|
|
224 |
if (emojiButton) {
|
|
|
225 |
emojiButton.innerHTML = String.fromCodePoint(0x1F600);
|
|
|
226 |
}
|
|
|
227 |
|
|
|
228 |
// Handle emoji selection
|
|
|
229 |
$('#emojiPicker').on('click', '.emoji-item', function () {
|
|
|
230 |
var emoji = $(this).text();
|
|
|
231 |
var range = quill.getSelection(true);
|
|
|
232 |
quill.insertText(range.index, emoji);
|
|
|
233 |
quill.setSelection(range.index + emoji.length);
|
|
|
234 |
$('#emojiPicker').removeClass('show');
|
|
|
235 |
});
|
|
|
236 |
|
|
|
237 |
// Close emoji picker when clicking outside
|
| 37498 |
amit |
238 |
// Fragment is re-injected with .html(), which re-runs this script; clear the
|
|
|
239 |
// namespace first so handlers replace rather than stack.
|
|
|
240 |
$(document).off('.postbulletin');
|
|
|
241 |
$(document).on('click.postbulletin', function (e) {
|
| 35587 |
ranu |
242 |
if (!$(e.target).closest('#emojiPicker, .ql-emoji').length) {
|
|
|
243 |
$('#emojiPicker').removeClass('show');
|
|
|
244 |
}
|
|
|
245 |
});
|
| 35549 |
ranu |
246 |
});
|
|
|
247 |
|
| 35587 |
ranu |
248 |
function emojiHandler() {
|
|
|
249 |
var emojiPicker = document.getElementById('emojiPicker');
|
|
|
250 |
var emojiButton = document.querySelector('.ql-emoji');
|
|
|
251 |
|
|
|
252 |
// Position the picker below the emoji button
|
|
|
253 |
var rect = emojiButton.getBoundingClientRect();
|
|
|
254 |
var editorContainer = document.querySelector('.quill-editor');
|
|
|
255 |
var editorRect = editorContainer.getBoundingClientRect();
|
|
|
256 |
|
|
|
257 |
emojiPicker.style.top = (rect.bottom + window.scrollY + 5) + 'px';
|
|
|
258 |
emojiPicker.style.left = Math.min(rect.left, editorRect.right - 330) + 'px';
|
|
|
259 |
|
|
|
260 |
// Toggle visibility
|
|
|
261 |
emojiPicker.classList.toggle('show');
|
|
|
262 |
}
|
|
|
263 |
|
| 35549 |
ranu |
264 |
function imageHandler() {
|
|
|
265 |
const input = document.getElementById('uploadFileInput');
|
|
|
266 |
input.value = '';
|
|
|
267 |
input.click();
|
|
|
268 |
|
|
|
269 |
input.onchange = function () {
|
|
|
270 |
const file = input.files[0];
|
|
|
271 |
if (!file) return;
|
|
|
272 |
const fileList = document.getElementById("uploadedFileList");
|
|
|
273 |
|
|
|
274 |
// Show preview ONLY for image
|
|
|
275 |
if (file.type.startsWith("image/")) {
|
|
|
276 |
const preview = document.getElementById("imgPreview");
|
|
|
277 |
preview.src = URL.createObjectURL(file);
|
|
|
278 |
preview.style.display = "block";
|
|
|
279 |
}
|
|
|
280 |
// NON-IMAGE FILE (PDF, CSV, XLS)
|
|
|
281 |
else {
|
|
|
282 |
const fileItem = document.createElement("div");
|
|
|
283 |
fileItem.className = "uploaded-file-item";
|
|
|
284 |
fileItem.innerHTML = `
|
|
|
285 |
<i class="fa fa-file"></i>
|
|
|
286 |
<span>${file.name}</span>
|
|
|
287 |
`;
|
|
|
288 |
fileList.appendChild(fileItem);
|
|
|
289 |
}
|
|
|
290 |
|
|
|
291 |
// ✅ Reuse existing working upload method
|
|
|
292 |
uploadDocument(file, function (documentId) {
|
|
|
293 |
|
|
|
294 |
// Store document id
|
|
|
295 |
uploadedDocumentIds.push(documentId);
|
|
|
296 |
$("#bulletinDocumentIds").val(uploadedDocumentIds.join(","));
|
|
|
297 |
// Success message
|
|
|
298 |
bootbox.alert("File uploaded successfully");
|
|
|
299 |
|
|
|
300 |
});
|
|
|
301 |
};
|
|
|
302 |
}
|
|
|
303 |
</script>
|
|
|
304 |
|
|
|
305 |
|