UNPKG

typecho-core

Version:

An element-drived engine working well with XHR-intensive front-end. Originally designed for Typecho.

1 lines 1.65 kB
!function(e){e.fn.resizeable=function(t){const c=e.extend({minHeight:100,afterResize:null},t);let n;return this.each((function(){let t,l=e('<span class="resize"><i></i></span>').insertAfter(this),o=0,i=c.minHeight,s=this;function u(e){let c=r(e).y,l=t+c;return o>=c&&(l-=5),o=c,l=Math.max(i,l),n.height(l+"px"),l<i&&h(e),!1}function h(l){const i=n.outerHeight();e(document).unbind("mousemove",u).unbind("mouseup",h),n.css("opacity",1),n.focus(),n=null,t=null,o=0,c.afterResize&&c.afterResize.call(s,i)}function r(e){return{x:e.clientX+document.documentElement.scrollLeft,y:e.clientY+document.documentElement.scrollTop}}l.bind("mousedown",{el:this},(function(c){return n=e(c.data.el),n.blur(),o=r(c).y,t=n.height()-o,n.css("opacity",.25),e(document).mousemove(u).mouseup(h),!1}))}))},e.fn.tableSelectable=function(t){const c=this,n=e.extend({checkEl:null,rowEl:null,selectAllEl:null,actionEl:null},t);function l(t){t=e(t);let c=e(n.checkEl,t),l=c.prop("checked");c.length&&(c.prop("checked",!l),l?t.removeClass("checked"):t.addClass("checked"))}e(n.rowEl,this).each((function(){e(n.checkEl,this).click((function(t){l(e(this).parents(n.rowEl))}))})).click((function(t){const c=e(t.toElement?t.toElement:t.target),n=c.prop("tagName").toLowerCase();e.inArray(n,["input","textarea","button","i","a","sup"])>=0&&"checkbox"!==c.attr("type")||l(this)})),e(n.selectAllEl).click((function(){e(this).prop("checked")?e(n.rowEl,c).each((function(){const t=e(this);e(n.checkEl,this).prop("checked",!0).length>0&&t.addClass("checked")})):e(n.rowEl,c).each((function(){const t=e(this);e(n.checkEl,this).prop("checked",!1).length>0&&t.removeClass("checked")}))}))}}($);