mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Merge pull request #3276 from hennevogel/bugfix/word-count-js
Move word counting javascript to the page
This commit is contained in:
commit
9fd0807a9a
3 changed files with 26 additions and 24 deletions
|
|
@ -45,6 +45,7 @@ linters:
|
||||||
- "app/views/layouts/_admin_sidebar.html.haml"
|
- "app/views/layouts/_admin_sidebar.html.haml"
|
||||||
- "app/views/proposals/index.html.haml"
|
- "app/views/proposals/index.html.haml"
|
||||||
- "app/views/proposals/show.html.haml"
|
- "app/views/proposals/show.html.haml"
|
||||||
|
- "app/views/proposals/_form.html.haml"
|
||||||
|
|
||||||
# Offense count: 28
|
# Offense count: 28
|
||||||
IdNames:
|
IdNames:
|
||||||
|
|
|
||||||
|
|
@ -142,29 +142,6 @@ function word_count(text, divId, maxcount) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Wait for the DOM to be ready before attaching events to the elements */
|
|
||||||
$( document ).ready(function() {
|
|
||||||
/* Set the minimum and maximum proposal abstract word length */
|
|
||||||
function updateEventTypeRequirements() {
|
|
||||||
var $selected = $("#event_event_type_id option:selected")
|
|
||||||
var max = $selected.data("max-words");
|
|
||||||
var min = $selected.data("min-words");
|
|
||||||
|
|
||||||
$("#abstract-maximum-word-count").text(max);
|
|
||||||
$("#abstract-minimum-word-count").text(min);
|
|
||||||
word_count($('#event_abstract').get(0), 'abstract-count', max);
|
|
||||||
}
|
|
||||||
$("#event_event_type_id").change(updateEventTypeRequirements);
|
|
||||||
updateEventTypeRequirements();
|
|
||||||
|
|
||||||
/* Count the proposal abstract length */
|
|
||||||
$("#event_abstract").on('input', function() {
|
|
||||||
var $selected = $("#event_event_type_id option:selected")
|
|
||||||
var max = $selected.data("max-words");
|
|
||||||
word_count(this, 'abstract-count', max);
|
|
||||||
} );
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Commodity function for modal windows */
|
/* Commodity function for modal windows */
|
||||||
|
|
||||||
window.build_dialog = function(selector, content) {
|
window.build_dialog = function(selector, content) {
|
||||||
|
|
|
||||||
|
|
@ -90,3 +90,27 @@
|
||||||
- submit_copy = action_is_edit ? 'Update Proposal' : 'Create Proposal'
|
- submit_copy = action_is_edit ? 'Update Proposal' : 'Create Proposal'
|
||||||
= f.submit submit_copy, class: 'btn btn-success'
|
= f.submit submit_copy, class: 'btn btn-success'
|
||||||
|
|
||||||
|
- content_for :script_head do
|
||||||
|
:javascript
|
||||||
|
/* Wait for the DOM to be ready before attaching events to the elements */
|
||||||
|
$( document ).ready(function() {
|
||||||
|
/* Set the minimum and maximum proposal abstract word length */
|
||||||
|
function updateEventTypeRequirements() {
|
||||||
|
var $selected = $("#event_event_type_id option:selected")
|
||||||
|
var max = $selected.data("max-words");
|
||||||
|
var min = $selected.data("min-words");
|
||||||
|
|
||||||
|
$("#abstract-maximum-word-count").text(max);
|
||||||
|
$("#abstract-minimum-word-count").text(min);
|
||||||
|
word_count($('#event_abstract').get(0), 'abstract-count', max);
|
||||||
|
}
|
||||||
|
$("#event_event_type_id").change(updateEventTypeRequirements);
|
||||||
|
updateEventTypeRequirements();
|
||||||
|
|
||||||
|
/* Count the proposal abstract length */
|
||||||
|
$("#event_abstract").on('input', function() {
|
||||||
|
var $selected = $("#event_event_type_id option:selected")
|
||||||
|
var max = $selected.data("max-words");
|
||||||
|
word_count(this, 'abstract-count', max);
|
||||||
|
} );
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue