source: extensions/cl_conflit/js/conflit.js @ 7944

Last change on this file since 7944 was 7944, checked in by cljosse, 13 years ago

[cl_conflit] fix bug cl_conflit/autosize

File size: 18.4 KB
Line 
1//==== autosize  remplace $(... avec jQuery( ====
2/*
3*[gmaps=id:1;width:800;height:640;]
4*       Luciano rv_gmaps
5* pb : Gmaps llgbo pamooramics rv_map
6*/
7var d1 = 0;
8var init_tb = 0;
9var dom = {};
10if (typeof jQuery == 'undefined') {
11    alert(" jQuery n'est pas chargé");
12} else {
13    // jQuery est chargé
14}
15
16//===================================================
17var detect = navigator.userAgent.toLowerCase();
18var OS, version;
19//==============================================================================
20browser = detect_browser();
21function detect_browser() {
22    mybrowser = {
23        browser: "",
24        konqueror: false,
25        chrome: false,
26        safari: false,
27        omniWeb: false,
28        opera: false,
29        firefox: false,
30        msie: false,
31        netscape: false
32    }
33    if (checkIt('konqueror')) { mybrowser.Konqueror = true; lbrowser = "konqueror"; OS = "Linux"; }
34    else if (checkIt('chrome')) { mybrowser.chrome = true; lbrowser = "chrome"; }
35    else if (checkIt('safari')) { mybrowser.safari = true; lbrowser = "safari"; }
36    else if (checkIt('omniweb')) { mybrowser.omniweb = true; lbrowser = "omniWeb"; }
37    else if (checkIt('opera')) { mybrowser.opera = true; lbrowser = "opera"; }
38    else if (checkIt('firefox')) { mybrowser.firefox = true; lbrowser = "firefox"; }
39
40    else if (checkIt('msie')) { mybrowser.msie = true; lbrowser = "msie"; }
41    else if (checkIt('compatible')) { mybrowser.NetscapeNavigator = true; lmybrowser.browser = "NetscapeNavigator"; version = detect.charAt(8); }
42    else lbrowser = "An unknown browser";
43    if (!version) version = detect.charAt(place + thestring.length);
44    if (!OS) {
45        if (checkIt('linux')) OS = "Linux";
46        else if (checkIt('x11')) OS = "Unix";
47        else if (checkIt('mac')) OS = "Mac";
48        else if (checkIt('win')) OS = "Windows";
49        else OS = "an unknown operating system";
50    }
51
52    mybrowser.browser = lbrowser;
53    return mybrowser
54
55
56};
57
58
59
60function checkIt(string) {
61    place = detect.indexOf(string) + 1;
62    thestring = string;
63    return place;
64}
65/*
66 
67*/
68
69
70konqueror = mybrowser.konqueror || false;
71chrome = mybrowser.chrome || false;
72safari = mybrowser.safari || false;
73omniWeb = mybrowser.omniWeb || false;
74opera = mybrowser.opera || false;
75firefox = mybrowser.firefox || false;
76msie = mybrowser.msie || false;
77netscape = mybrowser.netscape || false;
78
79
80//========================================
81/*function $defined(A) {
82$ = _$2; //   ;
83return A != undefined;
84}
85*/
86
87var time_out = 0;
88//===================================================
89
90nbpa = 0;
91var Fn;
92function conflit(element, nc) {
93    //--- cl_conflit   
94    var retour = (getStackTrace());
95    Fn = retour.fn;
96    retour = retour.state;
97
98    n = document;
99    v = window;
100    var ret_element = "";
101    if (retour.match(RegExp("jQuery", "gi"))) {
102        ret_element = jQuery(element);
103    }
104    else if (retour.match(RegExp("rv_gmaps", "gi"))) {
105        ret_element = jQuery().$Prototype(element);
106    } else if (retour.match(RegExp("GMaps", "gi"))) {
107       
108
109        ret_element = jQuery(element);
110    } else if (retour.match(RegExp("pamooramics", "gi"))) {
111
112        ret_element = jQuery().$Pamoorama(element);
113
114        if (retour.match(RegExp("init_", "gi"))) {
115
116        }
117        nbpa += 1;
118
119    } else if (retour.match(RegExp("luciano", "gi"))) {
120         
121
122        ret_element = jQuery().$Luciano(element, nc);
123
124    } else if (retour.match(RegExp("jQuery", "gi"))) {
125        ret_element = jQuery(element);
126    }
127
128    if (ret_element != "")
129        return ret_element;
130
131    if (typeof (element) == "string") {
132        if (element.match("^#|.ui", "gi")) {
133            ret_element = jQuery(element);
134            return ret_element;
135        }
136    } else if (typeof (element) == "function") {
137        fn = element.toString();
138        if (fn.match("#pwg|open", "gi")) {
139            ret_element = jQuery(element);
140            return ret_element;
141        }
142    } else if (element == document) {
143
144        ret_element = jQuery(element);
145        return ret_element;
146
147
148    }
149    tp0 = typeof (element);
150
151    ret_element = jQuery(element);
152    if (DEBUG == "true") {
153        retour = (getStackTrace());
154        alert("element : " + element + " retour : " + retour + "Fonctions:" + Fn);
155
156    }
157    return ret_element;
158} // conflit(element,nc)
159
160jQuery(document).ready(
161    function (jQuery) {
162        jQuery(window).load(function () {
163            //============================================================
164            jQuery("#icon_gmaps").bind('click', function () {
165
166                jQuery('html,body').stop().scrollTop(0);
167                jQuery('html,body').stop().scrollLeft(0);
168                jQuery(".ui-widget-overlay").css("opacity", "0.75");
169
170                l1 = (jQuery(window).width() - (jQuery(".gmapsPopup").width())) / 2;
171                h1 = (jQuery(window).height() - (jQuery(".gmapsPopup").height())) / 2;
172
173                jQuery(".gmapsPopup").css("left", l1 + "px");
174                jQuery(".gmapsPopup").css("top", h1 + "px");
175            })
176            //============================================================= 
177            if (typeof(Parent)=="undefined")
178                Parent = "#theImage";
179
180            info_image = jQuery(Parent).infos();
181            p0 = jQuery(Parent);
182            if (p0.length > 0) {   
183
184                //======================================================
185                if (theme.match("gally", "gi"))
186                    if (jQuery.isFunction(inittoolbar)) {
187                        if (typeof (currentTab) == "undefined") inittoolbar();
188                        else initializeImageMode("resize");
189                   
190
191                    if (info_image.position != "static") {
192                    //==== compatibilité Gally/LLGBO ===
193                    //--- passage relative ==> static ===/
194                    jQuery(Parent).css({ position: "static" } );
195                    jQuery("#imageToolBar").css({ position: "relative", top: "0px" });
196                    };
197                }
198            }
199            //   jQuery(window).resize();
200
201        });
202        //=============================================================       
203
204        //  $ = _$2; ;
205
206
207    })
208;
209
210
211
212//=========================================================
213
214jQuery.fn.extend({
215
216    //---------------- luciano -------------------------------
217    $Luciano: function (el, nc) {
218        return document.id(el, nc, this.document);
219    },
220    //=============== PaMOOramics ===========================
221
222    $Pamoorama: function (B) {
223
224
225        if (!B) {
226            if (typeof (B) == "boolean") return null;
227
228        }
229
230        try {
231            if (B.htmlElement) {
232                return Garbage.collect(B);
233            }
234        } catch (e) {
235
236        }
237
238        if ([window, document].contains(B)) { return B; }
239        var A = $type(B);
240        if (A == "string") { B = document.getElementById(B); A = (B) ? "element" : false; }
241        if (A != "element") {
242            return null;
243        }
244        if (B.htmlElement) { return Garbage.collect(B); }
245        if (["object", "embed"].contains(B.tagName.toLowerCase())) { return B; }
246        $extend(B, Element.prototype);
247        B.htmlElement = function () { };
248        try { return Garbage.collect(B); } catch (e) {
249            return;
250        }
251
252    },
253    //===================================================
254    $Prototype: function (element) {
255        //======== prototype.js =====================
256        if (arguments.length > 1) {
257            for (var i = 0, elements = [], length = arguments.length; i < length; i++)
258                elements.push($(arguments[i]));
259            return elements;
260        }
261        if (typeof element == "string")
262            element = document.getElementById(element);
263
264        return Element.extend(element);
265
266        try {
267            new_element = Element.extend(element);
268        } catch (e) {
269            return new_element;
270        }
271        return new_element;
272    }
273    //=========================================================
274});    // fin extend
275
276
277
278/*
279* mootools.js  version: "1.11"
280* pamoorama0.3.js
281*
282* main.js (google maps)
283* prototype.js(mootool version: "1.62")
284* windows.js
285*
286*/
287function getStackTrace() {
288    var callstack = [];
289    var isCallstackPopulated = false;
290    try {
291        i.dont.exist += 0; //doesn't exist- that's the point
292    } catch (e) {
293        var retcallstack = [];
294        var e_message = e.message;
295        var e_stack = e.stack;
296        var state_ff = "";
297        if (e_stack) { //Firefox Opera 3.6
298            //=== test fichier source =============
299            var lines = e.stack.split("\n");
300            for (var i = 0, len = lines.length; i < len; i++) {
301                var Src_Match = lines[i];
302                if (Src_Match.match(/conflit.js/)) {
303                    //
304                } else {
305                    if (Src_Match.match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
306                        callstack.push(Src_Match); //php?
307                    } else {
308                        callstack.push(Src_Match);
309                    }
310                    if (Src_Match.match("GMaps|applyMap|markupMaps|applyMarkers")) {
311                        callstack.push("GMaps");
312                        isCallstackPopulated = true;
313                        break;
314                    }
315                    if (Src_Match.match("rv_gmaps", "gi")) {
316                        callstack.push("rv_gmaps");
317                        isCallstackPopulated = true;
318                        break;
319                    }
320                    if (Src_Match.match("paMOOramics")) {
321                        isCallstackPopulated = true;
322                        callstack.push("paMOOramics");
323                        break;
324                    }
325                    if (Src_Match.match("Luciano", "gi")) {
326                        callstack.push("Luciano");
327                        isCallstackPopulated = true;
328                        break;
329                    }
330                    if (Src_Match.match("main")) {
331
332                        callstack.push("main");
333                        isCallstackPopulated = true;
334                        break;
335                    }
336                    if (Src_Match.match("jQuery", "gi")) {
337                        callstack.push("jQuery");
338                        isCallstackPopulated = true;
339                     
340                        break;
341                    }
342                }
343            }
344            //callstack.shift();
345            state_ff = callstack.join('\n');
346            isCallstackPopulated = false;
347        }
348        if (window.opera && e.message && isCallstackPopulated == false) {
349            callstack = [];
350            //Opera =================================
351            var lines = e.message.split("\n");
352            for (var i = 0, len = lines.length; i < len; i++) {
353                if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
354                    var entry = lines[i];
355                    //Append next line also since it has the file info
356                    if (lines[i + 1]) {
357                        entry += " at " + lines[i + 1];
358                        i++;
359                    }
360                    callstack.push(entry);
361                    //isCallstackPopulated = true;
362                }
363            }
364
365        }
366        //===== fin Opera======================================
367    }
368    if (!isCallstackPopulated) { //IE and Safari
369        var currentFunction = arguments.callee.caller;
370        //next
371        callstack = [];
372        all_functions = [];
373        state = "";
374        if (currentFunction == null) {
375            return ("");
376        }
377        states = [];
378        var fn1 = currentFunction.toString(); // fonction d'appel local (conflit)
379
380        currentFunction = currentFunction.caller;
381        var fn2 = currentFunction.toString(); // fonction d'appel local (conflit)
382        currentFunction = currentFunction.caller;
383        //$family
384
385        while (currentFunction) {
386            var fn = currentFunction.toString();
387            all_functions.push(fn);
388            var fname = fn.substring(fn.indexOf("function") + 8, fn.indexOf("(")) || " ";
389            if (fname != " ") {
390
391                jQuery.noop;
392                if (states.length > 0) break;
393
394                // if (fname != " $") callstack.push(fn);
395            } if (fname != "") {
396                jQuery.noop;
397                // if (fname != " $") callstack.push(fn);
398            }
399            callstack.push(fn);
400
401            if (fn.match(RegExp("jquery|switchmenu|switchTabs|switchInterface|gally|initializeImageMode", "gi"))) {
402                states.push('jQuery');
403                break;
404            }
405            if (fn.match(RegExp("dialog..open", "gi"))) {
406                states.push('GMaps');
407                break;
408            }
409            if (fn.match(RegExp("GMaps|applyMap|markupMaps|applyMarkers", "gi"))) {
410                states.push('GMaps');
411                break;
412            }
413            //======================
414            //? bubble 
415            Expression = new RegExp("\\$", "gi")
416            if (fn.match(Expression)) {
417                if (fn.match(RegExp("rateForm", "gi"))) {
418
419                    states.push('Luciano');
420                    break;
421                }
422            }
423            // "window.fireEvent('domready')"
424            Expression = new RegExp("window.fireEvent", "gi")
425            if (fn.match(Expression)) {  //luciano
426                // "window.fireEvent('domready')"
427                Expression = new RegExp("window.fireEvent..domready..", "gi")
428                if (fn.match(Expression)) {
429                    states.push('Luciano');
430                    break;
431                }
432            }
433            if (fn.match(RegExp("(splat|buildFrameWork|photoNext)", "gi"))) {  //luciano
434
435                states.push('Luciano');
436                break;
437            }
438            //======================
439            if (fn.match(RegExp("_footer|ie_ready|makeDraggable|droppables", "gi"))) {
440
441                states.push('paMOOramics');
442              break;
443          }
444          //window_1290934905697_top
445          if (fn.match(RegExp("window_..|WindowUtilities", "gi"))) {
446              states.push('rv_gmaps');
447              break;
448          }
449          if (fn.match(RegExp("that.overlayOpacity", "gi"))) {
450              states.push('rv_gmaps');
451              break;
452          }
453          if (fn.match(RegExp("For backward compatibility like win", "gi"))) {
454              states.push('rv_gmaps');
455              break;
456          }
457          if (fn.match(RegExp("overlay_modal|HTMLDivElement|constraintPad", "gi"))) {
458              states.push('rv_gmaps');
459              break;
460          }
461
462            if (fn.match(RegExp("__content|__method|observe|responder|stopobserving|fireContentLoadedEvent", "gi"))) {
463                states.push('rv_gmaps');
464                break;
465            }
466
467
468            if (all_functions.length > 50) 
469            break;
470
471
472            currentFunction = currentFunction.caller;
473        }
474
475    }
476  // state_ff + "|" +
477    state = states.join('\n');
478    if (state == "") {
479       
480        if (DEBUG == "true") {
481            Fn = all_functions.join('\n');
482            try {
483                alert(Conflit.name + Conflit.version + "\n Appel non trouvée:" + fn1 + "\n" + Fn + "\n Firefox(retour):" + state_ff);
484            } catch (e) {
485            }
486        }
487
488 
489        state = state_ff;
490    }
491
492    Fn = all_functions;
493    return { state: state, fn: callstack.join('\n'),fn1:fn2 };
494}
495//====================================
496
497
498(function ($) {
499    $(document).ready(function () {
500        jQuery(window).load(function () {
501            a = jQuery(':Description');
502        });
503    });
504    //==============================================
505    librairies=[];
506    jQuery.extend(jQuery.expr[':'], {
507        // Nom du sélecteur personnalisé
508        Description: function (a) {
509            n = jQuery(a).infos();
510            if (n.id != "") {
511                //alert("<" + n.nodeName  +" id= " + n.id    + " >") ;
512            }
513            if (n.nodeName == "SCRIPT")
514                if (a.src == "") {
515                    Match = jQuery(a).html();
516                    /*
517                    if ( Match.match(new RegExp("jQuery", "gi") )) {
518                    alert(n.id + n.nodeName + a.outerHTML ) ;
519                    }
520                    if ( Match.match(new RegExp("ajax", "gi") )) {
521                    alert(n.id + n.nodeName + a.outerHTML ) ;
522                    }
523                    */
524                    if (Match.match(new RegExp("\\$", "gi"))) {
525
526                        if (Match.match(new RegExp("ajax", "gi"))) {
527                            //     alert(n.id + n.nodeName + a.outerHTML);
528
529                        }
530                    }
531                    if (Match.match(new RegExp("pamoorama", "ig"))) {
532
533                        //     alert(n.id + n.nodeName + a.innerHTML);
534
535                    }
536                } else {
537
538                    if (a.src.match(RegExp("mootools|pamooramic|luciano", "gi"))) {
539                        jQuery.noop;
540                        librairies.push(a.src);
541                    }
542
543                }
544
545            return a;
546
547        }
548    }); //fin extend
549    /*
550    *
551    */
552
553
554
555
556
557
558})(jQuery);
559
560 
561 
562$_0= $;
563function $(element, nc0) {
564    a = conflit(element, nc0);
565    return a;
566}
567if (typeof ($.ajax) != "function") {
568    $.ajax = function (origSettings) {
569        jQuery.ajax(origSettings);
570    }
571
572
573    $.parseJSON = function (msg) {
574        return jQuery.parseJSON(msg);
575    }
576
577
578}
579//============================================
580/* url (String): URl de la page à charger
581* params (Map): (optionnel) paires de clé/valeur qui seront envoyées au serveur.
582* callback (Fonction): (optionnel) fonction qui sera éxécutée quand les données sera chargées.
583* type (String): (optionnel) format des données renvoyées à la fonction de callback
584*/
585if (typeof ($.get) != "function") {
586    $.get = function ( a, b, c, d) {
587        return jQuery.get(a, b, c,d );
588    }
589
590
591}
592 
593
594$_ = $;
595function save_framework(page) {
596    try {
597        Conflit = { version: cl_version, name: cl_plugin };
598    } catch (e) {
599
600    }
601   
602    $_2 = $;
603    return
604
605}
606
Note: See TracBrowser for help on using the repository browser.