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

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

[Autosize][beta] compatibility with theme simple


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