AVE.CMS v3.28
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.2 KiB

7 years ago
var MultiLinks = {
8 years ago
init: false,
init: function() {
if (this.initialized) return;
this.initialized = true;
this.lists();
},
lists: function() {
this.lists_sortable();
this.lists_del_item();
this.lists_add();
},
lists_update: function() {
this.lists_maxid();
this.lists_del_item();
AveAdmin.tooltip();
},
lists_maxid: function(id) {
var maxid = 1;
7 years ago
$('#multi_links_' + id).children('.multi_link').each(function() {
8 years ago
maxid = Math.max(maxid, parseInt($(this).attr("data-id")) + 1);
});
return maxid;
},
lists_del_item: function() {
7 years ago
$('.multi_link .DelButton').on('click', function(event) {
8 years ago
event.preventDefault();
var id = $(this).attr('data-id');
jConfirm(
7 years ago
links_del_conf,
links_del_head,
8 years ago
function(b) {
if (b) {
7 years ago
$('#link_' + id).remove();
8 years ago
}
}
);
});
},
lists_add: function() {
7 years ago
$('.multi_links .AddButton').on('click', function(event) {
8 years ago
event.preventDefault();
7 years ago
c_id = $(this).parent().parent('.multi_links').attr("data-id");
iid = MultiLinks.lists_maxid(c_id);
$('#multi_links_' + c_id + ':last').append(
'<div class="multi_link fix mb10" id="link_' + c_id + '_' + iid + '" data-id="' + iid + '">' +
'<input class="mousetrap" type="text" value="" name="feld[' + c_id + '][' + iid + '][param]" placeholder="' + links_name + '" style="width: 200px;"/>&nbsp;&nbsp;<input type="text" class="mousetrap" value="" name="feld[' + c_id + '][' + iid + '][value]" id="links_' + c_id + '_' + iid + '" placeholder="' + links_url + '" style="width: 300px;" />&nbsp;&nbsp;<a class="btn greyishBtn" onclick="openFileWindow(\'links_' + c_id + '_' + iid + '\',\'links_' + c_id + '_' + iid + '\',\'links_' + c_id + '_' + iid + '\');">PDF</a>&nbsp;&nbsp;<a href="javascript:void(0);" data-id="' + c_id + '_' + iid + '" class="button redBtn topDir DelButton" title="' + links_del + '">&times;</a>' +
8 years ago
'<div class="handle" style="float: left; display: inline-block; margin: 4px 7px; cursor: move;"><span class="icon_sprite ico_move"></span></div>' +
'</div>'
);
7 years ago
MultiLinks.lists_update();
8 years ago
});
},
lists_sortable: function() {
7 years ago
$('.multi_links').sortable({
8 years ago
handle: ".handle",
placeholder: "ui-state-highlight grey_bg"
});
}
}
$(document).ready(function() {
7 years ago
MultiLinks.init();
8 years ago
});