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

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

[cl_conflit] compatibility whith piwishack


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