@@ -559,8 +559,6 @@ function IFM() {
559
559
$('.clickable-row').click(function(event) {
560
560
if( event.ctrlKey ) {
561
561
$(this).toggleClass( 'selectedItem' );
562
- } else {
563
- self.highlightItem( $(this) );
564
562
}
565
563
});
566
564
}
@@ -597,14 +595,38 @@ function IFM() {
597
595
this.showFileForm = function () {
598
596
var filename = arguments.length > 0 ? arguments[0] : "newfile.txt";
599
597
var content = arguments.length > 1 ? arguments[1] : "";
600
- var overlay = '<form id="showFile">';
601
- overlay += '<div class="modal-body"><fieldset><label>Filename:</label><input onkeypress="return ifm.preventEnter(event);" type="text" class="form-control" name="filename" value="'+filename+'" /><br>';
602
- overlay += '<div id="content" name="content"></div><input type="checkbox" id="aceWordWrap"> word wrap</input></fieldset></div>';
603
- overlay += '<div class="modal-footer"><button type="button" class="btn btn-default" onclick="ifm.saveFile();ifm.hideModal();return false;">Save';
604
- overlay += '</button><button type="button" onclick="ifm.saveFile();return false;" class="btn btn-default">Save without closing</button>';
605
- overlay += '<button type="button" class="btn btn-default" onclick="ifm.hideModal();return false;">Close</button></div></form>';
598
+ var overlay = '<form id="showFile">' +
599
+ '<div class="modal-body"><fieldset><label>Filename:</label><input onkeypress="return ifm.preventEnter(event);" type="text" class="form-control" name="filename" value="'+filename+'" /><br>' +
600
+ '<div id="content" name="content"></div><br>' +
601
+ '<button type="button" class="btn btn-default" id="editoroptions">editor options</button><div class="hide" id="editoroptions-head">options</div><div class="hide" id="editoroptions-content">' +
602
+ '<input type="checkbox" id="editor-wordwrap"> word wrap</input><br>' +
603
+ '<input type="checkbox" id="editor-softtabs"> use soft tabs</input>' +
604
+ '<div class="input-group"><span class="input-group-addon">tabsize</span><input class="form-control" type="text" size="2" id="editor-tabsize"title="tabsize"></div>' +
605
+ '</div></fieldset></div>' +
606
+ '<div class="modal-footer"><button type="button" class="btn btn-default" onclick="ifm.saveFile();ifm.hideModal();return false;">Save' +
607
+ '</button><button type="button" onclick="ifm.saveFile();return false;" class="btn btn-default">Save without closing</button>' +
608
+ '<button type="button" class="btn btn-default" onclick="ifm.hideModal();return false;">Close</button></div></form>';
606
609
self.showModal( overlay, { large: true } );
607
- $('#ifmmodal').on('remove', function () { self.editor = null; self.fileChanged = false; });
610
+ $('#editoroptions').popover({
611
+ html: true,
612
+ title: function() { return $('#editoroptions-head').html(); },
613
+ content: function() {
614
+ var content = $('#editoroptions-content').clone()
615
+ var aceSession = self.editor.getSession();
616
+ content.removeClass( 'hide' );
617
+ content.find( '#editor-wordwrap' )
618
+ .prop( 'checked', ( aceSession.getOption( 'wrap' ) == 'off' ? false : true ) )
619
+ .on( 'change', function() { self.editor.setOption( 'wrap', $( this ).is( ':checked' ) ); });
620
+ content.find( '#editor-softtabs' )
621
+ .prop( 'checked', aceSession.getOption( 'useSoftTabs' ) )
622
+ .on( 'change', function() { self.editor.setOption( 'useSoftTabs', $( this ).is( ':checked' ) ); });
623
+ content.find( '#editor-tabsize' )
624
+ .val( aceSession.getOption( 'tabSize' ) )
625
+ .on( 'keydown', function( e ) { if( e.key == 'Enter' ) { self.editor.setOption( 'tabSize', $( this ).val() ); } });
626
+ return content;
627
+ }
628
+ });
629
+ $('#ifmmodal').on( 'remove', function () { self.editor = null; self.fileChanged = false; });
608
630
// Start ACE
609
631
self.editor = ace.edit("content");
610
632
self.editor.$blockScrolling = 'Infinity';
@@ -1048,7 +1070,7 @@ function IFM() {
1048
1070
$(document.body).prepend('<div id="waitqueue"></div>');
1049
1071
//$("#waitqueue").on("mouseover", function() { $(this).toggleClass("left"); });
1050
1072
}
1051
- $("#waitqueue").append ('<div id="'+id+'" class="panel panel-default"><div class="panel-body"><div class="progress"><div class="progress-bar progress-bar-info progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemax="100" style="width:100%"></div><span class="progbarlabel">'+name+'</span></div></div></div>');
1073
+ $("#waitqueue").prepend ('<div id="'+id+'" class="panel panel-default"><div class="panel-body"><div class="progress"><div class="progress-bar progress-bar-info progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemax="100" style="width:100%"></div><span class="progbarlabel">'+name+'</span></div></div></div>');
1052
1074
};
1053
1075
this.task_done = function(id) {
1054
1076
$("#"+id).remove();
@@ -1060,27 +1082,29 @@ function IFM() {
1060
1082
$('#'+id+' .progress-bar').css('width', progress+'%').attr('aria-valuenow', progress);
1061
1083
};
1062
1084
this.highlightItem = function( param ) {
1085
+ var highlight = function( el ) {
1086
+ el.addClass( 'highlightedItem' ).siblings().removeClass( 'highlightedItem' );
1087
+ el.find( 'a' ).first().focus();
1088
+ if( ! self.isElementInViewport( el ) ) {
1089
+ var scrollOffset = 0;
1090
+ if( param=="prev" )
1091
+ scrollOffset = el.offset().top - ( window.innerHeight || document.documentElement.clientHeight ) + el.height() + 15;
1092
+ else
1093
+ scrollOffset = el.offset().top - 55;
1094
+ $('html, body').animate( { scrollTop: scrollOffset }, 500 );
1095
+ }
1096
+ };
1063
1097
if( param.jquery ) {
1064
- param.addClass( 'highlightedItem' ).siblings().removeClass( 'highlightedItem' );
1098
+ highlight( param );
1065
1099
} else {
1066
1100
var highlightedItem = $('.highlightedItem');
1067
1101
if( ! highlightedItem.length ) {
1068
- $('#filetable tbody tr:first-child').addClass( 'highlightedItem' );
1102
+ highlight( $('#filetable tbody tr:first-child') );
1069
1103
} else {
1070
1104
var newItem = ( param=="next" ? highlightedItem.next() : highlightedItem.prev() );
1071
1105
1072
1106
if( newItem.is( 'tr' ) ) {
1073
- highlightedItem.removeClass( 'highlightedItem' );
1074
- newItem.addClass( 'highlightedItem' );
1075
- newItem.find( 'a' ).first().focus();
1076
- if( ! this.isElementInViewport( newItem ) ) {
1077
- var scrollOffset = 0;
1078
- if( param=="next" )
1079
- scrollOffset = highlightedItem.offset().top - 15;
1080
- else
1081
- scrollOffset = highlightedItem.offset().top - ( window.innerHeight || document.documentElement.clientHeight ) + highlightedItem.height() + 15;
1082
- $('html, body').animate( { scrollTop: scrollOffset }, 500 );
1083
- }
1107
+ highlight( newItem );
1084
1108
}
1085
1109
}
1086
1110
}
0 commit comments