2
0

application.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. $(function(){
  2. $.fn.springPopover = function(){
  3. this.each(function(i,e){
  4. var $e = $(e);
  5. var contents = $e.html();
  6. $e.html("<span class='btn'>"+$e.data('title')+"</span>").
  7. popover({content: contents, trigger: 'click', html: true});
  8. });
  9. return this;
  10. };
  11. $("#scrim").click(function() {
  12. $(".js-item-dropdown--wrapper").removeClass("js-open");
  13. $(".js-item--open-dropdown").removeClass("js-show");
  14. $("#scrim").removeClass("js-show");
  15. });
  16. //OPENS SEARCH DROPDOWN
  17. $(".js-search-input-open").click(function() {
  18. $(".nav-search").addClass("js-highlight");
  19. var inputContainer = $(".js-search-dropdown");
  20. var input = $(".js-search-input");
  21. inputContainer.addClass("js-show");
  22. //FOCUSES SEARCH INPUT ON OPEN
  23. setTimeout(function() {
  24. input.focus();
  25. }, 100);
  26. //CLOSES SEARCH DROPDOWN
  27. $(".body--container, .js-search-input-close").click(function() {
  28. inputContainer.removeClass("js-show");
  29. $(".nav-search").removeClass("js-highlight");
  30. });
  31. });
  32. //AUTO OPENS SEARCH DROPDOWN ON SEARCH VIEW AND
  33. if (window.location.pathname == "/search") {
  34. $(".nav-search").addClass("js-highlight");
  35. $(".js-search-dropdown").addClass("js-show no-animation");
  36. //PREPOPULATES INPUT WITH SEARCH QUERY AND
  37. var searchQuery = decodeURIComponent(window.location.search.replace(/\+/g," "));
  38. var seachStart = searchQuery.search("q=");
  39. var searchString = searchQuery.substr(seachStart+2);
  40. $(".js-search-input").val(searchString);
  41. //PREPOPULATES TITLE WITH SEARCH QUERY
  42. $(".js-search-results--title").html(searchString);
  43. //CLOSES SEARCH DROPDOWN
  44. $(".js-search-input-close").click(function() {
  45. $(".js-search-dropdown").removeClass("js-show no-animation");
  46. $(".nav-search").removeClass("js-highlight");
  47. });
  48. };
  49. $.fn.showPreferredLink = function() {
  50. this.find("li").hide();
  51. this.find("li." + detectOs() + detectArch()).show();
  52. return this;
  53. };
  54. $('.download-links').showPreferredLink();
  55. new Spring.ProjectDocumentationWidget();
  56. });
  57. var detectOs = function() {
  58. if (navigator.appVersion.indexOf("Win")!=-1) return "Windows";
  59. if (navigator.appVersion.indexOf("Mac")!=-1) return "Mac";
  60. if (navigator.appVersion.indexOf("Linux")!=-1) return "Linux";
  61. return "Unknown";
  62. }
  63. var detectArch = function() {
  64. if (navigator.platform.indexOf("Win64") !== -1) {
  65. return "64"
  66. }
  67. if (navigator.platform.indexOf("Linux x86_64") !== -1) {
  68. return "64";
  69. }
  70. if (/Mac OS X 10.[0-5]/.test(navigator.userAgent)) {
  71. return "32"
  72. }
  73. if (navigator.userAgent.indexOf("Mac OS X") !== -1) {
  74. return "64"
  75. }
  76. return "32";
  77. }