s'assurer de l'existence de jQuery
This commit is contained in:
parent
e3055eaeb8
commit
ee218a6cbb
1 changed files with 88 additions and 85 deletions
|
|
@ -1,4 +1,9 @@
|
||||||
+(function($,maps){
|
if (typeof jQuery === 'undefined') {
|
||||||
|
throw new Error('Bootstrap\'s JavaScript requires jQuery')
|
||||||
|
}
|
||||||
|
|
||||||
|
+
|
||||||
|
(function($, maps) {
|
||||||
$.widget("psc.googlegeocode", {
|
$.widget("psc.googlegeocode", {
|
||||||
options: {
|
options: {
|
||||||
mapId: 'map',
|
mapId: 'map',
|
||||||
|
|
@ -18,8 +23,7 @@ $.widget("psc.googlegeocode" , {
|
||||||
center: { lat: 48.862854, lng: 2.2056466 }
|
center: { lat: 48.862854, lng: 2.2056466 }
|
||||||
});
|
});
|
||||||
var _this = this;
|
var _this = this;
|
||||||
this.element.rules("add",
|
this.element.rules("add", {
|
||||||
{
|
|
||||||
remote: {
|
remote: {
|
||||||
url: 'https://maps.googleapis.com/maps/api/geocode/json',
|
url: 'https://maps.googleapis.com/maps/api/geocode/json',
|
||||||
type: 'get',
|
type: 'get',
|
||||||
|
|
@ -37,23 +41,22 @@ $.widget("psc.googlegeocode" , {
|
||||||
.data("geoloc", item)
|
.data("geoloc", item)
|
||||||
.click(function() { _this.chooseLoc('user', item) })
|
.click(function() { _this.chooseLoc('user', item) })
|
||||||
.css('cursor', 'pointer')
|
.css('cursor', 'pointer')
|
||||||
.appendTo($('#'+_this.options.locComboId));}
|
.appendTo($('#' + _this.options.locComboId));
|
||||||
else { }
|
} else {}
|
||||||
});
|
});
|
||||||
if ((data.status === 'OK') && (data.results.length == 1))
|
if ((data.status === 'OK') && (data.results.length == 1)) {
|
||||||
{
|
|
||||||
// _this.chooseLoc('google',data.results[0]);
|
// _this.chooseLoc('google',data.results[0]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
error: function()
|
error: function() {
|
||||||
{
|
|
||||||
// xhr, textStatus, errorThrown console.log('ajax loading error ... '+textStatus+' ... '+ errorThrown);
|
// xhr, textStatus, errorThrown console.log('ajax loading error ... '+textStatus+' ... '+ errorThrown);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})},
|
})
|
||||||
|
},
|
||||||
chooseLoc: function(sender, loc) {
|
chooseLoc: function(sender, loc) {
|
||||||
if (sender === 'user') this.element.val(loc.formatted_address);
|
if (sender === 'user') this.element.val(loc.formatted_address);
|
||||||
var pos = loc.geometry.location;
|
var pos = loc.geometry.location;
|
||||||
|
|
@ -85,4 +88,4 @@ $.widget("psc.googlegeocode" , {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})(jQuery,google.maps)
|
})(jQuery, google.maps);
|
||||||
Loading…
Add table
Add a link
Reference in a new issue