Commit b180c4b2e6bfba87665324f708879eb8202ed882

  • avatar
  • Samuel Uusi-Mäkelä <kaiutindev @gm…l.com> (Committer)
  • Fri Jun 06 12:24:50 EEST 2014
  • avatar
  • Samuel Uusi-Mäkelä <kaiutindev @gm…l.com> (Author)
  • Fri Jun 06 12:24:50 EEST 2014
Editoritoiminto melko hyvässä vaiheessa
timApp/static/scripts/timApp.js
(9 / 5)
  
1414 sc.setEditable = function(par){
1515 var elem = sc.findPar(par);
1616 var elemId = sc.findParId(par);
17 if(sc.editing == true && sc.editorExists(elem.par)){
17 if(sc.paragraphs[elemId].display == true && sc.editorExists(elem.par)){
1818 mdtext = sc.getEditor(elem.par).editor.getSession().getValue();
1919 sc.paragraphs[elemId].text = mdtext;
2020 $('.'+elem.par).html(sc.convertHtml.makeHtml(mdtext));
2121 sc.paragraphs[elemId].display = false;
2222 sc.activeEdit.editId = "";
2323 sc.activeEdit.text = "";
24 sc.editing = false;
2524 }
2625
2726
2827 else {
29
3028 sc.paragraphs[elemId].display = true;
3129 var editor = ace.edit(elem.par);
3230 editor.getSession().setValue(sc.paragraphs[elemId].text);
3434 editor.getSession().on('change', function(e) {
3535 $('.'+elem.par).html(sc.convertHtml.makeHtml(editor.getSession().getValue()));
3636 });
37 sc.editing = true;
3837 sc.activeEdit.text = sc.paragraphs[elemId].text;
3938 sc.activeEdit.editId = elem.par;
40 // sc.setEditPosition(elem.par);
4139 }
4240 };
4341
109109 }
110110 }
111111 });
112
113// Here we define converter for markdown --> html. You can define custom hooks here.
114function makeSanitizingConverter(){
115 converter = new Markdown.getSanitizingConverter();
116 converter.hooks.chain("postConversion", function(text){
117 });
118 return converter;
119}
timApp/static/stylesheet.css
(14 / 2)
  
1
12.content{
2 width: 40em;
3 white-space: pre;
3 width: 30em;
4 text-align: justify;
5}
6
7.paragraph{
8 position: relative;
9 width: 60em;
10}
11
12.editButton{
13 position:relative;
14 left:37em;
15 top:0em;
416}
timApp/templates/start.html
(16 / 15)
  
1<!doctype html>
1<!DOCTYPE html>
22<html lang="en" ng-app="timApp">
33<head>
44 <title>TIM</title>
1313 <script type="text/javascript" src="{{url_for('static', filename='scripts/Markdown.Sanitizer.js')}}"></script>
1414 <script type="text/javascript" src="{{url_for('static', filename='scripts/src-min/ace.js')}}"> </script>
1515 <style type="text/css" media="screen">
16 .editor {
17 position: absolute;
18 height:30em;
19 width:30em;
20 top: -20;
21 right: 40em;
22
23 }
16
17 .editor {
18 position: absolute;
19 height: 100%;
20 width:40em;
21 top: 0em;
22 bottom; 0em;
23 left: 45em;
24 }
2425 </style>
2526 <script>
2627 // Imported data from jinja2 template
2728 var jsonData = JSON.parse({{ text|tojson|safe }});
28 </script>
29 </script>
2930 <script type="text/javascript" src="{{url_for('static', filename='scripts/timApp.js')}}"></script>
3031
3132 <!--[if lt IE 9]>
3636 </script>
3737</head>
3838 <body ng-controller="TimCtrl">
39 <div ng-repeat="par in paragraphs">
39 <div class="paragraph" ng-repeat="par in paragraphs">
4040 <div style="" id="" class="content {{ '{{ par.par }}' }}" bind-once ng-bind-html="par.html"> </div>
41 <button ng-click="setEditable(par.par)"> Edit </button>
42 <div id="{{'{{ par.par }}'}}" class="editor" ng-show="par.display" ng-model="activeEdit.text"></div>
43
41 <button class="editButton" ng-click="setEditable(par.par)"> Edit </button>
42 <div id="{{'{{ par.par }}'}}" class="editor" ng-show="par.display" ng-model="activeEdit.text">
43 </div>
4444 </div>
45 </body>
45 </body>
4646</html>