Revision 634 (by ahitrov, 2016/12/19 18:37:20) |
Tag search
|
<script>
$(function() {
var nActiveTab = getCookie( 'tag_tab_index' ) || 0;
$( "#tag_view_tabs" ).tabs({
active: nActiveTab,
beforeLoad: function( event, ui ) {
ui.jqXHR.fail(function() {
ui.panel.html(
"Couldn't load this tab. We'll try to fix this as soon as possible. " +
"If this wouldn't be a demo." );
});
},
activate: function( event, ui ) {
var nIndex = $(this).tabs( "option", "active" );
setCookie( 'tag_tab_index', nIndex );
}
});
$( "#tag-search" ).autocomplete({
minLength : 2,
source : '/contenido/ajax/document_search.html?class=tag::Tag',
select : function( event, ui )
{
var item = ui.item;
$('#tag-search-id').val( item.id );
$.ajax({
'url' : '/contenido/tag/ajax/find.html',
'data' : { 'id' : item.id },
'dataType' : 'json',
'success' : function( data ) {
if ( data.success ) {
$('#tag-found').html( data.html );
}
}
});
},
change : function( event, ui )
{
var sValue = $(this).val();
if ( sValue == '' ) {
$('#tag-search-id').val('');
$('#tag-found').html('');
}
}
});
$('form[name=tag-search-form]').on('submit', function( ev ){
ev.preventDefault();
var oForm = $(this)[0];
var sValue = oForm.elements['tag_search'].value;
if ( sValue == '' ) {
$('#tag-search-id').val('');
$('#tag-found').html('');
} else {
$.ajax({
'url' : '/contenido/tag/ajax/find.html',
'data' : { 'name' : sValue },
'dataType' : 'json',
'success' : function( data ) {
if ( data.success ) {
$('#tag-found').html( data.html );
}
}
});
}
});
});
</script>
<div id="tag_view_tabs">
<ul>
<li><a href="#tag_view_tabs-search">Поиск</a></li>
<li><a href="/contenido/tag/ajax/tag_view_list.html">Список</a></li>
% if ( $state->{tag}->tag_structure eq 'tree' ) {
<li><a href="/contenido/tag/ajax/tag_view_tree.html">Дерево</a></li>
% }
</ul>
<div id="tag_view_tabs-search">
<form enctype="multipart/form-data" method="POST" name="tag-search-form">
<input type="hidden" name="tag_search_id" id="tag-search-id" value="" autocomplete="off">
<div class="form-field">
<div class="prompt">Название тега:</div>
<input type="text" name="tag_search" id="tag-search" value="" autocomplete="off" style="width:85%; border:1px solid gray; padding:4px;"><input
type="submit" class="search_btn" value="">
</div>
</form>
<div id="tag-found"></div>
</div>
</div>