Commit 4e92275db60176c4da0c6769f19fdbe4cac57eca

Authored by AurelioAHeckert
1 parent 008118fb

ActionItem183: better help interaction

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1515 3f533792-8f58-4932-b0fe-aaf55b0a4547
public/javascripts/noosfero-show-help.js
@@ -13,20 +13,25 @@ function mouseHelpOnOff() { @@ -13,20 +13,25 @@ function mouseHelpOnOff() {
13 document.cookie = "mouseHelpTurnOn="+ pageHelp.info.updateBox + expires +"; path=/"; 13 document.cookie = "mouseHelpTurnOn="+ pageHelp.info.updateBox + expires +"; path=/";
14 } 14 }
15 15
16 -function noosferoHelpInit(confirm_msg, rejected_msg) {  
17 - if ( document.cookie.indexOf("mouseHelpTurnOn=") > -1 ) {  
18 - if ( document.cookie.indexOf("mouseHelpTurnOn=true") > -1 ) {  
19 - mouseHelpOnOff();  
20 - }  
21 - } else {  
22 - var date = new Date();  
23 - date.setTime( date.getTime() + ( 60*24*60*60*1000 ) );  
24 - var expires = "; expires=" + date.toGMTString();  
25 - document.cookie = "mouseHelpTurnOn=false" + expires +"; path=/";  
26 - if ( confirm(confirm_msg) ) {  
27 - mouseHelpOnOff();  
28 - } else {  
29 - alert(rejected_msg)  
30 - } 16 +function mouseHelpOn() {
  17 + mouseHelpOnOff();
  18 + new Effect.Fade( "noticeAboutHelp" );
  19 +}
  20 +
  21 +function mouseHelpOff() {
  22 + var date = new Date();
  23 + date.setTime( date.getTime() + ( 60*24*60*60*1000 ) );
  24 + var expires = "; expires=" + date.toGMTString();
  25 + document.cookie = "mouseHelpTurnOn=false" + expires +"; path=/";
  26 + new Effect.Fade( "noticeAboutHelp" );
  27 +}
  28 +
  29 +if ( document.cookie.indexOf("mouseHelpTurnOn=") > -1 ) {
  30 + if ( document.cookie.indexOf("mouseHelpTurnOn=true") > -1 ) {
  31 + mouseHelpOnOff();
31 } 32 }
32 } 33 }
  34 +else {
  35 + new Effect.Appear( "noticeAboutHelp", {duration:2} );
  36 +}
  37 +
