##// END OF EJS Templates
forms: added a codemirror form widget.
marcink -
r2409:36eff123 default
parent child Browse files
Show More
@@ -0,0 +1,32 b''
1 # -*- coding: utf-8 -*-
2
3 # Copyright (C) 2011-2017 RhodeCode GmbH
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
21 import logging
22
23 import deform
24 import deform.widget
25
26
27 log = logging.getLogger(__name__)
28
29
30 class CodeMirrorWidget(deform.widget.TextAreaWidget):
31 template = 'codemirror'
32 requirements = (('deform', None), ('codemirror', None))
@@ -0,0 +1,30 b''
1 <div tal:define="rows rows|field.widget.rows;
2 cols cols|field.widget.cols;
3 css_class css_class|field.widget.css_class;
4 oid oid|field.oid;
5 name name|field.name;
6 style style|field.widget.style;
7 help_block help_block|field.widget.help_block|'';
8 codemirror_options codemirror_options|field.widget.codemirror_options|{};
9 codemirror_mode codemirror_mode|field.widget.codemirror_mode|''
10 ">
11
12 <textarea tal:attributes="rows rows;
13 cols cols;
14 class string: form-control ${css_class or ''};
15 style style"
16 id="${oid}"
17 name="${name}">${cstruct}</textarea>
18
19 <p tal:condition="help_block" class="help-block">${help_block}</p>
20 <script type="text/javascript">
21 deform.addCallback(
22 '${oid}',
23 function(oid) {
24 var myCodeMirror = initCodeMirror(oid, '', false, ${codemirror_options});
25 setCodeMirrorMode(myCodeMirror, '${codemirror_mode}');
26 }
27 );
28 </script>
29
30 </div>
General Comments 0
You need to be logged in to leave comments. Login now