refactor profile modules

remotes/origin/1203
pavel 11 years ago
parent 719b30f844
commit f68ca8ddf7
  1. 2
      templates/client/static_client/js/_modules/block.common.js
  2. 127
      templates/client/static_client/js/_modules/page.company.js
  3. 78
      templates/client/static_client/js/_modules/page.profile.js
  4. 2
      templates/client/static_client/js_min/_modules/block.common.min.js
  5. 2
      templates/client/static_client/js_min/_modules/page.company.min.js
  6. 2
      templates/client/static_client/js_min/_modules/page.profile.min.js

@ -493,7 +493,7 @@ if (EXPO.common){
* @param {string} selector * @param {string} selector
* @public * @public
*/ */
pullData: function (selector) { afterSubmit: function (selector) {
this.id = selector.substr(1); this.id = selector.substr(1);
$(selector).show().siblings().hide(); $(selector).show().siblings().hide();
this.refresh(); this.refresh();

@ -42,7 +42,7 @@ if (EXPO.company){
// methods to perform ajax responses to send and receive data from the server // methods to perform ajax responses to send and receive data from the server
Forms.prototype = { Forms.prototype = {
// ajax request realization // ajax request realization
getajax: function (dataToSend) { submit: function (dataToSend) {
var self = this; var self = this;
if(!dataToSend){ if(!dataToSend){
dataToSend = ''; dataToSend = '';
@ -54,7 +54,7 @@ if (EXPO.company){
processData: false, processData: false,
contentType: false, contentType: false,
success: function(data) { success: function(data) {
self.pullHandler(data); self.afterSubmit(data);
if(data.success){ if(data.success){
EXPO.company.rating.refresh(data.rating); EXPO.company.rating.refresh(data.rating);
} }
@ -64,8 +64,8 @@ if (EXPO.company){
}, },
// check if there exists custom data manipulation handler and evaluate it // check if there exists custom data manipulation handler and evaluate it
pushData: function (data, formName) { beforeSubmit: function (data, formName) {
var handler = this.pushHandler, var handler = this.beforeSubmitHandler,
formData = data; formData = data;
if(typeof formData != "string"){ if(typeof formData != "string"){
this.formData =formData; this.formData =formData;
@ -77,16 +77,16 @@ if (EXPO.company){
if(typeof handler == 'function'){ if(typeof handler == 'function'){
// if particular data change required // if particular data change required
this.formData = handler(data, formName); this.formData = handler(data, formName);
this.getajax(data); this.submit(data);
$('#wait-ajax').show(); $('#wait-ajax').show();
} else{ } else{
this.getajax(data); this.submit(data);
$('#wait-ajax').show(); $('#wait-ajax').show();
} }
}, },
pullData: function (data) { afterSubmit: function (data) {
var handler = this.pullHandler; var handler = this.afterSubmitHandler;
if(typeof handler == 'function'){ if(typeof handler == 'function'){
handler(data); handler(data);
} else{ } else{
@ -103,7 +103,7 @@ if (EXPO.company){
* @function * @function
* @public * @public
*/ */
refreshState: function () { refreshHTML: function () {
var pureText = $.trim( this.$staticValue.text()).replace(/[^0-9a-zA-Zа-я\s]/g,'').replace( /(\d)\s/, '' ).replace(/\s+/g,''); var pureText = $.trim( this.$staticValue.text()).replace(/[^0-9a-zA-Zа-я\s]/g,'').replace( /(\d)\s/, '' ).replace(/\s+/g,'');
if(($.trim( this.$staticValue.text()) == '' || pureText == 'NoneNone') && this.$wrapper.length && this.refrashable){ if(($.trim( this.$staticValue.text()) == '' || pureText == 'NoneNone') && this.$wrapper.length && this.refrashable){
this.$editable.addClass('hidden'); this.$editable.addClass('hidden');
@ -116,6 +116,11 @@ if (EXPO.company){
} }
} }
}; };
/**
* factory object directly
* @param {String} type - type of fabricated object
* @param {String} ajaxpath - attribute action from each form html element
*/
Forms.factory = function (type, ajaxpath) { Forms.factory = function (type, ajaxpath) {
var constr = type, var constr = type,
newForm; newForm;
@ -125,20 +130,23 @@ if (EXPO.company){
message: constr + "doesen't exist" message: constr + "doesen't exist"
}; };
} }
if(typeof Forms[constr].prototype.pushData !== "function"){ if(typeof Forms[constr].prototype.beforeSubmit !== "function"){
Forms[constr].prototype = new Forms(); Forms[constr].prototype = new Forms();
} }
newForm = new Forms[constr](ajaxpath); newForm = new Forms[constr](ajaxpath);
return newForm; return newForm;
}; };
/**
* set of child objects that will override the factory default
*/
Forms.name_form = function (path) { Forms.name_form = function (path) {
this.pullHandler = function (data) { var self = this;
this.afterSubmitHandler = function (data) {
if (data.success){ if (data.success){
$('#static-name-value').text($('#id_name').val()); $('#static-name-value').text($('#id_name').val());
$('.p-editable').removeClass('pe-current'); $('.p-editable').removeClass('pe-current');
this.refreshState(); self.refreshHTML();
}else{ }else{
this.$editable.addClass('err'); this.$editable.addClass('err');
@ -148,11 +156,12 @@ if (EXPO.company){
}; };
Forms.spec_form = function (path) { Forms.spec_form = function (path) {
this.pullHandler = function (data) { var self = this;
this.afterSubmitHandler = function (data) {
if (data.success){ if (data.success){
$('#static-spec-value').html(com.nl2br($('#id_specialization').val())); $('#static-spec-value').html(com.nl2br($('#id_specialization').val()));
$('.p-editable').removeClass('pe-current'); $('.p-editable').removeClass('pe-current');
this.refreshState(); self.refreshHTML();
}else{ }else{
this.$editable.addClass('err'); this.$editable.addClass('err');
@ -162,11 +171,13 @@ if (EXPO.company){
}; };
Forms.address_form = function (path) { Forms.address_form = function (path) {
this.pullHandler = function (data) { var self = this;
this.afterSubmitHandler = function (data) {
if (data.success){ if (data.success){
$('#static-address-value').text($('#id_address_inf').val()); $('#static-address-value').text($('#id_address_inf').val());
$('.p-editable').removeClass('pe-current'); $('.p-editable').removeClass('pe-current');
this.refreshState(); self.refreshHTML();
}else{ }else{
this.$editable.addClass('err'); this.$editable.addClass('err');
@ -178,7 +189,7 @@ if (EXPO.company){
Forms.social_form = function (path) { Forms.social_form = function (path) {
var self = this, var self = this,
$img, imgSrc, $input, inputValue,item; $img, imgSrc, $input, inputValue,item;
this.pullHandler = function (data) { this.afterSubmitHandler = function (data) {
if (data.success){ if (data.success){
for (item in self.formData) { for (item in self.formData) {
@ -221,10 +232,10 @@ if (EXPO.company){
}); });
} }
} }
this.refreshState(); self.refreshHTML();
}; };
this.pushHandler = function (data, formName){ this.beforeSubmitHandler = function (data, formName){
var formData = $('#'+formName).serialize(); var formData = $('#'+formName).serialize();
return JSON.parse('{"' + decodeURI(formData).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}'); return JSON.parse('{"' + decodeURI(formData).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}');
@ -233,7 +244,7 @@ if (EXPO.company){
}; };
this.refreshState = function () { this.refreshHTML = function () {
console.log(this); console.log(this);
var fullComplete = true; var fullComplete = true;
$('input:text',this.$form).each(function () { $('input:text',this.$form).each(function () {
@ -253,11 +264,13 @@ if (EXPO.company){
}; };
Forms.phone_form = function (path) { Forms.phone_form = function (path) {
this.pullHandler = function (data) { var self = this;
this.afterSubmitHandler = function (data) {
if (data.success){ if (data.success){
$('#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(); self.refreshHTML();
} }
}; };
this.ajaxPath = path; this.ajaxPath = path;
@ -265,12 +278,14 @@ if (EXPO.company){
}; };
Forms.email_form = function (path) { Forms.email_form = function (path) {
var mailValue; var mailValue;
this.pullHandler = function (data) { var self = this;
this.afterSubmitHandler = function (data) {
if (data.success){ if (data.success){
mailValue = $('#id_email').val(); mailValue = $('#id_email').val();
$('#static-email-value').attr('href', 'mailto:'+mailValue).text(mailValue); $('#static-email-value').attr('href', 'mailto:'+mailValue).text(mailValue);
$('.p-editable').removeClass('pe-current'); $('.p-editable').removeClass('pe-current');
this.refreshState(); self.refreshHTML();
}else{ }else{
this.$editable.addClass('err'); this.$editable.addClass('err');
} }
@ -280,12 +295,14 @@ if (EXPO.company){
}; };
Forms.web_page_form = function (path) { Forms.web_page_form = function (path) {
var userLink; var userLink;
this.pullHandler = function (data) { var self = this;
this.afterSubmitHandler = function (data) {
if (data.success){ if (data.success){
userLink = $('#id_web_page').val(); 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(); self.refreshHTML();
} }
}; };
@ -294,14 +311,16 @@ if (EXPO.company){
}; };
Forms.home_form = function (path) { Forms.home_form = function (path) {
this.pullHandler = function (data) { var self = this;
this.afterSubmitHandler = function (data) {
if (data.success){ if (data.success){
var country = $('#s2id_id_country').find('.select2-chosen').text(), var country = $('#s2id_id_country').find('.select2-chosen').text(),
city = $('#s2id_id_city').find('.select2-chosen').text(); city = $('#s2id_id_city').find('.select2-chosen').text();
$('#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(); self.refreshHTML();
} }
}; };
@ -311,7 +330,9 @@ if (EXPO.company){
Forms.found_form = function (path) { Forms.found_form = function (path) {
var currValue, var currValue,
$input; $input;
this.pullHandler = function (data) { var self = this;
this.afterSubmitHandler = function (data) {
if (data.success){ if (data.success){
var $fullComplete = $('.full-complete',this.$staticValue); var $fullComplete = $('.full-complete',this.$staticValue);
@ -321,13 +342,13 @@ if (EXPO.company){
$fullComplete.text(currValue); $fullComplete.text(currValue);
$('.p-editable').removeClass('pe-current'); $('.p-editable').removeClass('pe-current');
this.refreshState(); self.refreshHTML();
} }
}; };
this.ajaxPath = path; this.ajaxPath = path;
this.refreshState = function () { this.refreshHTML = function () {
var $fullComplete = $('.full-complete',this.$staticValue), var $fullComplete = $('.full-complete',this.$staticValue),
$notComplete = $('.not-complete',this.$staticValue); $notComplete = $('.not-complete',this.$staticValue);
if($.trim($fullComplete.text()) == ''){ if($.trim($fullComplete.text()) == ''){
@ -345,19 +366,21 @@ if (EXPO.company){
Forms.staff_form = function (path) { Forms.staff_form = function (path) {
var currValue, var currValue,
$input; $input;
this.pullHandler = function (data) { var self = this;
this.afterSubmitHandler = function (data) {
if (data.success){ if (data.success){
var $fullComplete = $('.full-complete',this.$staticValue); var $fullComplete = $('.full-complete',this.$staticValue);
$input = $('#id_staff_number'); $input = $('#id_staff_number');
currValue = $.trim($input.val()); currValue = $.trim($input.val());
$fullComplete.text(currValue); $fullComplete.text(currValue);
$('.p-editable').removeClass('pe-current'); $('.p-editable').removeClass('pe-current');
this.refreshState(); self.refreshHTML();
} }
}; };
this.ajaxPath = path; this.ajaxPath = path;
this.refreshState = function () { this.refreshHTML = function () {
var $fullComplete = $('.full-complete',this.$staticValue), var $fullComplete = $('.full-complete',this.$staticValue),
$notComplete = $('.not-complete',this.$staticValue); $notComplete = $('.not-complete',this.$staticValue);
if($.trim($fullComplete.text()) == ''){ if($.trim($fullComplete.text()) == ''){
@ -375,7 +398,9 @@ if (EXPO.company){
Forms.description_form = function (path) { Forms.description_form = function (path) {
var currValue, var currValue,
$input = $('#id_description'); $input = $('#id_description');
this.pullHandler = function (data) { var self = this;
this.afterSubmitHandler = function (data) {
if (data.success){ if (data.success){
var $fullComplete = $('.full-complete',this.$staticValue); var $fullComplete = $('.full-complete',this.$staticValue);
@ -383,12 +408,12 @@ if (EXPO.company){
$fullComplete.html(com.nl2br(currValue)); $fullComplete.html(com.nl2br(currValue));
$('.p-editable').removeClass('pe-current'); $('.p-editable').removeClass('pe-current');
this.refreshState(); self.refreshHTML();
} }
}; };
this.ajaxPath = path; this.ajaxPath = path;
this.refreshState = function () { this.refreshHTML = function () {
var $fullComplete = $('.full-complete',this.$staticValue), var $fullComplete = $('.full-complete',this.$staticValue),
$notComplete = $('.not-complete',this.$staticValue); $notComplete = $('.not-complete',this.$staticValue);
if($.trim($fullComplete.text()) == ''){ if($.trim($fullComplete.text()) == ''){
@ -414,20 +439,20 @@ if (EXPO.company){
* 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.afterSubmitHandler = function (data) {
if (data.success){ if (data.success){
if($avatar.length){ if($avatar.length){
$avatar.attr('src', data.url); $avatar.attr('src', data.url);
this.refreshState(); self.refreshHTML();
} }
} }
}; };
this.pushHandler = function(data){ this.beforeSubmitHandsler = function(data){
if(typeof data != 'string'){ if(typeof data != 'string'){
self.getajax(data); self.submit(data);
$('#wait-ajax').show(); $('#wait-ajax').show();
}else{ }else{
$form = $('#'+self.formId); $form = $('#'+self.formId);
@ -440,7 +465,7 @@ if (EXPO.company){
}); });
this.ajaxPath = path; this.ajaxPath = path;
this.refreshState = function () { this.refreshHTML = function () {
if($.trim(this.$image.attr('src')) == this.noImageSrc){ if($.trim(this.$image.attr('src')) == this.noImageSrc){
this.$editable.addClass('hidden'); this.$editable.addClass('hidden');
this.$description.removeClass('hidden'); this.$description.removeClass('hidden');
@ -458,7 +483,7 @@ if (EXPO.company){
* 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.afterSubmitHandler = function (data) {
var divider ='<span>, </span>'; var divider ='<span>, </span>';
if (data.success){ if (data.success){
@ -469,7 +494,7 @@ if (EXPO.company){
this.$staticValue.append($(divider)); this.$staticValue.append($(divider));
} }
} }
this.refreshState(); self.refreshHTML();
} }
}; };
@ -477,7 +502,7 @@ if (EXPO.company){
this.$input = $('#id_tag'); this.$input = $('#id_tag');
this.refreshState = function () { this.refreshHTML = function () {
this.$label = $('.label', this.$editable); this.$label = $('.label', this.$editable);
this.$initial = $(".initial-position",this.$wrapper); this.$initial = $(".initial-position",this.$wrapper);
this.formId = this.$form.attr("id"); this.formId = this.$form.attr("id");
@ -808,17 +833,17 @@ if (EXPO.company){
$waiter.show(); $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].beforeSubmit(inputData, formName);
} else { } else {
inputData = $(this).serialize(); inputData = $(this).serialize();
self.forms[formName].pushData(inputData, formName); self.forms[formName].beforeSubmit(inputData, formName);
} }
return false; return false;
}); });
$closeButton.on('click', function() { $closeButton.on('click', function() {
$editable.removeClass(self.opt.formCurrentClass); $editable.removeClass(self.opt.formCurrentClass);
self.forms[formName].refreshState(); self.forms[formName].refreshHTML();
return false; return false;
}); });
@ -850,7 +875,7 @@ if (EXPO.company){
if($(this).hasClass(self.opt.formCurrentClass)){ if($(this).hasClass(self.opt.formCurrentClass)){
if(self.forms[formId].refrashable){ if(self.forms[formId].refrashable){
self.forms[formId].refreshState(); self.forms[formId].refreshHTML();
$editable.removeClass(EXPO.company.opt.formCurrentClass); $editable.removeClass(EXPO.company.opt.formCurrentClass);
}else{ }else{
$editable.removeClass(self.opt.formCurrentClass); $editable.removeClass(self.opt.formCurrentClass);
@ -870,7 +895,7 @@ if (EXPO.company){
var targetObj = $(event.target); var targetObj = $(event.target);
if (targetObj.parents().filter('.e-form').length < 1) { if (targetObj.parents().filter('.e-form').length < 1) {
$editable.removeClass(self.opt.formCurrentClass); $editable.removeClass(self.opt.formCurrentClass);
self.forms[formName].refreshState(); self.forms[formName].refreshHTML();
$(document).off('click.form'); $(document).off('click.form');
} }
}); });

@ -45,7 +45,7 @@ if (EXPO.profile){
// factory for on page form objects // factory for on page form objects
Forms.prototype = { Forms.prototype = {
// ajax request realization // ajax request realization
getajax: function (dataToSend) { submit: function (dataToSend) {
var self = this; var self = this;
if(!dataToSend){ if(!dataToSend){
dataToSend = ''; dataToSend = '';
@ -57,7 +57,7 @@ if (EXPO.profile){
processData: false, processData: false,
contentType: false, contentType: false,
success: function(data) { success: function(data) {
self.pullHandler(data); self.afterSubmitHandler(data);
if(data.success){ if(data.success){
EXPO.profile.rating.refresh(data.rating); EXPO.profile.rating.refresh(data.rating);
} }
@ -67,8 +67,8 @@ if (EXPO.profile){
}, },
// check if there exists custom data manipulation handler and evaluate it // check if there exists custom data manipulation handler and evaluate it
pushData: function (data, formName) { beforeSubmit: function (data, formName) {
var handler = this.pushHandler, var handler = this.beforeSubmitHandler,
formData = data; formData = data;
if(typeof formData != "string"){ if(typeof formData != "string"){
this.formData =formData; this.formData =formData;
@ -80,10 +80,10 @@ if (EXPO.profile){
if(typeof handler == 'function'){ if(typeof handler == 'function'){
// if particular data change required // if particular data change required
this.formData = handler(data, formName); this.formData = handler(data, formName);
this.getajax(data); this.submit(data);
$('#wait-ajax').show(); $('#wait-ajax').show();
} else{ } else{
this.getajax(data); this.submit(data);
$('#wait-ajax').show(); $('#wait-ajax').show();
} }
@ -91,8 +91,8 @@ if (EXPO.profile){
}, },
pullData: function (data) { afterSubmit: function (data) {
var handler = this.pullHandler; var handler = this.afterSubmitHandler;
if(typeof handler == 'function'){ if(typeof handler == 'function'){
handler(data); handler(data);
} else{ } else{
@ -122,7 +122,7 @@ if (EXPO.profile){
* @function * @function
* @public * @public
*/ */
refreshState: function () { refreshHTML: function () {
var pureText = $.trim( this.$staticValue.text()).replace(/[^0-9a-zA-Zа-я\s]/g,'').replace( /(\d)\s/, '' ).replace(/\s+/g,''); var pureText = $.trim( this.$staticValue.text()).replace(/[^0-9a-zA-Zа-я\s]/g,'').replace( /(\d)\s/, '' ).replace(/\s+/g,'');
if(($.trim( this.$staticValue.text()) == '' || pureText == 'NoneNone') && this.$wrapper.length && this.refrashable){ if(($.trim( this.$staticValue.text()) == '' || pureText == 'NoneNone') && this.$wrapper.length && this.refrashable){
this.$editable.addClass('hidden'); this.$editable.addClass('hidden');
@ -145,7 +145,7 @@ if (EXPO.profile){
message: constr + "doesen't exist" message: constr + "doesen't exist"
}; };
} }
if(typeof Forms[constr].prototype.pushData !== "function"){ if(typeof Forms[constr].prototype.beforeSubmit !== "function"){
Forms[constr].prototype = new Forms(); Forms[constr].prototype = new Forms();
} }
newForm = new Forms[constr](ajaxpath); newForm = new Forms[constr](ajaxpath);
@ -154,7 +154,7 @@ if (EXPO.profile){
//# constructors for each indivivdual form //# constructors for each indivivdual form
// please add functionality for new profile forms here // 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 // beforeSubmitHandler 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. // name of each method is equal 'id' attribute of <form/> element on the page.
Forms.home_form = function (path) { Forms.home_form = function (path) {
@ -163,14 +163,14 @@ if (EXPO.profile){
* 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.afterSubmitHandler = function (data) {
if (data.success){ if (data.success){
var country = $('#s2id_id_country').find('.select2-chosen').text(), var country = $('#s2id_id_country').find('.select2-chosen').text(),
city = $('#s2id_id_city').find('.select2-chosen').text(); city = $('#s2id_id_city').find('.select2-chosen').text();
$('#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.refreshHTML();
} }
}; };
this.ajaxPath = path; this.ajaxPath = path;
@ -182,11 +182,11 @@ if (EXPO.profile){
* 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.afterSubmitHandler = function (data) {
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.refreshHTML();
} }
}; };
@ -199,7 +199,7 @@ if (EXPO.profile){
* 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.afterSubmitHandler = function (data) {
var staticText, var staticText,
work_fieldValue = $.trim($('#s2id_id_company').text()); work_fieldValue = $.trim($('#s2id_id_company').text());
if (data.success ){ if (data.success ){
@ -209,7 +209,7 @@ if (EXPO.profile){
} }
$('#static-work-value').text(staticText); $('#static-work-value').text(staticText);
$('.p-editable').removeClass('pe-current'); $('.p-editable').removeClass('pe-current');
this.refreshState(); this.refreshHTML();
} }
}; };
@ -222,12 +222,12 @@ if (EXPO.profile){
* 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.afterSubmitHandler = function (data) {
if (data.success){ if (data.success){
$('#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(); this.refreshHTML();
} }
}; };
@ -240,12 +240,12 @@ if (EXPO.profile){
* 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.afterSubmitHandler = function (data) {
if (data.success){ if (data.success){
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(); this.refreshHTML();
} }
}; };
@ -259,11 +259,11 @@ if (EXPO.profile){
* 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.afterSubmitHandler = function (data) {
if (data.success){ if (data.success){
$('#static-about-value').html(com.nl2br($('#id_about').val())); $('#static-about-value').html(com.nl2br($('#id_about').val()));
$('.p-editable').removeClass('pe-current'); $('.p-editable').removeClass('pe-current');
this.refreshState(); this.refreshHTML();
} }
}; };
@ -277,7 +277,7 @@ if (EXPO.profile){
* 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.afterSubmitHandler = function (data) {
if (data.success){ if (data.success){
for (item in self.formData) { for (item in self.formData) {
@ -310,7 +310,7 @@ if (EXPO.profile){
} }
$('.p-editable').removeClass('pe-current'); $('.p-editable').removeClass('pe-current');
this.refreshState(); this.refreshHTML();
}else { }else {
for (item in data.errors) { for (item in data.errors) {
@ -323,7 +323,7 @@ if (EXPO.profile){
} }
} }
}; };
this.pushHandler = function (data, formName){ this.beforeSubmitHandler = function (data, formName){
var formData = $('#'+formName).serialize(); var formData = $('#'+formName).serialize();
return JSON.parse('{"' + decodeURI(formData).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}'); return JSON.parse('{"' + decodeURI(formData).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}');
@ -332,7 +332,7 @@ if (EXPO.profile){
}; };
this.refreshState = function () { this.refreshHTML = function () {
console.log(this); console.log(this);
var fullComplete = true; var fullComplete = true;
$('input:text',this.$form).each(function () { $('input:text',this.$form).each(function () {
@ -362,20 +362,20 @@ if (EXPO.profile){
* 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.afterSubmitHandler = function (data) {
if (data.success){ if (data.success){
if($avatar.length){ if($avatar.length){
$avatar.attr('src', data.url); $avatar.attr('src', data.url);
this.refreshState(); this.refreshHTML();
} }
} }
}; };
this.pushHandler = function(data){ this.beforeSubmitHandler = function(data){
if(typeof data != 'string'){ if(typeof data != 'string'){
self.getajax(data); self.submit(data);
$('#wait-ajax').show(); $('#wait-ajax').show();
}else{ }else{
$form = $('#'+self.formId); $form = $('#'+self.formId);
@ -389,7 +389,7 @@ if (EXPO.profile){
this.ajaxPath = path; this.ajaxPath = path;
this.refreshState = function () { this.refreshHTML = function () {
if($.trim(this.$image.attr('src')) == this.noImageSrc){ if($.trim(this.$image.attr('src')) == this.noImageSrc){
this.$editable.addClass('hidden'); this.$editable.addClass('hidden');
this.$description.removeClass('hidden'); this.$description.removeClass('hidden');
@ -411,7 +411,7 @@ if (EXPO.profile){
* 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.afterSubmitHandler = function (data) {
if (data.success){ if (data.success){
location.reload(); location.reload();
@ -610,7 +610,7 @@ if (EXPO.profile){
} }
// todo:временно отключил // todo:временно отключил
//self.forms[formName].refreshState(); //self.forms[formName].refreshHTML();
// submit events handler // submit events handler
$(this).off('submit'); $(this).off('submit');
@ -619,17 +619,17 @@ if (EXPO.profile){
$waiter.show(); $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].beforeSubmit(inputData, formName);
} else { } else {
inputData = $(this).serialize(); inputData = $(this).serialize();
self.forms[formName].pushData(inputData, formName); self.forms[formName].beforeSubmit(inputData, formName);
} }
return false; return false;
}); });
$closeButton.on('click', function() { $closeButton.on('click', function() {
$editable.removeClass(self.opt.formCurrentClass); $editable.removeClass(self.opt.formCurrentClass);
self.forms[formName].refreshState(); self.forms[formName].refreshHTML();
return false; return false;
}); });
if($('.'+self.opt.avatarButtonClass, $wrapper).length){ if($('.'+self.opt.avatarButtonClass, $wrapper).length){
@ -660,7 +660,7 @@ if (EXPO.profile){
if($(this).hasClass(self.opt.formCurrentClass)){ if($(this).hasClass(self.opt.formCurrentClass)){
if(self.forms[formId].refrashable){ if(self.forms[formId].refrashable){
self.forms[formId].refreshState(); self.forms[formId].refreshHTML();
$editable.removeClass(EXPO.profile.opt.formCurrentClass); $editable.removeClass(EXPO.profile.opt.formCurrentClass);
}else{ }else{
$editable.removeClass(self.opt.formCurrentClass); $editable.removeClass(self.opt.formCurrentClass);
@ -680,7 +680,7 @@ if (EXPO.profile){
var targetObj = $(event.target); var targetObj = $(event.target);
if (targetObj.parents().filter('.e-form').length < 1) { if (targetObj.parents().filter('.e-form').length < 1) {
$editable.removeClass(self.opt.formCurrentClass); $editable.removeClass(self.opt.formCurrentClass);
self.forms[formName].refreshState(); self.forms[formName].refreshHTML();
$(document).off('click.form'); $(document).off('click.form');
} }
}); });

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save