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

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

[extensions] Autosize fix compatibility with theme hr_os_xl

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();
8image_w = 600;
9image_h = 400
10
11function detect_browser() {
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,
22        netscape: false,
23        seamonkey: false
24    }
25    if (checkIt('konqueror')) { mybrowser.Konqueror = true; lbrowser = "konqueror"; OS = "Linux"; }
26    else if (checkIt('seamonkey')) { mybrowser.seamonkey = true; lbrowser = "seamonkey"; }
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    }
44    mybrowser.version = version;
45    mybrowser.OS = OS;
46    mybrowser.browser = lbrowser;
47    return mybrowser
48};
49function checkIt(string) {
50    place = detect.indexOf(string) + 1;
51    thestring = string;
52    return place;
53}
54
55/*
56
57*/
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;
66var time_out = 0;
67//===================================================
68nbpa = 0;
69var Fn;
70if (typeof MooTools == "undefined" && typeof Prototype == "undefined") {
71
72} else {
73  $mootools = $;
74}
75//====================================================
76function conflit(element, nc) {
77    //--- cl_conflit
78    if (typeof MooTools == "undefined" && typeof Prototype == "undefined") {
79        ret_element = jQuery(element);
80        return ret_element;
81    }
82    //====================================================
83    if (typeof (element) == "string") {
84        if (element.match("^#|.ui|html", "gi")) {
85            ret_element = jQuery(element);
86            return ret_element;
87        }
88
89    }
90
91    var retour = (getStackTrace());
92    Fn = retour.fn;
93    retour = retour.state;
94
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"))) {
100        try {
101            ret_element = myjQuery().$Prototype(element);
102        }
103        catch (e) {
104
105            ret_element = myjQuery().$Prototype(element);
106
107        }
108    } else if (retour.match(RegExp("GMaps", "gi"))) {
109
110        ret_element = jQuery(element);
111    } else if (retour.match(RegExp("pamooramics", "gi"))) {
112
113        ret_element = jQuery().$Pamoorama(element);
114
115        if (retour.match(RegExp("init_", "gi"))) {
116
117        }
118
119
120    } else if (retour.match(RegExp("luciano", "gi"))) {
121
122
123        ret_element = jQuery().$Luciano(element, nc);
124
125    } else if (retour.match(RegExp("jQuery", "gi"))) {
126        ret_element = jQuery(element);
127    }
128
129    if (ret_element != "")
130    return ret_element;
131
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
145    ret_element = jQuery(element);
146    return ret_element;
147
148
149    } else if (element == window) {
150
151        ret_element = jQuery(element);
152        return ret_element;
153
154
155    }
156    tp0 = typeof (element);
157
158    ret_element = jQuery(element);
159 
160    if (typeof DEBUG_autosize == "boolean" && DEBUG_autosize == "true") {
161        retour = (getStackTrace());
162        alert("element : " + element + " retour : " + retour + "Fonctions:" + Fn);
163
164    }
165    return ret_element;
166} // conflit(element,nc)
167//======================================================
168/*
169*
170*
171*/
172//======================================================
173jQuery(document).ready(
174    function (jQuery) {
175      jQuery(window).load(function () {
176       
177        //============================================================
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          }
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)
193              obj.css({ backgroundColor: "green", color: "white" });
194            else
195              obj.css({ backgroundColor: "red", color: "white" });
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        });
215        jQuery("#icon_gmaps").bind('click', function () {
216          //jQuery("#iGMapsIconContent").dialog("open");
217          if (Version_pwg > '2.2.0')
218            return;
219          jQuery('html,body').stop().scrollTop(0);
220          jQuery('html,body').stop().scrollLeft(0);
221          jQuery(".ui-widget-overlay").css("opacity", "0.75");
222
223          l1 = (jQuery(window).width() - (jQuery(".gmapsPopup").width())) / 2;
224          h1 = (jQuery(window).height() - (jQuery(".gmapsPopup").height())) / 2;
225
226          jQuery(".gmapsPopup").css("left", l1 + "px");
227          jQuery(".gmapsPopup").css("top", h1 + "px");
228        })
229        //=============================================================
230        //   jQuery(window).resize();
231      });
232      //  $ = _$2; ;
233    });
234//=========================================================
235jQuery.fn.extend({
236    $: function (el, nc) {
237        a = conflit(el, nc);
238        return a;
239    },
240    removeListener: function (B, A) {
241  if (this.removeEventListener) { this.removeEventListener(B, A, false); } else {
242    this.detachEvent("on" + B, A);
243  } return this;
244 },
245    //---------------- luciano -------------------------------
246    $Luciano: function (el, nc) {
247        return document.id(el, nc, this.document);
248    },
249    //=============== PaMOOramics ===========================
250
251    $Pamoorama: function (B) {
252
253
254        if (!B) {
255            if (typeof (B) == "boolean") return null;
256
257        }
258
259        try {
260            if (B.htmlElement) {
261                return Garbage.collect(B);
262            }
263        } catch (e) {
264
265        }
266
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        }
280
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);
292
293        return Element.extend(element);
294
295        try {
296            new_element = Element.extend(element);
297        } catch (e) {
298            return new_element;
299        }
300        return new_element;
301    }
302    //=========================================================
303});    // fin extend
304
305
306
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*/
316function getStackTrace() {
317    var callstack = [];
318    var isCallstackPopulated = false;
319    try {
320        i.dont.exist += 0; //doesn't exist- that's the point
321    } catch (e) {
322        var retcallstack = [];
323        var e_message = e.message;
324        var e_stack = e.stack;
325        var state_ff = "";
326        if (e_stack) { //Firefox Opera 3.6
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);
338                    }
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")) {
360
361                        callstack.push("main");
362                        isCallstackPopulated = true;
363                        break;
364                    }
365                    if (Src_Match.match("jQuery", "gi")) {
366                        callstack.push("jQuery");
367                        isCallstackPopulated = true;
368
369                        break;
370                    }
371                }
372            }
373            //callstack.shift();
374            state_ff = callstack.join('\n');
375            isCallstackPopulated = false;
376           }
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                }
392            }
393
394        }
395        //===== fin Opera======================================
396    }
397    if (!isCallstackPopulated) { //IE and Safari
398        var currentFunction = arguments.callee.caller;
399        //next
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)
408
409        currentFunction = currentFunction.caller;
410        var fn2 = currentFunction.toString(); // fonction d'appel local (conflit)
411        currentFunction = currentFunction.caller;
412        //$family
413
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 != " ") {
419
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            }
428            callstack.push(fn);
429
430            if (fn.match(RegExp("jquery|switchmenu|switchTabs|switchInterface|gally|initializeImageMode", "gi"))) {
431                states.push('jQuery');
432                break;
433            }
434            if (fn.match(RegExp("dialog..open", "gi"))) {
435                states.push('GMaps');
436                break;
437            }
438            if (fn.match(RegExp("GMaps|applyMap|markupMaps|applyMarkers", "gi"))) {
439                states.push('GMaps');
440                break;
441            }
442            //======================
443            //? bubble
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            //======================
468            if (fn.match(RegExp("_footer|ie_ready|makeDraggable|droppables", "gi"))) {
469
470                states.push('paMOOramics');
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            }
490
491            if (fn.match(RegExp("__content|__method|observe|responder|stopobserving|fireContentLoadedEvent", "gi"))) {
492                states.push('rv_gmaps');
493                break;
494            }
495
496
497            if (all_functions.length > 50)
498                break;
499
500
501            currentFunction = currentFunction.caller;
502        }
503
504    }
505    // state_ff + "|" +
506    state = states.join('\n');
507    if (state == "") {
508
509      if (typeof DEBUG_autosize == "boolean" && DEBUG_autosize == "true") {
510            Fn = all_functions.join('\n');
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            }
515        }
516
517
518        state = state_ff;
519    }
520
521    Fn = all_functions;
522    return { state: state, fn: callstack.join('\n'), fn1: fn2 };
523}
524//====================================
525
526librairies = new Array;
527 
528function save_framework(page) {
529    // theGategoryPage,theRegisterPage
530    // thePicturePage
531    // si admin.php page = "",theIdentificationPage
532    try {
533        Conflit = { version: cl_version, name: cl_plugin };
534    } catch (e) {
535
536    }
537    if (jQuery('#browser').length > 0) {
538        jQuery('#browser').val(browser.browser);
539  }
540    if (typeof (Parent) == "undefined")
541        Parent = "#theImage";
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" });
557        }
558      } catch (e) {
559      }
560
561    }
562  }
563
564 
565  return
566}
567
568(function ($) {
569  jQuery(document).ready(function () {
570    //=================================================
571    if (typeof jQuery.fn.infos != "function") {
572      jQuery = myjQuery;
573      $ = my$;
574    }
575  });
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    }
583})(jQuery);
584
585 
586//--------------------------------------------------------------
587//=== ajout des fonctions jQuery ===
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.