|
|
|
@ -15,7 +15,8 @@ if (EXPO.profile){ |
|
|
|
//language object
|
|
|
|
//language object
|
|
|
|
that.lang ={}; |
|
|
|
that.lang ={}; |
|
|
|
//dependences
|
|
|
|
//dependences
|
|
|
|
var com = EXPO.common; |
|
|
|
var com = EXPO.common, |
|
|
|
|
|
|
|
$waiter; |
|
|
|
|
|
|
|
|
|
|
|
//private
|
|
|
|
//private
|
|
|
|
// factory for on page form objects
|
|
|
|
// factory for on page form objects
|
|
|
|
@ -92,6 +93,22 @@ if (EXPO.profile){ |
|
|
|
$('#static-'+input).html(); |
|
|
|
$('#static-'+input).html(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* refreshes form state: if value was entered by user, then there will be label with rhis value |
|
|
|
|
|
|
|
* or there will be prompt to enter value |
|
|
|
|
|
|
|
* @function |
|
|
|
|
|
|
|
* @public |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
refreshState: function () { |
|
|
|
|
|
|
|
if($.trim( this.$staticValue.text()) == '' && this.$wrapper.length && this.refrashable){ |
|
|
|
|
|
|
|
this.$editable.addClass('hidden'); |
|
|
|
|
|
|
|
this.$description.removeClass('hidden'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else if(this.$wrapper.length && this.refrashable){ |
|
|
|
|
|
|
|
this.$editable.removeClass('hidden'); |
|
|
|
|
|
|
|
this.$description.addClass('hidden'); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
Forms.factory = function (type, ajaxpath) { |
|
|
|
Forms.factory = function (type, ajaxpath) { |
|
|
|
@ -128,6 +145,7 @@ if (EXPO.profile){ |
|
|
|
$('#static-home-country').text(country); |
|
|
|
$('#static-home-country').text(country); |
|
|
|
$('#static-home-city').text(city); |
|
|
|
$('#static-home-city').text(city); |
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
|
|
|
this.refreshState(); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
this.ajaxPath = path; |
|
|
|
this.ajaxPath = path; |
|
|
|
@ -143,6 +161,8 @@ if (EXPO.profile){ |
|
|
|
if (data.success){ |
|
|
|
if (data.success){ |
|
|
|
$('#static-name-value').text($('#id_last_name').val()+' '+$('#id_first_name').val()); |
|
|
|
$('#static-name-value').text($('#id_last_name').val()+' '+$('#id_first_name').val()); |
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
|
|
|
this.refreshState(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
this.ajaxPath = path; |
|
|
|
this.ajaxPath = path; |
|
|
|
@ -159,19 +179,8 @@ if (EXPO.profile){ |
|
|
|
$('#static-work-value').text($('#id_position').val()); |
|
|
|
$('#static-work-value').text($('#id_position').val()); |
|
|
|
|
|
|
|
|
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
} |
|
|
|
this.refreshState(); |
|
|
|
}; |
|
|
|
|
|
|
|
this.ajaxPath = path; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
Forms.about_company_form = function (path) { |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* callback after successful request to the server |
|
|
|
|
|
|
|
* @param data -data object recieved from server |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
this.pullHandler = function (data) { |
|
|
|
|
|
|
|
if (data.success){ |
|
|
|
|
|
|
|
window.location.reload(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
this.ajaxPath = path; |
|
|
|
this.ajaxPath = path; |
|
|
|
@ -188,6 +197,8 @@ if (EXPO.profile){ |
|
|
|
$('#static-phone-value').text($('#id_phone')[0].value); |
|
|
|
$('#static-phone-value').text($('#id_phone')[0].value); |
|
|
|
|
|
|
|
|
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
|
|
|
this.refreshState(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
@ -205,6 +216,8 @@ if (EXPO.profile){ |
|
|
|
var userLink = $('#id_web_page').val(); |
|
|
|
var userLink = $('#id_web_page').val(); |
|
|
|
$('#static-web-page-value').attr('href',userLink).text(userLink); |
|
|
|
$('#static-web-page-value').attr('href',userLink).text(userLink); |
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
|
|
|
this.refreshState(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
@ -221,6 +234,8 @@ if (EXPO.profile){ |
|
|
|
if (data.success){ |
|
|
|
if (data.success){ |
|
|
|
$('#static-about-value').text($('#id_about').val()); |
|
|
|
$('#static-about-value').text($('#id_about').val()); |
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
|
|
|
this.refreshState(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
$('#id_about').on('keypress', function (e) { |
|
|
|
$('#id_about').on('keypress', function (e) { |
|
|
|
@ -273,6 +288,7 @@ if (EXPO.profile){ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
this.pushHandler = function (data, formName){ |
|
|
|
this.pushHandler = function (data, formName){ |
|
|
|
@ -305,6 +321,7 @@ if (EXPO.profile){ |
|
|
|
$avatar.attr('src', data.url); |
|
|
|
$avatar.attr('src', data.url); |
|
|
|
} |
|
|
|
} |
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
this.pushHandler = function(data){ |
|
|
|
this.pushHandler = function(data){ |
|
|
|
@ -328,16 +345,26 @@ if (EXPO.profile){ |
|
|
|
* @param path |
|
|
|
* @param path |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
Forms.create_company_form = function (path) { |
|
|
|
Forms.create_company_form = function (path) { |
|
|
|
var self = this; |
|
|
|
var self = this, |
|
|
|
|
|
|
|
containerClass = 'pwf-field'; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* callback after successful request to the server |
|
|
|
* callback after successful request to the server |
|
|
|
* @param data -data object recieved from server |
|
|
|
* @param data -data object recieved from server |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
this.pullHandler = function (data) { |
|
|
|
this.pullHandler = function (data) { |
|
|
|
if (data.success){ |
|
|
|
if (data.success){ |
|
|
|
|
|
|
|
location.reload(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ( var key in data.errors) { |
|
|
|
|
|
|
|
if (data.errors.hasOwnProperty(key)) { |
|
|
|
|
|
|
|
$('input[name="' + key + '"], select[name="' + key + '"]', self.$form).closest('.'+containerClass).addClass('err'); |
|
|
|
|
|
|
|
$waiter.hide(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -383,6 +410,7 @@ if (EXPO.profile){ |
|
|
|
}; |
|
|
|
}; |
|
|
|
this.forms = {}; |
|
|
|
this.forms = {}; |
|
|
|
$(function () { |
|
|
|
$(function () { |
|
|
|
|
|
|
|
$waiter = $('#wait-ajax').css({'z-index': '8012'}); |
|
|
|
/** |
|
|
|
/** |
|
|
|
* <selectbox> styling with 3-rd party libs |
|
|
|
* <selectbox> styling with 3-rd party libs |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -474,15 +502,36 @@ if (EXPO.profile){ |
|
|
|
$('.'+self.opt.updateFormClass).each(function () { |
|
|
|
$('.'+self.opt.updateFormClass).each(function () { |
|
|
|
var formName = $(this).attr('id'), |
|
|
|
var formName = $(this).attr('id'), |
|
|
|
path = $(this).attr('action'), |
|
|
|
path = $(this).attr('action'), |
|
|
|
inputData; |
|
|
|
inputData, |
|
|
|
|
|
|
|
$wrapper = $(this).closest('.'+self.opt.formWrapperClass), |
|
|
|
|
|
|
|
$staticValue = $('.'+self.opt.staticValueClass, $wrapper), |
|
|
|
|
|
|
|
$description = $('.'+self.opt.descriptionClass, $wrapper), |
|
|
|
|
|
|
|
$editable = $('.'+self.opt.editableClass, $wrapper), |
|
|
|
|
|
|
|
$closeButton = $('.'+self.opt.closeButtonClass, $wrapper); |
|
|
|
|
|
|
|
|
|
|
|
//make and initialize form objects
|
|
|
|
//make and initialize form objects
|
|
|
|
|
|
|
|
|
|
|
|
self.forms[formName] = Forms.factory(formName,path); |
|
|
|
self.forms[formName] = Forms.factory(formName,path); |
|
|
|
|
|
|
|
if($('.'+self.opt.editButtonClass, $wrapper).hasClass('no-refresh')){ |
|
|
|
|
|
|
|
self.forms[formName].refrashable = false; |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
self.forms[formName].refrashable = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
self.forms[formName].$form = $(this); |
|
|
|
|
|
|
|
self.forms[formName].$wrapper = $wrapper; |
|
|
|
|
|
|
|
self.forms[formName].$staticValue = $staticValue; |
|
|
|
|
|
|
|
self.forms[formName].$description = $description; |
|
|
|
|
|
|
|
self.forms[formName].$editable = $editable; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.forms[formName].refreshState(); |
|
|
|
|
|
|
|
|
|
|
|
// submit events handler
|
|
|
|
// submit events handler
|
|
|
|
$(this).off('submit'); |
|
|
|
$(this).off('submit'); |
|
|
|
$(this).on('submit', function () { |
|
|
|
$(this).on('submit', function () { |
|
|
|
//check if formData is supported
|
|
|
|
//check if formData is supported
|
|
|
|
|
|
|
|
$waiter.show(); |
|
|
|
if ( window.FormData && ("upload" in ($.ajaxSettings.xhr())) ){ |
|
|
|
if ( window.FormData && ("upload" in ($.ajaxSettings.xhr())) ){ |
|
|
|
inputData = new FormData(this); |
|
|
|
inputData = new FormData(this); |
|
|
|
self.forms[formName].pushData(inputData, formName); |
|
|
|
self.forms[formName].pushData(inputData, formName); |
|
|
|
@ -493,38 +542,40 @@ if (EXPO.profile){ |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
$closeButton.on('click', function() { |
|
|
|
|
|
|
|
$editable.removeClass(self.opt.formCurrentClass); |
|
|
|
|
|
|
|
self.forms[formName].refreshState(); |
|
|
|
|
|
|
|
return false; |
|
|
|
}); |
|
|
|
}); |
|
|
|
/** |
|
|
|
/** |
|
|
|
* edit button |
|
|
|
* edit button |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
$('.'+self.opt.editButtonClass).on('click', function () { |
|
|
|
$('.'+self.opt.editButtonClass, $wrapper).on('click', function () { |
|
|
|
var $switch = $(this), |
|
|
|
if(self.forms[formName].refrashable){ |
|
|
|
$wrapper = $switch.closest('.edit-wrap'), |
|
|
|
$editable.removeClass('hidden'); |
|
|
|
$container = $switch.closest('.p-editable'), |
|
|
|
$description.addClass('hidden'); |
|
|
|
$pForm = $wrapper.children('.e-form'), |
|
|
|
}else{ |
|
|
|
$closeBtn = $pForm.find('a.ef-close'), |
|
|
|
|
|
|
|
$eContainers = $('.p-editable.pe-current').not($container); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$eContainers.each(function() { |
|
|
|
|
|
|
|
$(this).removeClass('pe-current'); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
$container.toggleClass('pe-current'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$closeBtn.one('click', function() { |
|
|
|
} |
|
|
|
$container.removeClass('pe-current'); |
|
|
|
$editable.each(function() { |
|
|
|
return false; |
|
|
|
$(this).removeClass(self.opt.formCurrentClass); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
$editable.toggleClass(self.opt.formCurrentClass); |
|
|
|
|
|
|
|
|
|
|
|
$(document).one('click', function(event) { |
|
|
|
//todo: custom click event
|
|
|
|
|
|
|
|
$(document).on('click.form', function(event) { |
|
|
|
var targetObj = $(event.target); |
|
|
|
var targetObj = $(event.target); |
|
|
|
if (targetObj.parents().filter('.e-form').length < 1) { |
|
|
|
if (targetObj.parents().filter('.e-form').length < 1) { |
|
|
|
$container.removeClass('pe-current'); |
|
|
|
$editable.removeClass(self.opt.formCurrentClass); |
|
|
|
|
|
|
|
$(document).off('click.form'); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* add new company modal window trigger |
|
|
|
* add new company modal window trigger |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|