-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1318 from dradis/hera/add-main-layout
Hera/add main layout
- Loading branch information
Showing
212 changed files
with
3,372 additions
and
3,422 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
document.addEventListener('turbolinks:load', function () { | ||
// Activate jQuery.breadCrumbs | ||
$('.breadcrumb').breadcrumbs({ | ||
tree: $('.main-sidebar .tree-navigation'), | ||
}); | ||
|
||
// Activate jQuery.treeNav | ||
$('.tree-navigation').treeNav(); | ||
|
||
// Activate jQuery.treeModal | ||
$('.modal-node-selection-form').treeModal(); | ||
|
||
// Focus first input on modal window display. | ||
$('.modal').on('shown.bs.modal', function () { | ||
$(this).find('input:text:visible:first').focus(); | ||
}); | ||
|
||
// If project id is changed in project path | ||
if (!/^\/projects\/1(\/|$)/.test(window.location.pathname)) { | ||
$('[data-behavior~=project-teaser]').removeClass('d-none'); | ||
} | ||
|
||
if ($('#activities-poller').length) { | ||
if (!ActivitiesPoller.initialized) { | ||
ActivitiesPoller.init($('#activities-poller')); | ||
ActivitiesPoller.poll(); | ||
} | ||
} | ||
|
||
// Disable form buttons after submitting them. | ||
$('form').submit(function (ev) { | ||
if ( | ||
!$('input[type=submit]', this).is('[data-behavior~=skip-auto-disable]') | ||
) { | ||
$('input[type=submit]', this) | ||
.attr('disabled', 'disabled') | ||
.val('Processing...'); | ||
} | ||
}); | ||
|
||
// Toggle sidebar menu | ||
$('[data-behavior~=sidebar]').each(function () { | ||
new Sidebar($(this)); | ||
}); | ||
|
||
// Disable turbolinks for on-page anchor links (prevents page from jumping to top and allows smooth-scrolling) | ||
if ($('a[href^="#"]').length) { | ||
$('a[href^="#"]').each(function () { | ||
if (!$(this).data('turbolinks')) { | ||
$(this).attr('data-turbolinks', 'false'); | ||
} | ||
}); | ||
} | ||
|
||
// Smooth Scrolling - scroll to element on page load if hash present in current browser url | ||
if (window.location.hash) { | ||
const target = window.location.hash; | ||
$(target)[0].scrollIntoView({ behavior: 'smooth' }); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
//= require hera/modules/issues/evidence | ||
//= require hera/modules/issues/importer | ||
//= require hera/modules/issues/merge | ||
//= require hera/modules/issues/tag-input |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
document.addEventListener('turbolinks:load', function () { | ||
$('[data-behavior~=form-search]').hover(function () { | ||
$(this).find('[data-behavior~=search-query]').focus(); | ||
}); | ||
|
||
$('[data-behavior~=search-button]').on('click', function (e) { | ||
e.preventDefault(); | ||
submitSearch($(this).parents('form')); | ||
}); | ||
|
||
$('[data-behavior~=search-query]').on('keypress', function (e) { | ||
const enterKeyCode = 13; | ||
if (e.which === enterKeyCode) { | ||
submitSearch($(this).parents('form')); | ||
} | ||
}); | ||
|
||
if ($('body.search.index').length) { | ||
const highlighter = new SearchWordHighlight(); | ||
const query = $('.form-search #q').val(); | ||
$('#tbl-search .search-matches').each(function () { | ||
highlighter.highlight($(this), query); | ||
}); | ||
} | ||
}); | ||
|
||
function submitSearch($form) { | ||
if ($form.find('[data-behavior~=search-query]').val() !== '') { | ||
$form.submit(); | ||
setTimeout(() => { | ||
$form.find('[data-behavior~=search-query]').val('Searching...'); | ||
}, 100); | ||
} else { | ||
$form | ||
.find('[data-behavior~=search-query]') | ||
.effect('shake', { direction: 'left', times: 2, distance: 5 }, 'fast') | ||
.focus(); | ||
} | ||
} | ||
|
||
class SearchWordHighlight { | ||
highlight(element, term) { | ||
let src_str = element.html(); | ||
term = term.replace(/(\s+)/, '(<[^>]+>)*$1(<[^>]+>)*'); | ||
const pattern = new RegExp('(' + term + ')', 'gi'); | ||
src_str = src_str.replace(pattern, '<mark>$1</mark>'); | ||
src_str = src_str.replace( | ||
/(<mark>[^<>]*)((<[^>]+>)+)([^<>]*<\/mark>)/, | ||
'$1</mark>$2<mark>$4' | ||
); | ||
element.html(src_str); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
(function ($, window) { | ||
class Sidebar { | ||
constructor($sidebar) { | ||
this.$sidebar = $sidebar; | ||
this.storageKey = $sidebar.data('storage-key'); | ||
this.$toggleLink = $sidebar.find($('[data-behavior~=sidebar-toggle]')); | ||
this.mobileBreakpoint = 992; | ||
|
||
this.init(); | ||
} | ||
|
||
init() { | ||
this.toggle(this.isSidebarOpen()); | ||
|
||
const that = this; | ||
|
||
this.$toggleLink.on('click', function () { | ||
that.toggle(!that.isSidebarOpen()); | ||
}); | ||
|
||
$(window).on('resize', function () { | ||
if ($(window).width() < that.mobileBreakpoint) { | ||
that.close(); | ||
} | ||
that.setViewContentMaxWidth(); | ||
}); | ||
} | ||
|
||
changeState(key, state) { | ||
localStorage.setItem(key, state); | ||
Turbolinks.clearCache(); | ||
} | ||
|
||
close() { | ||
this.$sidebar | ||
.removeClass('sidebar-expanded') | ||
.addClass('sidebar-collapsed') | ||
.attr('data-behavior', 'sidebar'); | ||
|
||
this.setViewContentMaxWidth(); | ||
this.changeState(this.storageKey, false); | ||
} | ||
|
||
isSidebarOpen() { | ||
if (JSON.parse(localStorage.getItem(this.storageKey)) === null) { | ||
return true; | ||
} else { | ||
return JSON.parse(localStorage.getItem(this.storageKey)); | ||
} | ||
} | ||
|
||
open() { | ||
this.$sidebar | ||
.removeClass('sidebar-collapsed') | ||
.addClass('sidebar-expanded') | ||
.attr('data-behavior', 'sidebar sidebar-expanded'); | ||
|
||
this.setViewContentMaxWidth(); | ||
this.changeState(this.storageKey, true); | ||
} | ||
|
||
setViewContentMaxWidth() { | ||
const collapsedSidebarsWidth = 10; | ||
const viewportWidth = $(window).width() - collapsedSidebarsWidth; | ||
let sidebarsWidth = 0; | ||
|
||
$('[data-behavior~=sidebar]').each(function () { | ||
sidebarsWidth += $(this).width(); | ||
}); | ||
|
||
const limit = | ||
$(window).width() < this.mobileBreakpoint | ||
? viewportWidth | ||
: viewportWidth - sidebarsWidth; | ||
|
||
$('[data-behavior~=view-content]').css('max-width', limit); | ||
} | ||
|
||
toggle(openSidebar) { | ||
openSidebar ? this.open() : this.close(); | ||
} | ||
} | ||
|
||
window.Sidebar = Sidebar; | ||
})(jQuery, window); |
Oops, something went wrong.