Concatenate all general js files into tutti.js

This commit is contained in:
2016-09-29 12:22:53 +02:00
parent bdbf460623
commit 4c4489a890
5 changed files with 75 additions and 63 deletions

2
.gitignore vendored
View File

@@ -11,3 +11,5 @@ __pycache__
/node_modules/
/attract/templates/
/attract/static/assets/css/
/attract/static/assets/js/*.min.js

View File

@@ -65,6 +65,22 @@ gulp.task('scripts', function() {
});
/* Collection of scripts in src/scripts/tutti/ to merge into tutti.min.js */
/* Since it's always loaded, it's only for functions that we want site-wide */
gulp.task('scripts_tutti', function() {
gulp.src('src/scripts/tutti/**/*.js')
.pipe(gulpif(enabled.failCheck, plumber()))
.pipe(cache('scripting_tutti'))
.pipe(gulpif(enabled.maps, sourcemaps.init()))
.pipe(concat("tutti.min.js"))
.pipe(gulpif(enabled.uglify, uglify()))
.pipe(gulpif(enabled.maps, sourcemaps.write(".")))
.pipe(chmod(644))
.pipe(gulp.dest('attract/static/assets/js/'))
.pipe(gulpif(enabled.liveReload, livereload()));
});
// While developing, run 'gulp watch'
gulp.task('watch',function() {
// Only listen for live reloads if ran with --livereload
@@ -75,8 +91,9 @@ gulp.task('watch',function() {
gulp.watch('src/styles/**/*.sass',['styles']);
gulp.watch('src/templates/**/*.jade',['templates']);
gulp.watch('src/scripts/*.js',['scripts']);
gulp.watch('src/scripts/tutti/*.js',['scripts_tutti']);
});
// Run 'gulp' to build everything at once
gulp.task('default', ['styles', 'templates', 'scripts']);
gulp.task('default', ['styles', 'templates', 'scripts', 'scripts_tutti']);

View File

@@ -0,0 +1,52 @@
(function ( $ ) {
$.fn.flashOnce = function() {
var target = this;
this
.addClass('flash-on')
.delay(1000) // this delay is linked to the transition in the flash-on CSS class.
.queue(function() {
target
.removeClass('flash-on')
.addClass('flash-off')
.dequeue()
;})
.delay(1000) // this delay is just to clean up the flash-X classes.
.queue(function() {
target
.removeClass('flash-on flash-off')
.dequeue()
;})
;
return this;
};
/**
* Fades out the element, then erases its contents and shows the now-empty element again.
*/
$.fn.fadeOutAndClear = function(fade_speed) {
var target = this;
this
.fadeOut(fade_speed, function() {
target
.html('')
.show();
});
}
$.fn.hideAndRemove = function(hide_speed, finished) {
this.slideUp(hide_speed, function() {
this.remove();
if (typeof finished !== 'undefined') finished();
});
}
$.fn.removeClassPrefix = function(prefix) {
this.each(function(i, el) {
var classes = el.className.split(" ").filter(function(c) {
return c.lastIndexOf(prefix, 0) !== 0;
});
el.className = $.trim(classes.join(" "));
});
return this;
};
}(jQuery));

View File

@@ -1,56 +1,3 @@
(function ( $ ) {
$.fn.flashOnce = function() {
var target = this;
this
.addClass('flash-on')
.delay(1000) // this delay is linked to the transition in the flash-on CSS class.
.queue(function() {
target
.removeClass('flash-on')
.addClass('flash-off')
.dequeue()
;})
.delay(1000) // this delay is just to clean up the flash-X classes.
.queue(function() {
target
.removeClass('flash-on flash-off')
.dequeue()
;})
;
return this;
};
/**
* Fades out the element, then erases its contents and shows the now-empty element again.
*/
$.fn.fadeOutAndClear = function(fade_speed) {
var target = this;
this
.fadeOut(fade_speed, function() {
target
.html('')
.show();
});
}
$.fn.hideAndRemove = function(hide_speed, finished) {
this.slideUp(hide_speed, function() {
this.remove();
if (typeof finished !== 'undefined') finished();
});
}
$.fn.removeClassPrefix = function(prefix) {
this.each(function(i, el) {
var classes = el.className.split(" ").filter(function(c) {
return c.lastIndexOf(prefix, 0) !== 0;
});
el.className = $.trim(classes.join(" "));
});
return this;
};
}(jQuery));
/**
* Removes the task from the task list and shot list, and show the 'task-add-link'
* when this was the last task in its category.
@@ -330,10 +277,3 @@ $(function() {
});
});
/* Copy to clipboard when clicking on an input with 'copy-to-clipboard' class */
$('body').on('click', '.copy-to-clipboard', function(e){
e.preventDefault();
$(this).select();
document.execCommand('copy');
});

View File

@@ -15,6 +15,8 @@ html(lang="en")
link(href="{{ url_for('static_attract', filename='assets/css/main.css') }}", rel="stylesheet")
link(href="{{ url_for('static_attract', filename='assets/css/plugins/js_select2.css') }}", rel="stylesheet")
script(src="{{ url_for('static_pillar', filename='assets/js/vendor/jquery-3.1.0.min.js')}}")
script(src="{{ url_for('static_pillar', filename='assets/js/tutti.min.js') }}")
script(src="{{ url_for('static_attract', filename='assets/js/tutti.min.js') }}")
| {% block style %}{% endblock %}
@@ -38,8 +40,7 @@ html(lang="en")
h1 Right
| {% endblock %}
script(src="{{ url_for('static_pillar', filename='assets/js/tutti.min.js') }}")
script(src="{{ url_for('static_attract', filename='assets/js/tasks.js') }}", async=true)
script(src="{{ url_for('static_pillar', filename='assets/js/vendor/jquery.select2.min.js') }}", async=true)
| {% block footer_scripts %}{% endblock %}