Plugin Directory

Changeset 1912961


Ignore:
Timestamp:
07/22/2018 10:55:19 AM (8 years ago)
Author:
rahburma
Message:

support for highlighting selected portion of the web design code in public view

Location:
code-editor-and-compiler/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code-editor-and-compiler/trunk/admin/compilebin-admin.php

    r1912848 r1912961  
    77   public function __construct() {
    88      $this->plugin_name = "code-editor-and-compiler";
    9       $this->plugin_version = "1.3.8";
     9      $this->plugin_version = "1.3.9";
    1010      add_action('admin_notices', array($this, 'plugin_activation'));
    1111      add_action('deactivated_plugin', array($this, 'plugin_deactivation'));   
     
    4141                    </div>';
    4242           deactivate_plugins('crayon-syntax-highlighter/crayon_wp.class.php');
     43           echo $html;   
     44       }
     45       if (is_plugin_active('wp-syntaxhighlighter/wp-syntaxhighlighter.php')) {
     46           $html = '<div class="updated notice is-dismissible">
     47                       <p>Compilebin is not compatible with WP Syntax Highlighter. So, WP Syntax Highlighter is <strong>deactivated</strong> and all previous code snippets added with WP Syntax Highlighter will be syntax highlighted by compilebin.</p>
     48                    </div>';
     49           deactivate_plugins('wp-syntaxhighlighter/wp-syntaxhighlighter.php');
    4350           echo $html;   
    4451       }
  • code-editor-and-compiler/trunk/admin/js/editor-handler.js

    r1912848 r1912961  
    293293              });
    294294               
     295              if (cdbx_linesHighlightHtml) cdbx_appendHighlightedLinesHtml();   
     296              cdbx_editor_html.getSession().selection.on('changeSelection', function(e) {
     297                 var selectionRange = cdbx_editor_html.getSelectionRange();
     298                 var startLine = parseInt(selectionRange.start.row) + 1;
     299                 var endLine = parseInt(selectionRange.end.row) + 1;
     300                 $(CDBX_LINES_HIGHLIGHT_NOW_HTML).html(startLine + '-' + endLine);
     301                 $(CDBX_SELECT_LINES_HTML).css('display', 'inline'); 
     302              });
     303               
     304              if (cdbx_linesHighlightCss) cdbx_appendHighlightedLinesCss();   
     305              cdbx_editor_css.getSession().selection.on('changeSelection', function(e) {
     306                 var selectionRange = cdbx_editor_css.getSelectionRange();
     307                 var startLine = parseInt(selectionRange.start.row) + 1;
     308                 var endLine = parseInt(selectionRange.end.row) + 1;
     309                 $(CDBX_LINES_HIGHLIGHT_NOW_CSS).html(startLine + '-' + endLine);
     310                 $(CDBX_SELECT_LINES_CSS).css('display', 'inline'); 
     311              });
     312               
     313              if (cdbx_linesHighlightJs) cdbx_appendHighlightedLinesJs();   
     314              cdbx_editor_js.getSession().selection.on('changeSelection', function(e) {
     315                 var selectionRange = cdbx_editor_js.getSelectionRange();
     316                 var startLine = parseInt(selectionRange.start.row) + 1;
     317                 var endLine = parseInt(selectionRange.end.row) + 1;
     318                 $(CDBX_LINES_HIGHLIGHT_NOW_JS).html(startLine + '-' + endLine);
     319                 $(CDBX_SELECT_LINES_JS).css('display', 'inline'); 
     320              });   
     321               
    295322              cdbx_setModeWeb();
    296323              cdbx_setTheme();
     
    360387                          }
    361388                          initEditorDialog();
    362                           cdbx_linesHighlight = null;   
     389                          cdbx_linesHighlight = cdbx_linesHighlightHtml = cdbx_linesHighlightCss = cdbx_linesHighlightJs = null;
    363390                          $(CDBX_EDITOR_DIALOG).dialog(CDBX_EVENT_OPEN);
    364391                          pref_loaded = true;
     
    372399                    }
    373400                    initEditorDialog();
    374                     cdbx_linesHighlight = null;
     401                    cdbx_linesHighlight = cdbx_linesHighlightHtml = cdbx_linesHighlightCss = cdbx_linesHighlightJs = null;
    375402                    $(CDBX_EDITOR_DIALOG).dialog(CDBX_EVENT_OPEN);
    376403                }
     
    538565            var pre_id_js = pre_id + 'js';
    539566           
     567            var highlightHtml = cdbx_linesHighlightHtml ? cdbx_linesHighlightHtml : '';
     568            var highlightCss = cdbx_linesHighlightCss ? cdbx_linesHighlightCss : '';
     569            var highlightJs = cdbx_linesHighlightJs ? cdbx_linesHighlightJs : '';
     570           
    540571            var prefix = '<div id="' + pre_id + '"' + ' class="cdbxweb prettyprint">';
    541572            var suffix = '</div>';
     
    544575                         'class="cdbx-try-code-web cdbx-btn-main"' +
    545576                         'style="background-color:#FFFFFF;margin-bottom:0;color:#008B8B;border: 1px solid rgba(231, 231, 230, 1); border-radius: 10px;font-size:13px;height:30px;min-width:110px;max-width:220px;padding:4px;font-weight:normal;outline:none;display:none;"' +
    546                          'type="button" value="Run HTML" data-code="' + pre_id + '"' +
     577                         'type="button" value="Run HTML" data-lang="html" data-code="' + pre_id + '"' +
    547578                         '" /></pre>';
    548579           
    549580            var css_suffix = '<input id="' + input_id + '"' +
    550581                         'class="cdbx-try-code-web cdbx-btn-main"' +
    551                          'type="button" value="Run CSS" data-code="' + pre_id + '"' +
     582                         'type="button" value="Run CSS" data-lang="css" data-code="' + pre_id + '"' +
    552583                         'style="background-color:#FFFFFF;margin-bottom:0;color:#008B8B;border: 1px solid rgba(231, 231, 230, 1); border-radius: 10px;font-size:13px;height:30px;min-width:110px;max-width:220px;padding:4px;font-weight:normal;outline:none;display:none"' +
    553584                         '" /></pre>';
     
    555586            var js_suffix = '<input id="' + input_id + '"' +
    556587                         'class="cdbx-try-code-web cdbx-btn-main"' +
    557                          'type="button" value="Run Javascript" data-code="' + pre_id + '"' +
     588                         'type="button" value="Run Javascript" data-lang="js" data-code="' + pre_id + '"' +
    558589                         'style="background-color:#FFFFFF;margin-bottom:0;color:#008B8B;border: 1px solid rgba(231, 231, 230, 1); border-radius: 10px;font-size:13px;height:30px;min-width:110px;max-width:220px;padding:4px;font-weight:normal;outline:none;display:none;"' +
    559590                         '" /></pre>';
    560591
    561             var html_code_prefix = '<pre id="' + pre_id_html + '"' + ' class="cdbxweb prettyprint" style="padding:10px;border:1px solid rgba(231, 231, 230, 1);border-radius:10px;margin-bottom:5px;background-color:#FFFFFF;font-size:13px;">';
     592            var html_code_prefix = '<pre id="' + pre_id_html + '"' + 'data-lang="html" data-highlight="' + highlightHtml + '"' + ' class="cdbxweb prettyprint" style="padding:10px;border:1px solid rgba(231, 231, 230, 1);border-radius:10px;margin-bottom:5px;background-color:#FFFFFF;font-size:13px;">';
    562593            var html_code_div = html_code_prefix + code_html + html_suffix;
    563594           
    564             var css_code_prefix = '<pre id="' + pre_id_css + '"' + ' class="cdbxweb prettyprint" style="padding:10px;border:1px solid rgba(231, 231, 230, 1);border-radius:10px;margin-bottom:5px;background-color:#FFFFFF;font-size:13px;">';
     595            var css_code_prefix = '<pre id="' + pre_id_css + '"' + 'data-lang="css" data-highlight="' + highlightCss + '"' + ' class="cdbxweb prettyprint" style="padding:10px;border:1px solid rgba(231, 231, 230, 1);border-radius:10px;margin-bottom:5px;background-color:#FFFFFF;font-size:13px;">';
    565596            var css_code_div = css_code_prefix + code_css + css_suffix;
    566597           
    567             var js_code_prefix = '<pre id="' + pre_id_js + '"' + ' class="cdbxweb prettyprint" style="padding:10px;border:1px solid rgba(231, 231, 230, 1);border-radius:10px;margin-bottom:5px;background-color:#FFFFFF;font-size:13px;">';
     598            var js_code_prefix = '<pre id="' + pre_id_js + '"' + 'data-lang="js" data-highlight="' + highlightJs + '"' + ' class="cdbxweb prettyprint" style="padding:10px;border:1px solid rgba(231, 231, 230, 1);border-radius:10px;margin-bottom:5px;background-color:#FFFFFF;font-size:13px;">';
    568599            var js_code_div = js_code_prefix + code_js + js_suffix;
    569600           
     
    934965        });
    935966       
     967        $(CDBX_TAB_WEB_HTML).live(CDBX_EVENT_CLICK, function (e) {
     968            cdbx_active_tab_web = CDBX_TAB_HTML_ID;
     969            cdbx_updateHighlightArea();
     970        });
     971       
     972        $(CDBX_TAB_WEB_CSS).live(CDBX_EVENT_CLICK, function (e) {
     973            cdbx_active_tab_web = CDBX_TAB_CSS_ID;
     974            cdbx_updateHighlightArea();
     975        });
     976       
     977        $(CDBX_TAB_WEB_JS).live(CDBX_EVENT_CLICK, function (e) {
     978            cdbx_active_tab_web = CDBX_TAB_JS_ID;
     979            cdbx_updateHighlightArea();
     980        });
     981       
    936982        $(CDBX_CODE_LINES_HIGHLIGHT).live(CDBX_EVENT_CLICK, function (e) {
    937983            e.preventDefault();
     
    942988            }
    943989        });
     990       
     991        $(CDBX_CODE_LINES_HIGHLIGHT_WEB).live(CDBX_EVENT_CLICK, function (e) {
     992            e.preventDefault();
     993            if (cdbx_highlight_area_active) {
     994                $(CDBX_CODE_LINES_HIGHLIGHT_AREA_HTML).css('display', 'none');
     995                $(CDBX_CODE_LINES_HIGHLIGHT_AREA_CSS).css('display', 'none');
     996                $(CDBX_CODE_LINES_HIGHLIGHT_AREA_JS).css('display', 'none');
     997                cdbx_highlight_area_active = false;
     998            } else {
     999                cdbx_highlight_area_active = true;
     1000                cdbx_updateHighlightArea();
     1001            }
     1002            /*if ($(CDBX_CODE_LINES_HIGHLIGHT_AREA_HTML).css('display') == 'block') {
     1003                $(CDBX_CODE_LINES_HIGHLIGHT_AREA_HTML).css('display', 'none');
     1004                $(CDBX_CODE_LINES_HIGHLIGHT_AREA_CSS).css('display', 'none');
     1005                $(CDBX_CODE_LINES_HIGHLIGHT_AREA_JS).css('display', 'none');
     1006            } else {
     1007                $(CDBX_CODE_LINES_HIGHLIGHT_AREA_HTML).css('display', 'block');
     1008                $(CDBX_CODE_LINES_HIGHLIGHT_AREA_CSS).css('display', 'block');
     1009                $(CDBX_CODE_LINES_HIGHLIGHT_AREA_JS).css('display', 'block');
     1010            } */
     1011        });
     1012       
     1013        var cdbx_updateHighlightArea = function () {
     1014            if (cdbx_highlight_area_active) {
     1015                $(CDBX_CODE_LINES_HIGHLIGHT_AREA_HTML).css('display', 'none');
     1016                $(CDBX_CODE_LINES_HIGHLIGHT_AREA_CSS).css('display', 'none');
     1017                $(CDBX_CODE_LINES_HIGHLIGHT_AREA_JS).css('display', 'none');
     1018                switch (cdbx_active_tab_web) {
     1019                    case CDBX_TAB_HTML_ID : $(CDBX_CODE_LINES_HIGHLIGHT_AREA_HTML).css('display', 'block'); break;
     1020                    case CDBX_TAB_CSS_ID  : $(CDBX_CODE_LINES_HIGHLIGHT_AREA_CSS).css('display', 'block');  break;
     1021                    case CDBX_TAB_JS_ID   : $(CDBX_CODE_LINES_HIGHLIGHT_AREA_JS).css('display', 'block');   break;   
     1022                };   
     1023            }
     1024        };
    9441025       
    9451026        $(CDBX_SELECT_LINES).live(CDBX_EVENT_CLICK, function (e) {
     
    9941075        var cdbx_detectDuplicateOverlapHighlight = function (selectedLines) {
    9951076            var linesGroup = cdbx_linesHighlight.split(',');
     1077            for (var i = 0; i < linesGroup.length; i++) {
     1078                if (selectedLines == linesGroup[i]) {
     1079                    alert('Duplicate highlight range !!!');
     1080                    return true;
     1081                }
     1082            }
     1083            return false;
     1084        };
     1085       
     1086        $(CDBX_SELECT_LINES_HTML).live(CDBX_EVENT_CLICK, function (e) {
     1087            var selectedLines = $(CDBX_LINES_HIGHLIGHT_NOW_HTML).text();
     1088            if (cdbx_linesHighlightHtml) {
     1089                if (!cdbx_detectDuplicateOverlapHighlightWeb(selectedLines, cdbx_linesHighlightHtml)) {
     1090                    cdbx_linesHighlightHtml += ',' + selectedLines;
     1091                }
     1092            } else {
     1093                cdbx_linesHighlightHtml = selectedLines;
     1094            }
     1095           
     1096            cdbx_appendHighlightedLinesHtml();
     1097            cdbx_editor_html.clearSelection();
     1098        });
     1099       
     1100        $(CDBX_SELECT_LINES_CSS).live(CDBX_EVENT_CLICK, function (e) {
     1101            var selectedLines = $(CDBX_LINES_HIGHLIGHT_NOW_CSS).text();
     1102            if (cdbx_linesHighlightCss) {
     1103                if (!cdbx_detectDuplicateOverlapHighlightWeb(selectedLines, cdbx_linesHighlightCss)) {
     1104                    cdbx_linesHighlightCss += ',' + selectedLines;
     1105                }
     1106            } else {
     1107                cdbx_linesHighlightCss = selectedLines;
     1108            }
     1109           
     1110            cdbx_appendHighlightedLinesCss();
     1111            cdbx_editor_css.clearSelection();
     1112        });
     1113       
     1114        $(CDBX_SELECT_LINES_JS).live(CDBX_EVENT_CLICK, function (e) {
     1115            var selectedLines = $(CDBX_LINES_HIGHLIGHT_NOW_JS).text();
     1116            if (cdbx_linesHighlightJs) {
     1117                if (!cdbx_detectDuplicateOverlapHighlightWeb(selectedLines, cdbx_linesHighlightJs)) {
     1118                    cdbx_linesHighlightJs += ',' + selectedLines;
     1119                }
     1120            } else {
     1121                cdbx_linesHighlightJs = selectedLines;
     1122            }
     1123           
     1124            cdbx_appendHighlightedLinesJs();
     1125            cdbx_editor_js.clearSelection();
     1126        });
     1127       
     1128        $(CDBX_REMOVE_HIGHLIGHT_LINES_HTML).live(CDBX_EVENT_CLICK, function (e) {
     1129            var idx = parseInt($(this).attr('id').split('@')[1]);
     1130            var linesGroup = cdbx_linesHighlightHtml.split(',');
     1131            linesGroup.splice(idx, 1);
     1132            var linestr = '';
     1133            for (var i = 0; i < linesGroup.length; i++) {
     1134                linestr += linesGroup[i];
     1135                if (i != linesGroup.length - 1) {
     1136                    linestr += ',';
     1137                }
     1138            }
     1139            cdbx_linesHighlightHtml = linestr;
     1140            cdbx_appendHighlightedLinesHtml();
     1141        });
     1142       
     1143        $(CDBX_REMOVE_HIGHLIGHT_LINES_CSS).live(CDBX_EVENT_CLICK, function (e) {
     1144            var idx = parseInt($(this).attr('id').split('@')[1]);
     1145            var linesGroup = cdbx_linesHighlightCss.split(',');
     1146            linesGroup.splice(idx, 1);
     1147            var linestr = '';
     1148            for (var i = 0; i < linesGroup.length; i++) {
     1149                linestr += linesGroup[i];
     1150                if (i != linesGroup.length - 1) {
     1151                    linestr += ',';
     1152                }
     1153            }
     1154            cdbx_linesHighlightCss = linestr;
     1155            cdbx_appendHighlightedLinesCss();
     1156        });
     1157       
     1158        $(CDBX_REMOVE_HIGHLIGHT_LINES_JS).live(CDBX_EVENT_CLICK, function (e) {
     1159            var idx = parseInt($(this).attr('id').split('@')[1]);
     1160            var linesGroup = cdbx_linesHighlightJs.split(',');
     1161            linesGroup.splice(idx, 1);
     1162            var linestr = '';
     1163            for (var i = 0; i < linesGroup.length; i++) {
     1164                linestr += linesGroup[i];
     1165                if (i != linesGroup.length - 1) {
     1166                    linestr += ',';
     1167                }
     1168            }
     1169            cdbx_linesHighlightJs = linestr;
     1170            cdbx_appendHighlightedLinesJs();
     1171        });
     1172       
     1173        var cdbx_appendHighlightedLinesHtml = function () {
     1174            $(CDBX_LINES_HIGHLIGHTED_HIDDEN_HTML).html(cdbx_linesHighlightHtml);
     1175            if (!cdbx_linesHighlightHtml  || cdbx_linesHighlightHtml.length == 0) {
     1176                $(CDBX_LINES_HIGHLIGHTED_HTML).html(cdbx_linesHighlightHtml);
     1177                return;
     1178            }
     1179            var linesGroup = cdbx_linesHighlightHtml.split(',');
     1180            var currentHighlights = '';
     1181            for (var i = 0; i < linesGroup.length; i++) {
     1182                currentHighlights +=
     1183                    '<span> \
     1184                        <a id="cdbx-remove-highlight-html@' + i + '" class="cdbx-remove-highlight-lines-html" style="cursor:pointer;" title="Remove highlight"> \
     1185                            <span class="dashicons dashicons-no"></span> ' + '<span style="margin-top:0.5em">' + linesGroup[i] + '</span>' +
     1186                        '</button> \
     1187                    </span>';
     1188                currentHighlights += '&nbsp;&nbsp;&nbsp;';
     1189            }
     1190            $(CDBX_LINES_HIGHLIGHTED_HTML).html(currentHighlights);
     1191        };
     1192       
     1193        var cdbx_appendHighlightedLinesCss = function () {
     1194            $(CDBX_LINES_HIGHLIGHTED_HIDDEN_CSS).html(cdbx_linesHighlightCss);
     1195            if (!cdbx_linesHighlightCss || cdbx_linesHighlightCss.length == 0) {
     1196                $(CDBX_LINES_HIGHLIGHTED_CSS).html(cdbx_linesHighlightCss);
     1197                return;
     1198            }
     1199            var linesGroup = cdbx_linesHighlightCss.split(',');
     1200            var currentHighlights = '';
     1201            for (var i = 0; i < linesGroup.length; i++) {
     1202                currentHighlights +=
     1203                    '<span> \
     1204                        <a id="cdbx-remove-highlight-css@' + i + '" class="cdbx-remove-highlight-lines-css" style="cursor:pointer;" title="Remove highlight"> \
     1205                            <span class="dashicons dashicons-no"></span> ' + '<span style="margin-top:0.5em">' + linesGroup[i] + '</span>' +
     1206                        '</button> \
     1207                    </span>';
     1208                currentHighlights += '&nbsp;&nbsp;&nbsp;';
     1209            }
     1210            $(CDBX_LINES_HIGHLIGHTED_CSS).html(currentHighlights);
     1211        };
     1212       
     1213        var cdbx_appendHighlightedLinesJs = function () {
     1214            $(CDBX_LINES_HIGHLIGHTED_HIDDEN_JS).html(cdbx_linesHighlightJs);
     1215            if (!cdbx_linesHighlightJs || cdbx_linesHighlightJs.length == 0) {
     1216                $(CDBX_LINES_HIGHLIGHTED_JS).html(cdbx_linesHighlightJs);
     1217                return;
     1218            }
     1219            var linesGroup = cdbx_linesHighlightJs.split(',');
     1220            var currentHighlights = '';
     1221            for (var i = 0; i < linesGroup.length; i++) {
     1222                currentHighlights +=
     1223                    '<span> \
     1224                        <a id="cdbx-remove-highlight-js@' + i + '" class="cdbx-remove-highlight-lines-js" style="cursor:pointer;" title="Remove highlight"> \
     1225                            <span class="dashicons dashicons-no"></span> ' + '<span style="margin-top:0.5em">' + linesGroup[i] + '</span>' +
     1226                        '</button> \
     1227                    </span>';
     1228                currentHighlights += '&nbsp;&nbsp;&nbsp;';
     1229            }
     1230            $(CDBX_LINES_HIGHLIGHTED_JS).html(currentHighlights);
     1231        };
     1232       
     1233        var cdbx_detectDuplicateOverlapHighlightWeb = function (selectedLines, highlightLines) {
     1234            var linesGroup = highlightLines.split(',');
    9961235            for (var i = 0; i < linesGroup.length; i++) {
    9971236                if (selectedLines == linesGroup[i]) {
     
    11861425                    var jsCode = $(CDBX_HIDDEN_CONTENT_JS).text();
    11871426                     
     1427                    cdbx_linesHighlightHtml = null;
     1428                    if (cdbx_editorNode_html && cdbx_editorNode_html.dataset.highlight && cdbx_editorNode_html.dataset.highlight.length > 0) {
     1429                        cdbx_linesHighlightHtml = cdbx_editorNode_html.dataset.highlight;   
     1430                    }   
     1431                   
     1432                    cdbx_linesHighlightCss = null;
     1433                    if (cdbx_editorNode_css && cdbx_editorNode_css.dataset.highlight && cdbx_editorNode_css.dataset.highlight.length > 0) {
     1434                        cdbx_linesHighlightCss = cdbx_editorNode_css.dataset.highlight;   
     1435                    } 
     1436                   
     1437                    cdbx_linesHighlightJs = null;
     1438                    if (cdbx_editorNode_js && cdbx_editorNode_js.dataset.highlight && cdbx_editorNode_js.dataset.highlight.length > 0) {
     1439                        cdbx_linesHighlightJs = cdbx_editorNode_js.dataset.highlight;   
     1440                    }
     1441 
    11881442                    var postLoadSetupWeb = function () {
    11891443                        cdbx_editor_html = ace.edit(CDBX_ELEM_COMPILEBIN_EDITOR_HTML);
     
    12041458                        activateTabs();
    12051459                        $("[data-tab=cdbx-tab-2]").click();
     1460                       
     1461                        if (cdbx_editorNode.dataset.lang) {
     1462                            switch (cdbx_editorNode.dataset.lang) {
     1463                                case 'html' : $("[data-tab=cdbx-tab-html]").click(); break;
     1464                                case 'css'  : $("[data-tab=cdbx-tab-css]").click();  break;
     1465                                case 'js'   : $("[data-tab=cdbx-tab-js]").click();   break;   
     1466                            }   
     1467                        }
    12061468                    };
    12071469                     
     
    13231585           </ul></div> \
    13241586           <ul class="cdbx-tabs-web"> \
    1325                <li class="cdbx-tab-link current" data-tab="cdbx-tab-html">Html</li> \
    1326                <li class="cdbx-tab-link" data-tab="cdbx-tab-css">CSS</li> \
    1327                <li class="cdbx-tab-link" data-tab="cdbx-tab-js">Javascript</li> \
     1587               <li id="cdbx-tab-web-html" class="cdbx-tab-link current" data-tab="cdbx-tab-html">Html</li> \
     1588               <li id="cdbx-tab-web-css" class="cdbx-tab-link" data-tab="cdbx-tab-css">CSS</li> \
     1589               <li id="cdbx-tab-web-js" class="cdbx-tab-link" data-tab="cdbx-tab-js">Javascript</li> \
    13281590           </ul> \
    13291591           <div class="cdbx-tabs-placeholder"> \
     
    14581720                     </button> \
    14591721                    </div> \
     1722                    <div> \
     1723                     <p><a id="cdbx-code-lines-highlight-web" style="cursor:pointer" title="Selected lines will be highlighted with different background color in public view"><u>Highlight lines</u></a></p> \
     1724                     <div id="cdbx-code-lines-highlight-area-html" style="display:none;border:1px solid #ddd;padding:0.5em"> \
     1725                        <div id="cdbx-lines-highlighted-hidden-html" style="display:none"></div> \
     1726                        <div id="cdbx-lines-highlighted-html"></div> \
     1727                        <p style="font-size:0.8em;color:#008B8B">Select lines to be highlighted in the editor</p> \
     1728                        <span id="cdbx-lines-highlight-now-html"></span>&nbsp;&nbsp; \
     1729                        <span> \
     1730                           <button type="button" id="cdbx-select-lines-html" style="cursor:pointer;display:none;"> \
     1731                              <span class="dashicons dashicons-yes"></span> \
     1732                           </button> \
     1733                        </span> \
     1734                     </div> \
     1735                     <div id="cdbx-code-lines-highlight-area-css" style="display:none;border:1px solid #ddd;padding:0.5em"> \
     1736                        <div id="cdbx-lines-highlighted-hidden-css" style="display:none"></div> \
     1737                        <div id="cdbx-lines-highlighted-css"></div> \
     1738                        <p style="font-size:0.8em;color:#008B8B">Select lines to be highlighted in the editor</p> \
     1739                        <span id="cdbx-lines-highlight-now-css"></span>&nbsp;&nbsp; \
     1740                        <span> \
     1741                           <button type="button" id="cdbx-select-lines-css" style="cursor:pointer;display:none;"> \
     1742                              <span class="dashicons dashicons-yes"></span> \
     1743                           </button> \
     1744                        </span> \
     1745                     </div> \
     1746                     <div id="cdbx-code-lines-highlight-area-js" style="display:none;border:1px solid #ddd;padding:0.5em"> \
     1747                        <div id="cdbx-lines-highlighted-hidden-js" style="display:none"></div> \
     1748                        <div id="cdbx-lines-highlighted-js"></div> \
     1749                        <p style="font-size:0.8em;color:#008B8B">Select lines to be highlighted in the editor</p> \
     1750                        <span id="cdbx-lines-highlight-now-js"></span>&nbsp;&nbsp; \
     1751                        <span> \
     1752                           <button type="button" id="cdbx-select-lines-js" style="cursor:pointer;display:none;"> \
     1753                              <span class="dashicons dashicons-yes"></span> \
     1754                           </button> \
     1755                        </span> \
     1756                     </div> \
     1757                    </div> \
    14601758                    <div id="cdbx-div-output-web" style="width:98%"> \
    14611759                        Output Appears Here ... \
  • code-editor-and-compiler/trunk/common/js/include.js

    r1912838 r1912961  
    113113var CDBX_REMOVE_HIGHLIGHT_LINES    = '.cdbx-remove-highlight-lines';
    114114
     115var CDBX_CODE_LINES_HIGHLIGHT_WEB      = '#cdbx-code-lines-highlight-web';
     116
     117var CDBX_CODE_LINES_HIGHLIGHT_AREA_HTML = '#cdbx-code-lines-highlight-area-html';
     118var CDBX_LINES_HIGHLIGHTED_HTML         = '#cdbx-lines-highlighted-html';
     119var CDBX_LINES_HIGHLIGHTED_HIDDEN_HTML  = '#cdbx-lines-highlighted-hidden-html';
     120var CDBX_LINES_HIGHLIGHT_NOW_HTML       = '#cdbx-lines-highlight-now-html';
     121var CDBX_SELECT_LINES_HTML              = '#cdbx-select-lines-html';
     122var CDBX_REMOVE_HIGHLIGHT_LINES_HTML    = '.cdbx-remove-highlight-lines-html';
     123
     124var CDBX_CODE_LINES_HIGHLIGHT_AREA_CSS = '#cdbx-code-lines-highlight-area-css';
     125var CDBX_LINES_HIGHLIGHTED_CSS         = '#cdbx-lines-highlighted-css';
     126var CDBX_LINES_HIGHLIGHTED_HIDDEN_CSS  = '#cdbx-lines-highlighted-hidden-css';
     127var CDBX_LINES_HIGHLIGHT_NOW_CSS       = '#cdbx-lines-highlight-now-css';
     128var CDBX_SELECT_LINES_CSS              = '#cdbx-select-lines-css';
     129var CDBX_REMOVE_HIGHLIGHT_LINES_CSS    = '.cdbx-remove-highlight-lines-css';
     130
     131var CDBX_CODE_LINES_HIGHLIGHT_AREA_JS = '#cdbx-code-lines-highlight-area-js';
     132var CDBX_LINES_HIGHLIGHTED_JS         = '#cdbx-lines-highlighted-js';
     133var CDBX_LINES_HIGHLIGHTED_HIDDEN_JS  = '#cdbx-lines-highlighted-hidden-js';
     134var CDBX_LINES_HIGHLIGHT_NOW_JS       = '#cdbx-lines-highlight-now-js';
     135var CDBX_SELECT_LINES_JS              = '#cdbx-select-lines-js';
     136var CDBX_REMOVE_HIGHLIGHT_LINES_JS    = '.cdbx-remove-highlight-lines-js';
     137
     138var CDBX_TAB_WEB_HTML  = '#cdbx-tab-web-html';
     139var CDBX_TAB_WEB_CSS   = '#cdbx-tab-web-css';
     140var CDBX_TAB_WEB_JS    = '#cdbx-tab-web-js';
     141
    115142var cdbx_languages = [
    116143    { id: 0,     name: 'C',           mode: 'ace/mode/c_cpp',      ext: '.c'     },
     
    174201var cdbx_linenum_status = 1;
    175202var cdbx_linesHighlight = null;
     203var cdbx_linesHighlightHtml = null;
     204var cdbx_linesHighlightCss = null;
     205var cdbx_linesHighlightJs = null;
    176206var cdbx_curThemePrefId = CDBX_THEME_XCODE;
    177207var cdbx_curThemeId = CDBX_THEME_XCODE;
     
    179209var cdbx_curTheme = CDBX_ACE_THEME_XCODE;
    180210
     211var CDBX_TAB_HTML_ID = 0;
     212var CDBX_TAB_CSS_ID  = 1;
     213var CDBX_TAB_JS_ID   = 2;
     214
     215var cdbx_active_tab_web = CDBX_TAB_HTML_ID;
     216var cdbx_highlight_area_active = false;
     217
    181218var CDBX_CRAYON_DETECT_STRING = "lang:";
     219var CDBX_WP_SYNTAX_HIGHLIGHTER_DETECT_STRING = "brush:";
  • code-editor-and-compiler/trunk/compilebin.php

    r1912848 r1912961  
    1010 * Plugin URI:        https://www.compilebin.com
    1111 * Description:       Syntax highlighter and code compiler.
    12  * Version:           1.3.8
     12 * Version:           1.3.9
    1313 * Author:            Compilebin
    1414 * Author URI:        https://www.compilebin.com
  • code-editor-and-compiler/trunk/public/compilebin-public.php

    r1912848 r1912961  
    77   public function __construct() {
    88      $this->plugin_name = "code-editor-and-compiler";
    9       $this->plugin_version = "1.3.8";
     9      $this->plugin_version = "1.3.9";
    1010      add_action('wp_enqueue_scripts', array(&$this, 'enqueueScripts'));
    1111      add_action('wp_enqueue_scripts', array(&$this, 'enqueueStyles'));
  • code-editor-and-compiler/trunk/public/js/editor-handler-public.js

    r1912838 r1912961  
    1717        };
    1818       
     19        var cdbx_isWPSyntaxHighlighterPresent = function(elem) {
     20           if (elem.className.substr(0, CDBX_WP_SYNTAX_HIGHLIGHTER_DETECT_STRING.length) == CDBX_WP_SYNTAX_HIGHLIGHTER_DETECT_STRING) {
     21               return true;
     22           }
     23           return false;
     24        };
     25       
    1926        var cdbx_lineHighlight = function (cdbx_codeElem) {
    2027            var elem = document.getElementById(cdbx_codeElem.id);
    21             if (cdbx_codeElem.getAttribute('class') != 'prettyprint') return;
     28            var className = cdbx_codeElem.getAttribute('class');
     29            if (className != 'prettyprint' && className != 'cdbxweb prettyprint') return;
    2230            var highlightedLines = '';
    2331            if (elem && elem.dataset && elem.dataset.highlight) {
     
    4755            for (var i = 0; i < cdbx_preElems.length; i++) {
    4856                cdbx_lineHighlight(cdbx_preElems[i]);
    49                 if (cdbx_isCrayonHighlighterPresent(cdbx_preElems[i])) {
     57                if (cdbx_isCrayonHighlighterPresent(cdbx_preElems[i]) || cdbx_isWPSyntaxHighlighterPresent(cdbx_preElems[i])) {
    5058                    cdbx_preElems[i].classList.add('prettyprint');
    5159                    cdbx_preElems[i].setAttribute("style", "padding: 10px; border: 1px solid rgba(231, 231, 230, 1); border-radius: 10px; background-color: #ffffff; font-family: courier, sans-serif; font-size: 13px;");
     
    415423            cdbx_setModeWeb();
    416424            activateTabs();
     425           
     426            if (this.dataset.lang) {
     427                switch (this.dataset.lang) {
     428                    case 'html' : $("[data-tab=cdbx-tab-html]").click(); break;
     429                    case 'css'  : $("[data-tab=cdbx-tab-css]").click();  break;
     430                    case 'js'   : $("[data-tab=cdbx-tab-js]").click();   break;   
     431                }   
     432            }
     433           
    417434            $(CDBX_TABS_WEB).css('display', 'block');   
    418435            $(CDBX_OUTPUT_WEB_LINK).addClass('disabled').removeAttr("href");   
    419436            $(CDBX_EDITOR_DIALOG).dialog(CDBX_EVENT_OPEN);
     437
    420438         
    421439            /************************************* Deprecated Code ***************************/
     
    569587            '<div id="cdbx-editor-dialog"> \
    570588              <ul class="cdbx-tabs-web" style="text-align:left"> \
    571                <li class="cdbx-tab-link current" data-tab="cdbx-tab-html">Html</li> \
    572                <li class="cdbx-tab-link" data-tab="cdbx-tab-css">CSS</li> \
    573                <li class="cdbx-tab-link" data-tab="cdbx-tab-js">Javascript</li> \
     589               <li id="cdbx-tab-web-html" class="cdbx-tab-link current" data-tab="cdbx-tab-html">Html</li> \
     590               <li id="cdbx-tab-web-css" class="cdbx-tab-link" data-tab="cdbx-tab-css">CSS</li> \
     591               <li id="cdbx-tab-web-js" class="cdbx-tab-link" data-tab="cdbx-tab-js">Javascript</li> \
    574592             </ul> \
    575593             <div class="cdbx-editor-div-left" style="margin-top:5px;"> \
  • code-editor-and-compiler/trunk/readme.txt

    r1912848 r1912961  
    55Requires at least: 3.1
    66Tested up to: 4.9.4
    7 Stable tag: 1.3.8
     7Stable tag: 1.3.9
    88Requires PHP: 5.2.4
    99License: GPLv2 or later
     
    3535
    3636== Changelog ==
     371.3.9
     38Support for highlighting selected portion of web design code in public view.
     39UI improvement
     40
    37411.3.8
    3842Support for highlighting selected portion of code in public view.
Note: See TracChangeset for help on using the changeset viewer.