html5forms-rails 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/Gemfile +11 -0
- data/README.md +208 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/demos/html5-form-demo.html +79 -0
- data/html5forms-rails.gemspec +142 -0
- data/lib/html5forms.rb +6 -0
- data/vendor/assets/images/colorpicker/blank.gif +0 -0
- data/vendor/assets/images/colorpicker/colorpicker_background.png +0 -0
- data/vendor/assets/images/colorpicker/colorpicker_hex.png +0 -0
- data/vendor/assets/images/colorpicker/colorpicker_hsb_b.png +0 -0
- data/vendor/assets/images/colorpicker/colorpicker_hsb_h.png +0 -0
- data/vendor/assets/images/colorpicker/colorpicker_hsb_s.png +0 -0
- data/vendor/assets/images/colorpicker/colorpicker_indic.gif +0 -0
- data/vendor/assets/images/colorpicker/colorpicker_overlay.png +0 -0
- data/vendor/assets/images/colorpicker/colorpicker_rgb_b.png +0 -0
- data/vendor/assets/images/colorpicker/colorpicker_rgb_g.png +0 -0
- data/vendor/assets/images/colorpicker/colorpicker_rgb_r.png +0 -0
- data/vendor/assets/images/colorpicker/colorpicker_select.gif +0 -0
- data/vendor/assets/images/colorpicker/colorpicker_submit.png +0 -0
- data/vendor/assets/images/colorpicker/custom_background.png +0 -0
- data/vendor/assets/images/colorpicker/custom_hex.png +0 -0
- data/vendor/assets/images/colorpicker/custom_hsb_b.png +0 -0
- data/vendor/assets/images/colorpicker/custom_hsb_h.png +0 -0
- data/vendor/assets/images/colorpicker/custom_hsb_s.png +0 -0
- data/vendor/assets/images/colorpicker/custom_indic.gif +0 -0
- data/vendor/assets/images/colorpicker/custom_rgb_b.png +0 -0
- data/vendor/assets/images/colorpicker/custom_rgb_g.png +0 -0
- data/vendor/assets/images/colorpicker/custom_rgb_r.png +0 -0
- data/vendor/assets/images/colorpicker/custom_submit.png +0 -0
- data/vendor/assets/images/colorpicker/select.png +0 -0
- data/vendor/assets/images/colorpicker/select2.png +0 -0
- data/vendor/assets/images/colorpicker/slider.png +0 -0
- data/vendor/assets/images/h5f/form_validation.png +0 -0
- data/vendor/assets/images/html5form-shim/asterisk.png +0 -0
- data/vendor/assets/images/html5form-shim/down.png +0 -0
- data/vendor/assets/images/html5form-shim/fail.png +0 -0
- data/vendor/assets/images/html5form-shim/ok.png +0 -0
- data/vendor/assets/images/html5forms/jscolor/arrow.gif +0 -0
- data/vendor/assets/images/html5forms/jscolor/cross.gif +0 -0
- data/vendor/assets/images/html5forms/jscolor/hs.png +0 -0
- data/vendor/assets/images/html5forms/jscolor/hv.png +0 -0
- data/vendor/assets/images/html5forms/slider/slider-1.png +0 -0
- data/vendor/assets/images/html5forms/slider/slider-disabled-1.png +0 -0
- data/vendor/assets/images/html5forms/slider/slider-disabled.png +0 -0
- data/vendor/assets/images/html5forms/slider/slider.png +0 -0
- data/vendor/assets/javascripts/colorpicker.js +484 -0
- data/vendor/assets/javascripts/colorpicker.min.js +9 -0
- data/vendor/assets/javascripts/h5f.js +328 -0
- data/vendor/assets/javascripts/h5f.min.js +4 -0
- data/vendor/assets/javascripts/html5forms/EventHelpers.min.js +15 -0
- data/vendor/assets/javascripts/html5forms/autocomplete.min.js +1 -0
- data/vendor/assets/javascripts/html5forms/cssQuery-p.min.js +6 -0
- data/vendor/assets/javascripts/html5forms/dev/EventHelpers.js +486 -0
- data/vendor/assets/javascripts/html5forms/dev/autocomplete.js +387 -0
- data/vendor/assets/javascripts/html5forms/dev/cssQuery-p.js +6 -0
- data/vendor/assets/javascripts/html5forms/dev/html5.js +121 -0
- data/vendor/assets/javascripts/html5forms/dev/html5Forms.js +892 -0
- data/vendor/assets/javascripts/html5forms/dev/html5Widgets.js +1417 -0
- data/vendor/assets/javascripts/html5forms/dev/jscolor.js +840 -0
- data/vendor/assets/javascripts/html5forms/dev/slider.js +797 -0
- data/vendor/assets/javascripts/html5forms/dev/timer.js +137 -0
- data/vendor/assets/javascripts/html5forms/dev/visibleIf.js +1100 -0
- data/vendor/assets/javascripts/html5forms/html5.min.js +2 -0
- data/vendor/assets/javascripts/html5forms/html5Forms.min.js +1 -0
- data/vendor/assets/javascripts/html5forms/html5Widgets.min.js +20 -0
- data/vendor/assets/javascripts/html5forms/jscolor.min.js +10 -0
- data/vendor/assets/javascripts/html5forms/slider.min.js +25 -0
- data/vendor/assets/javascripts/html5forms/timer.min.js +1 -0
- data/vendor/assets/javascripts/html5forms/visibleIf.min.js +19 -0
- data/vendor/assets/javascripts/html5forms.fallback.js +115 -0
- data/vendor/assets/javascripts/html5forms.fallback.min.js +11 -0
- data/vendor/assets/javascripts/jquery.html5form-shim.js +402 -0
- data/vendor/assets/javascripts/jquery.html5form.min.js +4 -0
- data/vendor/assets/javascripts/jquery.placehold.min.js +7 -0
- data/vendor/assets/javascripts/ui.spinner.js +649 -0
- data/vendor/assets/javascripts/ui.spinner.min.js +7 -0
- data/vendor/assets/javascripts/webforms2/webforms2-msie.js +1 -0
- data/vendor/assets/javascripts/webforms2/webforms2-p.js +14 -0
- data/vendor/assets/javascripts/webforms2/webforms2.js +14 -0
- data/vendor/assets/javascripts/webforms2/webforms2_src.js +3195 -0
- data/vendor/assets/stylesheets/colorpicker.css +161 -0
- data/vendor/assets/stylesheets/h5f.css +86 -0
- data/vendor/assets/stylesheets/html5form-shim.css +109 -0
- data/vendor/assets/stylesheets/html5forms/number.css +35 -0
- data/vendor/assets/stylesheets/html5forms/slider.css +169 -0
- data/vendor/assets/stylesheets/html5forms/slider_ie.css +41 -0
- data/vendor/assets/stylesheets/html5forms/visibleIf.css +23 -0
- data/vendor/assets/stylesheets/html5forms.layout.css +116 -0
- data/vendor/assets/stylesheets/ui.spinner.css +3 -0
- data/vendor/assets/stylesheets/webforms2.css +42 -0
- metadata +221 -0
@@ -0,0 +1,486 @@
|
|
1
|
+
/*******************************************************************************
|
2
|
+
* This notice must be untouched at all times.
|
3
|
+
*
|
4
|
+
* This javascript library contains helper routines to assist with event
|
5
|
+
* handling consinstently among browsers
|
6
|
+
*
|
7
|
+
* EventHelpers.js v.1.4 available at http://www.useragentman.com/
|
8
|
+
*
|
9
|
+
* released under the MIT License:
|
10
|
+
* http://www.opensource.org/licenses/mit-license.php
|
11
|
+
*
|
12
|
+
* Chagelog: 1.4: fix fireEvent to work correctly for IE9.
|
13
|
+
*
|
14
|
+
*******************************************************************************/
|
15
|
+
var EventHelpers = new function(){
|
16
|
+
var me = this;
|
17
|
+
|
18
|
+
var safariTimer;
|
19
|
+
var isSafari = /WebKit/i.test(navigator.userAgent);
|
20
|
+
var globalEvent;
|
21
|
+
|
22
|
+
me.init = function () {
|
23
|
+
if (me.hasPageLoadHappened(arguments)) {
|
24
|
+
return;
|
25
|
+
}
|
26
|
+
|
27
|
+
/* This is for fireEvent */
|
28
|
+
if (document.createEvent) {
|
29
|
+
globalEvent = document.createEvent("HTMLEvents");
|
30
|
+
} else if (document.createEventObject){
|
31
|
+
// dispatch for IE8 and lower.
|
32
|
+
globalEvent = document.createEventObject();
|
33
|
+
}
|
34
|
+
|
35
|
+
me.docIsLoaded = true;
|
36
|
+
}
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Adds an event to the document. Examples of usage:
|
40
|
+
* me.addEvent(window, "load", myFunction);
|
41
|
+
* me.addEvent(docunent, "keydown", keyPressedFunc);
|
42
|
+
* me.addEvent(document, "keyup", keyPressFunc);
|
43
|
+
*
|
44
|
+
* @author Scott Andrew - http://www.scottandrew.com/weblog/articles/cbs-events
|
45
|
+
* @author John Resig - http://ejohn.org/projects/flexible-javascript-events/
|
46
|
+
* @param {Object} obj - a javascript object.
|
47
|
+
* @param {String} evType - an event to attach to the object.
|
48
|
+
* @param {Function} fn - the function that is attached to the event.
|
49
|
+
*/
|
50
|
+
me.addEvent = function(obj, evType, fn){
|
51
|
+
|
52
|
+
if (obj.addEventListener) {
|
53
|
+
obj.addEventListener(evType, fn, false);
|
54
|
+
} else if (obj.attachEvent) {
|
55
|
+
obj['e' + evType + fn] = fn;
|
56
|
+
obj[evType + fn] = function(){
|
57
|
+
obj["e" + evType + fn](self.event);
|
58
|
+
}
|
59
|
+
obj.attachEvent("on" + evType, obj[evType + fn]);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Removes an event that is attached to a javascript object.
|
66
|
+
*
|
67
|
+
* @author Scott Andrew - http://www.scottandrew.com/weblog/articles/cbs-events
|
68
|
+
* @author John Resig - http://ejohn.org/projects/flexible-javascript-events/ * @param {Object} obj - a javascript object.
|
69
|
+
* @param {String} evType - an event attached to the object.
|
70
|
+
* @param {Function} fn - the function that is called when the event fires.
|
71
|
+
*/
|
72
|
+
me.removeEvent = function(obj, evType, fn){
|
73
|
+
|
74
|
+
if (obj.removeEventListener) {
|
75
|
+
obj.removeEventListener(evType, fn, false);
|
76
|
+
} else if (obj.detachEvent) {
|
77
|
+
try {
|
78
|
+
obj.detachEvent("on" + evType, obj[evType + fn]);
|
79
|
+
obj[evType + fn] = null;
|
80
|
+
obj["e" + evType + fn] = null;
|
81
|
+
}
|
82
|
+
catch (ex) {
|
83
|
+
// do nothing;
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
function removeEventAttribute(obj, beginName){
|
89
|
+
var attributes = obj.attributes;
|
90
|
+
for (var i = 0; i < attributes.length; i++) {
|
91
|
+
var attribute = attributes[i]
|
92
|
+
var name = attribute.name
|
93
|
+
if (name.indexOf(beginName) == 0) {
|
94
|
+
//obj.removeAttributeNode(attribute);
|
95
|
+
attribute.specified = false;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
me.addScrollWheelEvent = function(obj, fn){
|
101
|
+
if (obj.addEventListener) {
|
102
|
+
/** DOMMouseScroll is for mozilla. */
|
103
|
+
obj.addEventListener('DOMMouseScroll', fn, true);
|
104
|
+
}
|
105
|
+
|
106
|
+
/** IE/Opera. */
|
107
|
+
if (obj.attachEvent) {
|
108
|
+
obj.attachEvent("onmousewheel", fn);
|
109
|
+
}
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
me.removeScrollWheelEvent = function(obj, fn){
|
114
|
+
if (obj.removeEventListener) {
|
115
|
+
/** DOMMouseScroll is for mozilla. */
|
116
|
+
obj.removeEventListener('DOMMouseScroll', fn, true);
|
117
|
+
}
|
118
|
+
|
119
|
+
/** IE/Opera. */
|
120
|
+
if (obj.detachEvent) {
|
121
|
+
obj.detatchEvent("onmousewheel", fn);
|
122
|
+
}
|
123
|
+
|
124
|
+
}
|
125
|
+
|
126
|
+
me.getMouseCoords = function (e) {
|
127
|
+
if (!e) {
|
128
|
+
return;
|
129
|
+
}
|
130
|
+
// IE
|
131
|
+
if (e.clientX != null) {
|
132
|
+
return {
|
133
|
+
x: e.clientX,
|
134
|
+
y: e.clientY
|
135
|
+
}
|
136
|
+
|
137
|
+
}
|
138
|
+
// NS4
|
139
|
+
else if (e.pageX != null) {
|
140
|
+
return {
|
141
|
+
x: e.pageX,
|
142
|
+
y: e.pageY
|
143
|
+
}
|
144
|
+
// W3C
|
145
|
+
} else if (window.event != null && window.event.clientX != null
|
146
|
+
&& document.body != null &&
|
147
|
+
document.body.scrollLeft != null) {
|
148
|
+
return {
|
149
|
+
x: window.event.clientX + document.body.scrollLeft,
|
150
|
+
y: window.event.clientY + document.body.scrollTop
|
151
|
+
}
|
152
|
+
|
153
|
+
} else {
|
154
|
+
return null;
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Given a mouse event, get the mouse pointer's x-coordinate.
|
160
|
+
*
|
161
|
+
* @param {Object} e - a DOM Event object.
|
162
|
+
* @return {int} - the mouse pointer's x-coordinate.
|
163
|
+
*/
|
164
|
+
me.getMouseX = function(e){
|
165
|
+
if (!e) {
|
166
|
+
return;
|
167
|
+
}
|
168
|
+
// NS4
|
169
|
+
if (e.pageX != null) {
|
170
|
+
return e.pageX;
|
171
|
+
// IE
|
172
|
+
} else if (window.event != null && window.event.clientX != null &&
|
173
|
+
document.body != null &&
|
174
|
+
document.body.scrollLeft != null)
|
175
|
+
return window.event.clientX + document.body.scrollLeft;
|
176
|
+
// W3C
|
177
|
+
else if (e.clientX != null)
|
178
|
+
return e.clientX;
|
179
|
+
else
|
180
|
+
return null;
|
181
|
+
}
|
182
|
+
|
183
|
+
/**
|
184
|
+
* Given a mouse event, get the mouse pointer's y-coordinate.
|
185
|
+
* @param {Object} e - a DOM Event Object.
|
186
|
+
* @return {int} - the mouse pointer's y-coordinate.
|
187
|
+
*/
|
188
|
+
me.getMouseY = function(e){
|
189
|
+
// NS4
|
190
|
+
if (e.pageY != null)
|
191
|
+
return e.pageY;
|
192
|
+
// IE
|
193
|
+
else if (window.event != null && window.event.clientY != null &&
|
194
|
+
document.body != null &&
|
195
|
+
document.body.scrollTop != null)
|
196
|
+
return window.event.clientY + document.body.scrollTop;
|
197
|
+
// W3C
|
198
|
+
else if (e.clientY != null) {
|
199
|
+
return e.clientY;
|
200
|
+
}
|
201
|
+
}
|
202
|
+
/**
|
203
|
+
* Given a mouse scroll wheel event, get the "delta" of how fast it moved.
|
204
|
+
* @param {Object} e - a DOM Event Object.
|
205
|
+
* @return {int} - the mouse wheel's delta. It is greater than 0, the
|
206
|
+
* scroll wheel was spun upwards; if less than 0, downwards.
|
207
|
+
*/
|
208
|
+
me.getScrollWheelDelta = function(e){
|
209
|
+
var delta = 0;
|
210
|
+
if (!e) /* For IE. */
|
211
|
+
e = window.event;
|
212
|
+
if (e.wheelDelta) { /* IE/Opera. */
|
213
|
+
delta = e.wheelDelta / 120;
|
214
|
+
/** In Opera 9, delta differs in sign as compared to IE.
|
215
|
+
*/
|
216
|
+
if (window.opera) {
|
217
|
+
delta = -delta;
|
218
|
+
}
|
219
|
+
} else if (e.detail) { /** Mozilla case. */
|
220
|
+
/** In Mozilla, sign of delta is different than in IE.
|
221
|
+
* Also, delta is multiple of 3.
|
222
|
+
*/
|
223
|
+
delta = -e.detail / 3;
|
224
|
+
}
|
225
|
+
return delta
|
226
|
+
}
|
227
|
+
|
228
|
+
/**
|
229
|
+
* Sets a mouse move event of a document.
|
230
|
+
*
|
231
|
+
* @deprecated - use only if compatibility with IE4 and NS4 is necessary. Otherwise, just
|
232
|
+
* use EventHelpers.addEvent(window, 'mousemove', func) instead. Cannot be used to add
|
233
|
+
* multiple mouse move event handlers.
|
234
|
+
*
|
235
|
+
* @param {Function} func - the function that you want a mouse event to fire.
|
236
|
+
*/
|
237
|
+
me.addMouseEvent = function(func){
|
238
|
+
|
239
|
+
if (document.captureEvents) {
|
240
|
+
document.captureEvents(Event.MOUSEMOVE);
|
241
|
+
}
|
242
|
+
|
243
|
+
document.onmousemove = func;
|
244
|
+
window.onmousemove = func;
|
245
|
+
window.onmouseover = func;
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
/**
|
252
|
+
* Find the HTML object that fired an Event.
|
253
|
+
*
|
254
|
+
* @param {Object} e - an HTML object
|
255
|
+
* @return {Object} - the HTML object that fired the event.
|
256
|
+
*/
|
257
|
+
me.getEventTarget = function(e){
|
258
|
+
// first, IE method for mouse events(also supported by Safari and Opera)
|
259
|
+
if (e.toElement) {
|
260
|
+
return e.toElement;
|
261
|
+
// W3C
|
262
|
+
} else if (e.currentTarget) {
|
263
|
+
return e.currentTarget;
|
264
|
+
|
265
|
+
// MS way
|
266
|
+
} else if (e.srcElement) {
|
267
|
+
return e.srcElement;
|
268
|
+
} else {
|
269
|
+
return null;
|
270
|
+
}
|
271
|
+
}
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
/**
|
277
|
+
* Given an event fired by the keyboard, find the key associated with that event.
|
278
|
+
*
|
279
|
+
* @param {Object} e - an event object.
|
280
|
+
* @return {String} - the ASCII character code representing the key associated with the event.
|
281
|
+
*/
|
282
|
+
me.getKey = function(e){
|
283
|
+
if (e.keyCode) {
|
284
|
+
return e.keyCode;
|
285
|
+
} else if (e.event && e.event.keyCode) {
|
286
|
+
return window.event.keyCode;
|
287
|
+
} else if (e.which) {
|
288
|
+
return e.which;
|
289
|
+
}
|
290
|
+
}
|
291
|
+
|
292
|
+
|
293
|
+
/**
|
294
|
+
* Will execute a function when the page's DOM has fully loaded (and before all attached images, iframes,
|
295
|
+
* etc., are).
|
296
|
+
*
|
297
|
+
* Usage:
|
298
|
+
*
|
299
|
+
* EventHelpers.addPageLoadEvent('init');
|
300
|
+
*
|
301
|
+
* where the function init() has this code at the beginning:
|
302
|
+
*
|
303
|
+
* function init() {
|
304
|
+
*
|
305
|
+
* if (EventHelpers.hasPageLoadHappened(arguments)) return;
|
306
|
+
*
|
307
|
+
* // rest of code
|
308
|
+
* ....
|
309
|
+
* }
|
310
|
+
*
|
311
|
+
* @author This code is based off of code from http://dean.edwards.name/weblog/2005/09/busted/ by Dean
|
312
|
+
* Edwards, with a modification by me.
|
313
|
+
*
|
314
|
+
* @param {String} funcName - a string containing the function to be called.
|
315
|
+
*/
|
316
|
+
me.addPageLoadEvent = function(funcName){
|
317
|
+
|
318
|
+
var func = eval(funcName);
|
319
|
+
|
320
|
+
// for Internet Explorer (using conditional comments)
|
321
|
+
/*@cc_on @*/
|
322
|
+
/*@if (@_win32)
|
323
|
+
pageLoadEventArray.push(func);
|
324
|
+
return;
|
325
|
+
/*@end @*/
|
326
|
+
if (isSafari) { // sniff
|
327
|
+
pageLoadEventArray.push(func);
|
328
|
+
|
329
|
+
if (!safariTimer) {
|
330
|
+
|
331
|
+
safariTimer = setInterval(function(){
|
332
|
+
if (/loaded|complete/.test(document.readyState)) {
|
333
|
+
clearInterval(safariTimer);
|
334
|
+
|
335
|
+
/*
|
336
|
+
* call the onload handler
|
337
|
+
* func();
|
338
|
+
*/
|
339
|
+
me.runPageLoadEvents();
|
340
|
+
return;
|
341
|
+
}
|
342
|
+
set = true;
|
343
|
+
}, 10);
|
344
|
+
}
|
345
|
+
/* for Mozilla */
|
346
|
+
} else if (document.addEventListener) {
|
347
|
+
var x = document.addEventListener("DOMContentLoaded", func, null);
|
348
|
+
|
349
|
+
/* Others */
|
350
|
+
} else {
|
351
|
+
me.addEvent(window, 'load', func);
|
352
|
+
}
|
353
|
+
}
|
354
|
+
|
355
|
+
var pageLoadEventArray = new Array();
|
356
|
+
|
357
|
+
me.runPageLoadEvents = function(e){
|
358
|
+
if (isSafari || e.srcElement.readyState == "complete") {
|
359
|
+
|
360
|
+
for (var i = 0; i < pageLoadEventArray.length; i++) {
|
361
|
+
pageLoadEventArray[i]();
|
362
|
+
}
|
363
|
+
}
|
364
|
+
}
|
365
|
+
/**
|
366
|
+
* Determines if either addPageLoadEvent('funcName') or addEvent(window, 'load', funcName)
|
367
|
+
* has been executed.
|
368
|
+
*
|
369
|
+
* @see addPageLoadEvent
|
370
|
+
* @param {Function} funcArgs - the arguments of the containing. function
|
371
|
+
*/
|
372
|
+
me.hasPageLoadHappened = function(funcArgs){
|
373
|
+
// If the function already been called, return true;
|
374
|
+
if (funcArgs.callee.done)
|
375
|
+
return true;
|
376
|
+
|
377
|
+
// flag this function so we don't do the same thing twice
|
378
|
+
funcArgs.callee.done = true;
|
379
|
+
}
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
/**
|
384
|
+
* Used in an event method/function to indicate that the default behaviour of the event
|
385
|
+
* should *not* happen.
|
386
|
+
*
|
387
|
+
* @param {Object} e - an event object.
|
388
|
+
* @return {Boolean} - always false
|
389
|
+
*/
|
390
|
+
me.preventDefault = function(e){
|
391
|
+
|
392
|
+
if (e.preventDefault) {
|
393
|
+
e.preventDefault();
|
394
|
+
}
|
395
|
+
|
396
|
+
try {
|
397
|
+
e.returnValue = false;
|
398
|
+
}
|
399
|
+
catch (ex) {
|
400
|
+
// do nothing
|
401
|
+
}
|
402
|
+
|
403
|
+
}
|
404
|
+
|
405
|
+
me.cancelBubble = function(e){
|
406
|
+
if (e.stopPropagation) {
|
407
|
+
e.stopPropagation();
|
408
|
+
}
|
409
|
+
|
410
|
+
try {
|
411
|
+
e.cancelBubble = true;
|
412
|
+
}
|
413
|
+
catch (ex) {
|
414
|
+
// do nothing
|
415
|
+
}
|
416
|
+
}
|
417
|
+
|
418
|
+
/*
|
419
|
+
* Fires an event manually.
|
420
|
+
* @author Scott Andrew - http://www.scottandrew.com/weblog/articles/cbs-events
|
421
|
+
* @author John Resig - http://ejohn.org/projects/flexible-javascript-events/
|
422
|
+
* @param {Object} obj - a javascript object.
|
423
|
+
* @param {String} evType - an event attached to the object.
|
424
|
+
* @param {Function} fn - the function that is called when the event fires.
|
425
|
+
*
|
426
|
+
*/
|
427
|
+
me.fireEvent = function (element,event, options){
|
428
|
+
|
429
|
+
if(!element) {
|
430
|
+
return;
|
431
|
+
}
|
432
|
+
|
433
|
+
if (element.dispatchEvent) {
|
434
|
+
// dispatch for firefox + ie9 + others
|
435
|
+
globalEvent.initEvent(event, true, true); // event type,bubbling,cancelable
|
436
|
+
return !element.dispatchEvent(globalEvent);
|
437
|
+
} else if (document.createEventObject){
|
438
|
+
return element.fireEvent('on' + event, globalEvent)
|
439
|
+
} else {
|
440
|
+
return false;
|
441
|
+
}
|
442
|
+
}
|
443
|
+
|
444
|
+
/*
|
445
|
+
* Detects whether the event "eventName" is supported on a tag with name
|
446
|
+
* "nodeName". Based on code from
|
447
|
+
* http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
|
448
|
+
*/
|
449
|
+
me.isSupported = function (eventName, nodeName) {
|
450
|
+
var el = document.createElement(nodeName);
|
451
|
+
eventName = 'on' + eventName;
|
452
|
+
var isSupported = (eventName in el);
|
453
|
+
if (!isSupported) {
|
454
|
+
el.setAttribute(eventName, 'return;');
|
455
|
+
isSupported = typeof el[eventName] == 'function';
|
456
|
+
}
|
457
|
+
el = null;
|
458
|
+
return isSupported;
|
459
|
+
}
|
460
|
+
|
461
|
+
|
462
|
+
/* EventHelpers.init () */
|
463
|
+
function init(){
|
464
|
+
// Conditional comment alert: Do not remove comments. Leave intact.
|
465
|
+
// The detection if the page is secure or not is important. If
|
466
|
+
// this logic is removed, Internet Explorer will give security
|
467
|
+
// alerts.
|
468
|
+
/*@cc_on @*/
|
469
|
+
/*@if (@_win32)
|
470
|
+
|
471
|
+
document.write('<script id="__ie_onload" defer src="' +
|
472
|
+
|
473
|
+
((location.protocol == 'https:') ? '//0' : 'javascript:void(0)') + '"><\/script>');
|
474
|
+
|
475
|
+
var script = document.getElementById("__ie_onload");
|
476
|
+
|
477
|
+
me.addEvent(script, 'readystatechange', me.runPageLoadEvents);
|
478
|
+
|
479
|
+
/*@end @*/
|
480
|
+
|
481
|
+
}
|
482
|
+
|
483
|
+
init();
|
484
|
+
}
|
485
|
+
|
486
|
+
EventHelpers.addPageLoadEvent('EventHelpers.init');
|