##// END OF EJS Templates
Ability to switch file source field in posting form
neko259 -
r1461:0a26ae7c default
parent child Browse files
Show More
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -533,3 +533,6 b' msgstr "\xd0\x9c\xd0\xbe\xd0\xbd\xd0\xbe\xd1\x85\xd1\x80\xd0\xbe\xd0\xbc\xd0\xbd\xd1\x8b\xd0\xb9"'
533
533
534 msgid "Subsections: "
534 msgid "Subsections: "
535 msgstr "Подразделы: "
535 msgstr "Подразделы: "
536
537 msgid "Change file source"
538 msgstr "Изменить источник файла"
@@ -153,3 +153,4 b' textarea, input {'
153 filter: grayscale(100%);
153 filter: grayscale(100%);
154 -webkit-filter: grayscale(100%);
154 -webkit-filter: grayscale(100%);
155 }
155 }
156
@@ -1,3 +1,5 b''
1 var ITEM_FILE_SOURCE = 'fileSource';
2
1 $('input[name=image]').wrap($('<div class="file_wrap"></div>'));
3 $('input[name=image]').wrap($('<div class="file_wrap"></div>'));
2
4
3 $('body').on('change', 'input[name=image]', function(event) {
5 $('body').on('change', 'input[name=image]', function(event) {
@@ -60,6 +62,27 b' function addHiddenInput(form, name, valu'
60 form.find('input[name=' + name + ']').val(value);
62 form.find('input[name=' + name + ']').val(value);
61 }
63 }
62
64
65 function selectFileChoice() {
66 var file_input = $('#id_file');
67 var url_input = $('#id_file_url');
68
69 var file_input_row = file_input.parent().parent();
70 var url_input_row = url_input.parent().parent();
71
72 file_input_row.toggle();
73 url_input_row.toggle();
74 url_input.val('');
75 file_input.val('');
76
77 var source;
78 if (file_input_row.is(':visible')) {
79 source = 'file';
80 } else {
81 source = 'url';
82 }
83 localStorage.setItem(ITEM_FILE_SOURCE, source);
84 }
85
63 $(document).ready(function() {
86 $(document).ready(function() {
64 var powDifficulty = parseInt($('body').attr('data-pow-difficulty'));
87 var powDifficulty = parseInt($('body').attr('data-pow-difficulty'));
65 if (powDifficulty > 0) {
88 if (powDifficulty > 0) {
@@ -92,4 +115,18 b' function addHiddenInput(form, name, valu'
92 return false;
115 return false;
93 });
116 });
94 }
117 }
118
119 var source = localStorage.getItem(ITEM_FILE_SOURCE);
120 if (source == null) {
121 source = 'file';
122 }
123 if (source == 'file') {
124 $('#id_file_url').parent().parent().hide();
125 } else {
126 $('#id_file').parent().parent().hide();
127 }
128
129 $('#file-source-button').click(function() {
130 selectFileChoice();
95 });
131 });
132 });
@@ -163,6 +163,7 b''
163 <div class="form-submit">
163 <div class="form-submit">
164 <input type="submit" value="{% trans "Post" %}"/>
164 <input type="submit" value="{% trans "Post" %}"/>
165 <button id="preview-button" onclick="return false;">{% trans 'Preview' %}</button>
165 <button id="preview-button" onclick="return false;">{% trans 'Preview' %}</button>
166 <button id="file-source-button" onclick="return false;">{% trans 'Change file source' %}</button>
166 </div>
167 </div>
167 </form>
168 </form>
168 </div>
169 </div>
@@ -51,6 +51,7 b''
51 <div class="form-submit">
51 <div class="form-submit">
52 <input type="submit" value="{% trans "Post" %}"/>
52 <input type="submit" value="{% trans "Post" %}"/>
53 <button id="preview-button" onclick="return false;">{% trans 'Preview' %}</button>
53 <button id="preview-button" onclick="return false;">{% trans 'Preview' %}</button>
54 <button id="file-source-button" onclick="return false;">{% trans 'Change file source' %}</button>
54 </div>
55 </div>
55 </form>
56 </form>
56 </div>
57 </div>
General Comments 0
You need to be logged in to leave comments. Login now