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

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

[autosize] compatiblity with gally 1.4.0

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