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

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

[extensions] autosize compatibility with pamooramics & gmaps

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