Commit f6aa134a by Mykhailo Makohin

make ajax request in funding

parent 09b64583
......@@ -23,7 +23,7 @@ gem 'haml'
gem 'bootstrap-sass'
gem 'gmaps4rails'
gem 'remotipart'
gem 'simple_form', '~> 5.0', '>= 5.0.1'
gem 'simple_form', '~> 4.0', '>= 4.0.1'
gem 'activeadmin'
gem 'carrierwave'
gem 'cancancan'
......
......@@ -270,7 +270,7 @@ GEM
tilt (>= 1.1, < 3)
sassc (2.2.1)
ffi (~> 1.9)
simple_form (5.0.1)
simple_form (4.1.0)
actionpack (>= 5.0)
activemodel (>= 5.0)
spring (2.0.2)
......@@ -353,7 +353,7 @@ DEPENDENCIES
ransack
remotipart
sass-rails (~> 5.0)
simple_form (~> 5.0, >= 5.0.1)
simple_form (~> 4.0, >= 4.0.1)
spring
spring-watcher-listen (~> 2.0.0)
turbolinks (~> 5)
......
<svg id="SvgjsSvg1016" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" width="12" height="11"><defs id="SvgjsDefs1017"></defs><path id="SvgjsPath1018" d="M1102.54 604.464C1104.49 606.417 1104.49 609.5830000000001 1102.54 611.5350000000001C1100.58 613.488 1097.42 613.488 1095.46 611.5350000000001C1093.51 609.5830000000001 1093.51 606.417 1095.46 604.464C1097.42 602.5120000000001 1100.58 602.5120000000001 1102.54 604.464Z " fill="#ff6c6c" transform="matrix(1,0,0,1,-1093,-602)"></path><path id="SvgjsPath1019" d="M1097 609L1097 607L1101 607L1101 609Z " fill="#ffffff" transform="matrix(1,0,0,1,-1093,-602)"></path></svg>
\ No newline at end of file
<svg id="SvgjsSvg1008" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" width="12" height="11"><defs id="SvgjsDefs1009"></defs><path id="SvgjsPath1010" d="M1102.54 534.464C1104.49 536.417 1104.49 539.5830000000001 1102.54 541.5350000000001C1100.58 543.488 1097.42 543.488 1095.46 541.5350000000001C1093.51 539.5830000000001 1093.51 536.417 1095.46 534.464C1097.42 532.5120000000001 1100.58 532.5120000000001 1102.54 534.464Z " fill="#50d8c4" transform="matrix(1,0,0,1,-1093,-532)"></path><path id="SvgjsPath1011" d="M1102 537L1101 536L1098.5 538.5L1097 537L1096 538L1099 541L1099 540Z " fill="#ffffff" transform="matrix(1,0,0,1,-1093,-532)"></path></svg>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
try{
++ /dev/null
try{
s_Q("r36a9c");
var s_GTa=s_S("r36a9c");
var s_HTa=function(a){return null!=a&&0<a.getBoundingClientRect().width&&0<a.getBoundingClientRect().height?(a=window.getComputedStyle(a,null),"none"!==a.display&&"hidden"!==a.visibility&&"auto"===a.clip):!1},s_ITa=function(a){s_h.call(this,a.Pa)};s_k(s_ITa,s_h);s_ITa.Ka=s_h.Ka;
s_ITa.prototype.$ub=function(){var a=this.Ia("BKxS1e").el();s_f(a);a=s_Wi(this.XE().documentElement).find('[role="heading"], h1, h2, h3').filter(s_HTa).Ng();if(!s_yf(a.el())){if(null==s_Ti(a,"aria-label")&&null==s_Ti(a,"aria-describedby")){var b=s_Ri(a);if(s_HTa(b.el())&&"A"==b.el().tagName){b.focus();return}b=a.children().filter(s_HTa);if(1==b.size()&&"A"==b.Ng().el().tagName){b.Ng().focus();return}}a.el().tabIndex="-1";a.el().onblur=function(c){c.target.removeAttribute("tabIndex")}}a.focus()};
s_Y(s_ITa.prototype,"i3viod",function(){return this.$ub});s_Z(s_GTa,s_ITa);
s_g().$();
}catch(e){_DumpException(e)}
// Google Inc.
......@@ -11,6 +11,7 @@
// about supported directives.
//
//= require jquery
//= require turbolinks
//= require jquery-ui
//= require jBox.all
//= require demo
......@@ -26,6 +27,7 @@
//= require freewall
//= require underscore
//= require jquery.autocomplete
//= require autocompleteUser
//= require gmaps/google
//= require squares
//= require ckeditor/init
......
initUser = (user_email) ->
$.ajax
type: 'GET'
url: '/autocomplete_user'
data: {email: user_email}
success: (data) ->
console.log data
if (data[0] && data[0]['email'] && data[0]['name'])
$('span.error_text').text('').end()
$('div.field_with_errors').removeClass('form_error')
$('#bottom_message').text(data[1])
console.log('if')
console.log(user_email)
$("#user_email").val(user_email)
$("#user_name").val(data[0]['name'])
$('div.field_wrap').addClass('form_ok')
$(".user_location").val(data[0]['location'])
if data[0]['is_signed']
$('#user_check').prop('checked',true)
$('#user_check_map').prop('checked',true)
else
console.log('else')
$('span.error_text').text('').end()
$('#bottom_message').text('')
$("#user_name").val('')
$(".user_location").val('')
$('#user_check').prop('checked',false)
$('#user_check_map').prop('checked',false)
$('div.field_wrap').removeClass('form_ok')
$('div.field_with_errors').removeClass('form_error')
$('div.field_with_errors').removeClass('form_ok')
$('div.form-group').removeClass('form_ok')
$(document).ready ->
$('body').on 'keyup', '#user_email', (e) ->
user_email = $(this).val()
initUser(user_email)
\ No newline at end of file
......@@ -21,7 +21,7 @@ jQuery(document).ready(function($){
//mobilePartners();
// initTip();
// initMap();
initBookmarkAnimation();
// initBookmarkAnimation();
initLoadMore();
initSlider();
topTip();
......@@ -33,21 +33,23 @@ jQuery(document).ready(function($){
// $('[data-toggle="popover"]').popover({title: "<span class=\"usr_surname\">Фондар</span><span class=\"usr_name\">Вікторія Тараневська <a href=\"#\" class=\"round_link\"><i class=\"icon icon_fb\"></i></span>", content: "<div class=\"usr_contributions\">Внесків 3</div><div class=\"usr_funds\"><div class=\"usr_funds_value\">на суму: 14 200 UAH</div></div><div class=\"usr_volunteering\">Волонтерство 2</div>", html: true, placement: "top"});
})
function initBookmarkAnimation(){
let anchorlinks = document.querySelectorAll('a[href^="#"]')
for (let item of anchorlinks) { // relitere
item.addEventListener('click', (e)=> {
let hashval = item.getAttribute('href')
let target = document.querySelector(hashval)
target.scrollIntoView({
behavior: 'smooth'
})
history.pushState(null, null, hashval)
e.preventDefault()
})
}
}
// function initBookmarkAnimation(){
// let anchorlinks = document.querySelectorAll('a[href^="#"]')
// for (let item of anchorlinks) { // relitere
// item.addEventListener('click', (e)=> {
// let hashval = item.getAttribute('href')
// let target = document.querySelector(hashval)
// target.scrollIntoView({
// behavior: 'smooth'
// })
// history.pushState(null, null, hashval)
// e.preventDefault()
// })
// }
// }
function initLoadMore(){
$(document).ready(function(){
......
......@@ -5,6 +5,7 @@ class ContributionsController < ApplicationController
if @contrbution.save
redirect_to root_path
else
ap @contrbution.errors
head :ok
end
end
......
class ProjectsController < ApplicationController
respond_to :js
def show
@project = Project.friendly.find(params[:id])
end
......
......@@ -16,10 +16,14 @@ class UsersController < ApplicationController
def create
@user = User.find_or_create_by(user_params)
@user.skip_password_validation = true
if @user.save
redirect_to root_path
else
redirect_to root_path
respond_to do |format|
if @user.save
format.html { redirect_to root_path }
format.js
else
format.html
format.js
end
end
end
......@@ -40,7 +44,15 @@ class UsersController < ApplicationController
def destroy
@user = resource
@user.destroy
end
def autocomplete_user
@user = User.find_by(email: params[:email])
if @user
render status: 200, json: [@user, t('activerecord.errors.models.user.attributes.email.taken')]
else
render json: 0
end
end
private
......
class Contribution < ApplicationRecord
belongs_to :user
belongs_to :project
validates :contribution, presence: true
validates :contribution, presence: true, numericality: { only_integer: true }
end
class User < ApplicationRecord
has_many :contributions
attr_accessor :skip_password_validation
after_initialize :set_default_role, :if => :new_record?
mount_uploader :avatar, AvatarUploader
has_many :contributions
enum role: [:user, :admin]
def set_default_role
......
......@@ -6,7 +6,6 @@
= image_tag(project.photo_preview_url(:thumb_small))
%span.item_label
= t "#{project.types}"
%span.btn.btn_default.btn_round.btn_bordered{"data-original-title" => "підтримай проект", "data-placement" => "top", "data-toggle" => "tooltip"}
%i.icon.icon_plus
%span.project_item_middle
%span.project_item_title #{project.title}
......
......@@ -12,7 +12,7 @@
%meta{:content => "width=device-width", :name => "viewport"}
%meta{:content => "IE=edge", "http-equiv" => "X-UA-Compatible"}
%link{:href => "https://cdn.jsdelivr.net/bxslider/4.2.12/jquery.bxslider.css", :rel => "stylesheet"}/
%script{:src => "https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"}
/ %script{:src => "https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"}
%script{:src => "https://cdn.jsdelivr.net/bxslider/4.2.12/jquery.bxslider.min.js"}
/Fonts
%link{:href => "//fonts.googleapis.com/css?family=Open+Sans:400,600,700", :rel => "stylesheet", :type => "text/css"}
......@@ -22,12 +22,6 @@
%link{:href => "//fonts.googleapis.com/css?family=Roboto+Slab:300,400&subset=cyrillic-ext", :rel => "stylesheet"}
%link{:href => "//fonts.googleapis.com/css?family=Roboto:300,500&subset=cyrillic-ext", :rel => "stylesheet"}
%link{:href => "https://fonts.googleapis.com/css?family=Montserrat:300|Six+Caps", :rel => "stylesheet"}
/Favicons + Touch Icons
%link{:href => "favicons/apple-touch-icon57.png", :rel => "apple-touch-icon", :sizes => "57x57"}
%link{:href => "favicons/apple-touch-icon60.png", :rel => "apple-touch-icon", :sizes => "60x60"}
%link{:href => "favicons/apple-touch-icon114.png", :rel => "apple-touch-icon", :sizes => "114x114"}
%link{:href => "favicons/apple-touch-icon120.png", :rel => "apple-touch-icon", :sizes => "120x120"}
%link{:href => "favicons/apple-touch-icon180.png", :rel => "apple-touch-icon", :sizes => "180x180"}
%body
= render 'partials/modal'
- if current_page?('/') || current_page?('/en') || current_page?('/uk')
......
= simple_form_for :user, url: users_path, authenticity_token: true do |f|
#modal3.modal.fade.modal_styled{"aria-labelledby" => "modalLabel", :role => "dialog", :tabindex => "-1"}
.modal-dialog{:role => "document"}
.modal-content
.modal-header
.modal-header_top.clearfix
.modal-header_top_bg
%button.round_link.close{"aria-label" => "Close", "data-dismiss" => "modal", :type => "button"}
%i.icon.icon_close
.modal-header_bot
%h3#modalLabel.modal-title Вхід
.help_text.absolute
%span.asterisk *
Поля обов'язкові для заповнення
.modal-body
.row
.col-sm-9.modal-body_login
%h4.modal_subtitle
Авторизація
.form-group
%label{:for => "id_3"}
%span.asterisk> *
E-mail
.field_wrap
= f.input :email, class: 'form-control', label: false
.form-group
%label{:for => "id_2"}
%span.asterisk> *
Ім'я та прізвище
.field_wrap
= f.input :name, class: 'form-control', label: false
.form-group
%label{:for => "user_location"}
Населений пункт
.field_wrap
= f.input :location, class: 'form-control', label: ""
.col-sm-3.modal-body_registration
%h4.modal_subtitle
Швидка реєстрація
.soc_btn_wrap.clearfix
%a.soc_btn.soc_btn_fb{href: "/users/auth/facebook"}
%i.icon.icon_fb
%a.soc_btn.soc_btn_tw{href: "/users/auth/linkedin"}
%i.icon.icon_tw
%a.soc_btn.soc_btn_google{href: "/users/auth/google_oauth2"}
%i.icon.icon_google
.text-center
= f.button :submit, "Register Now", class: "btn btn-success btn-lg"
......@@ -24,7 +24,7 @@
.container
%h2.heading_with_btn
%span #{@project.title}
%a.btn.btn_default{:href => "#"}
%a.btn.btn_default{"data-target" => "#modal", "data-toggle" => "modal", :href => "#"}
%i.icon.icon_plus>
підтримати проект
.news_wrap
......
$('#modal').append(<%= j (render('partials/modal')) %>);
\ No newline at end of file
......@@ -127,10 +127,7 @@ SimpleForm.setup do |config|
# in this configuration, which is recommended due to some quirks from different browsers.
# To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
# change this configuration to true.
config.browser_validations = false
# Collection of methods to detect if a file type was given.
# config.file_methods = [ :mounted_as, :file?, :public_filename, :attached? ]
config.browser_validations = true
# Custom mappings for input types. This should be a hash containing a regexp
# to match as key, and the input type that will be used when the field name
......
uk:
activerecord:
errors:
models:
user:
attributes:
email:
blank: "Email can't be blank"
invalid: "Email is invalid"
time:
formats:
short: "%Y-%m-%d %H:%M:%S"
......@@ -2,6 +2,7 @@ Rails.application.routes.draw do
scope "(:locale)", locale: /en|uk/ do
mount Ckeditor::Engine => '/ckeditor'
root 'home#index'
get "/autocomplete_user", to: "users#autocomplete_user"
put "/admin/projects/:id", to: 'admin/projects#sort'
ActiveAdmin.routes(self)
resources :users
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment