source: extensions/gally/gally-cuise/js/crossbrowser.js @ 7459

Last change on this file since 7459 was 7459, checked in by cljosse, 13 years ago

[Gally's theme 'cuise'] Compatibility whith GMaps

File size: 30.6 KB
Line 
1; (function (jQuery) {
2                         
3 if (!document.namespaces.v) { document.namespaces.add("v", "urn:schemas-microsoft-com:vml"); }
4    var mode = document.documentMode || 0;
5    var noBottomFold = jQuery.browser.msie && ((jQuery.browser.version < 8 && !mode) || mode < 8);
6    var init = false;
7    var angle = 0;
8    var strokeWeight =0;
9
10//=======================================================================================
11//Filter: Alpha(Opacity=100, FinishOpacity=0, Style=2, StartX=20, StartY=40, FinishX=0, FinishY=0);
12//filter:progid:DXImageTransform.Microsoft.Alpha(opacity=20)"
13function opacity(obj) {
14        alpha_css=jQuery(obj).css("opacity");
15        fils=     $(obj).children() ;
16        if (fils.length>1) { 
17                jQuery( fils).css("opacity",alpha_css);
18            }
19}
20     //======================================================================================
21function transform(obj) {
22     if (!obj) return ;
23         if (typeof obj == "string") var s = document.getElementById(obj).style;
24         else var s = obj.style;
25       
26         if (typeof s.transform != "undefined") {
27             var angle1 = s.transform.split("rotate(");
28             angle1 = angle1[1].split("deg)");
29             angle = angle1[0];
30         }
31         //==================================================================================   
32         var deg2radians = Math.PI * 2 / 360;
33         var rad = angle * deg2radians;
34         var costheta = Math.cos(rad);
35         var sintheta = Math.sin(rad);
36
37         if (!obj.style.filter.match("progid:DXImageTransform.Microsoft.Matrix")) obj.style.filter += "  progid:DXImageTransform.Microsoft.Matrix() ";
38
39
40         centered = true;
41         try{
42         obj.filters.item("DXImageTransform.Microsoft.Matrix").M11 = costheta;
43         obj.filters.item("DXImageTransform.Microsoft.Matrix").M12 = -sintheta;
44         obj.filters.item("DXImageTransform.Microsoft.Matrix").M21 = sintheta;
45         obj.filters.item("DXImageTransform.Microsoft.Matrix").M22 = costheta;
46         obj.filters.item("DXImageTransform.Microsoft.Matrix").sizingMethod = 'auto expand'; //'clip to original' ; //
47         }  catch (_) { 
48         centered = true;
49         }
50
51  height = obj.clientHeight;
52  width = obj.clientWidth;
53  xleft= obj.offsetLeft;
54  ytop= obj.offsetTop;     
55  ntop = ((height - obj.offsetHeight) / 2);
56  nleft = ((width - obj.offsetWidth) / 2); 
57
58
59    if (obj.vml) {
60          if (!init) {
61            jQuery(obj).css("position", "absolute");
62          pos_img=jQuery(obj).findPos();
63           pos_vml=jQuery(obj.vml).findPos();
64                  nleft=-strokeWeight;
65                  ntop =-strokeWeight;
66
67                   var mode = document.documentMode || 0;
68                  if (obj.currentStyle.position!="absolute"){
69
70                    init_x0=init_x - (0.5*strokeWeight) ;
71                   if (mode==8) init_y0=init_y + (0.5*strokeWeight) ;
72                   else init_y0=init_y + (1.5*strokeWeight) ;
73                    init_y=strokeWeight;
74                    init_x=strokeWeight;
75
76
77                  }else{
78                   init_y=parseInt(pos_img.x)+strokeWeight;
79                   init_x=parseInt(pos_img.y)+strokeWeight;
80                   init_x0=init_x+(0.5*strokeWeight);
81                    init_y0=init_y+(0.5*strokeWeight);
82
83                  }
84
85                   jQuery(obj).css("position", "absolute");
86                  init=true;
87                   
88                 }
89
90                        x = init_x+  nleft ;
91                        y = init_y+  ntop ;
92
93
94                 jQuery(obj).css("left",  x +  "px");
95                 jQuery(obj).css("top",  y +  "px");
96 
97                 jQuery(obj.vml).css("left",   init_x0 +  nleft+  "px");
98                 jQuery(obj.vml).css("top",  init_y0 +  ntop+  "px");
99       
100
101                 transform(obj.vml);
102                       
103                } 
104var name_id=obj.id ; 
105 jQuery(obj).css("opacity",alpha);
106 if (alpha!=1) {
107     opacity(obj);
108 
109 }
110 
111          return ;
112
113 
114   
115
116
117
118
119     
120
121     }
122//===========================================
123function onPropertyChange(e) {
124         var el = e.srcElement;
125
126         switch (e.propertyName) {
127            case "opacity":
128                 opacity(el);
129
130                 break;
131             case "style.transform":
132             // init=false;
133                 transform(el);
134
135                 break;
136             case "style.textShadow":
137
138                 var text_shadow = el.style.textShadow;
139                 var sizeShadow = text_shadow.split(" ");
140                 aff_filter(el, sizeShadow);
141                 break;
142             case "style.color":
143                 new_color = translateColor(el.style.color);
144                 el.style.color = new_color;
145                 break;
146             case 'width':
147
148                 el.style.width = el.attributes.width.nodeValue + 'px';
149                 // In IE8 this does not trigger onresize.
150                 el.firstChild.style.width = el.clientWidth + 'px';
151                 break;
152             case 'height':
153
154                 el.style.height = el.attributes.height.nodeValue + 'px';
155                 el.firstChild.style.height = el.clientHeight + 'px';
156                 break;
157         }
158     }
159//==================================================
160function findSize(obj) {
161         var cur_height = obj.offsetHeight;
162         var cur_width = obj.offsetWidth;
163
164     
165
166         return ({
167             'x': cur_width,
168             'y': cur_height
169         });
170     }
171//==================================================
172function roundWebkit(e, s) {
173    var radius = '' + s.sizex + 'px ' + s.sizey + 'px';
174    var $e = jQuery(e);
175    if (s.tl) $e.css('WebkitBorderTopLeftRadius', radius);
176    if (s.tr) $e.css('WebkitBorderTopRightRadius', radius);
177    if (s.bl) $e.css('WebkitBorderBottomLeftRadius', radius);
178    if (s.br) $e.css('WebkitBorderBottomRightRadius', radius);
179  }
180//================================================== 
181  function roundMozilla(e, s)
182  { 
183    var radius = '' + s.sizex + 'px';
184    var $e = jQuery(e);
185    if (s.tl) $e.css('-moz-border-radius-topleft', radius);
186    if (s.tr) $e.css('-moz-border-radius-topright', radius);
187    if (s.bl) $e.css('-moz-border-radius-bottomleft', radius);
188    if (s.br) $e.css('-moz-border-radius-bottomright', radius); 
189  }
190//=================================================================
191     var rect_init;
192     var css_init;
193     var fill_init;
194     //==============================================================
195
196     // precompute "00" to "FF"
197    var decToHex = [];
198    var alpha = 1;
199    var      init_x = 0;
200    var init_y = 0;
201    var  init_x0 =0;
202    var  init_y0 = 0;
203//==============================================================
204function oncontentready(Obj) {
205         //======== test si classe existe =============================
206         classID= Obj.uniqueID;
207         if (Obj.className.match(classID)) { return (false); }
208         if (!document.namespaces.v+classID) { document.namespaces.add("v"+classID, "urn:schemas-microsoft-com:vml"); }
209         Obj.className = Obj.className.concat(' ', classID);
210         // Find which element provides position:relative for the target element (default to BODY)
211 
212        pos=jQuery(Obj).findPos();
213        Left=pos.x;
214        Top=pos.y;
215        pos_src=jQuery(Obj.parentElement).findPos();
216
217    var limit = 100, i = 0;
218    var el = Obj; //(this) 
219           style= el.currentStyle ;
220         zindex = 3;
221         var El_src = el.element;
222
223         while ((typeof (El_src) != 'undefined') && (El_src.currentStyle.position != 'relative') && (El_src.tagName != 'BODY')) {
224             El_src = El_src.parentElement;
225             
226             if (El_src.style.zIndex> zindex) zindex++;
227             i++;
228             if (i >= limit) { return (false); }
229         }
230       
231
232         var el_zindex = parseInt(el.currentStyle.zIndex);
233         if (isNaN(el_zindex)) { el_zindex = 3; }
234         var m = el.children;
235         for (i = 0; i < m.length; i++) {
236             echild = m.item(i);
237            echild.style.zIndex = el_zindex + 1  ;
238         }
239
240          Obj.style.zIndex = el_zindex+3 ;
241     
242
243         //=============================================================================       
244
245   
246         switch(Obj.currentStyle.borderWidth)
247         {
248         case 'solid':
249            break;
250         default:
251         strokeWeight=parseInt(Obj.currentStyle.borderWidth);
252             break;
253         }
254           
255         switch(Obj.currentStyle.borderStyle)
256         {
257         case 'solid':
258         strokeStyle=Obj.currentStyle.borderStyle;
259            break;
260        case 'double':
261        strokeStyle=Obj.currentStyle.borderStyle;
262            break;
263
264         default:
265         strokeStyle=Obj.currentStyle.borderStyle;
266
267             break;
268         }
269
270         if (isNaN(strokeWeight)) {
271             strokeWeight = 0;
272             
273         } 
274         stroked =( strokeWeight> 0);
275         
276
277         //================================================================================
278         for (var i = 0; i < 16; i++) {
279             for (var j = 0; j < 16; j++) {
280                 decToHex[i * 16 + j] = i.toString(16) + j.toString(16);
281             }
282         }
283         //==================================
284         var fillColor = translateColor(Obj.currentStyle.backgroundColor);
285         var strokeColor =  translateColor(Obj.currentStyle.borderColor);
286 
287
288         width=jQuery(Obj).width();
289         height=jQuery(Obj).height();
290              Width=(width+strokeWeight );
291     Height=(height+strokeWeight);
292
293         Left=parseInt(jQuery(Obj).css("left"));
294         if (isNaN(Left)) Left=0 ;
295         Top=parseInt(jQuery(Obj).css("top"));
296           if (isNaN(Top)) Top=0 ;
297   //=================================================================
298           s = Obj.currentStyle;
299
300         if (typeof s.transform != "undefined") {
301             rotation = s['transform'];
302             var angle1 = s.transform.split("rotate(");
303             angle1 = angle1[1].split("deg)");
304             angle = angle1[0];
305         }
306         //=================================================================
307
308
309         var VgFillType = new Array("solid", "gradient", "gradientradial", "tile", "pattern", "frame");
310         var VgFillmethod = new Array("none", "linear", "sigma", "any");
311         var VgFillaspect = new Array("atless", "atmost")
312
313
314         alpha = Obj.currentStyle['opacity'] || 1;
315
316
317         var fillSrc = Obj.currentStyle.backgroundImage.replace(/^url\("(.+)"\)$/, '$1');
318
319         if (fillSrc) var filltype = (Obj.currentStyle['type']) || "tile";
320         else var filltype = (Obj.currentStyle['type']) || "gradientRadial";
321  /*
322         var fillopacity = alpha;
323       
324         var fillmethod = "none";
325         var fillfocus = "100%";
326
327         var fillcolor2 = "#00FF00";
328         var fillcolors = "0,#ff0000, 0.5#00ff00, 0.6 #0000ff, 0.8 #ff0000, 0.9 #ff0000";
329
330         var fillopacity2 = "1.0";
331         var fillangle = "0";
332         var fillfocusposition = "0.5,0.5";
333         */
334       
335
336         //==================================================================================   
337         radius = s['-moz-border-radius'];
338
339
340         if (typeof radius == "undefined") { radius = "0" }
341         if (typeof radius == undefined) { radius = "" }
342                 
343         if (radius.match("\/")) {
344             //=============================================================
345
346             var tableau = radius.split("/");
347             var rect = document.createElement('v:oval');
348             var typeelement="oval";
349
350         } else {
351                   if (radius.match("\ ")) { 
352          var tableau = radius.split(" "); 
353
354          }
355
356  var tableau = radius.split(" "); 
357      tableau = radius + " " + radius + " " +tableau[0] +" " + tableau[0] + " " + tableau[0];   
358      tableau = tableau.split(" "); 
359      top_left = parseInt(s['-moz-border-top-left-radius']||tableau[0]) ;
360      top_right =  parseInt(s['-moz-border-top-right-radius']||tableau[1]);
361      bottom_right =  parseInt(s['-moz-border-radius-radius']||tableau[2]);
362      bottom_left =  parseInt(s['-moz-border-bottom-left-radius']||tableau[3]);       
363
364
365     radius=tableau[0];
366//=============================================================
367if (parseInt(radius) != "0") {
368    if (top_left!=top_right) {
369          var typeelement="shape";
370          var rect = document.createElement('v'+classID+':shape');     
371
372       with(rect){
373            fillColor = 'none'; 
374            fillStroked = 'true';
375             //   coordsize  = "100 , 100";
376             //    coordSize  = "100 , 100";
377               }
378     
379        rect.setAttribute("coordSize",Width + "," + Height); //mode7
380 TL =top_left ;
381 TR = top_right  ;
382 BR = bottom_right ;
383 BL =bottom_left ;
384
385
386
387 var Origine ={ x: Width - TR, y:0} ;
388 var TR_  ={ x: Width , y : 0 + TR} ;
389 var L1 ={ x: Width , y:Height-BR} ;
390 var BR_ ={ x: Width - BR, y:Height} ;
391 var L2 ={ x:BL, y:Height} ;
392 var BL_ ={ x:0 , y:Height-BL} ;
393 var L3 ={ x:0 , y:TL} ;
394 var TL_ ={ x:TL, y:0} ;
395 var L4 ={ x: Width - TR, y:0} ;
396
397 var path=" m "+ Origine.x +","+ Origine.y + 
398        " qx " + TR_.x + "," + TR_.y +
399        " l  " + L1.x + "," + L1.y +
400        " qy " + BR_.x + "," + BR_.y +
401        " l " + L2.x + "," + L2.y +
402        " qx "+ BL_.x + "," + BL_.y +
403        " l " + L3.x + "," + L3.y +
404        " qy "+ TL_.x + "," + TL_.y +
405        " l " + L4.x + "," + L4.y +
406        " x e";
407    rect.path=path ;
408
409 
410    }   else {       
411        var typeelement="roundrect";
412        var rect = document.createElement('v'+classID+':roundrect');
413        var arcSize = Math.min(parseInt(radius) / Math.min(Obj.offsetWidth, Obj.offsetHeight), 1);     
414        rect.arcsize = arcSize + 'px';
415        }
416  } else {
417                 var rect = document.createElement('v'+classID+':rect');
418                 var typeelement="rect";
419             }
420
421         }
422
423
424         /*===================================================================================*/
425         var text_shadow = Obj.currentStyle['text-shadow'];
426
427         var box_shadow = Obj.currentStyle['-moz-box-shadow'] ||
428                   Obj.currentStyle['box-shadow'] ||
429                   Obj.currentStyle['-webkit-box-shadow'] ||
430                   Obj.currentStyle['-khtml-box-shadow'];
431
432
433
434         if (text_shadow || box_shadow) {
435             if (text_shadow) {
436                 var sizeShadow = text_shadow.split(" ");
437                 aff_filter(Obj, sizeShadow);
438
439             }
440
441
442             if (box_shadow) {
443                 var sizeShadow = box_shadow.split(" ");
444                 aff_filter(rect, sizeShadow)
445             }
446
447         }
448         /*===================================================================================*/
449
450         var fill = document.createElement('v'+classID+':fill');
451
452         fill.src = fillSrc;
453         fill.color = fillColor;
454         fill.type = filltype;
455     
456
457/*
458         var fillopacity = alpha;
459if(fillopacity)      fill.opacity = fillopacity;
460
461         var fillmethod = "none";
462if (fillmethod) fill.method = fillmethod;
463
464         var fillfocus = "100%";
465         var fillcolor2 = "#00FF00";
466         var fillcolors = "0,#ff0000, 0.5#00ff00, 0.6 #0000ff, 0.8 #ff0000, 0.9 #ff0000";
467            if (fillfocus) fill.focus = fillfocus;
468            if (fillcolor2) fill.color2 = fillcolor2;
469            if (fillcolors) fill.colors = fillcolors;
470
471         var fillopacity2 = "1.0";
472         var fillangle = "0";
473         var fillfocusposition = "0.5,0.5";
474            if (fillopacity2) fill.opacity2 = fillopacity2;
475            if (fillangle) fill.angle = fillangle;
476            if (fillfocusposition) fill.focusposition = fillfocusposition;
477
478*/
479              jQuery(rect).width(Width  );
480              jQuery(rect).height(Height );
481               
482         rect.appendChild(fill);
483//================================================================
484         with(rect.style){
485                left=Left+(0.5*strokeWeight);
486                top=Top+(0.5*strokeWeight);
487                position="absolute"
488                display = 'block';
489                antialias = true;
490                zindex = el_zindex+3;
491
492             }
493//<v:stroke on="True" filltype="solid"
494 //   color="#9094C9" weight="8pt" />
495//   filltype="pattern" src="rond.gif" />
496
497if (stroked) {
498                    rect.strokecolor = strokeColor;
499                    rect.strokeWeight = strokeWeight + 'px';
500                    rect.stroked = stroked;
501   }
502        //================================================================
503document.body.appendChild(rect);
504  var css =  document.createStyleSheet(); 
505  var styleSheet = (document.styleSheets.length > 0) ? document.styleSheets[0] :  document.createStyleSheet();
506        //  css = styleSheet;
507//if (stroked)  css.addRule('v'+classID+"\\:stroke" , "behavior: url(#default#VML)");
508         css.addRule('v'+classID+"\\:"+typeelement, "behavior: url(#default#VML)");
509         css.addRule('v'+classID+"\\:fill", "behavior: url(#default#VML)");
510       //  css.addRule("v\\:*", "behavior: url(#default#VML)");
511         //=================================================================   
512   
513       
514
515          Obj.style.background =    'transparent';
516          Obj.style.borderColor = 'transparent';
517
518         isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
519         // IE6 doesn't support transparent borders, use padding to offset original element
520         if (isIE6 && (strokeWeight > 0)) {
521             Obj.style.borderStyle = 'none';
522             Obj.style.paddingTop = parseInt(Obj.currentStyle.paddingTop || 0) + strokeWeight;
523             Obj.style.paddingBottom = parseInt(Obj.currentStyle.paddingBottom || 0) + strokeWeight;
524         }
525
526
527   init_x = Left;
528   init_y = Top;
529   init_x0 = Left;
530   init_y0 = Top;
531
532        init_x  =parseInt(init_x)+strokeWeight;
533        init_y = parseInt(init_y)+strokeWeight;
534
535        init_x0  =parseInt(init_x);
536        init_y0 = parseInt(init_y);
537
538         Obj.vml = rect;
539
540//===============================================================================================
541         if (typeof (window.rounded_elements) == 'undefined') {
542             window.rounded_elements = new Array();
543
544             if (typeof (window.onresize) == 'function') { window.previous_onresize = window.onresize; }
545             window.onresize = window_resize;
546         }
547         window.rounded_elements[i]
548         window.rounded_elements.push(Obj);
549
550        // Resize(Obj.element);
551         obj = Obj;
552         init = false;
553    transform(obj)
554
555         Obj.attachEvent('onpropertychange', onPropertyChange);
556     }
557     //=====================================================================================
558     var Curwidth = 0;
559     var Curheight = 0;
560
561     function Resize(obj) {
562     return ;
563
564         var h0 = 0;
565         var strokeWeight = parseInt(obj.currentStyle.borderWidth);
566         if (isNaN(strokeWeight)) { strokeWeight = 0; }
567
568
569         Size = findSize(obj);
570         //     obj.style.backgroundColor="green";
571
572         pos = findPos(obj);
573         var parent_pos = findPos(obj.vml.parentNode);
574         //var position = $(obj).position();
575         pos.y = pos.y + (0.5 * strokeWeight) - parent_pos.y;
576         pos.x = pos.x + (0.5 * strokeWeight) - parent_pos.x;
577         objvml = obj.vml;
578         objvml.style.top = pos.y + 'px';
579         objvml.style.left = pos.x + 'px';
580
581         //===================================================
582         if (Curwidth == 0) {
583             OldWidth =  objvml.offsetWidth;
584
585             OldHeight = objvml.offsetHeight;
586             Curwidth = obj.offsetWidth - strokeWeight;
587             Curheight =   obj.offsetHeight - strokeWeight;
588 
589         }
590
591         objvml.style.width= Curwidth ;
592         objvml.style.height=Curheight ;
593
594     }
595     //==================================================================================
596     function window_resize() {
597         if (typeof (window.rounded_elements) == 'undefined') { return (false); }
598         if (typeof (handle) == 'undefined') { return (false); }
599         old_handle = handle;
600         old_angle = nangle;
601         rotate(0, true)
602         Curwidth = 0;
603         for (var i in window.rounded_elements) {
604             Resize(window.rounded_elements[i]);
605         }
606
607         if (typeof (window.previous_onresize) == 'function') { window.previous_onresize(); }
608         nangle = old_angle
609         if (old_handle) toggleAnimation()
610
611     }
612     //=======================================================================================
613
614     function aff_filter(obj, sizeShadow) {
615     if (!obj) return ;
616
617         if (typeof obj == "string") var s = document.getElementById(obj).style;
618         else var s = obj.style;
619         Blur = 0;
620         ShadowColor = 0;
621         Horizontal = sizeShadow[0];
622         Vertical = sizeShadow[1];
623         if (sizeShadow.length > 2) Blur = sizeShadow[2]; //radius
624         if (sizeShadow.length > 3) ShadowColor = translateColor(sizeShadow[3]);
625
626
627         direction = 180 - Math.atan((parseInt(Horizontal)) / (parseInt(Vertical))) * 180 / Math.PI;
628         Strength = parseInt(Blur);
629         couleur = ShadowColor;
630
631         obj.style.filter = "progid:DXImageTransform.Microsoft.Shadow(color =" + couleur + ",Direction =" + direction + ",Strength = " + Strength + ") ";
632
633
634
635
636
637         return;
638
639     }
640
641     function hasSilverlight() {
642         try {
643             new ActiveXObject('AgControl.AgControl');
644             return true;
645         } catch (_) {
646             return false;
647         }
648     }
649
650     function getRgbHslContent(styleString) {
651         var start = styleString.indexOf('(', 3);
652         var end = styleString.indexOf(')', start + 1);
653         var parts = styleString.substring(start + 1, end).split(',');
654         // add alpha if needed
655         if (parts.length == 4 && styleString.substr(3, 1) == 'a') {
656             alpha = +parts[3];
657         } else {
658             parts[3] = 1;
659         }
660         return parts;
661     }
662
663     function percent(s) {
664         return parseFloat(s) / 100;
665     }
666
667     function clamp(v, min, max) {
668         return Math.min(max, Math.max(min, v));
669     }
670
671     function hslToRgb(parts) {
672         var r, g, b, h, s, l;
673         h = parseFloat(parts[0]) / 360 % 360;
674         if (h < 0)
675             h++;
676         s = clamp(percent(parts[1]), 0, 1);
677         l = clamp(percent(parts[2]), 0, 1);
678         if (s == 0) {
679             r = g = b = l; // achromatic
680         } else {
681             var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
682             var p = 2 * l - q;
683             r = hueToRgb(p, q, h + 1 / 3);
684             g = hueToRgb(p, q, h);
685             b = hueToRgb(p, q, h - 1 / 3);
686         }
687
688         return decToHex[Math.floor(r * 255)] +
689         decToHex[Math.floor(g * 255)] +
690         decToHex[Math.floor(b * 255)];
691     }
692
693     function hueToRgb(m1, m2, h) {
694         if (h < 0)
695             h++;
696         if (h > 1)
697             h--;
698
699         if (6 * h < 1)
700             return m1 + (m2 - m1) * 6 * h;
701         else if (2 * h < 1)
702             return m2;
703         else if (3 * h < 2)
704             return m1 + (m2 - m1) * (2 / 3 - h) * 6;
705         else
706             return m1;
707     }
708     function hexToDec(hex) {
709         return parseInt(hex, 16);
710     }
711
712
713     function translateColor(styleString) {
714         var str;
715         var n = 0;
716
717
718         styleString = String(styleString);
719         if (styleString.charAt(0) == '#') {
720             styleString = (styleString + "00000000").substring(0, 7);
721
722             return styleString;
723         } else if (/^rgb/.test(styleString)) {
724             var parts = getRgbHslContent(styleString);
725             var str = '', n;
726             for (var i = 0; i < 3; i++) {
727                 if (parts[i].indexOf('%') != -1) {
728                     n = Math.floor(percent(parts[i]) * 255);
729                 } else {
730                     n = +parts[i];
731                 }
732                 str += decToHex[clamp(n, 0, 255)];
733             }
734
735             alpha = parts[3];
736         } else if (/^hsl/.test(styleString)) {
737             var parts = getRgbHslContent(styleString);
738             str = hslToRgb(parts);
739             alpha = parts[3];
740         } else if (styleString in colorData) {
741             var exp = new RegExp(/^#/);
742
743             return colorData[styleString];
744
745
746
747         } else {
748
749
750             return styleString;
751
752
753         }
754         // decToHex[Math.floor(alpha * 255)] +
755         return '#' + str;
756     }         
757 
758      var colorData = {
759         aliceblue: '#F0F8FF',
760         antiquewhite: '#FAEBD7',
761         aquamarine: '#7FFFD4',
762         azure: '#F0FFFF',
763         beige: '#F5F5DC',
764         bisque: '#FFE4C4',
765         black: '#000000',
766         blanchedalmond: '#FFEBCD',
767         blueviolet: '#8A2BE2',
768         brown: '#A52A2A',
769         burlywood: '#DEB887',
770         cadetblue: '#5F9EA0',
771         chartreuse: '#7FFF00',
772         chocolate: '#D2691E',
773         coral: '#FF7F50',
774         cornflowerblue: '#6495ED',
775         cornsilk: '#FFF8DC',
776         crimson: '#DC143C',
777         cyan: '#00FFFF',
778         darkblue: '#00008B',
779         darkcyan: '#008B8B',
780         darkgoldenrod: '#B8860B',
781         darkgray: '#A9A9A9',
782         darkgreen: '#006400',
783         darkgrey: '#A9A9A9',
784         darkkhaki: '#BDB76B',
785         darkmagenta: '#8B008B',
786         darkolivegreen: '#556B2F',
787         darkorange: '#FF8C00',
788         darkorchid: '#9932CC',
789         darkred: '#8B0000',
790         darksalmon: '#E9967A',
791         darkseagreen: '#8FBC8F',
792         darkslateblue: '#483D8B',
793         darkslategray: '#2F4F4F',
794         darkslategrey: '#2F4F4F',
795         darkturquoise: '#00CED1',
796         darkviolet: '#9400D3',
797         deeppink: '#FF1493',
798         deepskyblue: '#00BFFF',
799         dimgray: '#696969',
800         dimgrey: '#696969',
801         dodgerblue: '#1E90FF',
802         firebrick: '#B22222',
803         floralwhite: '#FFFAF0',
804         forestgreen: '#228B22',
805         gainsboro: '#DCDCDC',
806         ghostwhite: '#F8F8FF',
807         gold: '#FFD700',
808         goldenrod: '#DAA520',
809         grey: '#808080',
810         greenyellow: '#ADFF2F',
811         honeydew: '#F0FFF0',
812         hotpink: '#FF69B4',
813         indianred: '#CD5C5C',
814         indigo: '#4B0082',
815         ivory: '#FFFFF0',
816         khaki: '#F0E68C',
817         lavender: '#E6E6FA',
818         lavenderblush: '#FFF0F5',
819         lawngreen: '#7CFC00',
820         lemonchiffon: '#FFFACD',
821         lightblue: '#ADD8E6',
822         lightcoral: '#F08080',
823         lightcyan: '#E0FFFF',
824         lightgoldenrodyellow: '#FAFAD2',
825         lightgreen: '#90EE90',
826         lightgrey: '#D3D3D3',
827         lightpink: '#FFB6C1',
828         lightsalmon: '#FFA07A',
829         lightseagreen: '#20B2AA',
830         lightskyblue: '#87CEFA',
831         lightslategray: '#778899',
832         lightslategrey: '#778899',
833         lightsteelblue: '#B0C4DE',
834         lightyellow: '#FFFFE0',
835         limegreen: '#32CD32',
836         linen: '#FAF0E6',
837         magenta: '#FF00FF',
838         mediumaquamarine: '#66CDAA',
839         mediumblue: '#0000CD',
840         mediumorchid: '#BA55D3',
841         mediumpurple: '#9370DB',
842         mediumseagreen: '#3CB371',
843         mediumslateblue: '#7B68EE',
844         mediumspringgreen: '#00FA9A',
845         mediumturquoise: '#48D1CC',
846         mediumvioletred: '#C71585',
847         midnightblue: '#191970',
848         mintcream: '#F5FFFA',
849         mistyrose: '#FFE4E1',
850         moccasin: '#FFE4B5',
851         navajowhite: '#FFDEAD',
852         oldlace: '#FDF5E6',
853         olivedrab: '#6B8E23',
854         orange: '#FFA500',
855         orangered: '#FF4500',
856         orchid: '#DA70D6',
857         palegoldenrod: '#EEE8AA',
858         palegreen: '#98FB98',
859         paleturquoise: '#AFEEEE',
860         palevioletred: '#DB7093',
861         papayawhip: '#FFEFD5',
862         peachpuff: '#FFDAB9',
863         peru: '#CD853F',
864         pink: '#FFC0CB',
865         plum: '#DDA0DD',
866         powderblue: '#B0E0E6',
867         rosybrown: '#BC8F8F',
868         royalblue: '#4169E1',
869         saddlebrown: '#8B4513',
870         salmon: '#FA8072',
871         sandybrown: '#F4A460',
872         seagreen: '#2E8B57',
873         seashell: '#FFF5EE',
874         sienna: '#A0522D',
875         skyblue: '#87CEEB',
876         slateblue: '#6A5ACD',
877         slategray: '#708090',
878         slategrey: '#708090',
879         snow: '#FFFAFA',
880         springgreen: '#00FF7F',
881         steelblue: '#4682B4',
882         tan: '#D2B48C',
883         thistle: '#D8BFD8',
884         tomato: '#FF6347',
885         turquoise: '#40E0D0',
886         violet: '#EE82EE',
887         wheat: '#F5DEB3',
888         whitesmoke: '#F5F5F5',
889         yellowgreen: '#9ACD32'
890     };
891//=====================================================================
892// Ajoute une fonctionnalité jQuery
893jQuery.extend(jQuery.expr[':'], {
894        // Nom du sélecteur personnalisé
895        Radius: function (a) {
896            if (!jQuery.browser.msie) return;
897
898    s= a.currentStyle;
899           var moz = s['-moz-border-radius'] !== undefined   ;
900            var webkit = s['-webkit-border-radius'] !== undefined;
901            var radius = s['border-radius'] !== undefined ||s['border-Radius'] !== undefined || s['Border-Radius'] !== undefined;
902
903            var mode = document.documentMode || 0;
904            var noBottomFold = jQuery.browser.msie && ((jQuery.browser.version < 8 && !mode) || mode < 8);
905
906            // Eléments correspondant
907       Attribut = s[radius ? 'border-radius' : moz ? '-moz-border-radius' : '-webkit-border-radius'];
908            if (Attribut != undefined) {
909                jQuery(a).crossbrowser(a);
910                 
911            }
912            return false;
913
914        }
915    });
916 //==============================================================================
917jQuery.fn.extend({
918   findPos : function() {
919       obj = jQuery(this).get(0);
920       var curleft = obj.offsetLeft || 0;
921       var curtop = obj.offsetTop || 0;
922       while (obj = obj.offsetParent) {
923                curleft += obj.offsetLeft
924                curtop += obj.offsetTop
925       }
926       return {x:curleft,y:curtop};
927   }
928});
929 //==============================================================================       
930jQuery.fn.crossbrowser = function (options) {
931         oncontentready(options);
932 }
933 
934})(jQuery);
935//================================================================================
936 
937
938
939jQuery(document).ready(function () {
940
941 jQuery(':Radius');
942
943     
944});
Note: See TracBrowser for help on using the repository browser.