1/** 2_ _____ _ _ _ 3| | __ \ (_) | | | | 4___ ___ | | |__) |___ ___ _ ______ _| |__ | | ___ 5/ __/ _ \| | _ // _ \/ __| |_ / _` | '_ \| |/ _ \ 6| (_| (_) | | | \ \ __/\__ \ |/ / (_| | |_) | | __/ 7\___\___/|_|_| \_\___||___/_/___\__,_|_.__/|_|\___| 8 9v 1.3 - a jQuery plugin by Alvaro Prieto Lauroba 10 11Licences: MIT & GPL 12Feel free to use or modify this plugin as far as my full name is kept 13 14If you are going to use this plugin in production environments it is 15strongly recomended to use its minified version: colResizable.min.js 16 17 */ 18(function ($) { 19 var d = $(document); 20 var h = $("head"); 21 var drag = null; 22 var tables = []; 23 var count = 0; 24 var ID = "id"; 25 var PX = "px"; 26 var SIGNATURE = "WebFiliale"; 27 var I = parseInt; 28 var M = Math; 29 var ie = false; 30 var S; 31 try { 32 S = sessionStorage; 33 } catch (e) {} 34 h.append("<style type='text/css'> .WebFiliale{table-layout:fixed;} .WebFiliale td, .WebFiliale th{overflow:hidden;padding-left:0; padding-right:0;} .WebFilialegrips{ height:0px; position:relative;} .WebFilialegrip{margin-left:-2px; position:absolute; z-index:98; } .WebFilialegrip .WebFiliale{position:absolute;width:10px;height:100%;top:0px} .WebFilialeLastGrip{position:absolute; width:1px; } .WebFilialegripDrag{ border-left:1px dotted black; }</style>"); 35 var init = function (tb, options) { 36 var t = $(tb); 37 if (options.disable) 38 return destroy(t); 39 var id = t.id = t.attr(ID) || SIGNATURE + count++; 40 t.p = options.postbackSafe; 41 if (!t.is("table") || tables[id]) 42 return; 43 t.addClass(SIGNATURE).attr(ID, id).before('<div class="WebFilialegrips"/>'); 44 t.opt = options; 45 t.g = []; 46 t.c = []; 47 t.w = t.width(); 48 t.gc = t.prev(); 49 if (options.marginLeft) 50 t.gc.css("marginLeft", options.marginLeft); 51 if (options.marginRight) 52 t.gc.css("marginRight", options.marginRight); 53 t.cs = I(ie ? tb.cellSpacing || tb.currentStyle.borderSpacing : t.css('border-spacing')) || 2; 54 t.b = I(ie ? tb.border || tb.currentStyle.borderLeftWidth : t.css('border-left-width')) || 1; 55 tables[id] = t; 56 createGrips(t); 57 }; 58 var destroy = function (t) { 59 var id = t.attr(ID), 60 t = tables[id]; 61 if (!t || !t.is("table")) 62 return; 63 t.removeClass(SIGNATURE).gc.remove(); 64 delete tables[id]; 65 }; 66 var createGrips = function (t) { 67 var th = t.find(">thead:first>tr>th:not(.c_noResizable),>thead:first>tr>td:not(.c_noResizable)"); 68 if (!th.length) 69 th = t.find(">tbody>tr:first>th:not(.c_noResizable),>tr:first>th:not(.c_noResizable),>tbody>tr:first>td:not(.c_noResizable), >tr:first>td:not(.c_noResizable)"); 70 t.cg = t.find("col"); 71 t.ln = th.length; 72 if (t.p && S && S[t.id]) 73 memento(t, th); 74 th.each(function (i) { 75 var c = $(this); 76 var g = $(t.gc.append('<div class="WebFilialegrip"></div>')[0].lastChild); 77 g.t = t; 78 g.i = i; 79 g.c = c; 80 c.w = c.width(); 81 t.g.push(g); 82 t.c.push(c); 83 c.width(c.w).removeAttr("width"); 84 if (i < t.ln - 1) 85 g.mousedown(onGripMouseDown).append(t.opt.gripInnerHtml).append('<div class="' + SIGNATURE + '" style="cursor:' + t.opt.hoverCursor + '"></div>'); 86 else 87 g.addClass("WebFilialeLastGrip").removeClass("WebFilialegrip"); 88 g.data(SIGNATURE, { 89 i : i, 90 t : t.attr(ID) 91 }); 92 }); 93 t.cg.removeAttr("width"); 94 syncGrips(t); 95 t.find('td:not(.c_noResizable), th:not(.c_noResizable)').not(th).not('table th:not(.c_noResizable), table td:not(.c_noResizable)').each(function () { 96 $(this).removeAttr('width'); 97 }); 98 }; 99 var memento = function (t, th) { 100 var w, 101 m = 0, 102 i = 0, 103 aux = []; 104 if (th) { 105 t.cg.removeAttr("width"); 106 if (t.opt.flush) { 107 S[t.id] = ""; 108 return; 109 } 110 w = S[t.id].split(";"); 111 for (; i < t.ln; i++) { 112 aux.push(100 * w[i] / w[t.ln] + "%"); 113 th.eq(i).css("width", aux[i]); 114 } 115 for (i = 0; i < t.ln; i++) 116 t.cg.eq(i).css("width", aux[i]); 117 } else { 118 S[t.id] = ""; 119 for (i in t.c) { 120 w = t.c[i].width(); 121 S[t.id] += w + ";"; 122 m += w; 123 } 124 S[t.id] += m; 125 } 126 }; 127 var syncGrips = function (t) { 128 t.gc.width(t.w); 129 for (var i = 0; i < t.ln; i++) { 130 var c = t.c[i]; 131 t.g[i].css({ 132 left : c.offset().left - t.offset().left + c.outerWidth() + t.cs / 2 + PX, 133 height : t.opt.headerOnly ? t.c[0].outerHeight() : t.outerHeight() 134 }); 135 } 136 }; 137 var syncCols = function (t, i, isOver) { 138 var inc = drag.x - drag.l, 139 c = t.c[i], 140 c2 = t.c[i + 1];
141 var w = c.w + inc; 142 var w2 = c2.w - inc; 143 c.width(w + PX); 144 c2.width(w2 + PX); 145 t.cg.eq(i).width(w + PX); 146 t.cg.eq(i + 1).width(w2 + PX); 147 if (isOver) { 148 c.w = w; 149 c2.w = w2; 150 } 151 }; 152 var onGripDrag = function (e) { 153 if (!drag) 154 return; 155 var t = drag.t; 156 var x = e.pageX - drag.ox + drag.l; 157 var mw = t.opt.minWidth, 158 i = drag.i; 159 var l = t.cs * 1.5 + mw + t.b; 160 var max = i == t.ln - 1 ? t.w - l : t.g[i + 1].position().left - t.cs - mw; 161 var min = i ? t.g[i - 1].position().left + t.cs + mw : l; 162 x = M.max(min, M.min(max, x)); 163 drag.x = x; 164 drag.css("left", x + PX); 165 if (t.opt.liveDrag) { 166 syncCols(t, i); 167 syncGrips(t); 168 var cb = t.opt.onDrag; 169 if (cb) { 170 e.currentTarget = t[0]; 171 cb(e); 172 } 173 } 174 return false; 175 }; 176 var onGripDragOver = function (e) { 177 d.unbind('mousemove.' + SIGNATURE).unbind('mouseup.' + SIGNATURE); 178 $("head :last-child").remove(); 179 if (!drag) 180 return; 181 drag.removeClass(drag.t.opt.draggingClass); 182 var t = drag.t, 183 cb = t.opt.onResize; 184 if (drag.x) { 185 syncCols(t, drag.i, true); 186 syncGrips(t); 187 if (cb) { 188 e.currentTarget = t[0]; 189 cb(e); 190 } 191 } 192 if (t.p && S) 193 memento(t); 194 drag = null; 195 }; 196 var onGripMouseDown = function (e) { 197 var o = $(this).data(SIGNATURE); 198 var t = tables[o.t], 199 g = t.g[o.i]; 200 g.ox = e.pageX; 201 g.l = g.position().left; 202 d.bind('mousemove.' + SIGNATURE, onGripDrag).bind('mouseup.' + SIGNATURE, onGripDragOver); 203 h.append("<style type='text/css'>*{cursor:" + t.opt.dragCursor + "!important}</style>"); 204 g.addClass(t.opt.draggingClass); 205 drag = g; 206 if (t.c[o.i].l) 207 for (var i = 0, c; i < t.ln; i++) { 208 c = t.c[i]; 209 c.l = false; 210 c.w = c.width(); 211 } 212 return false; 213 }; 214 var onResize = function () { 215 for (t in tables) { 216 var t = tables[t], 217 i, 218 mw = 0; 219 t.removeClass(SIGNATURE); 220 t.w = $('.c_content').width(); 221 if (t.w != t.width()) { 222 t.w = $('.c_content').width(); 223 for (i = 0; i < t.ln; i++) 224 mw += t.c[i].w; 225 for (i = 0; i < t.ln; i++) 226 t.c[i].css("width", M.round(1000 * t.c[i].w / mw) / 10 + "%").l = true; 227 } 228 syncGrips(t.addClass(SIGNATURE)); 229 } 230 }; 231 $(window).bind('resize.' + SIGNATURE, onResize); 232 $.fn.extend({ 233 colResizable : function (options) { 234 var defaults = { 235 draggingClass : 'WebFilialegripDrag', 236 gripInnerHtml : '', 237 liveDrag : false, 238 minWidth : 15, 239 headerOnly : false, 240 hoverCursor : "e-resize", 241 dragCursor : "e-resize", 242 postbackSafe : false, 243 flush : false, 244 marginLeft : null, 245 marginRight : null, 246 disable : false, 247 onDrag : null, 248 onResize : null 249 } 250 var options = $.extend(defaults, options); 251 return this.each(function () { 252 init(this, options); 253 }); 254 } 255 }); 256})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.