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

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

[extensions] autosize compatibility with theme gally

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