1 /*
  2  * ***** BEGIN LICENSE BLOCK *****
  3  * Zimbra Collaboration Suite Web Client
  4  * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013, 2014, 2015, 2016 Synacor, Inc.
  5  *
  6  * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the "License");
  7  * you may not use this file except in compliance with the License.
  8  * You may obtain a copy of the License at: https://www.zimbra.com/license
  9  * The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15
 10  * have been added to cover use of software over a computer network and provide for limited attribution
 11  * for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
 12  *
 13  * Software distributed under the License is distributed on an "AS IS" basis,
 14  * WITHOUT WARRANTY OF ANY KIND, either express or implied.
 15  * See the License for the specific language governing rights and limitations under the License.
 16  * The Original Code is Zimbra Open Source Web Client.
 17  * The Initial Developer of the Original Code is Zimbra, Inc.  All rights to the Original Code were
 18  * transferred by Zimbra, Inc. to Synacor, Inc. on September 14, 2015.
 19  *
 20  * All portions of the code are Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013, 2014, 2015, 2016 Synacor, Inc. All Rights Reserved.
 21  * ***** END LICENSE BLOCK *****
 22  */
 23 
 24 /**
 25  * @class
 26  * This class is the base class of all DWT events.
 27  * 
 28  * @param {boolean} 	__init 	a dummy parameter used for class initialization
 29  * 
 30  * @author Ross Dargahi
 31  * @author Conrad Damon
 32  * 
 33  */
 34 DwtEvent = function(__init) {
 35 	if (arguments.length == 0) return;
 36 	/**
 37 	 * The Dwt object that generated the event
 38 	 * @type DwtControl
 39 	 */
 40 	this.dwtObj = null;
 41 }
 42 
 43 /**
 44  * Returns a string representation of the object.
 45  * 
 46  * @return		{string}		a string representation of the object
 47  */
 48 DwtEvent.prototype.toString = 
 49 function() {
 50 	return "DwtEvent";
 51 }
 52 
 53 // native browser events - value is the associated DOM property
 54 /**
 55  * Browser "onchange" event.
 56  */
 57 DwtEvent.ONCHANGE = "onchange";
 58 
 59 /**
 60  * Browser "onclick" event.
 61  */
 62 DwtEvent.ONCLICK = "onclick";
 63 
 64 /**
 65  * Browser "oncontextmenu" event.
 66  */
 67 DwtEvent.ONCONTEXTMENU = "oncontextmenu";
 68 
 69 /**
 70  * Browser double-click event "ondblclick" event.
 71  */
 72 DwtEvent.ONDBLCLICK = "ondblclick";
 73 
 74 /**
 75  * Browser "onfocus" event.
 76  */
 77 DwtEvent.ONFOCUS = "onfocus";
 78 
 79 /**
 80  * Browser "onblur" event.
 81  */
 82 DwtEvent.ONBLUR = "onblur";
 83 
 84 /**
 85  * Browser "onkeydown" event.
 86  */
 87 DwtEvent.ONKEYDOWN = "onkeydown";
 88 
 89 /**
 90  * Browser "onkeypress" event.
 91  */
 92 DwtEvent.ONKEYPRESS = "onkeypress";
 93 
 94 /**
 95  * Browser "onkeyup" event.
 96  */
 97 DwtEvent.ONKEYUP = "onkeyup";
 98 
 99 /**
100  * Browser "onmousedown" event.
101  */
102 DwtEvent.ONMOUSEDOWN = "onmousedown";
103 
104 /**
105  * Browser "onmouseenter" event (IE Only) - reported only for the element.
106  */
107 DwtEvent.ONMOUSEENTER = "onmouseenter";
108 
109 /**
110  * Browser "onmouseleave" event (IE Only) - reported only for the element.
111  */
112 DwtEvent.ONMOUSELEAVE = "onmouseleave";
113 
114 /**
115  * Browser "onmousemove" event.
116  */
117 DwtEvent.ONMOUSEMOVE = "onmousemove";
118 
119 /**
120  * Browser "onmouseout" event - reported for element and children.
121  */
122 DwtEvent.ONMOUSEOUT = "onmouseout";
123 
124 /**
125  * Browser "onmouseover" event - reported for element and children.
126  */
127 DwtEvent.ONMOUSEOVER = "onmouseover";
128 
129 /**
130  * Browser "onmouseup" event
131  */
132 DwtEvent.ONMOUSEUP = "onmouseup";
133 
134 /**
135  * Browser "onmousewheel" event.
136  */
137 DwtEvent.ONMOUSEWHEEL = "onmousewheel";
138 
139 /**
140  * Browser "onselectstart" event.
141  */
142 DwtEvent.ONSELECTSTART = "onselectstart";
143 
144 /**
145  * Browser "onscroll" event.
146  */
147 DwtEvent.ONSCROLL = "onscroll";
148 
149 /**
150  * Browser "onpaste" event.
151  */
152 DwtEvent.ONPASTE = "onpaste";
153 
154 /**
155  * Browser "oncut" event.
156  */
157 DwtEvent.ONCUT = "oncut";
158 
159 /**
160  * Browser "oninput" event is fired synchronously when the value of an <input> or <textarea> element is changed.
161  */
162 DwtEvent.ONINPUT = "oninput";
163 
164 // semantic events
165 
166 /**
167  * Action event. An example is right-clicking on a list item or tree item
168  * generally brings up a context menu.
169  */
170 DwtEvent.ACTION	= "ACTION";
171 
172 /**
173  * Control event. Control events are fired by resizing or repositioning {@link DwtControl}s.
174  */
175 DwtEvent.CONTROL = "CONTROL";		// resize
176 
177 /**
178  * Date Range events are fired by the {@link DwtCalendar} widget. This event is
179  * fired when the date range of the calendar widget changes.
180  */
181 DwtEvent.DATE_RANGE	= "DATE_RANGE";
182 
183 /**
184  * The dispose event is fired when the {@link DwtControl#dispose} method of a control is called.
185  */
186 DwtEvent.DISPOSE = "DISPOSE";
187 
188 /**
189  * The enter event is fired when the enter key is pressed.
190  * @private
191  */
192 DwtEvent.ENTER = "ENTER";			// enter/return key
193 
194 /**
195  * This event is fired when the mouse hovers over a control for a certain period of time.
196  */
197 DwtEvent.HOVEROVER = "HOVEROVER";
198 
199 /**
200  * This event is fired when the mouse stops hovering over a control.
201  */
202 DwtEvent.HOVEROUT = "HOVEROUT";
203 
204 /**
205  * The popdown event is fired when a item (such as a {@link DwtMenu}) is popped down.
206  */
207 DwtEvent.POPDOWN = "POPDOWN";
208 
209 /**
210  * The popup event is fired when a item (such as a {@link DwtMenu}) is popped up.
211  */
212 DwtEvent.POPUP = "POPUP";
213 
214 /**
215  * The selection event is fired when controls are selected. This generally means
216  * that there has been a "left mouse button click" in the control (for example: a button, or
217  * list item, or tree node).
218  */
219 DwtEvent.SELECTION = "SELECTION";		// left-click
220 
221 /**
222  * A tree event is fired when a {@link DwtTree} node is expanded or collapsed.
223  */
224 DwtEvent.TREE = "TREE";
225 
226 /**
227  * State change events are fired when some intrinsic state of a widget changes. For
228  * example it may be that an item was added to a {@link DwtListView}
229  */
230 DwtEvent.STATE_CHANGE	= "STATE_CHANGE";
231 
232 /**
233  * The tab event is fired when the tab key is pressed.
234  * @private
235  */
236 DwtEvent.TAB = "TAB";
237 
238 // XForms
239 DwtEvent.XFORMS_READY				= "xforms-ready";
240 DwtEvent.XFORMS_DISPLAY_UPDATED		= "xforms-display-updated";
241 DwtEvent.XFORMS_VALUE_CHANGED		= "xforms-value-changed";
242 DwtEvent.XFORMS_FORM_DIRTY_CHANGE	= "xforms-form-dirty-change";
243 DwtEvent.XFORMS_CHOICES_CHANGED		= "xforms-choices-changed";
244 DwtEvent.XFORMS_VALUE_ERROR			= "xforms-value-error";
245 DwtEvent.XFORMS_INSTANCE_CHANGED 	= "xforms-instance-cahnged"; //fires when a new instance is applied to the form
246 
247 // Convenience lists
248 /**
249  * An array of key event types.
250  */
251 DwtEvent.KEY_EVENTS = [DwtEvent.ONKEYDOWN, DwtEvent.ONKEYPRESS, DwtEvent.ONKEYUP];
252 
253 /**
254  * An array of mouse event types.
255  */
256 DwtEvent.MOUSE_EVENTS = [
257 	DwtEvent.ONCONTEXTMENU, DwtEvent.ONCLICK, DwtEvent.ONDBLCLICK,
258 	DwtEvent.ONMOUSEDOWN, DwtEvent.ONMOUSEMOVE, DwtEvent.ONMOUSEUP,
259 	DwtEvent.ONSELECTSTART, DwtEvent.ONMOUSEOVER, DwtEvent.ONMOUSEOUT
260 ];
261