forked from josdejong/jsoneditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reworked the source code to commonjs modules
- Loading branch information
Showing
15 changed files
with
11,123 additions
and
11,208 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,84 @@ | ||
define(function () { | ||
/** | ||
* The highlighter can highlight/unhighlight a node, and | ||
* animate the visibility of a context menu. | ||
* @constructor Highlighter | ||
*/ | ||
function Highlighter () { | ||
this.locked = false; | ||
} | ||
|
||
/** | ||
* The highlighter can highlight/unhighlight a node, and | ||
* animate the visibility of a context menu. | ||
* @constructor Highlighter | ||
*/ | ||
function Highlighter () { | ||
this.locked = false; | ||
/** | ||
* Hightlight given node and its childs | ||
* @param {Node} node | ||
*/ | ||
Highlighter.prototype.highlight = function (node) { | ||
if (this.locked) { | ||
return; | ||
} | ||
|
||
/** | ||
* Hightlight given node and its childs | ||
* @param {Node} node | ||
*/ | ||
Highlighter.prototype.highlight = function (node) { | ||
if (this.locked) { | ||
return; | ||
if (this.node != node) { | ||
// unhighlight current node | ||
if (this.node) { | ||
this.node.setHighlight(false); | ||
} | ||
|
||
if (this.node != node) { | ||
// unhighlight current node | ||
if (this.node) { | ||
this.node.setHighlight(false); | ||
} | ||
// highlight new node | ||
this.node = node; | ||
this.node.setHighlight(true); | ||
} | ||
|
||
// highlight new node | ||
this.node = node; | ||
this.node.setHighlight(true); | ||
} | ||
// cancel any current timeout | ||
this._cancelUnhighlight(); | ||
}; | ||
|
||
// cancel any current timeout | ||
this._cancelUnhighlight(); | ||
}; | ||
|
||
/** | ||
* Unhighlight currently highlighted node. | ||
* Will be done after a delay | ||
*/ | ||
Highlighter.prototype.unhighlight = function () { | ||
if (this.locked) { | ||
return; | ||
} | ||
/** | ||
* Unhighlight currently highlighted node. | ||
* Will be done after a delay | ||
*/ | ||
Highlighter.prototype.unhighlight = function () { | ||
if (this.locked) { | ||
return; | ||
} | ||
|
||
var me = this; | ||
if (this.node) { | ||
this._cancelUnhighlight(); | ||
var me = this; | ||
if (this.node) { | ||
this._cancelUnhighlight(); | ||
|
||
// do the unhighlighting after a small delay, to prevent re-highlighting | ||
// the same node when moving from the drag-icon to the contextmenu-icon | ||
// or vice versa. | ||
this.unhighlightTimer = setTimeout(function () { | ||
me.node.setHighlight(false); | ||
me.node = undefined; | ||
me.unhighlightTimer = undefined; | ||
}, 0); | ||
} | ||
}; | ||
// do the unhighlighting after a small delay, to prevent re-highlighting | ||
// the same node when moving from the drag-icon to the contextmenu-icon | ||
// or vice versa. | ||
this.unhighlightTimer = setTimeout(function () { | ||
me.node.setHighlight(false); | ||
me.node = undefined; | ||
me.unhighlightTimer = undefined; | ||
}, 0); | ||
} | ||
}; | ||
|
||
/** | ||
* Cancel an unhighlight action (if before the timeout of the unhighlight action) | ||
* @private | ||
*/ | ||
Highlighter.prototype._cancelUnhighlight = function () { | ||
if (this.unhighlightTimer) { | ||
clearTimeout(this.unhighlightTimer); | ||
this.unhighlightTimer = undefined; | ||
} | ||
}; | ||
/** | ||
* Cancel an unhighlight action (if before the timeout of the unhighlight action) | ||
* @private | ||
*/ | ||
Highlighter.prototype._cancelUnhighlight = function () { | ||
if (this.unhighlightTimer) { | ||
clearTimeout(this.unhighlightTimer); | ||
this.unhighlightTimer = undefined; | ||
} | ||
}; | ||
|
||
/** | ||
* Lock highlighting or unhighlighting nodes. | ||
* methods highlight and unhighlight do not work while locked. | ||
*/ | ||
Highlighter.prototype.lock = function () { | ||
this.locked = true; | ||
}; | ||
/** | ||
* Lock highlighting or unhighlighting nodes. | ||
* methods highlight and unhighlight do not work while locked. | ||
*/ | ||
Highlighter.prototype.lock = function () { | ||
this.locked = true; | ||
}; | ||
|
||
/** | ||
* Unlock highlighting or unhighlighting nodes | ||
*/ | ||
Highlighter.prototype.unlock = function () { | ||
this.locked = false; | ||
}; | ||
/** | ||
* Unlock highlighting or unhighlighting nodes | ||
*/ | ||
Highlighter.prototype.unlock = function () { | ||
this.locked = false; | ||
}; | ||
|
||
return Highlighter; | ||
}); | ||
module.exports = Highlighter; |
Oops, something went wrong.