Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare code for jQuery 3.x #1144

Merged
merged 10 commits into from
Mar 24, 2021
26 changes: 13 additions & 13 deletions resource/js/docready.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$(function() { // DOCUMENT READY

var spinner = '<div class="loading-spinner"><span class="spinner-text">'+ loading_text + '</span><span class="spinner" /></div>';
var spinner = '<div class="loading-spinner"><span class="spinner-text">'+ loading_text + '</span><span class="spinner"></span></div>';
var searchString = ''; // stores the search field's value before autocomplete selection changes it
var selectedVocabs = [];
var vocabId;
Expand All @@ -14,7 +14,7 @@ $(function() { // DOCUMENT READY
shortenProperties();

// kills the autocomplete after a form submit so we won't have to wait for the ajax to complete.
$('.navbar-form').submit(
$('.navbar-form').on('submit',
function() {
$('#search-field').typeahead('destroy');
$.ajaxQ.abortAll();
Expand Down Expand Up @@ -198,8 +198,8 @@ $(function() { // DOCUMENT READY
// ajaxing the concept count and the preflabel counts on the vocabulary front page
if ($('#vocab-info').length && $('#statistics').length) {
// adding the spinners
$('#counts tr:nth-of-type(1)').after('<tr><td><span class="spinner" /></td></td></tr>');
$('#statistics tr:nth-of-type(1)').after('<tr><td><span class="spinner" /></td></td></tr>');
$('#counts tr:nth-of-type(1)').after('<tr><td><span class="spinner"></span></td></td></tr>');
$('#statistics tr:nth-of-type(1)').after('<tr><td><span class="spinner"></span></td></td></tr>');
$.ajax({
url : rest_base_url + vocab + '/vocabularyStatistics',
req_kind: $.ajaxQ.requestKind.GLOBAL,
Expand Down Expand Up @@ -501,7 +501,7 @@ $(function() { // DOCUMENT READY

// Event handlers for the language selection links for setting the cookie
$('#language a').each( function(index, el) {
$(el).click(function() {
$(el).on('click', function() {
var langCode = el.id.substr(el.id.indexOf("-") + 1);
setLangCookie(langCode);
});
Expand Down Expand Up @@ -579,15 +579,15 @@ $(function() { // DOCUMENT READY
createCookie('SKOSMOS_SEARCH_LANG', qlang, 365);
}

$('.lang-button').click(function() {
$('.lang-button').on('click', function() {
qlang = $(this)[0].attributes.hreflang ? $(this)[0].attributes.hreflang.value : 'anything';
$('#lang-dropdown-toggle').html($(this).html() + ' <span class="caret"></span>');
$('#lang-input').val(qlang);
createCookie('SKOSMOS_SEARCH_LANG', qlang, 365);
if (concepts) { concepts.clear(); }
});

$('.lang-button, .lang-button-all').click(function() {
$('.lang-button, .lang-button-all').on('click', function() {
$('#search-field').focus();
});

Expand All @@ -597,7 +597,7 @@ $(function() { // DOCUMENT READY
}

// disables the button with an empty search form
$('#search-field').keyup(function() {
$('#search-field').on('keyup', function() {
var empty = false;
$('#search-field').each(function() {
if ($(this).val().length === 0) { empty = true; }
Expand Down Expand Up @@ -779,7 +779,7 @@ $(function() { // DOCUMENT READY
source: concepts.ttAdapter()
}).on('typeahead:cursorchanged', function() {
$('.tt-dropdown-menu').mCustomScrollbar("scrollTo", '.tt-cursor');
}).on('typeahead:selected', onSelection).bind('focus', function() {
}).on('typeahead:selected', onSelection).on('focus', function() {
$('#search-field').typeahead('open');
}).after(clearButton).on('keypress', function() {
if ($typeahead.val().length > 0 && $(this).hasClass('clear-search-dark') === false) {
Expand Down Expand Up @@ -811,7 +811,7 @@ $(function() { // DOCUMENT READY
});

// Some form validation for the feedback form
$("#send-feedback").click(function() {
$('#send-feedback').on('click', function() {
$('#message').removeClass('missing-value');
$('#msgsubject').removeClass('missing-value');
var emailMessageVal = $("#message").val();
Expand All @@ -829,7 +829,7 @@ $(function() { // DOCUMENT READY
});

// Initializes the waypoints plug-in used for the search listings.
var $loading = $("<p>" + loading_text + "&hellip;<span class='spinner'/></p>");
var $loading = $("<p>" + loading_text + "&hellip;<span class='spinner'></span></p>");
var $trigger = $('.search-result:nth-last-of-type(6)');
var options = { offset : '100%', continuous: false, triggerOnce: true };
var alpha_complete = false;
Expand Down Expand Up @@ -1060,7 +1060,7 @@ $(function() { // DOCUMENT READY
if ($('#alpha').hasClass('active') && $('#vocab-info').length === 1 && $('.alphabetical-search-results').length === 0) {
// taking into account the possibility that the lang parameter has been changed by the WebController.
var urlLangCorrected = vocab + '/' + lang + '/index?limit=250&offset=0&clang=' + clang;
$('.sidebar-grey').empty().append('<div class="loading-spinner"><span class="spinner-text">'+ loading_text + '</span><span class="spinner" /></div>');
$('.sidebar-grey').empty().append('<div class="loading-spinner"><span class="spinner-text">'+ loading_text + '</span><span class="spinner"></span></div>');
$.ajax({
url : urlLangCorrected,
req_kind: $.ajaxQ.requestKind.SIDEBAR,
Expand Down Expand Up @@ -1114,7 +1114,7 @@ $(function() { // DOCUMENT READY
source: concepts.ttAdapter()
}).on('typeahead:cursorchanged', function() {
$('.tt-dropdown-menu').mCustomScrollbar("scrollTo", '.tt-cursor');
}).on('typeahead:selected', onSelection).bind('focus', function() {
}).on('typeahead:selected', onSelection).on('focus', function() {
$('#search-field').typeahead('open');
});
}
Expand Down
2 changes: 1 addition & 1 deletion resource/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function setLangCookie(lang) {
}

function clearResultsAndAddSpinner() {
var $loading = $("<div class='search-result'><p>" + loading_text + "&hellip;<span class='spinner'/></p></div>");
var $loading = $("<div class='search-result'><p>" + loading_text + "&hellip;<span class='spinner'></span></p></div>");
$('.search-result-listing').empty().append($loading);
}

Expand Down
42 changes: 21 additions & 21 deletions view/scripts.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script type="text/javascript">
<script>
<!-- translations needed in javascript -->
var noResultsTranslation = "{% trans %}No results{% endtrans %}";
var loading_text = "{% trans %}Loading more items{% endtrans %}";
Expand Down Expand Up @@ -45,24 +45,24 @@ var pluginParameters = {{ plugin_params|raw }};
{{ search_results|first.dumpJsonLd|raw }}
</script>
{% endif %}
<script type="text/javascript" src="vendor/components/jquery/jquery.min.js"></script>
<script type="text/javascript" src="vendor/components/jqueryui/jquery-ui.min.js"></script>
<script type="text/javascript" src="vendor/components/handlebars.js/handlebars.min.js"></script>
<script type="text/javascript" src="vendor/vakata/jstree/dist/jstree.min.js"></script>
<script type="text/javascript" src="vendor/twitter/typeahead.js/dist/typeahead.bundle.min.js"></script>
<script type="text/javascript" src="vendor/medialize/uri.js/src/URI.min.js"></script>
<script type="text/javascript" src="vendor/davidstutz/bootstrap-multiselect/dist/js/bootstrap-multiselect.js"></script>
<script type="text/javascript" src="vendor/twitter/bootstrap/dist/js/bootstrap.js"></script>
<script type="text/javascript" src="vendor/grimmlink/qtip2/dist/jquery.qtip.min.js"></script>
<script type="text/javascript" src="vendor/etdsolutions/waypoints/jquery.waypoints.min.js"></script>
<script type="text/javascript" src="vendor/newerton/jquery-mousewheel/jquery.mousewheel.min.js"></script>
<script type="text/javascript" src="vendor/pamelafox/lscache/lscache.min.js"></script>
<script type="text/javascript" src="vendor/malihu/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js"></script>
<script type="text/javascript" src="resource/js/config.js"></script>
<script type="text/javascript" src="resource/js/hierarchy.js"></script>
<script type="text/javascript" src="resource/js/groups.js"></script>
<script type="text/javascript" src="resource/js/scripts.js"></script>
{% for files in request.plugins.pluginsJS %}{% for file in files %}<script type="text/javascript" src="{{ file }}"></script>{% endfor %}{% endfor %}
{% if request.plugins.callbacks %}<script type="text/javascript">var pluginCallbacks = [{% for function in request.plugins.callbacks %}{% if not loop.first %}, {% endif %}"{{ function }}"{% endfor %}];</script>{% endif %}
<script type="text/javascript" src="resource/js/docready.js"></script>
<script src="vendor/components/jquery/jquery.min.js"></script>
<script src="vendor/components/jqueryui/jquery-ui.min.js"></script>
<script src="vendor/components/handlebars.js/handlebars.min.js"></script>
<script src="vendor/vakata/jstree/dist/jstree.min.js"></script>
<script src="vendor/twitter/typeahead.js/dist/typeahead.bundle.min.js"></script>
<script src="vendor/medialize/uri.js/src/URI.min.js"></script>
<script src="vendor/davidstutz/bootstrap-multiselect/dist/js/bootstrap-multiselect.js"></script>
<script src="vendor/twitter/bootstrap/dist/js/bootstrap.js"></script>
<script src="vendor/grimmlink/qtip2/dist/jquery.qtip.min.js"></script>
<script src="vendor/etdsolutions/waypoints/jquery.waypoints.min.js"></script>
<script src="vendor/newerton/jquery-mousewheel/jquery.mousewheel.min.js"></script>
<script src="vendor/pamelafox/lscache/lscache.min.js"></script>
<script src="vendor/malihu/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js"></script>
<script src="resource/js/config.js"></script>
<script src="resource/js/hierarchy.js"></script>
<script src="resource/js/groups.js"></script>
<script src="resource/js/scripts.js"></script>
{% for files in request.plugins.pluginsJS %}{% for file in files %}<script src="{{ file }}"></script>{% endfor %}{% endfor %}
{% if request.plugins.callbacks %}<script>var pluginCallbacks = [{% for function in request.plugins.callbacks %}{% if not loop.first %}, {% endif %}"{{ function }}"{% endfor %}];</script>{% endif %}
<script src="resource/js/docready.js"></script>