Skip to content

Commit

Permalink
Reworked the source code to commonjs modules
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Feb 27, 2015
1 parent abc3ac3 commit c18145f
Show file tree
Hide file tree
Showing 15 changed files with 11,123 additions and 11,208 deletions.
11,193 changes: 5,590 additions & 5,603 deletions jsoneditor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jsoneditor.map

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions jsoneditor.min.js

Large diffs are not rendered by default.

793 changes: 396 additions & 397 deletions src/js/ContextMenu.js

Large diffs are not rendered by default.

145 changes: 71 additions & 74 deletions src/js/Highlighter.js
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;
Loading

0 comments on commit c18145f

Please sign in to comment.