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

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

[extensions] Autosize fix compatibility with theme hr_os_xl

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