1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-01-18 11:52:11 +01:00

New: In the syntax highlighting also pickout DataTables' API methods and link them to the reference page

This commit is contained in:
Allan Jardine 2011-09-05 19:24:18 +01:00
parent f788dd28d3
commit a444026985
2 changed files with 23 additions and 1 deletions

View File

@ -362,3 +362,13 @@
*cursor: hand;
}
.syntaxhighlighter .dtapi {
color: #069;
}
.syntaxhighlighter .dtapi:hover {
text-decoration: underline;
cursor: pointer;
*cursor: hand;
}

View File

@ -45,6 +45,11 @@ eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a
'new null return super switch ' +
'this throw true try typeof var while with'
;
var datatablesAPI =
'fnSettings fnDraw fnFilter fnSort fnAddData fnDeleteRow fnClearTable fnGetData '+
'fnGetPosition fnGetNodes fnOpen fnClose fnUpdate fnSetColumnVis fnVersionCheck '+
'fnPageChange fnSortListener fnDestroy fnAdjustColumnSizing';
var r = SyntaxHighlighter.regexLib;
@ -54,7 +59,8 @@ eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a
{ regex: r.singleLineCComments, css: 'comments' }, // one line comments
{ regex: r.multiLineCComments, css: 'comments' }, // multiline comments
{ regex: /\s*#.*/gm, css: 'preprocessor' }, // preprocessor tags like #region and #endregion
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // keywords
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords
{ regex: new RegExp(this.getKeywords(datatablesAPI), 'gm'), css: 'dtapi' } // DataTables API methods
];
this.forHtmlScript(r.scriptScriptTags);
@ -298,6 +304,12 @@ var dtLinks = [
}
} );
$('code.dtapi').each( function () {
if ( dtList.indexOf( this.innerHTML ) !== -1 ) {
$(this).addClass( 'datatables_ref' );
}
} );
/* Click handler to redirect to the documentation */
$('code.datatables_ref').live('click', function () {
var i = $.inArray( this.innerHTML.replace(/"/g,''), dtOptions );