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

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

[extensions] Autosize fix compatibility with 2.4, add option: SelMax / Autosize (default setting)

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