This repository has been archived by the owner on Feb 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
draw.js
110 lines (94 loc) · 2.87 KB
/
draw.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
var postAceInit = function(hook, context){
var draw = clientVars.ep_draw;
if(draw){
if(draw.onByDefault){ // Setup testing else poop out
if(draw.onByDefault === 'true'){
enabledraw();
showdraw();
}
}
else{
$("#draw").hide();
clientVars.ep_draw.enabled = false;
// we don't draw it by default
}
$('.toggle_draw').click(function() {
toggledraw();
});
}
try {
if (clientVars.ep_draw.icon){
$('.draw_icon').css("background-image", 'url('+clientVars.ep_draw.icon+')');
$('.draw_icon').css({
height: "16px",
width: "16px"
});
}
} catch (e) {
}
try {
if (clientVars.ep_draw.position){
if(clientVars.ep_draw.position === "right"){
$('.draw').parent().prependTo(".menu_right");
}
}
} catch (e) {
}
}
function enabledraw(){
var authorName = 'Testing';
var authorColor = $('#myswatch').css('background-color');
var draw_host = clientVars.ep_draw.host;
var padID = clientVars.padId;
if($("#draw").length === 0){ // If it's not available already then draw it
$("#editorcontainer").prepend("<div id=draw><iframe id='drawEmbed' src='//"+draw_host+"/d/"+padID+"?authorName="+authorName+"&authorColor="+authorColor+"' width='100%' height='100%' style='border:none' frameborder='0' scrolling='no'></iframe></div>");
}
clientVars.ep_draw.enabled = true;
showdraw();
}
function showdraw(){
$("#draw").css({"z-index":"999999", "position":"absolute", "top":"0px", "right":"0px", "height":"200px", "width":"200px", "border":"1px solid #ccc"}).show();
$("#drawEmbed").show().css({"overflow":"hidden"});
if(clientVars.ep_draw.enabled !== true){
enabledraw();
$("#draw").hover(function(){
clearTimeout($(this).data('timeout'));
$("#draw").animate({"width":"100%", "height": "100%"});;
clientVars.ep_draw.fullscreen = true;
}, function(){
var t = setTimeout(function() { // Dont zoom out right away, wait a while
$("#draw").animate({"width":"200px", "height": "200px"});;
clientVars.ep_draw.fullscreen = false;
}, 500);
$(this).data('timeout', t);
});
}
clientVars.ep_draw.visible = true;
}
function hidedraw(){
$("#draw").hide();
clientVars.ep_draw.fullscreen = false;
clientVars.ep_draw.visible = false;
}
function toggledraw(){
if(clientVars.ep_draw.visible === true && clientVars.ep_draw.fullscreen){
hidedraw();
return;
}
if(!clientVars.ep_draw.visible){
showdraw();
return;
}
if(clientVars.ep_draw.visible === true && !clientVars.ep_draw.fullscreen){
fullScreenDraw();
return;
}
}
function fullScreenDraw(){
clientVars.ep_draw.fullscreen = true;
$("#draw").animate({"width":"100%", "height": "100%"});;
}
exports.postAceInit = postAceInit;
exports.enabledraw = enabledraw;
exports.showdraw = showdraw;
exports.hidedraw = hidedraw;