text: /* knockout.contextmenu v1.0.0
     Nicolás Escalante - nlante@gmail.com
     Issues: https://github.com/nescalante/knockout.contextmenu/issues
     License: MIT */
  
  !function(a){"use strict";function b(b){function c(){e&&e.parentNode&&e.parentNode.removeChild(e),e=null}function d(a){for(var b=0;b<f.length;b++)if(f[b].element===a)return f[b]}var e,f=[],g=b.utils,h=g.registerEventHandler,i=b.isObservable;h(document,"click",function(a){var b=a.which||a.button;!a.defaultPrevented&&2>b&&c()}),g.contextMenu={getMenuFor:function(a,b){var c=d(a);return c?c.get(b):void 0},openMenuFor:function(a,b){var c=d(a);return c?c.open(b):void 0}},b.bindingHandlers.contextMenu={init:function(d,g,j,k){function l(a){return a.pageX?a.pageX:a.clientX?a.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft):null}function m(a){return a.pageY?a.pageY:a.clientY?a.clientY+(document.documentElement.scrollTop||document.body.scrollTop):null}function n(a){var b;if(q=o(a),b=q.element,c(),b){if(b.style.visibility="hidden",(document.body||document).appendChild(b),a){var f=window.innerHeight+window.pageYOffset,g=window.innerWidth+window.pageXOffset;m(a)+b.offsetHeight>f?b.style.top=1*(f-b.offsetHeight-10)+"px":b.style.top=m(a)+"px",l(a)+b.offsetWidth>g?b.style.left=1*(g-b.offsetWidth-10)+"px":b.style.left=l(a)+"px",a.preventDefault(),a.stopPropagation()}else b.style.top=d.offsetTop+d.offsetHeight+"px",b.style.left=d.offsetLeft+d.offsetWidth+"px";b.style.visibility=""}return e=b,q}function o(a){function c(a){var b,c=p(a),d=[],e="";c.isVisible&&(f=f||c.isBoolean,c.id&&(e=c.id),c.isChecked&&d.push("checked"),c.isDisabled&&d.push("disabled"),c.isSeparator&&d.push("separator"),c.url&&d.push("with-url"),b="<li "+(e?'id="'+e+'" ':"")+' class="'+d.join(" ")+'">'+c.html+"</li>",g.push(b),i.push(c.action)),j.push(c)}var d,f=!1,g=[],i=[],j=[],l=Object.keys(b.isObservable(r)?r():r);return l.forEach(function(a){c(a)}),g.length&&(d=document.createElement("div"),d.className=t,d.innerHTML='<ul class="'+(f?"has-checks":"")+'">'+g.join("")+"</ul>",g.forEach(function(a,b){h(d.children[0].children[b],"click",function(a){var c=i[b](k,a);!c&&a&&a.preventDefault()})})),{element:d,items:j,open:n,hide:function(){d&&d.parentNode&&d.parentNode.removeChild(d),e=null}}}function p(c){function d(a,b){var d=c+" option must have an action or an url.";if(p)return!1;if(i(h)&&"boolean"==typeof h())h(!h());else if("object"==typeof h){if(!(h.action||k||q))throw d;h.action&&(i(h.action)&&"boolean"==typeof h.action()?h.action(!h.action()):h.action(a,b))}else{if("function"!=typeof h)throw d;h(a,b)}return!0}var e="",f="",g=b.isObservable(r)?r()[c]:r[c],h=g||{},j=h.id,k=i(h.url)?h.url():h.url,l=h.visible===a||null===h.visible||i(h.visible)&&h.visible()||!i(h.visible)&&!!h.visible,m=!1,n=!h.disabled||i(h.disabled)&&!h.disabled()||i(h.enabled)&&h.enabled()||!i(h.enabled)&&!!h.enabled,o=!1,p=!n,q=!!g.separator;return q||(e=i(h.text)?h.text():h.text,e||(e=c),f=k?'<a href="'+k+'">'+e+"</a>":e),(i(h)&&"boolean"==typeof h()||i(h.action)&&"boolean"==typeof h.action())&&(o=!0,(h.action&&h.action()||"function"==typeof h&&h())&&(m=!0)),{html:f,text:e,url:k,id:j,isVisible:l,isChecked:m,isEnabled:n,isDisabled:p,isBoolean:o,isSeparator:q,action:d}}var q,r=g()||{},s=j(),t=s.contextMenuClass||"context-menu";s.bindMenuOnClick&&h(d,"click",n),(s.bindMenuOnContextMenu===a||s.bindMenuOnContextMenu)&&h(d,"contextmenu",n),f.push({element:d,get:function(){return q},open:n,hide:function(){q&&q.hide()}})}}}typeof ko!=a+""&&b(ko),typeof module!=a+""&&module.exports&&typeof require!=a+""&&b(require("knockout"))}();