') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); Handle by widmoser · Pull Request #178 · angular-ui/ui-layout · GitHub
Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,6 +100,13 @@ Default: `false`

Like `disableToggle` above but only removes the arrows on mobile devices (max-device-width: 480px).

### showHandle

Type: `Boolean`
Default: `false`

Whether to show a handle in the middle of a splitbar. If toggle is enabled at the same time, the handle is shown between
the two toggle buttons. The handle has the css class `.ui-splitbar-handle`.

## Child Attributes

Expand Down
19 changes: 17 additions & 2 deletions src/ui-layout.css
Original file line numberDiff line numberDiff line change
Expand Up@@ -73,9 +73,13 @@
overflow-x: hidden;
}

.ui-layout-column > .ui-splitbar > a:not(.ui-splitbar-handle-container),
.ui-layout-row > .ui-splitbar > a:not(.ui-splitbar-handle-container) {
cursor: pointer;
}

.ui-layout-column > .ui-splitbar > a,
.ui-layout-row > .ui-splitbar > a {
cursor: pointer;
text-align: center;
font-size: 16px;
color: #aaa;
Expand DownExpand Up@@ -127,8 +131,19 @@
margin-top: 0.45em;
}

.ui-splitbar-handle {
width: 10px;
height: 2px;
box-shadow: inset 0 0 0 32px, 0 -6px, 0 6px;
margin: 12px 0;
}

/* Allow disabling of icons */
.no-toggle .ui-splitbar-icon {
.no-toggle .ui-splitbar-toggle {
display: none;
}

.no-handle .ui-splitbar-handle {
display: none;
}

Expand Down
16 changes: 10 additions & 6 deletions src/ui-layout.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,6 +52,9 @@ angular.module('ui.layout', [])
if (opts.disableMobileToggle) {
$element.addClass('no-mobile-toggle');
}
if (!opts.showHandle) {
$element.addClass('no-handle');
}

// Initial global size definition
opts.sizes = opts.sizes || [];
Expand DownExpand Up@@ -422,7 +425,7 @@ angular.module('ui.layout', [])
el = splitter.element[0].children[0];
} else {
splitter = ctrl.containers[index - 1];
el = splitter.element[0].children[1];
el = splitter.element[0].children[2];
}

$timeout(function(){
Expand DownExpand Up@@ -688,7 +691,7 @@ angular.module('ui.layout', [])

//icon <a> elements
var prevButton = angular.element(element.children()[0]);
var afterButton = angular.element(element.children()[1]);
var afterButton = angular.element(element.children()[2]);

//icon <span> elements
var prevIcon = angular.element(prevButton.children()[0]);
Expand All@@ -714,7 +717,7 @@ angular.module('ui.layout', [])

if(previousSplitbar !== null) {
prevSplitbarBeforeButton = angular.element(previousSplitbar.element.children()[0]);
prevSplitbarAfterButton = angular.element(previousSplitbar.element.children()[1]);
prevSplitbarAfterButton = angular.element(previousSplitbar.element.children()[2]);
}

if(ctrl.isUsingColumnFlow) {
Expand DownExpand Up@@ -774,7 +777,7 @@ angular.module('ui.layout', [])

if(nextSplitbar !== null) {
nextSplitbarBeforeButton = angular.element(nextSplitbar.element.children()[0]);
nextSplitbarAfterButton = angular.element(nextSplitbar.element.children()[1]);
nextSplitbarAfterButton = angular.element(nextSplitbar.element.children()[2]);
}

if(ctrl.isUsingColumnFlow) {
Expand DownExpand Up@@ -947,8 +950,9 @@ angular.module('ui.layout', [])
var children = parent.children();
var index = ctrl.indexOfElement(element);
var splitbar = angular.element('<div ui-splitbar>' +
'<a><span class="ui-splitbar-icon"></span></a>' +
'<a><span class="ui-splitbar-icon"></span></a>' +
'<a><span class="ui-splitbar-icon ui-splitbar-toggle"></span></a>' +
'<a class="ui-splitbar-handle-container"><span class="ui-splitbar-icon ui-splitbar-handle"></span></a>' +
'<a><span class="ui-splitbar-icon ui-splitbar-toggle"></span></a>' +
'</div>');
if(0 < index && !ctrl.hasSplitbarBefore(scope.container)) {
angular.element(children[index-1]).after(splitbar);
Expand Down
2 changes: 1 addition & 1 deletion test/layout-scenar.spec.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -141,7 +141,7 @@ function splitMoveTests(description, startEvent, moveEvent, endEvent) {

beforeEach(function() {
toggleBeforeButton = $splitbar.children()[0];
toggleAfterButton = $splitbar.children()[1];
toggleAfterButton = $splitbar.children()[2];
});

it('should exist', function() {
Expand Down