|
|
|
|
@ -236,138 +236,141 @@ $(document).ready(function(){ |
|
|
|
|
return false; |
|
|
|
|
}); |
|
|
|
|
// end on-of events
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#id_city').select2({ |
|
|
|
|
if( $("#id_city" ).length ) { |
|
|
|
|
$('#id_city').select2({ |
|
|
|
|
placeholder: "Город", |
|
|
|
|
width: 'element', |
|
|
|
|
ajax: { |
|
|
|
|
|
|
|
|
|
url: "/admin/city/search/", |
|
|
|
|
dataType: "json", |
|
|
|
|
quietMillis: 200, |
|
|
|
|
|
|
|
|
|
data: function(term, page, country){ |
|
|
|
|
var country = $('#id_country').val() |
|
|
|
|
return {term: term, |
|
|
|
|
page: page, |
|
|
|
|
country: country}; |
|
|
|
|
url: "/admin/city/search/", |
|
|
|
|
dataType: "json", |
|
|
|
|
quietMillis: 200, |
|
|
|
|
|
|
|
|
|
data: function(term, page, country){ |
|
|
|
|
var country = $('#id_country').val() |
|
|
|
|
return {term: term, |
|
|
|
|
page: page, |
|
|
|
|
country: country}; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
results: function (data) { |
|
|
|
|
var results = []; |
|
|
|
|
$.each(data, function(index, item){ |
|
|
|
|
results.push({ |
|
|
|
|
id: item.id, |
|
|
|
|
text: item.label |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
return {results: results}; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
initSelection : function(element, callback) { |
|
|
|
|
var id= $(element).val(); |
|
|
|
|
var text = $(element).attr('data-init-text'); |
|
|
|
|
callback({id: id, text:text}); |
|
|
|
|
|
|
|
|
|
results: function (data) { |
|
|
|
|
var results = []; |
|
|
|
|
$.each(data, function(index, item){ |
|
|
|
|
results.push({ |
|
|
|
|
id: item.id, |
|
|
|
|
text: item.label |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
return {results: results}; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
initSelection : function(element, callback) { |
|
|
|
|
var id= $(element).val(); |
|
|
|
|
var text = $(element).attr('data-init-text'); |
|
|
|
|
callback({id: id, text:text}); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$('#id_main_page_news').select2({ |
|
|
|
|
if( $("#id_main_page_news" ).length ) { |
|
|
|
|
$('#id_main_page_news').select2({ |
|
|
|
|
placeholder: "Новости", |
|
|
|
|
multiple: true, |
|
|
|
|
width: '100%', |
|
|
|
|
ajax: { |
|
|
|
|
|
|
|
|
|
url: "/admin/ajax/get-news/", |
|
|
|
|
dataType: "json", |
|
|
|
|
quietMillis: 200, |
|
|
|
|
data: function(term, page){ |
|
|
|
|
|
|
|
|
|
return {term: term, |
|
|
|
|
page: page}; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
results: function (data) { |
|
|
|
|
var results = []; |
|
|
|
|
$.each(data, function(index, item){ |
|
|
|
|
results.push({ |
|
|
|
|
id: item.id, |
|
|
|
|
text: item.label |
|
|
|
|
url: "/admin/ajax/get-news/", |
|
|
|
|
dataType: "json", |
|
|
|
|
quietMillis: 200, |
|
|
|
|
data: function(term, page){ |
|
|
|
|
|
|
|
|
|
return {term: term, |
|
|
|
|
page: page}; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
results: function (data) { |
|
|
|
|
var results = []; |
|
|
|
|
$.each(data, function(index, item){ |
|
|
|
|
results.push({ |
|
|
|
|
id: item.id, |
|
|
|
|
text: item.label |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
return {results: results}; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
initSelection : function(element, callback) { |
|
|
|
|
var text = $(element).attr('data-init-text'); |
|
|
|
|
var data = $.parseJSON(text); |
|
|
|
|
console.log(data); |
|
|
|
|
/* |
|
|
|
|
var data = []; |
|
|
|
|
$(element.val().split(",")).each(function(i) { |
|
|
|
|
var item = this.split(':'); |
|
|
|
|
data.push({ |
|
|
|
|
id: item[0], |
|
|
|
|
text: item[1] |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
return {results: results}; |
|
|
|
|
console.log(data) |
|
|
|
|
*/ |
|
|
|
|
callback(data); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
initSelection : function(element, callback) { |
|
|
|
|
var text = $(element).attr('data-init-text'); |
|
|
|
|
var data = $.parseJSON(text); |
|
|
|
|
console.log(data); |
|
|
|
|
/* |
|
|
|
|
var data = []; |
|
|
|
|
$(element.val().split(",")).each(function(i) { |
|
|
|
|
var item = this.split(':'); |
|
|
|
|
data.push({ |
|
|
|
|
id: item[0], |
|
|
|
|
text: item[1] |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
console.log(data) |
|
|
|
|
*/ |
|
|
|
|
callback(data); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// selects
|
|
|
|
|
$('#id_tag').select2({ |
|
|
|
|
if( $("#id_main_page_news" ).length ) { |
|
|
|
|
$('#id_tag').select2({ |
|
|
|
|
placeholder: "Теги", |
|
|
|
|
width: '550px', |
|
|
|
|
multiple: true, |
|
|
|
|
ajax: { |
|
|
|
|
|
|
|
|
|
url: "/admin/theme/tag/search/", |
|
|
|
|
dataType: "json", |
|
|
|
|
quietMillis: 200, |
|
|
|
|
multiple: true, |
|
|
|
|
|
|
|
|
|
data: function(term, page, theme){ |
|
|
|
|
var theme = $('#id_theme').serialize(); |
|
|
|
|
return {term: term, |
|
|
|
|
page: page, |
|
|
|
|
theme: theme}; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
results: function (data) { |
|
|
|
|
var results = []; |
|
|
|
|
$.each(data, function(index, item){ |
|
|
|
|
results.push({ |
|
|
|
|
id: item.id, |
|
|
|
|
text: item.label |
|
|
|
|
url: "/admin/theme/tag/search/", |
|
|
|
|
dataType: "json", |
|
|
|
|
quietMillis: 200, |
|
|
|
|
multiple: true, |
|
|
|
|
|
|
|
|
|
data: function(term, page, theme){ |
|
|
|
|
var theme = $('#id_theme').serialize(); |
|
|
|
|
return {term: term, |
|
|
|
|
page: page, |
|
|
|
|
theme: theme}; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
results: function (data) { |
|
|
|
|
var results = []; |
|
|
|
|
$.each(data, function(index, item){ |
|
|
|
|
results.push({ |
|
|
|
|
id: item.id, |
|
|
|
|
text: item.label |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
return {results: results}; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
initSelection : function(element, callback) { |
|
|
|
|
var data = []; |
|
|
|
|
$(element.val().split(",")).each(function(i) { |
|
|
|
|
var item = this.split(':'); |
|
|
|
|
data.push({ |
|
|
|
|
id: item[0], |
|
|
|
|
text: item[1] |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
return {results: results}; |
|
|
|
|
callback(data); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
initSelection : function(element, callback) { |
|
|
|
|
var data = []; |
|
|
|
|
$(element.val().split(",")).each(function(i) { |
|
|
|
|
var item = this.split(':'); |
|
|
|
|
data.push({ |
|
|
|
|
id: item[0], |
|
|
|
|
text: item[1] |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
callback(data); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
// end selects
|
|
|
|
|
/* |
|
|
|
|
*/ |
|
|
|
|
@ -486,12 +489,14 @@ $(document).ready(function(){ |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if($('select').length){ |
|
|
|
|
$('select').select2({ |
|
|
|
|
width: 'element', |
|
|
|
|
allowClear: true |
|
|
|
|
|
|
|
|
|
});//end select
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|