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.

143 lines
3.7 KiB

7 years ago
var Teasers = {
8 years ago
init: false,
init: function() {
if (this.initialized) return;
this.initialized = true;
this.Analoque_items();
},
Analoque_items: function() {
this.Analoque_sortable();
this.Analoque_del_item();
this.Analoque_add();
this.Analoque_search();
},
Analoque_update: function() {
this.Analoque_maxid();
this.Analoque_del_item();
this.Analoque_search();
AveAdmin.tooltip();
},
/**
* @return {number}
*/
Analoque_maxid: function(id)
{
var maxid = 1;
$('#analoque_lists_' + id).children('.analoque_list').each(function() {
maxid = Math.max(maxid, parseInt($(this).attr("data-id")) + 1);
});
return maxid;
},
Analoque_del_item: function()
{
$('.analoque_list .DelButton').on('click', function(event) {
event.preventDefault();
var id = $(this).attr('data-id');
jConfirm(
analoque_del_conf,
analoque_del_head,
function(b) {
if (b) {
$('#analoque_list_' + id).remove();
}
}
);
});
},
Analoque_add: function()
{
$('.AddButton').on('click', function() {
c_id = $(this).parent().parent('.analoque_lists').attr("data-id");
d_id = $(this).parent().parent('.analoque_lists').attr("data-docid");
7 years ago
i_id = Teasers.Analoque_maxid(d_id + '_' + c_id);
8 years ago
$('#analoque_lists_' + d_id + '_' + c_id + ':last').append(
'<div class="analoque_list fix mb10" id="analoque_list_' + d_id + '_' + c_id + '_' + i_id + '" data-id="' + i_id + '">' +
'<input class="mousetrap search_analoque" name="feld[' + c_id + '][' + i_id + '][param]" type="text" value="" placeholder="' + analoque_param + '" data-docid="' + d_id + '" data-fieldid="' + c_id + '" data-id="' + i_id + '" style="width: 450px;"/>&nbsp;&nbsp;Id:&nbsp;<input type="text" class="mousetrap field_' + d_id + '_' + c_id + '_' + i_id + '" value="" name="feld[' + c_id + '][' + i_id + '][value]" placeholder="' + analoque_value + '" style="width: 50px;" readonly />&nbsp;&nbsp;<a href="javascript:void(0);" data-id="' + d_id + '_' + c_id + '_' + i_id + '" class="button redBtn topDir DelButton" title="' + analoque_del + '">&times;</a>' +
'<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
Teasers.Analoque_update();
8 years ago
});
},
Analoque_sortable: function() {
$('.analoque_lists').sortable({
handle: ".handle",
placeholder: "ui-state-highlight grey_bg"
});
},
/**
* @return {boolean}
*/
Analoque_search: function() {
7 years ago
var res_search = false;
8 years ago
$('.search_analoque').on('input', function(event)
{
event.preventDefault();
var query = $(this);
var did = query.attr('data-docid');
var fid = query.attr('data-fieldid');
var kid = query.attr('data-id');
var field_id_input = $('.field_' + did + '_' + fid + '_' + kid);
7 years ago
if (res_search)
return false;
res_search = true;
query.autocomplete("index.php?do=fields&field=teasers&type=search&doc_id=" + did + "&field_id=" + fid, {
8 years ago
width: query.outerWidth(),
7 years ago
max: 5,
8 years ago
dataType: "json",
matchContains: "word",
scroll: true,
scrollHeight: 200,
parse: function(data) {
7 years ago
res_search = false;
if (typeof data === 'object')
{
return $.map(data, function(row) {
return {
data: row,
value: row.doc_title,
result: query.val()
}
});
}
return false;
8 years ago
},
formatItem: function(item) {
7 years ago
return '<div style="padding: 3px 0;"><span style="font-weight: 700;">' + item.doc_article + '</span> ' + item.doc_name + '</div>';
8 years ago
}
}).result(function(e, item) {
7 years ago
query.val(item.doc_name);
field_id_input.val(item.doc_id);
8 years ago
});
return false;
});
return false;
}
}
7 years ago
$(document).ready(function() {
Teasers.init();
8 years ago
});