/*! * jQuery Contextify v1.0.7 (http://contextify.js.org) * Copyright (c) 2016 Adam Bouqdib * Licensed under GPL-2.0 (http://abemedia.co.uk/license) */ !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery,window)}(function(a,b){function c(b,c){this.element=b,this.options=a.extend({},e,c),this._defaults=e,this._name=d,this.init()}var d="contextify",e={items:[],action:"contextmenu",menuId:"contextify-menu",menuClass:"dropdown-menu",headerClass:"dropdown-header",dividerClass:"divider",before:!1},f=0;c.prototype.init=function(){var c=a.extend({},this.options,a(this.element).data());c.id=f,a(this.element).attr("data-contextify-id",c.id).on("contextmenu",function(d){d.preventDefault(),"function"==typeof c.before&&c.before(this,c);var e=a('
');e.data(c);var f,g=c.items.length;for(f=0;g>f;f++){var h=c.items[f],i=a("");if(h.divider)i.addClass(c.dividerClass);else if(h.header)i.addClass(c.headerClass),i.html(h.header);else{i.append("");var j=i.find("a");if(h.href&&j.attr("href",h.href),h.onclick&&(j.on("click",c,h.onclick),j.css("cursor","pointer")),h.data){for(var k in h.data)e.attr("data-"+k,h.data[k]);j.data(h.data)}j.html(h.text)}e.append(i)}var l=a("#"+c.menuId);l.length>0?l!==e&&l.replaceWith(e):a("body").append(e);var m=a(b).scrollTop()+d.clientY,n=e.width()+d.clientX