Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.deleteBoxAction = function(ev, args) {
ev.preventDefault();
// Get box ID from event.target element
var id = args.id || this._getIDFromTarget(ev.target);
// Get box jQuery element by id
var $box = this._getBoxElement(id);
// get the box settings
var box = this.attr.storage.get(id);
var isNew = (_.isUndefined(box.dummy)) ? false : true;
this.attr.storage.destroy(id);
// Destroy it from DOM
$box.remove();
if (!isNew) {
this.trigger(document, 'personal.boxes.data.delete', {
id: id,
});
}
this.trigger(document, 'personal.wrapper.check.button.limits');
};
this.update = function(ev, args) {
var that = this;
that.trigger(document, 'personal.wrapper.loader.show');
var id = args.id;
var box = that.attr.boxStorage.get(id);
var isNew = _.isUndefined(box.dummy) ? false : true;
var data = args.data;
box._settings = data;
that.attr.boxStorage.save(box);
var sendingData = {}
if (!isNew) {
sendingData.index = id - 1;
sendingData.data = that._prepareSettings();
} else {
delete box.dummy;
that.attr.boxStorage.save(box);
sendingData.data = that._prepareSettings();
}
console.log('Sendingdata', sendingData);
$.when(
that._request({
url: that.attr.api.boxes,
this._addBoxSkeleton = function(args) {
var isNew = _.isUndefined(args);
var box = !isNew ? args : this._getDefaultBox();
var html = wrapperTemplate(box, {
nav: navTemplate.template,
header: headerTemplate.template,
footer: footerTemplate.template,
});
if (isNew) {
this.attr.storage.save(box)
}
this.$node.append(html);
return box.id;
};
var boxes = this.attr.boxStorage.find(function(box){
return (_.isUndefined(box.dummy) || !box.dummy) && box._settings.title;
});
var settings = _.pluck(boxes, '_settings');