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

Last change on this file since 22218 was 22218, checked in by cljosse, 11 years ago

[extensions] Autosize update to piwigo 2.5 (fix bugs)

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