source: trunk/spip/esqueleto-redcta/plugins/crayons/js/crayons-fade.js @ 357

Last change on this file since 357 was 69, checked in by guille, 16 years ago

Se agrego Plugin Crayon y se actualizaron los esqueletos para que funcione

File size: 2.8 KB
Line 
1
2// Gestion du Yellow Fade (fonctionnalite optionnelle)
3function easeInOut(minValue,maxValue,totalSteps,actualStep,powr) {
4        var delta = maxValue - minValue;
5        var stepp = minValue+(Math.pow(((1 / totalSteps)*actualStep),powr)*delta);
6        return Math.ceil(stepp)
7};
8
9function doBGFade(elem,startRGB,endRGB,finalColor,steps,intervals,powr) {
10        if (elem.bgFadeInt) window.clearInterval(elem.bgFadeInt);
11        var actStep = 0;
12        elem.bgFadeInt = window.setInterval(
13                function() {
14                        elem.style.backgroundColor = "rgb("+
15                                easeInOut(startRGB[0],endRGB[0],steps,actStep,powr)+","+
16                                easeInOut(startRGB[1],endRGB[1],steps,actStep,powr)+","+
17                                easeInOut(startRGB[2],endRGB[2],steps,actStep,powr)+")";
18                        actStep++;
19                        if (actStep > steps) {
20                        elem.style.backgroundColor = finalColor;
21                        window.clearInterval(elem.bgFadeInt);
22                        }
23                }
24                ,intervals)
25};
26
27function findPos(obj) {
28        var curleft = curtop = 0;
29        if (obj.offsetParent) {
30                curleft = obj.offsetLeft;
31                curtop = obj.offsetTop;
32                while (obj = obj.offsetParent) {
33                        curleft += obj.offsetLeft;
34                        curtop += obj.offsetTop;
35                }
36        }
37        return [curleft,curtop];
38};
39
40// demarrage crayons-fade
41jQuery(document).ready(function() {
42        if (configCrayons.cfg.yellow_fade) {
43                // Activer le Yellow Fade pour les elements editables
44                jQuery("div.crayon").hover(function(){doBGFade(this,[255,255,180],[255,255,255],'transparent',40,20,4);}, function(){});
45        }
46
47        if (configCrayons.cfg.filet) {
48                // on rajoute une div supplémentaire qui se cale avec la div courante
49                // C'est elle qui va s'afficher lors du hover
50               
51                // esthetique
52                jQuery('.crayon-icones img',this).css({
53                        'padding':'2px',
54                        'border':'2px solid #999',
55                        'border-left':'0',
56                        'background-color':'#FFF'
57                });
58                       
59                var test=0;
60               
61                jQuery('.crayon-autorise').each(
62                        function(){
63                                var contenu = jQuery(this).html();
64                                jQuery(this)
65                                        .css('height',this.offsetHeight + 'px')
66                                        .html('<div></div>');
67                                jQuery(this)
68                                        .find('div')
69                                                .html(contenu)
70                                                .css('position','absolute')
71                                                .css('width',this.offsetWidth + 'px');
72                                jQuery(this)
73                                        .prepend('<div class="survol"></div>')
74                                        .find('.survol')
75                                                .css('border','1px solid red')
76                                                .css('display','none')
77                                                .css('position','absolute')
78                                                .css('height',(this.offsetHeight - 2) + 'px')
79                                                .css('width',(this.offsetWidth - 2) + 'px');
80                                if (jQuery.browser.msie) {
81                            jQuery('#survol')
82                                                .css('width',this.offsetWidth + 'px')
83                                                .css('height',this.offsetHeight + 'px');
84                                }
85                        }
86                );
87
88                jQuery('.crayon-autorise').hover(
89                        function(){
90                                if (jQuery.browser.msie) jQuery(this).addClass('crayon-hover');
91                                jQuery('.survol', this).css('display','block');
92                        },
93                        function(){
94                                if (jQuery.browser.msie) jQuery(this).removeClass('crayon-hover');
95                                jQuery('.survol', this).css('display','none');
96                        }
97                );
98               
99        }
100
101});
Note: See TracBrowser for help on using the repository browser.