diff options
author | prashantsinalkar | 2019-08-27 12:29:12 +0530 |
---|---|---|
committer | prashantsinalkar | 2019-08-27 12:29:12 +0530 |
commit | b9c709823e26f5b20d3732e1788b871cdd961a03 (patch) | |
tree | a9089f56541854b48ddbda733832a153c6d53927 /static/website/js/custom.js | |
parent | 50e8fc0832d81d124abd7606b15502545bf84b23 (diff) | |
download | SciPy2019-b9c709823e26f5b20d3732e1788b871cdd961a03.tar.gz SciPy2019-b9c709823e26f5b20d3732e1788b871cdd961a03.tar.bz2 SciPy2019-b9c709823e26f5b20d3732e1788b871cdd961a03.zip |
added intial code for project
Diffstat (limited to 'static/website/js/custom.js')
-rw-r--r-- | static/website/js/custom.js | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/static/website/js/custom.js b/static/website/js/custom.js new file mode 100644 index 0000000..4b0ab0a --- /dev/null +++ b/static/website/js/custom.js @@ -0,0 +1,107 @@ +let modalId = $('#image-gallery'); + +$(document) + .ready(function () { + + loadGallery(true, 'a.thumbnail'); + + //This function disables buttons when needed + function disableButtons(counter_max, counter_current) { + $('#show-previous-image, #show-next-image') + .show(); + if (counter_max === counter_current) { + $('#show-next-image') + .hide(); + } else if (counter_current === 1) { + $('#show-previous-image') + .hide(); + } + } + + /** + * + * @param setIDs Sets IDs when DOM is loaded. If using a PHP counter, set to false. + * @param setClickAttr Sets the attribute for the click handler. + */ + + function loadGallery(setIDs, setClickAttr) { + let current_image, + selector, + counter = 0; + + $('#show-next-image, #show-previous-image') + .click(function () { + if ($(this) + .attr('id') === 'show-previous-image') { + current_image--; + } else { + current_image++; + } + + selector = $('[data-image-id="' + current_image + '"]'); + updateGallery(selector); + }); + + function updateGallery(selector) { + let $sel = selector; + current_image = $sel.data('image-id'); + $('#image-gallery-title') + .text($sel.data('title')); + $('#image-gallery-image') + .attr('src', $sel.data('image')); + disableButtons(counter, $sel.data('image-id')); + } + + if (setIDs == true) { + $('[data-image-id]') + .each(function () { + counter++; + $(this) + .attr('data-image-id', counter); + }); + } + $(setClickAttr) + .on('click', function () { + updateGallery($(this)); + }); + } + }); + +// build key actions +$(document) + .keydown(function (e) { + switch (e.which) { + case 37: // left + if ((modalId.data('bs.modal') || {})._isShown && $('#show-previous-image').is(":visible")) { + $('#show-previous-image') + .click(); + } + break; + + case 39: // right + if ((modalId.data('bs.modal') || {})._isShown && $('#show-next-image').is(":visible")) { + $('#show-next-image') + .click(); + } + break; + + default: + return; // exit this handler for other keys + } + e.preventDefault(); // prevent the default action (scroll / move caret) + }); + + +$(function() +{ + $('#id_terms_and_conditions').click(function() + { + if ($('#id_terms_and_conditions').is(":checked")) { + $('#modal_terms_and_conditions').modal('show'); + }else { + $('#modal_terms_and_conditions').modal('hide'); + } + }); +}); + + |