New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jquery-contextmenu-common

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jquery-contextmenu-common - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

bower.json
{
"name": "jquery-contextmenu-common",
"version": "1.0.0",
"version": "1.0.1",
"description": "jQuery plugin to add common checkable menu items `checkbox` and `radio` and more features to jQuery.contextMenu.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -1,1 +0,1 @@

!function(e){"use strict";function t(e,t,n){var o,c=n||e.checkedItem,i=l+"radio-";return e.items.forEach(function(n){var r,u=t[n],s=u.options;n===c?(r=!0,e.checkedItem=n,o=u.value):r=!1,r!==u.checked&&(u.checked=s.checked=s.selected=r,u.$elm&&u.$elm.removeClass(i+(r?"off":"on")).addClass(i+(r?"on":"off")))}),o}function n(e,t){var n=l+"checkbox-",o=e.options;return"boolean"==typeof t&&t!==e.checked&&(e.checked=o.checked=o.selected=t,e.$elm&&e.$elm.removeClass(n+(t?"off":"on")).addClass(n+(t?"on":"off"))),e.value[e.checked?1:0]}function o(n,o){var c=this,i={},r={},p=[],h={},f={};Object.keys(n).forEach(function(t){var o,c,u=n[t],s=u.options;i[u.itemKey]=t,u.checked=s.checked=s.selected=!!s.checked||!!s.selected,"checkbox"===u.type?u.value=e.isArray(s.value)?s.value:[!1,s.hasOwnProperty("value")?s.value:!0]:(null==(o=s.radiogroup)&&null==(o=s.radio)||!(c=o+"")||(u.groupId=c,r[c]=!0),s.hasOwnProperty("value")&&(u.value=s.value),p.push(t))}),p.forEach(function(e){var o,c,i,u=n[e];if(!u.groupId){if(!h[u.nodeId]){for(o="node-"+u.nodeId,c=0;r[o];o="node-"+u.nodeId+"-"+c++);h[u.nodeId]=o}u.groupId=h[u.nodeId]}f[u.groupId]?(i=f[u.groupId],i.items.push(e),u.checked&&t(i,n,e)):t(i=f[u.groupId]={items:[e]},n,e),u.hasOwnProperty("value")||(u.value=i.items.length-1)}),Object.keys(n).forEach(function(t){var o=n[t],i=o.options,r=i.callback,u=i.icon;i.callback=function(){return c.click(t),r?r.apply(c.$trigger,arguments):void 0},i.icon=function(t,n){return o.$elm=n,e.isFunction(u)&&u.apply(this,arguments),s+" "+a+"icon-ctrl "+l+o.type+"-"+(o.checked?"on":"off")}}),c.$trigger=o,c.items=n,c.groups=f,c.itemKey2itemId=i,c.specificGroupIds=r,o.data(u,c),d.push(c)}function c(){d.map(function(e){return e}).forEach(function(e){e.remove()})}function i(t,n,o){var c;return null==o?o={value:0}:o.value++,c=o.value,Object.keys(t).reduce(function(n,r){var u,l,d,p,h=t[r],f=h.type,m=h.label||h.name;if("checkbox"===f||"radio"===f){for(delete h.type,d=r,p=0;!d||n[d];d=r+""+p++);n[d]={itemKey:r,options:h,type:f,nodeId:c}}return m&&e.isArray(m)&&(u=m[1],m=m[0]),m&&((l=m instanceof jQuery||null!=m.nodeType)||u?(h.name=l?"":m,h.icon=function(t){return function(n,o){return l&&!e.contains(o,m)&&o.empty().append(m),u&&!o.has("."+a+"sublabel").length&&o.prepend(e('<span class="'+a+'sublabel"/>')[u instanceof jQuery||null!=u.nodeType?"append":"text"](u)),t?e.isFunction(t)?t.apply(this,arguments):s+" "+s+"-"+t:""}}(h.icon)):h.name=m),h.items&&(n=i(h.items,n,o)),n},n||{})}function r(e,t){var n;return e.items&&Object.keys(n=i(e.items)).length?new o(n,t):null}var u="_contextmenu_common_checkable",s="context-menu-icon",a="contextmenu-common-",l=s+"-common-",d=[];if(o.prototype.click=function(e){var o=this.items[e];"checkbox"===o.type?n(o,!o.checked):t(this.groups[o.groupId],this.items,e)},o.prototype.value=function(e,o){function c(e,t,n){var o;return e.items.some(function(e){return t[e].value===n?(o=e,!0):!1}),o}function i(e,t){return e[0]===t?!1:e[1]===t?!0:null}var r,u,s;if(e){if(this.specificGroupIds[e]?u=e:(r=this.itemKey2itemId[e])&&(s=this.items[r],"radio"===s.type&&(u=s.groupId)),u)return t(this.groups[u],this.items,arguments.length>=2?c(this.groups[u],this.items,o):null);if(r)return n(s,arguments.length>=2?i(s.value,o):null)}},o.prototype.remove=function(){var e;this.$trigger.removeData(u),this.$trigger=this.items=this.groups=this.itemKey2itemId=this.specificGroupIds=null,(e=d.indexOf(this))>-1&&d.splice(e,1)},!e.contextMenu)throw new Error("jQuery.contextMenu is not loaded.");e.contextMenuCommon=function(t,n){var o,i,s,a;return"string"==typeof t?(i=t,o=n||{}):(i="create",o=t||{}),"create"===i?e.isPlainObject(o)&&o.selector&&(s=e(o.selector)).length&&r(o,s):"destroy"===i&&((s="string"==typeof o?e(o):o.context)?s.length&&(a=s.data(u))&&a.remove():c()),e.contextMenu.apply(e,arguments)},e.fn.contextMenuCommon=function(t,n){var o,c=this.length?this.data(u):null;if(c)switch(t){case"click":return(o=c.itemKey2itemId[n])&&c.click(o),this;case"value":return c.value.apply(c,[].slice.call(arguments,1));case"destroy":return e.contextMenuCommon("destroy",{context:this}),this;case"checkable":return c}return e.fn.contextMenu.apply(this,arguments)}}(jQuery);
!function(e){"use strict";function t(e,t,n){var o,c=n||e.checkedItem,r=l+"radio-";return e.items.forEach(function(n){var i,u=t[n],s=u.options;n===c?(i=!0,e.checkedItem=n,o=u.value):i=!1,i!==u.checked&&(u.checked=s.checked=s.selected=i,u.$elm&&u.$elm.removeClass(r+(i?"off":"on")).addClass(r+(i?"on":"off")))}),o}function n(e,t){var n=l+"checkbox-",o=e.options;return"boolean"==typeof t&&t!==e.checked&&(e.checked=o.checked=o.selected=t,e.$elm&&e.$elm.removeClass(n+(t?"off":"on")).addClass(n+(t?"on":"off"))),e.value[e.checked?1:0]}function o(n,o,c){var r=this,i={},p={},h=[],f={},m={};Object.keys(n).forEach(function(t){var o,c,r=n[t],u=r.options;i[r.itemKey]=t,r.checked=u.checked=u.selected=!!u.checked||!!u.selected,"checkbox"===r.type?r.value=e.isArray(u.value)?u.value:[!1,u.hasOwnProperty("value")?u.value:!0]:(null==(o=u.radiogroup)&&null==(o=u.radio)||!(c=o+"")||(r.groupId=c,p[c]=!0),u.hasOwnProperty("value")&&(r.value=u.value),h.push(t))}),h.forEach(function(e){var o,c,r,i=n[e];if(!i.groupId){if(!f[i.nodeId]){for(o="node-"+i.nodeId,c=0;p[o];o="node-"+i.nodeId+"-"+c++);f[i.nodeId]=o}i.groupId=f[i.nodeId]}m[i.groupId]?(r=m[i.groupId],r.items.push(e),i.checked&&t(r,n,e)):t(r=m[i.groupId]={items:[e]},n,e),i.hasOwnProperty("value")||(i.value=r.items.length-1)}),Object.keys(n).forEach(function(t){var o=n[t],i=o.options,u=i.callback,d=i.icon;i.callback=function(){return r.click(t),u?u.apply(r.$trigger,arguments):c.callback?c.callback.apply(r.$trigger,arguments):void 0},i.icon=function(t,n){return o.$elm=n,e.isFunction(d)&&d.apply(this,arguments),s+" "+a+"icon-ctrl "+l+o.type+"-"+(o.checked?"on":"off")}}),r.$trigger=o,r.items=n,r.groups=m,r.itemKey2itemId=i,r.specificGroupIds=p,o.data(u,r),d.push(r)}function c(){d.map(function(e){return e}).forEach(function(e){e.remove()})}function r(t,n,o){var c;return null==o?o={value:0}:o.value++,c=o.value,Object.keys(t).reduce(function(n,i){var u,l,d,p,h=t[i],f=h.type,m=h.label||h.name;if("checkbox"===f||"radio"===f){for(delete h.type,d=i,p=0;!d||n[d];d=i+""+p++);n[d]={itemKey:i,options:h,type:f,nodeId:c}}return m&&e.isArray(m)&&(u=m[1],m=m[0]),m&&((l=m instanceof jQuery||null!=m.nodeType)||u?(h.name=l?"":m,h.icon=function(t){return function(n,o){return l&&!e.contains(o,m)&&o.empty().append(m),u&&!o.has("."+a+"sublabel").length&&o.prepend(e('<span class="'+a+'sublabel"/>')[u instanceof jQuery||null!=u.nodeType?"append":"text"](u)),t?e.isFunction(t)?t.apply(this,arguments):s+" "+s+"-"+t:""}}(h.icon)):h.name=m),h.items&&(n=r(h.items,n,o)),n},n||{})}function i(e,t){var n;return e.items&&Object.keys(n=r(e.items)).length?new o(n,t,e):null}var u="_contextmenu_common_checkable",s="context-menu-icon",a="contextmenu-common-",l=s+"-common-",d=[];if(o.prototype.click=function(e){var o=this.items[e];"checkbox"===o.type?n(o,!o.checked):t(this.groups[o.groupId],this.items,e)},o.prototype.value=function(e,o){function c(e,t,n){var o;return e.items.some(function(e){return t[e].value===n?(o=e,!0):!1}),o}function r(e,t){return e[0]===t?!1:e[1]===t?!0:null}var i,u,s,a;if(e){if(this.specificGroupIds[e]?u=e:(i=this.itemKey2itemId[e])&&(s=this.items[i],"radio"===s.type&&(u=s.groupId)),u)return t(this.groups[u],this.items,arguments.length>=2?c(this.groups[u],this.items,o):null);if(i)return n(s,arguments.length>=2?r(s.value,o):null)}return a},o.prototype.remove=function(){var e;this.$trigger.removeData(u),this.$trigger=this.items=this.groups=this.itemKey2itemId=this.specificGroupIds=null,(e=d.indexOf(this))>-1&&d.splice(e,1)},!e.contextMenu)throw new Error("jQuery.contextMenu is not loaded.");e.contextMenuCommon=function(t,n){var o,r,s,a;return"string"==typeof t?(r=t,o=n||{}):(r="create",o=t||{}),"create"===r?e.isPlainObject(o)&&o.selector&&(s=e(o.selector)).length&&i(o,s):"destroy"===r&&((s="string"==typeof o?e(o):o.context)?s.length&&(a=s.data(u))&&a.remove():c()),e.contextMenu.apply(e,arguments)},e.fn.contextMenuCommon=function(t,n){var o,c=this.length?this.data(u):null;if(c)switch(t){case"click":return(o=c.itemKey2itemId[n])&&c.click(o),this;case"value":return c.value.apply(c,[].slice.call(arguments,1));case"destroy":return e.contextMenuCommon("destroy",{context:this}),this;case"checkable":return c}return e.fn.contextMenu.apply(this,arguments)}}(jQuery);
{
"name": "jquery-contextmenu-common",
"version": "1.0.0",
"version": "1.0.1",
"title": "jQuery.contextMenuCommon",

@@ -5,0 +5,0 @@ "description": "jQuery plugin to add common checkable menu items `checkbox` and `radio` and more features to jQuery.contextMenu.",

@@ -99,4 +99,5 @@ /*

* @param {jQuery} $trigger - Trigger of the menu.
* @param {Object} rootOptions - Current root options.
*/
function CheckableMan(items, $trigger) {
function CheckableMan(items, $trigger, rootOptions) {
var that = this, itemKey2itemId = {}, specificGroupIds = {},

@@ -118,4 +119,4 @@ radioItems = [], nodeId2groupId = {}, groups = {};

// Don't make `groupId` and `value` if those are not specified to check after.
if (((radiogroup = options.radiogroup) != null || // eslint-disable-line eqeqeq
(radiogroup = options.radio) != null) && // eslint-disable-line eqeqeq
if (((radiogroup = options.radiogroup) != null ||
(radiogroup = options.radio) != null) &&
(groupId = radiogroup + '')) {

@@ -166,3 +167,4 @@ item.groupId = groupId;

that.click(itemId);
return orgCallback ? orgCallback.apply(that.$trigger, arguments) : void 0;
return orgCallback ? orgCallback.apply(that.$trigger, arguments) :
rootOptions.callback ? rootOptions.callback.apply(that.$trigger, arguments) : void 0;
};

@@ -231,3 +233,3 @@

var itemId, groupId, item;
var itemId, groupId, item, undef;
if (itemKeyOrRadioGroup) {

@@ -249,3 +251,3 @@ if (this.specificGroupIds[itemKeyOrRadioGroup]) { // give priority

}
return void 0;
return undef;
};

@@ -275,3 +277,3 @@

var curNodeId; // nodeId that is not changed by nested nodes.
if (nodeId == null) { // eslint-disable-line eqeqeq
if (nodeId == null) {
nodeId = {value: 0};

@@ -327,3 +329,2 @@ } else {

if (label) {
// eslint-disable-next-line eqeqeq
if ((isElmLabel = label instanceof jQuery || label.nodeType != null) || // loose check

@@ -342,3 +343,2 @@ subLabel) {

$('<span class="' + CLASS_PREFIX + 'sublabel"/>')[
// eslint-disable-next-line eqeqeq
subLabel instanceof jQuery || subLabel.nodeType != null ? // loose check

@@ -376,3 +376,3 @@ 'append' : 'text'](subLabel)

Object.keys((checkableItems = parseItems(options.items))).length ?
new CheckableMan(checkableItems, $trigger) : null;
new CheckableMan(checkableItems, $trigger, options) : null;
}

@@ -379,0 +379,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc