Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
locate: function( elem, index ){
var data = $.data( elem, drop.datakey ),
$elem = $( elem ),
posi = $elem.offset() || {},
height = $elem.outerHeight(),
width = $elem.outerWidth(),
location = {
elem: elem,
width: width,
height: height,
top: posi.top,
left: posi.left,
right: posi.left + width,
bottom: posi.top + height
};
// drag elements might not have dropdata
if ( data ){
data.location = location;
function handleThemes() {
var newTheme = themeSelect.val();
// Store the scheme of the old theme
$.data(themeSelect, 'theme-' + $.data(themeSelect, 'last-theme'), colourSchemeSelect.val());
// Get the scheme of the new theme
var newThemeStoredScheme = $.data(themeSelect, 'theme-' + newTheme);
var isStoredUsable = false;
colourSchemeSelect.empty();
_.each(colour.schemes, function (scheme) {
if (!scheme.themes || scheme.themes.length === 0 || scheme.themes.indexOf(newTheme) !== -1 ||
scheme.themes.indexOf('all') !== -1) {
colourSchemeSelect.append($('<option value="' + scheme.name + '">' + scheme.desc + "</option>"));
if (newThemeStoredScheme === scheme.name) {
isStoredUsable = true;
}
}
});
if (colourSchemeSelect.children().length >= 1) {
colourSchemeSelect.val(isStoredUsable ? newThemeStoredScheme : colourSchemeSelect.first().val());
Decorator.prototype.elementDecorator = function elementDecorator(
root, el, level, pre_context_handler, post_context_handler) {
if (level > this._editor.max_label_level) {
throw new Error("level higher than the maximum set by the mode: " +
level);
}
// Save the caret because the decoration may mess up the GUI caret.
var data_caret = this._editor.getDataCaret();
if (data_caret &&
!(data_caret.node instanceof this._editor.my_window.Attr &&
data_caret.node.ownerElement === $.data(el, "wed_mirror_node"))) {
data_caret = undefined;
}
var data_node = $.data(el, "wed_mirror_node");
this.setReadOnly(el, this._editor.validator.getNodeProperty(
data_node, "PossibleDueToWildcard"));
var orig_name = util.getOriginalName(el);
// _[name]_label is used locally to make the function idempotent.
var cls = "_" + orig_name + "_label";
// We must grab a list of nodes to remove before we start removing
// them because an element that has a placeholder in it is going
// to lose the placeholder while we are modifying it. This could
// throw off the scan.
var to_remove = domutil.childrenByClass(el, cls);
var i;
var remove;
for (i = 0; i < to_remove.length; ++i) {
remove = to_remove[i];
function () {
var selectee = $.data(this, 'selectable-item');
me.removeClass(selectee.$element, 'unselecting');
selectee.unselecting = false;
selectee.startselected = false;
me.trigger('unselected', event, {unselected: selectee.element});
}
);
function linkTrees(root_a, root_b) {
$.data(root_a, "wed_mirror_node", root_b);
$.data(root_b, "wed_mirror_node", root_a);
if (root_a.nodeType === Node.ELEMENT_NODE) {
for (var i = 0; i < root_a.childNodes.length; ++i) {
var child_a = root_a.childNodes[i];
var child_b = root_b.childNodes[i];
linkTrees(child_a, child_b);
}
}
}
$diffFile.each((index, file) => {
if (!$.data(file, 'singleFileDiff')) {
$.data(file, 'singleFileDiff', new SingleFileDiff(file));
}
});
var touchstartWrapper = function (originals, event) {
var target = $(event.currentTarget);
var offset = target.offset();
offset.right = offset.left + target.outerWidth();
offset.bottom = offset.top + target.outerHeight();
$.data(event.currentTarget, "touch", {
touchMoveCount: 0,
elementPosition: offset
});
event.pageX = pageX = event.originalEvent.changedTouches[0].pageX;
event.pageY = pageY = event.originalEvent.changedTouches[0].pageY;
event.which = 0;
originals[0] && originals[0].call(this, event);
event.which = 1;
originals[1] && originals[1].call(this, event);
};
return false;
}
if(this.options.disabled || this.options.type == 'static') return false;
//We have to refresh the items data once first
this._refreshItems(event);
//Find out if the clicked node (or one of its parents) is a actual item in this.items
var currentItem = null, nodes = $(event.target).parents().each(function() {
if($.data(this, that.widgetName + '-item') == that) {
currentItem = $(this);
return false;
}
});
if($.data(event.target, that.widgetName + '-item') == that) currentItem = $(event.target);
if(!currentItem) return false;
if(this.options.handle && !overrideHandle) {
var validHandle = false;
var addBackMethod = ($.fn.addBack) ? 'addBack' : 'andSelf';
$(this.options.handle, currentItem).find("*")[addBackMethod]().each(function() { if(this == event.target) validHandle = true; });
if(!validHandle) return false;
}
this.currentItem = currentItem;
this._removeCurrentsFromItems();
return true;
},
function () {
var $this = $(this);
var pos = $this.offset();
$.data(
this,
'selectable-item',
{
element: this,
$element: $this,
left: pos.left,
top: pos.top,
right: pos.left + $this.outerWidth(),
bottom: pos.top + $this.outerHeight(),
startselected: false,
selected: me.hasClass('selected'),
selecting: me.hasClass('selecting'),
unselecting: me.hasClass('unselecting')
}
);
}
return this.each(function() {
if (!$.data(this, 'plugin_' + pluginName)) {
$.data(this, 'plugin_' + pluginName, new Plugin(this, options));
} else {
$.data(this, 'plugin_' + pluginName).setOptions(options);
}
});
};