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

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

[gally_cuise] update theme

File size: 36.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 (getStyles(obj).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= getStyles(el); 
220    strokeWeight = Get_stokeWeight( style.borderWidth);
221    strokeStyle  = Get_style( style.borderStyle);
222    strokeColor  = Get_Color( style.borderColor);
223
224         zindex = 3;
225         var El_src = el.element;
226
227         while ((typeof (El_src) != 'undefined') && ( getStyles(El_src).position != 'relative') && (El_src.tagName != 'BODY')) {
228             El_src = El_src.parentElement;
229             
230             if (El_src.style.zIndex> zindex) zindex++;
231             i++;
232             if (i >= limit) { return (false); }
233         }
234       
235
236         var el_zindex = parseInt(getStyles(el).zIndex);
237         if (isNaN(el_zindex)) { el_zindex = 3; }
238         var m = el.children;
239         for (i = 0; i < m.length; i++) {
240             echild = m.item(i);
241            echild.style.zIndex = el_zindex + 1  ;
242         }
243
244          Obj.style.zIndex = el_zindex+3 ;
245     
246
247         //=============================================================================       
248
249   
250         switch(getStyles(Obj).borderWidth)
251         {
252         case 'solid':
253            break;
254         default:
255         strokeWeight=parseInt(getStyles(Obj).borderWidth);
256             break;
257         }
258           
259         switch(getStyles(Obj).borderStyle)
260         {
261         case 'solid':
262         strokeStyle=getStyles(Obj).borderStyle;
263            break;
264        case 'double':
265        strokeStyle=getStyles(Obj).borderStyle;
266            break;
267
268         default:
269         strokeStyle=getStyles(Obj).borderStyle;
270
271             break;
272         }
273
274         if (isNaN(strokeWeight)) {
275             strokeWeight = 0;
276             
277         } 
278         stroked =( strokeWeight> 0);
279         
280
281         //================================================================================
282         for (var i = 0; i < 16; i++) {
283             for (var j = 0; j < 16; j++) {
284                 decToHex[i * 16 + j] = i.toString(16) + j.toString(16);
285             }
286         }
287         //==================================
288         var fillColor = translateColor(getStyles(Obj).backgroundColor);
289         var strokeColor =  translateColor(getStyles(Obj).borderColor);
290 
291
292         width=jQuery(Obj).width();
293         height=jQuery(Obj).height();
294              Width=(width+strokeWeight );
295     Height=(height+strokeWeight);
296
297         Left=parseInt(jQuery(Obj).css("left"));
298         if (isNaN(Left)) Left=0 ;
299         Top=parseInt(jQuery(Obj).css("top"));
300           if (isNaN(Top)) Top=0 ;
301   //=================================================================
302           s = getStyles(Obj);
303
304         if (typeof s.transform != "undefined") {
305             rotation = s['transform'];
306             var angle1 = s.transform.split("rotate(");
307             angle1 = angle1[1].split("deg)");
308             angle = angle1[0];
309         }
310         //=================================================================
311
312
313         var VgFillType = new Array("solid", "gradient", "gradientradial", "tile", "pattern", "frame");
314         var VgFillmethod = new Array("none", "linear", "sigma", "any");
315         var VgFillaspect = new Array("atless", "atmost")
316
317
318         alpha = getStyles(Obj)['opacity'] || 1;
319
320
321         var fillSrc = getStyles(Obj).backgroundImage.replace(/^url\("(.+)"\)$/, '$1');
322
323         if (fillSrc) var filltype = (getStyles(Obj)['type']) || "tile";
324         else var filltype = (getStyles(Obj)['type']) || "gradientRadial";
325  /*
326         var fillopacity = alpha;
327       
328         var fillmethod = "none";
329         var fillfocus = "100%";
330
331         var fillcolor2 = "#00FF00";
332         var fillcolors = "0,#ff0000, 0.5#00ff00, 0.6 #0000ff, 0.8 #ff0000, 0.9 #ff0000";
333
334         var fillopacity2 = "1.0";
335         var fillangle = "0";
336         var fillfocusposition = "0.5,0.5";
337         */
338       
339
340         //==================================================================================   
341         radius = s['-moz-border-radius'];
342
343
344         if (typeof radius == "undefined") { radius = "0" }
345         if (typeof radius == undefined) { radius = "" }
346                 
347         if (radius.match("\/")) {
348             //=============================================================
349
350             var tableau = radius.split("/");
351             var rect = document.createElement('v:oval');
352             var typeelement="oval";
353
354         } else {
355                   if (radius.match("\ ")) { 
356          var tableau = radius.split(" "); 
357
358          }
359
360  var tableau = radius.split(" "); 
361      tableau = radius + " " + radius + " " +tableau[0] +" " + tableau[0] + " " + tableau[0];   
362      tableau = tableau.split(" "); 
363      top_left = parseInt(s['-moz-border-top-left-radius']||tableau[0]) ;
364      top_right =  parseInt(s['-moz-border-top-right-radius']||tableau[1]);
365      bottom_right =  parseInt(s['-moz-border-radius-radius']||tableau[2]);
366      bottom_left =  parseInt(s['-moz-border-bottom-left-radius']||tableau[3]);       
367
368
369     radius=tableau[0];
370//=============================================================
371if (parseInt(radius) != "0") {
372    if (top_left!=top_right) {
373          var typeelement="shape";
374          var rect = document.createElement('v'+classID+':shape');     
375
376       with(rect){
377            fillColor = 'none'; 
378            fillStroked = 'true';
379             //   coordsize  = "100 , 100";
380             //    coordSize  = "100 , 100";
381               }
382     
383        rect.setAttribute("coordSize",Width + "," + Height); //mode7
384 TL =top_left ;
385 TR = top_right  ;
386 BR = bottom_right ;
387 BL =bottom_left ;
388
389
390
391 var Origine ={ x: Width - TR, y:0} ;
392 var TR_  ={ x: Width , y : 0 + TR} ;
393 var L1 ={ x: Width , y:Height-BR} ;
394 var BR_ ={ x: Width - BR, y:Height} ;
395 var L2 ={ x:BL, y:Height} ;
396 var BL_ ={ x:0 , y:Height-BL} ;
397 var L3 ={ x:0 , y:TL} ;
398 var TL_ ={ x:TL, y:0} ;
399 var L4 ={ x: Width - TR, y:0} ;
400
401 var path=" m "+ Origine.x +","+ Origine.y + 
402        " qx " + TR_.x + "," + TR_.y +
403        " l  " + L1.x + "," + L1.y +
404        " qy " + BR_.x + "," + BR_.y +
405        " l " + L2.x + "," + L2.y +
406        " qx "+ BL_.x + "," + BL_.y +
407        " l " + L3.x + "," + L3.y +
408        " qy "+ TL_.x + "," + TL_.y +
409        " l " + L4.x + "," + L4.y +
410        " x e";
411    rect.path=path ;
412
413 
414    }   else {       
415        var typeelement="roundrect";
416        var rect = document.createElement('v'+classID+':roundrect');
417        var arcSize = Math.min(parseInt(radius) / Math.min(Obj.offsetWidth, Obj.offsetHeight), 1);     
418        rect.arcsize = arcSize + 'px';
419        }
420  } else {
421                 var rect = document.createElement('v'+classID+':rect');
422                 var typeelement="rect";
423             }
424
425         }
426
427
428         /*===================================================================================*/
429         var text_shadow = getStyles(Obj)['text-shadow'];
430
431         var box_shadow = getStyles(Obj)['-moz-box-shadow'] ||
432                   getStyles(Obj)['box-shadow'] ||
433                   getStyles(Obj)['-webkit-box-shadow'] ||
434                   getStyles(Obj)['-khtml-box-shadow'];
435
436
437
438         if (text_shadow || box_shadow) {
439             if (text_shadow) {
440                 var sizeShadow = text_shadow.split(" ");
441                 aff_filter(Obj, sizeShadow);
442
443             }
444
445
446             if (box_shadow) {
447                 var sizeShadow = box_shadow.split(" ");
448                 aff_filter(rect, sizeShadow)
449             }
450
451         }
452         /*===================================================================================*/
453
454         var fill = document.createElement('v'+classID+':fill');
455
456         fill.src = fillSrc;
457         fill.color = fillColor;
458         fill.type = filltype;
459     
460
461/*
462         var fillopacity = alpha;
463if(fillopacity)      fill.opacity = fillopacity;
464
465         var fillmethod = "none";
466if (fillmethod) fill.method = fillmethod;
467
468         var fillfocus = "100%";
469         var fillcolor2 = "#00FF00";
470         var fillcolors = "0,#ff0000, 0.5#00ff00, 0.6 #0000ff, 0.8 #ff0000, 0.9 #ff0000";
471            if (fillfocus) fill.focus = fillfocus;
472            if (fillcolor2) fill.color2 = fillcolor2;
473            if (fillcolors) fill.colors = fillcolors;
474
475         var fillopacity2 = "1.0";
476         var fillangle = "0";
477         var fillfocusposition = "0.5,0.5";
478            if (fillopacity2) fill.opacity2 = fillopacity2;
479            if (fillangle) fill.angle = fillangle;
480            if (fillfocusposition) fill.focusposition = fillfocusposition;
481
482*/
483              jQuery(rect).width(Width  );
484              jQuery(rect).height(Height );
485               
486         rect.appendChild(fill);
487//================================================================
488         with(rect.style){
489                left=Left+(0.5*strokeWeight);
490                top=Top+(0.5*strokeWeight);
491                position="absolute"
492                display = 'block';
493                antialias = true;
494                zindex = el_zindex+3;
495
496             }
497//<v:stroke on="True" filltype="solid"
498 //   color="#9094C9" weight="8pt" />
499//   filltype="pattern" src="rond.gif" />
500
501if (stroked) {
502                    rect.strokecolor = strokeColor;
503                    rect.strokeWeight = strokeWeight + 'px';
504                    rect.stroked = stroked;
505   }
506        //================================================================
507document.body.appendChild(rect);
508  var css =  document.createStyleSheet(); 
509  var styleSheet = (document.styleSheets.length > 0) ? document.styleSheets[0] :  document.createStyleSheet();
510        //  css = styleSheet;
511//if (stroked)  css.addRule('v'+classID+"\\:stroke" , "behavior: url(#default#VML)");
512         css.addRule('v'+classID+"\\:"+typeelement, "behavior: url(#default#VML)");
513         css.addRule('v'+classID+"\\:fill", "behavior: url(#default#VML)");
514       //  css.addRule("v\\:*", "behavior: url(#default#VML)");
515         //=================================================================   
516   
517       
518
519          Obj.style.background =    'transparent';
520          Obj.style.borderColor = 'transparent';
521
522         isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
523         // IE6 doesn't support transparent borders, use padding to offset original element
524         if (isIE6 && (strokeWeight > 0)) {
525             Obj.style.borderStyle = 'none';
526             Obj.style.paddingTop = parseInt(getStyles(Obj).paddingTop || 0) + strokeWeight;
527             Obj.style.paddingBottom = parseInt(getStyles(Obj).paddingBottom || 0) + strokeWeight;
528         }
529
530
531   init_x = Left;
532   init_y = Top;
533   init_x0 = Left;
534   init_y0 = Top;
535
536        init_x  =parseInt(init_x)+strokeWeight;
537        init_y = parseInt(init_y)+strokeWeight;
538
539        init_x0  =parseInt(init_x);
540        init_y0 = parseInt(init_y);
541
542         Obj.vml = rect;
543
544//===============================================================================================
545         if (typeof (window.rounded_elements) == 'undefined') {
546             window.rounded_elements = new Array();
547
548             if (typeof (window.onresize) == 'function') { window.previous_onresize = window.onresize; }
549             window.onresize = window_resize;
550         }
551         window.rounded_elements[i]
552         window.rounded_elements.push(Obj);
553
554        // Resize(Obj.element);
555         obj = Obj;
556         init = false;
557    transform(obj)
558
559         Obj.attachEvent('onpropertychange', onPropertyChange);
560     }
561     //=====================================================================================
562     var Curwidth = 0;
563     var Curheight = 0;
564
565     function Resize(obj) {
566     return ;
567
568         var h0 = 0;
569         var strokeWeight = parseInt(getStyles(obj).borderWidth);
570         if (isNaN(strokeWeight)) { strokeWeight = 0; }
571
572
573         Size = findSize(obj);
574         //     obj.style.backgroundColor="green";
575
576         pos = findPos(obj);
577         var parent_pos = findPos(obj.vml.parentNode);
578         //var position = $(obj).position();
579         pos.y = pos.y + (0.5 * strokeWeight) - parent_pos.y;
580         pos.x = pos.x + (0.5 * strokeWeight) - parent_pos.x;
581         objvml = obj.vml;
582         objvml.style.top = pos.y + 'px';
583         objvml.style.left = pos.x + 'px';
584
585         //===================================================
586         if (Curwidth == 0) {
587             OldWidth =  objvml.offsetWidth;
588
589             OldHeight = objvml.offsetHeight;
590             Curwidth = obj.offsetWidth - strokeWeight;
591             Curheight =   obj.offsetHeight - strokeWeight;
592 
593         }
594
595         objvml.style.width= Curwidth ;
596         objvml.style.height=Curheight ;
597
598     }
599     //==================================================================================
600     function window_resize() {
601         if (typeof (window.rounded_elements) == 'undefined') { return (false); }
602         if (typeof (handle) == 'undefined') { return (false); }
603         old_handle = handle;
604         old_angle = nangle;
605         rotate(0, true)
606         Curwidth = 0;
607         for (var i in window.rounded_elements) {
608             Resize(window.rounded_elements[i]);
609         }
610
611         if (typeof (window.previous_onresize) == 'function') { window.previous_onresize(); }
612         nangle = old_angle
613         if (old_handle) toggleAnimation()
614
615     }
616     //=======================================================================================
617
618     function aff_filter(obj, sizeShadow) {
619     if (!obj) return ;
620
621         if (typeof obj == "string") var s = document.getElementById(obj).style;
622         else var s = obj.style;
623         Blur = 0;
624         ShadowColor = 0;
625         Horizontal = sizeShadow[0];
626         Vertical = sizeShadow[1];
627         if (sizeShadow.length > 2) Blur = sizeShadow[2]; //radius
628         if (sizeShadow.length > 3) ShadowColor = translateColor(sizeShadow[3]);
629
630
631         direction = 180 - Math.atan((parseInt(Horizontal)) / (parseInt(Vertical))) * 180 / Math.PI;
632         Strength = parseInt(Blur);
633         couleur = ShadowColor;
634
635         obj.style.filter = "progid:DXImageTransform.Microsoft.Shadow(color =" + couleur + ",Direction =" + direction + ",Strength = " + Strength + ") ";
636
637
638
639
640
641         return;
642
643     }
644
645     function hasSilverlight() {
646         try {
647             new ActiveXObject('AgControl.AgControl');
648             return true;
649         } catch (_) {
650             return false;
651         }
652     }
653
654     function getRgbHslContent(styleString) {
655         var start = styleString.indexOf('(', 3);
656         var end = styleString.indexOf(')', start + 1);
657         var parts = styleString.substring(start + 1, end).split(',');
658         // add alpha if needed
659         if (parts.length == 4 && styleString.substr(3, 1) == 'a') {
660             alpha = +parts[3];
661         } else {
662             parts[3] = 1;
663         }
664         return parts;
665     }
666
667     function percent(s) {
668         return parseFloat(s) / 100;
669     }
670
671     function clamp(v, min, max) {
672         return Math.min(max, Math.max(min, v));
673     }
674
675     function hslToRgb(parts) {
676         var r, g, b, h, s, l;
677         h = parseFloat(parts[0]) / 360 % 360;
678         if (h < 0)
679             h++;
680         s = clamp(percent(parts[1]), 0, 1);
681         l = clamp(percent(parts[2]), 0, 1);
682         if (s == 0) {
683             r = g = b = l; // achromatic
684         } else {
685             var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
686             var p = 2 * l - q;
687             r = hueToRgb(p, q, h + 1 / 3);
688             g = hueToRgb(p, q, h);
689             b = hueToRgb(p, q, h - 1 / 3);
690         }
691
692         return decToHex[Math.floor(r * 255)] +
693         decToHex[Math.floor(g * 255)] +
694         decToHex[Math.floor(b * 255)];
695     }
696
697     function hueToRgb(m1, m2, h) {
698         if (h < 0)
699             h++;
700         if (h > 1)
701             h--;
702
703         if (6 * h < 1)
704             return m1 + (m2 - m1) * 6 * h;
705         else if (2 * h < 1)
706             return m2;
707         else if (3 * h < 2)
708             return m1 + (m2 - m1) * (2 / 3 - h) * 6;
709         else
710             return m1;
711     }
712     function hexToDec(hex) {
713         return parseInt(hex, 16);
714     }
715
716
717     function translateColor(styleString) {
718         var str;
719         var n = 0;
720
721
722         styleString = String(styleString);
723         if (styleString.charAt(0) == '#') {
724             styleString = (styleString + "00000000").substring(0, 7);
725
726             return styleString;
727         } else if (/^rgb/.test(styleString)) {
728             var parts = getRgbHslContent(styleString);
729             var str = '', n;
730             for (var i = 0; i < 3; i++) {
731                 if (parts[i].indexOf('%') != -1) {
732                     n = Math.floor(percent(parts[i]) * 255);
733                 } else {
734                     n = +parts[i];
735                 }
736                 str += decToHex[clamp(n, 0, 255)];
737             }
738
739             alpha = parts[3];
740         } else if (/^hsl/.test(styleString)) {
741             var parts = getRgbHslContent(styleString);
742             str = hslToRgb(parts);
743             alpha = parts[3];
744         } else if (styleString in colorData) {
745             var exp = new RegExp(/^#/);
746
747             return colorData[styleString];
748
749
750
751         } else {
752
753
754             return styleString;
755
756
757         }
758         // decToHex[Math.floor(alpha * 255)] +
759         return '#' + str;
760     }         
761 
762      var colorData = {
763         aliceblue: '#F0F8FF',
764         antiquewhite: '#FAEBD7',
765         aquamarine: '#7FFFD4',
766         azure: '#F0FFFF',
767         beige: '#F5F5DC',
768         bisque: '#FFE4C4',
769         black: '#000000',
770         blanchedalmond: '#FFEBCD',
771         blueviolet: '#8A2BE2',
772         brown: '#A52A2A',
773         burlywood: '#DEB887',
774         cadetblue: '#5F9EA0',
775         chartreuse: '#7FFF00',
776         chocolate: '#D2691E',
777         coral: '#FF7F50',
778         cornflowerblue: '#6495ED',
779         cornsilk: '#FFF8DC',
780         crimson: '#DC143C',
781         cyan: '#00FFFF',
782         darkblue: '#00008B',
783         darkcyan: '#008B8B',
784         darkgoldenrod: '#B8860B',
785         darkgray: '#A9A9A9',
786         darkgreen: '#006400',
787         darkgrey: '#A9A9A9',
788         darkkhaki: '#BDB76B',
789         darkmagenta: '#8B008B',
790         darkolivegreen: '#556B2F',
791         darkorange: '#FF8C00',
792         darkorchid: '#9932CC',
793         darkred: '#8B0000',
794         darksalmon: '#E9967A',
795         darkseagreen: '#8FBC8F',
796         darkslateblue: '#483D8B',
797         darkslategray: '#2F4F4F',
798         darkslategrey: '#2F4F4F',
799         darkturquoise: '#00CED1',
800         darkviolet: '#9400D3',
801         deeppink: '#FF1493',
802         deepskyblue: '#00BFFF',
803         dimgray: '#696969',
804         dimgrey: '#696969',
805         dodgerblue: '#1E90FF',
806         firebrick: '#B22222',
807         floralwhite: '#FFFAF0',
808         forestgreen: '#228B22',
809         gainsboro: '#DCDCDC',
810         ghostwhite: '#F8F8FF',
811         gold: '#FFD700',
812         goldenrod: '#DAA520',
813         grey: '#808080',
814         greenyellow: '#ADFF2F',
815         honeydew: '#F0FFF0',
816         hotpink: '#FF69B4',
817         indianred: '#CD5C5C',
818         indigo: '#4B0082',
819         ivory: '#FFFFF0',
820         khaki: '#F0E68C',
821         lavender: '#E6E6FA',
822         lavenderblush: '#FFF0F5',
823         lawngreen: '#7CFC00',
824         lemonchiffon: '#FFFACD',
825         lightblue: '#ADD8E6',
826         lightcoral: '#F08080',
827         lightcyan: '#E0FFFF',
828         lightgoldenrodyellow: '#FAFAD2',
829         lightgreen: '#90EE90',
830         lightgrey: '#D3D3D3',
831         lightpink: '#FFB6C1',
832         lightsalmon: '#FFA07A',
833         lightseagreen: '#20B2AA',
834         lightskyblue: '#87CEFA',
835         lightslategray: '#778899',
836         lightslategrey: '#778899',
837         lightsteelblue: '#B0C4DE',
838         lightyellow: '#FFFFE0',
839         limegreen: '#32CD32',
840         linen: '#FAF0E6',
841         magenta: '#FF00FF',
842         mediumaquamarine: '#66CDAA',
843         mediumblue: '#0000CD',
844         mediumorchid: '#BA55D3',
845         mediumpurple: '#9370DB',
846         mediumseagreen: '#3CB371',
847         mediumslateblue: '#7B68EE',
848         mediumspringgreen: '#00FA9A',
849         mediumturquoise: '#48D1CC',
850         mediumvioletred: '#C71585',
851         midnightblue: '#191970',
852         mintcream: '#F5FFFA',
853         mistyrose: '#FFE4E1',
854         moccasin: '#FFE4B5',
855         navajowhite: '#FFDEAD',
856         oldlace: '#FDF5E6',
857         olivedrab: '#6B8E23',
858         orange: '#FFA500',
859         orangered: '#FF4500',
860         orchid: '#DA70D6',
861         palegoldenrod: '#EEE8AA',
862         palegreen: '#98FB98',
863         paleturquoise: '#AFEEEE',
864         palevioletred: '#DB7093',
865         papayawhip: '#FFEFD5',
866         peachpuff: '#FFDAB9',
867         peru: '#CD853F',
868         pink: '#FFC0CB',
869         plum: '#DDA0DD',
870         powderblue: '#B0E0E6',
871         rosybrown: '#BC8F8F',
872         royalblue: '#4169E1',
873         saddlebrown: '#8B4513',
874         salmon: '#FA8072',
875         sandybrown: '#F4A460',
876         seagreen: '#2E8B57',
877         seashell: '#FFF5EE',
878         sienna: '#A0522D',
879         skyblue: '#87CEEB',
880         slateblue: '#6A5ACD',
881         slategray: '#708090',
882         slategrey: '#708090',
883         snow: '#FFFAFA',
884         springgreen: '#00FF7F',
885         steelblue: '#4682B4',
886         tan: '#D2B48C',
887         thistle: '#D8BFD8',
888         tomato: '#FF6347',
889         turquoise: '#40E0D0',
890         violet: '#EE82EE',
891         wheat: '#F5DEB3',
892         whitesmoke: '#F5F5F5',
893         yellowgreen: '#9ACD32'
894     };
895//=====================================================================
896// Ajoute une fonctionnalité jQuery
897jQuery.extend(jQuery.expr[':'], {
898        // Nom du sélecteur personnalisé
899        Radius: function (a) {
900            if (!jQuery.browser.msie) return;
901
902    s= getStyles(a);
903           var moz = s['-moz-border-radius'] !== undefined   ;
904            var webkit = s['-webkit-border-radius'] !== undefined;
905            var radius = s['border-radius'] !== undefined ||s['border-Radius'] !== undefined || s['Border-Radius'] !== undefined;
906
907            var mode = document.documentMode || 0;
908            var noBottomFold = jQuery.browser.msie && ((jQuery.browser.version < 8 && !mode) || mode < 8);
909
910            // Eléments correspondant
911       Attribut = s[radius ? 'border-radius' : moz ? '-moz-border-radius' : '-webkit-border-radius'];
912            if (Attribut != undefined) {
913                jQuery(a).crossbrowser(a);
914                 
915            }
916            return false;
917
918        }
919    });
920 //==============================================================================
921jQuery.fn.extend({
922   findPos : function() {
923       obj = jQuery(this).get(0);
924       var curleft = obj.offsetLeft || 0;
925       var curtop = obj.offsetTop || 0;
926       while (obj = obj.offsetParent) {
927                curleft += obj.offsetLeft
928                curtop += obj.offsetTop
929       }
930       return {x:curleft,y:curtop};
931   }
932});
933 //==============================================================================       
934jQuery.fn.crossbrowser = function (options) {
935         oncontentready(options);
936 }
937 
938})(jQuery);
939//================================================================================
940 
941
942
943jQuery(document).ready(function () {
944
945 jQuery(':Radius');
946
947
948});
949
950
951//====================================================================
952function Get_Tableau(Val_src) {
953    Val_src = removeExtraSpace(Val_src)
954
955    var tableau = Val_src.split(" ");
956    tableau = Val_src + " " + Val_src + " " + tableau[0] + " " + tableau[0];
957
958    tableau = tableau.split(" ");
959
960    return { Top: tableau[0], Right: tableau[1], Bottom: tableau[2], Left: tableau[3] };
961}
962//============================================================
963function Get_radius(obj) {
964    /*
965    1 La valeur spécifiée est appliquée aux quatre coins.
966    2 La première valeur est appliquée aux coins supérieur gauche et inférieur droit, et la seconde, aux coins supérieur droit et inférieur gauche 
967    3 La première valeur est appliquée au coin supérieur gauche, la deuxième aux coins supérieur droit et inférieur gauche, et la troisième, au coin inférieur droit 
968    4 Les angles supérieur gauche, supérieur droit, inférieur droit et inférieur gauche sont respectivement définis 
969    */
970
971    var m1 = "border-radius,-o-border-radius,-moz-border-radius,-webkit-border-radius,star";
972    m1 += ",borderRadius,OBorderRadius,MozBorderRadius,WebkitBorderRadius,star";
973
974    $e = jQuery(obj);
975    m1 = m1.split(",");
976    s = obj.currentStyle;
977    // s = obj.style.cssText.split(";");
978
979    Attribut = false;
980    type = "";
981    for (i in m1)
982        if (s[m1[i]] != undefined) {
983            Attribut = true;
984            radius = s[m1[i]];
985            type = m1[i];
986            break;
987        }
988    if (typeof radius == "undefined") { radius = "0" }
989    var reg = new RegExp("\ \ ", "g");
990    nr = radius;
991    while (radius.match("\/")) {
992        radius = radius.replace("\/", " ");
993    }
994
995    while (radius.match("\ \ ")) {
996        radius = radius.replace(reg, " ");
997    }
998
999    if (type.match("star")) {
1000        var radius = (radius + " " + 1)
1001        var tableau = radius.split(" ");
1002        return { r: tableau[0],
1003            type: type
1004        }
1005    }
1006
1007
1008    v1 = Get_Tableau(radius);
1009
1010
1011
1012    top_left = parseInt(s['border-top-left-radius'] || v1.Top);
1013    top_right = parseInt(s['border-top-right-radius'] || v1.Right);
1014    bottom_right = parseInt(s['border-bottom-right-radius'] || v1.Bottom);
1015    bottom_left = parseInt(s['border-bottom-left-radius'] || v1.Left);
1016
1017
1018
1019    type = (nr.match("\/")) ? "oval" : (parseInt(v1.Left) == 0) ? "rect" : "shape";
1020
1021    return { r: v1.Left,
1022        top_left: top_left,
1023        top_right: top_right,
1024        bottom_right: bottom_right,
1025        bottom_left: bottom_left,
1026        type: type
1027    };
1028
1029}
1030//=======================================================================================
1031/*
1032Single (default)
1033ThinThin
1034ThinThick
1035ThickThin
1036ThickBetweenThin
1037*/
1038function Get_style(borderStyle_src) {
1039
1040    v1 = Get_Tableau(borderStyle_src);
1041
1042    for (i1 in v1) {
1043        borderStyle = v1[i1];
1044
1045
1046        switch (borderStyle) {
1047            case 'solid':
1048                strokeStyle[i1] = "Single";
1049                break;
1050            case 'double':
1051                strokeStyle[i1] = "thinThin";
1052                break;
1053            case 'none':
1054                strokeStyle[i1] = "Single";
1055                stroked = false
1056                break;
1057            default:
1058                strokeStyle[i1] = "Single";
1059
1060                break;
1061        }
1062
1063    }
1064    return strokeStyle;
1065}
1066
1067//=============================================================
1068function Get_Color(Color_src) {
1069
1070    v1 = Get_Tableau(Color_src);
1071    for (i1 in v1) {
1072        strokeColor[i1] = (translateColor(v1[i1]) == "transparent") ? "none" : translateColor(v1[i1]);
1073
1074    }
1075
1076    return strokeColor;
1077}
1078
1079//=============================================================
1080function Get_stokeWeight(Weight_src) {
1081
1082    v1 = Get_Tableau(Weight_src);
1083    stroked = false;
1084    for (i1 in v1) {
1085        Weight = v1[i1];
1086        p1 = Weight.match("%")
1087
1088        switch (Weight) {
1089            case p1:
1090                strokeWeight[i1] = 10;
1091                break;
1092            case 'thin':
1093                strokeWeight[i1] = 0.5;
1094                break;
1095            case 'medium':
1096                strokeWeight[i1] = 0.75;
1097                break;
1098            case 'thick':
1099                strokeWeight[i1] = 2;
1100                break;
1101            case 'inherit':
1102                if (Obj.parentElement)
1103                    strokeWeight[i1] = Get_stokeWeight(Obj.parentElement.currentStyle.borderWidth);
1104                else
1105                    strokeWeight[i1] = 0;
1106
1107                break;
1108
1109            default:
1110
1111                strokeWeight[i1] = Weight;
1112                break;
1113        }
1114        strokeWeight[i1] = parseInt(strokeWeight[i1]);
1115        if (isNaN(strokeWeight[i1])) {
1116            strokeWeight[i1] = 0;
1117        }
1118
1119        stroked = (strokeWeight[i1] > 0) ? true : stroked;
1120    }
1121    return strokeWeight;
1122
1123}
1124
1125// Récupérer la valeur d'une propriété CSS d'un élément id
1126function getStyle(elt, pro) {
1127    var element = document.getElementById(elt);
1128    if (window.getComputedStyle) // Mozilla Firefox & cie
1129    {
1130        var propriete = window.getComputedStyle(element, null).getPropertyValue(pro);
1131    }
1132    else if (element.currentStyle) // Microsoft Internet Explorer
1133    {
1134        // Formatage (IE) de la propriété CSS
1135        while (pro.indexOf('-') != -1) {
1136            var lettresuivtiret = pro.charAt(pro.indexOf('-') + 1);
1137            pro = pro.replace(/-\S{1}/, lettresuivtiret.toUpperCase());
1138        }
1139        var propriete = eval('element.currentStyle.' + pro);
1140    }
1141    return propriete;
1142}
1143// Récupérer la valeur CSS
1144function getStyles(elt) {
1145    var element = elt;
1146    if (window.getComputedStyle) // Mozilla Firefox & cie
1147    {
1148        var propriete = window.getComputedStyle(element, null);
1149    }
1150    else if (element.currentStyle) // Microsoft Internet Explorer
1151    {
1152
1153        var propriete = element.currentStyle;
1154    }
1155    return propriete;
1156}
Note: See TracBrowser for help on using the repository browser.