| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- $(function() {
- $("#page-jump-button").click(function(event) {
- let urlTemplate = $(this).data("url-template");
- let page = $("#page-jump-input").val();
- let url = urlTemplate.replace("PAGE", page);
- window.location = url;
- });
- $("#sort-dropdown").change(function(event) {
- let urlTemplate = $(this).data("url-template");
- let sort = $(this).val();
- let url = urlTemplate.replace("SORT", sort);
- window.location = url;
- });
- $("input[type=password]").keyup(function(event) {
- let formText = $(this).next(".form-text");
- let lengthSpan = $(formText).find("span[data-length-requirement]");
- let upperSpan = $(formText).find("span[data-uppercase-requirement]");
- let lowerSpan = $(formText).find("span[data-lowercase-requirement]");
- let numberSpan = $(formText).find("span[data-number-requirement]");
- let specialSpan = $(formText).find("span[data-special-requirement]");
- let upper = new RegExp("[A-Z]");
- let lower = new RegExp("[a-z]");
- let number = new RegExp("[0-9]");
- let special = new RegExp("[^A-Za-z0-9]");
- let value = $(this).val();
- let lengthClass = value.length >= 6 ? "text-success" : "text-danger";
- let upperClass = upper.test(value) ? "text-success" : "text-danger";
- let lowerClass = lower.test(value) ? "text-success" : "text-danger";
- let numberClass = number.test(value) ? "text-success" : "text-danger";
- let specialClass = special.test(value) ? "text-success" : "text-danger";
- lengthSpan.attr("class", lengthClass);
- upperSpan.attr("class", upperClass);
- lowerSpan.attr("class", lowerClass);
- numberSpan.attr("class", numberClass);
- specialSpan.attr("class", specialClass);
- });
- var clipboard = new ClipboardJS(".btn[data-clipboard-target]");
- });
- var maps = [];
- function initialiseTooltips() {
- $('[data-toggle="tooltip"]').tooltip();
- }
- function initialiseMaps() {
- $("div[data-maps]").each(function() {
- let position = {
- lat: $(this).data("lat"),
- lng: $(this).data("lng")
- };
- let options = {};
- options.center = position;
- options.zoom = $(this).data("zoom");
- options.gestureHandling = "greedy";
- options.scaleControl = true;
- let map = new google.maps.Map(this, options);
- if(this.id) {
- maps[this.id] = map;
- }
- // Plot marker
- let marker = $(this).data("marker");
- if(marker) {
- let options = {};
- options.position = position;
- options.map = map;
- options.draggable = $(this).data("marker-draggable");
- let marker = new google.maps.Marker(options);
- let markerDragendTarget = $(this).data("marker-dragend-target");
- if(markerDragendTarget) {
- marker.addListener("dragend", function() {
- let position = marker.getPosition();
- $(markerDragendTarget).find("input[data-latitude]").val(position.lat());
- $(markerDragendTarget).find("input[data-longitude]").val(position.lng());
- });
- }
- }
- // Plot basic markers
- let markers = $(this).data("markers");
- if(markers) {
- let bounds = new google.maps.LatLngBounds;
- for(let i in markers) {
- let options = {};
- options.position = {
- "lat": markers[i].latitude * 1,
- "lng": markers[i].longitude * 1
- };
- options.map = map;
- let marker = new google.maps.Marker(options);
- bounds.extend(options.position);
- }
- if(markers.length > 1) {
- maps[this.id].fitBounds(bounds, 32);
- }
- }
- let callback = $(this).data("callback");
- if(callback) {
- try {
- window[callback]();
- }
- catch(err) {
- console.log(err);
- }
- }
- });
- $("input[data-autocomplete]").each(function() {
- let mapId = $(this).data("autocomplete");
- let map = maps[mapId];
- let autocomplete = new google.maps.places.Autocomplete(this);
- autocomplete.bindTo("bounds", map);
- autocomplete.setFields(["address_components", "geometry", "icon", "name"]);
- autocomplete.addListener("place_changed", function() {
- let place = autocomplete.getPlace();
- if(place.geometry.viewport) {
- map.fitBounds(place.geometry.viewport);
- }
- else {
- map.setCenter(place.geometry.location);
- map.setZoom(17);
- }
- });
- });
- }
|