/*! * jQuery clip-path-polygon Plugin v0.1.15 (2020-06-24) * jQuery plugin that makes easy to use clip-path on whatever tag under different browsers * https://github.com/andrusieczko/clip-path-polygon * * Copyright 2020 Karol Andrusieczko * Released under MIT license */ var globalVariable=window||root,jQuery=jQuery||globalVariable.jQuery||require("jquery");(function(s){var n=0,r=function(t,e,i,s){this.$=t,this.$el=e,this.points=i,this.svgDefId="clipPathPolygonGenId"+n++,this.processOptions(s)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=r),exports.ClipPath=r):globalVariable.ClipPath=r,r.prototype={$:null,$el:null,points:null,isForWebkit:!0,isForSvg:!0,svgDefId:null,isPercentage:!1,create:function(){this._createClipPath(this.points)},_createClipPath:function(t){this._createSvgDefs(),this.isForSvg&&this._createSvgBasedClipPath(t),this.isForWebkit&&this._createWebkitClipPath(t)},_createWebkitClipPath:function(t){var e="polygon("+this._translatePoints(t,!0,this.isPercentage)+")";this.$el.css("-webkit-clip-path",e)},_createSvgBasedClipPath:function(t){this.$("#"+this.svgDefId).find("polygon").attr("points",this._translatePoints(t,!1,this.isPercentage)),this.$el.css("clip-path","url(#"+this.svgDefId+")")},_translatePoints:function(t,e,i){var s=[];for(var n in t){var r=this._handlePxs(t[n][0],e,i),a=this._handlePxs(t[n][1],e,i);s.push(r+" "+a)}return s.join(", ")},_handlePxs:function(t,e,i){return 0===t?t:e?t+(i?"%":"px"):i?t/100:t},_createSvgElement:function(t){return this.$(document.createElementNS("http://www.w3.org/2000/svg",t))},_createSvgDefs:function(){if(0===this.$("#"+this.svgDefId).length){var t=this._createSvgElement("svg").attr("width",0).attr("height",0).css({position:"absolute",visibility:"hidden",width:0,height:0}),e=this._createSvgElement("defs");t.append(e);var i=this._createSvgElement("clipPath").attr("id",this.svgDefId);this.isPercentage&&i.get(0).setAttribute("clipPathUnits","objectBoundingBox"),e.append(i);var s=this._createSvgElement("polygon");i.append(s),this.$("body").append(t)}},processOptions:function(t){this.isForWebkit=t&&void 0!==t.isForWebkit?t.isForWebkit:this.isForWebkit,this.isForSvg=t&&void 0!==t.isForSvg?t.isForSvg:this.isForSvg,this.isPercentage=t&&t.isPercentage||this.isPercentage,this.svgDefId=t&&t.svgDefId||this.svgDefId}},s.fn.clipPath=function(e,i){return this.each(function(){var t=s(this);new r(s,t,e,i).create()})}}).call(this,jQuery);