##// END OF EJS Templates
Updated form to a new style. Fixed mark manel
neko259 -
r680:1d0d562c default
parent child Browse files
Show More
@@ -68,13 +68,13 b' class NeboardForm(forms.Form):'
68
68
69 return self._html_output(
69 return self._html_output(
70 # TODO Do not show hidden rows in the list here
70 # TODO Do not show hidden rows in the list here
71 normal_row='<div class="form-row">'
71 normal_row='<div class="form-row"><div class="form-label">'
72 '<div class="form-label">'
73 '%(label)s'
72 '%(label)s'
74 '</div>'
73 '</div></div>'
75 '<div class="form-input">'
74 '<div class="form-row"><div class="form-input">'
76 '%(field)s'
75 '%(field)s'
77 '</div>'
76 '</div></div>'
77 '<div class="form-row">'
78 '%(help_text)s'
78 '%(help_text)s'
79 '</div>',
79 '</div>',
80 error_row='<div class="form-row">'
80 error_row='<div class="form-row">'
@@ -47,15 +47,18 b' input[name="image"] {'
47 z-index: 1;
47 z-index: 1;
48 }
48 }
49
49
50 #file_wrap {
50 .file_wrap {
51 width: 100px;
51 width: 100px;
52 height: 100px;
52 height: 100px;
53 border: solid 1px white;
53 border: solid 1px white;
54 display: inline-block;
54 display: inline-block;
55 float: left;
56 }
55 }
57
56
58 #file-thumb {
57 form > .file_wrap {
58 float: left;
59 }
60
61 .file-thumb {
59 width: 100px;
62 width: 100px;
60 height: 100px;
63 height: 100px;
61 background-size: cover;
64 background-size: cover;
@@ -66,7 +69,7 b' input[name="image"] {'
66 margin-left:110px;
69 margin-left:110px;
67 }
70 }
68
71
69 textarea {
72 textarea, input {
70 -moz-box-sizing: border-box;
73 -moz-box-sizing: border-box;
71 -webkit-box-sizing: border-box;
74 -webkit-box-sizing: border-box;
72 box-sizing: border-box;
75 box-sizing: border-box;
@@ -128,11 +128,7 b' p {'
128 }
128 }
129
129
130 .form-row {
130 .form-row {
131 display: table-row;
131 width: 100%;
132 }
133
134 .form-label, .form-input, .form-errors {
135 display: table-cell;
136 }
132 }
137
133
138 .form-label {
134 .form-label {
@@ -149,12 +145,13 b' p {'
149 vertical-align: middle;
145 vertical-align: middle;
150 }
146 }
151
147
152 .post-form input, .post-form textarea {
148 .post-form input:not([name="image"]), .post-form textarea {
153 background: #333;
149 background: #333;
154 color: #fff;
150 color: #fff;
155 border: solid 1px;
151 border: solid 1px;
156 padding: 0;
152 padding: 0;
157 font: medium sans;
153 font: medium sans-serif;
154 width: 100%;
158 }
155 }
159
156
160 .form-submit {
157 .form-submit {
@@ -89,7 +89,8 b' li {'
89 }
89 }
90
90
91 .form-row {
91 .form-row {
92 display: table-row;
92 display: table;
93 width: 100%;
93 }
94 }
94 .form-label, .form-input {
95 .form-label, .form-input {
95 display: table-cell;
96 display: table-cell;
@@ -108,8 +109,12 b' li {'
108 border: none;
109 border: none;
109 padding: 0;
110 padding: 0;
110 resize: vertical;
111 resize: vertical;
112 }
113
114 .form-input > :not(.file_wrap) {
111 width: 100%;
115 width: 100%;
112 }
116 }
117
113 .form-submit {
118 .form-submit {
114 border-bottom: 1px solid #666;
119 border-bottom: 1px solid #666;
115 margin-bottom: .5em;
120 margin-bottom: .5em;
@@ -127,7 +132,7 b' li {'
127 padding: .2em 1ex;
132 padding: .2em 1ex;
128 }
133 }
129 .form-label {
134 .form-label {
130 text-align: right;
135 text-align: left;
131 }
136 }
132
137
133 .block {
138 .block {
@@ -1,6 +1,6 b''
1 var isCompact = true;
1 var isCompact = true;
2
2
3 $('input[name=image]').wrap($('<div id="file_wrap"></div>'));
3 $('input[name=image]').wrap($('<div class="file_wrap"></div>'));
4
4
5 $('body').on('change', 'input[name=image]', function(event) {
5 $('body').on('change', 'input[name=image]', function(event) {
6 var file = event.target.files[0];
6 var file = event.target.files[0];
@@ -9,9 +9,11 b' var isCompact = true;'
9 var fileReader = new FileReader();
9 var fileReader = new FileReader();
10
10
11 fileReader.addEventListener("load", function(event) {
11 fileReader.addEventListener("load", function(event) {
12 $('#file_wrap').find('#file-thumb').remove();
12 var wrapper = $('.file_wrap');
13 $('#file_wrap').append(
13
14 $('<div id="file-thumb" style="background-image: url('+event.target.result+')"></div>')
14 wrapper.find('.file-thumb').remove();
15 wrapper.append(
16 $('<div class="file-thumb" style="background-image: url('+event.target.result+')"></div>')
15 );
17 );
16 });
18 });
17
19
@@ -34,19 +34,23 b' function addMarkToMsg(start, end) {'
34 return addTextToEachLineOfSelection(start);
34 return addTextToEachLineOfSelection(start);
35 }
35 }
36
36
37 var textarea = document.getElementsByTagName('textarea')[0];
37 var textareas = document.getElementsByTagName('textarea');
38 if(!textarea) return;
38
39 if( document.selection ) {
39 for (var i = 0; i < textareas.length; i++) {
40 textarea.focus();
40 var textarea = textareas[i];
41 sel = document.selection.createRange();
41
42 sel.text = start + sel.text + end;
42 if( document.selection ) {
43 } else if(textarea.selectionStart || textarea.selectionStart == '0') {
43 textarea.focus();
44 textarea.focus();
44 var sel = document.selection.createRange();
45 var startPos = textarea.selectionStart;
45 sel.text = start + sel.text + end;
46 var endPos = textarea.selectionEnd;
46 } else if(textarea.selectionStart || textarea.selectionStart == '0') {
47 textarea.value = textarea.value.substring(0, startPos) + start + textarea.value.substring(startPos, endPos) + end + textarea.value.substring( endPos, textarea.value.length );
47 textarea.focus();
48 } else {
48 var startPos = textarea.selectionStart;
49 textarea.value += start + end;
49 var endPos = textarea.selectionEnd;
50 textarea.value = textarea.value.substring(0, startPos) + start + textarea.value.substring(startPos, endPos) + end + textarea.value.substring( endPos, textarea.value.length );
51 } else {
52 textarea.value += start + end;
53 }
50 }
54 }
51 return false;
55 return false;
52 }
56 }
General Comments 0
You need to be logged in to leave comments. Login now