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

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

[extensions] autosize compatiblity with gmaps(Version 1.3.0a)

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