Spade
Mini Shell
| Directory:~$ /home/lmsyaran/public_html/joomla4/ |
| [Home] [System Details] [Kill Me] |
home/lmsyaran/public_html/media/com_easyblog/scripts_/location.js000064400000031604151155730070021352
0ustar00EasyBlog.module("location", function($) {
var module = this;
// require: start
EasyBlog.require()
.library(
"throttle-debounce",
"ui/autocomplete"
)
.done(function(){
// controller: start
EasyBlog.Controller(
"Location.Form",
{
defaultOptions: {
language: 'en',
initialLocation: null,
mapType : "ROADMAP",
"{locationInput}": ".locationInput",
"{locationLatitude}": ".locationLatitude",
"{locationLongitude}": ".locationLongitude",
"{locationMap}": ".locationMap",
"{autoDetectButton}": ".autoDetectButton"
}
},
function(self) { return {
init: function() {
var mapReady = $.uid("ext");
window[mapReady] = function() {
$.___GoogleMaps.resolve();
}
if (!$.___GoogleMaps) {
$.___GoogleMaps = $.Deferred();
EasyBlog.require()
.script(
{prefetch: false},
"https://maps.googleapis.com/maps/api/js?sensor=true&language="
+ self.options.language + "&callback=" + mapReady
);
}
// Defer instantiation of controller until Google Maps library is
loaded.
$.___GoogleMaps.done(function() {
self._init();
});
},
_init: function(el, event) {
self.geocoder = new google.maps.Geocoder();
self.hasGeolocation = navigator.geolocation!==undefined;
if (!self.hasGeolocation) {
self.autoDetectButton().remove();
} else {
self.autoDetectButton().show();
}
self.locationInput()
.autocomplete({
delay: 300,
minLength: 0,
source: self.retrieveSuggestions,
select: function(event, ui) {
self.locationInput()
.autocomplete("close");
self.setLocation(ui.item.location);
}
})
.prop("disabled", false);
self.autocomplete =
self.locationInput().autocomplete("widget");
self.autocomplete
.addClass("location-suggestion");
var initialLocation = $.trim(self.options.initialLocation);
if (initialLocation) {
self.getLocationByAddress(
initialLocation,
function(location) {
self.setLocation(location[0]);
}
);
};
self.busy(false);
},
busy: function(isBusy) {
self.locationInput().toggleClass("loading", isBusy);
},
getUserLocations: function(callback) {
self.getLocationAutomatically(
function(locations) {
self.userLocations = self.buildDataset(locations);
callback && callback(locations);
}
);
},
getLocationByAddress: function(address, callback) {
self.geocoder.geocode(
{
address: address
},
callback);
},
getLocationByCoords: function(latitude, longitude, callback) {
self.geocoder.geocode(
{
location: new google.maps.LatLng(latitude, longitude)
},
callback);
},
getLocationAutomatically: function(success, fail) {
if (!navigator.geolocation) {
return fail("ERRCODE", "Browser does not support
geolocation or do not have permission to retrieve location data.")
}
navigator.geolocation.getCurrentPosition(
// Success
function(position) {
self.getLocationByCoords(position.coords.latitude,
position.coords.longitude, success)
},
// Fail
fail
);
},
renderMap: function(location, tooltipContent) {
self.busy(true);
self.locationMap().show();
var map = new google.maps.Map(
self.locationMap()[0],
{
zoom: 15,
center: location.geometry.location,
mapTypeId: google.maps.MapTypeId[self.options.mapType],
disableDefaultUI: true
}
);
var marker = new google.maps.Marker(
{
position: location.geometry.location,
center : location.geometry.location,
title : location.formatted_address,
map : map
}
);
var infoWindow = new google.maps.InfoWindow({ content: tooltipContent
});
google.maps.event.addListener(map, "tilesloaded", function() {
infoWindow.open(map, marker);
self.busy(false);
});
},
setLocation: function(location) {
if (!location) return;
self.locationResolved = true;
self.lastResolvedLocation = location;
self.locationInput()
.val(location.formatted_address);
self.locationLatitude()
.val(location.geometry.location.lat());
self.locationLongitude()
.val(location.geometry.location.lng());
self.renderMap(location, location.formatted_address);
},
removeLocation: function() {
self.locationResolved = false;
self.locationInput()
.val('');
self.locationLatitude()
.val('');
self.locationLongitude()
.val('');
self.locationMap().hide();
},
buildDataset: function(locations) {
var dataset = $.map(locations, function(location){
return {
label: location.formatted_address,
value: location.formatted_address,
location: location
};
});
return dataset;
},
retrieveSuggestions: function(request, response) {
self.busy(true);
var address = request.term,
respondWith = function(locations) {
response(locations);
self.busy(false);
};
// User location
if (address=="") {
respondWith(self.userLocations || []);
// Keyword search
} else {
self.getLocationByAddress(address, function(locations) {
respondWith(self.buildDataset(locations));
});
}
},
suggestUserLocations: function() {
if (self.hasGeolocation && self.userLocations) {
self.removeLocation();
self.locationInput()
.autocomplete("search", "");
}
self.busy(false);
},
"{locationInput} blur": function() {
// Give way to autocomplete
setTimeout(function(){
var address = $.trim(self.locationInput().val());
// Location removal
if (address=="") {
self.removeLocation();
// Unresolved location, reset to last resolved location
} else if (self.locationResolved) {
if (address != self.lastResolvedLocation.formatted_address) {
self.setLocation(self.lastResolvedLocation);
}
} else {
self.removeLocation();
}
}, 250);
},
"{autoDetectButton} click": function() {
self.busy(true);
if (self.hasGeolocation && !self.userLocations) {
self.getUserLocations(self.suggestUserLocations);
} else {
self.suggestUserLocations();
}
}
}}
);
EasyBlog.Controller(
"Location.Map",
{
defaultOptions: {
animation: 'drop',
language: 'en',
useStaticMap: false,
disableMapsUI: true,
// fitBounds = true will disobey zoom
// single location with fitBounds = true will set zoom to max (by
default from Google)
// locations.length == 1 will set fitBounds = false unless explicitly
specified
// locations.length > 1 will set fitBounds = true unless explicitly
specified
zoom: 5,
fitBounds: null,
minZoom: null,
maxZoom: null,
// location in center has to be included in locations array
// center will default to first object in locations
// latitude and longitude always have precedence over address
// {
// "latitude": latitude,
// "longitude": longitude,
// "address": address
// }
center: null,
// address & title are optional
// latitude and longitude always have precedence over address
// title will default to geocoded address
// first object will open info window
// [
// {
// "latitude": latitude,
// "longitude": longitude,
// "address": address,
// "title": title
// }
// ]
locations: [],
// Default map type to be road map. Can be overriden.
mapType: "ROADMAP",
width: 500,
height: 400,
"{locationMap}": ".locationMap"
}
},
function(self) { return {
init: function() {
self.mapLoaded = false;
var mapReady = $.uid("ext");
window[mapReady] = function() {
$.___GoogleMaps.resolve();
}
if(self.options.useStaticMap == true) {
var language = '&language=' +
String(self.options.language);
var dimension = '&size=' + String(self.options.width) +
'x' + String(self.options.height);
var zoom = '&zoom=' + String(self.options.zoom);
var center = '¢er=' +
String(parseFloat(self.options.locations[0].latitude).toFixed(6)) +
',' +
String(parseFloat(self.options.locations[0].longitude).toFixed(6));
var maptype = '&maptype=' + google.maps.MapTypeId[
self.options.mapType ];
var markers = '&markers=';
var url =
'https://maps.googleapis.com/maps/api/staticmap?sensor=false' +
language + dimension;
if(self.options.locations.length == 1) {
markers +=
String(parseFloat(self.options.locations[0].latitude).toFixed(6)) +
',' +
String(parseFloat(self.options.locations[0].longitude).toFixed(6));
url += zoom + center + maptype + markers;
} else {
var temp = new Array();
$.each(self.options.locations, function(i, location) {
temp.push(String(parseFloat(location.latitude).toFixed(6)) +
',' + String(parseFloat(location.longitude).toFixed(6)));
})
markers += temp.join('|');
url += markers + maptype;
}
self.locationMap().show().html('<img src="' + url +
'" />');
self.busy(false);
} else {
var mapReady = $.uid("ext");
window[mapReady] = function() {
$.___GoogleMaps.resolve();
}
if (!$.___GoogleMaps) {
$.___GoogleMaps = $.Deferred();
EasyBlog.require()
.script(
{prefetch: false},
"https://maps.googleapis.com/maps/api/js?sensor=true&language="
+ self.options.language + "&callback=" + mapReady
);
}
// Defer instantiation of controller until Google Maps library is
loaded.
$.___GoogleMaps.done(function() {
self._init();
});
}
},
_init: function() {
// initialise fitBounds according to locations.length
if(self.options.fitBounds === null) {
if(self.options.locations.length == 1) {
self.options.fitBounds = false;
} else {
self.options.fitBounds = true;
}
}
// initialise disableMapsUI value to boolean
self.options.disableMapsUI = Boolean(self.options.disableMapsUI);
// initialise all location object
self.locations = new Array();
$.each(self.options.locations, function(i, location) {
if( location.latitude != 'null' &&
location.longitude != 'null' ) {
self.locations.push(new google.maps.LatLng(location.latitude,
location.longitude));
}
});
if(self.locations.length > 0) {
self.renderMap();
}
self.busy(false);
},
busy: function(isBusy) {
self.locationMap().toggleClass("loading", isBusy);
},
renderMap: function() {
self.busy(true);
self.locationMap().show();
var latlng;
if(self.options.center) {
latlng = new google.maps.LatLng(center.latitude, center.longitude);
} else {
latlng = self.locations[0];
}
self.map = new google.maps.Map(
self.locationMap()[0],
{
zoom: parseInt( self.options.zoom ),
minZoom: parseInt( self.options.minZoom ),
maxZoom: parseInt( self.options.maxZoom ),
center: latlng,
mapTypeId: google.maps.MapTypeId[ self.options.mapType ],
disableDefaultUI: self.options.disableMapsUI
}
);
google.maps.event.addListener(self.map, "tilesloaded",
function() {
if(self.mapLoaded == false) {
self.mapLoaded = true;
self.loadLocations();
}
});
},
loadLocations: function() {
self.bounds = new google.maps.LatLngBounds();
self.infoWindow = new Array();
var addLocations = function() {
$.each(self.locations, function(i, location) {
self.bounds.extend(location);
var placeMarker = function() {
self.addMarker(location, self.options.locations[i]);
}
setTimeout(placeMarker, 100 * ( i + 1 ) );
});
if(self.options.fitBounds) {
self.map.fitBounds(self.bounds);
}
};
setTimeout(addLocations, 500);
},
addMarker: function(location, info) {
if (!location) return;
var marker = new google.maps.Marker(
{
position: location,
map: self.map
}
);
marker.setAnimation(google.maps.Animation.DROP);
self.addInfoWindow(marker, info)
},
addInfoWindow: function(marker, info) {
var content = info.content;
if(!content) {
content = info.address;
}
var infoWindow = new google.maps.InfoWindow();
infoWindow.setContent(content);
self.infoWindow.push(infoWindow);
if(self.options.locations.length > 1) {
google.maps.event.addListener(marker, 'click', function() {
$.each(self.infoWindow, function(i, item) {
item.close();
});
infoWindow.open(self.map, marker);
});
} else {
google.maps.event.addListener(marker, 'click', function() {
infoWindow.open(self.map, marker);
});
infoWindow.open(self.map, marker);
}
// custom hack for postmap module
if(info.ratingid) {
google.maps.event.addListener(infoWindow, 'domready',
function() {
$.each(info.ratingid, function(i, rid) {
eblog.ratings.setup( 'ebpostmap_' + rid +
'-ratings' , true , 'entry' );
$('#ebpostmap_' + rid +
'-ratings').removeClass('ui-state-disabled');
$('#ebpostmap_' + rid +
'-ratings-form').find('.blog-rating-text').hide();
$('#ebpostmap_' + rid + '-ratings
.ratings-value').hide();
})
});
}
}
}}
);
module.resolve();
// controller: end
});
// require: end
});
home/lmsyaran/public_html/media/com_easyblog/scripts/location.js000064400000016357151155735230021226
0ustar00EasyBlog.module("location",function(e){var
t=this;EasyBlog.require().library("throttle-debounce","ui/autocomplete").done(function(){EasyBlog.Controller("Location.Form",{defaultOptions:{language:"en",initialLocation:null,mapType:"ROADMAP","{locationInput}":".locationInput","{locationLatitude}":".locationLatitude","{locationLongitude}":".locationLongitude","{locationMap}":".locationMap","{autoDetectButton}":".autoDetectButton"}},function(t){return{init:function(){var
n=e.uid("ext");window[n]=function(){e.___GoogleMaps.resolve()},e.___GoogleMaps||(e.___GoogleMaps=e.Deferred(),EasyBlog.require().script({prefetch:!1},"https://maps.googleapis.com/maps/api/js?sensor=true&language="+t.options.language+"&callback="+n)),e.___GoogleMaps.done(function(){t._init()})},_init:function(n,r){t.geocoder=new
google.maps.Geocoder,t.hasGeolocation=navigator.geolocation!==undefined,t.hasGeolocation?t.autoDetectButton().show():t.autoDetectButton().remove(),t.locationInput().autocomplete({delay:300,minLength:0,source:t.retrieveSuggestions,select:function(e,n){t.locationInput().autocomplete("close"),t.setLocation(n.item.location)}}).prop("disabled",!1),t.autocomplete=t.locationInput().autocomplete("widget"),t.autocomplete.addClass("location-suggestion");var
i=e.trim(t.options.initialLocation);i&&t.getLocationByAddress(i,function(e){t.setLocation(e[0])}),t.busy(!1)},busy:function(e){t.locationInput().toggleClass("loading",e)},getUserLocations:function(e){t.getLocationAutomatically(function(n){t.userLocations=t.buildDataset(n),e&&e(n)})},getLocationByAddress:function(e,n){t.geocoder.geocode({address:e},n)},getLocationByCoords:function(e,n,r){t.geocoder.geocode({location:new
google.maps.LatLng(e,n)},r)},getLocationAutomatically:function(e,n){if(!navigator.geolocation)return
n("ERRCODE","Browser does not support geolocation or do not
have permission to retrieve location
data.");navigator.geolocation.getCurrentPosition(function(n){t.getLocationByCoords(n.coords.latitude,n.coords.longitude,e)},n)},renderMap:function(e,n){t.busy(!0),t.locationMap().show();var
r=new
google.maps.Map(t.locationMap()[0],{zoom:15,center:e.geometry.location,mapTypeId:google.maps.MapTypeId[t.options.mapType],disableDefaultUI:!0}),i=new
google.maps.Marker({position:e.geometry.location,center:e.geometry.location,title:e.formatted_address,map:r}),s=new
google.maps.InfoWindow({content:n});google.maps.event.addListener(r,"tilesloaded",function(){s.open(r,i),t.busy(!1)})},setLocation:function(e){if(!e)return;t.locationResolved=!0,t.lastResolvedLocation=e,t.locationInput().val(e.formatted_address),t.locationLatitude().val(e.geometry.location.lat()),t.locationLongitude().val(e.geometry.location.lng()),t.renderMap(e,e.formatted_address)},removeLocation:function(){t.locationResolved=!1,t.locationInput().val(""),t.locationLatitude().val(""),t.locationLongitude().val(""),t.locationMap().hide()},buildDataset:function(t){var
n=e.map(t,function(e){return{label:e.formatted_address,value:e.formatted_address,location:e}});return
n},retrieveSuggestions:function(e,n){t.busy(!0);var
r=e.term,i=function(e){n(e),t.busy(!1)};r==""?i(t.userLocations||[]):t.getLocationByAddress(r,function(e){i(t.buildDataset(e))})},suggestUserLocations:function(){t.hasGeolocation&&t.userLocations&&(t.removeLocation(),t.locationInput().autocomplete("search","")),t.busy(!1)},"{locationInput}
blur":function(){setTimeout(function(){var
n=e.trim(t.locationInput().val());n==""?t.removeLocation():t.locationResolved?n!=t.lastResolvedLocation.formatted_address&&t.setLocation(t.lastResolvedLocation):t.removeLocation()},250)},"{autoDetectButton}
click":function(){t.busy(!0),t.hasGeolocation&&!t.userLocations?t.getUserLocations(t.suggestUserLocations):t.suggestUserLocations()}}}),EasyBlog.Controller("Location.Map",{defaultOptions:{animation:"drop",language:"en",useStaticMap:!1,disableMapsUI:!0,zoom:5,fitBounds:null,minZoom:null,maxZoom:null,center:null,locations:[],mapType:"ROADMAP",width:500,height:400,"{locationMap}":".locationMap"}},function(t){return{init:function(){t.mapLoaded=!1;var
n=e.uid("ext");window[n]=function(){e.___GoogleMaps.resolve()};if(t.options.useStaticMap==1){var
r="&language="+(t.options.language+""),i="&size="+(t.options.width+"")+"x"+(t.options.height+""),s="&zoom="+(t.options.zoom+""),o="¢er="+(parseFloat(t.options.locations[0].latitude).toFixed(6)+"")+","+(parseFloat(t.options.locations[0].longitude).toFixed(6)+""),u="&maptype="+google.maps.MapTypeId[t.options.mapType],a="&markers=",f="https://maps.googleapis.com/maps/api/staticmap?sensor=false"+r+i;if(t.options.locations.length==1)a+=parseFloat(t.options.locations[0].latitude).toFixed(6)+""+","+(parseFloat(t.options.locations[0].longitude).toFixed(6)+""),f+=s+o+u+a;else{var
l=[];e.each(t.options.locations,function(e,t){l.push(parseFloat(t.latitude).toFixed(6)+""+","+(parseFloat(t.longitude).toFixed(6)+""))}),a+=l.join("|"),f+=a+u}t.locationMap().show().html('<img
src="'+f+'" />'),t.busy(!1)}else{var
n=e.uid("ext");window[n]=function(){e.___GoogleMaps.resolve()},e.___GoogleMaps||(e.___GoogleMaps=e.Deferred(),EasyBlog.require().script({prefetch:!1},"https://maps.googleapis.com/maps/api/js?sensor=true&language="+t.options.language+"&callback="+n)),e.___GoogleMaps.done(function(){t._init()})}},_init:function(){t.options.fitBounds===null&&(t.options.locations.length==1?t.options.fitBounds=!1:t.options.fitBounds=!0),t.options.disableMapsUI=Boolean(t.options.disableMapsUI),t.locations=[],e.each(t.options.locations,function(e,n){n.latitude!="null"&&n.longitude!="null"&&t.locations.push(new
google.maps.LatLng(n.latitude,n.longitude))}),t.locations.length>0&&t.renderMap(),t.busy(!1)},busy:function(e){t.locationMap().toggleClass("loading",e)},renderMap:function(){t.busy(!0),t.locationMap().show();var
e;t.options.center?e=new
google.maps.LatLng(center.latitude,center.longitude):e=t.locations[0],t.map=new
google.maps.Map(t.locationMap()[0],{zoom:parseInt(t.options.zoom),minZoom:parseInt(t.options.minZoom),maxZoom:parseInt(t.options.maxZoom),center:e,mapTypeId:google.maps.MapTypeId[t.options.mapType],disableDefaultUI:t.options.disableMapsUI}),google.maps.event.addListener(t.map,"tilesloaded",function(){t.mapLoaded==0&&(t.mapLoaded=!0,t.loadLocations())})},loadLocations:function(){t.bounds=new
google.maps.LatLngBounds,t.infoWindow=[];var
n=function(){e.each(t.locations,function(e,n){t.bounds.extend(n);var
r=function(){t.addMarker(n,t.options.locations[e])};setTimeout(r,100*(e+1))}),t.options.fitBounds&&t.map.fitBounds(t.bounds)};setTimeout(n,500)},addMarker:function(e,n){if(!e)return;var
r=new
google.maps.Marker({position:e,map:t.map});r.setAnimation(google.maps.Animation.DROP),t.addInfoWindow(r,n)},addInfoWindow:function(n,r){var
i=r.content;i||(i=r.address);var s=new
google.maps.InfoWindow;s.setContent(i),t.infoWindow.push(s),t.options.locations.length>1?google.maps.event.addListener(n,"click",function(){e.each(t.infoWindow,function(e,t){t.close()}),s.open(t.map,n)}):(google.maps.event.addListener(n,"click",function(){s.open(t.map,n)}),s.open(t.map,n)),r.ratingid&&google.maps.event.addListener(s,"domready",function(){e.each(r.ratingid,function(t,n){eblog.ratings.setup("ebpostmap_"+n+"-ratings",!0,"entry"),e("#ebpostmap_"+n+"-ratings").removeClass("ui-state-disabled"),e("#ebpostmap_"+n+"-ratings-form").find(".blog-rating-text").hide(),e("#ebpostmap_"+n+"-ratings
.ratings-value").hide()})})}}}),t.resolve()})});