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