Fixed Responsive Menu

This commit is contained in:
2015-11-09 19:23:23 -06:00
parent 2820263379
commit 23172a5115
6 changed files with 62 additions and 42 deletions

View File

@@ -29,7 +29,7 @@ function B(els, attrs) {
// Map a function to the first element in 'this'
B.prototype.mapOne = function(callback) {
var m = this.map(callback);
return m.length > 1 ? m[0] : m;
return Object.prototype.toString.call(m) === '[object Array]' ? m[0] : m;
};
// Update css for each element in 'this'
@@ -49,11 +49,11 @@ function B(els, attrs) {
};
// Update the innerText for each element in 'this'
B.prototype.html = function(text) {
B.prototype.text = function(text) {
if(typeof text !== "undefined") {
return this.forEach(function(el){el.innerHTML=text;});
return this.forEach(function(el){el.textContent=text;});
} else {
return this.mapOne(function(el){return el.innerHTML;});
return this.mapOne(function(el){return el.textContent;});
}
};
@@ -103,7 +103,7 @@ function B(els, attrs) {
});
}
} else {
// And getting the value
// And clearing the value
if(this[0].tagName=="INPUT" && attr.toUpperCase()=="VALUE") {
return this.mapOne(function(el){
return el.value;

View File

@@ -26,4 +26,22 @@ B(window).on('load',function() {
B(B_t.firstChild('.fa-toggle-down')).removeClass('fa-toggle-down').addClass('fa-toggle-up');
}
});
// For responsive menu click
var mainLayout = B('#layout'),
menu = B('#resp_menu'),
menuLink = B('#resp_menu_link');
menuLink.on('click', function(e) {
e.preventDefault();
if(mainLayout.hasClass('active')) {
mainLayout.removeClass('active');
menu.removeClass('active');
menuLink.removeClass('active');
return;
}
mainLayout.addClass('active');
menu.addClass('active');
menuLink.addClass('active');
});
});

View File

@@ -112,11 +112,15 @@ function buildList() {
idName = userName.replace('.','_');
B("#userXpList").append(B('<div>').attr('id',"levelup-user-"+idName).addClass('levelup-user pure-u-1 pure-u-md-11-24').attr('data-username',userName));
var userNameSpan = B("<span>").attr('id','levelup-user-'+idName+'-name').addClass('levelup-username');
B("#levelup-user-"+idName).append(B("<div>").attr('id','levelup-user-'+idName+'-level').addClass('levelup-level').html(userLevel));
B("#levelup-user-"+idName).append(userNameSpan.html(userName));
B("#levelup-user-"+idName).append(B("<div>").attr('id','levelup-user-'+idName+'-smalllevel').addClass('levelup-smalllevel').html("Level "+userLevel));
B("#levelup-user-"+idName).append(B("<div>").attr('id','levelup-user-'+idName+'-xp').addClass('levelup-xp').html("("+xp+"/"+toNext+")"));
var userNameSpan = B("<span>").attr('id','levelup-user-'+idName+'-name');
userNameSpan.addClass('levelup-username');
var levelDiv = B("<div>").attr('id','levelup-user-'+idName+'-level');
levelDiv.addClass('levelup-level');
levelDiv.text(userLevel);
B("#levelup-user-"+idName).append(levelDiv);
B("#levelup-user-"+idName).append(userNameSpan.text(userName));
B("#levelup-user-"+idName).append(B("<div>").attr('id','levelup-user-'+idName+'-smalllevel').addClass('levelup-smalllevel').text("Level "+userLevel));
B("#levelup-user-"+idName).append(B("<div>").attr('id','levelup-user-'+idName+'-xp').addClass('levelup-xp').text("("+xp+"/"+toNext+")"));
B('.levelup-user').on('click', function() {
console.log("Load User Profile: "+B(this).attr('data-username'));