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

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

[extensions] Autosize fix bugs whith panorama

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