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

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

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

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).on("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                if (states.length > 0) break;
391
392                // if (fname != " $") callstack.push(fn);
393            } if (fname != "") {
394                 
395                // if (fname != " $") callstack.push(fn);
396            }
397            callstack.push(fn);
398
399            if (fn.match(RegExp("jquery|switchmenu|switchTabs|switchInterface|gally|initializeImageMode", "gi"))) {
400                states.push('jQuery');
401                break;
402            }
403            if (fn.match(RegExp("dialog..open", "gi"))) {
404                states.push('GMaps');
405                break;
406            }
407            if (fn.match(RegExp("GMaps|applyMap|markupMaps|applyMarkers", "gi"))) {
408                states.push('GMaps');
409                break;
410            }
411            //======================
412            //? bubble
413            Expression = new RegExp("\\$", "gi");
414            if (fn.match(Expression)) {
415                if (fn.match(RegExp("rateForm", "gi"))) {
416
417                    states.push('Luciano');
418                    break;
419                }
420            }
421            // "window.fireEvent('domready')"
422            Expression = new RegExp("window.fireEvent", "gi");
423            if (fn.match(Expression)) {  //luciano
424                // "window.fireEvent('domready')"
425                Expression = new RegExp("window.fireEvent..domready..", "gi");
426                if (fn.match(Expression)) {
427                    states.push('Luciano');
428                    break;
429                }
430            }
431            if (fn.match(RegExp("(splat|buildFrameWork|photoNext)", "gi"))) {  //luciano
432
433                states.push('Luciano');
434                break;
435            }
436            //======================
437            if (fn.match(RegExp("_footer|ie_ready|makeDraggable|droppables", "gi"))) {
438
439                states.push('paMOOramics');
440                break;
441            }
442            //window_1290934905697_top
443            if (fn.match(RegExp("window_..|WindowUtilities", "gi"))) {
444                states.push('rv_gmaps');
445                break;
446            }
447            if (fn.match(RegExp("that.overlayOpacity", "gi"))) {
448                states.push('rv_gmaps');
449                break;
450            }
451            if (fn.match(RegExp("For backward compatibility like win", "gi"))) {
452                states.push('rv_gmaps');
453                break;
454            }
455            if (fn.match(RegExp("overlay_modal|HTMLDivElement|constraintPad", "gi"))) {
456                states.push('rv_gmaps');
457                break;
458            }
459
460            if (fn.match(RegExp("__content|__method|observe|responder|stopobserving|fireContentLoadedEvent", "gi"))) {
461                states.push('rv_gmaps');
462                break;
463            }
464
465
466            if (all_functions.length > 50)
467                break;
468
469
470            currentFunction = currentFunction.caller;
471        }
472
473    }
474    // state_ff + "|" +
475    state = states.join('\n');
476    if (state == "") {
477
478      if (typeof DEBUG_autosize == "boolean" && DEBUG_autosize == "true") {
479            Fn = all_functions.join('\n');
480            try {
481                alert(Conflit.name + Conflit.version + "\n Appel non trouvée:" + fn1 + "\n" + Fn + "\n Firefox(retour):" + state_ff);
482            } catch (e) {
483            }
484        }
485
486
487        state = state_ff;
488    }
489
490    Fn = all_functions;
491    return { state: state, fn: callstack.join('\n'), fn1: fn2 };
492}
493//====================================
494function Ajout_Ajax() {
495  if (typeof $.ajax != "function")
496    $.ajax = function (args) {
497      return jQuery.ajax(args);
498    }   ;
499}
500   
501function save_framework(page) {
502    try {
503        Conflit = { version: cl_version, name: cl_plugin };
504    } catch (e) {
505
506    }
507    if (jQuery('#browser').length > 0) {
508        jQuery('#browser').val(browser.browser);
509      }
510      Ajout_Ajax();
511
512    if (typeof (Parent) == "undefined")
513      Parent = "#theImage";
514        if(typeof jQuery(Parent).infos=="function"){
515  info_image = jQuery(Parent).infos();
516  p0 = jQuery(Parent);
517  if (p0.length > 0) {
518    //======================================================
519    if (info_image.position != "static") {
520      try {
521        if (theme.match("gally", "gi")) {
522          if (typeof gallyPP != "undefined") {
523
524          } else if (jQuery.isFunction(inittoolbar)) {
525            if (typeof (currentTab) == "undefined") inittoolbar();
526            else initializeImageMode("resize");
527          };
528          //==== compatibilité Gally/LLGBO ===
529          jQuery(Parent).css({ position: "static" });
530        }
531      } catch (e) {
532      }
533    }
534    }
535  }
536
537 
538  return
539}
540
541(function ($) {
542  jQuery(document).ready(function () {
543    //=================================================
544    if (typeof jQuery.fn.infos != "function") {
545     try{ jQuery = myjQuery;
546      $ = my$;
547      }catch(e){
548
549      }
550    }
551  });
552    function $(element, nc0) {
553        if (typeof jQuery.fn.infos != "function")
554            if (typeof myjQuery != "undefined")
555                jQuery = myjQuery;
556        a = conflit(element, nc0);
557        return a;
558    }
559})(jQuery);
560
561
562//--------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.