adminimal_theme.js 2.3 KB

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