if (jQuery('.cont_code').length) { var tagCode = jQuery('.cont_code'); } else { if (jQuery('.cont_code').length) { var tagCode = jQuery('.code'); } else { var tagCode = jQuery('code'); } } tagCode.each(function () { var sContent = jQuery(this).html(); var codebox = jQuery(this).parent().parent(); codebox.before('<div class="punbbtop"> تظليل المحتوى <button onclick="punbbExpand(this); return false;">تكبير</button><button style="display: none" onclick="punbbCollapse(this); return false;">تصغير</button> <button onclick="punbbSelect(this); return false;">انسخ</button> <button onclick="punbbPopup(this); return false;">نافذة</button> <button style="margin-right: 50px; float: right;" onclick="punbbAbout(this); return false;"></button></div><pre class="highlight punbb_block">' + sContent + '</pre>'); codebox.remove(); }); jQuery.getScript('http://balupton.github.io/jquery-syntaxhighlighter/scripts/jquery.syntaxhighlighter.min.js', function () { jQuery.SyntaxHighlighter.init({ 'wrapLines': false }) }) }); function punbbExpand(oThis) { jQuery(oThis).css('display', 'none'); jQuery(oThis).next().css('display', ''); jQuery(oThis).parent().next('pre.punbb_block').addClass('expand'); } function punbbCollapse(oThis) { jQuery(oThis).css('display', 'none'); jQuery(oThis).prev().css('display', ''); jQuery(oThis).parent().next('pre.punbb_block').removeClass('expand'); } function punbbPopup(oThis) { var content = jQuery(oThis).parent().next('pre.punbb_block').html(); var my_window = window.open("","PunBB_Code","scrollbars=1,toolbar=no,menubar=no,personalbar=no,status=0,left=0,location=0,menubar=0,top=0,width=640,height=480");
my_window.document.write('<pre>'+content+'</pre>'); } function punbbAbout(oThis) { alert('Simple code to add Syntax Highlighter fuctionality for Forumotion\n\hamsahaq - 2013/12/16\n'); } function punbbSelect(oThis) { var doc = document; var text = jQuery(oThis).parent().next('pre.punbb_block')[0]; if (doc.body.createTextRange) { var range = doc.body.createTextRange(); range.moveToElementText(text); range.select(); } else if (window.getSelection) { var selection = window.getSelection(); var range = doc.createRange(); range.selectNodeContents(text); selection.removeAllRanges(); selection.addRange(range); } }