-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX Don't require jquery on the frontend (#2854)
- Loading branch information
1 parent
241fa3e
commit 55eabd6
Showing
3 changed files
with
66 additions
and
27 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,29 +1,69 @@ | ||
import $ from 'jquery'; | ||
(function() { | ||
function windowName(suffix) { | ||
const base = document.getElementsByTagName('base')[0].href.replace('http://','').replace(/\//g,'_').replace(/\./g,'_'); | ||
return base + suffix; | ||
} | ||
|
||
function windowName(suffix) { | ||
var base = document.getElementsByTagName('base')[0].href.replace('http://','').replace(/\//g,'_').replace(/\./g,'_'); | ||
return base + suffix; | ||
} | ||
function displayHide(elem) { | ||
const displayComputed = getComputedStyle(elem).display; | ||
elem.style.display = 'none'; | ||
elem.dataset.__toggle_display = displayComputed; | ||
} | ||
|
||
function displayShow(elem) { | ||
elem.style.display = elem.dataset.__toggle_display ? elem.dataset.__toggle_display : 'block'; | ||
} | ||
|
||
$(document).ready(function() { | ||
$('#switchView a.newWindow').on('click', function(e) { | ||
var w = window.open(this.href, windowName(this.target)); | ||
w.focus(); | ||
return false; | ||
}); | ||
function displayToggle(elem) { | ||
const displayComputed = getComputedStyle(elem).display; | ||
if (displayComputed !== 'none') { | ||
displayHide(elem); | ||
} else { | ||
displayShow(elem); | ||
} | ||
} | ||
|
||
$('#SilverStripeNavigatorLink').on('click', function(e) { | ||
$('#SilverStripeNavigatorLinkPopup').toggle(); | ||
return false; | ||
}); | ||
|
||
$('#SilverStripeNavigatorLinkPopup a.close').on('click', function(e) { | ||
$('#SilverStripeNavigatorLinkPopup').hide(); | ||
return false; | ||
}); | ||
|
||
$('#SilverStripeNavigatorLinkPopup input').on('focus',function(e) { | ||
this.select(); | ||
}); | ||
}); | ||
const newWindowLinks = document.querySelectorAll('#switchView a.newWindow'); | ||
if (newWindowLinks.length > 0) { | ||
for (const link of newWindowLinks.values()) { | ||
link.addEventListener('click', function(e) { | ||
e.preventDefault(); | ||
const w = window.open(link.href, windowName(link.target)); | ||
w.focus(); | ||
return false; | ||
}); | ||
} | ||
} | ||
|
||
const popup = document.getElementById('SilverStripeNavigatorLinkPopup'); | ||
if (popup) { | ||
const navigatorLink = document.getElementById('SilverStripeNavigatorLink'); | ||
if (navigatorLink) { | ||
navigatorLink.addEventListener('click', function(e) { | ||
e.preventDefault(); | ||
displayToggle(popup); | ||
return false; | ||
}); | ||
} | ||
|
||
const closeLinks = popup.querySelectorAll('a.close'); | ||
if (closeLinks.length > 0) { | ||
for (const link of closeLinks.values()) { | ||
link.addEventListener('click', function(e) { | ||
e.preventDefault(); | ||
displayHide(popup); | ||
return false; | ||
}); | ||
} | ||
} | ||
|
||
const inputs = popup.querySelectorAll('input'); | ||
if (inputs.length > 0) { | ||
for (const input of inputs.values()) { | ||
input.addEventListener('focus', function(e) { | ||
input.select(); | ||
}); | ||
} | ||
} | ||
} | ||
})(); |
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