Script.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. function display_message(message, type="info") {
  2. if ($(".alert-wrapper").is(":empty")) {
  3. var flag = true;
  4. }
  5. $(".alert-wrapper").html("<div class='alert'><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>&times;</span></button>"+message+"</div>");
  6. $(".alert").addClass("alert-" + type);
  7. if (flag) {
  8. $(".alert").css('display', 'none');
  9. }
  10. if ($(".alert").css("display") == "none")
  11. $(".alert").slideToggle();
  12. }
  13. var updateSelect = function() {
  14. if ($("#typeselect").val() == "page") {
  15. $("#linkselect").css("display", "none");
  16. $("#linkselect input").attr("name", "inactive");
  17. $("#pageselect").css("display", "table");
  18. $("#pageselect select").attr("name", "value");
  19. } else if ($("#typeselect").val() == "link") {
  20. $("#linkselect").css("display", "table");
  21. $("#linkselect input").attr("name", "value");
  22. $("#pageselect").css("display", "none");
  23. $("#pageselect select").attr("name", "inactive");
  24. }
  25. }
  26. $(document).ready(function(){
  27. $("#typeselect").change(function(){
  28. updateSelect();
  29. });
  30. $('[data-toggle="tooltip"]').tooltip();
  31. });
  32. $(function() {
  33. $('#side-menu').metisMenu();
  34. });
  35. //Loads the correct sidebar on window load,
  36. //collapses the sidebar on window resize.
  37. // Sets the min-height of #page-wrapper to window size
  38. $(function() {
  39. $(window).bind("load resize", function() {
  40. topOffset = 50;
  41. width = (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width;
  42. if (width < 768) {
  43. $('div.navbar-collapse').addClass('collapse');
  44. topOffset = 100; // 2-row-menu
  45. } else {
  46. $('div.navbar-collapse').removeClass('collapse');
  47. }
  48. height = ((this.window.innerHeight > 0) ? this.window.innerHeight : this.screen.height) - 1;
  49. height = height - topOffset;
  50. if (height < 1) height = 1;
  51. if (height > topOffset) {
  52. $("#page-wrapper").css("min-height", (height) + "px");
  53. }
  54. });
  55. var url = window.location;
  56. var element = $('ul.nav a').filter(function() {
  57. return this.href == url || url.href.indexOf(this.href) == 0;
  58. }).addClass('active').parent().parent().addClass('in').parent();
  59. if (element.is('li')) {
  60. element.addClass('active');
  61. }
  62. });