[OSD] make it not possible to overflow the bounds of the preview window when positioning elements

10.3.x-maintenance
nathan 2016-08-12 22:09:07 -07:00
parent 32c3f40abb
commit 6c85978220
1 changed files with 6 additions and 1 deletions

View File

@ -379,10 +379,15 @@ OSD.GUI.preview = {
onDrop: function(e) {
var ev = e.originalEvent;
var position = $(this).removeAttr('style').data('position');
var field_id = parseInt(ev.dataTransfer.getData('text').split('field-')[1])
var display_item = OSD.data.display_items[field_id];
var overflows_line = FONT.constants.SIZES.LINE - ((position % FONT.constants.SIZES.LINE) + display_item.preview.length);
if (overflows_line < 0) {
position += overflows_line;
}
if (position > OSD.data.display_size.total/2) {
position = position - OSD.data.display_size.total;
}
var field_id = parseInt(ev.dataTransfer.getData('text').split('field-')[1])
$('input.'+field_id+'.position').val(position).change();
},
};