public/javascripts/show-mouse-help.js
@@ -114,21 +114,26 @@ function getHelp( ev ) { @@ -114,21 +114,26 @@ function getHelp( ev ) {
114 debug += " :: "+ el.nodeName +" "+ el.getAttribute("help"); 114 debug += " :: "+ el.nodeName +" "+ el.getAttribute("help");
115 debug += "<br>"+ pageHelp.myFrame.src +" x:"+ mX +" y:"+ mY; 115 debug += "<br>"+ pageHelp.myFrame.src +" x:"+ mX +" y:"+ mY;
116 var txt = el.getAttribute("help"); 116 var txt = el.getAttribute("help");
117 - if ( txt ) {  
118 - box.style.display = "block";  
119 - if ( txt != "FALSE" ) {  
120 - if ( /^#.+/.test( txt ) ) {  
121 - var txtEl = el.ownerDocument.getElementById( txt.replace(/#/,"") );  
122 - if ( txtEl ) txt = txtEl.innerHTML; 117 + if ( txt != box.txt ) {
  118 + if ( txt ) {
  119 + helpWow(true);
  120 + box.style.display = "block";
  121 + if ( txt != "FALSE" ) {
  122 + var realTxt = txt;
  123 + if ( /^#.+/.test( txt ) ) {
  124 + var txtEl = el.ownerDocument.getElementById( txt.replace(/#/,"") );
  125 + if ( txtEl ) realTxt = txtEl.innerHTML;
  126 + }
  127 + box.content.innerHTML = '<p>'+ realTxt +'</p>'+
  128 + '<br style="clear:both" />'+
  129 + '<div class="help-force-clear-ieworkarroundbug"'+
  130 + ' style="height:1px; overflow:hidden"></div>';
123 } 131 }
124 - box.content.innerHTML = '<p>'+ txt +'</p>'+  
125 - '<br style="clear:both" />'+  
126 - '<div class="help-force-clear-ieworkarroundbug"'+  
127 - ' style="height:1px; overflow:hidden"></div>'; 132 + } else {
  133 + box.style.display = "none";
128 } 134 }
129 - } else {  
130 - box.style.display = "none";  
131 } 135 }
  136 + box.txt = txt;
132 box.style.left = ( mX + helpInfo.incPos.x ) +"px"; 137 box.style.left = ( mX + helpInfo.incPos.x ) +"px";
133 box.style.top = ( mY + helpInfo.incPos.y ) +"px"; 138 box.style.top = ( mY + helpInfo.incPos.y ) +"px";
134 } 139 }
@@ -180,12 +185,60 @@ if( window.attachEvent ) { // IE @@ -180,12 +185,60 @@ if( window.attachEvent ) { // IE
180 document.body.attachEvent( "onmousemove", getHelp ); 185 document.body.attachEvent( "onmousemove", getHelp );
181 } 186 }
182 187
  188 +function helpWow( start ) {
  189 + var bg = pageHelp.info.bg;
  190 + var box = pageHelp.info.helpBox.style;
  191 + var change = false;
  192 + if ( start ) {
  193 + box.backgroundColor = "rgb("+ bg.r.wow +","+ bg.g.wow +","+ bg.b.wow +")";
  194 + bg.r.cur = bg.r.wow;
  195 + bg.g.cur = bg.g.wow;
  196 + bg.b.cur = bg.b.wow;
  197 + change = true;
  198 + } else {
  199 + for ( c in bg ) {
  200 + if ( bg[c].cur != bg[c].orig ) {
  201 + bg[c].cur += bg[c].inc;
  202 + if ( ( bg[c].inc > 0 ) && ( bg[c].cur > bg[c].orig ) ) bg[c].cur = bg[c].orig
  203 + if ( ( bg[c].inc < 0 ) && ( bg[c].cur < bg[c].orig ) ) bg[c].cur = bg[c].orig
  204 + change = true;
  205 + }
  206 + }
  207 + }
  208 + if ( change ) {
  209 + box.backgroundColor = "rgb("+ Math.round(bg.r.cur) +","+
  210 + Math.round(bg.g.cur) +","+
  211 + Math.round(bg.b.cur) +")";
  212 + setTimeout( "helpWow()", 20 )
  213 + }
  214 +}
  215 +
183 function showMouseHelpOn() { 216 function showMouseHelpOn() {
184 pageHelp.info.helpBox = document.getElementById("helpBox"); 217 pageHelp.info.helpBox = document.getElementById("helpBox");
185 pageHelp.info.helpBox.content = document.getElementById("helpBoxContent"); 218 pageHelp.info.helpBox.content = document.getElementById("helpBoxContent");
186 pageHelp.info.helpBox.setAttribute( "help", "FALSE" ); 219 pageHelp.info.helpBox.setAttribute( "help", "FALSE" );
187 pageHelp.info.updateBox = true; 220 pageHelp.info.updateBox = true;
188 pageHelp.info.myDoc.body.style.cursor = "help"; 221 pageHelp.info.myDoc.body.style.cursor = "help";
  222 + if ( window.getComputedStyle ) {
  223 + var bg = window.getComputedStyle( pageHelp.info.helpBox, "" ).backgroundColor;
  224 + } else {
  225 + var bg = pageHelp.info.helpBox.currentStyle.backgroundColor;
  226 + }
  227 + if ( /^#/.test(bg) ) {
  228 + var r = parseInt( bg.replace(/^#(..)..../,"$1"), 16 );
  229 + var g = parseInt( bg.replace(/^#..(..)../,"$1"), 16 );
  230 + var b = parseInt( bg.replace(/^#....(..)/,"$1"), 16 );
  231 + } else {
  232 + bg = bg.replace(/\s/g, "");
  233 + var r = parseInt( bg.replace(/^rgb\(([0-9]+),[0-9]+,[0-9]+\)/,"$1") );
  234 + var g = parseInt( bg.replace(/^rgb\([0-9]+,([0-9]+),[0-9]+\)/,"$1") );
  235 + var b = parseInt( bg.replace(/^rgb\([0-9]+,[0-9]+,([0-9]+)\)/,"$1") );
  236 + }
  237 + bg = { r:{orig:r,wow:255}, g:{orig:g,wow:250}, b:{orig:b,wow:100} }
  238 + for ( c in bg ) {
  239 + bg[c].inc = ( bg[c].orig - bg[c].wow ) / 20;
  240 + }
  241 + pageHelp.info.bg = bg;
189 } 242 }
190 243
191 function showMouseHelpOff() { 244 function showMouseHelpOff() {