-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathieError.js
111 lines (92 loc) · 2.15 KB
/
ieError.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/**
* ieError lib
*
* @author : Louis Lainé
*
*/
var ieError = (function($){
'use strict';
/* check for jQuery */
if(typeof $ === 'undefined'){
return;
}
/* common vars */
var bodyNode = $('body')
, img = "./assets/ieError.gif"
, idBoxError = "ieError"
, idBoxSnap = 'snap'
, style = "width: 419px; height: 282px; background-image: url(./assets/ieError.gif);"
, zindex = " z-index: 100;"
, divError = "<div id='" + idBoxError + "' style='" + style + ' ' + zindex + "'></div>"
, divSnap = "<div id='" + idBoxSnap + "' style='" + style + " position: absolute;'></div>"
, timeOut = 100;
/**
* the ieError object.
* Display a log if debug is true
*
* @debug
*/
function ieError(debug) {
/* default parameter */
debug = typeof debug !== 'undefined' ? debug : false;
this.debug = debug;
/* setup */
this.setup();
/* launching */
this.launch(idBoxError, idBoxSnap);
};
/**
* Append the ieError div to the DOM body element.
*/
ieError.prototype.setup = function() {
/* append to the body DOM element */
bodyNode.append(divError);
this.log('append div to body node')
};
/**
* Bootstrap the ieError tricks.
*
* @idBoxError the id of the error div
* @idBoxSnap the id of the snap div.
*/
ieError.prototype.launch = function(idBoxError, idBoxSnap){
/* setup the ids */
var idBoxError = "#" + idBoxError
, idBoxSnap = "#" + idBoxSnap;
/* check for jQuery ui */
if(typeof $.ui !== 'undefined'){
this.log('initialisation draggable');
$(idBoxError).draggable({
drag: function(evt, self){
if(self !== 'undefined'){
/* let's make some snap ! :) */
setTimeout(function(){
/* just creating a dom element for each snap ! */
$(divSnap).
css({
top: self.offset.top,
left: self.offset.left
}).
appendTo(bodyNode);
}, timeOut);
}else{
throw new Error('self undefined');
}
}
})
}
};
/**
* Logger function
*
* @msg :
*/
ieError.prototype.log = function(msg) {
if(console !== 'undefined'){
if(this.debug){
console.log("[i] ieError : " + msg);
}
}
};
return ieError;
})(jQuery);