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

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

[extensions] Autosize fix compatibility with 2.4, new options

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