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

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

[Autosize][beta] fix bug whith user tags


File size: 18.0 KB
Line 
1//==== cl_conflit  remplace $(... avec jQuery( ====
2
3//===================================================
4var detect = navigator.userAgent.toLowerCase();
5var OS, version;
6//==============================================================================
7browser = detect_browser();
8
9function detect_browser() {
10    mybrowser = {
11        browser: "",
12        konqueror: false,
13        chrome: false,
14        safari: false,
15        omniWeb: false,
16        opera: false,
17        firefox: false,
18        msie: false,
19        netscape: false
20    }
21    if (checkIt('konqueror')) { mybrowser.Konqueror = true; lbrowser = "konqueror"; OS = "Linux"; }
22    else if (checkIt('chrome')) { mybrowser.chrome = true; lbrowser = "chrome"; }
23    else if (checkIt('safari')) { mybrowser.safari = true; lbrowser = "safari"; }
24    else if (checkIt('omniweb')) { mybrowser.omniweb = true; lbrowser = "omniWeb"; }
25    else if (checkIt('opera')) { mybrowser.opera = true; lbrowser = "opera"; }
26    else if (checkIt('firefox')) { mybrowser.firefox = true; lbrowser = "firefox"; }
27
28    else if (checkIt('msie')) { mybrowser.msie = true; lbrowser = "msie"; }
29    else if (checkIt('compatible')) { mybrowser.NetscapeNavigator = true; lmybrowser.browser = "NetscapeNavigator"; version = detect.charAt(8); }
30    else lbrowser = "An unknown browser";
31    if (!version) version = detect.charAt(place + thestring.length);
32    if (!OS) {
33        if (checkIt('linux')) OS = "Linux";
34        else if (checkIt('x11')) OS = "Unix";
35        else if (checkIt('mac')) OS = "Mac";
36        else if (checkIt('win')) OS = "Windows";
37        else OS = "an unknown operating system";
38    }
39
40    mybrowser.browser = lbrowser;
41    return mybrowser
42
43
44};
45
46
47
48function checkIt(string) {
49    place = detect.indexOf(string) + 1;
50    thestring = string;
51    return place;
52}
53/*
54 
55*/
56
57
58konqueror = mybrowser.konqueror || false;
59chrome = mybrowser.chrome || false;
60safari = mybrowser.safari || false;
61omniWeb = mybrowser.omniWeb || false;
62opera = mybrowser.opera || false;
63firefox = mybrowser.firefox || false;
64msie = mybrowser.msie || false;
65netscape = mybrowser.netscape || false;
66
67var time_out = 0;
68//===================================================
69
70nbpa = 0;
71var Fn;
72function conflit(element, nc) {
73    //--- cl_conflit
74if (typeof MooTools=="undefined" && typeof  Prototype=="undefined" ) {
75       ret_element = jQuery(element);
76        return ret_element;
77    }
78    //====================================================
79    if (typeof (element) == "string") {
80        if (element.match("^#|.ui", "gi")) {
81            ret_element = jQuery(element);
82            return ret_element;
83        }
84   
85    }
86
87    var retour = (getStackTrace());
88    Fn = retour.fn;
89    retour = retour.state;
90
91    var ret_element = "";
92    if (retour.match(RegExp("jQuery", "gi"))) {
93        ret_element = jQuery(element);
94    }
95    else if (retour.match(RegExp("rv_gmaps", "gi"))) {
96    try{
97        ret_element = myjQuery().$Prototype(element);
98        }
99        catch(e)
100        {
101
102         ret_element = myjQuery().$Prototype(element);
103
104        }
105    } else if (retour.match(RegExp("GMaps", "gi"))) {     
106
107        ret_element = jQuery(element);
108    } else if (retour.match(RegExp("pamooramics", "gi"))) {
109
110        ret_element = jQuery().$Pamoorama(element);
111
112        if (retour.match(RegExp("init_", "gi"))) {
113
114        }
115       
116
117    } else if (retour.match(RegExp("luciano", "gi"))) {
118         
119
120        ret_element = jQuery().$Luciano(element, nc);
121
122    } else if (retour.match(RegExp("jQuery", "gi"))) {
123        ret_element = jQuery(element);
124    }
125
126    if (ret_element != "")
127        return ret_element;
128
129    if (typeof (element) == "string") {
130        if (element.match("^#|.ui", "gi")) {
131            ret_element = jQuery(element);
132            return ret_element;
133        }
134    } else if (typeof (element) == "function") {
135        fn = element.toString();
136        if (fn.match("#pwg|open", "gi")) {
137            ret_element = jQuery(element);
138            return ret_element;
139        }
140    } else if (element == document) {
141
142        ret_element = jQuery(element);
143        return ret_element;
144
145
146    } else if (element == window) {
147
148        ret_element = jQuery(element);
149        return ret_element;
150
151
152    }
153    tp0 = typeof (element);
154
155    ret_element = jQuery(element);
156    if (DEBUG == "true") {
157        retour = (getStackTrace());
158        alert("element : " + element + " retour : " + retour + "Fonctions:" + Fn);
159
160    }
161    return ret_element;
162} // conflit(element,nc)
163//======================================================
164/*
165*
166*
167*/
168//======================================================
169jQuery(document).ready(
170       function (jQuery) {
171            jQuery(window).load(function () {
172             //============================================================
173             jQuery("#icon_gmaps").bind('click', function () {
174
175                jQuery('html,body').stop().scrollTop(0);
176                jQuery('html,body').stop().scrollLeft(0);
177                jQuery(".ui-widget-overlay").css("opacity", "0.75");
178
179                l1 = (jQuery(window).width() - (jQuery(".gmapsPopup").width())) / 2;
180                h1 = (jQuery(window).height() - (jQuery(".gmapsPopup").height())) / 2;
181
182                jQuery(".gmapsPopup").css("left", l1 + "px");
183                jQuery(".gmapsPopup").css("top", h1 + "px");
184            })
185            //============================================================= 
186            if (typeof(Parent)=="undefined")
187                Parent = "#theImage";
188                info_image = jQuery(Parent).infos();
189                p0 = jQuery(Parent);
190                if (p0.length > 0) {   
191                    //======================================================
192                    if (theme.match("gally", "gi"))
193                    if (jQuery.isFunction(inittoolbar)) {
194                        if (typeof (currentTab) == "undefined") inittoolbar();
195                            else initializeImageMode("resize");
196                        if (info_image.position != "static") {
197                            //==== compatibilité Gally/LLGBO ===
198                            //--- passage relative ==> static ===/
199                            jQuery(Parent).css({ position: "static" } );
200                            jQuery("#imageToolBar").css({ position: "relative", top: "0px" });
201                        };
202                     }
203                }
204            //   jQuery(window).resize();
205        });
206    //=============================================================       
207    //  $ = _$2; ;
208});
209
210
211
212//=========================================================
213
214jQuery.fn.extend({
215
216//---------------- luciano -------------------------------
217$Luciano: function (el, nc) {
218return 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//====================================
496test_conflit = false;
497 librairies =new Array;
498
499
500
501$_ = $;
502function save_framework(page) {
503    try {
504        Conflit = { version: cl_version, name: cl_plugin };
505    } catch (e) {
506
507    }
508        $_2 = $;
509    return
510    }
511
512(function ($) {
513    $(document).ready(function () {   
514          //=================================================
515          if (typeof  jQuery.fn.infos !="function")
516          {
517               jQuery=myjQuery;
518               $=my$ ;
519               }
520        });
521
522})(jQuery);
523
524if(test_conflit!=true)
525{
526//--------------------------------------------------------------
527$_0 = $;
528 
529        function $(element, nc0) {
530            if (typeof  jQuery.fn.infos !="function") 
531             if (typeof  myjQuery !="undefined") 
532                 jQuery=myjQuery;   
533             a = conflit(element, nc0);
534            return a;
535        }
536       
537        if (typeof ($.ajax) != "function") {
538            $.ajax = function (origSettings) {
539                jQuery.ajax(origSettings);
540            }
541
542
543            $.parseJSON = function (msg) {
544                return jQuery.parseJSON(msg);
545            }
546
547
548        }
549        //============================================
550        /* url (String): URl de la page à charger
551        * params (Map): (optionnel) paires de clé/valeur qui seront envoyées au serveur.
552        * callback (Fonction): (optionnel) fonction qui sera éxécutée quand les données sera chargées.
553        * type (String): (optionnel) format des données renvoyées à la fonction de callback
554        */
555        if (typeof ($.get) != "function") {
556            $.get = function ( a, b, c, d) {
557                return jQuery.get(a, b, c,d );
558            }
559        }
560        if (typeof ($.post) != "function") {
561
562            $.post = function (a, b, c,d) {
563                return jQuery.post(a, b, c, d);
564            }
565            ;
566
567        }
568       
569
570 
571}
572//--------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.