Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var oGMap;
- var oMarkerAnimation;
- var sGoogleAPIKey = "AIzaSyBSbNQ90Aqf96RBysWjw0nwUuu-q6R5pwU";
- var icSel;
- var markSel;
- var aGMMarkers = [];
- var aValObj = [];
- (function($) {
- $.fn.shake = function(options) {
- var settings = {
- 'shakes': 2,
- 'distance': 10,
- 'duration': 400
- };
- if (options) {
- $.extend(settings, options);
- }
- var pos;
- return this.each(function() {
- $this = $(this);
- pos = $this.css('position');
- if (!pos || pos === 'static') {
- $this.css('position', 'relative');
- }
- for (var x = 1; x <= settings.shakes; x++) {
- $this.animate({left: settings.distance * -1}, (settings.duration / settings.shakes) / 4)
- .animate({left: settings.distance}, (settings.duration / settings.shakes) / 2)
- .animate({left: 0}, (settings.duration / settings.shakes) / 4);
- }
- });
- };
- }(jQuery));
- function initializeMap() {
- oGCCenter = new google.maps.LatLng(aGMCenter.lat, aGMCenter.lng);
- var myOptions = {
- zoom: iGMZoom,
- center: oGCCenter,
- mapTypeId: google.maps.MapTypeId.ROADMAP
- };
- oMarkerAnimation = google.maps.Animation.DROP;
- oGMap = new google.maps.Map(document.getElementById('map_container'), myOptions);
- addMapPoints();
- }
- function addMapPoints() {
- for (var i = 0; i < dbData.length; i++) {
- var myLatLng = new google.maps.LatLng(dbData[i].lat, dbData[i].lng);
- var pointMark = new google.maps.Marker({
- position: myLatLng,
- map: oGMap,
- animation: oMarkerAnimation,
- icon: "http://labs.google.com/ridefinder/images/mm_20_white.png",
- url: dbData[i].v
- });
- aGMMarkers.push(pointMark);
- google.maps.event.addListener(pointMark, 'click', function() {
- if (icSel) {
- markSel.setIcon(icSel);
- }
- markSel = this;
- icSel = markSel.icon;
- this.setAnimation(oMarkerAnimation);
- this.setIcon("http://maps.google.com/mapfiles/marker_black.png");
- var refv = this.url;
- $("select.carrierplaces option").filter(function() {
- return $(this).attr('ref') === refv;
- }).attr('selected', true);
- });
- }
- }
- function loadGoogleScript() {
- var script = document.createElement("script");
- script.type = "text/javascript";
- script.src = "//maps.googleapis.com/maps/api/js?key=" + sGoogleAPIKey + "&sensor=false&callback=initializeMap";
- document.body.appendChild(script);
- }
- $(function() {
- $('input[name="id_carrier"]').change(function() {
- var _this = this;
- $('.carrier_places').each(function() {
- if ($(this).attr("id") === ($(_this).attr("value") + '_places') && $(_this).is(':checked')) {
- $(this).show('slow');
- loadGoogleScript();
- $('input#addressesAreEquals').parent().hide();
- $('fieldset#address_delivery').hide();
- $('fieldset#address_invoice').show('fast');
- } else if (typeof oGMap !== 'undefined'){
- $(this).hide('fast');
- $('input#addressesAreEquals').parent().show();
- $('fieldset#address_delivery').show();
- if ($('input#addressesAreEquals').is(':checked')) {
- $('fieldset#address_invoice').hide('fast');
- }
- }
- });
- });
- $('input[name="id_carrier"]').trigger('change');
- $('select.carrierplaces').change(function() {
- var i = $('select.carrierplaces option:selected').attr('tag');
- google.maps.event.trigger(aGMMarkers[i], 'click');
- });
- $('form#account-creation_form').bind('submit', function() {
- var ret = true;
- $('p.required').find('input, select, textarea').each(function() {
- if ($(this).parent().parent('div').parent('fieldset').css('display') === 'block') {
- if ($(this).val() === '') {
- aValObj.push($(this));
- ret = false;
- } else {
- $(this).css('background-color', '');
- }
- }
- });
- if (!ret) {
- alert('Prašome suvesti privalomus duomenis.');
- for (var i = 0; i < aValObj.length; i++) {
- aValObj[i].css('background-color', 'red');
- aValObj[i].shake();
- }
- aValObj = [];
- }
- return ret;
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment