diff --git a/templates/client/static_client/js/_modules/block.common.js b/templates/client/static_client/js/_modules/block.common.js index 640b05c0..b4407b86 100644 --- a/templates/client/static_client/js/_modules/block.common.js +++ b/templates/client/static_client/js/_modules/block.common.js @@ -493,7 +493,7 @@ if (EXPO.common){ * @param {string} selector * @public */ - pullData: function (selector) { + afterSubmit: function (selector) { this.id = selector.substr(1); $(selector).show().siblings().hide(); this.refresh(); diff --git a/templates/client/static_client/js/_modules/page.company.js b/templates/client/static_client/js/_modules/page.company.js index a4f03c46..087150a6 100644 --- a/templates/client/static_client/js/_modules/page.company.js +++ b/templates/client/static_client/js/_modules/page.company.js @@ -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 =', '; 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'); } }); diff --git a/templates/client/static_client/js/_modules/page.profile.js b/templates/client/static_client/js/_modules/page.profile.js index 56c0aef9..bcd063bd 100644 --- a/templates/client/static_client/js/_modules/page.profile.js +++ b/templates/client/static_client/js/_modules/page.profile.js @@ -45,7 +45,7 @@ if (EXPO.profile){ // factory for on page form objects Forms.prototype = { // ajax request realization - getajax: function (dataToSend) { + submit: function (dataToSend) { var self = this; if(!dataToSend){ dataToSend = ''; @@ -57,7 +57,7 @@ if (EXPO.profile){ processData: false, contentType: false, success: function(data) { - self.pullHandler(data); + self.afterSubmitHandler(data); if(data.success){ EXPO.profile.rating.refresh(data.rating); } @@ -67,8 +67,8 @@ if (EXPO.profile){ }, // 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; @@ -80,10 +80,10 @@ if (EXPO.profile){ 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(); } @@ -91,8 +91,8 @@ if (EXPO.profile){ }, - pullData: function (data) { - var handler = this.pullHandler; + afterSubmit: function (data) { + var handler = this.afterSubmitHandler; if(typeof handler == 'function'){ handler(data); } else{ @@ -122,7 +122,7 @@ if (EXPO.profile){ * @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'); @@ -145,7 +145,7 @@ if (EXPO.profile){ 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); @@ -154,7 +154,7 @@ if (EXPO.profile){ //# 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 + // 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
element on the page. Forms.home_form = function (path) { @@ -163,14 +163,14 @@ if (EXPO.profile){ * 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){ 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(); + this.refreshHTML(); } }; this.ajaxPath = path; @@ -182,11 +182,11 @@ if (EXPO.profile){ * 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){ $('#static-name-value').text($('#id_last_name').val()+' '+$('#id_first_name').val()); $('.p-editable').removeClass('pe-current'); - this.refreshState(); + this.refreshHTML(); } }; @@ -199,7 +199,7 @@ if (EXPO.profile){ * callback after successful request to the server * @param data -data object recieved from server */ - this.pullHandler = function (data) { + this.afterSubmitHandler = function (data) { var staticText, work_fieldValue = $.trim($('#s2id_id_company').text()); if (data.success ){ @@ -209,7 +209,7 @@ if (EXPO.profile){ } $('#static-work-value').text(staticText); $('.p-editable').removeClass('pe-current'); - this.refreshState(); + this.refreshHTML(); } }; @@ -222,12 +222,12 @@ if (EXPO.profile){ * 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){ $('#static-phone-value').text($('#id_phone')[0].value); $('.p-editable').removeClass('pe-current'); - this.refreshState(); + this.refreshHTML(); } }; @@ -240,12 +240,12 @@ if (EXPO.profile){ * 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){ var userLink = $('#id_web_page').val(); $('#static-web-page-value').attr('href',userLink).text(userLink); $('.p-editable').removeClass('pe-current'); - this.refreshState(); + this.refreshHTML(); } }; @@ -259,11 +259,11 @@ if (EXPO.profile){ * 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){ $('#static-about-value').html(com.nl2br($('#id_about').val())); $('.p-editable').removeClass('pe-current'); - this.refreshState(); + this.refreshHTML(); } }; @@ -277,7 +277,7 @@ if (EXPO.profile){ * 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){ for (item in self.formData) { @@ -310,7 +310,7 @@ if (EXPO.profile){ } $('.p-editable').removeClass('pe-current'); - this.refreshState(); + this.refreshHTML(); }else { 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(); 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); var fullComplete = true; $('input:text',this.$form).each(function () { @@ -362,20 +362,20 @@ if (EXPO.profile){ * 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(); + this.refreshHTML(); } } }; - this.pushHandler = function(data){ + this.beforeSubmitHandler = function(data){ if(typeof data != 'string'){ - self.getajax(data); + self.submit(data); $('#wait-ajax').show(); }else{ $form = $('#'+self.formId); @@ -389,7 +389,7 @@ if (EXPO.profile){ 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'); @@ -411,7 +411,7 @@ if (EXPO.profile){ * 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){ location.reload(); @@ -610,7 +610,7 @@ if (EXPO.profile){ } // todo:временно отключил - //self.forms[formName].refreshState(); + //self.forms[formName].refreshHTML(); // submit events handler $(this).off('submit'); @@ -619,17 +619,17 @@ if (EXPO.profile){ $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; }); if($('.'+self.opt.avatarButtonClass, $wrapper).length){ @@ -660,7 +660,7 @@ if (EXPO.profile){ if($(this).hasClass(self.opt.formCurrentClass)){ if(self.forms[formId].refrashable){ - self.forms[formId].refreshState(); + self.forms[formId].refreshHTML(); $editable.removeClass(EXPO.profile.opt.formCurrentClass); }else{ $editable.removeClass(self.opt.formCurrentClass); @@ -680,7 +680,7 @@ if (EXPO.profile){ 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'); } }); diff --git a/templates/client/static_client/js_min/_modules/block.common.min.js b/templates/client/static_client/js_min/_modules/block.common.min.js index d8b3362e..8061b52c 100644 --- a/templates/client/static_client/js_min/_modules/block.common.min.js +++ b/templates/client/static_client/js_min/_modules/block.common.min.js @@ -1 +1 @@ -var EXPO=EXPO||{};EXPO.common?console.warn("WARNING: EXPO.common is already defined!"):EXPO.common=function(){var t,e={},s=function(t,e){return(t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector).call(t,e)};e.opt={};var o=function(t){this.fields=[],this.allIsClear=!1,this.ajaxUrl=t.getAttribute("action"),this.DOM=t,this._initFields(),this._eventController()};return o.prototype={_eventController:function(){var t=this;this.DOM.addEventListener?this.DOM.addEventListener("submit",function(e){return t.validate(),e.preventDefault(),!1},!1):this.DOM.attachEvent&&this.DOM.attachEvent("onsubmit",function(e){return t.validate(),e.preventDefault(),!1})},_initFields:function(){},validate:function(){var e,s=this,o=$(s.DOM).serialize(),i={},a="err-message-box",n=s.DOM.querySelector("."+a),r=n.innerHTML,l=function(o){var a,l;if(e=o,s.unHighlightFields(),e.success)n&&EXPO.common.removeClass(n,"active"),$(s.DOM).attr("id")==EXPO.common.opt.registerFormId?(a=$("#"+EXPO.common.opt.successRegisterId),l=$.trim($("#id_email",s.DOM).val()),$("."+EXPO.common.opt.resendLetterClass,a).attr("data-email",l),$.fancybox.close(!0),$.fancybox("#"+EXPO.common.opt.successRegisterId)):window.location.reload();else{EXPO.common.removeClass(n,"active"),i={},s.fields=[];for(var c in e.errors)e.errors.hasOwnProperty(c)&&("__all__"!=c?(i={name:c,id:"id_"+c,errorText:e.errors[c]},s.fields.push(i)):n&&(EXPO.common.addClass(n,"active"),r.indexOf(e.errors[c])<0&&n.insertAdjacentHTML("beforeend",e.errors[c]+" ")));s.highliteFields()}t.hide()};s.unHighlightFields(),t.show(),EXPO.common.postRequest(o,s.ajaxUrl,l)},highliteFields:function(){for(var t,e,s=0;s').appendTo("body"),$.fn.customRadioCheck=function(){return $(this).each(function(){function t(){if("radio"==s){var t=e.attr("name"),o=$('input[type="radio"]').filter('[name="'+t+'"]');o.each(function(){var t=$(this).closest(".custom-radio");t.removeClass("checked"),$(this).is(":checked")&&t.addClass("checked")})}else e.prop("checked")?i.addClass("checked"):i.removeClass("checked");e.trigger("blur")}var e=$(this),s=e.attr("type"),o=e.closest("label"),i=e.wrap("").parent();o.addClass("custom-radio-check"),t(),e.on("change",t)})},$("input[type='checkbox'], input[type='radio']").customRadioCheck()}),function(t){t.fn.inlineStyle=function(e){var s,o=this.attr("style");return o&&o.split(";").forEach(function(o){var i=o.split(":");t.trim(i[0])===e&&(s=i[1])}),s}}(jQuery),e.init=function(e){$.extend(this.opt,e);{var s,o=this,i=this.opt.addCalendarClass,a=this.opt.removeCalendarClass,n=this.opt.addCalendarText,r=this.opt.removeCalendarText,l=o.opt.staticValidation.errorClass,c=o.opt.staticValidation.containerClass;o.opt.staticValidation.blobClass}$(function(){s=$("."+l),t=$("#wait-ajax:not(.absolute)").css({"z-index":"8031"}),$("."+i+", ."+a).on("click",function(t){n=o.opt.addCalendarText,r=o.opt.removeCalendarText,t.preventDefault();var e=$(this),s=e.attr("href");$.get(s,function(t){t.not_authorized?$.fancybox.open("#"+o.opt.loginModalId):t.success&&(t.in?e.removeClass(i).addClass(a).text(r):e.removeClass(a).addClass(i).text(n))})}),s.length&&s.find("input:text").on("keyup",function(){""!=$.trim($(this).val())?$(this).closest("."+l).removeClass(l):$(this).closest("."+c).addClass(l)});for(var e=0;e=0;)o=o.replace(" "+s+" "," ");t.className=o.replace(/^\s+|\s+$/g," ")}return t},e.closest=function(t,s){for(var o=function(s){return e.hasClass(t,s)};t;){if(o(s))return t;t=t.parentNode}},e.children=function(t,e){for(var o,i=[],o=0,a=t.childNodes.length;a>o;++o)s(t.childNodes[o],e)&&i.push(t.childNodes[o]);return i},e.postRequest=function(t,e,s){t||(t=""),$.ajax({type:"POST",url:e,data:t,success:function(t){return"function"!=typeof s?t:(console.log("data recieved:"),console.log(t),console.log(JSON.stringify(t)),s(t),void 0)}})},e.getRequest=function(t,e,s){t||(t=""),$.ajax({type:"GET",url:e,data:t,success:function(t){return"function"!=typeof s?t:(console.log("data recieved:"),console.log(t),console.log(JSON.stringify(t)),s(t),void 0)}})},e.Modal=function(t){var e=this;this.id,this.opt=t,this.DOMwrap=document.getElementById(t.id),this.DOM=this.DOMwrap.querySelector("."+t.wrapClass),$(".modal-close",this.DOM).on("click",function(){e.close()}),$(".modals > *").on("click",function(t){$(t.target.parentNode).find(e.DOMwrap).length&&e.close()})},e.Modal.prototype={pullData:function(t){this.id=t.substr(1),$(t).show().siblings().hide(),this.refresh()},open:function(){$(this.DOMwrap).fadeIn(),e.addClass(document.body,"ov-hidden")},close:function(){$(this.DOMwrap).fadeOut(),e.removeClass(document.body,"ov-hidden")},refresh:function(){var t=this;t.DOM.style.width=t.opt.size[t.id].width+"px",t.DOM.style.minHeight=t.opt.size[t.id].height+"px",t.DOM.style.marginLeft=-(t.opt.size[t.id].width/2)+"px",t.DOM.style.marginTop=-(t.opt.size[t.id].height/2)+"px"}},e.SEOhide={seoContent:{},seoHrefs:{},decode:function(t){for(var e=$("["+t+"]"),s=0,o=e.length;o>s;s++){var i=e.eq(s),a=i.attr("data-hash");switch(i.data("type")){case"href":i.attr("href",Base64.decode(this.seoHrefs[a]));break;case"content":i.replaceWith(Base64.decode(this.seoContent[a]))}}}},e.nl2br=function(t,e){var s=e||"undefined"==typeof e?"
":"
";return(t+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+s+"$2")},e}(); \ No newline at end of file +var EXPO=EXPO||{};EXPO.common?console.warn("WARNING: EXPO.common is already defined!"):EXPO.common=function(){var t,e={},s=function(t,e){return(t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector).call(t,e)};e.opt={};var o=function(t){this.fields=[],this.allIsClear=!1,this.ajaxUrl=t.getAttribute("action"),this.DOM=t,this._initFields(),this._eventController()};return o.prototype={_eventController:function(){var t=this;this.DOM.addEventListener?this.DOM.addEventListener("submit",function(e){return t.validate(),e.preventDefault(),!1},!1):this.DOM.attachEvent&&this.DOM.attachEvent("onsubmit",function(e){return t.validate(),e.preventDefault(),!1})},_initFields:function(){},validate:function(){var e,s=this,o=$(s.DOM).serialize(),i={},a="err-message-box",n=s.DOM.querySelector("."+a),r=n.innerHTML,l=function(o){var a,l;if(e=o,s.unHighlightFields(),e.success)n&&EXPO.common.removeClass(n,"active"),$(s.DOM).attr("id")==EXPO.common.opt.registerFormId?(a=$("#"+EXPO.common.opt.successRegisterId),l=$.trim($("#id_email",s.DOM).val()),$("."+EXPO.common.opt.resendLetterClass,a).attr("data-email",l),$.fancybox.close(!0),$.fancybox("#"+EXPO.common.opt.successRegisterId)):window.location.reload();else{EXPO.common.removeClass(n,"active"),i={},s.fields=[];for(var c in e.errors)e.errors.hasOwnProperty(c)&&("__all__"!=c?(i={name:c,id:"id_"+c,errorText:e.errors[c]},s.fields.push(i)):n&&(EXPO.common.addClass(n,"active"),r.indexOf(e.errors[c])<0&&n.insertAdjacentHTML("beforeend",e.errors[c]+" ")));s.highliteFields()}t.hide()};s.unHighlightFields(),t.show(),EXPO.common.postRequest(o,s.ajaxUrl,l)},highliteFields:function(){for(var t,e,s=0;s').appendTo("body"),$.fn.customRadioCheck=function(){return $(this).each(function(){function t(){if("radio"==s){var t=e.attr("name"),o=$('input[type="radio"]').filter('[name="'+t+'"]');o.each(function(){var t=$(this).closest(".custom-radio");t.removeClass("checked"),$(this).is(":checked")&&t.addClass("checked")})}else e.prop("checked")?i.addClass("checked"):i.removeClass("checked");e.trigger("blur")}var e=$(this),s=e.attr("type"),o=e.closest("label"),i=e.wrap("").parent();o.addClass("custom-radio-check"),t(),e.on("change",t)})},$("input[type='checkbox'], input[type='radio']").customRadioCheck()}),function(t){t.fn.inlineStyle=function(e){var s,o=this.attr("style");return o&&o.split(";").forEach(function(o){var i=o.split(":");t.trim(i[0])===e&&(s=i[1])}),s}}(jQuery),e.init=function(e){$.extend(this.opt,e);{var s,o=this,i=this.opt.addCalendarClass,a=this.opt.removeCalendarClass,n=this.opt.addCalendarText,r=this.opt.removeCalendarText,l=o.opt.staticValidation.errorClass,c=o.opt.staticValidation.containerClass;o.opt.staticValidation.blobClass}$(function(){s=$("."+l),t=$("#wait-ajax:not(.absolute)").css({"z-index":"8031"}),$("."+i+", ."+a).on("click",function(t){n=o.opt.addCalendarText,r=o.opt.removeCalendarText,t.preventDefault();var e=$(this),s=e.attr("href");$.get(s,function(t){t.not_authorized?$.fancybox.open("#"+o.opt.loginModalId):t.success&&(t.in?e.removeClass(i).addClass(a).text(r):e.removeClass(a).addClass(i).text(n))})}),s.length&&s.find("input:text").on("keyup",function(){""!=$.trim($(this).val())?$(this).closest("."+l).removeClass(l):$(this).closest("."+c).addClass(l)});for(var e=0;e=0;)o=o.replace(" "+s+" "," ");t.className=o.replace(/^\s+|\s+$/g," ")}return t},e.closest=function(t,s){for(var o=function(s){return e.hasClass(t,s)};t;){if(o(s))return t;t=t.parentNode}},e.children=function(t,e){for(var o,i=[],o=0,a=t.childNodes.length;a>o;++o)s(t.childNodes[o],e)&&i.push(t.childNodes[o]);return i},e.postRequest=function(t,e,s){t||(t=""),$.ajax({type:"POST",url:e,data:t,success:function(t){return"function"!=typeof s?t:(console.log("data recieved:"),console.log(t),console.log(JSON.stringify(t)),s(t),void 0)}})},e.getRequest=function(t,e,s){t||(t=""),$.ajax({type:"GET",url:e,data:t,success:function(t){return"function"!=typeof s?t:(console.log("data recieved:"),console.log(t),console.log(JSON.stringify(t)),s(t),void 0)}})},e.Modal=function(t){var e=this;this.id,this.opt=t,this.DOMwrap=document.getElementById(t.id),this.DOM=this.DOMwrap.querySelector("."+t.wrapClass),$(".modal-close",this.DOM).on("click",function(){e.close()}),$(".modals > *").on("click",function(t){$(t.target.parentNode).find(e.DOMwrap).length&&e.close()})},e.Modal.prototype={afterSubmit:function(t){this.id=t.substr(1),$(t).show().siblings().hide(),this.refresh()},open:function(){$(this.DOMwrap).fadeIn(),e.addClass(document.body,"ov-hidden")},close:function(){$(this.DOMwrap).fadeOut(),e.removeClass(document.body,"ov-hidden")},refresh:function(){var t=this;t.DOM.style.width=t.opt.size[t.id].width+"px",t.DOM.style.minHeight=t.opt.size[t.id].height+"px",t.DOM.style.marginLeft=-(t.opt.size[t.id].width/2)+"px",t.DOM.style.marginTop=-(t.opt.size[t.id].height/2)+"px"}},e.SEOhide={seoContent:{},seoHrefs:{},decode:function(t){for(var e=$("["+t+"]"),s=0,o=e.length;o>s;s++){var i=e.eq(s),a=i.attr("data-hash");switch(i.data("type")){case"href":i.attr("href",Base64.decode(this.seoHrefs[a]));break;case"content":i.replaceWith(Base64.decode(this.seoContent[a]))}}}},e.nl2br=function(t,e){var s=e||"undefined"==typeof e?"
":"
";return(t+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+s+"$2")},e}(); \ No newline at end of file diff --git a/templates/client/static_client/js_min/_modules/page.company.min.js b/templates/client/static_client/js_min/_modules/page.company.min.js index 61e12431..fbd1593a 100644 --- a/templates/client/static_client/js_min/_modules/page.company.min.js +++ b/templates/client/static_client/js_min/_modules/page.company.min.js @@ -1 +1 @@ -var EXPO=EXPO||{};EXPO.company?console.warn("WARNING: EXPO.company is already defined!"):EXPO.company=function(){function t(t){this.opt=t,this.$inst=$("#"+t.id),this.value=this.$inst.text}function e(){}var a={};a.opt={updateFormClass:"update-profile-form"},a.lang={};var s,i=EXPO.common;return t.prototype={refresh:function(t){this.value=t,this.$inst.text(this.value)}},e.prototype={getajax:function(t){var e=this;t||(t=""),$.ajax({type:"POST",url:e.ajaxPath,data:t,processData:!1,contentType:!1,success:function(t){e.pullHandler(t),t.success&&EXPO.company.rating.refresh(t.rating),$("#wait-ajax").fadeOut()}})},pushData:function(t,e){var a=this.pushHandler,s=t;this.formData="string"!=typeof s?s:JSON.parse('{"'+decodeURI(s).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"')+'"}'),this.formId=e,"function"==typeof a?(this.formData=a(t,e),this.getajax(t),$("#wait-ajax").show()):(this.getajax(t),$("#wait-ajax").show())},pullData:function(t){var e=this.pullHandler;if("function"!=typeof e)throw{name:"Error",message:" handler function for processing response after form submit not defined, please define it!"};e(t)},refreshState:function(){var t=$.trim(this.$staticValue.text()).replace(/[^0-9a-zA-Zа-я\s]/g,"").replace(/(\d)\s/,"").replace(/\s+/g,"");(""==$.trim(this.$staticValue.text())||"NoneNone"==t)&&this.$wrapper.length&&this.refrashable?(this.$editable.addClass("hidden"),this.$editable.removeClass(EXPO.company.opt.formCurrentClass),this.$description.removeClass("hidden")):this.$wrapper.length&&this.refrashable&&(this.$editable.removeClass("hidden"),this.$description.addClass("hidden"))}},e.factory=function(t,a){var s,i=t;if("function"!=typeof e[i])throw{name:"Error",message:i+"doesen't exist"};return"function"!=typeof e[i].prototype.pushData&&(e[i].prototype=new e),s=new e[i](a)},e.name_form=function(t){this.pullHandler=function(t){t.success?($("#static-name-value").text($("#id_name").val()),$(".p-editable").removeClass("pe-current"),this.refreshState()):this.$editable.addClass("err")},this.ajaxPath=t},e.spec_form=function(t){this.pullHandler=function(t){t.success?($("#static-spec-value").html(i.nl2br($("#id_specialization").val())),$(".p-editable").removeClass("pe-current"),this.refreshState()):this.$editable.addClass("err")},this.ajaxPath=t},e.address_form=function(t){this.pullHandler=function(t){t.success?($("#static-address-value").text($("#id_address_inf").val()),$(".p-editable").removeClass("pe-current"),this.refreshState()):this.$editable.addClass("err")},this.ajaxPath=t},e.social_form=function(t){var e,a,s,i,r,n=this;this.pullHandler=function(t){if(t.success){for(r in n.formData)s=$("#id_"+r),s.parent(".required").removeClass("err"),""!=$.trim(n.formData[r])&&s.length?(e=$("#img-"+r),e.length&&(i=$.trim(s.val()),e.parent("a").length?(e.parent("a").attr("href",i),a=e.attr("src").replace("_hover",""),e.attr("src",a)):(a=e.attr("src").replace("_hover",""),e.attr("src",a),e.wrap('')))):s.length&&(e=$("#img-"+r),e.parent("a").length&&(a=e.attr("src").replace(".png","_hover.png"),e.attr("src",a),e.unwrap()));$(".p-editable").removeClass("pe-current")}else for(r in t.errors)s=$("#id_"+r),s.parent(".required").addClass("err"),s.blur(function(){s.parent(".required").removeClass("err"),n.$form.submit()});this.refreshState()},this.pushHandler=function(t,e){var a=$("#"+e).serialize();return JSON.parse('{"'+decodeURI(a).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"')+'"}')},this.refreshState=function(){console.log(this);var t=!0;$("input:text",this.$form).each(function(){""==$.trim($(this).val())&&(t=!1)}),t?($(".full-complete",this.$description).removeClass("hidden"),$(".not-complete",this.$description).addClass("hidden")):($(".full-complete",this.$description).addClass("hidden"),$(".not-complete",this.$description).removeClass("hidden"))},this.ajaxPath=t},e.phone_form=function(t){this.pullHandler=function(t){t.success&&($("#static-phone-value").text($("#id_phone")[0].value),$(".p-editable").removeClass("pe-current"),this.refreshState())},this.ajaxPath=t},e.email_form=function(t){var e;this.pullHandler=function(t){t.success?(e=$("#id_email").val(),$("#static-email-value").attr("href","mailto:"+e).text(e),$(".p-editable").removeClass("pe-current"),this.refreshState()):this.$editable.addClass("err")},this.ajaxPath=t},e.web_page_form=function(t){var e;this.pullHandler=function(t){t.success&&(e=$("#id_web_page").val(),$("#static-web-page-value").attr("href",e).text(e),$(".p-editable").removeClass("pe-current"),this.refreshState())},this.ajaxPath=t},e.home_form=function(t){this.pullHandler=function(t){if(t.success){var e=$("#s2id_id_country").find(".select2-chosen").text(),a=$("#s2id_id_city").find(".select2-chosen").text();$("#static-home-country").text(e),$("#static-home-city").text(a),$(".p-editable").removeClass("pe-current"),this.refreshState()}},this.ajaxPath=t},e.found_form=function(t){var e,a;this.pullHandler=function(t){if(t.success){var s=$(".full-complete",this.$staticValue);a=$("#id_foundation"),e=$.trim(a.val()),s.text(e),$(".p-editable").removeClass("pe-current"),this.refreshState()}},this.ajaxPath=t,this.refreshState=function(){var t=$(".full-complete",this.$staticValue),e=$(".not-complete",this.$staticValue);return""==$.trim(t.text())?(t.addClass("hidden"),e.removeClass("hidden")):(t.removeClass("hidden"),e.addClass("hidden")),!1}},e.staff_form=function(t){var e,a;this.pullHandler=function(t){if(t.success){var s=$(".full-complete",this.$staticValue);a=$("#id_staff_number"),e=$.trim(a.val()),s.text(e),$(".p-editable").removeClass("pe-current"),this.refreshState()}},this.ajaxPath=t,this.refreshState=function(){var t=$(".full-complete",this.$staticValue),e=$(".not-complete",this.$staticValue);return""==$.trim(t.text())?(t.addClass("hidden"),e.removeClass("hidden")):(t.removeClass("hidden"),e.addClass("hidden")),!1}},e.description_form=function(t){var e,a=$("#id_description");this.pullHandler=function(t){if(t.success){var s=$(".full-complete",this.$staticValue);e=$.trim(a.val()),s.html(i.nl2br(e)),$(".p-editable").removeClass("pe-current"),this.refreshState()}},this.ajaxPath=t,this.refreshState=function(){var t=$(".full-complete",this.$staticValue),e=$(".not-complete",this.$staticValue);return""==$.trim(t.text())?(t.addClass("hidden"),e.removeClass("hidden")):(t.removeClass("hidden"),e.addClass("hidden")),!1}},e.avatar_form=function(t){var e,a=this,s=$("#id_avatar"),i=($("#pic-edit-photo"),$("#pick-block")),r=$("img",i);this.pullHandler=function(t){t.success&&r.length&&(r.attr("src",t.url),this.refreshState())},this.pushHandler=function(t){"string"!=typeof t?(a.getajax(t),$("#wait-ajax").show()):(e=$("#"+a.formId),e.off("submit"),e.trigger("submit"))},s.on("change",function(){$(this).parents("form").submit()}),this.ajaxPath=t,this.refreshState=function(){$.trim(this.$image.attr("src"))==this.noImageSrc?(this.$editable.addClass("hidden"),this.$description.removeClass("hidden")):(this.$editable.removeClass("hidden"),this.$description.addClass("hidden"))}},e.tag_form=function(t){this.pullHandler=function(t){var e=", ";if(t.success){this.$staticValue.html("");for(var a=0;a"+t.tags[a].text+"")),a!=t.tags.length-1&&this.$staticValue.append($(e));this.refreshState()}},this.ajaxPath=t,this.$input=$("#id_tag"),this.refreshState=function(){this.$label=$(".label",this.$editable),this.$initial=$(".initial-position",this.$wrapper),this.formId=this.$form.attr("id"),""==$.trim(this.$input.val())?(this.$form.detach().appendTo(this.$editable),this.$label.detach().appendTo(this.$editable),this.$initial.removeClass("hidden"),this.$description.addClass("hidden")):($("#"+this.formId,this.$editable).length<0&&(this.$form.detach().appendTo(this.$editable),this.$label.detach().appendTo(this.$editable)),this.$editable.addClass("hidden"),this.$initial.addClass("hidden"),this.$description.removeClass("hidden"))}},a.init=function(a){$.extend(this.lang,a.lang),a.lang=null,$.extend(this.opt,a);var i=this,r=function(t){var e=$.masksSort($.masksLoad("/static/client/js/plugins/inputmask/phone-codes.json"),["#"],/[0-9]|#/,"mask"),a={inputmask:{definitions:{"#":{validator:"[0-9]",cardinality:1}},showMaskOnHover:!1,insertMode:!1,autoUnmask:!0},match:/[0-9]/,insertMode:!1,replace:"#",list:e,listKey:"mask",onMaskChange:function(){$(this).attr("placeholder","+_(___)___-__-__")}},s="#"+t;$(s).inputmasks(a)};this.rating=new t(this.opt.rating),this.forms={},$(function(){var t=$("."+i.opt.editableClass),a=$("#"+i.opt.selectBox[0].id),n=$("#"+i.opt.selectBox[1].id),o=$("#"+i.opt.selectBox[3].id);s=$("#wait-ajax").css({"z-index":"8012"}),o.select2({width:"element",placeholder:i.opt.selectBox[3].placeHolder,maximumSelectionSize:3}),a.select2({width:"element",placeholder:i.opt.selectBox[0].placeholder}),a.on("change",function(){n.val(0),n.select2("val","")}),a.on("change",function(){(0!=$(this).val()||""!=$(this).val())&&n.prop("disabled",!1)}),(0==a.val()||""==a.val())&&n.prop("disabled",!0),n.select2({placeholder:i.opt.selectBox[1].placeHolder,width:"element",ajax:{url:i.opt.selectBox[1].path,dataType:"json",quietMillis:200,data:function(t,e,a){var a=$("#"+i.opt.selectBox[0].id).val();return{term:t,page:e,country:a}},results:function(t){var e=[];return $.each(t,function(t,a){e.push({id:a.id,text:a.label})}),{results:e}}},initSelection:function(t,e){var a=$.trim($(t).val()),s=$(t).attr("data-init-text");e({id:a,text:s})}}),$("#"+i.opt.selectBox[2].id).val("0"),$("#"+i.opt.selectBox[2].id).select2({placeholder:i.opt.selectBox[2].placeholder,width:"368px",multiple:!0,maximumSelectionSize:5,ajax:{url:i.opt.selectBox[2].path,dataType:"json",quietMillis:200,data:function(t,e){var a=$("#theme-inf").attr("data-theme");return a=a.split(","),a.pop(),{term:t,page:e,themes:a}},results:function(t){var e=[];return $.each(t,function(t,a){e.push({id:a.id,text:a.label})}),{results:e}}},initSelection:function(t,e){var a;t.val(""),""!=$.trim(t.attr("data-predifined"))&&"[]"!=$.trim(t.attr("data-predifined"))?(a=JSON.parse(t.attr("data-predifined")),e(a)):$("#tag_form .select2-input").width(336).addClass("select2-default").val(i.opt.selectBox[2].placeholder)}}),$("#"+i.opt.selectBox[2].id).on("change",function(){var t=$("#tag_form");t.submit()}),r(i.opt.phoneBox),$("."+i.opt.updateFormClass).each(function(){var a,r=$(this).attr("id"),n=$(this).attr("action"),o=$(this).closest("."+i.opt.formWrapperClass),l=$("."+i.opt.staticValueClass,o),d=$("."+i.opt.descriptionClass,o),h=$("."+i.opt.editableClass,o),c=$("."+i.opt.closeButtonClass,o),p=$("."+i.opt.avatarImageClass,o);i.forms[r]=e.factory(r,n),i.forms[r].refrashable=$("."+i.opt.editButtonClass,o).hasClass("no-refresh")?!1:!0,i.forms[r].$form=$(this),i.forms[r].$wrapper=o,i.forms[r].$staticValue=l,i.forms[r].$description=d,i.forms[r].$editable=h,p.length&&(i.forms[r].$image=p,i.forms[r].noImageSrc=i.opt.noImageSrc),$(this).off("submit"),$(this).on("submit",function(){return s.show(),window.FormData&&"upload"in $.ajaxSettings.xhr()?(a=new FormData(this),i.forms[r].pushData(a,r)):(a=$(this).serialize(),i.forms[r].pushData(a,r)),!1}),c.on("click",function(){return h.removeClass(i.opt.formCurrentClass),i.forms[r].refreshState(),!1}),$("."+i.opt.avatarButtonClass,o).length?$("."+i.opt.editButtonClass+", ."+i.opt.avatarButtonClass,o).on("click",function(){var t=$("#"+i.opt.avatarInputId);return t.trigger("click"),!1}):$("."+i.opt.editButtonClass+", ."+i.opt.avatarButtonClass,o).on("click",function(){var e=$(this).closest("."+i.opt.formWrapperClass),a=e.find("."+i.opt.updateFormClass).attr("id"),s=e.find("."+i.opt.descriptionClass),n=e.find("."+i.opt.editableClass);return t.each(function(){var t=$(this).closest("."+i.opt.formWrapperClass),e=t.find("."+i.opt.updateFormClass).attr("id"),a=(t.find("."+i.opt.descriptionClass),t.find("."+i.opt.editableClass));$(this).hasClass(i.opt.formCurrentClass)&&(i.forms[e].refrashable?(i.forms[e].refreshState(),a.removeClass(EXPO.company.opt.formCurrentClass)):a.removeClass(i.opt.formCurrentClass))}),i.forms[a].refrashable&&(n.removeClass("hidden"),s.addClass("hidden")),n.addClass(i.opt.formCurrentClass),$(document).on("click.form",function(t){var e=$(t.target);e.parents().filter(".e-form").length<1&&(n.removeClass(i.opt.formCurrentClass),i.forms[r].refreshState(),$(document).off("click.form"))}),!1})}),$("#"+i.opt.previewBtnId).attr("href",window.location.href+"?logout=1")})},a}(); \ No newline at end of file +var EXPO=EXPO||{};EXPO.company?console.warn("WARNING: EXPO.company is already defined!"):EXPO.company=function(){function t(t){this.opt=t,this.$inst=$("#"+t.id),this.value=this.$inst.text}function e(){}var a={};a.opt={updateFormClass:"update-profile-form"},a.lang={};var s,i=EXPO.common;t.prototype={refresh:function(t){this.value=t,this.$inst.text(this.value)}},e.prototype={submit:function(t){var e=this;t||(t=""),$.ajax({type:"POST",url:e.ajaxPath,data:t,processData:!1,contentType:!1,success:function(t){e.afterSubmit(t),t.success&&EXPO.company.rating.refresh(t.rating),$("#wait-ajax").fadeOut()}})},beforeSubmit:function(t,e){var a=this.beforeSubmitHandler,s=t;this.formData="string"!=typeof s?s:JSON.parse('{"'+decodeURI(s).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"')+'"}'),this.formId=e,"function"==typeof a?(this.formData=a(t,e),this.submit(t),$("#wait-ajax").show()):(this.submit(t),$("#wait-ajax").show())},afterSubmit:function(t){var e=this.afterSubmitHandler;if("function"!=typeof e)throw{name:"Error",message:" handler function for processing response after form submit not defined, please define it!"};e(t)},refreshHTML:function(){var t=$.trim(this.$staticValue.text()).replace(/[^0-9a-zA-Zа-я\s]/g,"").replace(/(\d)\s/,"").replace(/\s+/g,"");(""==$.trim(this.$staticValue.text())||"NoneNone"==t)&&this.$wrapper.length&&this.refrashable?(this.$editable.addClass("hidden"),this.$editable.removeClass(EXPO.company.opt.formCurrentClass),this.$description.removeClass("hidden")):this.$wrapper.length&&this.refrashable&&(this.$editable.removeClass("hidden"),this.$description.addClass("hidden"))}},e.factory=function(t,a){var s,i=t;if("function"!=typeof e[i])throw{name:"Error",message:i+"doesen't exist"};return"function"!=typeof e[i].prototype.beforeSubmit&&(e[i].prototype=new e),s=new e[i](a)},e.name_form=function(t){var e=this;this.afterSubmitHandler=function(t){t.success?($("#static-name-value").text($("#id_name").val()),$(".p-editable").removeClass("pe-current"),e.refreshHTML()):this.$editable.addClass("err")},this.ajaxPath=t},e.spec_form=function(t){var e=this;this.afterSubmitHandler=function(t){t.success?($("#static-spec-value").html(i.nl2br($("#id_specialization").val())),$(".p-editable").removeClass("pe-current"),e.refreshHTML()):this.$editable.addClass("err")},this.ajaxPath=t},e.address_form=function(t){var e=this;this.afterSubmitHandler=function(t){t.success?($("#static-address-value").text($("#id_address_inf").val()),$(".p-editable").removeClass("pe-current"),e.refreshHTML()):this.$editable.addClass("err")},this.ajaxPath=t},e.social_form=function(t){var e,a,s,i,r,o=this;this.afterSubmitHandler=function(t){if(t.success){for(r in o.formData)s=$("#id_"+r),s.parent(".required").removeClass("err"),""!=$.trim(o.formData[r])&&s.length?(e=$("#img-"+r),e.length&&(i=$.trim(s.val()),e.parent("a").length?(e.parent("a").attr("href",i),a=e.attr("src").replace("_hover",""),e.attr("src",a)):(a=e.attr("src").replace("_hover",""),e.attr("src",a),e.wrap('')))):s.length&&(e=$("#img-"+r),e.parent("a").length&&(a=e.attr("src").replace(".png","_hover.png"),e.attr("src",a),e.unwrap()));$(".p-editable").removeClass("pe-current")}else for(r in t.errors)s=$("#id_"+r),s.parent(".required").addClass("err"),s.blur(function(){s.parent(".required").removeClass("err"),o.$form.submit()});o.refreshHTML()},this.beforeSubmitHandler=function(t,e){var a=$("#"+e).serialize();return JSON.parse('{"'+decodeURI(a).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"')+'"}')},this.refreshHTML=function(){console.log(this);var t=!0;$("input:text",this.$form).each(function(){""==$.trim($(this).val())&&(t=!1)}),t?($(".full-complete",this.$description).removeClass("hidden"),$(".not-complete",this.$description).addClass("hidden")):($(".full-complete",this.$description).addClass("hidden"),$(".not-complete",this.$description).removeClass("hidden"))},this.ajaxPath=t},e.phone_form=function(t){var e=this;this.afterSubmitHandler=function(t){t.success&&($("#static-phone-value").text($("#id_phone")[0].value),$(".p-editable").removeClass("pe-current"),e.refreshHTML())},this.ajaxPath=t},e.email_form=function(t){var e,a=this;this.afterSubmitHandler=function(t){t.success?(e=$("#id_email").val(),$("#static-email-value").attr("href","mailto:"+e).text(e),$(".p-editable").removeClass("pe-current"),a.refreshHTML()):this.$editable.addClass("err")},this.ajaxPath=t},e.web_page_form=function(t){var e,a=this;this.afterSubmitHandler=function(t){t.success&&(e=$("#id_web_page").val(),$("#static-web-page-value").attr("href",e).text(e),$(".p-editable").removeClass("pe-current"),a.refreshHTML())},this.ajaxPath=t},e.home_form=function(t){var e=this;this.afterSubmitHandler=function(t){if(t.success){var a=$("#s2id_id_country").find(".select2-chosen").text(),s=$("#s2id_id_city").find(".select2-chosen").text();$("#static-home-country").text(a),$("#static-home-city").text(s),$(".p-editable").removeClass("pe-current"),e.refreshHTML()}},this.ajaxPath=t},e.found_form=function(t){var e,a,s=this;this.afterSubmitHandler=function(t){if(t.success){var i=$(".full-complete",this.$staticValue);a=$("#id_foundation"),e=$.trim(a.val()),i.text(e),$(".p-editable").removeClass("pe-current"),s.refreshHTML()}},this.ajaxPath=t,this.refreshHTML=function(){var t=$(".full-complete",this.$staticValue),e=$(".not-complete",this.$staticValue);return""==$.trim(t.text())?(t.addClass("hidden"),e.removeClass("hidden")):(t.removeClass("hidden"),e.addClass("hidden")),!1}},e.staff_form=function(t){var e,a,s=this;this.afterSubmitHandler=function(t){if(t.success){var i=$(".full-complete",this.$staticValue);a=$("#id_staff_number"),e=$.trim(a.val()),i.text(e),$(".p-editable").removeClass("pe-current"),s.refreshHTML()}},this.ajaxPath=t,this.refreshHTML=function(){var t=$(".full-complete",this.$staticValue),e=$(".not-complete",this.$staticValue);return""==$.trim(t.text())?(t.addClass("hidden"),e.removeClass("hidden")):(t.removeClass("hidden"),e.addClass("hidden")),!1}},e.description_form=function(t){var e,a=$("#id_description"),s=this;this.afterSubmitHandler=function(t){if(t.success){var r=$(".full-complete",this.$staticValue);e=$.trim(a.val()),r.html(i.nl2br(e)),$(".p-editable").removeClass("pe-current"),s.refreshHTML()}},this.ajaxPath=t,this.refreshHTML=function(){var t=$(".full-complete",this.$staticValue),e=$(".not-complete",this.$staticValue);return""==$.trim(t.text())?(t.addClass("hidden"),e.removeClass("hidden")):(t.removeClass("hidden"),e.addClass("hidden")),!1}},e.avatar_form=function(t){var e,a=this,s=$("#id_avatar"),i=($("#pic-edit-photo"),$("#pick-block")),r=$("img",i);this.afterSubmitHandler=function(t){t.success&&r.length&&(r.attr("src",t.url),a.refreshHTML())},this.beforeSubmitHandsler=function(t){"string"!=typeof t?(a.submit(t),$("#wait-ajax").show()):(e=$("#"+a.formId),e.off("submit"),e.trigger("submit"))},s.on("change",function(){$(this).parents("form").submit()}),this.ajaxPath=t,this.refreshHTML=function(){$.trim(this.$image.attr("src"))==this.noImageSrc?(this.$editable.addClass("hidden"),this.$description.removeClass("hidden")):(this.$editable.removeClass("hidden"),this.$description.addClass("hidden"))}},e.tag_form=function(t){var e=this;this.afterSubmitHandler=function(t){var a=", ";if(t.success){this.$staticValue.html("");for(var s=0;s"+t.tags[s].text+"")),s!=t.tags.length-1&&this.$staticValue.append($(a));e.refreshHTML()}},this.ajaxPath=t,this.$input=$("#id_tag"),this.refreshHTML=function(){this.$label=$(".label",this.$editable),this.$initial=$(".initial-position",this.$wrapper),this.formId=this.$form.attr("id"),""==$.trim(this.$input.val())?(this.$form.detach().appendTo(this.$editable),this.$label.detach().appendTo(this.$editable),this.$initial.removeClass("hidden"),this.$description.addClass("hidden")):($("#"+this.formId,this.$editable).length<0&&(this.$form.detach().appendTo(this.$editable),this.$label.detach().appendTo(this.$editable)),this.$editable.addClass("hidden"),this.$initial.addClass("hidden"),this.$description.removeClass("hidden"))}};var r=function(t){var e=this;this.opt=t,this.$wrapper=$("#address-block"),this.$toggle=$(".map-toggle",this.$wrapper),this.$container=$(".map-wrap",this.$wrapper),this.status={visible:!1},this.$toggle.on("click",function(){return $(this).hasClass("active")?e.hideMap():e.showMap(),!1});var a=document.getElementById("gmap-canvas"),s=function(){var t={zoom:4};e.map=new google.maps.Map(a,t);var s=$("#id_country option:selected").text(),i=new google.maps.Geocoder;i.geocode({address:s},function(t,a){if(a==google.maps.GeocoderStatus.OK){e.map.setCenter(t[0].geometry.location);{new google.maps.Marker({map:e.map,position:t[0].geometry.location})}}else alert("Geocode was not successful for the following reason: "+a)})};google.maps.event.addDomListener(window,"load",s)};return r.prototype={showMap:function(){this.$toggle.addClass("active").children(".label").text(this.$toggle.attr("data-hide-text")),this.status.visible=!0,this.$container.removeClass("hidden")},hideMap:function(){this.$toggle.removeClass("active").children(".label").text(this.$toggle.attr("data-show-text")),this.status.visible=!1,this.$container.addClass("hidden")},refresh:function(){}},a.init=function(a){$.extend(this.lang,a.lang),a.lang=null,$.extend(this.opt,a);var i=this,o=function(t){var e=$.masksSort($.masksLoad("/static/client/js/plugins/inputmask/phone-codes.json"),["#"],/[0-9]|#/,"mask"),a={inputmask:{definitions:{"#":{validator:"[0-9]",cardinality:1}},showMaskOnHover:!1,insertMode:!1,autoUnmask:!0},match:/[0-9]/,insertMode:!1,replace:"#",list:e,listKey:"mask",onMaskChange:function(){$(this).attr("placeholder","+_(___)___-__-__")}},s="#"+t;$(s).inputmasks(a)};this.rating=new t(this.opt.rating),this.forms={},$(function(){var t=$("."+i.opt.editableClass),a=$("#"+i.opt.selectBox[0].id),n=$("#"+i.opt.selectBox[1].id),l=$("#"+i.opt.selectBox[3].id);s=$("#wait-ajax").css({"z-index":"8012"}),l.select2({width:"element",placeholder:i.opt.selectBox[3].placeHolder,maximumSelectionSize:3}),a.select2({width:"element",placeholder:i.opt.selectBox[0].placeholder}),a.on("change",function(){n.val(0),n.select2("val","")}),a.on("change",function(){(0!=$(this).val()||""!=$(this).val())&&n.prop("disabled",!1)}),(0==a.val()||""==a.val())&&n.prop("disabled",!0),n.select2({placeholder:i.opt.selectBox[1].placeHolder,width:"element",ajax:{url:i.opt.selectBox[1].path,dataType:"json",quietMillis:200,data:function(t,e,a){var a=$("#"+i.opt.selectBox[0].id).val();return{term:t,page:e,country:a}},results:function(t){var e=[];return $.each(t,function(t,a){e.push({id:a.id,text:a.label})}),{results:e}}},initSelection:function(t,e){var a=$.trim($(t).val()),s=$(t).attr("data-init-text");e({id:a,text:s})}}),$("#"+i.opt.selectBox[2].id).val("0"),$("#"+i.opt.selectBox[2].id).select2({placeholder:i.opt.selectBox[2].placeholder,width:"368px",multiple:!0,maximumSelectionSize:5,ajax:{url:i.opt.selectBox[2].path,dataType:"json",quietMillis:200,data:function(t,e){var a=$("#theme-inf").attr("data-theme");return a=a.split(","),a.pop(),{term:t,page:e,themes:a}},results:function(t){var e=[];return $.each(t,function(t,a){e.push({id:a.id,text:a.label})}),{results:e}}},initSelection:function(t,e){var a;t.val(""),""!=$.trim(t.attr("data-predifined"))&&"[]"!=$.trim(t.attr("data-predifined"))?(a=JSON.parse(t.attr("data-predifined")),e(a)):$("#tag_form .select2-input").width(336).addClass("select2-default").val(i.opt.selectBox[2].placeholder)}}),$("#"+i.opt.selectBox[2].id).on("change",function(){var t=$("#tag_form");t.submit()}),o(i.opt.phoneBox),$("."+i.opt.updateFormClass).each(function(){var a,r=$(this).attr("id"),o=$(this).attr("action"),n=$(this).closest("."+i.opt.formWrapperClass),l=$("."+i.opt.staticValueClass,n),d=$("."+i.opt.descriptionClass,n),h=$("."+i.opt.editableClass,n),c=$("."+i.opt.closeButtonClass,n),p=$("."+i.opt.avatarImageClass,n);i.forms[r]=e.factory(r,o),i.forms[r].refrashable=$("."+i.opt.editButtonClass,n).hasClass("no-refresh")?!1:!0,i.forms[r].$form=$(this),i.forms[r].$wrapper=n,i.forms[r].$staticValue=l,i.forms[r].$description=d,i.forms[r].$editable=h,p.length&&(i.forms[r].$image=p,i.forms[r].noImageSrc=i.opt.noImageSrc),$(this).off("submit"),$(this).on("submit",function(){return s.show(),window.FormData&&"upload"in $.ajaxSettings.xhr()?(a=new FormData(this),i.forms[r].beforeSubmit(a,r)):(a=$(this).serialize(),i.forms[r].beforeSubmit(a,r)),!1}),c.on("click",function(){return h.removeClass(i.opt.formCurrentClass),i.forms[r].refreshHTML(),!1}),$("."+i.opt.avatarButtonClass,n).length?$("."+i.opt.editButtonClass+", ."+i.opt.avatarButtonClass,n).on("click",function(){var t=$("#"+i.opt.avatarInputId);return t.trigger("click"),!1}):$("."+i.opt.editButtonClass+", ."+i.opt.avatarButtonClass,n).on("click",function(){var e=$(this).closest("."+i.opt.formWrapperClass),a=e.find("."+i.opt.updateFormClass).attr("id"),s=e.find("."+i.opt.descriptionClass),o=e.find("."+i.opt.editableClass);return t.each(function(){var t=$(this).closest("."+i.opt.formWrapperClass),e=t.find("."+i.opt.updateFormClass).attr("id"),a=(t.find("."+i.opt.descriptionClass),t.find("."+i.opt.editableClass));$(this).hasClass(i.opt.formCurrentClass)&&(i.forms[e].refrashable?(i.forms[e].refreshHTML(),a.removeClass(EXPO.company.opt.formCurrentClass)):a.removeClass(i.opt.formCurrentClass))}),i.forms[a].refrashable&&(o.removeClass("hidden"),s.addClass("hidden")),o.addClass(i.opt.formCurrentClass),$(document).on("click.form",function(t){var e=$(t.target);e.parents().filter(".e-form").length<1&&(o.removeClass(i.opt.formCurrentClass),i.forms[r].refreshHTML(),$(document).off("click.form"))}),!1})}),$("#"+i.opt.previewBtnId).attr("href",window.location.href+"?logout=1"),this.map=new r})},a}(); \ No newline at end of file diff --git a/templates/client/static_client/js_min/_modules/page.profile.min.js b/templates/client/static_client/js_min/_modules/page.profile.min.js index 44999626..23fbb9cb 100644 --- a/templates/client/static_client/js_min/_modules/page.profile.min.js +++ b/templates/client/static_client/js_min/_modules/page.profile.min.js @@ -1 +1 @@ -var EXPO=EXPO||{};EXPO.profile?console.warn("WARNING: EXPO.profile is already defined!"):EXPO.profile=function(){function t(t){this.opt=t,this.$inst=$("#"+t.id),this.value=this.$inst.text}function e(){}var a={};a.opt={updateFormClass:"update-profile-form"},a.lang={};var s,r=EXPO.common;return t.prototype={refresh:function(t){this.value=t,this.$inst.text(this.value)}},e.prototype={getajax:function(t){var e=this;t||(t=""),$.ajax({type:"POST",url:e.ajaxPath,data:t,processData:!1,contentType:!1,success:function(t){e.pullHandler(t),t.success&&EXPO.profile.rating.refresh(t.rating),$("#wait-ajax").fadeOut()}})},pushData:function(t,e){var a=this.pushHandler,s=t;this.formData="string"!=typeof s?s:JSON.parse('{"'+decodeURI(s).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"')+'"}'),this.formId=e,"function"==typeof a?(this.formData=a(t,e),this.getajax(t),$("#wait-ajax").show()):(this.getajax(t),$("#wait-ajax").show())},pullData:function(t){var e=this.pullHandler;if("function"!=typeof e)throw{name:"Error",message:" handler function for processing response after form submit not defined, please define it!"};e(t)},fulfillInputs:function(){var t=this;for(input in t.formData)$("#id_"+input,$("#"+t.formId)).length>0&&$("#id_"+input,$("#"+t.formId)).value(t.formData[input]),$("#static-"+input).length>0&&$("#static-"+input).html()},refreshState:function(){var t=$.trim(this.$staticValue.text()).replace(/[^0-9a-zA-Zа-я\s]/g,"").replace(/(\d)\s/,"").replace(/\s+/g,"");(""==$.trim(this.$staticValue.text())||"NoneNone"==t)&&this.$wrapper.length&&this.refrashable?(this.$editable.addClass("hidden"),this.$editable.removeClass(EXPO.profile.opt.formCurrentClass),this.$description.removeClass("hidden")):this.$wrapper.length&&this.refrashable&&(this.$editable.removeClass("hidden"),this.$description.addClass("hidden"))}},e.factory=function(t,a){var s,r=t;if("function"!=typeof e[r])throw{name:"Error",message:r+"doesen't exist"};return"function"!=typeof e[r].prototype.pushData&&(e[r].prototype=new e),s=new e[r](a)},e.home_form=function(t){this.pullHandler=function(t){if(t.success){var e=$("#s2id_id_country").find(".select2-chosen").text(),a=$("#s2id_id_city").find(".select2-chosen").text();$("#static-home-country").text(e),$("#static-home-city").text(a),$(".p-editable").removeClass("pe-current"),this.refreshState()}},this.ajaxPath=t},e.name_form=function(t){this.pullHandler=function(t){t.success&&($("#static-name-value").text($("#id_last_name").val()+" "+$("#id_first_name").val()),$(".p-editable").removeClass("pe-current"),this.refreshState())},this.ajaxPath=t},e.work_form=function(t){this.pullHandler=function(t){var e,a=$.trim($("#s2id_id_company").text());t.success&&(e=$("#id_position").val(),""!=a&&"Поиск компании"!=a&&(e+=" "+EXPO.profile.opt.lang.workIn+" "+a),$("#static-work-value").text(e),$(".p-editable").removeClass("pe-current"),this.refreshState())},this.ajaxPath=t},e.phone_form=function(t){this.pullHandler=function(t){t.success&&($("#static-phone-value").text($("#id_phone")[0].value),$(".p-editable").removeClass("pe-current"),this.refreshState())},this.ajaxPath=t},e.web_page_form=function(t){this.pullHandler=function(t){if(t.success){var e=$("#id_web_page").val();$("#static-web-page-value").attr("href",e).text(e),$(".p-editable").removeClass("pe-current"),this.refreshState()}},this.ajaxPath=t},e.about_form=function(t){this.pullHandler=function(t){t.success&&($("#static-about-value").html(r.nl2br($("#id_about").val())),$(".p-editable").removeClass("pe-current"),this.refreshState())},this.ajaxPath=t},e.social_form=function(t){var e,a,s,r,i=this;this.pullHandler=function(t){if(t.success){for(item in i.formData)s=$("#id_"+item),s.parent(".required").removeClass("err"),""!=$.trim(i.formData[item])&&s.length?(e=$("#img-"+item),e.length&&(r=$.trim(s.val()),e.parent("a").length?(e.parent("a").attr("href",r),a=e.attr("src").replace("_hover",""),e.attr("src",a)):(a=e.attr("src").replace("_hover",""),e.attr("src",a),e.wrap('')))):s.length&&(e=$("#img-"+item),e.parent("a").length&&(a=e.attr("src").replace(".png","_hover.png"),e.attr("src",a),e.unwrap()));$(".p-editable").removeClass("pe-current"),this.refreshState()}else for(item in t.errors)s=$("#id_"+item),s.parent(".required").addClass("err"),s.blur(function(){s.parent(".required").removeClass("err"),i.$form.submit()})},this.pushHandler=function(t,e){var a=$("#"+e).serialize();return JSON.parse('{"'+decodeURI(a).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"')+'"}')},this.refreshState=function(){console.log(this);var t=!0;$("input:text",this.$form).each(function(){""==$.trim($(this).val())&&(t=!1)}),t?($(".full-complete",this.$description).removeClass("hidden"),$(".not-complete",this.$description).addClass("hidden")):($(".full-complete",this.$description).addClass("hidden"),$(".not-complete",this.$description).removeClass("hidden"))},this.ajaxPath=t},e.avatar_form=function(t){var e,a=this,s=$("#id_avatar"),r=($("#pic-edit-photo"),$("#pick-block")),i=$("img",r);this.pullHandler=function(t){t.success&&i.length&&(i.attr("src",t.url),this.refreshState())},this.pushHandler=function(t){"string"!=typeof t?(a.getajax(t),$("#wait-ajax").show()):(e=$("#"+a.formId),e.off("submit"),e.trigger("submit"))},s.on("change",function(){$(this).parents("form").submit()}),this.ajaxPath=t,this.refreshState=function(){$.trim(this.$image.attr("src"))==this.noImageSrc?(this.$editable.addClass("hidden"),this.$description.removeClass("hidden")):(this.$editable.removeClass("hidden"),this.$description.addClass("hidden"))}},e.create_company_form=function(t){var e=this,a="pwf-field";this.pullHandler=function(t){if(t.success)location.reload();else for(var r in t.errors)t.errors.hasOwnProperty(r)&&($('input[name="'+r+'"], select[name="'+r+'"]',e.$form).closest("."+a).addClass("err"),s.hide())},this.ajaxPath=t},a.init=function(a){$.extend(this.lang,a.lang),$.extend(this.opt,a);var r=this,i=function(t){var e=$.masksSort($.masksLoad("/static/client/js/plugins/inputmask/phone-codes.json"),["#"],/[0-9]|#/,"mask"),a={inputmask:{definitions:{"#":{validator:"[0-9]",cardinality:1}},showMaskOnHover:!1,insertMode:!1,autoUnmask:!0},insertMode:!1,match:/[0-9]/,replace:"#",list:e,listKey:"mask",onMaskChange:function(){$(this).attr("placeholder","+_(___)___-__-__")}},s="#"+t;$(s).inputmasks(a)};this.rating=new t(this.opt.rating),this.forms={},$(function(){var t=$("."+r.opt.editableClass),a=$("#"+r.opt.selectBox[0].id),o=$("#"+r.opt.selectBox[2].id),n=$("#id_url");s=$("#wait-ajax").css({"z-index":"8012"}),a.select2({width:"element"}),a.on("change",function(){o.val(0),o.select2("val","")}),$("#"+r.opt.selectBox[1].id).select2({width:"element",placeholder:r.opt.selectBox[1].placeholder,maximumSelectionSize:3}),o.select2({placeholder:r.opt.selectBox[2].placeholder,width:"element",ajax:{url:r.opt.selectBox[2].path,dataType:"json",quietMillis:200,data:function(t,e,a){var a=$("#"+r.opt.selectBox[0].id).val();return{term:t,page:e,country:a}},results:function(t){var e=[];return $.each(t,function(t,a){e.push({id:a.id,text:a.label})}),{results:e}}},initSelection:function(t,e){var a=$(t).val(),s=$(t).attr("data-init-text");e({id:a,text:s})}}),$("#"+r.opt.selectBox[3].id).select2({placeholder:r.opt.selectBox[3].placeholder,width:"200px",minimumInputLength:1,ajax:{url:r.opt.selectBox[3].path,dataType:"json",quietMillis:200,data:function(t,e){return{term:t,page:e}},results:function(t){var e=[];return $.each(t,function(t,a){e.push({id:a.id,text:a.label})}),{results:e}}},initSelection:function(t,e){var a=$(t).val(),s=$(t).attr("data-init-text");e({id:a,text:s})}}),i(r.opt.phoneBox),$("."+r.opt.updateFormClass).each(function(){var a,i=$(this).attr("id"),o=$(this).attr("action"),n=$(this).closest("."+r.opt.formWrapperClass),l=$("."+r.opt.staticValueClass,n),c=$("."+r.opt.descriptionClass,n),p=$("."+r.opt.editableClass,n),h=$("."+r.opt.closeButtonClass,n),d=$("."+r.opt.avatarImageClass,n);r.forms[i]=e.factory(i,o),r.forms[i].refrashable=$("."+r.opt.editButtonClass,n).hasClass("no-refresh")?!1:!0,r.forms[i].$form=$(this),r.forms[i].$wrapper=n,r.forms[i].$staticValue=l,r.forms[i].$description=c,r.forms[i].$editable=p,d.length&&(r.forms[i].$image=d,r.forms[i].noImageSrc=r.opt.noImageSrc),$(this).off("submit"),$(this).on("submit",function(){return s.show(),window.FormData&&"upload"in $.ajaxSettings.xhr()?(a=new FormData(this),r.forms[i].pushData(a,i)):(a=$(this).serialize(),r.forms[i].pushData(a,i)),!1}),h.on("click",function(){return p.removeClass(r.opt.formCurrentClass),r.forms[i].refreshState(),!1}),$("."+r.opt.avatarButtonClass,n).length?$("."+r.opt.editButtonClass+", ."+r.opt.avatarButtonClass,n).on("click",function(){var t=$("#"+r.opt.avatarInputId);return t.trigger("click"),!1}):$("."+r.opt.editButtonClass+", ."+r.opt.avatarButtonClass,n).on("click",function(){var e=$(this).closest("."+r.opt.formWrapperClass),a=e.find("."+r.opt.updateFormClass).attr("id"),s=e.find("."+r.opt.descriptionClass),o=e.find("."+r.opt.editableClass);return t.each(function(){var t=$(this).closest("."+r.opt.formWrapperClass),e=t.find("."+r.opt.updateFormClass).attr("id"),a=(t.find("."+r.opt.descriptionClass),t.find("."+r.opt.editableClass));$(this).hasClass(r.opt.formCurrentClass)&&(r.forms[e].refrashable?(r.forms[e].refreshState(),a.removeClass(EXPO.profile.opt.formCurrentClass)):a.removeClass(r.opt.formCurrentClass))}),r.forms[a].refrashable&&(o.removeClass("hidden"),s.addClass("hidden")),o.addClass(r.opt.formCurrentClass),$(document).on("click.form",function(t){var e=$(t.target);e.parents().filter(".e-form").length<1&&(o.removeClass(r.opt.formCurrentClass),r.forms[i].refreshState(),$(document).off("click.form"))}),!1})}),$("#"+r.opt.addCompanyButtonId).on("click",function(t){return t.preventDefault(),$.fancybox.open("#"+r.opt.addCompany.modalId),!1}),n.on("focus",function(){var t=$(this),e=r.opt.companyAddInputMask;return""==$.trim(t.val())&&t.val(e),!1}),n.on("click",function(){if(this.setSelectionRange&&$.trim($(this).val())==r.opt.companyAddInputMask){var t=$(this).val().length;this.setSelectionRange(t,t)}}),n.on("keypress",function(){var t=$(this),e=r.opt.companyAddInputMask;""==$.trim(t.val())&&t.val(e)}),n.on("blur",function(){var t=$(this),e=r.opt.companyAddInputMask;$.trim(t.val())==e&&t.val("")})})},a}(); \ No newline at end of file +var EXPO=EXPO||{};EXPO.profile?console.warn("WARNING: EXPO.profile is already defined!"):EXPO.profile=function(){function t(t){this.opt=t,this.$inst=$("#"+t.id),this.value=this.$inst.text}function e(){}var a={};a.opt={updateFormClass:"update-profile-form"},a.lang={};var s,r=EXPO.common;return t.prototype={refresh:function(t){this.value=t,this.$inst.text(this.value)}},e.prototype={submit:function(t){var e=this;t||(t=""),$.ajax({type:"POST",url:e.ajaxPath,data:t,processData:!1,contentType:!1,success:function(t){e.afterSubmitHandler(t),t.success&&EXPO.profile.rating.refresh(t.rating),$("#wait-ajax").fadeOut()}})},beforeSubmit:function(t,e){var a=this.beforeSubmitHandler,s=t;this.formData="string"!=typeof s?s:JSON.parse('{"'+decodeURI(s).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"')+'"}'),this.formId=e,"function"==typeof a?(this.formData=a(t,e),this.submit(t),$("#wait-ajax").show()):(this.submit(t),$("#wait-ajax").show())},afterSubmit:function(t){var e=this.afterSubmitHandler;if("function"!=typeof e)throw{name:"Error",message:" handler function for processing response after form submit not defined, please define it!"};e(t)},fulfillInputs:function(){var t=this;for(input in t.formData)$("#id_"+input,$("#"+t.formId)).length>0&&$("#id_"+input,$("#"+t.formId)).value(t.formData[input]),$("#static-"+input).length>0&&$("#static-"+input).html()},refreshHTML:function(){var t=$.trim(this.$staticValue.text()).replace(/[^0-9a-zA-Zа-я\s]/g,"").replace(/(\d)\s/,"").replace(/\s+/g,"");(""==$.trim(this.$staticValue.text())||"NoneNone"==t)&&this.$wrapper.length&&this.refrashable?(this.$editable.addClass("hidden"),this.$editable.removeClass(EXPO.profile.opt.formCurrentClass),this.$description.removeClass("hidden")):this.$wrapper.length&&this.refrashable&&(this.$editable.removeClass("hidden"),this.$description.addClass("hidden"))}},e.factory=function(t,a){var s,r=t;if("function"!=typeof e[r])throw{name:"Error",message:r+"doesen't exist"};return"function"!=typeof e[r].prototype.beforeSubmit&&(e[r].prototype=new e),s=new e[r](a)},e.home_form=function(t){this.afterSubmitHandler=function(t){if(t.success){var e=$("#s2id_id_country").find(".select2-chosen").text(),a=$("#s2id_id_city").find(".select2-chosen").text();$("#static-home-country").text(e),$("#static-home-city").text(a),$(".p-editable").removeClass("pe-current"),this.refreshHTML()}},this.ajaxPath=t},e.name_form=function(t){this.afterSubmitHandler=function(t){t.success&&($("#static-name-value").text($("#id_last_name").val()+" "+$("#id_first_name").val()),$(".p-editable").removeClass("pe-current"),this.refreshHTML())},this.ajaxPath=t},e.work_form=function(t){this.afterSubmitHandler=function(t){var e,a=$.trim($("#s2id_id_company").text());t.success&&(e=$("#id_position").val(),""!=a&&"Поиск компании"!=a&&(e+=" "+EXPO.profile.opt.lang.workIn+" "+a),$("#static-work-value").text(e),$(".p-editable").removeClass("pe-current"),this.refreshHTML())},this.ajaxPath=t},e.phone_form=function(t){this.afterSubmitHandler=function(t){t.success&&($("#static-phone-value").text($("#id_phone")[0].value),$(".p-editable").removeClass("pe-current"),this.refreshHTML())},this.ajaxPath=t},e.web_page_form=function(t){this.afterSubmitHandler=function(t){if(t.success){var e=$("#id_web_page").val();$("#static-web-page-value").attr("href",e).text(e),$(".p-editable").removeClass("pe-current"),this.refreshHTML()}},this.ajaxPath=t},e.about_form=function(t){this.afterSubmitHandler=function(t){t.success&&($("#static-about-value").html(r.nl2br($("#id_about").val())),$(".p-editable").removeClass("pe-current"),this.refreshHTML())},this.ajaxPath=t},e.social_form=function(t){var e,a,s,r,i=this;this.afterSubmitHandler=function(t){if(t.success){for(item in i.formData)s=$("#id_"+item),s.parent(".required").removeClass("err"),""!=$.trim(i.formData[item])&&s.length?(e=$("#img-"+item),e.length&&(r=$.trim(s.val()),e.parent("a").length?(e.parent("a").attr("href",r),a=e.attr("src").replace("_hover",""),e.attr("src",a)):(a=e.attr("src").replace("_hover",""),e.attr("src",a),e.wrap('')))):s.length&&(e=$("#img-"+item),e.parent("a").length&&(a=e.attr("src").replace(".png","_hover.png"),e.attr("src",a),e.unwrap()));$(".p-editable").removeClass("pe-current"),this.refreshHTML()}else for(item in t.errors)s=$("#id_"+item),s.parent(".required").addClass("err"),s.blur(function(){s.parent(".required").removeClass("err"),i.$form.submit()})},this.beforeSubmitHandler=function(t,e){var a=$("#"+e).serialize();return JSON.parse('{"'+decodeURI(a).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"')+'"}')},this.refreshHTML=function(){console.log(this);var t=!0;$("input:text",this.$form).each(function(){""==$.trim($(this).val())&&(t=!1)}),t?($(".full-complete",this.$description).removeClass("hidden"),$(".not-complete",this.$description).addClass("hidden")):($(".full-complete",this.$description).addClass("hidden"),$(".not-complete",this.$description).removeClass("hidden"))},this.ajaxPath=t},e.avatar_form=function(t){var e,a=this,s=$("#id_avatar"),r=($("#pic-edit-photo"),$("#pick-block")),i=$("img",r);this.afterSubmitHandler=function(t){t.success&&i.length&&(i.attr("src",t.url),this.refreshHTML())},this.beforeSubmitHandler=function(t){"string"!=typeof t?(a.submit(t),$("#wait-ajax").show()):(e=$("#"+a.formId),e.off("submit"),e.trigger("submit"))},s.on("change",function(){$(this).parents("form").submit()}),this.ajaxPath=t,this.refreshHTML=function(){$.trim(this.$image.attr("src"))==this.noImageSrc?(this.$editable.addClass("hidden"),this.$description.removeClass("hidden")):(this.$editable.removeClass("hidden"),this.$description.addClass("hidden"))}},e.create_company_form=function(t){var e=this,a="pwf-field";this.afterSubmitHandler=function(t){if(t.success)location.reload();else for(var r in t.errors)t.errors.hasOwnProperty(r)&&($('input[name="'+r+'"], select[name="'+r+'"]',e.$form).closest("."+a).addClass("err"),s.hide())},this.ajaxPath=t},a.init=function(a){$.extend(this.lang,a.lang),$.extend(this.opt,a);var r=this,i=function(t){var e=$.masksSort($.masksLoad("/static/client/js/plugins/inputmask/phone-codes.json"),["#"],/[0-9]|#/,"mask"),a={inputmask:{definitions:{"#":{validator:"[0-9]",cardinality:1}},showMaskOnHover:!1,insertMode:!1,autoUnmask:!0},insertMode:!1,match:/[0-9]/,replace:"#",list:e,listKey:"mask",onMaskChange:function(){$(this).attr("placeholder","+_(___)___-__-__")}},s="#"+t;$(s).inputmasks(a)};this.rating=new t(this.opt.rating),this.forms={},$(function(){var t=$("."+r.opt.editableClass),a=$("#"+r.opt.selectBox[0].id),o=$("#"+r.opt.selectBox[2].id),n=$("#id_url");s=$("#wait-ajax").css({"z-index":"8012"}),a.select2({width:"element"}),a.on("change",function(){o.val(0),o.select2("val","")}),$("#"+r.opt.selectBox[1].id).select2({width:"element",placeholder:r.opt.selectBox[1].placeholder,maximumSelectionSize:3}),o.select2({placeholder:r.opt.selectBox[2].placeholder,width:"element",ajax:{url:r.opt.selectBox[2].path,dataType:"json",quietMillis:200,data:function(t,e,a){var a=$("#"+r.opt.selectBox[0].id).val();return{term:t,page:e,country:a}},results:function(t){var e=[];return $.each(t,function(t,a){e.push({id:a.id,text:a.label})}),{results:e}}},initSelection:function(t,e){var a=$(t).val(),s=$(t).attr("data-init-text");e({id:a,text:s})}}),$("#"+r.opt.selectBox[3].id).select2({placeholder:r.opt.selectBox[3].placeholder,width:"200px",minimumInputLength:1,ajax:{url:r.opt.selectBox[3].path,dataType:"json",quietMillis:200,data:function(t,e){return{term:t,page:e}},results:function(t){var e=[];return $.each(t,function(t,a){e.push({id:a.id,text:a.label})}),{results:e}}},initSelection:function(t,e){var a=$(t).val(),s=$(t).attr("data-init-text");e({id:a,text:s})}}),i(r.opt.phoneBox),$("."+r.opt.updateFormClass).each(function(){var a,i=$(this).attr("id"),o=$(this).attr("action"),n=$(this).closest("."+r.opt.formWrapperClass),l=$("."+r.opt.staticValueClass,n),c=$("."+r.opt.descriptionClass,n),f=$("."+r.opt.editableClass,n),u=$("."+r.opt.closeButtonClass,n),h=$("."+r.opt.avatarImageClass,n);r.forms[i]=e.factory(i,o),r.forms[i].refrashable=$("."+r.opt.editButtonClass,n).hasClass("no-refresh")?!1:!0,r.forms[i].$form=$(this),r.forms[i].$wrapper=n,r.forms[i].$staticValue=l,r.forms[i].$description=c,r.forms[i].$editable=f,h.length&&(r.forms[i].$image=h,r.forms[i].noImageSrc=r.opt.noImageSrc),$(this).off("submit"),$(this).on("submit",function(){return s.show(),window.FormData&&"upload"in $.ajaxSettings.xhr()?(a=new FormData(this),r.forms[i].beforeSubmit(a,i)):(a=$(this).serialize(),r.forms[i].beforeSubmit(a,i)),!1}),u.on("click",function(){return f.removeClass(r.opt.formCurrentClass),r.forms[i].refreshHTML(),!1}),$("."+r.opt.avatarButtonClass,n).length?$("."+r.opt.editButtonClass+", ."+r.opt.avatarButtonClass,n).on("click",function(){var t=$("#"+r.opt.avatarInputId);return t.trigger("click"),!1}):$("."+r.opt.editButtonClass+", ."+r.opt.avatarButtonClass,n).on("click",function(){var e=$(this).closest("."+r.opt.formWrapperClass),a=e.find("."+r.opt.updateFormClass).attr("id"),s=e.find("."+r.opt.descriptionClass),o=e.find("."+r.opt.editableClass);return t.each(function(){var t=$(this).closest("."+r.opt.formWrapperClass),e=t.find("."+r.opt.updateFormClass).attr("id"),a=(t.find("."+r.opt.descriptionClass),t.find("."+r.opt.editableClass));$(this).hasClass(r.opt.formCurrentClass)&&(r.forms[e].refrashable?(r.forms[e].refreshHTML(),a.removeClass(EXPO.profile.opt.formCurrentClass)):a.removeClass(r.opt.formCurrentClass))}),r.forms[a].refrashable&&(o.removeClass("hidden"),s.addClass("hidden")),o.addClass(r.opt.formCurrentClass),$(document).on("click.form",function(t){var e=$(t.target);e.parents().filter(".e-form").length<1&&(o.removeClass(r.opt.formCurrentClass),r.forms[i].refreshHTML(),$(document).off("click.form"))}),!1})}),$("#"+r.opt.addCompanyButtonId).on("click",function(t){return t.preventDefault(),$.fancybox.open("#"+r.opt.addCompany.modalId),!1}),n.on("focus",function(){var t=$(this),e=r.opt.companyAddInputMask;return""==$.trim(t.val())&&t.val(e),!1}),n.on("click",function(){if(this.setSelectionRange&&$.trim($(this).val())==r.opt.companyAddInputMask){var t=$(this).val().length;this.setSelectionRange(t,t)}}),n.on("keypress",function(){var t=$(this),e=r.opt.companyAddInputMask;""==$.trim(t.val())&&t.val(e)}),n.on("blur",function(){var t=$(this),e=r.opt.companyAddInputMask;$.trim(t.val())==e&&t.val("")})})},a}(); \ No newline at end of file