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

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

[extensions] Autosize fix compatibility with 2.4, clean up...

File size: 17.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();
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
267});    // fin extend
268
269
270
271/*
272* mootools.js  version: "1.11"
273* pamoorama0.3.js
274*
275* main.js (google maps)
276* prototype.js(mootool version: "1.62")
277* windows.js
278*
279*/
280function getStackTrace() {
281    var callstack = [];
282    var isCallstackPopulated = false;
283    try {
284        i.dont.exist += 0; //doesn't exist- that's the point
285    } catch (e) {
286        var retcallstack = [];
287        var e_message = e.message;
288        var e_stack = e.stack;
289        var state_ff = "";
290        if (e_stack) { //Firefox Opera 3.6
291            //=== test fichier source =============
292            var lines = e.stack.split("\n");
293            for (var i = 0, len = lines.length; i < len; i++) {
294                var Src_Match = lines[i];
295                if (Src_Match.match(/conflit.js/)) {
296                    //
297                } else {
298                    if (Src_Match.match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
299                        callstack.push(Src_Match); //php?
300                    } else {
301                        callstack.push(Src_Match);
302                    }
303                    if (Src_Match.match("GMaps|applyMap|markupMaps|applyMarkers")) {
304                        callstack.push("GMaps");
305                        isCallstackPopulated = true;
306                        break;
307                    }
308                    if (Src_Match.match("rv_gmaps", "gi")) {
309                        callstack.push("rv_gmaps");
310                        isCallstackPopulated = true;
311                        break;
312                    }
313                    if (Src_Match.match("paMOOramics")) {
314                        isCallstackPopulated = true;
315                        callstack.push("paMOOramics");
316                        break;
317                    }
318                    if (Src_Match.match("Luciano", "gi")) {
319                        callstack.push("Luciano");
320                        isCallstackPopulated = true;
321                        break;
322                    }
323                    if (Src_Match.match("main")) {
324
325                        callstack.push("main");
326                        isCallstackPopulated = true;
327                        break;
328                    }
329                    if (Src_Match.match("jQuery", "gi")) {
330                        callstack.push("jQuery");
331                        isCallstackPopulated = true;
332
333                        break;
334                    }
335                }
336            }
337            //callstack.shift();
338            state_ff = callstack.join('\n');
339            isCallstackPopulated = false;
340           }
341        if (window.opera && e.message && isCallstackPopulated == false) {
342            callstack = [];
343            //Opera =================================
344            var lines = e.message.split("\n");
345            for (var i = 0, len = lines.length; i < len; i++) {
346                if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
347                    var entry = lines[i];
348                    //Append next line also since it has the file info
349                    if (lines[i + 1]) {
350                        entry += " at " + lines[i + 1];
351                        i++;
352                    }
353                    callstack.push(entry);
354                    //isCallstackPopulated = true;
355                }
356            }
357
358        }
359        //===== fin Opera======================================
360    }
361    if (!isCallstackPopulated) { //IE and Safari
362        var currentFunction = arguments.callee.caller;
363        //next
364        callstack = [];
365        all_functions = [];
366        state = "";
367        if (currentFunction == null) {
368            return ("");
369        }
370        states = [];
371        var fn1 = currentFunction.toString(); // fonction d'appel local (conflit)
372
373        currentFunction = currentFunction.caller;
374        var fn2 = currentFunction.toString(); // fonction d'appel local (conflit)
375        currentFunction = currentFunction.caller;
376        //$family
377
378        while (currentFunction) {
379            var fn = currentFunction.toString();
380            all_functions.push(fn);
381            var fname = fn.substring(fn.indexOf("function") + 8, fn.indexOf("(")) || " ";
382            if (fname != " ") {
383
384                jQuery.noop;
385                if (states.length > 0) break;
386
387                // if (fname != " $") callstack.push(fn);
388            } if (fname != "") {
389                jQuery.noop;
390                // if (fname != " $") callstack.push(fn);
391            }
392            callstack.push(fn);
393
394            if (fn.match(RegExp("jquery|switchmenu|switchTabs|switchInterface|gally|initializeImageMode", "gi"))) {
395                states.push('jQuery');
396                break;
397            }
398            if (fn.match(RegExp("dialog..open", "gi"))) {
399                states.push('GMaps');
400                break;
401            }
402            if (fn.match(RegExp("GMaps|applyMap|markupMaps|applyMarkers", "gi"))) {
403                states.push('GMaps');
404                break;
405            }
406            //======================
407            //? bubble
408            Expression = new RegExp("\\$", "gi")
409            if (fn.match(Expression)) {
410                if (fn.match(RegExp("rateForm", "gi"))) {
411
412                    states.push('Luciano');
413                    break;
414                }
415            }
416            // "window.fireEvent('domready')"
417            Expression = new RegExp("window.fireEvent", "gi")
418            if (fn.match(Expression)) {  //luciano
419                // "window.fireEvent('domready')"
420                Expression = new RegExp("window.fireEvent..domready..", "gi")
421                if (fn.match(Expression)) {
422                    states.push('Luciano');
423                    break;
424                }
425            }
426            if (fn.match(RegExp("(splat|buildFrameWork|photoNext)", "gi"))) {  //luciano
427
428                states.push('Luciano');
429                break;
430            }
431            //======================
432            if (fn.match(RegExp("_footer|ie_ready|makeDraggable|droppables", "gi"))) {
433
434                states.push('paMOOramics');
435                break;
436            }
437            //window_1290934905697_top
438            if (fn.match(RegExp("window_..|WindowUtilities", "gi"))) {
439                states.push('rv_gmaps');
440                break;
441            }
442            if (fn.match(RegExp("that.overlayOpacity", "gi"))) {
443                states.push('rv_gmaps');
444                break;
445            }
446            if (fn.match(RegExp("For backward compatibility like win", "gi"))) {
447                states.push('rv_gmaps');
448                break;
449            }
450            if (fn.match(RegExp("overlay_modal|HTMLDivElement|constraintPad", "gi"))) {
451                states.push('rv_gmaps');
452                break;
453            }
454
455            if (fn.match(RegExp("__content|__method|observe|responder|stopobserving|fireContentLoadedEvent", "gi"))) {
456                states.push('rv_gmaps');
457                break;
458            }
459
460
461            if (all_functions.length > 50)
462                break;
463
464
465            currentFunction = currentFunction.caller;
466        }
467
468    }
469    // state_ff + "|" +
470    state = states.join('\n');
471    if (state == "") {
472
473      if (typeof DEBUG_autosize == "boolean" && DEBUG_autosize == "true") {
474            Fn = all_functions.join('\n');
475            try {
476                alert(Conflit.name + Conflit.version + "\n Appel non trouvée:" + fn1 + "\n" + Fn + "\n Firefox(retour):" + state_ff);
477            } catch (e) {
478            }
479        }
480
481
482        state = state_ff;
483    }
484
485    Fn = all_functions;
486    return { state: state, fn: callstack.join('\n'), fn1: fn2 };
487}
488//====================================
489function Ajout_Ajax() {
490  if (typeof $.ajax != "function")
491    $.ajax = function (args) {
492      return jQuery.ajax(args);
493    }
494}
495   
496function save_framework(page) {
497    try {
498        Conflit = { version: cl_version, name: cl_plugin };
499    } catch (e) {
500
501    }
502    if (jQuery('#browser').length > 0) {
503        jQuery('#browser').val(browser.browser);
504      }
505      Ajout_Ajax();
506
507    if (typeof (Parent) == "undefined")
508        Parent = "#theImage";
509  info_image = jQuery(Parent).infos();
510  p0 = jQuery(Parent);
511  if (p0.length > 0) {
512    //======================================================
513    if (info_image.position != "static") {
514      try {
515        if (theme.match("gally", "gi")) {
516          if (typeof gallyPP != "undefined") {
517
518          } else if (jQuery.isFunction(inittoolbar)) {
519            if (typeof (currentTab) == "undefined") inittoolbar();
520            else initializeImageMode("resize");
521          };
522          //==== compatibilité Gally/LLGBO ===
523          jQuery(Parent).css({ position: "static" });
524        }
525      } catch (e) {
526      }
527
528    }
529  }
530
531 
532  return
533}
534
535(function ($) {
536  jQuery(document).ready(function () {
537    //=================================================
538    if (typeof jQuery.fn.infos != "function") {
539      jQuery = myjQuery;
540      $ = my$;
541    }
542  });
543    function $(element, nc0) {
544        if (typeof jQuery.fn.infos != "function")
545            if (typeof myjQuery != "undefined")
546                jQuery = myjQuery;
547        a = conflit(element, nc0);
548        return a;
549    }
550})(jQuery);
551
552
553//--------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.