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

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

[extensions] Autosize fix compatibility with gmaps

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