source: extensions/Autosize/js/conflit.js @ 8735

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

[Autosize][beta] compatibility whith GMAP


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