settings tab in admin editor
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
}}
|
||||
{{cm=URL('static','codemirror')}}
|
||||
<link rel="stylesheet" href="{{=cm}}/lib/codemirror.css">
|
||||
<link rel="stylesheet" href="{{=cm}}/theme/web2py.css">
|
||||
<link rel="stylesheet" href="{{="%s/theme/%s.css" % (cm, editor_settings['theme'])}}">
|
||||
<script src="{{=cm}}/lib/codemirror.js"></script>
|
||||
<script src="{{=cm}}/mode/clike/clike.js"></script>
|
||||
<script src="{{=cm}}/addon/edit/matchbrackets.js"></script>
|
||||
@@ -42,7 +42,7 @@
|
||||
<link rel="stylesheet" href="{{=URL('static/css','typeahead.js-bootstrap.css')}}">
|
||||
<link rel="stylesheet" href="{{=URL('static/css','web2py-codemirror.css')}}">
|
||||
<script type="text/javascript">
|
||||
var current_theme = "web2py"; //Default theme
|
||||
var current_theme = "{{=editor_settings['theme']}}"; //Default theme
|
||||
var current_font_incr = 0; // Default font-size, 0 means don't set
|
||||
jQuery(document).on('shown click', 'a[data-toggle="tab"]', function (e) {
|
||||
var tab_id = jQuery(this).attr('href');
|
||||
@@ -84,32 +84,27 @@ jQuery(document).on('click', '#restore', function (e) {
|
||||
});
|
||||
|
||||
// open the selected file
|
||||
jQuery(document).on('click', 'a.editor_filelink', function (e) {
|
||||
e.preventDefault();
|
||||
var url = jQuery(this).attr("href");
|
||||
load_file(url);
|
||||
jQuery(document).on('click', 'a.editor_filelink, a#editor_settingslink', function (e) {
|
||||
e.preventDefault();
|
||||
var url = jQuery(this).attr("href");
|
||||
load_file(url);
|
||||
});
|
||||
|
||||
// change the codemirror theme
|
||||
jQuery(document).on('click', '#themes a', function (e) {
|
||||
e.preventDefault();
|
||||
var href = jQuery(this).attr('href');
|
||||
var name = jQuery(this).text().replace('.css', '');
|
||||
var link = jQuery("<link>");
|
||||
link.attr({
|
||||
type: 'text/css',
|
||||
rel: 'stylesheet',
|
||||
href: href
|
||||
});
|
||||
jQuery("head").append( link );
|
||||
jQuery('textarea[name="data"]') .each(function(id, ta) {
|
||||
editor = jQuery(ta).data('editor');
|
||||
editor.setOption("theme", name);
|
||||
});
|
||||
jQuery('#themeName').html(name);
|
||||
current_theme = name;
|
||||
//#TODO save on session
|
||||
});
|
||||
function update_theme(name) {
|
||||
var href = "{{="%s/theme/" % cm}}" + name + ".css";
|
||||
var link = jQuery("<link>");
|
||||
link.attr({
|
||||
type: 'text/css',
|
||||
rel: 'stylesheet',
|
||||
href: href
|
||||
});
|
||||
jQuery("head").append( link );
|
||||
jQuery('textarea[name="data"]') .each(function(id, ta) {
|
||||
editor = jQuery(ta).data('editor');
|
||||
editor.setOption("theme", name);
|
||||
});
|
||||
current_theme = name;
|
||||
}
|
||||
|
||||
// incr/decr editor font-size
|
||||
jQuery(document).on('click', 'a.font_button', function (e) {
|
||||
@@ -166,14 +161,6 @@ jQuery(document).on('click', 'a.font_button', function (e) {
|
||||
<div class="btn-group">
|
||||
<a class="button btn" onclick="jQuery('#files').toggle(); return false" href="#">Files toggle</a>
|
||||
</div>
|
||||
<div class="dropdown btn-group pull-left">
|
||||
<a class="dropdown-toggle button btn" data-target="themes" data-toggle="dropdown" href="#" >Theme: <span id="themeName" style="color: #E8953C">Web2py</span> <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu" role="menu" id="themes">
|
||||
{{for f in listfiles('admin', "static/codemirror/theme", regexp='.*\.css$' ):}}
|
||||
<li class=""><a href="{{=URL('static/codemirror/theme', f, host=True)}}">{{=f[:-4]}}</a></li>
|
||||
{{pass}}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<a id="decr" class="button btn font_button">-</a>
|
||||
<a id="default" class="button btn font_button" >A</a>
|
||||
@@ -185,6 +172,7 @@ jQuery(document).on('click', 'a.font_button', function (e) {
|
||||
<a class="button btn" href="http://www.web2py.com/sqldesigner" target="_blank"><span>{{=T('online designer')}}</span></a>
|
||||
{{#pass}}
|
||||
<a class="button btn" href="http://www.web2py.com/examples/static/epydoc/index.html" target="_blank"><span>{{=T('docs')}}</span></a>
|
||||
<a class="button btn" title="{{=T('change editor settings')}}" id="editor_settingslink" href="{{=URL('default', 'edit', args=request.args, vars={'settings':True})}}"><i class="icon-cog"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user