Content deleted Content added
Tweaks |
refactor some ifs |
||
(3 intermediate revisions by the same user not shown) | |||
Line 77:
makeDiv(id) {
const div = document.createElement('div');
return div;
},
Line 137:
areas.updateSelection = function () {
this.selection.children().remove();
for (const
const title =
(area.title || area.link || '') +
Line 169:
// Remove element from this array
this.splice(this.currentlyEditing, 1);
this.update();
if (this.currentlyEditing >= 0)
Line 178 ⟶ 177:
function markPoint(point, color) {
if (point) {
ime.context.beginPath();▼
const arm = 8 / ime.scale;
▲ ime.context.beginPath();
ime.context.moveTo(point.x + arm, point.y);
ime.context.lineTo(point.x - arm, point.y);
Line 201 ⟶ 200:
ime.context.canvas.width / ime.scale,
ime.context.canvas.height / ime.scale);
for (const
const current = (ind == this.currentlyEditing);
ime.context.fillStyle =
const coords = area.coords;
ime.context.beginPath();
Line 450 ⟶ 449:
function updateResult() {
const
arr = Array.from(document.ime.imageDescriptionPos
imageDescriptionPos =
(arr.find(elt => elt.checked) || arr[0]).value;
Line 469 ⟶ 468:
const preResult = document.getElementById('imeResult');
while
preResult.removeChild(preResult.lastChild);
Line 481 ⟶ 480:
function updateInputs(fromAreas) {
function updateShape(selectors, coords) {
for (const
$(selector).val(coords && coords[index] || '');
}
Line 515 ⟶ 514:
function attachTemplate() {
{const
clicks = { '.ime_t_rect': () => areas.make('rect'),
'.ime_t_circle': () => areas.make('circle'),
'.ime_t_poly': () => areas.make('poly'),
'.ime_t_deletearea': areas.remove.bind(areas),
'#imeImportShow': ime.imports.show.bind(ime.imports),
'#imeImportHide': ime.imports.hide.bind(ime.imports),
'.ime_t_import': ime.imports.make.bind(ime.imports),
'.ime_t_deletecoordinates': () => {
areas.current().coords = [];
mouse.currentClicks = {};
ime.store();
}
}
'#ime_areaselector': function (e) {▼
for (const {id, click} of Object.entries(clicks))▼
areas.edit($(this).prop('selectedIndex'));▼
},▼
'.ime_saveonchange': ime.store.bind(ime),▼
'.ime-updateresultsonchange': updateResult,▼
'#ime_areaLink': function () {▼
areas.current().link = $(this).val(); updateResult();▼
},▼
'#ime_areaTitle': function () {▼
areas.current().title = $(this).val(); updateResult();▼
}▼
};▼
$(id).click(util.std_handler(click));
▲ '#ime_areaselector': function (e) {
▲ areas.edit($(this).prop('selectedIndex'));
▲ },
▲ '.ime_saveonchange': ime.store.bind(ime),
▲ '.ime-updateresultsonchange': updateResult,
▲ '#ime_areaLink': function () {
▲ areas.current().link = $(this).val(); updateResult();
▲ },
▲ '#ime_areaTitle': function () {
▲ areas.current().title = $(this).val(); updateResult();
▲ }
▲ };
▲ for (const {id, change} of Object.entries(changes))
$(id).change(change);
}
areas.selection = $('#ime_areaselector');
$('.ime-saveonchange').focusout(function () {
|