Jifty-Plugin-WyzzEditor

 view release on metacpan or  search on metacpan

share/web/static/js/wyzz.js  view on Meta::CPAN

  }
  toolbar2 += '<td>&nbsp;</td></tr>';

// the foreground color picker
  var swatchcount = 0;
  toolbar2 += '<tr><td colspan=' + colNumbers + '>';
  toolbar2 += '<div id="colorpicker' + n + '" class="colorpicker" style="display:none">';
    for (clr in buttonColors) {
      toolbar2 += '<a href="#" title="#' + buttonColors[clr] + '" alt="#' + buttonColors[clr] + '" "class="colorButton" onClick="formatTextColor(\'' + buttonColors[clr] + '\',\'' + n + '\');" style="background: #' + buttonColors[clr] + '">&nbsp;</a>'...
      swatchcount++;
      if(swatchcount%18==0) {
        toolbar2 += '<br>';
      }
    }
    toolbar2 += '<img class="closebutton" src="/static/img/wyzzicons/close.gif" border=0 onclick="closeColorPicker(\'colorpicker' + n + '\')"></div>';
  // the background color picker
  toolbar2 += '<div id="colorbackpicker' + n + '" class="colorpicker" style="display:none">';
  for (clr in buttonColors) {
    toolbar2 += '<a href="#" title="#' + buttonColors[clr] + '" alt="#' + buttonColors[clr] + '" class="colorButton" onClick="formatBackColor(\'' + buttonColors[clr] + '\',\'' + n + '\');" style="background: #' + buttonColors[clr] + '">&nbsp;</a>';
    swatchcount++;
    if(swatchcount%18==0) {
      toolbar2 += '<br>';
    }
  }
  toolbar2 += '<img class="closebutton" src="/static/img/wyzzicons/close.gif" border=0 onclick="closeColorPicker(\'colorbackpicker' + n + '\')"></div>'; 
  // the font picker
  toolbar2 += '<div id="fontpicker' + n + '" class="fontpicker" style="display:none">';
  var fCount = 0;
  for (fnt in myFonts) {
   if (fCount < myFonts.length) {
    fCount ++ ;
    toolbar2 += '<a href="#" class="fontSelect" onClick="formatFontName(\'' + myFonts[fnt] + '\',\'' + n + '\');" style="font-size:14px;padding: 0px 0px 0px 30px;font-family:' + myFonts[fnt] +'">' + myFonts[fnt] +'</a>';
    toolbar2 += '<br>';
   }
  }
  toolbar2 += '<img class="closebutton" src="/static/img/wyzzicons/close.gif" border=0 onclick="closeColorPicker(\'fontpicker' + n + '\')"></div>'; 
  // the special character picker
  toolbar2 += '<div id="specialpicker' + n + '" class="specialpicker" style="display:none"><table><tr>';
  var charcount = 0;
  for (chr in specialChars) {
   if ( charcount < specialChars.length ) {
    toolbar2 += '<td><a href="#" onClick="formatSpecialChar(\'' + specialChars[chr] + '\',\'' + n + '\');">' + specialChars[chr] + '</a>&nbsp;</td>';
    charcount++;
    if(charcount%10==0) {
      toolbar2 += '</tr><tr>';
    }
   }
  }
  toolbar2 += '</tr></table><br><img class="closebutton" src="/static/img/wyzzicons/close.gif" border=0 onclick="closeColorPicker(\'specialpicker' + n + '\')"></div>'; 
  // the header picker
  toolbar2 += '<div id="headerpicker' + n + '" class="headerpicker" style="display:none">';
  var hdrcount = 0;
  for (hdr in Headers) {
   if ( hdrcount < Headers.length ) {
   hdrcount ++;
    toolbar2 += '<a href="#" class="headerSelect" onClick="formatHeader(\'' + Headers[hdr] + '\',\'' + n + '\');" style="font-size:14px;padding: 0px 0px 0px 30px;font-family:arial">' + Headers[hdr] +'</a>';
    toolbar2 += '<br>';
   }
  }
  toolbar2 += '<img class="closebutton" src="/static/img/wyzzicons/close.gif" border=0 onclick="closeColorPicker(\'headerpicker' + n + '\')"></div>'; 
  // Add extra popups here
  // The help/about box
  // The copyright and link must remain unaltered
  toolbar2 += '<div id="helpbox' + n + '" class="helpbox" style="display:none">';
  toolbar2 += '<div class="help"><h4><img src="/static/img/wyzzicons/wyzzicon.gif" align="middle">Wyzz v' + version + '</h4><br>&copy; 2007 <a href="http://www.wyzz.info" target=_blank>www.wyzz.info</a><br><br></div>';
  toolbar2 += '<img class="closebutton" src="/static/img/wyzzicons/close.gif" border=0 onclick="closeColorPicker(\'helpbox' + n + '\')"></div></td></tr></table>';   

// Create iframe for editor
var iframe = '<table cellpadding="0" cellspacing="0" border="0" style="width:' + wyzzW + 'px; height:' + wyzzH + 'px;border: 1px inset #dddddd;"><tr><td valign="top">\n'
  + '<iframe frameborder="0" id="wysiwyg' + n + '"></iframe>\n'
  + '</td></tr></table>\n';
  
  // Insert toolbar after the textArea
  document.getElementById(n).insertAdjacentHTML("afterEnd", toolbar + toolbar2 + iframe);
	
  // Give the iframe the required height and width
  document.getElementById("wysiwyg" + n).style.height = wyzzH + "px";
  document.getElementById("wysiwyg" + n).style.width = wyzzW + "px";
	
  // Pass the textarea's existing text into the editor
  var content = document.getElementById(n).value;
  var doc = document.getElementById("wysiwyg" + n).contentWindow.document;
	
  // Write the textarea's content into the iframe
  doc.open();
  if (browserName == "Microsoft Internet Explorer") {
      doc.write('<link rel="stylesheet" media="screen" type="text/css" href="' + editstyle + '"/>' + content);
    } else {
      doc.write('<html><head><link rel="stylesheet" type="text/css" href="' + editstyle + '"/></head><body>' + content + '<br /></body></html>');
    }
  doc.close();

//  var browserName = navigator.appName;
  if (browserName == "Microsoft Internet Explorer"||browserName == "Opera") {    
    // Make the iframe editable
    doc.body.contentEditable = true;
  } else {
    // Make the iframe editable
    doc.designMode = "on";  
  }
	
  // Update the textarea with content in WYSIWYG when user submits form
  // var browserName = navigator.appName;
  if (browserName == "Microsoft Internet Explorer"||browserName == "Opera") {
    for (var idx=0; idx < document.forms.length; idx++) {
      document.forms[idx].attachEvent('onsubmit', function() { updateTextArea(n); });
    }
  }
  else {
  	for (var idx=0; idx < document.forms.length; idx++) {
    	document.forms[idx].addEventListener('submit',function OnSumbmit() { updateTextArea(n); }, true);
    }
  }
}

function formatTextColor(color, n, selected) {
  document.getElementById('wysiwyg' + n).contentWindow.document.execCommand('forecolor', false, color);
  document.getElementById('colorpicker' + n).style.display = "none";		
}

function formatBackColor(color, n, selected) {



( run in 1.805 second using v1.01-cache-2.11-cpan-364913b4093 )