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.
242 lines
5.9 KiB
242 lines
5.9 KiB
function handleNameForm(data){
|
|
if (data.success){
|
|
/*
|
|
var fname = $this.find('#id_first_name').val()
|
|
var lname = $this.find('#id_last_name').val()
|
|
$this.parent().parent().prev().html(fname+' '+lname)
|
|
$this.next().click()
|
|
*/
|
|
window.location.reload();
|
|
}
|
|
}
|
|
|
|
function handleHomeForm(data){
|
|
if (data.success){
|
|
window.location.reload();
|
|
/*
|
|
var country = $this.find('#id_country option:selected').text();
|
|
var city = $this.find('#id_city option:selected').text();
|
|
|
|
$this.parent().parent().prev();
|
|
$this.parent().parent().prev().prev().find('a').attr('#');
|
|
$this.parent().parent().prev().prev().find('a').html(country);
|
|
|
|
$this.next().click()
|
|
*/
|
|
}
|
|
}
|
|
|
|
function handleWorkForm(data){
|
|
if (data.success){
|
|
window.location.reload();
|
|
/*
|
|
var position = $this.find('#id_position').val();
|
|
var work = $this.find('#id_work').val();
|
|
|
|
var result = position;
|
|
if (work!=''){
|
|
result = result + ' в ' + work;
|
|
}
|
|
|
|
$this.parent().parent().prev().html(result);
|
|
|
|
$this.next().click()
|
|
*/
|
|
}
|
|
}
|
|
|
|
function handleAboutCompanyForm(data){
|
|
if (data.success){
|
|
window.location.reload();
|
|
/*
|
|
var about_company = $this.find('#id_about_company').val();
|
|
$this.parent().parent().prev().html(about_company);
|
|
$this.next().click();
|
|
*/
|
|
}
|
|
}
|
|
|
|
function handleSocialForm(data){
|
|
if (data.success){
|
|
window.location.reload();
|
|
/*
|
|
var fb = $this.find('#id_facebook').val();
|
|
var li = $this.find('#id_linkedin').val();
|
|
var tw = $this.find('#id_twitter').val();
|
|
var vk = $this.find('#id_vk').val();
|
|
|
|
if (fb==''){fb = '#';}
|
|
if (li==''){li = '#';}
|
|
if (tw==''){tw = '#';}
|
|
if (vk==''){vk = '#';}
|
|
|
|
var $ul = $this.parent().parent().prev();
|
|
$ul.find('li:eq(0) a').attr('href', fb);
|
|
$ul.find('li:eq(1) a').attr('href', li);
|
|
$ul.find('li:eq(2) a').attr('href', vk);
|
|
$ul.find('li:eq(3) a').attr('href', tw);
|
|
|
|
$this.next().click();
|
|
*/
|
|
}
|
|
}
|
|
|
|
function handlePhoneForm(data){
|
|
if (data.success){
|
|
window.location.reload();
|
|
/*
|
|
var phone = $this.find('#id_phone').val()
|
|
phone = '+'+phone.replace(/(\d{2})(\d{3})(\d{3})(\d{4})/, "$1 $2 $3 $4");
|
|
$this.parent().parent().prev().html(phone)
|
|
$this.next().click()
|
|
*/
|
|
}
|
|
}
|
|
|
|
function handleEmailForm(data){
|
|
if (data.success){
|
|
window.location.reload();
|
|
/*
|
|
var email = $this.find('#id_email').val()
|
|
$this.parent().parent().prev().html(email)
|
|
$this.parent().parent().prev().attr('href', 'mailto:'+url)
|
|
$this.next().click()
|
|
*/
|
|
}
|
|
}
|
|
|
|
function handleWebPageForm(data){
|
|
if (data.success){
|
|
window.location.reload();
|
|
/*
|
|
var url = $this.find('#id_web_page').val()
|
|
$this.parent().parent().prev().attr('href', url)
|
|
$this.parent().parent().prev().html(url)
|
|
$this.next().click()
|
|
*/
|
|
}
|
|
}
|
|
|
|
function handleAboutForm(data){
|
|
if (data.success){
|
|
window.location.reload();
|
|
/*
|
|
var about = $this.find('#id_about').val()
|
|
$this.parent().parent().prev().html(about)
|
|
$this.next().click()
|
|
*/
|
|
}
|
|
}
|
|
|
|
function handleCreateCompany(data){
|
|
if(data.success){
|
|
window.location = '/profile/company/'
|
|
}
|
|
}
|
|
|
|
function formHandler(id, handleFunction){
|
|
$(id).on('submit', function(event){
|
|
event.preventDefault();
|
|
$this = $(this);
|
|
var url = $this.attr('action');
|
|
var formData = $this.serialize();
|
|
$.post(url, formData, handleFunction);
|
|
});
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function(){
|
|
|
|
formHandler('#home_form', handleHomeForm);
|
|
formHandler('#name_form', handleNameForm);
|
|
formHandler('#work_form', handleWorkForm);
|
|
formHandler('#about_company_form', handleAboutCompanyForm);
|
|
formHandler('#social_form', handleSocialForm);
|
|
formHandler('#phone_form', handlePhoneForm);
|
|
//formHandler('#email_form', handleEmailForm);
|
|
formHandler('#web_page_form', handleWebPageForm);
|
|
formHandler('#about_form', handleAboutForm);
|
|
formHandler('#create_company_form', handleCreateCompany)
|
|
|
|
$('#id_country').select2({
|
|
width: 'element'
|
|
});
|
|
|
|
$('#id_theme').select2({
|
|
width: 'element',
|
|
placeholder: 'Выберите тематику компании',
|
|
maximumSelectionSize: 3
|
|
});
|
|
|
|
$('#id_city').select2({
|
|
placeholder: "Search city",
|
|
width: 'element',
|
|
ajax: {
|
|
|
|
url: "/city/get-city/",
|
|
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});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$('#id_company').select2({
|
|
placeholder: "Search company",
|
|
width: '200px',
|
|
minimumInputLength: 1,
|
|
ajax: {
|
|
|
|
url: "/company/get-company/",
|
|
dataType: "json",
|
|
quietMillis: 200,
|
|
|
|
data: function(term, page, country){
|
|
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 id= $(element).val();
|
|
var text = $(element).attr('data-init-text');
|
|
callback({id: id, text:text});
|
|
|
|
}
|
|
|
|
});
|
|
}); |