expo-20 (not tested)

remotes/origin/1203
pavel 11 years ago
parent c13b975635
commit daa1225738
  1. 243
      templates/client/includes/accounts/current_user.html
  2. 8
      templates/client/popups/create_company.html
  3. 47
      templates/client/static_client/css/main.css
  4. 131
      templates/client/static_client/js/_modules/page.profile.js
  5. 2
      templates/client/static_client/js_min/_modules/page.profile.min.js

@ -9,40 +9,43 @@
{# avatar #}
<aside>
<div class="i-pict p-editable">
{% if request.user.profile.avatar %}
<div id="pick-block" class="pic_block">
{% endif %}
{% thumbnail request.user.profile.avatar "100x100" crop="center" as im %}
<img clas="user-avatar" src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
{% endthumbnail %}
{% if request.user.profile.avatar %}
</div>
{% endif %}
<div class="edit-wrap">
<a class="e-btn" href="#">{% trans 'редактировать' %}</a>
<div class="e-form">
<form class="clearfix update-profile-form" enctype="multipart/form-data" id="avatar_form"action="/profile/update/avatar/" method="post">{% csrf_token %}
<div class="ef-body">
<div class="epfl">
<label>{{ avatar_form.avatar.label }}</label>
<div class="epf-field">
<div class="input-file clearfix">
<div class="button icon-clip">{% trans 'выберите файл' %}</div>
<div class="file-text placehlder">{% trans 'Файл не выбран' %}</div>
<div class="if-field-wrap"><input id="id_avatar" type="file" name="avatar" /></div>
<div class="form-item-wrap">
<div class="i-pict p-editable editable-wrap">
{% if request.user.profile.avatar %}
<div id="pick-block" class="pic_block">
{% endif %}
{% thumbnail request.user.profile.avatar "100x100" crop="center" as im %}
<img class="user-avatar" src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"/>
{% endthumbnail %}
{% if request.user.profile.avatar %}
</div>
{% endif %}
<div class="edit-wrap">
<a class="e-btn no-refresh" href="#">{% trans 'редактировать' %}</a>
<div class="e-form">
<form class="clearfix update-profile-form" enctype="multipart/form-data" id="avatar_form"action="/profile/update/avatar/" method="post">{% csrf_token %}
<div class="ef-body">
<div class="epfl">
<label>{{ avatar_form.avatar.label }}</label>
<div class="epf-field">
<div class="input-file clearfix">
<div class="button icon-clip">{% trans 'выберите файл' %}</div>
<div class="file-text placehlder">{% trans 'Файл не выбран' %}</div>
<div class="if-field-wrap"><input id="id_avatar" type="file" name="avatar" /></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="ef-buttons">
<button type="submit" class="lnk icon-save">{% trans 'Сохранить' %}</button>
</div>
</form>
<a class="ef-close" href="#">{% trans 'закрыть' %}</a>
<div class="ef-buttons">
<button type="submit" class="lnk icon-save">{% trans 'Сохранить' %}</button>
</div>
</form>
<a class="ef-close" href="#">{% trans 'закрыть' %}</a>
</div>
</div>
</div>
</div>
@ -53,108 +56,113 @@
</div>
</aside>
{# END avatar #}
<div class="i-info">
<div class="i-info ">
<header>
{# country and city #}
<div class="i-place p-editable">
{% if home_form.instance.country %}
<div class="form-item-wrap">
<div class="i-descr add_link_text ">
<a class="e-btn" href="#" title="">{% trans 'Указать' %}</a>
<div class="add_link_text_text">{% trans 'Страну и город' %}<b>+10</b></div>
</div>
<div class="i-place p-editable editable-wrap hidden">
{% else %}
<span style="display:none;">
{% endif %}
<span class="static-value">
<span id="static-home-country">{{ home_form.instance.country }}</span>
</span>
{% if home_form.instance.city %}
, <span id="static-home-city">{{ home_form.instance.city }}</span>
{% else %}
<span style="display:none;">
{% endif %}
, <span id="static-home-city">{{ home_form.instance.city }}</span>
</span>
<div class="edit-wrap e-left">
<a class="e-btn" href="#">{% trans 'редактировать' %}</a>
<div class="e-form">
<form class="clearfix update-profile-form" id="home_form" action="/profile/update/home/" method="post">{% csrf_token %}
<div class="ef-body">
<div class="epfl">
<label>{{ home_form.country.label }}</label>
<div class="epf-field">
{{ home_form.country }}
<div class="edit-wrap e-left">
<a class="e-btn" href="#">{% trans 'редактировать' %}</a>
<div class="e-form">
<form class="clearfix update-profile-form" id="home_form" action="/profile/update/home/" method="post">{% csrf_token %}
<div class="ef-body">
<div class="epfl">
<label>{{ home_form.country.label }}</label>
<div class="epf-field">
{{ home_form.country }}
</div>
</div>
</div>
<div class="epfl">
<label>{% trans 'Город' %}</label>
<div class="epf-field">
{{ home_form.city }}
<div class="epfl">
<label>{% trans 'Город' %}</label>
<div class="epf-field">
{{ home_form.city }}
</div>
</div>
</div>
</div>
</div>
<div class="ef-buttons">
<button type="submit" class="lnk icon-save">{% trans 'Сохранить' %}</button>
</div>
</form>
<a class="ef-close" href="#">{% trans 'закрыть' %}</a>
<div class="ef-buttons">
<button type="submit" class="lnk icon-save">{% trans 'Сохранить' %}</button>
</div>
</form>
<a class="ef-close" href="#">{% trans 'закрыть' %}</a>
</div>
</div>
</div>
</div>
{# END country and city #}
{# name #}
<div class="i-title p-editable">
<span id="static-name-value">
<div class="form-item-wrap">
<div class="i-descr add_link_text ">
<a class="e-btn" href="#" title="">{% trans 'Указать' %}</a>
<div class="add_link_text_text">{% trans 'имя и фамилию' %}<b>+10</b></div>
</div>
<div class="i-title p-editable editable-wrap">
<span id="static-name-value" class="static-value">
{{ name_form.get_full_name }}
</span>
<div class="edit-wrap">
<a class="e-btn" href="#">{% trans 'редактировать' %}</a>
<div class="e-form">
<form class="clearfix update-profile-form" id="name_form" action="/profile/update/name/"
method="post" method="post">{% csrf_token %}
<div class="ef-body">
<div class="epfl">
<label>{{ name_form.first_name.label }}</label>
<div class="epf-field">
{{ name_form.first_name }}
</div>
</div>
<div class="epfl">
<label>{{ name_form.last_name.label }}</label>
<div class="epf-field">
{{ name_form.last_name }}
<div class="edit-wrap">
<a class="e-btn" href="#">{% trans 'редактировать' %}</a>
<div class="e-form">
<form class="clearfix update-profile-form" id="name_form" action="/profile/update/name/"
method="post" method="post">{% csrf_token %}
<div class="ef-body">
<div class="epfl">
<label>{{ name_form.first_name.label }}</label>
<div class="epf-field">
{{ name_form.first_name }}
</div>
</div>
<div class="epfl">
<label>{{ name_form.last_name.label }}</label>
<div class="epf-field">
{{ name_form.last_name }}
</div>
</div>
</div>
</div>
</div>
<div class="ef-buttons">
<button type="submit" class="lnk icon-save">{% trans 'Сохранить' %}</button>
</div>
</form>
<div class="ef-buttons">
<button type="submit" class="lnk icon-save">{% trans 'Сохранить' %}</button>
</div>
</form>
<a class="ef-close" href="#">{% trans 'закрыть' %}</a>
</div>
</div>
<a class="ef-close" href="#">{% trans 'закрыть' %}</a>
</div>
</div>
</div>
</div>
{# END name #}
</header>
{# position #}
<div class="work_form-wrap">
<div class="form-item-wrap">
<div class="i-descr add_link_text ">
<a class="e-btn" href="#" title="">{% trans 'Указать' %}</a>
<div class="add_link_text_text">{% trans 'свою должность и место работы' %}<b>+10</b></div>
</div>
<div class="i-position p-editable hidden">
<p id="static-work-value ">
<div class="i-position p-editable editable-wrap hidden">
<p id="static-work-value" class="static-value">
{{ work_form.position.value }}
{% if work_form.work.value %}
{% trans 'в' %} {{ work_form.work.value }}
@ -199,10 +207,10 @@
<div class="i-contacts clearfix">
<div class="ic-buttons dd_width_4">
<div class="social_form-wrap">
<div class="p-editable">
<div class="form-item-wrap">
<div class="p-editable editable-wrap social">
<div class="i-descr add_link_text add_link_text_medium">
<a class="e-btn" href="#" title="">{% trans 'Добавить' %}</a>
<a class="e-btn no-refresh social" href="#" title="">{% trans 'Добавить' %}</a>
<ul class="soc-media-buttons soc-media-buttons1">
<li>
@ -248,8 +256,10 @@
</div>
<div class="edit-wrap">
<div class="edit-wrap ">
<div class="e-form">
<div class="edit-label"><span>&nbsp;</span></div>
<form class="clearfix update-profile-form" id="social_form" action="/profile/update/social/" method="post">{% csrf_token %}
<div class="ef-body">
@ -298,14 +308,14 @@
</div>
{# contacts #}
<div class="ic-links dd_width_5">
<div class="phone_form-wrap">
<div class="p-editable add_link_text add_link_text_medium">
<div class="form-item-wrap">
<div class="i-descr add_link_text add_link_text_medium">
<a class="e-btn" href="#" title="">{% trans 'Добавить' %}</a>
<div class="add_link_text_text">{% trans 'номер телефона' %} <b>+15</b></div>
</div>
<div class="ic-tel p-editable hidden">
<div class="ic-tel p-editable editable-wrap hidden">
{% if phone_form.phone.value %}
<span id="static-phone-value">{{ phone_form.phone.value|phone }}</span>
<span id="static-phone-value" class="static-value">{{ phone_form.phone.value|phone }}</span>
{% endif %}
<div class="edit-wrap">
<a class="e-btn" href="#">{% trans 'редактировать' %}</a>
@ -364,14 +374,14 @@
</div>
</div>
{% endcomment %}
<div class="web_page_form-wrap">
<div class="ic-site p-editable add_link_text add_link_text_medium">
<div class="form-item-wrap">
<div class=" i-descr ic-site p-editable add_link_text add_link_text_medium">
<a class="e-btn" href="#" title="">{% trans 'Добавить' %}</a>
<div class="add_link_text_text">{% trans 'сайт' %} <b>+5</b></div>
</div>
<div class="ic-site p-editable hidden">
<div class="ic-site p-editable editable-wrap hidden">
{% if web_page_form.web_page.value %}
<a class="icon-ext-link" id="static-web-page-value" href="{% if web_page_form.web_page.value %}{{ web_page_form.web_page.value }}{% else %}#{% endif %}" target="_blank">
<a class="icon-ext-link static-value" id="static-web-page-value" href="{% if web_page_form.web_page.value %}{{ web_page_form.web_page.value }}{% else %}#{% endif %}" target="_blank">
{% if web_page_form.web_page.value %}
{{ web_page_form.web_page.value }}
{% endif %}
@ -413,13 +423,13 @@
{# about #}
<div class="i-additional">
<div class="ia-title">{% trans 'О себе:' %}</div>
<div class="about_form-wrap">
<div class="p-editable add_link_text">
<div class="form-item-wrap">
<div class="i-descr add_link_text">
<a class="e-btn" href="#" title="">{% trans 'Добавить' %}</a>
<div class="add_link_text_text">{% trans 'информацию о себе' %} <b>+10</b></div>
</div>
<div class="p-editable hidden">
<p id="static-about-value">{{ about_form.about.value }}</p>
<div class="p-editable editable-wrap hidden">
<p id="static-about-value" class="static-value">{{ about_form.about.value }}</p>
<div class="edit-wrap">
<a class="e-btn" href="#">{% trans 'редактировать' %}</a>
@ -497,7 +507,12 @@
// class selector to identify required forms on page
updateFormClass:'update-profile-form',
// text part that is added to form id to designate its wrapper container
formContainerPostfix:'-wrap',
formWrapperClass:'form-item-wrap',
formCurrentClass:'pe-current',
staticValueClass:'static-value',
descriptionClass:'i-descr',
editableClass:'editable-wrap',
closeButtonClass:'ef-close',
// text and paths for dynamically rendered selectboxes
addCompanyButtonId:'add-new-company',
selectBox:[

@ -1,14 +1,14 @@
{% load static %}
{% load i18n %}
<div id="pw-company" class="popup-window pw-reg">
<div id="pw-company" class="popup-window pw-reg create-company-modal">
<header class="clearfix">
<div class="pw-title">{% trans 'Создание компании' %}</div>
</header>
<div class="pw-body clearfix">
<form id="create_company_form" method="post" class="pw-form update-profile-form" action="{{ form.action }}">{% csrf_token %}
<div class="pwf-line">
<div class="pwf-field">
<div class="pwf-field required">
{{ form.name }}
</div>
<div class="pwf-msg">
@ -17,7 +17,7 @@
</div>
<div class="pwf-line">
<div class="pwf-field">
<div class="pwf-field required">
{{ form.url }}
</div>
<div class="pwf-msg">
@ -26,7 +26,7 @@
</div>
<div class="pwf-line">
<div class="pwf-field">
<div class="pwf-field select-input required">
{{ form.theme }}
</div>
</div>

@ -12370,6 +12370,7 @@ hr + .rq-note {
width: 15px;
height: 16px;
background: transparent url(../img/sprites.png) -360px -159px;
z-index: 1;
}
.err-message-box{
display: none !important;
@ -12848,6 +12849,52 @@ hr + .rq-note {
.edit-profile .ic-buttons .p-editable{
padding-left: 0;
}
.create-company-modal .select-input.err{
width: auto;
}
.create-company-modal .select-input.err .select2-choices{
border-color: #d80000;
border-width: 2px;
}
.p-editable.pe-current .e-btn.social{
background-color: transparent;
}
.p-editable.pe-current .e-btn.social:before{
display: none;
}
.p-editable.social .edit-label{
display: none;
}
.p-editable.pe-current.social .e-form:before{
display: none;
}
.p-editable.pe-current.social .edit-label{
display: block;
width: 24px;
margin-left: -24px;
padding-left: 5px;
padding-top: 4px;
padding-bottom: 4px;
background-color: #ff6600;
position: absolute;
top: 0;
left: 0;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 0;
border-top-left-radius: 3px;
border-top-right-radius: 0;
}
.p-editable.pe-current.social .edit-label span{
display: block;
width: 18px;
height: 16px;
background: #ff6600 url(../img/sprites.png) -136px -145px no-repeat;
}
/*.create-company-modal .select-input.err:before{*/
/*margin-right: 0;*/
/*}*/
/************************\
# страница редактирования профиля

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

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