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

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

[Autosize][beta] compatibility whith piwigo 2.2


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