9a53b0f44a
- Build Syntax Highlighter based on https://github.com/syntaxhighlighter/syntaxhighlighter/wiki/Building and use theme generated by fxn.
- This also bundles these brushes in the file itself- ruby,css,xml,sql,javascript,plain. Generation command used:
gulp build --compat --brushes=javascript,ruby,xml,sql,plain --theme=/Path/To/RailsSource/rails/guides/assets/stylesheets/syntaxhighlighter/shThemeRailsGuides.css
- rm all old js and css files
- Moved over how JS configuration is created for Syntax Highlighter
- Fixed layout for all imports
- Fixes bug with old copy paste, generating wrong space character on webkit 7caa9632e7/src/dom.js (L227)
Fixes #25655
54 lines
1.7 KiB
JavaScript
54 lines
1.7 KiB
JavaScript
$.fn.selectGuide = function(guide) {
|
|
$("select", this).val(guide);
|
|
};
|
|
|
|
var guidesIndex = {
|
|
bind: function() {
|
|
var currentGuidePath = window.location.pathname;
|
|
var currentGuide = currentGuidePath.substring(currentGuidePath.lastIndexOf("/")+1);
|
|
$(".guides-index-small").
|
|
on("change", "select", guidesIndex.navigate).
|
|
selectGuide(currentGuide);
|
|
$(document).on("click", ".more-info-button", function(e){
|
|
e.stopPropagation();
|
|
if ($(".more-info-links").is(":visible")) {
|
|
$(".more-info-links").addClass("s-hidden").unwrap();
|
|
} else {
|
|
$(".more-info-links").wrap("<div class='more-info-container'></div>").removeClass("s-hidden");
|
|
}
|
|
});
|
|
$("#guidesMenu").on("click", function(e) {
|
|
$("#guides").toggle();
|
|
return false;
|
|
});
|
|
$(document).on("click", function(e){
|
|
e.stopPropagation();
|
|
var $button = $(".more-info-button");
|
|
var element;
|
|
|
|
// Cross browser find the element that had the event
|
|
if (e.target) element = e.target;
|
|
else if (e.srcElement) element = e.srcElement;
|
|
|
|
// Defeat the older Safari bug:
|
|
// http://www.quirksmode.org/js/events_properties.html
|
|
if (element.nodeType === 3) element = element.parentNode;
|
|
|
|
var $element = $(element);
|
|
|
|
var $container = $element.parents(".more-info-container");
|
|
|
|
// We've captured a click outside the popup
|
|
if($container.length === 0){
|
|
$container = $button.next(".more-info-container");
|
|
$container.find(".more-info-links").addClass("s-hidden").unwrap();
|
|
}
|
|
});
|
|
},
|
|
navigate: function(e){
|
|
var $list = $(e.target);
|
|
var url = $list.val();
|
|
window.location = url;
|
|
}
|
|
};
|