Remove submodule
This commit is contained in:
parent
f969dbb290
commit
89b74e8ef8
50 changed files with 32051 additions and 10 deletions
44
resources/libs/timezone-map/timezone-map.css
Normal file
44
resources/libs/timezone-map/timezone-map.css
Normal file
|
@ -0,0 +1,44 @@
|
|||
.map-inset {
|
||||
padding-bottom: 50%;
|
||||
background-size: cover !important;
|
||||
position: relative;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.map-wrap {
|
||||
padding: 1px;
|
||||
border-radius: 3px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.map-inset span {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
margin: -3px 0 0 -3px;
|
||||
background: #fff;
|
||||
position: absolute;
|
||||
border-radius: 3px;
|
||||
border: 1px solid #4e7cad;
|
||||
}
|
||||
|
||||
.map-inset span.active {
|
||||
background: #4e7cad;
|
||||
}
|
||||
|
||||
.map-inset .map-axis-x {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
border-left: 1px solid rgba(78, 124, 173, 0.5);
|
||||
width: 0;
|
||||
transition: left 100ms ease-out;
|
||||
}
|
||||
|
||||
.map-inset .map-axis-y {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
border-top: 1px solid rgba(78, 124, 173, 0.5);
|
||||
height: 0;
|
||||
transition: top 100ms ease-out;
|
||||
}
|
91
resources/libs/timezone-map/timezone-picker.js
Normal file
91
resources/libs/timezone-map/timezone-picker.js
Normal file
|
@ -0,0 +1,91 @@
|
|||
window.timezone_picker = function ($map, $field, json_data) {
|
||||
var $axisX = $map.find('.map-axis-x'),
|
||||
$axisY = $map.find('.map-axis-y'),
|
||||
width = $map.outerWidth(),
|
||||
height = $map.outerHeight(),
|
||||
lastCenter,
|
||||
centers = [];
|
||||
|
||||
$(window).resize(function () {
|
||||
width = $map.outerWidth();
|
||||
height = $map.outerHeight();
|
||||
}).resize();
|
||||
|
||||
function changeCenter(center) {
|
||||
if (center === lastCenter) {
|
||||
return;
|
||||
}
|
||||
if (lastCenter) {
|
||||
lastCenter.deactivate();
|
||||
}
|
||||
center.activate();
|
||||
lastCenter = center;
|
||||
}
|
||||
|
||||
function Center(data) {
|
||||
this.name = data.name;
|
||||
this.x = (180 + data['long']) / 360;
|
||||
this.y = (90 - data.lat) / 180;
|
||||
this.dom = $('<span>').appendTo($map).css({
|
||||
left: this.x * 100 + '%',
|
||||
top: this.y * 100 + '%'
|
||||
});
|
||||
if (this.name === $field.val())
|
||||
changeCenter(this);
|
||||
}
|
||||
|
||||
Center.prototype = {
|
||||
distSqr: function (x, y) {
|
||||
var dx = this.x - x,
|
||||
dy = this.y - y;
|
||||
return dx * dx + dy * dy;
|
||||
},
|
||||
activate: function () {
|
||||
if ($field.val() != this.name)
|
||||
$field.val(this.name).trigger('change');
|
||||
$axisX.css('left', this.x * 100 + '%');
|
||||
$axisY.css('top', this.y * 100 + '%');
|
||||
},
|
||||
deactivate: function () {
|
||||
this.dom.removeClass('active');
|
||||
}
|
||||
};
|
||||
|
||||
$.getJSON(json_data).then(function (data) {
|
||||
for (var name in data.zones)
|
||||
centers.push(new Center(data.zones[name]));
|
||||
});
|
||||
|
||||
$map.click(function (e) {
|
||||
var offset = $(this).offset(),
|
||||
x = e.pageX - offset.left,
|
||||
y = e.pageY - offset.top,
|
||||
px = x / width,
|
||||
py = y / height,
|
||||
dist,
|
||||
closestDist = 100,
|
||||
closestCenter,
|
||||
i;
|
||||
|
||||
for (i = 0; i < centers.length; i++) {
|
||||
dist = centers[i].distSqr(px, py);
|
||||
if (dist < closestDist) {
|
||||
closestCenter = centers[i];
|
||||
closestDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
if (closestCenter) {
|
||||
changeCenter(closestCenter);
|
||||
}
|
||||
});
|
||||
|
||||
$field.change(function(e) {
|
||||
var tz = $(this).val();
|
||||
for (var i = 0; i < centers.length; i++)
|
||||
if (centers[i].name == tz) {
|
||||
changeCenter(centers[i]);
|
||||
break;
|
||||
}
|
||||
})
|
||||
};
|
1
resources/libs/timezone-map/timezone-picker.json
Normal file
1
resources/libs/timezone-map/timezone-picker.json
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue