PageSourceSearch

https://goldengrovehs.sa.edu.au/theme/_blueprint/js/tinymcefunctions.js

js goldengrovehs.sa.edu.au collected 2026-10-08 12:02:18 UTC 18,249 bytes, 433 lines download raw bytes

1 var actualCaretPositionBookmark;
2 
3function setWysiwygValue(id, value) {
4    tinymce.get(id).setContent(value);
5}
6function getWysiwygValue(id) {
7    return tinyMCE.get(id).getContent();
8}
9function getWysiwygValuePlainText(id) {
10    return tinyMCE.get(id).getContent({ format: 'text' });
11}
12function insertIntoWysiwyg(value, id) {
13    if(actualCaretPositionBookmark != undefined) tinyMCE.activeEditor.selection.moveToBookmark(actualCaretPositionBookmark);
14//        console.log(tinyMCE.activeEditor);
15//        //tinyMCE.setActive(id);
16//        tinyMCE.activeEditor.id = id;
17//        console.log(tinyMCE.activeEditor.id);
18//        tinyMCE.execCommand('mceFocus',false,'#'+id);
19    tinyMCE.activeEditor.execCommand('mceInsertContent', false, ' ' + value + ' ');
20}
21function setUpTextEditor(id, isFullPage, toolbar1Custom, cssIncludes, isNewsletter, profile, relativeUrls) {
22
23    var plugins = [
24        "linkfrontend spellchecker link image external responsivefilemanager jbimages custom email phone sb_url"
25    ];
26
27    var menubar = false;
28    var height = "400px";
29    if($('#'+id).data('tinymce-height') != undefined) {
30        height = $('#'+id).data('tinymce-height');
31    }
32    toolbarOptions = "   link | styleselect |  bold italic underline bullist numlist | spellchecker | removeformat  ";
33    if($('#'+id).siblings('div.mce-tinymce').length == 0) {
34
35        var settings = {
36            branding: false,
37            selector: '#' + id,
38            width: "auto",
39            height: height,
40            statusbar: true,
41            resize: "both",
42            theme: "modern",
43            valid_elements: "*[*]",
44            extended_valid_elements: "*[*]",
45            valid_children : "multiline[a],singleline[a]",
46            plugins: plugins,
47            menubar: menubar,
48            cleanup: false,
49            verify_html: false,
50            toolbar: toolbarOptions,
51            image_advtab: true,
52            contextmenu: "link image inserttable | cell row column deletetable",
53            external_filemanager_path: "/{{ _assetUrl }}theme/_admin/bluetree/js/tinymce/js/filemanager/",
54            filemanager_title: "File Manager",
55            external_plugins: {"filemanager": "{{ _assetUrl }}theme/_admin/bluetree/js/tinymce/js/filemanager/plugin.js"},
56            image_list: [],
57            paste_preprocess: function (plugin, args) {
58
59                args.content += '';
60            },
61            setup: function (editor) {
62                editor.on("keyup", function (editor, e) {
63                    actualCaretPositionBookmark = tinyMCE.activeEditor.selection.getBookmark(2, true);
64                });
65                editor.on("click", function (editor, e) {
66                    actualCaretPositionBookmark = tinyMCE.activeEditor.selection.getBookmark(2, true);
67                });
68                editor.on('getContent', function (e) {
69
70                    if (e.content.indexOf("<a") >= 0) {
71                        var data = e.content;
72                        var hrefArr = [];
73                        $(data).find("a").each(function () {
74                            var attr = $(this).attr('lote_id');
75                            if (typeof attr !== typeof undefined && attr !== false && $.isNumeric(attr)) {
76                                var text = $(this).text();
77                                e.content = e.content.replace(text+"</a>", text+'</lotelink>');
78                            }
79                        });
80                        e.content = e.content.replace(/\<a type="page"/g, '<lotelink type="page"');
81                        e.content = e.content.replace(/\<a type="file"/g, '<lotelink type="file"');
82                        var data = e.content;
83                        $(data).find("a").each(function () {
84                            var attr = $(this).attr('lote_id');
85                            if (typeof attr !== typeof undefined && attr !== false && $.isNumeric(attr)) {
86                                var text = $(this).attr('href');
87                                e.content = e.content.replace('<a href="'+text+'"', '<lotelink href="'+text+'"');
88                            }
89                        });
90                        var data = e.content;
91                        $(data).find("a").each(function () {
92                            var attr = $(this).attr('lote_id');
93                            if (typeof attr !== typeof undefined && attr !== false && $.isNumeric(attr)) {
94                                e.content = e.content.replace('<a lote_id="'+attr+'"', '<lotelink lote_id="'+attr+'"');
95                            }
96                        });
97                    }
98                });
99                editor.on('paste', function (e) {
100                    var paste;
101                    if (e.clipboardData.types.indexOf('text/plain') >= 0) {
102                        paste = e.clipboardData.getData('text/plain');
103                    }
104
105                    if (e.clipboardData.types.indexOf('text/html') >= 0) {
106                        var tempPaste = e.clipboardData.getData('text/html');
107                        if (tempPaste.includes('<!--StartFragment-->')) { // check if the content is a special type such as actual html, image or file
108                        var regex = new RegExp("([^]*<!--StartFragment-->)|(<!--EndFragment-->[^]*)", "g"); // tinymce copy includes full html and body tags, and the actual content is actually between the comments
109                        paste = tempPaste.replace(regex, '');
110                    }
111                }
112
113                if (paste !== undefined) {
114                    paste = paste.replace(/<script[^]*<\/script>/g, ''); // replaces everything in-between and including (<scrip -- <\script>)
115                    e.preventDefault();
116                    insertIntoWysiwyg(paste);
117                }
118            });
119        editor.on('paste_preprocess', function (e) {
120            console.log('paste_preprocess', e.content);
121        });
122        editor.on('beforeSetContent', function (e) {
123            e.content = e.content.replace(/<p>(<a[^<]*(<img[^<]*)<\/a>)<\/p>/gi, function (a) {
124                return a.replace('<p>', '').replace('</p>', '');
125            });
126            if (e.content.indexOf("<lotelink") >= 0) {
127
128                var data = e.content;
129                $(data).find("lotelink").each(function () {
130                    var attr = $(this).attr('lote_id');
131                    if (typeof attr !== typeof undefined && attr !== false && $.isNumeric(attr)) {
132                        var text = $(this).attr('href');
133                        e.content = e.content.replace('<lotelink href="'+text+'"', '<a href="'+text+'"');
134                    }
135
136                });
137
138                var data = e.content;
139                $(data).find("lotelink").each(function () {
140                    var attr = $(this).attr('lote_id');
141                    if (typeof attr !== typeof undefined && attr !== false && $.isNumeric(attr)) {
142                        e.content = e.content.replace('<lotelink lote_id="'+attr+'"', '<a lote_id="'+attr+'"');
143                    }
144
145                });
146
147                e.content = e.content.replace(/\<lotelink type="img"/g, '<img');
148                e.content = e.content.replace(/\<lotelink type="page"/g, '<a type="page"');
149                e.content = e.content.replace(/\<lotelink type="file"/g, '<a type="file"');
150                e.content = e.content.replace(/\<\/lotelink>/g, '</a>');
151
152            }
153
154        });
155    },
156    spellchecker_language: "en_GB",
157            spellchecker_rpc_url: 'spellchecker.php',
158            link_formats: ["Link To URL", "Link To Email", "Link To Phone"],
159            is_campaign: (profile !== undefined && profile === "campaign"),
160            sz_profile: profile
161};
162
163if(typeof(toolbar) != 'undefined') {
164    settings.toolbar1 = toolbar1Custom;
165}
166
167//Add CSS includes if provided
168if(cssIncludes) {
169    settings.content_css = cssIncludes;
170}
171
172//If newsletter editor...
173if(isNewsletter) {
174    settings.width = "800px";
175    settings.resize = true;
176}
177
178if(typeof relativeUrls == 'undefined' || relativeUrls == false) {
179    settings.relative_urls = false;
180    settings.convert_urls = false;
181}
182
183tinymce.init(settings);
184}
185}
186
187function setUpTextEditorFrontEnd(id, isFullPage, toolbar1Custom, cssIncludes, isNewsletter, profile, relativeUrls) {
188
189    var plugins = [
190        "sb_links paste spellchecker textcolor sb_images sb_filemanager sb_table lists"
191    ];
192
193    var menubar = false;
194    var height = "400px";
195    if($('#'+id).data('tinymce-height') != undefined) {
196        height = $('#'+id).data('tinymce-height');
197    }
198    toolbarOptions = "sb_links | sb_images | table |styleselect |  fontsizeselect forecolor | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist | removeformat  ";
199    if($('#'+id).siblings('div.mce-tinymce').length == 0) {
200
201        var settings = {
202            branding: false,
203            selector: '#' + id,
204            width: "auto",
205            height: height,
206            statusbar: true,
207            paste_auto_cleanup_on_paste : true,
208            paste_remove_styles: true,
209            paste_remove_styles_if_webkit: true,
210            paste_strip_class_attributes: true,
211            resize: "both",
212            theme: "modern",
213            valid_elements: "*[*]",
214            extended_valid_elements: "*[*]",
215            valid_children : "multiline[a],singleline[a]",
216            plugins: plugins,
217            menubar: menubar,
218            cleanup: false,
219            verify_html: false,
220            toolbar: toolbarOptions,
221            image_advtab: true,
222            contextmenu: "link image inserttable | cell row column deletetable",
223            fontsize_formats: "8px 9px 10px 11px 12px 14px 16px 18px 20px 24px 36px",
224            image_list: [],
225            paste_preprocess: function (plugin, args) {
226                args.content += '';
227            },
228            setup: function (editor) {
229                editor.on("keyup", function (editor, e) {
230                    actualCaretPositionBookmark = tinyMCE.activeEditor.selection.getBookmark(2, true);
231                });
232                editor.on("click", function (editor, e) {
233                    actualCaretPositionBookmark = tinyMCE.activeEditor.selection.getBookmark(2, true);
234                });
235                editor.on('getContent', function (e) {
236
237                    if (e.content.indexOf("<a") >= 0) {
238                        var data = e.content;
239                        var hrefArr = [];
240                        $(data).find("a").each(function () {
241                            var attr = $(this).attr('lote_id');
242                            if (typeof attr !== typeof undefined && attr !== false && $.isNumeric(attr)) {
243                                var text = $(this).text();
244                                e.content = e.content.replace(text+"</a>", text+'</lotelink>');
245                            }
246                        });
247                        e.content = e.content.replace(/\<a type="page"/g, '<lotelink type="page"');
248                        e.content = e.content.replace(/\<a type="file"/g, '<lotelink type="file"');
249                        var data = e.content;
250                        $(data).find("a").each(function () {
251                            var attr = $(this).attr('lote_id');
252                            if (typeof attr !== typeof undefined && attr !== false && $.isNumeric(attr)) {
253                                var text = $(this).attr('href');
254                                e.content = e.content.replace('<a href="'+text+'"', '<lotelink href="'+text+'"');
255                            }
256                        });
257                        var data = e.content;
258                        $(data).find("a").each(function () {
259                            var attr = $(this).attr('lote_id');
260                            if (typeof attr !== typeof undefined && attr !== false && $.isNumeric(attr)) {
261                                e.content = e.content.replace('<a lote_id="'+attr+'"', '<lotelink lote_id="'+attr+'"');
262                            }
263                        });
264                    }
265                });
266                editor.on('paste', function (e) {
267                    var paste;
268                    if (e.clipboardData.types.indexOf('text/plain') >= 0) {
269                        paste = e.clipboardData.getData('text/plain');
270                    }
271
272                    if (e.clipboardData.types.indexOf('text/html') >= 0) {
273                        var tempPaste = e.clipboardData.getData('text/html');
274                        if (tempPaste.includes('<!--StartFragment-->')) { // check if the content is a special type such as actual html, image or file
275                        var regex = new RegExp("([^]*<!--StartFragment-->)|(<!--EndFragment-->[^]*)", "g"); // tinymce copy includes full html and body tags, and the actual content is actually between the comments
276                        paste = tempPaste.replace(regex, '');
277                    }
278                }
279
280                if (paste !== undefined) {
281                    paste = paste.replace(/<script[^]*<\/script>/g, ''); // replaces everything in-between and including (<scrip -- <\script>)
282                    e.preventDefault();
283                    insertIntoWysiwyg(paste);
284                }
285            });
286        editor.on('paste_preprocess', function (e) {
287            console.log('paste_preprocess', e.content);
288        });
289        editor.on('beforeSetContent', function (e) {
290
291            if (e.content.indexOf("<lotelink") >= 0) {
292
293                var data = e.content;
294                $(data).find("lotelink").each(function () {
295                    var attr = $(this).attr('lote_id');
296                    if (typeof attr !== typeof undefined && attr !== false && $.isNumeric(attr)) {
297                        var text = $(this).attr('href');
298                        e.content = e.content.replace('<lotelink href="'+text+'"', '<a href="'+text+'"');
299                    }
300
301                });
302
303                var data = e.content;
304                $(data).find("lotelink").each(function () {
305                    var attr = $(this).attr('lote_id');
306                    if (typeof attr !== typeof undefined && attr !== false && $.isNumeric(attr)) {
307                        e.content = e.content.replace('<lotelink lote_id="'+attr+'"', '<a lote_id="'+attr+'"');
308                    }
309
310                });
311
312                e.content = e.content.replace(/\<lotelink type="img"/g, '<img');
313                e.content = e.content.replace(/\<lotelink type="page"/g, '<a type="page"');
314                e.content = e.content.replace(/\<lotelink type="file"/g, '<a type="file"');
315                e.content = e.content.replace(/\<\/lotelink>/g, '</a>');
316
317            }
318
319        });
320    },
321    spellchecker_language: "en_GB",
322            spellchecker_rpc_url: 'spellchecker.php',
323            is_campaign: (profile !== undefined && profile === "campaign"),
324            sz_profile: profile
325};
326
327if(typeof(toolbar) != 'undefined') {
328    settings.toolbar1 = toolbar1Custom;
329}
330
331//Add CSS includes if provided
332if(cssIncludes) {
333    settings.content_css = cssIncludes;
334}
335
336//If newsletter editor...
337if(isNewsletter) {
338    settings.width = "800px";
339    settings.resize = true;
340}
341
342if(typeof relativeUrls == 'undefined' || relativeUrls == false) {
343    settings.relative_urls = false;
344    settings.convert_urls = false;
345}
346
347settings.sb_links_opts = {
348    link_url: true,
349    link_email: true,
350    link_phone: true
351};
352
353settings.sb_images_opts = {
354    link_upload: true,
355    link_external: true
356};
357
358tinymce.init(settings);
359
360}
361}
362
363function setupContentEditor(id, isFullPage, toolbar1Custom, cssIncludes, isNewsletter, profile, relativeUrls, wildcards, overrideHeight) {
364    var plugins = [
365        "contextmenu", "advlist", "autolink", "lists", "print",  "searchreplace", "visualblocks", "visualchars",
366        "code", "save", "directionality", "paste", "textcolor",
367        "sb_filemanager", "sb_links", "sb_images", "sb_table", "spellchecker"
368    ];
369    var contextMenu = " sb_links sb_images inserttable elements web_link pdf_viewer";
370
371    var wildcardSettings = {
372        content_holder: false,
373        update_forms: false
374    };
375
376    if (wildcards) {
377        if (profile !== 'campaign') {
378            plugins.push("sb_elements");
379        }
380        plugins.push("sb_wildcards");
381        contextMenu = contextMenu + " sb_wildcards sb_wildcards_update_form ";
382
383    }
384
385    var toolbarOptions = "sb_images sb_gallery sb_video pdf_viewer sb_links | formatselect | fontsizeselect forecolor | bold italic underline strikethrough | removeformat | alignleft aligncenter alignright al
385ignjustify | outdent indent | bullist numlist  |  undo redo | code";
386    if (profile === "campaign"){
387        toolbarOptions = "undo redo | fontsizeselect forecolor | bold italic | removeformat | alignleft aligncenter alignright alignjustify | outdent indent | bullist numlist | sb_links | code";
388    }
389    else if(profile === "manage_app_mobile") {
390        toolbarOptions = "undo redo removeformat |  bold italic | alignleft aligncenter alignright | outdent indent | sb_links | sb_images | code ";
391    }
392    else {
393        plugins.push("sb_gallery");
394        plugins.push("sb_video");
395        contextMenu = "sb_images sb_gallery sb_video pdf_viewer web_link inserttable elements sb_links";
396        //contextMenu =  "sb_gallery sb_video "+contextMenu;
397
398    }
399
400
401    if(isFullPage || isNewsletter) {
402        plugins.push("fullpage");
403    }
404
405    var validElements = "*[*]";
406    var invalidElements = "";
407    var validExtendedElements = '*[*]';
408    var validChildren = "multiline[a],singleline[a]";
409
410    var menubar = "edit insert view table tools sb_wildcards";
411    if(profile === "manage_app_mobile"){
412        menubar = false;
413    }
414    var height = "600px";
415    if(profile == "quick_feed" || profile == "summary" ){
416        height = "400px";
417    }
418    else if( profile === "manage_app_mobile"){
419        height = "250px";
420    }
421    else if( profile === "new_content_holder"){
422        height = "400px";
423    }
424    else if(profile === "company_note"){
425        height = "330px";
426    }
427
428
429    if (overrideHeight) {
430        height = overrideHeight + "px";
431    }
432
433}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.