|
|
|
|
@ -19,350 +19,375 @@ if (EXPO.profile){ |
|
|
|
|
$waiter; |
|
|
|
|
|
|
|
|
|
//private
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Rating functional. Object stores data, HTML Instance of rating field, and can refresh its value |
|
|
|
|
* @param {Object} opt - options for rating instance, like HTML Id and other |
|
|
|
|
* @constructor |
|
|
|
|
*/ |
|
|
|
|
function Rating(opt){ |
|
|
|
|
this.opt = opt; |
|
|
|
|
this.$inst = $('#'+opt.id); |
|
|
|
|
this.value = this.$inst.text; |
|
|
|
|
} |
|
|
|
|
Rating.prototype = { |
|
|
|
|
/** |
|
|
|
|
* refreshes value of HTML instance with new. |
|
|
|
|
* @param {number} newRating - new profile rating value |
|
|
|
|
*/ |
|
|
|
|
refresh: function (newRating) { |
|
|
|
|
this.value = newRating; |
|
|
|
|
this.$inst.text(this.value); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
function Forms(){}; |
|
|
|
|
// methods to perform ajax responses to send and receive data from the server
|
|
|
|
|
// factory for on page form objects
|
|
|
|
|
function Forms(){}; |
|
|
|
|
// methods to perform ajax responses to send and receive data from the server
|
|
|
|
|
Forms.prototype = { |
|
|
|
|
// ajax request realization
|
|
|
|
|
getajax: function (dataToSend) { |
|
|
|
|
var self = this; |
|
|
|
|
if(!dataToSend){ |
|
|
|
|
dataToSend = ''; |
|
|
|
|
} |
|
|
|
|
$.ajax({ |
|
|
|
|
type: 'POST', |
|
|
|
|
url: self.ajaxPath, |
|
|
|
|
data:dataToSend, |
|
|
|
|
processData: false, |
|
|
|
|
contentType: false, |
|
|
|
|
success: function(data) { |
|
|
|
|
self.pullHandler(data); |
|
|
|
|
$('#wait-ajax').fadeOut(); |
|
|
|
|
Forms.prototype = { |
|
|
|
|
// ajax request realization
|
|
|
|
|
getajax: function (dataToSend) { |
|
|
|
|
var self = this; |
|
|
|
|
if(!dataToSend){ |
|
|
|
|
dataToSend = ''; |
|
|
|
|
} |
|
|
|
|
$.ajax({ |
|
|
|
|
type: 'POST', |
|
|
|
|
url: self.ajaxPath, |
|
|
|
|
data:dataToSend, |
|
|
|
|
processData: false, |
|
|
|
|
contentType: false, |
|
|
|
|
success: function(data) { |
|
|
|
|
self.pullHandler(data); |
|
|
|
|
if(data.success){ |
|
|
|
|
EXPO.profile.rating.refresh(data.rating); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
// check if there exists custom data manipulation handler and evaluate it
|
|
|
|
|
pushData: function (data, formName) { |
|
|
|
|
var handler = this.pushHandler, |
|
|
|
|
formData = data; |
|
|
|
|
if(typeof formData != "string"){ |
|
|
|
|
this.formData =formData; |
|
|
|
|
}else{ |
|
|
|
|
this.formData = JSON.parse('{"' + decodeURI(formData).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}'); |
|
|
|
|
} |
|
|
|
|
this.formId = formName; |
|
|
|
|
|
|
|
|
|
if(typeof handler == 'function'){ |
|
|
|
|
// if particular data change required
|
|
|
|
|
this.formData = handler(data, formName); |
|
|
|
|
this.getajax(data); |
|
|
|
|
$('#wait-ajax').show(); |
|
|
|
|
} else{ |
|
|
|
|
this.getajax(data); |
|
|
|
|
$('#wait-ajax').show(); |
|
|
|
|
$('#wait-ajax').fadeOut(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
// check if there exists custom data manipulation handler and evaluate it
|
|
|
|
|
pushData: function (data, formName) { |
|
|
|
|
var handler = this.pushHandler, |
|
|
|
|
formData = data; |
|
|
|
|
if(typeof formData != "string"){ |
|
|
|
|
this.formData =formData; |
|
|
|
|
}else{ |
|
|
|
|
this.formData = JSON.parse('{"' + decodeURI(formData).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}'); |
|
|
|
|
} |
|
|
|
|
this.formId = formName; |
|
|
|
|
|
|
|
|
|
if(typeof handler == 'function'){ |
|
|
|
|
// if particular data change required
|
|
|
|
|
this.formData = handler(data, formName); |
|
|
|
|
this.getajax(data); |
|
|
|
|
$('#wait-ajax').show(); |
|
|
|
|
} else{ |
|
|
|
|
this.getajax(data); |
|
|
|
|
$('#wait-ajax').show(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
pullData: function (data) { |
|
|
|
|
var handler = this.pullHandler; |
|
|
|
|
if(typeof handler == 'function'){ |
|
|
|
|
handler(data); |
|
|
|
|
} else{ |
|
|
|
|
throw{ |
|
|
|
|
name: 'Error', |
|
|
|
|
message: " handler function for processing response after form submit not defined, please define it!" |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
// method to fulfill edited inputs with new content
|
|
|
|
|
fulfillInputs: function () { |
|
|
|
|
var self = this; |
|
|
|
|
for (input in self.formData) { |
|
|
|
|
if($('#id_'+input, $('#'+self.formId)).length > 0){ |
|
|
|
|
$('#id_'+input, $('#'+self.formId)).value(self.formData[input]); |
|
|
|
|
} |
|
|
|
|
if($('#static-'+input).length > 0){ |
|
|
|
|
$('#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) { |
|
|
|
|
var constr = type, |
|
|
|
|
newForm; |
|
|
|
|
if (typeof Forms[constr] !== 'function'){ |
|
|
|
|
}, |
|
|
|
|
pullData: function (data) { |
|
|
|
|
var handler = this.pullHandler; |
|
|
|
|
if(typeof handler == 'function'){ |
|
|
|
|
handler(data); |
|
|
|
|
} else{ |
|
|
|
|
throw{ |
|
|
|
|
name: 'Error', |
|
|
|
|
message: constr + "doesen't exist" |
|
|
|
|
message: " handler function for processing response after form submit not defined, please define it!" |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
if(typeof Forms[constr].prototype.pushData !== "function"){ |
|
|
|
|
Forms[constr].prototype = new Forms(); |
|
|
|
|
} |
|
|
|
|
newForm = new Forms[constr](ajaxpath); |
|
|
|
|
return newForm; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
//# constructors for each indivivdual form
|
|
|
|
|
// please add functionality for new profile forms here
|
|
|
|
|
// pushHandler is for ajax to server, pullHandler for ajax from it. Data is the response information from server
|
|
|
|
|
// name of each method is equal 'id' attribute of <form/> element on the page.
|
|
|
|
|
|
|
|
|
|
Forms.home_form = function (path) { |
|
|
|
|
}, |
|
|
|
|
// method to fulfill edited inputs with new content
|
|
|
|
|
fulfillInputs: function () { |
|
|
|
|
var self = this; |
|
|
|
|
/** |
|
|
|
|
* callback after successful request to the server |
|
|
|
|
* @param data -data object recieved from server |
|
|
|
|
*/ |
|
|
|
|
this.pullHandler = function (data) { |
|
|
|
|
if (data.success){ |
|
|
|
|
var country = $('#s2id_id_country').find('.select2-chosen').text(), |
|
|
|
|
city = $('#s2id_id_city').find('.select2-chosen').text(); |
|
|
|
|
$('#static-home-country').text(country); |
|
|
|
|
$('#static-home-city').text(city); |
|
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
this.refreshState(); |
|
|
|
|
for (input in self.formData) { |
|
|
|
|
if($('#id_'+input, $('#'+self.formId)).length > 0){ |
|
|
|
|
$('#id_'+input, $('#'+self.formId)).value(self.formData[input]); |
|
|
|
|
} |
|
|
|
|
if($('#static-'+input).length > 0){ |
|
|
|
|
$('#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) { |
|
|
|
|
var constr = type, |
|
|
|
|
newForm; |
|
|
|
|
if (typeof Forms[constr] !== 'function'){ |
|
|
|
|
throw{ |
|
|
|
|
name: 'Error', |
|
|
|
|
message: constr + "doesen't exist" |
|
|
|
|
}; |
|
|
|
|
this.ajaxPath = path; |
|
|
|
|
} |
|
|
|
|
if(typeof Forms[constr].prototype.pushData !== "function"){ |
|
|
|
|
Forms[constr].prototype = new Forms(); |
|
|
|
|
} |
|
|
|
|
newForm = new Forms[constr](ajaxpath); |
|
|
|
|
return newForm; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
//# constructors for each indivivdual form
|
|
|
|
|
// please add functionality for new profile forms here
|
|
|
|
|
// pushHandler is for ajax to server, pullHandler for ajax from it. Data is the response information from server
|
|
|
|
|
// name of each method is equal 'id' attribute of <form/> element on the page.
|
|
|
|
|
|
|
|
|
|
Forms.home_form = function (path) { |
|
|
|
|
var self = this; |
|
|
|
|
/** |
|
|
|
|
* callback after successful request to the server |
|
|
|
|
* @param data -data object recieved from server |
|
|
|
|
*/ |
|
|
|
|
this.pullHandler = function (data) { |
|
|
|
|
if (data.success){ |
|
|
|
|
var country = $('#s2id_id_country').find('.select2-chosen').text(), |
|
|
|
|
city = $('#s2id_id_city').find('.select2-chosen').text(); |
|
|
|
|
$('#static-home-country').text(country); |
|
|
|
|
$('#static-home-city').text(city); |
|
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
this.refreshState(); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
Forms.name_form = function (path) { |
|
|
|
|
var self = this; |
|
|
|
|
/** |
|
|
|
|
* callback after successful request to the server |
|
|
|
|
* @param data -data object recieved from server |
|
|
|
|
*/ |
|
|
|
|
this.pullHandler = function (data) { |
|
|
|
|
if (data.success){ |
|
|
|
|
$('#static-name-value').text($('#id_last_name').val()+' '+$('#id_first_name').val()); |
|
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
this.refreshState(); |
|
|
|
|
this.ajaxPath = path; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
this.ajaxPath = path; |
|
|
|
|
}; |
|
|
|
|
Forms.name_form = function (path) { |
|
|
|
|
var self = this; |
|
|
|
|
/** |
|
|
|
|
* callback after successful request to the server |
|
|
|
|
* @param data -data object recieved from server |
|
|
|
|
*/ |
|
|
|
|
this.pullHandler = function (data) { |
|
|
|
|
if (data.success){ |
|
|
|
|
$('#static-name-value').text($('#id_last_name').val()+' '+$('#id_first_name').val()); |
|
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
this.refreshState(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
Forms.work_form = function (path) { |
|
|
|
|
var self = this; |
|
|
|
|
/** |
|
|
|
|
* callback after successful request to the server |
|
|
|
|
* @param data -data object recieved from server |
|
|
|
|
*/ |
|
|
|
|
this.pullHandler = function (data) { |
|
|
|
|
var staticText, |
|
|
|
|
work_fieldValue = $.trim($('#s2id_id_company').text()); |
|
|
|
|
if (data.success){ |
|
|
|
|
staticText = $('#id_position').val(); |
|
|
|
|
if(work_fieldValue != ''){ |
|
|
|
|
staticText += ' '+ EXPO.profile.opt.lang.workIn + ' '+work_fieldValue; |
|
|
|
|
} |
|
|
|
|
$('#static-work-value').text(staticText); |
|
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
this.refreshState(); |
|
|
|
|
this.ajaxPath = path; |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
Forms.work_form = function (path) { |
|
|
|
|
var self = this; |
|
|
|
|
/** |
|
|
|
|
* callback after successful request to the server |
|
|
|
|
* @param data -data object recieved from server |
|
|
|
|
*/ |
|
|
|
|
this.pullHandler = function (data) { |
|
|
|
|
var staticText, |
|
|
|
|
work_fieldValue = $.trim($('#s2id_id_company').text()); |
|
|
|
|
if (data.success){ |
|
|
|
|
staticText = $('#id_position').val(); |
|
|
|
|
if(work_fieldValue != ''){ |
|
|
|
|
staticText += ' '+ EXPO.profile.opt.lang.workIn + ' '+work_fieldValue; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
this.ajaxPath = path; |
|
|
|
|
$('#static-work-value').text(staticText); |
|
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
this.refreshState(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
Forms.phone_form = function (path) { |
|
|
|
|
var self = this; |
|
|
|
|
/** |
|
|
|
|
* callback after successful request to the server |
|
|
|
|
* @param data -data object recieved from server |
|
|
|
|
*/ |
|
|
|
|
this.pullHandler = function (data) { |
|
|
|
|
if (data.success){ |
|
|
|
|
$('#static-phone-value').text($('#id_phone')[0].value); |
|
|
|
|
this.ajaxPath = path; |
|
|
|
|
|
|
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
this.refreshState(); |
|
|
|
|
}; |
|
|
|
|
Forms.phone_form = function (path) { |
|
|
|
|
var self = this; |
|
|
|
|
/** |
|
|
|
|
* callback after successful request to the server |
|
|
|
|
* @param data -data object recieved from server |
|
|
|
|
*/ |
|
|
|
|
this.pullHandler = function (data) { |
|
|
|
|
if (data.success){ |
|
|
|
|
$('#static-phone-value').text($('#id_phone')[0].value); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
this.ajaxPath = path; |
|
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
this.refreshState(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
Forms.web_page_form = function (path) { |
|
|
|
|
var self = this; |
|
|
|
|
/** |
|
|
|
|
* callback after successful request to the server |
|
|
|
|
* @param data -data object recieved from server |
|
|
|
|
*/ |
|
|
|
|
this.pullHandler = function (data) { |
|
|
|
|
if (data.success){ |
|
|
|
|
var userLink = $('#id_web_page').val(); |
|
|
|
|
$('#static-web-page-value').attr('href',userLink).text(userLink); |
|
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
this.refreshState(); |
|
|
|
|
this.ajaxPath = path; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
this.ajaxPath = path; |
|
|
|
|
}; |
|
|
|
|
Forms.web_page_form = function (path) { |
|
|
|
|
var self = this; |
|
|
|
|
/** |
|
|
|
|
* callback after successful request to the server |
|
|
|
|
* @param data -data object recieved from server |
|
|
|
|
*/ |
|
|
|
|
this.pullHandler = function (data) { |
|
|
|
|
if (data.success){ |
|
|
|
|
var userLink = $('#id_web_page').val(); |
|
|
|
|
$('#static-web-page-value').attr('href',userLink).text(userLink); |
|
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
this.refreshState(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
Forms.about_form = function (path) { |
|
|
|
|
var self = this; |
|
|
|
|
/** |
|
|
|
|
* callback after successful request to the server |
|
|
|
|
* @param data -data object recieved from server |
|
|
|
|
*/ |
|
|
|
|
this.pullHandler = function (data) { |
|
|
|
|
if (data.success){ |
|
|
|
|
$('#static-about-value').text($('#id_about').val()); |
|
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
this.refreshState(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
$('#id_about').on('keypress', function (e) { |
|
|
|
|
var keycode = (e.keyCode ? e.keyCode : e.which); |
|
|
|
|
if(keycode == '13'){ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
this.ajaxPath = path; |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
this.ajaxPath = path; |
|
|
|
|
}; |
|
|
|
|
Forms.about_form = function (path) { |
|
|
|
|
var self = this; |
|
|
|
|
/** |
|
|
|
|
* callback after successful request to the server |
|
|
|
|
* @param data -data object recieved from server |
|
|
|
|
*/ |
|
|
|
|
this.pullHandler = function (data) { |
|
|
|
|
if (data.success){ |
|
|
|
|
$('#static-about-value').text($('#id_about').val()); |
|
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
this.refreshState(); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
Forms.social_form = function (path) { |
|
|
|
|
var self = this, |
|
|
|
|
$img, imgSrc, $input, inputValue; |
|
|
|
|
/** |
|
|
|
|
* callback after successful request to the server |
|
|
|
|
* @param data -data object recieved from server |
|
|
|
|
*/ |
|
|
|
|
this.pullHandler = function (data) { |
|
|
|
|
if (data.success){ |
|
|
|
|
$('#id_about').on('keypress', function (e) { |
|
|
|
|
var keycode = (e.keyCode ? e.keyCode : e.which); |
|
|
|
|
if(keycode == '13'){ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (item in self.formData) { |
|
|
|
|
$input = $('#id_'+item); |
|
|
|
|
$input.parent('.required').removeClass('err'); |
|
|
|
|
|
|
|
|
|
if($.trim(self.formData[item]) != '' && $input.length){ |
|
|
|
|
$img = $('#img-'+item); |
|
|
|
|
if($img.length){ |
|
|
|
|
inputValue = $.trim($input.val()); |
|
|
|
|
if ($img.parent('a').length){ |
|
|
|
|
$img.parent('a').attr('href',inputValue); |
|
|
|
|
imgSrc = $img.attr('src').replace('_hover',''); |
|
|
|
|
$img.attr('src',imgSrc); |
|
|
|
|
}else { |
|
|
|
|
imgSrc = $img.attr('src').replace('_hover',''); |
|
|
|
|
$img.attr('src',imgSrc); |
|
|
|
|
$img.wrap('<a href="'+inputValue+'" target="_blank"></a>'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}else if($input.length){ |
|
|
|
|
$img = $('#img-'+item); |
|
|
|
|
}); |
|
|
|
|
this.ajaxPath = path; |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
Forms.social_form = function (path) { |
|
|
|
|
var self = this, |
|
|
|
|
$img, imgSrc, $input, inputValue; |
|
|
|
|
/** |
|
|
|
|
* callback after successful request to the server |
|
|
|
|
* @param data -data object recieved from server |
|
|
|
|
*/ |
|
|
|
|
this.pullHandler = function (data) { |
|
|
|
|
if (data.success){ |
|
|
|
|
|
|
|
|
|
for (item in self.formData) { |
|
|
|
|
$input = $('#id_'+item); |
|
|
|
|
$input.parent('.required').removeClass('err'); |
|
|
|
|
|
|
|
|
|
if($.trim(self.formData[item]) != '' && $input.length){ |
|
|
|
|
$img = $('#img-'+item); |
|
|
|
|
if($img.length){ |
|
|
|
|
inputValue = $.trim($input.val()); |
|
|
|
|
if ($img.parent('a').length){ |
|
|
|
|
imgSrc = $img.attr('src').replace('.png','_hover.png'); |
|
|
|
|
$img.parent('a').attr('href',inputValue); |
|
|
|
|
imgSrc = $img.attr('src').replace('_hover',''); |
|
|
|
|
$img.attr('src',imgSrc); |
|
|
|
|
}else { |
|
|
|
|
imgSrc = $img.attr('src').replace('_hover',''); |
|
|
|
|
$img.attr('src',imgSrc); |
|
|
|
|
$img.unwrap(); |
|
|
|
|
$img.wrap('<a href="'+inputValue+'" target="_blank"></a>'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}else if($input.length){ |
|
|
|
|
$img = $('#img-'+item); |
|
|
|
|
if ($img.parent('a').length){ |
|
|
|
|
imgSrc = $img.attr('src').replace('.png','_hover.png'); |
|
|
|
|
$img.attr('src',imgSrc); |
|
|
|
|
$img.unwrap(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
|
|
|
|
|
}else { |
|
|
|
|
for (item in data.errors) { |
|
|
|
|
$input = $('#id_' + item); |
|
|
|
|
$input.parent('.required').addClass('err'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
this.pushHandler = function (data, formName){ |
|
|
|
|
var formData = $('#'+formName).serialize(); |
|
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
|
|
|
|
|
return JSON.parse('{"' + decodeURI(formData).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}'); |
|
|
|
|
}else { |
|
|
|
|
for (item in data.errors) { |
|
|
|
|
$input = $('#id_' + item); |
|
|
|
|
$input.parent('.required').addClass('err'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
this.pushHandler = function (data, formName){ |
|
|
|
|
var formData = $('#'+formName).serialize(); |
|
|
|
|
|
|
|
|
|
return JSON.parse('{"' + decodeURI(formData).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
this.ajaxPath = path; |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
Forms.avatar_form = function (path) { |
|
|
|
|
var self = this, |
|
|
|
|
$input = $('#id_avatar'), |
|
|
|
|
$editPhoto = $('#pic-edit-photo'), |
|
|
|
|
$pickBlock = $('#pick-block'), |
|
|
|
|
$form, |
|
|
|
|
$avatar = $('img',$pickBlock); |
|
|
|
|
/** |
|
|
|
|
* callback after successful request to the server |
|
|
|
|
* @param data -data object recieved from server |
|
|
|
|
*/ |
|
|
|
|
this.pullHandler = function (data) { |
|
|
|
|
if (data.success){ |
|
|
|
|
this.ajaxPath = path; |
|
|
|
|
|
|
|
|
|
if($avatar.length){ |
|
|
|
|
$avatar.attr('src', data.url); |
|
|
|
|
} |
|
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
}; |
|
|
|
|
Forms.avatar_form = function (path) { |
|
|
|
|
var self = this, |
|
|
|
|
$input = $('#id_avatar'), |
|
|
|
|
$editPhoto = $('#pic-edit-photo'), |
|
|
|
|
$pickBlock = $('#pick-block'), |
|
|
|
|
$form, |
|
|
|
|
$avatar = $('img',$pickBlock); |
|
|
|
|
/** |
|
|
|
|
* callback after successful request to the server |
|
|
|
|
* @param data -data object recieved from server |
|
|
|
|
*/ |
|
|
|
|
this.pullHandler = function (data) { |
|
|
|
|
if (data.success){ |
|
|
|
|
|
|
|
|
|
if($avatar.length){ |
|
|
|
|
$avatar.attr('src', data.url); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
this.pushHandler = function(data){ |
|
|
|
|
if(typeof data != 'string'){ |
|
|
|
|
self.getajax(data); |
|
|
|
|
$('#wait-ajax').show(); |
|
|
|
|
}else{ |
|
|
|
|
$form = $('#'+self.formId); |
|
|
|
|
$form.off('submit'); |
|
|
|
|
$form.trigger('submit'); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
$input.on('change', function () { |
|
|
|
|
$(this).parents('form').submit(); |
|
|
|
|
}); |
|
|
|
|
$('.p-editable').removeClass('pe-current'); |
|
|
|
|
|
|
|
|
|
this.ajaxPath = path; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
this.pushHandler = function(data){ |
|
|
|
|
if(typeof data != 'string'){ |
|
|
|
|
self.getajax(data); |
|
|
|
|
$('#wait-ajax').show(); |
|
|
|
|
}else{ |
|
|
|
|
$form = $('#'+self.formId); |
|
|
|
|
$form.off('submit'); |
|
|
|
|
$form.trigger('submit'); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
$input.on('change', function () { |
|
|
|
|
$(this).parents('form').submit(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
this.refreshState = function () { |
|
|
|
|
if($.trim(this.$image.attr('src')) == this.noImageSrc){ |
|
|
|
|
this.$editable.addClass('hidden'); |
|
|
|
|
this.$description.removeClass('hidden'); |
|
|
|
|
}else{ |
|
|
|
|
this.$editable.removeClass('hidden'); |
|
|
|
|
this.$description.addClass('hidden'); |
|
|
|
|
} |
|
|
|
|
this.ajaxPath = path; |
|
|
|
|
|
|
|
|
|
this.refreshState = function () { |
|
|
|
|
if($.trim(this.$image.attr('src')) == this.noImageSrc){ |
|
|
|
|
this.$editable.addClass('hidden'); |
|
|
|
|
this.$description.removeClass('hidden'); |
|
|
|
|
}else{ |
|
|
|
|
this.$editable.removeClass('hidden'); |
|
|
|
|
this.$description.addClass('hidden'); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
/** |
|
|
|
|
* add new company form init |
|
|
|
|
* @param path |
|
|
|
|
*/ |
|
|
|
|
Forms.create_company_form = function (path) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
/** |
|
|
|
|
* add new company form init |
|
|
|
|
* @param path |
|
|
|
|
*/ |
|
|
|
|
Forms.create_company_form = function (path) { |
|
|
|
|
var self = this, |
|
|
|
|
containerClass = 'pwf-field'; |
|
|
|
|
/** |
|
|
|
|
@ -425,6 +450,7 @@ if (EXPO.profile){ |
|
|
|
|
$(selector).inputmasks(maskOpts); |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
this.rating = new Rating(this.opt.rating); |
|
|
|
|
this.forms = {}; |
|
|
|
|
$(function () { |
|
|
|
|
var $editables = $('.'+self.opt.editableClass); |
|
|
|
|
|