Plugin Name: Smileys Plugin Description: Add smileys to your comment section to let your commenters express their digital facial expressions. Sarcasm isn't sarcasm without a wink ;-) Plugin URL: http://www.intensedebate.com Author: Austin Author URL: https://www.intensedebate.com/people/austin Date Added: March 5th, 2009 Code: //associative array of smileys, if editing, escape all regex chars var smiley_array = new Array(); smiley_array[':)'] = '0pt 0pt;'; smiley_array[':D'] = '-12px 0pt;'; smiley_array['xD'] = '-24px 0pt;'; smiley_array[';)'] = '-36px 0pt;'; smiley_array[':p'] = '-48px 0pt;'; smiley_array['^_^'] = '0pt -12px;'; smiley_array[':$'] = '-12px -12px;'; smiley_array['B)'] = '-24px -12px;'; smiley_array[':*'] = '-36px -12px;'; smiley_array['<3'] = '-48px -12px;'; smiley_array[':S'] = '0pt -24px;'; smiley_array[':|'] = '-12px -24px;'; smiley_array['=/'] = '-24px -24px;'; smiley_array[':x'] = '-36px -24px;'; smiley_array['o.0'] = '-48px -24px;'; smiley_array[':o'] = '0pt -36px;'; smiley_array[':('] = '-12px -36px;'; smiley_array[':@'] = '-24px -36px;'; smiley_array[":%27("] = '-36px -36px;'; smiley_array = id_clean_array(smiley_array); function id_add_smiley_button() { var contents_new_thread = 'Smileys'; li_new_thread = document.createElement("LI"); IDReplaceHtml(li_new_thread, contents_new_thread); li_reply = document.createElement("LI"); IDReplaceHtml(li_reply, contents_reply); $id('idc-plugin-buttons-new-thread').appendChild(li_new_thread); $id('idc-plugin-buttons-reply').appendChild(li_reply); }; function id_replace_smileys_with_images(array) { var text = array['text']; //Add all the - to smileys smiley_array_replace = new Array(); for( var smiley in smiley_array) { if(typeof(smiley) != 'string') continue; smiley_array_replace[smiley] = smiley_array[smiley]; } smiley_array_replace[':-)'] = '0pt 0pt;'; smiley_array_replace[':-D'] = '-12px 0pt;'; smiley_array_replace['x-D'] = '-24px 0pt;'; smiley_array_replace[';-)'] = '-36px 0pt;'; smiley_array_replace[':-p'] = '-48px 0pt;'; smiley_array_replace[':-$'] = '-12px -12px;'; smiley_array_replace['B-)'] = '-24px -12px;'; smiley_array_replace[':-*'] = '-36px -12px;'; smiley_array_replace['<3'] = '-48px -12px;'; smiley_array_replace[':-S'] = '0pt -24px;'; smiley_array_replace[':-|'] = '-12px -24px;'; smiley_array_replace[':-/'] = '-24px -24px;'; smiley_array_replace[':-x'] = '-36px -24px;'; smiley_array_replace['o.0'] = '-48px -24px;'; smiley_array_replace[':-o'] = '0pt -36px;'; smiley_array_replace[':-('] = '-12px -36px;'; smiley_array_replace[':-@'] = '-24px -36px;'; smiley_array_replace[":-%27("] = '-36px -36px;'; smiley_array_replace[":-'("] = '-36px -36px;'; smiley_array_replace[":'("] = '-36px -36px;'; for( var smiley in smiley_array_replace) { if(typeof(smiley_array_replace[smiley]) != 'string') continue; //Escape regex var smiley_match = id_regex_escape( smiley ); //Find the match var smiley_regex = new RegExp( smiley_match, 'g' ); //HTML span tag var smiley_image = ' '+smiley+' '; if(text){ //Replace the match //trim text = text.replace(/^\s+|\s+$/g,''); text = ' '+text+' '; text = text.replace( smiley_regex, smiley_image ); } } return text; }; //Escape regex function id_regex_escape(str) { if (!arguments.callee.sRE) { var chars = new Array('/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '^', '$', '<', '>'); arguments.callee.sRE = new RegExp( '(\\' + chars.join('|\\') + ')', 'g' ); } return str.replace(arguments.callee.sRE, '\\$1'); }; function insertSmileyNewThread( smiley ) { txtOnFocus($id('IDCommentNewThreadText'), 'Enter text right here!'); $id('IDCommentNewThreadText').focus(); $id('IDCommentNewThreadText').value += smiley; //Hide smiley span $id("idc-smileys-new-thread").style.display="none"; //WYSIWYG Support if(typeof nicEditors != 'undefined') { newThreadNic = nicEditors.findEditor('IDCommentNewThreadText'); newContent = newThreadNic.getContent().replace(/^\s+|\s+$/g,''); if( newContent == 'Enter text right here!' ) newContent = ''; newContent += smiley; newThreadNic.setContent( newContent ); } }; function insertSmileyReply( smiley ) { txtOnFocus($id('txtComment'), 'Enter text right here!'); $id('txtComment').focus(); $id('txtComment').value += smiley; //Hide smiley span $id("idc-smileys-reply").style.display="none"; //WYSIWYG Support if(typeof nicEditors != 'undefined') { replyNic = nicEditors.findEditor('txtComment'); newContent =replyNic.getContent().replace(/^\s+|\s+$/g,''); if( newContent == 'Enter text right here!' ) newContent = ''; newContent += smiley; replyNic.setContent( newContent ); } }; id_add_filter('comment_text_load',id_replace_smileys_with_images, 1); id_add_action('idcomments_func_load',id_add_smiley_button); CSS: /* Simply Smileys - IntenseDebate Official Plugin CSS ver. 1.002 */ #idc-container .idc-smileys { background: #ffea00; clear: both; height: 84px; margin: 16px 0 0 -92px; padding: 2px 1px 1px 2px !important; position: absolute; width: 105px; z-index: 51; /* Nice shadows for browsers that support it! */ -webkit-box-shadow: 0 1px 3px #999; box-shadow: 1px 2px 3px #666; /* Rounded corners in most browsers! */ -moz-border-radius: 2px; /* For Mozilla Firefox */ -khtml-border-radius: 2px; /* For Konqueror */ -webkit-border-radius: 2px; /* For Safari */ border-radius: 2px; /* For future native implementations */ } #idc-container .idc-smileys li { display: inline; float: left; height: 20px; margin: 0 1px 1px 0 !important; width: 20px; } #idc-container .idc-smileys .idc-smiley { background: url(http://s.intensedebate.com/images1/-plugins/simplysmileys-bg.png ) no-repeat; display: block; height: 20px; width: 20px; } #idc-container .idc-smileys .idc-smiley:hover { background: #fff; } #idc-container .idc-smileys .idc-smiley span { background: url(http://s.intensedebate.com/images1/-plugins/simplysmileys.png ) no-repeat; _background: url(http://s.intensedebate.com/images1/-plugins/simplysmileys-ie6.png ) no-repeat; display: inline; float: left; height: 12px; margin: 4px !important; width: 12px; } #idc-container .idc-smileys .idc-smiley span span { display: none; } #idc-container .idc-c-t .idc-smiley span { background: url(http://s.intensedebate.com/images1/-plugins/simplysmileys.png ) no-repeat; _background: url(http://s.intensedebate.com/images1/-plugins/simplysmileys-ie6.png ) no-repeat; display: inline-block; height: 12px; margin: 0 1px; width: 12px; } #idc-container .idc-c-t .idc-smiley span span { display: none; }