Reindent file: change 2 spaced to 4.

This commit is contained in:
Arpad Csanyi
2016-06-12 18:00:22 +02:00
parent 00950618df
commit 94cc832552
+192 -192
View File
@@ -1,66 +1,66 @@
$(function() { $(function() {
// Handlebars template for Sidebar menu. // Handlebars template for Sidebar menu.
var sidebarMenuSource = $('#sidebar-menu--source').html(); var sidebarMenuSource = $('#sidebar-menu--source').html();
var sidebarMenuTemplate = Handlebars.compile(sidebarMenuSource); var sidebarMenuTemplate = Handlebars.compile(sidebarMenuSource);
$('#sidebar-menu').html(sidebarMenuTemplate(menuObject)); $('#sidebar-menu').html(sidebarMenuTemplate(menuObject));
_init('.keymap--edit'); _init('.keymap--edit');
// ======================= // =======================
// Menu-item functionality // Menu-item functionality
// ======================= // =======================
$('.sidebar__level-2--item').on('click', function() { $('.sidebar__level-2--item').on('click', function() {
var _this = $(this); var _this = $(this);
var dataContent = _this.data('content'); var dataContent = _this.data('content');
var dataAbbrev = _this.data('abbrev'); var dataAbbrev = _this.data('abbrev');
var dataName = _this.data('name'); var dataName = _this.data('name');
var _currentView = $('.main-content__inner:visible'); var _currentView = $('.main-content__inner:visible');
// This can be the same as _currentView. // This can be the same as _currentView.
var _newView = $(dataContent); var _newView = $(dataContent);
// Switch to the corresponding view. // Switch to the corresponding view.
_currentView.hide(); _currentView.hide();
_newView.show(); _newView.show();
// Fill pane title based on data attributes. // Fill pane title based on data attributes.
if (dataName != '') { if (dataName != '') {
_newView.find('.pane-title__name').text(dataName); _newView.find('.pane-title__name').text(dataName);
} }
if (dataAbbrev != '') { if (dataAbbrev != '') {
_newView.find('.pane-title__abbrev').text(dataAbbrev); _newView.find('.pane-title__abbrev').text(dataAbbrev);
} }
// Change .active class in the sidebar. // Change .active class in the sidebar.
$('.sidebar__level-2--item.active').removeClass('active'); $('.sidebar__level-2--item.active').removeClass('active');
_this.addClass('active'); _this.addClass('active');
_init(dataContent); _init(dataContent);
}); });
// ======================== // ========================
// Keymap related settings. // Keymap related settings.
// ======================== // ========================
$('.pane-title__name, .pane-title__abbrev').on('mouseover', function() { $('.pane-title__name, .pane-title__abbrev').on('mouseover', function() {
$(this).addClass('active'); $(this).addClass('active');
}).on('mouseout', function() { }).on('mouseout', function() {
if (!$(this).is(':focus')) { if (!$(this).is(':focus')) {
$(this).removeClass('active'); $(this).removeClass('active');
} }
}).on('focusout', function() { }).on('focusout', function() {
$(this).removeClass('active'); $(this).removeClass('active');
}); });
$('.keymap__is-default').on('click', function() { $('.keymap__is-default').on('click', function() {
$(this).toggleClass('fa-star-o'); $(this).toggleClass('fa-star-o');
}); });
$('.sidebar__level-1', '.sidebar__level-1--item').on('click', function() { $('.sidebar__level-1', '.sidebar__level-1--item').on('click', function() {
$(this).parents('.sidebar__level-1--item').find('ul').slideToggle(); $(this).parents('.sidebar__level-1--item').find('ul').slideToggle();
$(this).find('.fa-chevron-down, .fa-chevron-up').toggleClass('fa-chevron-down fa-chevron-up') $(this).find('.fa-chevron-down, .fa-chevron-up').toggleClass('fa-chevron-down fa-chevron-up')
}); });
$('button.uhk__layer-switcher').on('click', function(e) { $('button.uhk__layer-switcher').on('click', function(e) {
var button = $(this), var button = $(this),
layerOrder = ['base', 'mod', 'fn', 'mouse'], layerOrder = ['base', 'mod', 'fn', 'mouse'],
currentButton = $('button.uhk__layer-switcher.current'), currentButton = $('button.uhk__layer-switcher.current'),
slideLayer = button.data('layer'), slideLayer = button.data('layer'),
@@ -71,210 +71,210 @@ $(function() {
currentSlide = $('.uhk__layer-wrapper.current'), currentSlide = $('.uhk__layer-wrapper.current'),
slideWidth = currentSlide.width() + 'px'; slideWidth = currentSlide.width() + 'px';
if (slideNumber < currentSlideNumber) { if (slideNumber < currentSlideNumber) {
// From left to right // From left to right
currentSlide.css('left', 0); currentSlide.css('left', 0);
slide.css('left', '-' + slideWidth); slide.css('left', '-' + slideWidth);
currentSlide.animate({left: slideWidth}, function() { currentSlide.animate({left: slideWidth}, function() {
$(this).removeClass('current'); $(this).removeClass('current');
}); });
slide.animate({left: 0}, function() { slide.animate({left: 0}, function() {
$(this).addClass('current'); $(this).addClass('current');
}); });
currentButton.removeClass('current btn-primary').addClass('btn-default'); currentButton.removeClass('current btn-primary').addClass('btn-default');
button.addClass('current btn-primary').removeClass('btn-default').blur(); button.addClass('current btn-primary').removeClass('btn-default').blur();
} else if (slideNumber != currentSlideNumber) { } else if (slideNumber != currentSlideNumber) {
// From right to left // From right to left
currentSlide.css({left: 0}); currentSlide.css({left: 0});
slide.css({left: slideWidth}); slide.css({left: slideWidth});
currentSlide.animate({left: '-' + slideWidth}, function() { currentSlide.animate({left: '-' + slideWidth}, function() {
$(this).removeClass('current'); $(this).removeClass('current');
}); });
slide.animate({left: 0}, function() { slide.animate({left: 0}, function() {
$(this).addClass('current'); $(this).addClass('current');
}); });
currentButton.removeClass('current btn-primary').addClass('btn-default'); currentButton.removeClass('current btn-primary').addClass('btn-default');
button.addClass('current btn-primary').addClass('btn-default').blur(); button.addClass('current btn-primary').addClass('btn-default').blur();
} }
}); });
// Based on: http://stackoverflow.com/a/24933495 // Based on: http://stackoverflow.com/a/24933495
$('img.uhk').each(function(){ $('img.uhk').each(function(){
var $img = $(this); var $img = $(this);
var imgID = $img.attr('id'); var imgID = $img.attr('id');
var imgClass = $img.attr('class'); var imgClass = $img.attr('class');
var imgURL = $img.attr('src'); var imgURL = $img.attr('src');
var imgSelector = '.' + imgClass.replace(' ', '.') var imgSelector = '.' + imgClass.replace(' ', '.')
$.get(imgURL, function(data) { $.get(imgURL, function(data) {
// Get the SVG tag, ignore the rest // Get the SVG tag, ignore the rest
var $svg = $(data).find('svg'); var $svg = $(data).find('svg');
// Add replaced image's ID to the new SVG // Add replaced image's ID to the new SVG
if(typeof imgID !== 'undefined') { if(typeof imgID !== 'undefined') {
$svg = $svg.attr('id', imgID); $svg = $svg.attr('id', imgID);
} }
// Add replaced image's classes to the new SVG // Add replaced image's classes to the new SVG
if(typeof imgClass !== 'undefined') { if(typeof imgClass !== 'undefined') {
$svg = $svg.attr('class', imgClass+' replaced-svg'); $svg = $svg.attr('class', imgClass+' replaced-svg');
} }
// Remove any invalid XML tags as per http://validator.w3.org // Remove any invalid XML tags as per http://validator.w3.org
$svg = $svg.removeAttr('xmlns:a'); $svg = $svg.removeAttr('xmlns:a');
// Check if the viewport is set, else we gonna set it if we can. // Check if the viewport is set, else we gonna set it if we can.
if(!$svg.attr('viewBox') && $svg.attr('height') && $svg.attr('width')) { if(!$svg.attr('viewBox') && $svg.attr('height') && $svg.attr('width')) {
$svg.attr('viewBox', '0 0 ' + $svg.attr('height') + ' ' + $svg.attr('width')) $svg.attr('viewBox', '0 0 ' + $svg.attr('height') + ' ' + $svg.attr('width'))
} }
// Replace image with new SVG // Replace image with new SVG
$img.replaceWith($svg); $img.replaceWith($svg);
$('.keyboard-slider').height($svg.height()); $('.keyboard-slider').height($svg.height());
// Quick fix as jQuery 2.1.4 addClass() method is not working on SVG elements. // Quick fix as jQuery 2.1.4 addClass() method is not working on SVG elements.
var finalClasses = $svg.attr('class'); var finalClasses = $svg.attr('class');
$('#left-parts rect, #right-parts rect', imgSelector).on('click', function() { $('#left-parts rect, #right-parts rect', imgSelector).on('click', function() {
var _popup = $('.key-editor__popup'), var _popup = $('.key-editor__popup'),
rectB7 = $('rect#b7', $svg); rectB7 = $('rect#b7', $svg);
if (_popup.is(':hidden')) { if (_popup.is(':hidden')) {
$svg.attr('class', finalClasses + ' faded'); $svg.attr('class', finalClasses + ' faded');
_popup.show(); _popup.show();
rectB7.attr('class', 'active'); rectB7.attr('class', 'active');
} else { } else {
$svg.attr('class', finalClasses); $svg.attr('class', finalClasses);
_popup.hide(); _popup.hide();
rectB7.attr('class', ''); rectB7.attr('class', '');
} }
}); });
}, 'xml'); }, 'xml');
}); });
}); });
function _init(view) { function _init(view) {
switch (view) { switch (view) {
case '.keymap--edit': case '.keymap--edit':
var h = $('.uhk--base-layer').height(); var h = $('.uhk--base-layer').height();
$('.keyboard-slider').height(h + 'px'); $('.keyboard-slider').height(h + 'px');
break; break;
} }
} }
var menuObject = { var menuObject = {
menu: [ menu: [
{ {
icon: 'keyboard-o', icon: 'keyboard-o',
name: 'Keymaps', name: 'Keymaps',
hasDefaults: true, hasDefaults: true,
expandable: true, expandable: true,
dataContent: '.keymap--edit', dataContent: '.keymap--edit',
children: [ children: [
{ {
icon: '', icon: '',
name: 'Factory keymap', name: 'Factory keymap',
abbrev: 'FTY', abbrev: 'FTY',
isDefault: true isDefault: true
}, },
{ {
icon: '', icon: '',
name: 'QWERTY', name: 'QWERTY',
abbrev: 'QTY', abbrev: 'QTY',
classes: 'active' classes: 'active'
}, },
{ {
icon: '', icon: '',
name: 'Dvorak', name: 'Dvorak',
abbrev: 'DVR', abbrev: 'DVR',
}, },
{ {
icon: '', icon: '',
name: 'Colemak', name: 'Colemak',
abbrev: 'COL', abbrev: 'COL',
}, },
{ {
icon: '', icon: '',
name: 'VIM', name: 'VIM',
abbrev: 'VIM', abbrev: 'VIM',
}, },
{ {
icon: '', icon: '',
name: 'Mortal Kombat X', name: 'Mortal Kombat X',
abbrev: 'MKX', abbrev: 'MKX',
} }
] ]
}, },
{ {
icon: 'keyboard-o', icon: 'keyboard-o',
name: 'Keymaps-ng2', name: 'Keymaps-ng2',
hasDefaults: true, hasDefaults: true,
expandable: true, expandable: true,
dataContent: '.keymap--edit-ng2', dataContent: '.keymap--edit-ng2',
children: [ children: [
{ {
icon: '', icon: '',
name: 'Factory keymap', name: 'Factory keymap',
abbrev: 'FTY', abbrev: 'FTY',
isDefault: true isDefault: true
} }
] ]
}, },
{ {
icon: 'play', icon: 'play',
name: 'Macros', name: 'Macros',
expandable: true, expandable: true,
dataContent: '.macro--edit', dataContent: '.macro--edit',
children: [ children: [
{ {
icon: '', icon: '',
name: 'Macro1' name: 'Macro1'
}, },
{ {
icon: '', icon: '',
name: 'Macro2' name: 'Macro2'
}, },
{ {
icon: '', icon: '',
name: 'Macro3' name: 'Macro3'
}, },
{ {
icon: '', icon: '',
name: 'Macro4' name: 'Macro4'
} }
] ]
}, },
{ {
'icon': 'puzzle-piece', 'icon': 'puzzle-piece',
'name': 'Add-on modules', 'name': 'Add-on modules',
'children': [ 'children': [
{ {
'icon': '', 'icon': '',
'name': 'Key cluster' 'name': 'Key cluster'
}, },
{ {
'icon': '', 'icon': '',
'name': 'Trackball' 'name': 'Trackball'
}, },
{ {
'icon': '', 'icon': '',
'name': 'Toucpad' 'name': 'Toucpad'
}, },
{ {
'icon': '', 'icon': '',
'name': 'Trackpoint' 'name': 'Trackpoint'
} }
] ]
} }
], ],
menuBottom: [ menuBottom: [
{ {
'icon': 'gear', 'icon': 'gear',
'name': 'Settings' 'name': 'Settings'
} }
] ]
}; };