Skip to content

Commit

Permalink
FIX: hashchange
Browse files Browse the repository at this point in the history
  • Loading branch information
Golgarud committed Apr 5, 2016
1 parent 0e3cd3a commit eb46777
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 23 deletions.
60 changes: 60 additions & 0 deletions templates/night2015/gulpfile.js
Original file line number Diff line number Diff line change
@@ -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']);
});
79 changes: 56 additions & 23 deletions templates/night2015/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -77,25 +78,62 @@ $(function(){
});
}

if ( url.split("#")[1] == "conff" )
function displayPopUpMaj( data )
{
$(window).trigger('hashchange');
console.log(url.split("#"));
displayConff();
var html = "<div class='maj-info'>" +
"<a class='close' href='#closeMaj' >x</a>" +
"<span> MyLocal " +
"<a title='View release on GitHub' href='" + data.html_url + "' >" + data.tag_name + "</a>" +
" is now available! </span>" +
"<span class='link-container'>" +
"<a class='dl' title='Download zip' href='" + data.zipball_url + "' download ><i class='spLogo-zip'></i></a>" +
"<a class='git' title='View on GitHub' href='https://github.com/Golgarud/myLocal' ><i class='spLogo-github'></i></a>" +
"</span>" +
"</div>";
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);
Expand All @@ -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) );
}
});
}
});

0 comments on commit eb46777

Please sign in to comment.