From eb467778807ac54fae4f195a7e46ef7c59112f32 Mon Sep 17 00:00:00 2001 From: Golga Date: Tue, 5 Apr 2016 14:06:14 +0200 Subject: [PATCH] FIX: hashchange --- templates/night2015/gulpfile.js | 60 +++++++++++++++++++++++ templates/night2015/js/scripts.js | 79 ++++++++++++++++++++++--------- 2 files changed, 116 insertions(+), 23 deletions(-) create mode 100644 templates/night2015/gulpfile.js diff --git a/templates/night2015/gulpfile.js b/templates/night2015/gulpfile.js new file mode 100644 index 0000000..661366d --- /dev/null +++ b/templates/night2015/gulpfile.js @@ -0,0 +1,60 @@ +var gulp = require("gulp"); +var concat = require("gulp-concat"); +var plumber = require("gulp-plumber"); +var uglify = require("gulp-uglify"); +var rename = require("gulp-rename"); +var compass = require('gulp-compass'); + + +var jsPath = "./js"; +var cssPath = "./css"; +var scssPath = "./scss"; + + +gulp.task('default', ['script-concat', 'watch']); + +gulp.task('script-concat', function(){ + + // var files = [ + // jsWpPath+'/wp-embed.min.js', + // jsPath+'/aleteia.js', + // jsPath+'/functions.js', + // jsPath+'/softloading.js', + // jsPath+'/googl-analitycs.js', + // jsPath+'/bootstrap-scrollspy.js', + // jsPath+'/aleteiaDesktop.js' + // ]; + // gulp.src(files) + // .pipe(plumber()) + // .pipe(concat('aleteia-desktop.min.js')) + // .pipe(uglify()) + // .pipe(gulp.dest(jsPath)); + + // files = [ + // jsWpPath+'/wp-embed.min.js', + // jsPath+'/aleteia.js', + // jsPath+'/functions.js', + // jsPath+'/softloading.js', + // jsPath+'/aleteia-mobile.js', + // jsPath+'/jquery-smoothscroll.js' + // ]; + // gulp.src(files) + // .pipe(plumber()) + // .pipe(concat('aleteia-mobile.min.js')) + // .pipe(uglify()) + // .pipe(gulp.dest(jsPath)); +}); + +gulp.task('compass', function() { + gulp.src(cssPath + '/*.scss') + .pipe(compass({ + config_file: './config.rb', + css: cssPath, + sass: scssPath + })) + .pipe(gulp.dest('app/assets/temp')); +}); + +gulp.task('watch', function(){ + gulp.watch(jsPath+"/**/*.js", ['script-concat']); +}); \ No newline at end of file diff --git a/templates/night2015/js/scripts.js b/templates/night2015/js/scripts.js index 39d65b1..cae617d 100644 --- a/templates/night2015/js/scripts.js +++ b/templates/night2015/js/scripts.js @@ -3,6 +3,7 @@ $(function(){ var site_w; var lineHeight; var url = window.location.href; + var tag = window.location.href.split("#")[1]; var mmenu = $('nav#menu').mmenu(); var refreshW = 2000; // reload .site width 2s after window's reload var config_dev = $("#ajaxConfig input[name=dev]").val(); @@ -77,25 +78,62 @@ $(function(){ }); } - if ( url.split("#")[1] == "conff" ) + function displayPopUpMaj( data ) { - $(window).trigger('hashchange'); - console.log(url.split("#")); - displayConff(); + var html = "
" + + "x" + + " MyLocal " + + "" + data.tag_name + "" + + " is now available! " + + "" + + "" + + "" + + "" + + "
"; + return html; } - // on hashchange or trigger hashchange - $(window).on('hashchange', function(e){ - url = window.location.href; - if ( url.split("#")[1] == "conff" ) - { - closeMM(); - displayConff(); - } - else if( url.split("#")[1] == "closeConff" ) + + function hashchangeFunction() + { + tag = window.location.href.split("#")[1]; + window.history.replaceState(null, null, url); + + switch( tag ) { - $("#conffZone").slideToggle(500); + case "conff": + closeMM(); + displayConff(); + break; + case "closeConff": + $("#conffZone").slideToggle(500); + break; + case "closeMaj": + $(".maj-info").slideToggle(500); + break; + default: + console.log( "unknow " + tag + " hashange on script.js"); + break; } + + } + + if ( + tag != '' + && tag != null + && tag != "null" + && tag != undefined + && tag != "undefined" + ) + { + + hashchangeFunction(); + } + // hashchange detection (#pseudoElem) + $(window).on('hashchange', function(e) + { + hashchangeFunction(); }); + // on reload done $(window).on('resize', function(e) { clearTimeout(resizeTimer); @@ -112,17 +150,12 @@ $(function(){ { // alert(data[0]["sha"]); $("html").append( data ); + // ignore fix release (0.0.x) in test for displaying popup + // but take it in popup link (if pass popup test) if ( parseFloat(config_release) < parseFloat(data.tag_name) ) { - console.log( data.tag_name ); - console.log( data.name ); - console.log( data.zipball_url ); - console.log( data.author.login ); - console.log( data.author.avatar_url ); - console.log( data.name ); - console.log( parseFloat(config_release) +"<"+ parseFloat(data.tag_name)); - } - + $("#main").append( displayPopUpMaj(data) ); + } }); } }); \ No newline at end of file