this.linkeditor.save.hasChanged();
},
- updateLinkData: function (id, data) {
- if (LINKS[id] === undefined) {
- console.warn('Link ' + id + ' not found');
- return;
- }
- $.each(data, function (k, v) {
- LINKS[id][k] = v;
- });
- this.linkeditor.rulers.updateMagnetValues();
- this.updateLayers();
- },
startDragLink: function () {
this.dragLinkPos = {x: this.linkeditor.mx, y: this.linkeditor.my};
$(this).attr('fb-' + d.side, center - parseFloat($(this).attr('fb-' + d.length)) / 2);
});
}
+ this.updateSelectionData([d.side]);
this.linkeditor.hasChanged();
},
+
+ updateLinkData: function (id, data) {
+ if (LINKS[id] === undefined) {
+ console.warn('Link ' + id + ' not found');
+ return;
+ }
+ $.each(data, function (k, v) {
+ LINKS[id][k] = v;
+ });
+ this.linkeditor.rulers.updateMagnetValues();
+ this.updateLayers();
+ },
+
+ updateSelectionData: function (props) {
+ this.getCurrentSelection().each(function () {
+ let uid = $(this).attr('fb-uid');
+ for (let i = 0; i < props.length; i++) {
+ let prop = props[i];
+ LINKS[uid][prop] = $(this).attr('fb-' + prop);
+ }
+ });
+ this.linkeditor.rulers.updateMagnetValues();
+ this.updateLayers();
+ },
+
distributeSelection: function (axis) {
let d = this.getMinMaxSelection(axis);
let totalLength = d.max - d.min;
$(link.link).attr('fb-' + d.side, s);
s += link.length + space;
});
+ this.updateSelectionData([d.side]);
this.linkeditor.hasChanged();
},
let links = JSON.parse(state);
this.clear();
var $this = this;
+ var existingUIDs = [];
+ // Update existing and add new links
$.each(links, function (k, link) {
$this.addLink(link, false);
LINKS[link.uid] = link;
+ existingUIDs.push(link.uid);
});
+ // Search for missing links and delete them
+ var pages = this.linkeditor.getCurrentPages();
+ var currentPages = [];
+ $.each(pages, function (k, v) {
+ currentPages.push(v.toString());
+ })
+ $.each(LINKS, function (uid, link) {
+ if (currentPages.indexOf(link.page) >= 0) {
+ if (existingUIDs.indexOf(link.uid) === -1) {
+ delete LINKS[uid];
+ }
+ }
+ });
+
this.linkeditor.hasChanged(false);
},
};