adminimal_theme.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. (function($) {
  2. 'use strict';
  3. // Define jRespond Media queries.
  4. var jRes = jRespond([
  5. {
  6. label: 'mobile',
  7. enter: 0,
  8. exit: 480
  9. },{
  10. label: 'tablet',
  11. enter: 481,
  12. exit: 979
  13. },{
  14. label: 'desktop',
  15. enter: 980,
  16. exit: 9999
  17. }
  18. ]);
  19. // Detect Operating system and add class to the body.
  20. Drupal.behaviors.adminimal_os_class = {
  21. attach: function (context, settings) {
  22. // Detect if OS is mac based.
  23. if (navigator.userAgent.indexOf('Mac OS X') != -1) {
  24. $("body").addClass("mac");
  25. }
  26. }
  27. };
  28. // Modify the Search field for module filter.
  29. Drupal.behaviors.adminimal_module_filter_box = {
  30. attach: function (context, settings) {
  31. //Add default hint value using the HTML5 placeholder attribute.
  32. $('input#edit-module-filter-name').attr( "placeholder", Drupal.t('Search') );
  33. }
  34. };
  35. // Fix some krumo styling.
  36. Drupal.behaviors.krumo_remove_class = {
  37. attach: function (context, settings) {
  38. // Find status messages that has krumo div inside them, and change the classes.
  39. $('#console .messages.status').has("div.krumo-root").removeClass().addClass( "krumo-wrapper" );
  40. }
  41. };
  42. // Add media query classes to the body tag.
  43. Drupal.behaviors.adminimal_media_queries = {
  44. attach: function (context, settings) {
  45. jRes.addFunc([
  46. {
  47. breakpoint: 'mobile',
  48. enter: function() {
  49. $( "body" ).addClass( "mq-mobile" );
  50. },
  51. exit: function() {
  52. $( "body" ).removeClass( "mq-mobile" );
  53. }
  54. },{
  55. breakpoint: 'tablet',
  56. enter: function() {
  57. $( "body" ).addClass( "mq-tablet" );
  58. },
  59. exit: function() {
  60. $( "body" ).removeClass( "mq-tablet" );
  61. }
  62. },{
  63. breakpoint: 'desktop',
  64. enter: function() {
  65. $( "body" ).addClass( "mq-desktop" );
  66. },
  67. exit: function() {
  68. $( "body" ).removeClass( "mq-desktop" );
  69. }
  70. }
  71. ]);
  72. }
  73. };
  74. // Move the active primary tab on mobile to be displayed last.
  75. Drupal.behaviors.adminimal_move_active_primary_tab = {
  76. attach: function (context, settings) {
  77. // Add primary tabs class to the branding div for the bottom border.
  78. $('#branding').has("ul.tabs.primary").addClass( "has-primary-tabs" );
  79. // register enter and exit functions for a single breakpoint
  80. jRes.addFunc({
  81. breakpoint: 'mobile',
  82. enter: function() {
  83. $( "ul.tabs.primary li.active" ).clone().appendTo( "ul.tabs.primary" ).removeClass( "active" ).addClass( "current" );
  84. $( "ul.tabs.primary li.active" ).css("display", "none");
  85. },
  86. exit: function() {
  87. $( "ul.tabs.primary li.active" ).css("display", "table");
  88. $( "ul.tabs.primary li.current" ).css("display", "none");
  89. }
  90. });
  91. }
  92. };
  93. })(jQuery);