| | 6674 | /* |
| | 6675 | --------------------------------------------------------------------------- |
| | 6676 | EVENTS - NEW VERSION |
| | 6677 | --------------------------------------------------------------------------- |
| | 6678 | */ |
| | 6679 | |
| | 6680 | HTMLArea.Events = |
| | 6681 | { |
| | 6682 | /** |
| | 6683 | * Events listeners |
| | 6684 | * @private |
| | 6685 | */ |
| | 6686 | listeners : [], |
| | 6687 | |
| | 6688 | /** |
| | 6689 | * DOM0 handlers |
| | 6690 | * @private |
| | 6691 | */ |
| | 6692 | DOM0Handlers : [], |
| | 6693 | |
| | 6694 | /** |
| | 6695 | * DOM0 listeners |
| | 6696 | * @private |
| | 6697 | */ |
| | 6698 | DOM0Listeners : [], |
| | 6699 | |
| | 6700 | /** |
| | 6701 | * Fix the callback event object especially for IE which provides it in window.event |
| | 6702 | * @param {Event} evt Event (for W3C compliant) and null for IE |
| | 6703 | * @return {Event} Unified event |
| | 6704 | * @private |
| | 6705 | */ |
| | 6706 | fix : function(evt) { return evt || window.event; }, |
| | 6707 | |
| | 6708 | /** |
| | 6709 | * Add a listener to an element |
| | 6710 | * @param {string | HTMLElement} element Element ID or the reference |
| | 6711 | * @param {string | array} type Event type to add or indexed array of event types to add |
| | 6712 | * @param {function} handler Event handler |
| | 6713 | * @param {object} scope Execution scope (optional) default to the element reference |
| | 6714 | * @param {object} arbitraryObj Arbitrary object provided to the handler (optional) default to null |
| | 6715 | * @param {boolean|string} forceDom0 true if DOM0 model is forced, 'prepend' if DOM0 model is forced and must be prepended to the existings listeners of the same name (optional) default to false |
| | 6716 | * @return {boolean} true if the binding is successfull |
| | 6717 | * @public |
| | 6718 | */ |
| | 6719 | add : function(element, type, handler, scope, arbitraryObj, forceDom0) |
| | 6720 | { |
| | 6721 | // manage multiple type with an array |
| | 6722 | if ( typeof type !== 'string' && type.length && type.length > 0 ) |
| | 6723 | { |
| | 6724 | var returnValue = true; /* return value */ |
| | 6725 | for ( var j = 0, m = type.length; j < m; j++ ) |
| | 6726 | { |
| | 6727 | returnValue = HTMLArea.Events.add(element, type[j], handler, scope, arbitraryObj, forceDom0) && returnValue; |
| | 6728 | } |
| | 6729 | return returnValue; |
| | 6730 | } |
| | 6731 | // if the element is a string, try to find its reference |
| | 6732 | var Element = typeof element === 'string' ? document.getElementById(element) : element; |
| | 6733 | if ( !Element ) { return false; } |
| | 6734 | |
| | 6735 | // determine application scope |
| | 6736 | scope = scope ? scope : Element; |
| | 6737 | |
| | 6738 | var wrapped = function(z) { return handler.call(scope, HTMLArea.Events.fix(z), arbitraryObj); }, /* Wrapped function called */ |
| | 6739 | listenerIndex = HTMLArea.Events.listeners.length, /* global listener index */ |
| | 6740 | isDOM0 = false; /* flag the type of event model used */ |
| | 6741 | |
| | 6742 | // check if DOM0 must be used |
| | 6743 | if ( forceDom0 || HTMLArea.Events._useDOM0(Element, type) ) |
| | 6744 | { |
| | 6745 | // bind the event to the object with DOM0 model |
| | 6746 | var DOM0Index = HTMLArea.Events._getDOM0Index(Element, type); |
| | 6747 | if ( DOM0Index == -1 ) |
| | 6748 | { |
| | 6749 | DOM0Index = HTMLArea.Events.DOM0Handlers.length; |
| | 6750 | // cache the signature for the DOM0 event |
| | 6751 | // [element, type, alreadySetHandler] |
| | 6752 | HTMLArea.Events.DOM0Handlers[DOM0Index] = [Element, type, Element['on' + type]]; |
| | 6753 | HTMLArea.Events.DOM0Listeners[DOM0Index] = []; |
| | 6754 | |
| | 6755 | // set our own handler which will be used to fire every listeners |
| | 6756 | // for this type of event on this element |
| | 6757 | Element['on' + type] = function(evt) { return HTMLArea.Events._fireDOM0.call(Element, HTMLArea.Events.fix(evt), DOM0Index); }; |
| | 6758 | } |
| | 6759 | |
| | 6760 | // add a reference to the wrapped listener to |
| | 6761 | // the custom stack of events |
| | 6762 | if ( forceDom0 == 'prepend' && HTMLArea.Events.DOM0Listeners[DOM0Index].length > 0 ) |
| | 6763 | { |
| | 6764 | HTMLArea.Events.DOM0Listeners[DOM0Index].unshift(listenerIndex); |
| | 6765 | } |
| | 6766 | else |
| | 6767 | { |
| | 6768 | HTMLArea.Events.DOM0Listeners[DOM0Index].push(listenerIndex); |
| | 6769 | } |
| | 6770 | isDOM0 = true; |
| | 6771 | } |
| | 6772 | else |
| | 6773 | { |
| | 6774 | HTMLArea.Events.bind(Element, type, wrapped); |
| | 6775 | } |
| | 6776 | |
| | 6777 | // cache the listener so we can try to automatically unload |
| | 6778 | HTMLArea.Events.listeners[listenerIndex] = [Element, type, handler, wrapped, scope, arbitraryObj, isDOM0]; |
| | 6779 | |
| | 6780 | return true; |
| | 6781 | }, |
| | 6782 | |
| | 6783 | /** |
| | 6784 | * Remove an event listener |
| | 6785 | * @param {string | HTMLElement} element Element ID or the reference |
| | 6786 | * @param {string | array} type Event type to remove or indexed array of event types to remove |
| | 6787 | * @param {function} handler Event handler |
| | 6788 | * @return {boolean} true if the removing is successfull |
| | 6789 | * @public |
| | 6790 | */ |
| | 6791 | remove : function(element, type, handler) |
| | 6792 | { |
| | 6793 | var returnValue = true; /* return value */ |
| | 6794 | // manage multiple type with an array |
| | 6795 | if ( typeof type !== 'string' && type.length && type.length > 0 ) |
| | 6796 | { |
| | 6797 | for ( var j = 0, m = type.length; j < m; j++ ) |
| | 6798 | { |
| | 6799 | returnValue = HTMLArea.Events.remove(element, type[j], handler) && returnValue; |
| | 6800 | } |
| | 6801 | return returnValue; |
| | 6802 | } |
| | 6803 | // if the element is a string, try to find its reference |
| | 6804 | var Element = typeof element == 'string' ? document.getElementById(element) : element; |
| | 6805 | if ( !Element ) { return false; } |
| | 6806 | |
| | 6807 | var listener = null, |
| | 6808 | listenerIndex = HTMLArea.Events._getListenerIndex(Element, type, handler); |
| | 6809 | if ( listenerIndex >= 0 ) |
| | 6810 | { |
| | 6811 | listener = HTMLArea.Events.listeners[listenerIndex]; |
| | 6812 | } |
| | 6813 | if ( !listener ) { return false; } |
| | 6814 | |
| | 6815 | // listener is set like this : [Element, type, handler, wrapped, scope, arbitraryObj, isDOM0]; |
| | 6816 | |
| | 6817 | // remove DOM0 listeners |
| | 6818 | if ( listener[6] === true ) |
| | 6819 | { |
| | 6820 | returnValue = HTMLArea.Events.removeDOM0(listenerIndex, Element, type); |
| | 6821 | } |
| | 6822 | // remove DOM2 et IE listeners |
| | 6823 | else |
| | 6824 | { |
| | 6825 | try |
| | 6826 | { |
| | 6827 | HTMLArea.Events.unbind(Element, type, listener[3]); |
| | 6828 | } |
| | 6829 | catch(x) |
| | 6830 | { |
| | 6831 | try |
| | 6832 | { |
| | 6833 | throw('Error removing event : "' + type + '"\nExc: ' + x + '\nElt: ' + Element + ( Element.tagName ? Element.tagName : '' ) + '\nHandler : ' + listener[3]); |
| | 6834 | } |
| | 6835 | catch (x) |
| | 6836 | { |
| | 6837 | returnValue = false; |
| | 6838 | } |
| | 6839 | } |
| | 6840 | } |
| | 6841 | |
| | 6842 | // removed the wrapped handler |
| | 6843 | delete HTMLArea.Events.listeners[listenerIndex][3]; |
| | 6844 | delete HTMLArea.Events.listeners[listenerIndex][2]; |
| | 6845 | delete HTMLArea.Events.listeners[listenerIndex]; |
| | 6846 | |
| | 6847 | return returnValue; |
| | 6848 | }, |
| | 6849 | |
| | 6850 | /** |
| | 6851 | * Cancel an event |
| | 6852 | * @param {Event} evt The event to cancel |
| | 6853 | * @public |
| | 6854 | */ |
| | 6855 | stop : function(evt) |
| | 6856 | { |
| | 6857 | HTMLArea.Events.stopPropagation(evt); |
| | 6858 | HTMLArea.Events.preventDefault(evt); |
| | 6859 | }, |
| | 6860 | |
| | 6861 | /** |
| | 6862 | * Find the listener position in the listeners cache |
| | 6863 | * listener is set like this : [Element, type, handler, wrapped, scope, arbitraryObj, isDOM0]; |
| | 6864 | * @param {HTMLElement} Element Element reference |
| | 6865 | * @param {string} type Event type to search |
| | 6866 | * @param {function} handler Event handler to find |
| | 6867 | * @return {integer} Index in the global listeners array |
| | 6868 | * @private |
| | 6869 | */ |
| | 6870 | _getListenerIndex : function(Element, type, handler) |
| | 6871 | { |
| | 6872 | for ( var i = 0, m = HTMLArea.Events.listeners.length; i < m; i++ ) |
| | 6873 | { |
| | 6874 | var L = HTMLArea.Events.listeners[i]; |
| | 6875 | if ( L && L[0] == Element && L[1] == type && L[2] == handler) |
| | 6876 | { |
| | 6877 | return i; |
| | 6878 | } |
| | 6879 | } |
| | 6880 | return -1; |
| | 6881 | }, |
| | 6882 | |
| | 6883 | /* |
| | 6884 | --------------------------------------------------------------------------- |
| | 6885 | DOM0 MODEL |
| | 6886 | --------------------------------------------------------------------------- |
| | 6887 | */ |
| | 6888 | |
| | 6889 | /** |
| | 6890 | * Find if the DOM0 must be used instead of DOM2 model |
| | 6891 | * @param {HTMLElement} Element Element reference |
| | 6892 | * @param {string} type Event type |
| | 6893 | * @return {boolean} true if DOM0 model must be used |
| | 6894 | * @private |
| | 6895 | */ |
| | 6896 | _useDOM0 : function(Element, type) |
| | 6897 | { |
| | 6898 | return ( ( !Element.addEventListener && !Element.attachEvent ) || ( type == "click" && navigator.userAgent.match(/safari/gi) ) ); |
| | 6899 | }, |
| | 6900 | |
| | 6901 | /** |
| | 6902 | * Find index of the DOM0 listener with the couple Element + type |
| | 6903 | * @param {HTMLElement} Element Element reference |
| | 6904 | * @param {string} type Event type to search |
| | 6905 | * @return {integer} Index in the DOM0 listeners array |
| | 6906 | * @private |
| | 6907 | */ |
| | 6908 | _getDOM0Index : function(Element, type) |
| | 6909 | { |
| | 6910 | for ( var i = 0, m = HTMLArea.Events.DOM0Handlers.length; i < m; i++ ) |
| | 6911 | { |
| | 6912 | var L = HTMLArea.Events.DOM0Handlers[i]; |
| | 6913 | if ( L && L[0] == Element && L[1] == type ) |
| | 6914 | { |
| | 6915 | return i; |
| | 6916 | } |
| | 6917 | } |
| | 6918 | return -1; |
| | 6919 | }, |
| | 6920 | |
| | 6921 | /** |
| | 6922 | * When DOM0 is used, handlers are called from this function to let us fire every listeners |
| | 6923 | * @param {Event} evt The current event |
| | 6924 | * @param {integer} DOM0Index The index of the DOM0 listener to call |
| | 6925 | * @scope Original HTMLElement |
| | 6926 | * @private |
| | 6927 | */ |
| | 6928 | _fireDOM0 : function(evt, DOM0Index) |
| | 6929 | { |
| | 6930 | var returnValue = true, /* return value */ |
| | 6931 | DOMListeners = HTMLArea.Events.DOM0Listeners[DOM0Index], /* DOM0 listeners */ |
| | 6932 | previousListener = HTMLArea.Events.DOM0Handlers[DOM0Index][2], /* previously set DOM0 listener */ |
| | 6933 | returnListener; /* return value of the listener function */ |
| | 6934 | for ( var i = 0, m = DOMListeners.length; i < m; i++ ) |
| | 6935 | { |
| | 6936 | var indexListener = DOMListeners[i]; /* listeners index */ |
| | 6937 | if ( indexListener ) |
| | 6938 | { |
| | 6939 | var listener = HTMLArea.Events.listeners[indexListener]; /* real listener reference */ |
| | 6940 | if ( listener ) |
| | 6941 | { |
| | 6942 | // listener is set like this : [Element, type, handler, wrapped, scope, arbitraryObj, isDOM0]; |
| | 6943 | // call the wrapped function |
| | 6944 | returnListener = listener[3].call(listener[4], evt, listener[5]); |
| | 6945 | returnListener = typeof returnListener == 'boolean' ? returnListener : true; |
| | 6946 | returnValue = returnValue && returnListener; |
| | 6947 | } |
| | 6948 | } |
| | 6949 | } |
| | 6950 | // if a previous listener was set, call it now |
| | 6951 | if ( typeof previousListener == 'function' ) |
| | 6952 | { |
| | 6953 | returnListener = previousListener.call(this, evt); |
| | 6954 | returnListener = typeof returnListener == 'boolean' ? returnListener : true; |
| | 6955 | returnValue = returnValue && returnListener; |
| | 6956 | } |
| | 6957 | return returnValue; |
| | 6958 | }, |
| | 6959 | |
| | 6960 | /** |
| | 6961 | * Remove a DOM0 listener |
| | 6962 | * @param {integer} index Index of the global listener removed |
| | 6963 | * @param {HTMLElement} Element Element reference |
| | 6964 | * @param {string} type Event type to remove |
| | 6965 | * @return {boolean} true if the remove was success, false on the contrary |
| | 6966 | * @private |
| | 6967 | */ |
| | 6968 | removeDOM0 : function(index, Element, type) |
| | 6969 | { |
| | 6970 | var DOM0Index = HTMLArea.Events._getDOM0Index(Element, type); |
| | 6971 | if ( DOM0Index !== -1 ) |
| | 6972 | { |
| | 6973 | for ( var j = 0, m = HTMLArea.Events.DOM0Listeners[DOM0Index].length; j < m; j++ ) |
| | 6974 | { |
| | 6975 | if ( HTMLArea.Events.DOM0Listeners[DOM0Index] == index ) |
| | 6976 | { |
| | 6977 | delete HTMLArea.Events.DOM0Listeners[DOM0Index][j]; |
| | 6978 | break; |
| | 6979 | } |
| | 6980 | } |
| | 6981 | // check if anymore valid listeners are defined |
| | 6982 | for ( j = 0, m = HTMLArea.Events.DOM0Listeners[DOM0Index].length; j < m; j++ ) |
| | 6983 | { |
| | 6984 | // there it is another active listener of this type for the element, |
| | 6985 | // since we have removed the needed listener, our job is done and we break here |
| | 6986 | if ( HTMLArea.Events.DOM0Listeners[DOM0Index][j] ) |
| | 6987 | { |
| | 6988 | return true; |
| | 6989 | } |
| | 6990 | } |
| | 6991 | // no break, so there is ZERO remaining listener for this type for the element, |
| | 6992 | // so we remove our handler |
| | 6993 | Element['on' + type] = null; |
| | 6994 | delete HTMLArea.Events.DOM0Handlers[DOM0Index]; |
| | 6995 | delete HTMLArea.Events.DOM0Listeners[DOM0Index]; |
| | 6996 | return true; |
| | 6997 | } |
| | 6998 | return false; |
| | 6999 | }, |
| | 7000 | |
| | 7001 | /** |
| | 7002 | * Events Flushing |
| | 7003 | * @private |
| | 7004 | */ |
| | 7005 | flusher : function() |
| | 7006 | { |
| | 7007 | var L, i, m; |
| | 7008 | |
| | 7009 | // remove our DOM0 handlers |
| | 7010 | for ( i = 0, m = HTMLArea.Events.DOM0Handlers.length; i < m; i++ ) |
| | 7011 | { |
| | 7012 | L = HTMLArea.Events.DOM0Handlers[i]; |
| | 7013 | if ( L ) |
| | 7014 | { |
| | 7015 | L[0]['on' + L[1]] = null; |
| | 7016 | } |
| | 7017 | } |
| | 7018 | |
| | 7019 | // remove remaining events |
| | 7020 | if ( HTMLArea.Events.listeners && HTMLArea.Events.listeners.length > 0 ) |
| | 7021 | { |
| | 7022 | for ( i = 0, m = HTMLArea.Events.listeners.length; i < m; i++ ) |
| | 7023 | { |
| | 7024 | L = HTMLArea.Events.listeners[i]; |
| | 7025 | if ( L ) |
| | 7026 | { |
| | 7027 | HTMLArea.Events.remove(L[0], L[1], L[2]); |
| | 7028 | } |
| | 7029 | } |
| | 7030 | } |
| | 7031 | |
| | 7032 | for ( i = __htmlareas.length; i--; ) |
| | 7033 | { |
| | 7034 | // this should be in every Xinha instance disposer method instead of here |
| | 7035 | __htmlareas[i].statusBarDispose(); |
| | 7036 | // we should instead do this |
| | 7037 | //__htmlareas[i].dispose(); |
| | 7038 | } |
| | 7039 | |
| | 7040 | // garbage IE |
| | 7041 | HTMLArea.collectGarbageForIE(); |
| | 7042 | } |
| | 7043 | |
| | 7044 | }; |
| | 7045 | |
| | 7046 | /* |
| | 7047 | --------------------------------------------------------------------------- |
| | 7048 | W3C DOM2 EVENTS MODEL |
| | 7049 | --------------------------------------------------------------------------- |
| | 7050 | */ |
| | 7051 | |
| | 7052 | if ( document.addEventListener ) |
| | 7053 | { |
| | 7054 | /** |
| | 7055 | * Buttons constants |
| | 7056 | * @type hash |
| | 7057 | * @public |
| | 7058 | */ |
| | 7059 | HTMLArea.Events.buttons = { left: 0, right: 2, middle: 1 }; |
| | 7060 | |
| | 7061 | /** |
| | 7062 | * Bind the element, the event and the callback function |
| | 7063 | * @param {HTMLElement} Element The element reference |
| | 7064 | * @param {String} type The event type to bind |
| | 7065 | * @param {Function} handler (Function) The callback function |
| | 7066 | * @private |
| | 7067 | */ |
| | 7068 | HTMLArea.Events.bind = function(Element, type, handler) { Element.addEventListener(type, handler, false); }; |
| | 7069 | |
| | 7070 | /** |
| | 7071 | * Unbind the element, the event and the callback function |
| | 7072 | * @param {HTMLElement} Element The element reference |
| | 7073 | * @param {String} type The event type to bind |
| | 7074 | * @param {Function} handler (Function) The callback function |
| | 7075 | * @private |
| | 7076 | */ |
| | 7077 | HTMLArea.Events.unbind = function(Element, type, handler) { Element.removeEventListener(type, handler, false); }; |
| | 7078 | |
| | 7079 | /** |
| | 7080 | * Cancel the default behavior from the event |
| | 7081 | * @param {Event} evt Event |
| | 7082 | * @public |
| | 7083 | */ |
| | 7084 | HTMLArea.Events.preventDefault = function(evt) { evt.preventDefault(); }; |
| | 7085 | |
| | 7086 | /** |
| | 7087 | * Cancel the event propagation |
| | 7088 | * @param {Event} evt Event |
| | 7089 | * @public |
| | 7090 | */ |
| | 7091 | HTMLArea.Events.stopPropagation = function(evt) { evt.stopPropagation(); }; |
| | 7092 | } |
| | 7093 | |
| | 7094 | /* |
| | 7095 | --------------------------------------------------------------------------- |
| | 7096 | IE EVENTS MODEL |
| | 7097 | --------------------------------------------------------------------------- |
| | 7098 | */ |
| | 7099 | else if ( document.attachEvent ) |
| | 7100 | { |
| | 7101 | HTMLArea.Events.buttons = { left: 1, right: 2, middle: 4 }; |
| | 7102 | HTMLArea.Events.bind = function(Element, type, handler) { Element.attachEvent('on' + type, handler); }; |
| | 7103 | HTMLArea.Events.unbind = function(Element, type, handler) { Element.detachEvent('on' + type, handler); }; |
| | 7104 | HTMLArea.Events.preventDefault = function(evt) { evt = HTMLArea.Events.fix(evt); evt.returnValue = false; }; |
| | 7105 | HTMLArea.Events.stopPropagation = function(evt) { evt = HTMLArea.Events.fix(evt); evt.cancelBubble = true; }; |
| | 7106 | } |
| | 7107 | |
| | 7108 | /* |
| | 7109 | --------------------------------------------------------------------------- |
| | 7110 | EVENT CALLBACK LISTENERS |
| | 7111 | --------------------------------------------------------------------------- |
| | 7112 | */ |
| | 7113 | |
| | 7114 | /** |
| | 7115 | * Callback listener for onchange on a selectbox in the icon toolbar |
| | 7116 | * @param {Event} evt The current event |
| | 7117 | * @param {array} arbitraryObject here : {array} [el,txt] |
| | 7118 | * @scope Xinha instance |
| | 7119 | * @private |
| | 7120 | */ |
| | 7121 | HTMLArea.onchange_toolbar_select = function(evt, arbitraryObject) |
| | 7122 | { |
| | 7123 | this._comboSelected(arbitraryObject[0], arbitraryObject[1]); |
| | 7124 | }; |
| | 7125 | |
| | 7126 | /** |
| | 7127 | * Callback listener for onmouseout on an icon in the icon toolbar |
| | 7128 | * @param {Event} evt The current event |
| | 7129 | * @param {array} arbitraryObject here : {object} obj |
| | 7130 | * @scope The icon HTMLElement |
| | 7131 | * @private |
| | 7132 | */ |
| | 7133 | HTMLArea.onmouseout_toolbar_button = function(evt, arbitraryObject) |
| | 7134 | { |
| | 7135 | if ( arbitraryObject.enabled ) |
| | 7136 | { |
| | 7137 | //HTMLArea._removeClass(this, "buttonHover"); |
| | 7138 | HTMLArea._removeClass(this, "buttonActive"); |
| | 7139 | if ( arbitraryObject.active ) |
| | 7140 | { |
| | 7141 | HTMLArea._addClass(this, "buttonPressed"); |
| | 7142 | } |
| | 7143 | } |
| | 7144 | }; |
| | 7145 | |
| | 7146 | /** |
| | 7147 | * Callback listener for onmousedown on an icon in the icon toolbar |
| | 7148 | * @param {Event} evt The current event |
| | 7149 | * @param {array} arbitraryObject here : {object} obj |
| | 7150 | * @scope The icon HTMLElement |
| | 7151 | * @private |
| | 7152 | */ |
| | 7153 | HTMLArea.onmousedown_toolbar_button = function(evt, arbitraryObject) |
| | 7154 | { |
| | 7155 | if ( arbitraryObject.enabled ) |
| | 7156 | { |
| | 7157 | HTMLArea._addClass(this, "buttonActive"); |
| | 7158 | HTMLArea._removeClass(this, "buttonPressed"); |
| | 7159 | HTMLArea.Events.stop(evt); |
| | 7160 | } |
| | 7161 | }; |
| | 7162 | |
| | 7163 | /** |
| | 7164 | * Callback listener for onclick on an icon in the icon toolbar |
| | 7165 | * @param {Event} evt The current event |
| | 7166 | * @param {array} arbitraryObject here : {array} [el,obj] |
| | 7167 | * @scope Xinha instance |
| | 7168 | * @private |
| | 7169 | */ |
| | 7170 | HTMLArea.onclick_toolbar_button = function(evt, arbitraryObject) |
| | 7171 | { |
| | 7172 | var el = arbitraryObject[0], |
| | 7173 | obj = arbitraryObject[1]; |
| | 7174 | if ( obj.enabled ) |
| | 7175 | { |
| | 7176 | HTMLArea._removeClass(el, "buttonActive"); |
| | 7177 | //HTMLArea._removeClass(el, "buttonHover"); |
| | 7178 | if ( HTMLArea.is_gecko ) |
| | 7179 | { |
| | 7180 | this.activateEditor(); |
| | 7181 | } |
| | 7182 | obj.cmd(this, obj.name, obj); |
| | 7183 | HTMLArea.Events.stop(evt); |
| | 7184 | } |
| | 7185 | }; |
| | 7186 | |
| | 7187 | /** |
| | 7188 | * Callback listener for onload of the main iframe |
| | 7189 | * @param {Event} evt The current event |
| | 7190 | * @scope Xinha instance |
| | 7191 | * @private |
| | 7192 | */ |
| | 7193 | HTMLArea.onload_iframe = function(evt) |
| | 7194 | { |
| | 7195 | if ( !this._iframeLoadDone ) |
| | 7196 | { |
| | 7197 | this._iframeLoadDone = true; |
| | 7198 | this.initIframe(); |
| | 7199 | } |
| | 7200 | }; |
| | 7201 | |
| | 7202 | /** |
| | 7203 | * Generic callback listeners for ["keydown", "keypress", "mousedown", "mouseup", "drag"] of the iframe document |
| | 7204 | * @param {Event} evt The current event, the event in the iframe for IE |
| | 7205 | * @scope Xinha instance |
| | 7206 | * @private |
| | 7207 | */ |
| | 7208 | if ( HTMLArea.is_ie ) |
| | 7209 | { |
| | 7210 | HTMLArea.keymousedrag_doc = function(evt) { this._editorEvent(this._iframe.contentWindow.event); }; |
| | 7211 | } |
| | 7212 | else |
| | 7213 | { |
| | 7214 | HTMLArea.keymousedrag_doc = function(evt) { this._editorEvent(evt); }; |
| | 7215 | } |
| | 7216 | |
| | 7217 | /** |
| | 7218 | * Callback listener for onclick on an element on the statusbar |
| | 7219 | * @param {Event} evt The current event |
| | 7220 | * @param {array} arbitraryObject here : {HTMLElement} the tag A rerefence |
| | 7221 | * @scope Xinha instance |
| | 7222 | * @private |
| | 7223 | */ |
| | 7224 | HTMLArea.onclick_status_updateToolbar = function(evt, arbitraryObject) |
| | 7225 | { |
| | 7226 | arbitraryObject.blur(); |
| | 7227 | this.selectNodeContents(arbitraryObject.el); |
| | 7228 | this.updateToolbar(true); |
| | 7229 | HTMLArea.Events.stop(evt); |
| | 7230 | }; |
| | 7231 | |
| | 7232 | /** |
| | 7233 | * Callback listener for oncontextmenu on an element on the statusbar |
| | 7234 | * @param {Event} evt The current event |
| | 7235 | * @param {array} arbitraryObject here : {HTMLElement} the ancestor represented by the tag A |
| | 7236 | * @scope the a tag HTMLElement in the statusbar |
| | 7237 | * @private |
| | 7238 | */ |
| | 7239 | HTMLArea.oncontextmenu_status = function(evt, arbitraryObject) |
| | 7240 | { |
| | 7241 | // TODO: add context menu here |
| | 7242 | this.blur(); |
| | 7243 | var info = "Inline style:\n\n" + arbitraryObject.style.cssText.split(/;\s*/).join(";\n"); |
| | 7244 | HTMLArea.Events.stop(evt); |
| | 7245 | }; |
| | 7246 | |
| | 7247 | /** |
| | 7248 | * Callback listener for onsubmit (DOM0 model) on the textarea form |
| | 7249 | * @param {Event} evt The current event |
| | 7250 | * @param {array} arbitraryObject here : {HTMLElement} textarea |
| | 7251 | * @scope Xinha instance |
| | 7252 | * @private |
| | 7253 | */ |
| | 7254 | HTMLArea.onsubmit_form = function(evt, arbitraryObject) |
| | 7255 | { |
| | 7256 | arbitraryObject.value = this.outwardHtml(this.getHTML()); |
| | 7257 | return true; |
| | 7258 | }; |
| | 7259 | |
| | 7260 | /** |
| | 7261 | * Callback listener for onreset (DOM0 model) on the textarea form |
| | 7262 | * @param {Event} evt The current event |
| | 7263 | * @param {array} arbitraryObject here : {string} initial textarea value |
| | 7264 | * @scope Xinha instance |
| | 7265 | * @private |
| | 7266 | */ |
| | 7267 | HTMLArea.onreset_form = function(evt, arbitraryObject) |
| | 7268 | { |
| | 7269 | this.setHTML(this.inwardHtml(arbitraryObject)); |
| | 7270 | this.updateToolbar(); |
| | 7271 | return true; |
| | 7272 | }; |
| | 7273 | |
| | 7274 | /** |
| | 7275 | * Callback listener for unload (DOM0 model) on the window for the back/forward case |
| | 7276 | * @param {Event} evt The current event |
| | 7277 | * @param {array} arbitraryObject here : {HTMLElement} textarea |
| | 7278 | * @scope Xinha instance |
| | 7279 | * @private |
| | 7280 | */ |
| | 7281 | HTMLArea.onunload_backforward = function(evt, arbitraryObject) |
| | 7282 | { |
| | 7283 | arbitraryObject.value = this.outwardHtml(this.getHTML()); |
| | 7284 | return true; |
| | 7285 | }; |
| | 7286 | |
| | 7287 | |
| | 7288 | |
| | 7289 | /* |
| | 7290 | --------------------------------------------------------------------------- |
| | 7291 | FINALIZE |
| | 7292 | --------------------------------------------------------------------------- |
| | 7293 | */ |