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

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

[extensions] autosize compatibility with piwigo 2.2.ORC4

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