-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathpurplecoat.min.js
2 lines (2 loc) · 1.39 KB
/
purplecoat.min.js
1
2
/*! purplecoat.js 0.1.0 by Elle Kasai (MIT License).*/
!function(a){var b=function(b,c,d){var e=a("[data-purplecoat-for="+b+"]:visible"),f=a("[data-purplecoat-for="+b+"]:hidden");e.length?e.fadeOut():f.length?f.fadeIn():d.each(function(){var d=a(this);if(!d.is(":hidden")){var e=a('<div class="purplecoat"></div>');a("body").append(e);var f=a('<div class="purplecoat-inner"></div>');e.append(f);var g=a('<div class="purplecoat-inner-text"></div>');g.html(d.data("purplecoat-label")),f.append(g),d.data("purplecoat-color")&&(c=d.data("purplecoat-color")),c&&e.css("background-color",c),e.attr("data-purplecoat-for",b).css({top:d.offset().top,left:d.offset().left,width:d.outerWidth(),height:d.outerHeight()}).fadeIn()}})};a.fn.purplecoat=function(){var a=this.data("purplecoat"),c=this.data("purplecoat-color"),d=this;b(a,c,d)},a(function(){var c=".purplecoat { display: none; position: absolute; padding: 5px; box-sizing: border-box; background-color: rgba(142, 68, 173, 0.9); color: #FFF; text-align: center; font-weight: bold; overflow: hidden; z-index: 9999; } .purplecoat-inner { display: table; width: 100%; height: 100%; } .purplecoat-inner-text { display: table-cell; vertical-align: middle;}",d=a("<style/>");d.html(c),a("head").prepend(d),a("[data-purplecoat-toggle]").on("click",function(){var c=a(this).data("purplecoat-toggle"),d=a(this).data("purplecoat-color"),e=a("[data-purplecoat="+c+"]");b(c,d,e)})})}(jQuery);