une commande de coupe de cheveux
This commit is contained in:
88
Yavsc/wwwroot/js/google-geoloc.js
Normal file
88
Yavsc/wwwroot/js/google-geoloc.js
Normal file
@ -0,0 +1,88 @@
|
||||
+(function($,maps){
|
||||
$.widget("psc.googlegeocode" , {
|
||||
options: {
|
||||
mapId: 'map',
|
||||
longId: 'Longitude',
|
||||
latId: 'Latitude',
|
||||
addrValidationId: 'AddressError',
|
||||
formValidId: 'ValidationSummary',
|
||||
locComboId: 'LocationCombo'
|
||||
},
|
||||
marker: null,
|
||||
gmap: null,
|
||||
|
||||
_create: function() {
|
||||
this.element.addClass("googlegeocode");
|
||||
this.gmap = new maps.Map(document.getElementById(this.options.mapId), {
|
||||
zoom: 16,
|
||||
center: { lat: 48.862854, lng: 2.2056466 }
|
||||
});
|
||||
var _this =this;
|
||||
this.element.rules("add",
|
||||
{
|
||||
remote: {
|
||||
url: 'https://maps.googleapis.com/maps/api/geocode/json',
|
||||
type: 'get',
|
||||
data: {
|
||||
sensor: false,
|
||||
address: function () { return _this.element.val() }
|
||||
},
|
||||
dataType: 'json',
|
||||
dataFilter: function(datastr) {
|
||||
$('#'+_this.options.locComboId).html("");
|
||||
var data = JSON.parse(datastr);
|
||||
data.results.forEach(function(item) {
|
||||
if (item.formatted_address !== _this.element.val()) {
|
||||
$('<li>'+item.formatted_address+'</li>')
|
||||
.data("geoloc",item)
|
||||
.click(function() { _this.chooseLoc('user',item) })
|
||||
.css('cursor','pointer')
|
||||
.appendTo($('#'+_this.options.locComboId));}
|
||||
else { }
|
||||
});
|
||||
if ((data.status === 'OK') && (data.results.length == 1))
|
||||
{
|
||||
// _this.chooseLoc('google',data.results[0]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
error: function()
|
||||
{
|
||||
// xhr, textStatus, errorThrown console.log('ajax loading error ... '+textStatus+' ... '+ errorThrown);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
})},
|
||||
chooseLoc: function(sender,loc) {
|
||||
if (sender === 'user') this.element.val(loc.formatted_address);
|
||||
var pos = loc.geometry.location;
|
||||
var lat = new Number(pos.lat);
|
||||
var lng = new Number(pos.lng);
|
||||
$(document.getElementById(this.options.latId)).val(lat.toLocaleString('en'));
|
||||
$(document.getElementById(this.options.longId)).val(lng.toLocaleString('en'));
|
||||
this.gmap.setCenter(pos);
|
||||
if (this.marker) {
|
||||
this.marker.setMap(null);
|
||||
}
|
||||
this.marker = new maps.Marker({
|
||||
map: this.gmap,
|
||||
draggable: true,
|
||||
animation: maps.Animation.DROP,
|
||||
position: pos
|
||||
});
|
||||
maps.event.addListener(this.marker, 'dragend', function() {
|
||||
// TODO reverse geo code
|
||||
var pos = this.marker.getPosition();
|
||||
$('#'+this.options.latId).val(pos.lat);
|
||||
$('#'+this.options.longId).val(pos.lng);
|
||||
});
|
||||
this.element.valid();
|
||||
$('#'+this.options.addrValidationId).empty();
|
||||
$('#'+this.options.formValidId).empty();
|
||||
$('#'+this.options.locComboId).empty();
|
||||
|
||||
return this;
|
||||
}
|
||||
})
|
||||
})(jQuery,google.maps)
|
97
Yavsc/wwwroot/js/parallax.js
Normal file
97
Yavsc/wwwroot/js/parallax.js
Normal file
@ -0,0 +1,97 @@
|
||||
//
|
||||
// parralax.js
|
||||
//
|
||||
// Author:
|
||||
// Paul Schneider <paul@pschneider.fr>
|
||||
//
|
||||
// Copyright (c) 2015 GNU GPL
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
$(document).ready(function($){
|
||||
var $window = $(window);
|
||||
var $stwidth = $(window).width();
|
||||
var $stheight = $(window).height();
|
||||
|
||||
var onPos = function (bgobj,ax,ay) {
|
||||
var speed = bgobj.data('speed');
|
||||
var dx=($window.scrollLeft()+ax-$stwidth/2)/speed;
|
||||
var dy=($window.scrollTop()+ay-$stheight/2)/speed;
|
||||
var xPos = bgobj.attr('orgbgpx') - Math.round( dx );
|
||||
var yPos = bgobj.attr('orgbgpy') - Math.round( dy );
|
||||
// Put together our final background position
|
||||
var coords = '' + xPos + bgobj.attr('orgbgpxu') + yPos + bgobj.attr('orgbgpyu');
|
||||
// Move the background
|
||||
bgobj.css({ backgroundPosition: coords });
|
||||
};
|
||||
var tiltLR=0;
|
||||
var titleFB=0;
|
||||
|
||||
$('[data-type="background"]').each(function(){
|
||||
var $bgobj = $(this); // assigning the object
|
||||
// get the initial background position, assumes a "X% Yem" ?
|
||||
var orgpos = $bgobj.css('backgroundPosition');
|
||||
var bgpos = orgpos.split(" ");
|
||||
|
||||
var bgposx = bgpos[0];
|
||||
var bgposy = bgpos[1];
|
||||
if (/%$/.test(bgposx)){
|
||||
bgposx = bgposx.substr(0,bgposx.length-1);
|
||||
$bgobj.attr('orgbgpxu','% ');
|
||||
}
|
||||
else if (/em$/.test(bgposx)){
|
||||
bgposx = bgposx.substr(0,bgposx.length-2);
|
||||
$bgobj.attr('orgbgpxu','em ');
|
||||
}
|
||||
else if (/px$/.test(bgposx)){
|
||||
bgposx = bgposx.substr(0,bgposx.length-2);
|
||||
$bgobj.attr('orgbgpxu','px ');
|
||||
}
|
||||
else { $bgobj.attr('orgbgpxu','px '); }
|
||||
|
||||
if (/%$/.test(bgposy)){
|
||||
bgposy = bgposy.substr(0,bgposy.length-1);
|
||||
$bgobj.attr('orgbgpyu','% ');
|
||||
}
|
||||
else if (/em$/.test(bgposy)){
|
||||
bgposy = bgposy.substr(0,bgposy.length-2);
|
||||
$bgobj.attr('orgbgpyu','em ');
|
||||
}
|
||||
else if (/px$/.test(bgposy)){
|
||||
bgposy = bgposy.substr(0,bgposy.length-2);
|
||||
$bgobj.attr('orgbgpyu','px ');
|
||||
}
|
||||
else { $bgobj.attr('orgbgpyu','px '); }
|
||||
$bgobj.attr('orgbgpx',parseInt(bgposx));
|
||||
$bgobj.attr('orgbgpy',parseInt(bgposy));
|
||||
|
||||
$(window).scroll(function() {
|
||||
onPos($bgobj,tiltLR,titleFB);
|
||||
});
|
||||
if (window.DeviceOrientationEvent) {
|
||||
if ($stwidth>320 && $stheight>320) {
|
||||
window.addEventListener('deviceorientation', function(event) {
|
||||
tiltLR = $stwidth*Math.sin(event.gamma*Math.PI/180);
|
||||
titleFB = $stheight*Math.sin(event.beta*Math.PI/90);
|
||||
onPos($bgobj,tiltLR,titleFB);
|
||||
},false); }
|
||||
$(window).mousemove(function(e) {
|
||||
tiltLR = e.pageX;
|
||||
titleFB = e.pageY;
|
||||
onPos($bgobj,e.pageX,e.pageY);
|
||||
});
|
||||
}
|
||||
});
|
||||
}(jQuery));
|
Reference in New Issue
Block a user