Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
Revert "Merge branch 'development'"
Browse files Browse the repository at this point in the history
This reverts commit 5ef44c3, reversing
changes made to a6f0b32.
  • Loading branch information
osahyoun committed Nov 25, 2016
1 parent 5ef44c3 commit 6dde726
Show file tree
Hide file tree
Showing 30 changed files with 230 additions and 317 deletions.
6 changes: 0 additions & 6 deletions .rubocop.yml
Expand Up @@ -31,9 +31,3 @@ Lint/BlockAlignment:

Lint/InheritException:
Enabled: false

Style/GuardClause:
Enabled: false

Style/IfUnlessModifier:
MaxLineLength: 40
38 changes: 13 additions & 25 deletions app/assets/javascripts/member-facing.js.erb
Expand Up @@ -19,28 +19,16 @@
require("<%= Settings.external_js_path %>");
<% end %>

let initializeApp = () => {
window.URI = require('urijs');
window.sumofus = window.sumofus || {} // for legacy templates that reference window.sumofus
window.champaign = window.champaign || window.sumofus || {};
window.champaign.Petition = require('member-facing/backbone/petition');
window.champaign.Survey = require('member-facing/backbone/survey');
window.champaign.ActionForm = require('member-facing/backbone/action_form');
window.champaign.Fundraiser = require('member-facing/backbone/fundraiser');
window.champaign.OverlayToggle = require('member-facing/backbone/overlay_toggle');
window.champaign.Thermometer = require('member-facing/backbone/thermometer');
window.champaign.Sidebar = require('member-facing/backbone/sidebar');
window.champaign.Notification = require('member-facing/backbone/notification');
window.champaign.SweetPlaceholder = require('member-facing/backbone/sweet_placeholder');
window.champaign.CampaignerOverlay = require('member-facing/backbone/campaigner_overlay');
window.champaign.BraintreeHostedFields = require('member-facing/backbone/braintree_hosted_fields');
window.champaign.redirectors = require('member-facing/redirectors');
};

<% if Rails.env.production? %>
const airbrakeJs = require('airbrake-js');
const airbrake = new airbrakeJs({projectId: "<%= Settings.airbrake_project_id %>", projectKey: "<%= Settings.airbrake_api_key %>"});
initializeApp = airbrake.wrap(initializeApp);
<% end %>

