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

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

[cl_conflit] fix bug whith user $.post


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