PageSourceSearch

https://www.eglise-niort.net/local/cache-js/jsdyn-ckeditor4spip_js-af7919e4.js?1788762906

js eglise-niort.net collected 2026-10-02 12:13:35 UTC 16,158 bytes, 373 lines download raw bytes

1/* #PRODUIRE{fond=ckeditor4spip.js}
2   md5:f3a865353da69c395f8cf6ef5fce0b46 */
3
4var ckeDataProcessor;
5
6var sansConversion = false;
7
8function htmldecode(s) {
9    return jQuery('<div/>').html(s).text();
10}
11
12function HideSpipUI(editor_id) {
13    if (jQuery(editor_id).length == 0) { return; }
14    var crayon = editor_id.match(/^(#crayon_\d+)\s/), item, editor_id_light = editor_id;
15    if (crayon) {
16        editor_id_light = 'textarea.crayon-active';
17        stack[editor_id].crborder = jQuery(crayon[1] + ' .formulaire_spip').css('border');
18        stack[editor_id].crbg = jQuery(crayon[1] + ' .formulaire_spip').css('background-color');
19        jQuery(crayon[1] + ' .formulaire_spip')
20            .css('border', 'none')
21            .css('background-color', 'white');
22        item = jQuery(crayon + ' div.edition');
23    } else {
24        editor_id_light = editor_id.match(/^#\S*\s+(.*)$/);
25        if (editor_id_light) {
26            editor_id_light = editor_id_light[1];
27        } else {
28            editor_id_light = editor_id;
29        }
30
31        item = jQuery(editor_id_light).parents().find('div.forum, div.edition:has(' + editor_id_light + ')');
32    }
33    item.each(function () {
34        if (jQuery(this).find(editor_id_light).length == 1) {
35            if (editor_id.match(/^#formulaire_forum\s/)) {
36                stack[editor_id].fobd = jQuery(this).css('border');
37                stack[editor_id].fobg = jQuery(this).css('background');
38                jQuery(this).css('border', 'none');
39                jQuery(this).css('background', 'none');
40            }
41            jQuery(this).find('.spip_barre').css('display', 'none').end()
42                .find('.explication').css('display', 'none').end()
43                .find('.markItUpHeader').css('display', 'none').end()
44                .find('.markItUpTabs').css('display', 'none').end()
45                .find('.markItUpPreview').css('display', 'none').end()
46                .find('.markItUpFooter').css('display', 'none');
47        }
48    });
49}
50
51function ShowSpipUI(editor_id) {
52    if (jQuery(editor_id).length == 0) { return; }
53    if (!stack[editor_id].nobarre) {
54        jQuery(editor_id).removeClass('no_barre');
55        barrebouilles_editor(editor_id);
56        stack[editor_id].nobarre = false;
57    }
58    var crayon = editor_id.match(/^(#crayon_\d+)\s/), item;
59    if (crayon) {
60        item = jQuery(crayon + ' div.edition');
61    } else {
62        item = jQuery(editor_id).parents().find('div.forum, div.edition:has(' + editor_id + ')');
63    }
64    item.each(function () {
65        if (editor_id.match(/^#formulaire_forum\s/)) {
66            jQuery(this).css('border', stack[editor_id].fobd);
67            jQuery(this).css('background', stack[editor_id].fobg);
68        }
69        if (crayon) {
70            jQuery(crayon[1] + ' .formulaire_spip')
71                .css('border', stack[editor_id].crborder)
72                .css('background-color', stack[editor_id].crbg);
73        }
74        if (jQuery(this).find('.markItUpTabs .previsuVoir').hasClass('on')) {
75            jQuery(this).find('.markItUpTabs').css('display', '').end()
76                .find('.markItUpPreview').css('display', 'block').end()
77                .find('.markItUpEditor').css('display', 'none');
78        } else {
79            jQuery(this).find('.spip_barre').css('display', '').end()
80                .find('.explication').css('display', '').end()
81                .find('.markItUpHeader').css('display', '').end()
82                .find('.markItUpTabs').css('display', '').end()
83                .find('.markItUpFooter').css('display', '').end()
84                .find('.markItUpEditor').css('display', 'block').end()
85                .find('.markItUpPreview').css('display', 'none');
86        }
87    });
88}
89
90var stack = [];
91
92function SpipEditor2CKEditor(editor_id) {
93    if (jQuery(editor_id).length == 0) { return; }
94    jQuery('#swapeditor_' + stack[editor_id].md5)
95        .attr('disabled', true)
96        .attr('title', htmldecode('Chargement'))
97        .find('img')
98        .attr('src', 'https://www.eglise-niort.net/plugins/auto/ckeditor/v1.2.11/images/searching.gif');
99    jQuery(editor_id).attr('disabled', true);
100    var EdConfig = {}; jQuery.extend(EdConfig, CKEDITOR.ckConfig);
101    EdConfig.toolbar = 'Spip' + stack[editor_id].tb;
102    try {
103        editor = jQuery(editor_id).ckeditor(function () {
104            HideSpipUI(editor_id);
105            stack[editor_id].n = '#' + this.container.getId();
106            stack[editor_id].editor = this.name;
107
108            
109
110            var parent_ids = ['.cadre-formulaire-editer', '.formulaire_crayon', '.cadre-formulaire', '.formulaire_spip', '#contenu'];
111            var pc = 0, parent_trouve = false;
112            do {
113                stack[editor_id].parent_id = parent_ids[pc++];
114                if (jQuery(stack[editor_id].parent_id).length > 0) {
115                    parent_trouve = true;
116                    stack[editor_id].marges = jQuery(editor_id).parents(stack[editor_id].parent_id).width() - jQuery(stack[editor_id].n).width();
117                }
118            } while ((pc < parent_ids.length) && (!parent_trouve));
119
120            if (parent_trouve) {
121                this.on('resize', function (e) {
122                    jQuery(editor_id).parents(stack[editor_id].parent_id).width(jQuery(stack[editor_id].n).width() + stack[editor_id].marges);
123                });
124            }
125            contexteChange(editor_id);
126            jQuery(editor_id).attr('disabled', false);
127            jQuery('#swapeditor_' + stack[editor_id].md5)
128                .attr('title', htmldecode('Utiliser l&#39;éditeur de SPIP'))
129                .find('img')
130                .attr('src', 'https://www.eglise-niort.net/plugins/auto/ckeditor/v1.2.11/images/ckeditor_spip.png');
131            jQuery('#swapeditor_' + stack[editor_id].md5).attr('disabled', false);
132            this.setReadOnly(false);
133            this.on('dataReady', function (e) {
134                this.resize(CKEDITOR.ckConfig.minwidth, CKEDITOR.ckConfig.height);
135            });
136        }, EdConfig).editor;
137
138        if (!sansConversion) {
139            /*
140                Note : La conversion SPIP se fait sur le HTML final.
141                Par conséquent cela se passe à l'étape 16 des état de l'événement. Autrement il s'agit d'un fragment ckeditor (cf documentation)
142            */
143            //https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#event-toDataFormat
144            editor.on('toDataFormat', function (evt) {
145                evt.data.dataValue = jQuery.ajax({
146                    url: CKEDITOR.spipurl + '?page=ckspip_convert',
147                    data: {
148                        text_area: evt.data.dataValue.replace(/<span\s+data-scayt[^>]*>\s*(.*?)\s*<\/span>/g, '$1'),
149                        cvt: 'html2spip',
150                        fix: evt.data.fixForBody
151                    },
152                    global: false,
153                    type: 'POST',
154                    dataType: 'text',
155                    async: false
156                }
157                ).responseText;
158            }, null, null, 16);
159
160            //https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_editor.html#event-toHtml
161            editor.on('toHtml', function (evt) {
162                evt.data.dataValue = jQuery.ajax({
163                    url: CKEDITOR.spipurl + '?page=ckspip_convert',
164                    data: {
165                        text_area: evt.data.dataValue.replace(/<span\s+data-scayt[^>]*>\s*(.*?)\s*<\/span>/g, '$1'),
166                        cvt: 'spip2html',
167                        fix: evt.data.fixForBody
168                    },
169                    global: false,
170                    type: 'POST',
171                    dataType: 'text',
172                    async: false
173                }
174                ).responseText;
175            }, null, null, 1);
176        }
177    } catch (E) { /* rien */ }
178}
179
180function barrebouilles_editor(editor_id) {
181    
182    if (jQuery(editor_id).hasClass('inserer_barre_forum'))
183        jQuery(editor_id).barre_outils('forum');
184    if (jQuery(editor_id).hasClass('inserer_barre_edition'))
185        jQuery(editor_id).barre_outils('edition');
186    if (jQuery(editor_id).hasClass('inserer_previsualisation'))
187        jQuery(editor_id).barre_previsualisation();
188    
189    if (jQuery(editor_id).hasClass('textarea_forum'))
190        jQuery(editor_id).barre_outils('forum');
191    if (jQuery(editor_id).attr('name').match(/^(texte|\w+_texte)$/)) {
192        if (!editor_id.match(/\b#formulaire_forum\b/)) {
193            jQuery(editor_id).barre_outils('edition').barre_previsualisation();
194        }
195         
196        else {
197            jQuery(editor_id).barre_outils('forum');
198        }
199    }
200}
201
202function CKEditor2SpipEditor(editor_id) {
203    if (jQuery(editor_id).length == 0) { return; }
204    jQuery('#swapeditor_' + stack[editor_id].md5)
205        .attr('disabled', true)
206        .attr('title', htmldecode('Chargement'))
207        .find('img')
208        .attr('src', 'https://www.eglise-niort.net/plugins/auto/ckeditor/v1.2.11/images/searching.gif');
209    jQuery(editor_id)
210        .attr('disabled', true)
211        .css('display', 'block')
212        .ckeditorGet().destroy();
213    ShowSpipUI(editor_id);
214    jQuery('#swapeditor_' + stack[editor_id].md5)
215        .attr('title', htmldecode('Utiliser CKEditor'))
216        .find('img')
217        .attr('src', 'https://www.eglise-niort.net/plugins/auto/ckeditor/v1.2.11/images/ckeditor.png')
218        .end()
219        .attr('disabled', false);
220    jQuery(editor_id)
221        .attr('disabled', false);
222}
223
224function SwapEditor(editor_id) {
225    if (jQuery(editor_id).length == 0) { return; }
226    try {
227        CKEditor2SpipEditor(editor_id);
228    } catch (e) {
229        SpipEditor2CKEditor(editor_id);
230    }
231}
232
233function contexteChange(editor_id) {
234    if (jQuery(editor_id).length == 0) { return; }
235    if (jQuery("#contexte_" + stack[editor_id].md5).length) {
236        var contexte = jQuery("#contexte_" + stack[editor_id].md5).val().match(/^([\.#])(.*)$/);
237        if (stack[editor_id].ctx) {
238            
239            if (stack[editor_id].ctx[1] == "#") {
240                
241                jQuery(stack[editor_id].n + ' iframe').contents().find('body').attr('id', '');
242            } else {
243                jQuery(stack[editor_id].n + ' iframe').contents().find('body').removeClass(stack[editor_id].ctx[2]);
244            }
245        }
246        stack[editor_id].ctx = contexte;
247        if (contexte) {
248            
249            if (contexte[1] == "#") {
250                
251                jQuery(stack[editor_id].n + ' iframe').contents().find('body').attr('id', contexte[2]);
252            } else {
253                
254                jQuery(stack[editor_id].n + ' iframe').contents().find('body').addClass(contexte[2]);
255            }
256        }
257    }
258}
259
260function on_submit_destroy_cke() {
261    for (name in CKEDITOR.instances) {
262        CKEDITOR.instances[name].destroy()
263    }
264}
265
266function cke_crayon_submit(editor_id) {
267    if (jQuery(editor_id).length == 0) { return; }
268    try {
269        
270        jQuery(editor_id).ckeditorGet().updateElement();
271    } catch (e) { /* rien */ }
272    jQuery(this).parents('.formulaire_crayon').submit();
273}
274
275function fullInitCKEDITOR(editor_ids) {
276    if (!editor_ids) editor_ids = [["textarea[name=texte]", "Full"]];
277    jQuery("input[type=submit]").click(on_submit_destroy_cke);
278    if (!CKEDITOR.fullInitDone) {
279        CKEDITOR.fullInitDone = true;
280        CKEDITOR.on('dialogDefinition', function (ev) {
281            var dialogName = ev.data.name,
282                dialogDefinition = ev.data.definition;
283            if (dialogName === 'about') {
284                var aboutTab = dialogDefinition.getContents('tab1');
285                aboutTab.style = 'height:280px;';
286                aboutTab.add({
287                    'type': 'html',
288                    'html': '<div class="cke_about_container">
288Copyright &copy; 2009 <a style="text-decoration:underline;color:blue;cursor:pointer;" href="https://zone.spip.net/trac/spip-zone/browser/spip-zone/_plugins_/ckeditor-spip-plugin">Plugin SPIP</a> - Frédéric Bonnaud, Mehdi Cherifi, Emmanuel Dreyfus</div>'
289                });
290            }
291            var advTab = dialogDefinition.getContents('advanced');
292            if (advTab) {
293                var advClasses = advTab.get('advCSSClasses');
294                if (advClasses) {
295                    advClasses['default'] = 'spip';
296                }
297            }
298        });
299        for (var plugin in CKEDITOR.ckConfig.loadExtraPlugins) {
300            CKEDITOR.plugins.addExternal(plugin, CKEDITOR.ckConfig.loadExtraPlugins[plugin]);
301        }
302    }
303    for (var id in editor_ids) {
304        if ((jQuery(editor_ids[id][0]).length > 0) && (jQuery(editor_ids[id][0]).css('display') != 'none')) {
305            var editor_id = editor_ids[id][0], editor_tb = editor_ids[id][1], crayon = null, editor_md5 = editor_ids[id][3];
306            if (jQuery(editor_id).parents("[id^=crayon_]").length > 0) { // sommes-nous appelé depuis un crayon ?
307                crayon = jQuery(editor_id).parents("[id^=crayon_]").attr('id');
308                if (!editor_id.match(/^\s*#/)) {
309                    editor_id = "#" + crayon + " " + editor_id;
310                }
311            }
312
313            try {
314                jQuery(editor_id).ckeditorGet();
315            } catch (e) {
316
317                var buttons = '';
318                if (typeof stack[editor_id] == 'undefined') {
319                    stack[editor_id] = {};
320                }
321                stack[editor_id].crayons = 0;
322                stack[editor_id].tb = editor_tb;
323                stack[editor_id].nobarre = (jQuery(editor_id).hasClass('no_barre') || CKEDITOR.ckeditmode == 'spip');
324                stack[editor_id].md5 = editor_md5;
325                if (!stack[editor_id].nobarre)
326                    jQuery(editor_id).addClass('no_barre');
327
328            if (jQuery('#after_' + editor_md5).length == 0) {
329                    jQuery(editor_id).after('<span id="after_' + editor_md5 + '"></span>');
330                     
331                if (CKEDITOR.version < CKEDITOR.ckpreferedversion) {
332                    var pref = 'CKEditor version %1 est installé, ce plugin préférerait la version %2. Veuillez d&#39;
332abord désintaller la version actuelle.';
333                    jQuery('#after_' + editor_md5).prepend(
334                        '<div class="erreur_message">' + pref.replace(/%2/, CKEDITOR.ckpreferedversion).replace(/%1/, CKEDITOR.version) + '</div>'
335                    );
336                }
337    
338            }
339
340            if (CKEDITOR.ckeditmode != 'ckeditor-exclu') {
341                buttons = buttons +
342                    '<button style="margin:0;padding:0;width:40px;height:24px;" type="button" id="swapeditor_' + editor_md5 + '" onclick="javascript:SwapEditor(\'' + editor_id + '\');" title="'
343                    + htmldecode(CKEDITOR.ckeditmode == 'spip' ? 'Utiliser CKEditor' : 'Utiliser l&#39;éditeur de SPIP')
344                    + '"><img src="https://www.eglise-niort.net/plugins/auto/ckeditor/v1.2.11/images/ckeditor.png"/></button>';
345            }
346
347            
348            ;
349            if (buttons && (jQuery('#before_' + editor_md5).length == 0)) {
350                var div = jQuery(editor_id);
351                var style = "width;100%;text-align:right;position:relative;top:-24px;height:0px;clear:both;";
352                if (div.length != 0) {
353                    div.before('<div id="before_' + editor_md5 + '" style="' + style + '"><a name="ancre_' + editor_md5 + '"></a>' + buttons + '</div>');
354                }
355            }
356            
357            if (crayon) {
358                jQuery('#' + crayon + ' .crayon-submit')
359                    .after('<button class="crayon-submit" onclick="javascript:return cke_crayon_submit(\'' + editor_id + '\');" title="Enregistrer">Enregistrer</button>')
360                    .remove();
361            }
362            if (CKEDITOR.ckeditmode != 'spip') {
363                SpipEditor2CKEditor(editor_id);
364            }
365        }
366    }
367    CKEDITOR.on("currentInstance", function (event) {
368        $('.cke_contents > iframe').each(function (i) {
369            var done = $(this)[0].contentWindow.document.execCommand('enableObjectResizing');
370        });
371    });
372}
373}

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.