initializeApp();
window.sumofus = window.sumofus || {} // for legacy templates that reference window.sumofus
window.champaign = window.champaign || window.sumofus || {};
window.champaign.Petition = require('member-facing/backbone/petition');
window.champaign.Survey = require('member-facing/backbone/survey');
window.champaign.ActionForm = require('member-facing/backbone/action_form');
window.champaign.Fundraiser = require('member-facing/backbone/fundraiser');
window.champaign.OverlayToggle = require('member-facing/backbone/overlay_toggle');
window.champaign.Thermometer = require('member-facing/backbone/thermometer');
window.champaign.Sidebar = require('member-facing/backbone/sidebar');
window.champaign.Notification = require('member-facing/backbone/notification');
window.champaign.SweetPlaceholder = require('member-facing/backbone/sweet_placeholder');
window.champaign.CampaignerOverlay = require('member-facing/backbone/campaigner_overlay');
window.champaign.BraintreeHostedFields = require('member-facing/backbone/braintree_hosted_fields');
73 changes: 56 additions & 17 deletions app/assets/javascripts/member-facing/backbone/fundraiser.js
Expand Up @@ -34,6 +34,9 @@ const Fundraiser = Backbone.View.extend(_.extend(CurrencyMethods, {
},

// options: object with any of the following keys
// followUpUrl: the url to redirect to after success
// submissionCallback: a function to call after success, receives the
// arguments received by the ajax call posting the donation
// member: an object for an existing member. registered and email fields are used
// currency: the three letter capitalized currency code to use
// amount: a preselected donation amount, if > 0 the first step will be skipped
Expand All @@ -46,6 +49,10 @@ const Fundraiser = Backbone.View.extend(_.extend(CurrencyMethods, {
this.initializeCurrency(options.currency, options.donationBands);
this.changeStep(1);
this.donationAmount = 0;
this.followUpUrl = options.followUpUrl;
if (typeof options.submissionCallback === 'function') {
this.submissionCallback = options.submissionCallback;
}
if (typeof options.member === 'object') {
this.member = options.member;
} else {
Expand Down Expand Up @@ -289,50 +296,60 @@ const Fundraiser = Backbone.View.extend(_.extend(CurrencyMethods, {
data.device_data = JSON.parse(obj.deviceData);

$.post(`/api/payment/braintree/pages/${this.pageId}/transaction`, data)
.then(this.onSubmission.bind(this))
.then(this.transactionSuccess.bind(this), this.transactionFailed.bind(this));

if (this.directDebitOpened) {
$.publish('direct_debit:donated_via_other');
}
},

onSubmission(data, status) {
if (this.submissionCallback) {
this.submissionCallback(data, status);
}
return data;
},

submitOneClick(event) {
event.preventDefault();
const url = `/api/payment/braintree/pages/${this.pageId}/one_click`;
this.disableOneClickButton();
$.post(url, this.oneClickDonationData())
.then(this.transactionSuccess.bind(this), this.onOneClickFailed.bind(this));
},

formData() {
return {
storeInVault: this.readStoreInVault(),
member: _.pick(this.currentUser(), 'email', 'registered')
};
.then(this.onSubmission.bind(this))
.then(this.onOneClickSuccess.bind(this), this.onOneClickFailed.bind(this));
},

currentUser() {
var formUser = this.serializeUserForm();
if(this.member.email === formUser.email) {
return this.member;
onOneClickSuccess(data) {
if ( this.memberShouldRegister() ) {
this.followRedirect(this.registrationPath(this.member.email));
} else {
return formUser;
this.followRedirect((data && data.follow_up_url) || this.followUpUrl);
}
},

transactionSuccess(data) {
$.publish('fundraiser:transaction_success', [data, this.formData()])
let url = (data && data.follow_up_url) || this.followUpUrl;

if ( this.memberShouldRegister() ) {
const user = this.serializeUserForm();
url = this.registrationPath(user.email);
}

this.followRedirect(url);
},

registrationPath(email) {
return `/member_authentication/new?page_id=${this.pageId}&email=${encodeURIComponent(email)}`;
},

onOneClickFailed() {
$.publish('fundraiser:transaction_error');
this.enableOneClickButton();
const $errors = this.$('.fundraiser-bar__errors');
$errors.removeClass('hidden-closed');
},

transactionFailed(data, status) {
$.publish('fundraiser:transaction_error');
this.enableButton();
let $errors = this.$('.fundraiser-bar__errors');
$errors.removeClass('hidden-closed');
Expand Down Expand Up @@ -411,6 +428,21 @@ const Fundraiser = Backbone.View.extend(_.extend(CurrencyMethods, {
.prop('disabled', false);
},

followRedirect(url) {
// If we have no redirect URL or submission callback,
// we display a thank you message
if (!url && !this.submissionCallback) {
window.alert(I18n.t('fundraiser.thank_you'));
return;
}

this.redirectTo(url);
},

redirectTo(url) {
window.location.href = url;
},

displayDirectDebit(show) {
if (show === true) {
$('.hosted-fields__direct-debit-container').removeClass('hidden-irrelevant');
Expand All @@ -424,9 +456,9 @@ const Fundraiser = Backbone.View.extend(_.extend(CurrencyMethods, {
$(window).on('message', (e) => {
if (typeof e.originalEvent.data === 'object') {
if (e.originalEvent.data.event === 'follow_up:loaded') {
this.redirectTo(this.followUpUrl);
e.originalEvent.source.close();
$.publish('direct_debit:donated');
this.transactionSuccess({});
} else if (e.originalEvent.data.event === 'donation:error') {
const messages = e.originalEvent.data.errors.map(({ message }) => message);
this.showErrors(messages);
Expand All @@ -436,6 +468,13 @@ const Fundraiser = Backbone.View.extend(_.extend(CurrencyMethods, {
});
},

memberRegistered() {
return this.member.registered;
},

memberShouldRegister() {
return !this.memberRegistered() && this.readStoreInVault();
},
}));

module.exports = Fundraiser;
5 changes: 0 additions & 5 deletions app/assets/javascripts/member-facing/backbone/petition.js
Expand Up @@ -14,15 +14,10 @@ const Petition = Backbone.View.extend({
initialize(options = {}) {
this.followUpUrl = options.followUpUrl;
this.submissionCallback = options.submissionCallback;
this.skipOnSuccessAction = options.skipOnSuccessAction;
GlobalEvents.bindEvents(this);
},

handleSuccess(e, data) {
$.publish('petition:submitted');
if(this.skipOnSuccessAction) {
return;
}
let hasCallbackFunction = (typeof this.submissionCallback === 'function');
if (hasCallbackFunction) {
this.submissionCallback(e, data);
Expand Down
53 changes: 0 additions & 53 deletions app/assets/javascripts/member-facing/redirectors.js

This file was deleted.

64 changes: 0 additions & 64 deletions app/assets/stylesheets/member-facing/fundraiser.scss
@@ -1,8 +1,6 @@
@import "compass/css3/filter";

.fundraiser-bar {
text-align: left;

&__steps {
position: relative;
width: 100%;
Expand Down Expand Up @@ -103,7 +101,6 @@
position: relative;

font-size: 20px;
line-height: 20px;
&--past {
color: white;
background: $slate-gray;
Expand Down Expand Up @@ -232,67 +229,6 @@
top: 2px;
}
}
&--freestanding.fundraiser-bar {
position: static;
max-width: 400px;

.fundraiser-bar__top, .fundraiser-bar__main {
background-color: transparent;
position: relative;
}

.fundraiser-bar__top h2 {
font-size: 24px;
font-weight: normal;
text-align: center;
}

.form--big input,
.form--big select,
.form--big textarea,
.form--big .selectize-control.single .selectize-input,
.form--big .hosted-fields__host,
.hosted-fields__host, input, select, .selectize-input {
border-color: $slate-gray;
&.braintree-hosted-fields-focused {
border-color: $teal;
}
}

.overlay-toggle__close-button {
display: none;
}

.fundraiser-bar__step-number--upcoming {
background: white;
}

.hosted-fields__button-container {
font-size: 16px;
}

//paypal
#bt-pp-cancel {
width: 80%;
text-align: left;
}

@media(max-width: 736px) {
label.checkbox-label input[type='checkbox'] {
position: relative;
vertical-align: middle;
}

.action-form__welcome-name {
line-height: 14px;
}

.action-form__clear-form {
line-height: 12px;
}
}

}
}

.sticky-wrapper {
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/api/actions_controller.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true
class Api::ActionsController < ApplicationController
before_action :localize_from_page_id
before_action :store_locale_in_session, only: :create

before_filter :localize_from_page_id
skip_before_action :verify_authenticity_token

def create
Expand Down
1 change: 0 additions & 1 deletion app/controllers/api/survey_responses_controller.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
class Api::SurveyResponsesController < ApplicationController
skip_before_action :verify_authenticity_token
before_action :localize_from_page_id, :store_locale_in_session, only: :create

def create
service = ManageSurveyResponse.new(
Expand Down

0 comments on commit 6dde726

Please sign in to comment.