mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-17 10:41:06 +01:00
improve SyntaxHighlighterPanel
This commit is contained in:
@@ -131,6 +131,7 @@ Sonia.panel.SyntaxHighlighterPanel = Ext.extend(Ext.Panel, {
|
||||
}],
|
||||
|
||||
syntax: 'plain',
|
||||
brush: 'plain',
|
||||
brushUrl: 'shBrushPlain.js',
|
||||
theme: 'Default',
|
||||
shPath: 'resources/syntaxhighlighter',
|
||||
@@ -153,7 +154,6 @@ Sonia.panel.SyntaxHighlighterPanel = Ext.extend(Ext.Panel, {
|
||||
for ( var j=0;j<s.aliases.length; j++ ){
|
||||
if ( this.syntax == s.aliases[j] ){
|
||||
found = true;
|
||||
this.syntax = s.name;
|
||||
this.brushUrl = s.fileName;
|
||||
if (debug){
|
||||
console.debug( "found brush " + this.syntax + " at " + this.brushUrl );
|
||||
@@ -174,6 +174,8 @@ Sonia.panel.SyntaxHighlighterPanel = Ext.extend(Ext.Panel, {
|
||||
}
|
||||
}
|
||||
|
||||
this.brush = this.syntax;
|
||||
|
||||
// load core stylesheet
|
||||
main.loadStylesheet( this.shPath + '/styles/shCore.css');
|
||||
// load theme stylesheet
|
||||
@@ -186,31 +188,26 @@ Sonia.panel.SyntaxHighlighterPanel = Ext.extend(Ext.Panel, {
|
||||
autoScroll: true,
|
||||
listeners: {
|
||||
afterrender: {
|
||||
fn: this.loadContent,
|
||||
fn: this.loadBodyContent,
|
||||
scope: this
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.loadContent();
|
||||
|
||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||
|
||||
if (debug){
|
||||
console.debug(config);
|
||||
}
|
||||
|
||||
Sonia.panel.SyntaxHighlighterPanel.superclass.initComponent.apply(this, arguments);
|
||||
},
|
||||
|
||||
loadContent: function(){
|
||||
loadBodyContent: function(){
|
||||
main.loadScript(this.shPath + '/scripts/shCore.js', this.loadBrush, this);
|
||||
Ext.Ajax.request({
|
||||
url: this.contentUrl,
|
||||
scope: this,
|
||||
success: function(response){
|
||||
console.debug( this.syntax );
|
||||
this.update('<pre class="brush: ' + this.syntax + '">' + Ext.util.Format.htmlEncode(response.responseText) + '</pre>');
|
||||
if (debug){
|
||||
console.debug( 'load content for brush: ' + this.brush );
|
||||
}
|
||||
this.update('<pre class="brush: ' + this.brush + '; class-name: ' + this.brush + '">' + Ext.util.Format.htmlEncode(response.responseText) + '</pre>');
|
||||
this.contentLoaded = true;
|
||||
this.highlight();
|
||||
},
|
||||
|
||||
@@ -390,6 +390,7 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
||||
if ( this.scripts.indexOf(url) < 0 ){
|
||||
var js = document.createElement('script');
|
||||
js.type = "text/javascript";
|
||||
js.language = 'javascript';
|
||||
js.src = url;
|
||||
|
||||
if ( Ext.isIE ){
|
||||
@@ -408,8 +409,9 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
||||
console.debug('load script ' + url);
|
||||
}
|
||||
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
head.appendChild(js);
|
||||
document.body.appendChild(js);
|
||||
// var head = document.getElementsByTagName('head')[0];
|
||||
// head.appendChild(js);
|
||||
this.scripts.push(url);
|
||||
} else {
|
||||
if (debug){
|
||||
|
||||
Reference in New Issue
Block a user