source: extensions/cl_conflit/js/conflit.js @ 15907

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

[cl_conflit] script compatibility with piwigo 2.2

File size: 17.3 KB
Line 
1//==== cl_conflit  remplace $(... avec jQuery( ====
2//===================================================
3var detect = navigator.userAgent.toLowerCase();
4//   $_SERVER['HTTP_USER_AGENT'] ;
5var OS, version;
6//==============================================================================
7browser = detect_browser();
8function detect_browser() {
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,
19        netscape: false,
20        seamonkey: false 
21    }
22    if (checkIt('konqueror')) { mybrowser.Konqueror = true; lbrowser = "konqueror"; OS = "Linux"; }
23    else if (checkIt('seamonkey')) { mybrowser.seamonkey = true; lbrowser = "seamonkey"; }
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    }
41    mybrowser.version = version;
42    mybrowser.OS = OS;
43    mybrowser.browser = lbrowser;
44    return mybrowser
45};
46function checkIt(string) {
47    place = detect.indexOf(string) + 1;
48    thestring = string;
49    return place;
50}
51
52/*
53 
54*/
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;
63var time_out = 0;
64//===================================================
65nbpa = 0;
66var Fn;
67function conflit(element, nc) {
68    //--- cl_conflit
69    if (typeof MooTools == "undefined" && typeof Prototype == "undefined") {
70        ret_element = jQuery(element);
71        return ret_element;
72    }
73    //====================================================
74    if (typeof (element) == "string") {
75        if (element.match("^#|.ui|html", "gi")) {
76            ret_element = jQuery(element);
77            return ret_element;
78        }
79
80    }
81
82    var retour = (getStackTrace());
83    Fn = retour.fn;
84    retour = retour.state;
85
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"))) {
91        try {
92            ret_element = myjQuery().$Prototype(element);
93        }
94        catch (e) {
95
96            ret_element = myjQuery().$Prototype(element);
97
98        }
99    } else if (retour.match(RegExp("GMaps", "gi"))) {
100
101        ret_element = jQuery(element);
102    } else if (retour.match(RegExp("pamooramics", "gi"))) {
103
104        ret_element = jQuery().$Pamoorama(element);
105
106        if (retour.match(RegExp("init_", "gi"))) {
107
108        }
109
110
111    } else if (retour.match(RegExp("luciano", "gi"))) {
112
113
114        ret_element = jQuery().$Luciano(element, nc);
115
116    } else if (retour.match(RegExp("jQuery", "gi"))) {
117        ret_element = jQuery(element);
118    }
119
120    if (ret_element != "")
121        return ret_element;
122
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
136        ret_element = jQuery(element);
137        return ret_element;
138
139
140    } else if (element == window) {
141
142        ret_element = jQuery(element);
143        return ret_element;
144
145
146    }
147    tp0 = typeof (element);
148
149    ret_element = jQuery(element);
150    if (DEBUG == "true") {
151        retour = (getStackTrace());
152        alert("element : " + element + " retour : " + retour + "Fonctions:" + Fn);
153
154    }
155    return ret_element;
156} // conflit(element,nc)
157//======================================================
158/*
159*
160*
161*/
162//======================================================
163jQuery(document).ready(
164    function (jQuery) {
165        jQuery(window).load(function () {
166            //============================================================
167            jQuery("#icon_gmaps").bind('click', function () {
168
169                jQuery('html,body').stop().scrollTop(0);
170                jQuery('html,body').stop().scrollLeft(0);
171                jQuery(".ui-widget-overlay").css("opacity", "0.75");
172
173                l1 = (jQuery(window).width() - (jQuery(".gmapsPopup").width())) / 2;
174                h1 = (jQuery(window).height() - (jQuery(".gmapsPopup").height())) / 2;
175
176                jQuery(".gmapsPopup").css("left", l1 + "px");
177                jQuery(".gmapsPopup").css("top", h1 + "px");
178            })
179            //============================================================= 
180            //   jQuery(window).resize();
181        });
182        //  $ = _$2; ;
183    });
184//=========================================================
185jQuery.fn.extend({
186    $: function (el, nc) {
187        a = conflit(el, nc);
188        return a;
189    },
190
191    //---------------- luciano -------------------------------
192    $Luciano: function (el, nc) {
193        return document.id(el, nc, this.document);
194    },
195    //=============== PaMOOramics ===========================
196
197    $Pamoorama: function (B) {
198
199
200        if (!B) {
201            if (typeof (B) == "boolean") return null;
202
203        }
204
205        try {
206            if (B.htmlElement) {
207                return Garbage.collect(B);
208            }
209        } catch (e) {
210
211        }
212
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        }
226
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);
238
239        return Element.extend(element);
240
241        try {
242            new_element = Element.extend(element);
243        } catch (e) {
244            return new_element;
245        }
246        return new_element;
247    }
248    //=========================================================
249});    // fin extend
250
251
252
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*/
262function getStackTrace() {
263    var callstack = [];
264    var isCallstackPopulated = false;
265    try {
266        i.dont.exist += 0; //doesn't exist- that's the point
267    } catch (e) {
268        var retcallstack = [];
269        var e_message = e.message;
270        var e_stack = e.stack;
271        var state_ff = "";
272        if (e_stack) { //Firefox Opera 3.6
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);
284                    }
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")) {
306
307                        callstack.push("main");
308                        isCallstackPopulated = true;
309                        break;
310                    }
311                    if (Src_Match.match("jQuery", "gi")) {
312                        callstack.push("jQuery");
313                        isCallstackPopulated = true;
314
315                        break;
316                    }
317                }
318            }
319            //callstack.shift();
320            state_ff = callstack.join('\n');
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                }
338            }
339
340        }
341        //===== fin Opera======================================
342    }
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)
354
355        currentFunction = currentFunction.caller;
356        var fn2 = currentFunction.toString(); // fonction d'appel local (conflit)
357        currentFunction = currentFunction.caller;
358        //$family
359
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 != " ") {
365
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            }
374            callstack.push(fn);
375
376            if (fn.match(RegExp("jquery|switchmenu|switchTabs|switchInterface|gally|initializeImageMode", "gi"))) {
377                states.push('jQuery');
378                break;
379            }
380            if (fn.match(RegExp("dialog..open", "gi"))) {
381                states.push('GMaps');
382                break;
383            }
384            if (fn.match(RegExp("GMaps|applyMap|markupMaps|applyMarkers", "gi"))) {
385                states.push('GMaps');
386                break;
387            }
388            //======================
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            //======================
414            if (fn.match(RegExp("_footer|ie_ready|makeDraggable|droppables", "gi"))) {
415
416                states.push('paMOOramics');
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            }
436
437            if (fn.match(RegExp("__content|__method|observe|responder|stopobserving|fireContentLoadedEvent", "gi"))) {
438                states.push('rv_gmaps');
439                break;
440            }
441
442
443            if (all_functions.length > 50)
444                break;
445
446
447            currentFunction = currentFunction.caller;
448        }
449
450    }
451    // state_ff + "|" +
452    state = states.join('\n');
453    if (state == "") {
454
455        if (DEBUG == "true") {
456            Fn = all_functions.join('\n');
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            }
461        }
462
463
464        state = state_ff;
465    }
466
467    Fn = all_functions;
468    return { state: state, fn: callstack.join('\n'), fn1: fn2 };
469}
470//====================================
471
472librairies = new Array;
473$_ = $;
474function save_framework(page) {
475    // theGategoryPage,theRegisterPage
476    // thePicturePage
477    // si admin.php page = "",theIdentificationPage
478    try {
479        Conflit = { version: cl_version, name: cl_plugin };
480    } catch (e) {
481
482    }
483    if (jQuery('#browser').length > 0) {
484        jQuery('#browser').val(browser.browser);
485    }
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        }
508    }
509
510    $_2 = $;
511    return
512}
513
514(function ($) {
515    $(document).ready(function () {
516        //=================================================
517        if (typeof jQuery.fn.infos != "function") {
518            jQuery = myjQuery;
519            $ = my$;
520        }
521    });
522
523})(jQuery);
524
525if (typeof MooTools == "undefined" && typeof Prototype == "undefined") {
526
527} else {}
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    }
537    //=== ajout des fonctions jQuery ===
538    jQuery.extend($, jQuery);
539
540
541    //--------------------------------------------------------------
542
Note: See TracBrowser for help on using the repository browser.