1/** 2 * Automatic behaviours 3 * 4 * This class wraps various JavaScript functionalities that are triggered 5 * automatically whenever a certain object is in the DOM or a certain CSS 6 * class was found 7 */ 8 9dw_behaviour = { 10 11 init: function(){ 12 dw_behaviour.focusMarker(); 13 dw_behaviour.scrollToMarker(); 14 dw_behaviour.closeMsgOnClick(); 15 dw_behaviour.removeHighlightOnClick(); 16 dw_behaviour.quickSelect(); 17 dw_behaviour.checkWindowsShares(); 18 }, 19 20 /** 21 * Looks for an element with the ID scroll__here at scrolls to it 22 */ 23 scrollToMarker: function(){ 24 var obj = jQuery('#scroll__here'); 25 if(obj.length) obj[0].scrollIntoView(); 26 }, 27 28 /** 29 * Looks for an element with the ID focus__this at sets focus to it 30 */ 31 focusMarker: function(){ 32 var obj = jQuery('#focus__this'); 33 if(obj.length) obj[0].focus(); 34 }, 35 36 /** 37 * Close messages shown by the msg() PHP function by click 38 */ 39 closeMsgOnClick: function(){ 40 jQuery('div.success, div.info, div.error, div.notify').click( 41 function(e){ 42 jQuery(e.target).fadeOut('fast'); 43 } 44 ); 45 }, 46 47 /** 48 * Remove all search highlighting when clicking on a highlighted term 49 * 50 * @FIXME would be nice to have it fade out 51 */ 52 removeHighlightOnClick: function(){ 53 jQuery('span.search_hit').click( 54 function(e){ 55 jQuery(e.target).removeClass('search_hit'); 56 } 57 ); 58 }, 59 60 /** 61 * Autosubmit quick select forms 62 * 63 * When a <select> tag has the class "quickselect", this script will 64 * automatically submit its parent form when the select value changes. 65 * It also hides the submit button of the form. 66 * 67 * @author Andreas Gohr <andi@splitbrain.org> 68 */ 69 quickSelect: function(){ 70 jQuery('select.quickselect') 71 .change(function(e){ e.target.form.submit(); }) 72 .parents('form').find('input[type=submit]').hide(); 73 }, 74 75 /** 76 * Display error for Windows Shares on browsers other than IE 77 * 78 * @author Michael Klier <chi@chimeric.de> 79 */ 80 checkWindowsShares: function() { 81 if(!LANG['nosmblinks']) return true; 82 if(document.all != null) return true; 83 84 jQuery('a.windows').click(function(){ 85 alert(LANG['nosmblinks']); 86 }); 87 } 88 89}; 90 91jQuery(dw_behaviour.init); 92