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

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

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