todolist panel (frontend part), by clicking on the TODO the relatve file is opened in a tab and the cursor is placed at the right line
This commit is contained in:
@@ -52,12 +52,17 @@
|
||||
<link rel="stylesheet" href="{{=css_url}}/web2py-codemirror.css">
|
||||
<script type="text/javascript">
|
||||
var current_font_incr = 0; // Default font-size, 0 means isn't set
|
||||
$(document).on('shown click', 'a[data-toggle="tab"]', function (e) {
|
||||
$(document).on('shown click', 'a[data-toggle="tab"]', function (e, lineno) {
|
||||
var tab_id = $(this).attr('href');
|
||||
var editor = $(tab_id + " textarea").data('editor');
|
||||
if (editor) {
|
||||
editor.setSize('100%', $(tab_id).height());
|
||||
editor_height = $(window).height() - $(tab_id + " .well-small").offset().top - $(tab_id + " .well-small").outerHeight(true) - $('.navbar-fixed-bottom').outerHeight() - 1;
|
||||
editor.setSize('100%', editor_height);
|
||||
editor.refresh();
|
||||
if (lineno !== undefined) {
|
||||
editor.setCursor(lineno);
|
||||
editor.centerOnCursor();
|
||||
}
|
||||
}
|
||||
var n_li = $('#filesTab li').length;
|
||||
$.each($('#filesTab li'), function(index, element) {
|
||||
@@ -104,7 +109,8 @@ $(document).on('click', '#restore', function (e) {
|
||||
$(document).on('click', 'a.editor_filelink, a#editor_settingslink', function (e) {
|
||||
e.preventDefault();
|
||||
var url = $(this).attr("href");
|
||||
load_file(url);
|
||||
var lineno = $(this).data("lineno");
|
||||
load_file(url, lineno);
|
||||
});
|
||||
|
||||
/* This method updates all editors already instantiated with the selected preferences*/
|
||||
@@ -164,7 +170,7 @@ $(document).on('click', 'a.font_button', function (e) {
|
||||
});
|
||||
|
||||
{{if len(request.args) > 1:}}
|
||||
load_file('{{=URL(f='edit', args=request.args, vars=request.get_vars)}}');
|
||||
load_file('{{=URL(f='edit', args=request.args, vars=request.get_vars)}}', {{=request.vars.lineno or 1}});
|
||||
{{pass}}
|
||||
|
||||
</script>
|
||||
|
||||
@@ -74,15 +74,15 @@
|
||||
request.env['wsgi_url_scheme'], request.env['http_host'],
|
||||
URL(c='debug', f='toggle_breakpoint')))}}, sel);
|
||||
});
|
||||
function makeMarker() {
|
||||
var marker = document.createElement("div");
|
||||
marker.style.color = "#822";
|
||||
marker.innerHTML = "●";
|
||||
marker.className = "breakpoint";
|
||||
return marker;
|
||||
}
|
||||
function makeMarker() {
|
||||
var marker = document.createElement("div");
|
||||
marker.style.color = "#822";
|
||||
marker.innerHTML = "●";
|
||||
marker.className = "breakpoint";
|
||||
return marker;
|
||||
}
|
||||
|
||||
{{if filetype in ('html', 'javascript', 'css'):}}
|
||||
{{if filetype in ('html', 'javascript', 'css'):}}
|
||||
// must be here or break emmet/zencoding
|
||||
CodeMirror.defaults.extraKeys["Ctrl-S"] =
|
||||
function(instance) {
|
||||
@@ -94,26 +94,26 @@
|
||||
CodeMirror.defaults.extraKeys["Shift-Esc"] = function(cm) {
|
||||
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
|
||||
}
|
||||
{{pass}}
|
||||
{{if filetype=='python':}}
|
||||
// must be here or break emmet/zencoding for python
|
||||
CodeMirror.defaults.extraKeys["Ctrl-S"] =
|
||||
function(instance) {
|
||||
doClickSave();};
|
||||
CodeMirror.defaults.extraKeys["Ctrl-Space"] = "autocomplete";
|
||||
CodeMirror.defaults.extraKeys["Tab"] = "indentMore";
|
||||
CodeMirror.defaults.extraKeys["Shift-Tab"] = "indentLess";
|
||||
CodeMirror.defaults.extraKeys["Ctrl-F11"] = function(cm) {
|
||||
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
|
||||
},
|
||||
CodeMirror.defaults.extraKeys["Shift-Esc"] = function(cm) {
|
||||
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
|
||||
}
|
||||
//for autocomplete
|
||||
CodeMirror.commands.autocomplete = function(cm) {
|
||||
CodeMirror.showHint(cm, CodeMirror.pythonHint);
|
||||
}
|
||||
{{pass}}
|
||||
{{pass}}
|
||||
{{if filetype=='python':}}
|
||||
// must be here or break emmet/zencoding for python
|
||||
CodeMirror.defaults.extraKeys["Ctrl-S"] =
|
||||
function(instance) {
|
||||
doClickSave();};
|
||||
CodeMirror.defaults.extraKeys["Ctrl-Space"] = "autocomplete";
|
||||
CodeMirror.defaults.extraKeys["Tab"] = "indentMore";
|
||||
CodeMirror.defaults.extraKeys["Shift-Tab"] = "indentLess";
|
||||
CodeMirror.defaults.extraKeys["Ctrl-F11"] = function(cm) {
|
||||
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
|
||||
},
|
||||
CodeMirror.defaults.extraKeys["Shift-Esc"] = function(cm) {
|
||||
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
|
||||
}
|
||||
//for autocomplete
|
||||
CodeMirror.commands.autocomplete = function(cm) {
|
||||
CodeMirror.showHint(cm, CodeMirror.pythonHint);
|
||||
}
|
||||
{{pass}}
|
||||
store_changes_function = function(instance, changeObj) {
|
||||
jQuery(instance).data('saved', false);
|
||||
instance.off("change", store_changes_function);
|
||||
@@ -128,6 +128,19 @@
|
||||
request.env['wsgi_url_scheme'], request.env['http_host'],
|
||||
URL(c='debug', f='list_breakpoints')))}}, editor);
|
||||
|
||||
// TODO move it in a separated file
|
||||
CodeMirror.defineExtension("centerOnCursor", function(limit) {
|
||||
var coords = this.cursorCoords(null, "local");
|
||||
if (this.getScrollerElement().clientHeight === 0 && limit !== 10) {
|
||||
if (limit === undefined) limit = 1;
|
||||
else limit += 1;
|
||||
editor = this;
|
||||
setTimeout(function() {editor.centerOnCursor()}, 100);
|
||||
return;
|
||||
}
|
||||
clientHeight = (this.getScrollerElement().clientHeight / 2)
|
||||
this.scrollTo(null, (coords.top + coords.bottom)/2 - 10);
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="editor-bar-bottom" style="margin-top:9px;">
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<li onclick="collapse('{{=pos_file}}_matches');"><a ><i class='icon-chevron-right'></i>{{=file['filename']}} <span class='small'>({{=len(file['matches'])}} TODO)</span></a></li>
|
||||
<li id="{{=pos_file}}_matches" style="display: none;"><ul class="nav nav-list small-font">
|
||||
{{for m in file['matches']:}}
|
||||
<li><a href="{{=URL('edit', args=[app,file['dir'], file['filename']], vars={'lineno':m['lineno']}, extension="")}}" class="editor_filelink" >{{=m['text']}}</a></li>
|
||||
<li><a href="{{=URL('edit', args=[app,file['dir'], file['filename']], vars={'lineno':m['lineno']}, extension="")}}" data-lineno="{{=m['lineno']-1}}" class="editor_filelink" >{{=m['text']}}</a></li>
|
||||
{{pass}}
|
||||
</ul></li>
|
||||
{{pass}}
|
||||
|
||||
Reference in New Issue
Block a user