Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Commit

Permalink
Added sample js file
Browse files Browse the repository at this point in the history
  • Loading branch information
Wtower committed Dec 31, 2016
1 parent 7f00adb commit 83af1e4
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 3 deletions.
2 changes: 1 addition & 1 deletion generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ module.exports = yeoman.Base.extend({
var templatePaths = [
'_name_/',
'_name__core/',
'private/',
'_editorconfig',
'_gitignore',
'_venv',
Expand All @@ -111,7 +112,6 @@ module.exports = yeoman.Base.extend({
];
var copyPaths = [
'media/',
'private/',
'static/',
'templates/',
'CHANGELOG',
Expand Down
72 changes: 72 additions & 0 deletions generators/app/templates/private/javascripts/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* Created by yeoman generator-django-ana <%= version %> on <%= date %>.
*/
jQuery.fn.topLink = function(settings) {
settings = jQuery.extend({
min: 1,
fadeSpeed: 200
}, settings);
return this.each(function() {
//listen for scroll
var el = jQuery(this);
el.hide(); //in case the user forgot
jQuery(window).scroll(function() {
if(jQuery(window).scrollTop() >= settings.min) {
el.fadeIn(settings.fadeSpeed);
}
else {
el.fadeOut(settings.fadeSpeed);
}
});
});
};

$(document).ready(function () {
// Loader
// hide scroll and show on window.load
var loader = $('#loader');
if (loader.length && loader.css('display') != 'none') $('body').css({overflow: 'hidden'});

// Page top
$('#top-link')
// set the link
.topLink({
min: 400,
fadeSpeed: 500
})
// smooth scroll
.click(function (e) {
e.preventDefault();
$.scrollTo(0, 300);
});

// Shrink
if ($('.shrinkable').length) {
$(window).scroll(function () {
if ($(this).scrollTop() > 50) $('.shrinkable').addClass('shrink');
else $('.shrinkable').removeClass('shrink');
});
}

// Bookmark smooth scroll
$('.nav a[href*="#"]').each(function () {
var bookmark = $(this).attr('href').match(/(#.*)$/g)[0];
if (bookmark == '#') return;
if (!$(bookmark).length) return;
$(this).on('click', function () {
$.scrollTo(bookmark, 300, {offset: {top: -50, left: 0}});
});
});

// bootstrap
$('input[type="text"], input[type="number"], input[type="email"], input[type="url"], select')
.addClass('form-control');

});

$(window).load(function () {
// Loader
// hide loader and show scrollbars (hidden in document.ready)
$('#loader, #loader-container').fadeOut('slow');
$('body').css({'overflow': 'visible'});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generator-django-ana",
"version": "0.1.3",
"version": "0.1.4",
"description": "Generate Django boilerplate. Featuring REST, gulp build and ng-gentelella.",
"homepage": "https://github.com/Wtower/generator-django-ana.git",
"author": {
Expand Down
2 changes: 1 addition & 1 deletion test/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('generator-django-ana:app', function () {
var templatePaths = [
'yeotests/',
'yeotests_core/',
'private/',
'.editorconfig',
'.gitignore',
'.venv',
Expand All @@ -40,7 +41,6 @@ describe('generator-django-ana:app', function () {
];
var copyPaths = [
'media/',
'private/',
'templates/',
'CHANGELOG',
'requirements.txt'
Expand Down

0 comments on commit 83af1e4

Please sign in to comment.