guibik.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /**
  2. * Implementation of Drupal behavior.
  3. */
  4. (function($) {
  5. Drupal.behaviors.guibik = {};
  6. Drupal.behaviors.guibik.attach = function(context) {
  7. $('form.form-edit', '.views-edit-view').each(function(index) {
  8. var $this = $(this),
  9. _alt = false,
  10. _submit = function(event){
  11. // console.log('_submit');
  12. event.preventDefault();
  13. $('input[type=submit]#edit-actions-save', $this).focus();
  14. $this.submit();
  15. return false;
  16. };
  17. $(document).bind({
  18. keydown: function(event) {
  19. // console.log('keydown', event);
  20. switch(event.keyCode){
  21. case 18:
  22. _alt = true;
  23. break;
  24. case 83: // s
  25. if(_alt)
  26. return _submit(event);
  27. }
  28. },
  29. keyup: function(event) {
  30. // console.log('keyup', event);
  31. switch(event.keyCode){
  32. case 18:
  33. _alt = false;
  34. break;
  35. }
  36. }
  37. });
  38. // $(document).keydown(function(event){
  39. // console.log(event);
  40. // });
  41. });
  42. };
  43. Drupal.behaviors.init_theme = {};
  44. Drupal.behaviors.init_theme.attach = function (context) {
  45. // Growl-style system messages
  46. $('#messages-and-help > div.messages:not(.processed)')
  47. .addClass('processed')
  48. .each(function() {
  49. // If a message meets these criteria, we don't autoclose
  50. // - contains a link
  51. // - is an error or warning
  52. // - contains a lenghthy amount of text
  53. if ($('a', this).size() || $(this).is('.error') || $(this).is('.warning') || $(this).text().length > 100) {
  54. $(this).prepend("<span class='close'>X</span>");
  55. $('span.close', this).click(function() {
  56. $(this).parent().slideUp('fast');
  57. });
  58. }
  59. else {
  60. // This essentially adds a 3 second pause before hiding the message.
  61. $(this).animate({opacity:1}, 5000, 'linear', function() {
  62. $(this).slideUp('fast');
  63. });
  64. }
  65. });
  66. };
  67. })(jQuery);