-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[qa] Updated CSS/JS formatting to prettier
- Loading branch information
1 parent
cacc9aa
commit 8f37833
Showing
7 changed files
with
721 additions
and
697 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
.floorplan-raw{ display: none } | ||
.floorplan-widget{ | ||
width: 100%; | ||
height: 500px; | ||
padding: 0; | ||
margin: 0; | ||
background: #FFF; | ||
} | ||
.floorplan-image img{ | ||
width:50%; | ||
} | ||
p.change-image{ | ||
margin-left: 170px; | ||
.floorplan-raw { | ||
display: none; | ||
} | ||
.floorplan-widget { | ||
width: 100%; | ||
height: 500px; | ||
padding: 0; | ||
margin: 0; | ||
background: #fff; | ||
} | ||
.floorplan-image img { | ||
width: 50%; | ||
} | ||
p.change-image { | ||
margin-left: 170px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,63 @@ | ||
.coords, .coords .form-row{ display: none } | ||
.coords, | ||
.coords .form-row { | ||
display: none; | ||
} | ||
.coords .field-location_selection, | ||
.coords .field-floorplan_selection{ display: block } | ||
.coords .field-floorplan_selection { | ||
display: block; | ||
} | ||
/* hide redundant heading in objectlocationinline */ | ||
.loci.coords > h2{ display: none } | ||
.loci.coords > h2 { | ||
display: none; | ||
} | ||
/* improve raw_id_field look */ | ||
.coords .field-location input[type=text]{ display: none } | ||
.field-location .related-lookup{ | ||
width: auto; | ||
padding-left: 20px; | ||
background-position: left center; | ||
} | ||
.field-location .item-label{ | ||
display: inline-block; | ||
height: 16px; | ||
font-weight: bold; | ||
margin-left: 6px; | ||
} | ||
#floorplan_form .field-location .item-label{ vertical-align: middle } | ||
.coords .field-location input[type="text"] { | ||
display: none; | ||
} | ||
.field-location .related-lookup { | ||
width: auto; | ||
padding-left: 20px; | ||
background-position: left center; | ||
} | ||
.field-location .item-label { | ||
display: inline-block; | ||
height: 16px; | ||
font-weight: bold; | ||
margin-left: 6px; | ||
} | ||
#floorplan_form .field-location .item-label { | ||
vertical-align: middle; | ||
} | ||
.coords .field-location .item-label, | ||
.field-location strong{ | ||
position: relative; | ||
bottom: -3px; | ||
.field-location strong { | ||
position: relative; | ||
bottom: -3px; | ||
} | ||
.field-location strong { | ||
margin-left: 3px; | ||
} | ||
input[type="text"] { | ||
width: 320px; | ||
} | ||
.field-location strong{ margin-left: 3px } | ||
input[type=text]{ width: 320px } | ||
/* simulate required fields */ | ||
.coords.loci label{ | ||
font-weight: bold; | ||
color: #333; | ||
.coords.loci label { | ||
font-weight: bold; | ||
color: #333; | ||
} | ||
.no-location{ | ||
padding: 10px 0 10px 0; | ||
font-weight: bold; | ||
text-align: center; | ||
font-size: 14px; | ||
.no-location { | ||
padding: 10px 0 10px 0; | ||
font-weight: bold; | ||
text-align: center; | ||
font-size: 14px; | ||
} | ||
.form-row.field-geometry .flex-container { | ||
display: block; | ||
display: block; | ||
} | ||
#floorplan_set-group { | ||
display: none; | ||
} | ||
#floorplan_set-group{ display: none } | ||
@media (max-width: 767px){ | ||
.field-geometry > div{ | ||
flex-direction: column; | ||
} | ||
@media (max-width: 767px) { | ||
.field-geometry > div { | ||
flex-direction: column; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
django.jQuery(function ($) { | ||
'use strict'; | ||
var $type_field = $('#id_type'), | ||
$floorplan_set = $('#floorplan_set-group'), | ||
$floorplans_length = $floorplan_set.find('.inline-related.has_original').length, | ||
type_change_event = function (e) { | ||
var value = $type_field.val(); | ||
if (value === 'indoor') { | ||
$floorplan_set.show(); | ||
} else if (value === 'outdoor' && $floorplans_length === 0) { | ||
$floorplan_set.hide(); | ||
} else if (value === 'outdoor' && $floorplans_length > 0) { | ||
var msg = 'Please remove the associated floorplans first ' + | ||
'and save; then you can switch to type "indoor"'; | ||
alert(gettext(msg)); | ||
e.preventDefault(); | ||
$type_field.val('indoor'); | ||
} | ||
}; | ||
$type_field.change(type_change_event); | ||
type_change_event(); | ||
"use strict"; | ||
var $type_field = $("#id_type"), | ||
$floorplan_set = $("#floorplan_set-group"), | ||
$floorplans_length = $floorplan_set.find( | ||
".inline-related.has_original", | ||
).length, | ||
type_change_event = function (e) { | ||
var value = $type_field.val(); | ||
if (value === "indoor") { | ||
$floorplan_set.show(); | ||
} else if (value === "outdoor" && $floorplans_length === 0) { | ||
$floorplan_set.hide(); | ||
} else if (value === "outdoor" && $floorplans_length > 0) { | ||
var msg = | ||
"Please remove the associated floorplans first " + | ||
'and save; then you can switch to type "indoor"'; | ||
alert(gettext(msg)); | ||
e.preventDefault(); | ||
$type_field.val("indoor"); | ||
} | ||
}; | ||
$type_field.change(type_change_event); | ||
type_change_event(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,71 @@ | ||
(function () { | ||
'use strict'; | ||
django.loadFloorPlan = function (widgetName, imageUrl, imageW, imageH) { | ||
var $input = django.jQuery('#id_' + widgetName), | ||
$parent = $input.parents('fieldset').eq(0), | ||
url = imageUrl || $parent.find('a.floorplan-image').attr('href'), | ||
$dim = $parent.find('#id_' + widgetName.replace('indoor', 'image') + '-dim'), | ||
$indoorPosition = $parent.find('.field-indoor'), | ||
mapId = 'id_' + widgetName + '_map', | ||
w = imageW || $dim.data('width'), | ||
h = imageH || $dim.data('height'), | ||
coordinates, | ||
map; | ||
"use strict"; | ||
django.loadFloorPlan = function (widgetName, imageUrl, imageW, imageH) { | ||
var $input = django.jQuery("#id_" + widgetName), | ||
$parent = $input.parents("fieldset").eq(0), | ||
url = imageUrl || $parent.find("a.floorplan-image").attr("href"), | ||
$dim = $parent.find( | ||
"#id_" + widgetName.replace("indoor", "image") + "-dim", | ||
), | ||
$indoorPosition = $parent.find(".field-indoor"), | ||
mapId = "id_" + widgetName + "_map", | ||
w = imageW || $dim.data("width"), | ||
h = imageH || $dim.data("height"), | ||
coordinates, | ||
map; | ||
|
||
if (!url) { return; } | ||
$indoorPosition.show(); | ||
if (!url) { | ||
return; | ||
} | ||
$indoorPosition.show(); | ||
|
||
map = L.map(mapId, { | ||
crs: L.CRS.Simple, | ||
minZoom: -1, | ||
maxZoom: 2 | ||
}); | ||
map = L.map(mapId, { | ||
crs: L.CRS.Simple, | ||
minZoom: -1, | ||
maxZoom: 2, | ||
}); | ||
|
||
// calculate the edges of the image, in coordinate space | ||
var bottomRight = map.unproject([0, h * 2], map.getMaxZoom() - 1), | ||
upperLeft = map.unproject([w * 2, 0], map.getMaxZoom() - 1), | ||
bounds = new L.LatLngBounds(bottomRight, upperLeft); | ||
L.imageOverlay(url, bounds).addTo(map); | ||
map.fitBounds(bounds); | ||
map.setMaxBounds(bounds); | ||
map.setView([0, 0], 0); | ||
// calculate the edges of the image, in coordinate space | ||
var bottomRight = map.unproject([0, h * 2], map.getMaxZoom() - 1), | ||
upperLeft = map.unproject([w * 2, 0], map.getMaxZoom() - 1), | ||
bounds = new L.LatLngBounds(bottomRight, upperLeft); | ||
L.imageOverlay(url, bounds).addTo(map); | ||
map.fitBounds(bounds); | ||
map.setMaxBounds(bounds); | ||
map.setView([0, 0], 0); | ||
|
||
function updateInput(e) { | ||
var latlng = e.latlng || e.target._latlng; | ||
$input.val(latlng.lat + ',' + latlng.lng); | ||
} | ||
function updateInput(e) { | ||
var latlng = e.latlng || e.target._latlng; | ||
$input.val(latlng.lat + "," + latlng.lng); | ||
} | ||
|
||
if ($input.val()) { | ||
var latlng = $input.val().split(','); | ||
coordinates = {lat: latlng[0], lng: latlng[1]}; | ||
} else { | ||
coordinates = undefined; | ||
} | ||
if ($input.val()) { | ||
var latlng = $input.val().split(","); | ||
coordinates = { lat: latlng[0], lng: latlng[1] }; | ||
} else { | ||
coordinates = undefined; | ||
} | ||
|
||
var marker = new L.marker(coordinates, {draggable: true}); | ||
marker.bindPopup(gettext('Drag to reposition')); | ||
marker.on('dragend', updateInput); | ||
if (coordinates) { marker.addTo(map); } | ||
var marker = new L.marker(coordinates, { draggable: true }); | ||
marker.bindPopup(gettext("Drag to reposition")); | ||
marker.on("dragend", updateInput); | ||
if (coordinates) { | ||
marker.addTo(map); | ||
} | ||
|
||
map.on('click', function (e) { | ||
if (marker.getLatLng() === undefined) { | ||
marker.setLatLng(e.latlng); | ||
marker.addTo(map); | ||
updateInput(e); | ||
} | ||
}); | ||
map.on("click", function (e) { | ||
if (marker.getLatLng() === undefined) { | ||
marker.setLatLng(e.latlng); | ||
marker.addTo(map); | ||
updateInput(e); | ||
} | ||
}); | ||
|
||
// clear indoor coordinates if map is removed | ||
map.on('unload', function () { | ||
$input.val(''); | ||
}); | ||
// clear indoor coordinates if map is removed | ||
map.on("unload", function () { | ||
$input.val(""); | ||
}); | ||
|
||
return map; | ||
}; | ||
}()); | ||
return map; | ||
}; | ||
})(); |
Oops, something went wrong.