This repository has been archived by the owner on Dec 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 90
/
PreSelectionHandler.js
69 lines (55 loc) · 2.25 KB
/
PreSelectionHandler.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
/**
* @author Swagatam Mitra
*/
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/*global define, document, console, brackets, $, Mustache */
define(function (require, exports, module) {
"use strict";
var isPreSelectionActivated = true;
var preselectedElement = null;
var lastSelectedElement = null;
function _showPreControls(element){
var boundingRect = element.getBoundingClientRect();
$("#hover-outline").css("top",boundingRect.top+23);
$("#hover-outline").css("left",boundingRect.left+23);
$("#hover-outline").css("width",boundingRect.width);
$("#hover-outline").css("height",boundingRect.height);
$("#hover-outline").show();
preselectedElement = element;
}
function _handlePreSelection(element){
if(preselectedElement !== element){
_handleDeselection();
if(isPreSelectionActivated && element && element.tagName !== 'BODY' && element.tagName !== 'HTML' && lastSelectedElement!== element){
_showPreControls(element);
}
}
}
function _handleDeselection(){
$("#hover-outline").hide();
preselectedElement = null;
}
$(document).on("panelResizeStart", "#designer-content-placeholder", function () {
isPreSelectionActivated = false;
});
$(document).on("panelResizeEnd", "#designer-content-placeholder", function () {
isPreSelectionActivated = true;
});
$(document).on("targetdom.element.mousemove copymousemove","#html-design-editor",function(event,element,point){
_handlePreSelection(element);
});
$(document).on("mouseout","#scrollPlane",function(event){
_handleDeselection();
});
$(document).on("targetdom.element.mouseout targetdom.element.mouseleave","#html-design-editor",function(){
_handleDeselection();
});
$(document).on("element.selected","#html-design-editor",function(event,element){
lastSelectedElement = element;
_handleDeselection();
});
$(document).on("deselect.all","#html-design-editor",function(event,element){
lastSelectedElement = null;
_handleDeselection();
});
});