##// END OF EJS Templates
Fixed sticker autocompletions. Localized 'too many files' message and added max file count there
neko259 -
r1766:8d73e763 default
parent child Browse files
Show More
@@ -49,7 +49,8 b" LABEL_FILE = _('File')"
49
49
50 ERROR_SPEED = 'Please wait %(delay)d second before sending message'
50 ERROR_SPEED = 'Please wait %(delay)d second before sending message'
51 ERROR_SPEED_PLURAL = 'Please wait %(delay)d seconds before sending message'
51 ERROR_SPEED_PLURAL = 'Please wait %(delay)d seconds before sending message'
52 ERROR_MANY_FILES = _('Too many files.')
52 ERROR_MANY_FILES = 'You can post no more than %(files)d file.'
53 ERROR_MANY_FILES_PLURAL = 'You can post no more than %(files)d files.'
53
54
54 TAG_MAX_LENGTH = 20
55 TAG_MAX_LENGTH = 20
55
56
@@ -297,7 +298,9 b' class PostForm(NeboardForm):'
297
298
298 max_file_count = board_settings.get_int(SECTION_FORMS, 'MaxFileCount')
299 max_file_count = board_settings.get_int(SECTION_FORMS, 'MaxFileCount')
299 if len(inputs) > max_file_count:
300 if len(inputs) > max_file_count:
300 raise forms.ValidationError(ERROR_MANY_FILES)
301 raise forms.ValidationError(
302 ungettext_lazy(ERROR_MANY_FILES, ERROR_MANY_FILES,
303 max_file_count) % {'files': max_file_count})
301 for file_input in inputs:
304 for file_input in inputs:
302 if isinstance(file_input, UploadedFile):
305 if isinstance(file_input, UploadedFile):
303 files.append(self._clean_file_file(file_input))
306 files.append(self._clean_file_file(file_input))
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -567,3 +567,9 b' msgstr "\xd0\xa1\xd0\xb5\xd0\xb3\xd0\xbe\xd0\xb4\xd0\xbd\xd1\x8f \xd0\xbd\xd0\xb5\xd1\x82 \xd0\xb0\xd0\xba\xd1\x82\xd0\xb8\xd0\xb2\xd0\xbd\xd1\x8b\xd1\x85 \xd1\x82\xd0\xb5\xd0\xbc."'
567
567
568 msgid "Insert URLs on separate lines."
568 msgid "Insert URLs on separate lines."
569 msgstr "ВставляйтС ссылки Π½Π° ΠΎΡ‚Π΄Π΅Π»ΡŒΠ½Ρ‹Ρ… строках."
569 msgstr "ВставляйтС ссылки Π½Π° ΠΎΡ‚Π΄Π΅Π»ΡŒΠ½Ρ‹Ρ… строках."
570
571 msgid "You can post no more than %(files)d file."
572 msgid_plural "You can post no more than %(files)d files."
573 msgstr[0] "Π’Ρ‹ ΠΌΠΎΠΆΠ΅Ρ‚Π΅ ΠΎΡ‚ΠΏΡ€Π°Π²ΠΈΡ‚ΡŒ Π½Π΅ Π±ΠΎΠ»Π΅Π΅ %(files)d Ρ„Π°ΠΉΠ»Π°."
574 msgstr[1] "Π’Ρ‹ ΠΌΠΎΠΆΠ΅Ρ‚Π΅ ΠΎΡ‚ΠΏΡ€Π°Π²ΠΈΡ‚ΡŒ Π½Π΅ Π±ΠΎΠ»Π΅Π΅ %(files)d Ρ„Π°ΠΉΠ»ΠΎΠ²."
575 msgstr[2] "Π’Ρ‹ ΠΌΠΎΠΆΠ΅Ρ‚Π΅ ΠΎΡ‚ΠΏΡ€Π°Π²ΠΈΡ‚ΡŒ Π½Π΅ Π±ΠΎΠ»Π΅Π΅ %(files)d Ρ„Π°ΠΉΠ»ΠΎΠ²."
@@ -1,6 +1,7 b''
1 var ITEM_FILE_SOURCE = 'fileSource';
1 var ITEM_FILE_SOURCE = 'fileSource';
2 var URL_STICKERS = '/api/stickers'
2 var URL_STICKERS = '/api/stickers';
3 var MIN_INPUT_LENGTH = 3;
3 var MIN_INPUT_LENGTH = 3;
4 var URL_DELIMITER = '\n';
4
5
5 $('input[name=image]').wrap($('<div class="file_wrap"></div>'));
6 $('input[name=image]').wrap($('<div class="file_wrap"></div>'));
6
7
@@ -143,15 +144,24 b' function selectFileChoice() {'
143 $fileSourceButton.hide();
144 $fileSourceButton.hide();
144 }
145 }
145
146
146 $('#id_file_url').autocomplete({
147 // Stickers autocomplete
148 function split( val ) {
149 return val.split(URL_DELIMITER);
150 }
151
152 function extractLast( term ) {
153 return split(term).pop();
154 }
155
156 $('#id_file_1').autocomplete({
147 source: function( request, response ) {
157 source: function( request, response ) {
148 $.getJSON(URL_STICKERS, {
158 $.getJSON(URL_STICKERS, {
149 term: request.term
159 term: extractLast( request.term )
150 }, response);
160 }, response);
151 },
161 },
152 search: function() {
162 search: function() {
153 // custom minLength
163 // custom minLength
154 var term = this.value;
164 var term = extractLast( this.value );
155 if (term.length < MIN_INPUT_LENGTH) {
165 if (term.length < MIN_INPUT_LENGTH) {
156 return false;
166 return false;
157 }
167 }
@@ -161,7 +171,14 b' function selectFileChoice() {'
161 return false;
171 return false;
162 },
172 },
163 select: function( event, ui ) {
173 select: function( event, ui ) {
164 this.value = ui.item.alias;
174 var terms = split( this.value );
175 // remove the current input
176 terms.pop();
177 // add the selected item
178 terms.push( ui.item.alias );
179 // add placeholder to get the comma-and-space at the end
180 terms.push("");
181 this.value = terms.join(URL_DELIMITER);
165 return false;
182 return false;
166 }
183 }
167 })
184 })
General Comments 0
You need to be logged in to leave comments. Login now