-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also, - new activity badge - activity info and join button - bs4 version for main JS
- Loading branch information
Showing
7 changed files
with
388 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/*global webshim:true*/ | ||
|
||
'use strict'; | ||
|
||
var enableCsrf = require('./lib/enable-csrf.js'); | ||
|
||
require('drmonty-garlicjs'); | ||
require('webshim'); | ||
|
||
enableCsrf($); | ||
|
||
// Specifically so IE will support the HTML5 form attribute on <input> elements | ||
webshim.setOptions('basePath', '/static/vendor/shims/'); | ||
webshim.polyfill('forms'); | ||
|
||
function parsleyForm(element) { | ||
return $(element).parsley({ | ||
successClass: 'has-success', | ||
errorClass: 'has-error', | ||
trigger: 'change keyup focusout', | ||
classHandler: function (field) { | ||
if (field.$element.attr('type') === 'radio') { | ||
return $('input[type=radio][name=' + field.$element.attr('name') + ']') | ||
.parents('.radio'); | ||
} | ||
|
||
return field.$element.parents('.form-group'); | ||
}, | ||
errorsContainer: function (field) { | ||
var $field = field.$element; | ||
|
||
if (field.$element.attr('type') === 'radio') { | ||
$field = $('input[type=radio][name=' + field.$element.attr('name') + | ||
']:last').parent().parent(); | ||
|
||
return $('<span></span>').insertAfter($field); | ||
} | ||
|
||
if (field.$element.parent('.input-group')) { | ||
$field = field.$element.parent('.input-group'); | ||
} | ||
|
||
return $('<span></span>').insertAfter($field); | ||
}, | ||
errorsWrapper: '<span class="help-block"></span>', | ||
errorTemplate: '<div></div>' | ||
}); | ||
} | ||
|
||
function showModal(modalId) { | ||
return function (e) { | ||
// Allow for middle-clicking, control-clicking, and command-clicking | ||
if (e.isDefaultPrevented() || e.metaKey || e.ctrlKey) { | ||
return; | ||
} | ||
|
||
e.preventDefault(); | ||
|
||
$(modalId).modal({remote: false}); | ||
}; | ||
} | ||
|
||
function storeRedirect(){ | ||
var location = window.location.href; | ||
|
||
// Make a POST, but not asynchronously! | ||
$.ajax({ type: 'POST', | ||
url: '/account/storeredirect/', | ||
data: {next_url: location}, | ||
success: function(){}, | ||
async:false }); | ||
} | ||
|
||
$(function () { | ||
$('[rel=persist]').garlic(); | ||
|
||
parsleyForm('form'); | ||
|
||
$('.logout-link').click(function (e) { | ||
e.preventDefault(); | ||
|
||
$.post($(this).attr('href'), function () { | ||
location.reload(); | ||
}); | ||
}); | ||
|
||
// Add these modals with JavaScript rather than data- attributes to prevent | ||
// AJAX loading of modal content by Bootstrap. | ||
$('.login-link').click(showModal('#login-modal')); | ||
$('.signup-link').click(showModal('#signup-modal')); | ||
|
||
// POST current URL to be stored as a redirect link upon login/signup | ||
$('.redirect-storage-link').click(storeRedirect); | ||
}); |
Oops, something went wrong.