slickgrid
Advanced tools
Comparing version 2.1.0 to 2.3.3
@@ -12,16 +12,24 @@ (function ($) { | ||
grid.onHeaderContextMenu.subscribe(handleHeaderContextMenu); | ||
grid.onColumnsReordered.subscribe(updateColumnOrder); | ||
options = $.extend({}, defaults, options); | ||
$menu = $("<span class='slick-columnpicker' style='display:none;position:absolute;z-index:20;' />").appendTo(document.body); | ||
$menu = $("<span class='slick-columnpicker' style='display:none;position:absolute;z-index:20;overflow-y:scroll;' />").appendTo(document.body); | ||
$menu.bind("mouseleave", function (e) { | ||
$menu.on("mouseleave", function (e) { | ||
$(this).fadeOut(options.fadeSpeed) | ||
}); | ||
$menu.bind("click", updateColumn); | ||
$menu.on("click", updateColumn); | ||
} | ||
function destroy() { | ||
grid.onHeaderContextMenu.unsubscribe(handleHeaderContextMenu); | ||
grid.onColumnsReordered.unsubscribe(updateColumnOrder); | ||
$menu.remove(); | ||
} | ||
function handleHeaderContextMenu(e, args) { | ||
e.preventDefault(); | ||
$menu.empty(); | ||
updateColumnOrder(); | ||
columnCheckboxes = []; | ||
@@ -40,3 +48,3 @@ | ||
$("<label />") | ||
.text(columns[i].name) | ||
.html(columns[i].name) | ||
.prepend($input) | ||
@@ -70,5 +78,28 @@ .appendTo($li); | ||
.css("left", e.pageX - 10) | ||
.css("max-height", $(window).height() - e.pageY -10) | ||
.fadeIn(options.fadeSpeed); | ||
} | ||
function updateColumnOrder() { | ||
// Because columns can be reordered, we have to update the `columns` | ||
// to reflect the new order, however we can't just take `grid.getColumns()`, | ||
// as it does not include columns currently hidden by the picker. | ||
// We create a new `columns` structure by leaving currently-hidden | ||
// columns in their original ordinal position and interleaving the results | ||
// of the current column sort. | ||
var current = grid.getColumns().slice(0); | ||
var ordered = new Array(columns.length); | ||
for (var i = 0; i < ordered.length; i++) { | ||
if ( grid.getColumnIndex(columns[i].id) === undefined ) { | ||
// If the column doesn't return a value from getColumnIndex, | ||
// it is hidden. Leave it in this position. | ||
ordered[i] = columns[i]; | ||
} else { | ||
// Otherwise, grab the next visible column. | ||
ordered[i] = current.shift(); | ||
} | ||
} | ||
columns = ordered; | ||
} | ||
function updateColumn(e) { | ||
@@ -111,3 +142,12 @@ if ($(e.target).data("option") == "autoresize") { | ||
function getAllColumns() { | ||
return columns; | ||
} | ||
init(); | ||
return { | ||
"getAllColumns": getAllColumns, | ||
"destroy": destroy | ||
}; | ||
} | ||
@@ -114,0 +154,0 @@ |
@@ -0,0 +0,0 @@ (function ($) { |
@@ -0,0 +0,0 @@ ; |
@@ -0,0 +0,0 @@ if (typeof console === "undefined" || typeof console.log === "undefined") { |
@@ -181,3 +181,3 @@ /*! | ||
case !dd.dragging && 'mousemove': | ||
// drag tolerance, x� + y� = distance� | ||
// drag tolerance, x≤ + y≤ = distance≤ | ||
if ( Math.pow( event.pageX-dd.pageX, 2 ) + Math.pow( event.pageY-dd.pageY, 2 ) < Math.pow( dd.distance, 2 ) ) | ||
@@ -184,0 +184,0 @@ break; // distance tolerance not reached |
@@ -0,0 +0,0 @@ /* |
@@ -1,79 +0,94 @@ | ||
/* jquery.sparkline 1.4.3 - http://omnipotent.net/jquery.sparkline/ */ | ||
/* jquery.sparkline 1.6 - http://omnipotent.net/jquery.sparkline/ | ||
** Licensed under the New BSD License - see above site for details */ | ||
(function($){$.fn.simpledraw=function(width,height,use_existing){if(use_existing&&this[0].vcanvas)return this[0].vcanvas;if(width==undefined)width=$(this).innerWidth();if(height==undefined)height=$(this).innerHeight();if($.browser.hasCanvas){return new vcanvas_canvas(width,height,this);}else if($.browser.msie){return new vcanvas_vml(width,height,this);}else{return false;}};var pending=[];$.fn.sparkline=function(uservalues,options){var options=$.extend({type:'line',lineColor:'#00f',fillColor:'#cdf',defaultPixelsPerValue:3,width:'auto',height:'auto',composite:false},options?options:{});return this.each(function(){var render=function(){var values=(uservalues=='html'||uservalues==undefined)?$(this).text().split(','):uservalues;var width=options.width=='auto'?values.length*options.defaultPixelsPerValue:options.width;if(options.height=='auto'){if(!options.composite||!this.vcanvas){var tmp=document.createElement('span');tmp.innerHTML='a';$(this).html(tmp);height=$(tmp).innerHeight();$(tmp).remove();}}else{height=options.height;} | ||
$.fn.sparkline[options.type].call(this,values,options,width,height);} | ||
if(($(this).html()&&$(this).is(':hidden'))||($.fn.jquery<"1.3.0"&&$(this).parents().is(':hidden'))){pending.push([this,render]);}else{render.call(this);}});};$.sparkline_display_visible=function(){for(var i=pending.length-1;i>=0;i--){var el=pending[i][0];if($(el).is(':visible')&&!$(el).parents().is(':hidden')){pending[i][1].call(el);pending.splice(i,1);}}};$.fn.sparkline.line=function(values,options,width,height){var options=$.extend({spotColor:'#f80',spotRadius:1.5,minSpotColor:'#f80',maxSpotColor:'#f80',lineWidth:1,normalRangeMin:undefined,normalRangeMax:undefined,normalRangeColor:'#ccc',chartRangeMin:undefined,chartRangeMax:undefined},options?options:{});var xvalues=[],yvalues=[],yminmax=[];for(i=0;i<values.length;i++){var v=values[i];var isstr=typeof(values[i])=='string';var isarray=typeof(values[i])=='object'&&values[i]instanceof Array;var sp=isstr&&values[i].split(':');if(isstr&&sp.length==2){xvalues.push(Number(sp[0]));yvalues.push(Number(sp[1]));yminmax.push(Number(sp[1]));}else if(isarray){xvalues.push(values[i][0]);yvalues.push(values[i][1]);yminmax.push(values[i][1]);}else{xvalues.push(i);if(values[i]===null||values[i]=='null'){yvalues.push(null);}else{yvalues.push(Number(values[i]));yminmax.push(Number(values[i]));}}} | ||
if(options.xvalues){xvalues=options.xvalues;} | ||
var maxy=Math.max.apply(Math,yminmax);var maxyval=maxy;var miny=Math.min.apply(Math,yminmax);var minyval=miny;var maxx=Math.max.apply(Math,xvalues);var maxxval=maxx;var minx=Math.min.apply(Math,xvalues);var minxval=minx;if(options.normalRangeMin!=undefined){if(options.normalRangeMin<miny) | ||
miny=options.normalRangeMin;if(options.normalRangeMax>maxy) | ||
maxy=options.normalRangeMax;} | ||
if(options.chartRangeMin!=undefined&&options.chartRangeMin<miny){miny=options.chartRangeMin;} | ||
if(options.chartRangeMax!=undefined&&options.chartRangeMax>maxy){maxy=options.chartRangeMax;} | ||
var rangex=maxx-minx==0?1:maxx-minx;var rangey=maxy-miny==0?1:maxy-miny;var vl=yvalues.length-1;if(vl<1){this.innerHTML='';return;} | ||
var target=$(this).simpledraw(width,height,options.composite);if(target){var canvas_width=target.pixel_width;var canvas_height=target.pixel_height;var canvas_top=0;var canvas_left=0;if(options.spotRadius&&(canvas_width<(options.spotRadius*4)||canvas_height<(options.spotRadius*4))){options.spotRadius=0;} | ||
if(options.spotRadius){if(options.minSpotColor||(options.spotColor&&yvalues[vl]==miny)) | ||
canvas_height-=Math.ceil(options.spotRadius);if(options.maxSpotColor||(options.spotColor&&yvalues[vl]==maxy)){canvas_height-=Math.ceil(options.spotRadius);canvas_top+=Math.ceil(options.spotRadius);} | ||
if(options.minSpotColor||options.maxSpotColor&&(yvalues[0]==miny||yvalues[0]==maxy)){canvas_left+=Math.ceil(options.spotRadius);canvas_width-=Math.ceil(options.spotRadius);} | ||
if(options.spotColor||(options.minSpotColor||options.maxSpotColor&&(yvalues[vl]==miny||yvalues[vl]==maxy))) | ||
canvas_width-=Math.ceil(options.spotRadius);} | ||
canvas_height--;if(options.normalRangeMin!=undefined){var ytop=canvas_top+Math.round(canvas_height-(canvas_height*((options.normalRangeMax-miny)/rangey)));var height=Math.round((canvas_height*(options.normalRangeMax-options.normalRangeMin))/rangey);target.drawRect(canvas_left,ytop,canvas_width,height,undefined,options.normalRangeColor);} | ||
var path=[];var paths=[path];for(var i=0;i<yvalues.length;i++){var x=xvalues[i],y=yvalues[i];if(y===null){if(i){if(yvalues[i-1]!==null){path=[];paths.push(path);}}}else{if(!path.length){path.push([canvas_left+Math.round((x-minx)*(canvas_width/rangex)),canvas_top+canvas_height]);} | ||
(function($){var defaults={common:{type:'line',lineColor:'#00f',fillColor:'#cdf',defaultPixelsPerValue:3,width:'auto',height:'auto',composite:false,tagValuesAttribute:'values',tagOptionsPrefix:'spark',enableTagOptions:false},line:{spotColor:'#f80',spotRadius:1.5,minSpotColor:'#f80',maxSpotColor:'#f80',lineWidth:1,normalRangeMin:undefined,normalRangeMax:undefined,normalRangeColor:'#ccc',drawNormalOnTop:false,chartRangeMin:undefined,chartRangeMax:undefined,chartRangeMinX:undefined,chartRangeMaxX:undefined},bar:{barColor:'#00f',negBarColor:'#f44',zeroColor:undefined,nullColor:undefined,zeroAxis:undefined,barWidth:4,barSpacing:1,chartRangeMax:undefined,chartRangeMin:undefined,chartRangeClip:false,colorMap:undefined},tristate:{barWidth:4,barSpacing:1,posBarColor:'#6f6',negBarColor:'#f44',zeroBarColor:'#999',colorMap:{}},discrete:{lineHeight:'auto',thresholdColor:undefined,thresholdValue:0,chartRangeMax:undefined,chartRangeMin:undefined,chartRangeClip:false},bullet:{targetColor:'red',targetWidth:3,performanceColor:'blue',rangeColors:['#D3DAFE','#A8B6FF','#7F94FF'],base:undefined},pie:{sliceColors:['#f00','#0f0','#00f']},box:{raw:false,boxLineColor:'black',boxFillColor:'#cdf',whiskerColor:'black',outlierLineColor:'#333',outlierFillColor:'white',medianColor:'red',showOutliers:true,outlierIQR:1.5,spotRadius:1.5,target:undefined,targetColor:'#4a2',chartRangeMax:undefined,chartRangeMin:undefined}};var VCanvas_base,VCanvas_canvas,VCanvas_vml;$.fn.simpledraw=function(width,height,use_existing){if(use_existing&&this[0].VCanvas){return this[0].VCanvas;} | ||
if(width===undefined){width=$(this).innerWidth();} | ||
if(height===undefined){height=$(this).innerHeight();} | ||
if($.browser.hasCanvas){return new VCanvas_canvas(width,height,this);}else if($.browser.msie){return new VCanvas_vml(width,height,this);}else{return false;}};var pending=[];$.fn.sparkline=function(uservalues,userOptions){return this.each(function(){var options=new $.fn.sparkline.options(this,userOptions);var render=function(){var values,width,height;if(uservalues==='html'||uservalues===undefined){var vals=this.getAttribute(options.get('tagValuesAttribute'));if(vals===undefined||vals===null){vals=$(this).html();} | ||
values=vals.replace(/(^\s*<!--)|(-->\s*$)|\s+/g,'').split(',');}else{values=uservalues;} | ||
width=options.get('width')=='auto'?values.length*options.get('defaultPixelsPerValue'):options.get('width');if(options.get('height')=='auto'){if(!options.get('composite')||!this.VCanvas){var tmp=document.createElement('span');tmp.innerHTML='a';$(this).html(tmp);height=$(tmp).innerHeight();$(tmp).remove();}}else{height=options.get('height');} | ||
$.fn.sparkline[options.get('type')].call(this,values,options,width,height);};if(($(this).html()&&$(this).is(':hidden'))||($.fn.jquery<"1.3.0"&&$(this).parents().is(':hidden'))||!$(this).parents('body').length){pending.push([this,render]);}else{render.call(this);}});};$.fn.sparkline.defaults=defaults;$.sparkline_display_visible=function(){for(var i=pending.length-1;i>=0;i--){var el=pending[i][0];if($(el).is(':visible')&&!$(el).parents().is(':hidden')){pending[i][1].call(el);pending.splice(i,1);}}};var UNSET_OPTION={};var normalizeValue=function(val){switch(val){case'undefined':val=undefined;break;case'null':val=null;break;case'true':val=true;break;case'false':val=false;break;default:var nf=parseFloat(val);if(val==nf){val=nf;}} | ||
return val;};$.fn.sparkline.options=function(tag,userOptions){var extendedOptions;this.userOptions=userOptions=userOptions||{};this.tag=tag;this.tagValCache={};var defaults=$.fn.sparkline.defaults;var base=defaults.common;this.tagOptionsPrefix=userOptions.enableTagOptions&&(userOptions.tagOptionsPrefix||base.tagOptionsPrefix);var tagOptionType=this.getTagSetting('type');if(tagOptionType===UNSET_OPTION){extendedOptions=defaults[userOptions.type||base.type];}else{extendedOptions=defaults[tagOptionType];} | ||
this.mergedOptions=$.extend({},base,extendedOptions,userOptions);};$.fn.sparkline.options.prototype.getTagSetting=function(key){var val,i,prefix=this.tagOptionsPrefix;if(prefix===false||prefix===undefined){return UNSET_OPTION;} | ||
if(this.tagValCache.hasOwnProperty(key)){val=this.tagValCache.key;}else{val=this.tag.getAttribute(prefix+key);if(val===undefined||val===null){val=UNSET_OPTION;}else if(val.substr(0,1)=='['){val=val.substr(1,val.length-2).split(',');for(i=val.length;i--;){val[i]=normalizeValue(val[i].replace(/(^\s*)|(\s*$)/g,''));}}else if(val.substr(0,1)=='{'){var pairs=val.substr(1,val.length-2).split(',');val={};for(i=pairs.length;i--;){var keyval=pairs[i].split(':',2);val[keyval[0].replace(/(^\s*)|(\s*$)/g,'')]=normalizeValue(keyval[1].replace(/(^\s*)|(\s*$)/g,''));}}else{val=normalizeValue(val);} | ||
this.tagValCache.key=val;} | ||
return val;};$.fn.sparkline.options.prototype.get=function(key){var tagOption=this.getTagSetting(key);if(tagOption!==UNSET_OPTION){return tagOption;} | ||
return this.mergedOptions[key];};$.fn.sparkline.line=function(values,options,width,height){var xvalues=[],yvalues=[],yminmax=[];for(var i=0;i<values.length;i++){var val=values[i];var isstr=typeof(values[i])=='string';var isarray=typeof(values[i])=='object'&&values[i]instanceof Array;var sp=isstr&&values[i].split(':');if(isstr&&sp.length==2){xvalues.push(Number(sp[0]));yvalues.push(Number(sp[1]));yminmax.push(Number(sp[1]));}else if(isarray){xvalues.push(val[0]);yvalues.push(val[1]);yminmax.push(val[1]);}else{xvalues.push(i);if(values[i]===null||values[i]=='null'){yvalues.push(null);}else{yvalues.push(Number(val));yminmax.push(Number(val));}}} | ||
if(options.get('xvalues')){xvalues=options.get('xvalues');} | ||
var maxy=Math.max.apply(Math,yminmax);var maxyval=maxy;var miny=Math.min.apply(Math,yminmax);var minyval=miny;var maxx=Math.max.apply(Math,xvalues);var minx=Math.min.apply(Math,xvalues);var normalRangeMin=options.get('normalRangeMin');var normalRangeMax=options.get('normalRangeMax');if(normalRangeMin!==undefined){if(normalRangeMin<miny){miny=normalRangeMin;} | ||
if(normalRangeMax>maxy){maxy=normalRangeMax;}} | ||
if(options.get('chartRangeMin')!==undefined&&(options.get('chartRangeClip')||options.get('chartRangeMin')<miny)){miny=options.get('chartRangeMin');} | ||
if(options.get('chartRangeMax')!==undefined&&(options.get('chartRangeClip')||options.get('chartRangeMax')>maxy)){maxy=options.get('chartRangeMax');} | ||
if(options.get('chartRangeMinX')!==undefined&&(options.get('chartRangeClipX')||options.get('chartRangeMinX')<minx)){minx=options.get('chartRangeMinX');} | ||
if(options.get('chartRangeMaxX')!==undefined&&(options.get('chartRangeClipX')||options.get('chartRangeMaxX')>maxx)){maxx=options.get('chartRangeMaxX');} | ||
var rangex=maxx-minx===0?1:maxx-minx;var rangey=maxy-miny===0?1:maxy-miny;var vl=yvalues.length-1;if(vl<1){this.innerHTML='';return;} | ||
var target=$(this).simpledraw(width,height,options.get('composite'));if(target){var canvas_width=target.pixel_width;var canvas_height=target.pixel_height;var canvas_top=0;var canvas_left=0;var spotRadius=options.get('spotRadius');if(spotRadius&&(canvas_width<(spotRadius*4)||canvas_height<(spotRadius*4))){spotRadius=0;} | ||
if(spotRadius){if(options.get('minSpotColor')||(options.get('spotColor')&&yvalues[vl]==miny)){canvas_height-=Math.ceil(spotRadius);} | ||
if(options.get('maxSpotColor')||(options.get('spotColor')&&yvalues[vl]==maxy)){canvas_height-=Math.ceil(spotRadius);canvas_top+=Math.ceil(spotRadius);} | ||
if(options.get('minSpotColor')||options.get('maxSpotColor')&&(yvalues[0]==miny||yvalues[0]==maxy)){canvas_left+=Math.ceil(spotRadius);canvas_width-=Math.ceil(spotRadius);} | ||
if(options.get('spotColor')||(options.get('minSpotColor')||options.get('maxSpotColor')&&(yvalues[vl]==miny||yvalues[vl]==maxy))){canvas_width-=Math.ceil(spotRadius);}} | ||
canvas_height--;var drawNormalRange=function(){if(normalRangeMin!==undefined){var ytop=canvas_top+Math.round(canvas_height-(canvas_height*((normalRangeMax-miny)/rangey)));var height=Math.round((canvas_height*(normalRangeMax-normalRangeMin))/rangey);target.drawRect(canvas_left,ytop,canvas_width,height,undefined,options.get('normalRangeColor'));}};if(!options.get('drawNormalOnTop')){drawNormalRange();} | ||
var path=[];var paths=[path];var x,y,vlen=yvalues.length;for(i=0;i<vlen;i++){x=xvalues[i];y=yvalues[i];if(y===null){if(i){if(yvalues[i-1]!==null){path=[];paths.push(path);}}}else{if(y<miny){y=miny;} | ||
if(y>maxy){y=maxy;} | ||
if(!path.length){path.push([canvas_left+Math.round((x-minx)*(canvas_width/rangex)),canvas_top+canvas_height]);} | ||
path.push([canvas_left+Math.round((x-minx)*(canvas_width/rangex)),canvas_top+Math.round(canvas_height-(canvas_height*((y-miny)/rangey)))]);}} | ||
for(var i=0;i<paths.length;i++){path=paths[i];if(!path.length) | ||
continue;if(options.fillColor){path.push([path[path.length-1][0],canvas_top+canvas_height-1]);target.drawShape(path,undefined,options.fillColor);path.pop();} | ||
var lineshapes=[];var fillshapes=[];var plen=paths.length;for(i=0;i<plen;i++){path=paths[i];if(!path.length){continue;} | ||
if(options.get('fillColor')){path.push([path[path.length-1][0],canvas_top+canvas_height-1]);fillshapes.push(path.slice(0));path.pop();} | ||
if(path.length>2){path[0]=[path[0][0],path[1][1]];} | ||
target.drawShape(path,options.lineColor,undefined,options.lineWidth);} | ||
if(options.spotRadius&&options.spotColor){target.drawCircle(canvas_left+canvas_width,canvas_top+Math.round(canvas_height-(canvas_height*((yvalues[vl]-miny)/rangey))),options.spotRadius,undefined,options.spotColor);} | ||
if(maxy!=minyval){if(options.spotRadius&&options.minSpotColor){var x=xvalues[yvalues.indexOf(minyval)];target.drawCircle(canvas_left+Math.round((x-minx)*(canvas_width/rangex)),canvas_top+Math.round(canvas_height-(canvas_height*((minyval-miny)/rangey))),options.spotRadius,undefined,options.minSpotColor);} | ||
if(options.spotRadius&&options.maxSpotColor){var x=xvalues[yvalues.indexOf(maxyval)];target.drawCircle(canvas_left+Math.round((x-minx)*(canvas_width/rangex)),canvas_top+Math.round(canvas_height-(canvas_height*((maxyval-miny)/rangey))),options.spotRadius,undefined,options.maxSpotColor);}}}else{this.innerHTML='';}};$.fn.sparkline.bar=function(values,options,width,height){var options=$.extend({type:'bar',barColor:'#00f',negBarColor:'#f44',zeroColor:undefined,zeroAxis:undefined,barWidth:4,barSpacing:1,chartRangeMax:undefined,chartRangeMin:undefined,colorMap:{}},options?options:{});var width=(values.length*options.barWidth)+((values.length-1)*options.barSpacing);var num_values=[];for(var i=0;i<values.length;i++){if(values[i]=='null'||values[i]===null){values[i]=null;}else{values[i]=Number(values[i]);num_values.push(Number(values[i]));}} | ||
var max=Math.max.apply(Math,num_values);var min=Math.min.apply(Math,num_values);if(options.chartRangeMin!=undefined&&options.chartRangeMin<min){min=options.chartRangeMin;} | ||
if(options.chartRangeMax!=undefined&&options.chartRangeMax>max){max=options.chartRangeMax;} | ||
if(options.zeroAxis==undefined)options.zeroAxis=min<0;var range=max-min==0?1:max-min;var target=$(this).simpledraw(width,height);if(target){var canvas_width=target.pixel_width;var canvas_height=target.pixel_height;var yzero=min<0&&options.zeroAxis?canvas_height-Math.round(canvas_height*(Math.abs(min)/range))-1:canvas_height-1;for(var i=0;i<values.length;i++){var x=i*(options.barWidth+options.barSpacing);var val=values[i];if(val===null){continue;} | ||
var color=(val<0)?options.negBarColor:options.barColor;if(options.zeroAxis&&min<0){var height=Math.round(canvas_height*((Math.abs(val)/range)))+1;var y=(val<0)?yzero:yzero-height;}else{var height=Math.round(canvas_height*((val-min)/range))+1;var y=canvas_height-height;} | ||
if(val==0&&options.zeroColor!=undefined){color=options.zeroColor;} | ||
if(options.colorMap[val]){color=options.colorMap[val];} | ||
target.drawRect(x,y,options.barWidth-1,height-1,color,color);}}else{this.innerHTML='';}};$.fn.sparkline.tristate=function(values,options,width,height){values=$.map(values,Number);var options=$.extend({barWidth:4,barSpacing:1,posBarColor:'#6f6',negBarColor:'#f44',zeroBarColor:'#999',colorMap:{}},options);var width=(values.length*options.barWidth)+((values.length-1)*options.barSpacing);var target=$(this).simpledraw(width,height);if(target){var canvas_width=target.pixel_width;var canvas_height=target.pixel_height;var half_height=Math.round(canvas_height/2);for(var i=0;i<values.length;i++){var x=i*(options.barWidth+options.barSpacing);if(values[i]<0){var y=half_height;var height=half_height-1;var color=options.negBarColor;}else if(values[i]>0){var y=0;var height=half_height-1;var color=options.posBarColor;}else{var y=half_height-1;var height=2;var color=options.zeroBarColor;} | ||
if(options.colorMap[values[i]]){color=options.colorMap[values[i]];} | ||
target.drawRect(x,y,options.barWidth-1,height-1,color,color);}}else{this.innerHTML='';}};$.fn.sparkline.discrete=function(values,options,width,height){values=$.map(values,Number);var options=$.extend({lineHeight:'auto',thresholdColor:undefined,thresholdValue:0,chartRangeMax:undefined,chartRangeMin:undefined},options);width=options.width=='auto'?values.length*2:width;var interval=Math.floor(width/values.length);var target=$(this).simpledraw(width,height);if(target){var canvas_width=target.pixel_width;var canvas_height=target.pixel_height;var line_height=options.lineHeight=='auto'?Math.round(canvas_height*0.3):options.lineHeight;var pheight=canvas_height-line_height;var min=Math.min.apply(Math,values);var max=Math.max.apply(Math,values);if(options.chartRangeMin!=undefined&&options.chartRangeMin<min){min=options.chartRangeMin;} | ||
if(options.chartRangeMax!=undefined&&options.chartRangeMax>max){max=options.chartRangeMax;} | ||
var range=max-min;for(var i=0;i<values.length;i++){var val=values[i];var x=(i*interval);var ytop=Math.round(pheight-pheight*((val-min)/range));target.drawLine(x,ytop,x,ytop+line_height,(options.thresholdColor&&val<options.thresholdValue)?options.thresholdColor:options.lineColor);}}else{this.innerHTML='';}};$.fn.sparkline.bullet=function(values,options,width,height){values=$.map(values,Number);var options=$.extend({targetColor:'red',targetWidth:3,performanceColor:'blue',rangeColors:['#D3DAFE','#A8B6FF','#7F94FF'],base:undefined},options);width=options.width=='auto'?'4.0em':width;var target=$(this).simpledraw(width,height);if(target&&values.length>1){var canvas_width=target.pixel_width-Math.ceil(options.targetWidth/2);var canvas_height=target.pixel_height;var min=Math.min.apply(Math,values);var max=Math.max.apply(Math,values);if(options.base==undefined){var min=min<0?min:0;}else{min=options.base;} | ||
var range=max-min;for(i=2;i<values.length;i++){var rangeval=parseInt(values[i]);var rangewidth=Math.round(canvas_width*((rangeval-min)/range));target.drawRect(0,0,rangewidth-1,canvas_height-1,options.rangeColors[i-2],options.rangeColors[i-2]);} | ||
var perfval=parseInt(values[1]);var perfwidth=Math.round(canvas_width*((perfval-min)/range));target.drawRect(0,Math.round(canvas_height*0.3),perfwidth-1,Math.round(canvas_height*0.4)-1,options.performanceColor,options.performanceColor);var targetval=parseInt(values[0]);var x=Math.round(canvas_width*((targetval-min)/range)-(options.targetWidth/2));var targettop=Math.round(canvas_height*0.10);var targetheight=canvas_height-(targettop*2);target.drawRect(x,targettop,options.targetWidth-1,targetheight-1,options.targetColor,options.targetColor);}else{this.innerHTML='';}};$.fn.sparkline.pie=function(values,options,width,height){values=$.map(values,Number);var options=$.extend({sliceColors:['#f00','#0f0','#00f']},options);width=options.width=='auto'?height:width;var target=$(this).simpledraw(width,height);if(target&&values.length>1){var canvas_width=target.pixel_width;var canvas_height=target.pixel_height;var radius=Math.floor(Math.min(canvas_width,canvas_height)/2);var total=0;for(var i=0;i<values.length;i++) | ||
total+=values[i];var next=0;if(options.offset){next+=(2*Math.PI)*(options.offset/360);} | ||
var circle=2*Math.PI;for(var i=0;i<values.length;i++){var start=next;var end=next;if(total>0){end=next+(circle*(values[i]/total));} | ||
target.drawPieSlice(radius,radius,radius,start,end,undefined,options.sliceColors[i%options.sliceColors.length]);next=end;}}};function quartile(values,q){if(q==2){var vl2=Math.floor(values.length/2);return values.length%2?values[vl2]:(values[vl2]+values[vl2+1])/2;}else{var vl4=Math.floor(values.length/4);return values.length%2?(values[vl4*q]+values[vl4*q+1])/2:values[vl4*q];}};$.fn.sparkline.box=function(values,options,width,height){values=$.map(values,Number);var options=$.extend({raw:false,boxLineColor:'black',boxFillColor:'#cdf',whiskerColor:'black',outlierLineColor:'#333',outlierFillColor:'white',medianColor:'red',showOutliers:true,outlierIQR:1.5,spotRadius:1.5,target:undefined,targetColor:'#4a2',chartRangeMax:undefined,chartRangeMin:undefined},options);width=options.width=='auto'?'4.0em':width;minvalue=options.chartRangeMin==undefined?Math.min.apply(Math,values):options.chartRangeMin;maxvalue=options.chartRangeMax==undefined?Math.max.apply(Math,values):options.chartRangeMax;var target=$(this).simpledraw(width,height);if(target&&values.length>1){var canvas_width=target.pixel_width;var canvas_height=target.pixel_height;if(options.raw){if(options.showOutliers&&values.length>5){var loutlier=values[0],lwhisker=values[1],q1=values[2],q2=values[3],q3=values[4],rwhisker=values[5],routlier=values[6];}else{var lwhisker=values[0],q1=values[1],q2=values[2],q3=values[3],rwhisker=values[4];}}else{values.sort(function(a,b){return a-b;});var q1=quartile(values,1);var q2=quartile(values,2);var q3=quartile(values,3);var iqr=q3-q1;if(options.showOutliers){var lwhisker=undefined,rwhisker=undefined;for(var i=0;i<values.length;i++){if(lwhisker==undefined&&values[i]>q1-(iqr*options.outlierIQR)) | ||
lwhisker=values[i];if(values[i]<q3+(iqr*options.outlierIQR)) | ||
rwhisker=values[i];} | ||
var loutlier=values[0];var routlier=values[values.length-1];}else{var lwhisker=values[0];var rwhisker=values[values.length-1];}} | ||
var unitsize=canvas_width/(maxvalue-minvalue+1);var canvas_left=0;if(options.showOutliers){canvas_left=Math.ceil(options.spotRadius);canvas_width-=2*Math.ceil(options.spotRadius);var unitsize=canvas_width/(maxvalue-minvalue+1);if(loutlier<lwhisker) | ||
target.drawCircle((loutlier-minvalue)*unitsize+canvas_left,canvas_height/2,options.spotRadius,options.outlierLineColor,options.outlierFillColor);if(routlier>rwhisker) | ||
target.drawCircle((routlier-minvalue)*unitsize+canvas_left,canvas_height/2,options.spotRadius,options.outlierLineColor,options.outlierFillColor);} | ||
target.drawRect(Math.round((q1-minvalue)*unitsize+canvas_left),Math.round(canvas_height*0.1),Math.round((q3-q1)*unitsize),Math.round(canvas_height*0.8),options.boxLineColor,options.boxFillColor);target.drawLine(Math.round((lwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height/2),Math.round((q1-minvalue)*unitsize+canvas_left),Math.round(canvas_height/2),options.lineColor);target.drawLine(Math.round((lwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height/4),Math.round((lwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height-canvas_height/4),options.whiskerColor);target.drawLine(Math.round((rwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height/2),Math.round((q3-minvalue)*unitsize+canvas_left),Math.round(canvas_height/2),options.lineColor);target.drawLine(Math.round((rwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height/4),Math.round((rwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height-canvas_height/4),options.whiskerColor);target.drawLine(Math.round((q2-minvalue)*unitsize+canvas_left),Math.round(canvas_height*0.1),Math.round((q2-minvalue)*unitsize+canvas_left),Math.round(canvas_height*0.9),options.medianColor);if(options.target){var size=Math.ceil(options.spotRadius);target.drawLine(Math.round((options.target-minvalue)*unitsize+canvas_left),Math.round((canvas_height/2)-size),Math.round((options.target-minvalue)*unitsize+canvas_left),Math.round((canvas_height/2)+size),options.targetColor);target.drawLine(Math.round((options.target-minvalue)*unitsize+canvas_left-size),Math.round(canvas_height/2),Math.round((options.target-minvalue)*unitsize+canvas_left+size),Math.round(canvas_height/2),options.targetColor);}}else{this.innerHTML='';}};if(!Array.prototype.indexOf){Array.prototype.indexOf=function(entry){for(var i=0;i<this.length;i++){if(this[i]==entry) | ||
return i;} | ||
return-1;}} | ||
if($.browser.msie&&!document.namespaces['v']){document.namespaces.add('v','urn:schemas-microsoft-com:vml','#default#VML');} | ||
if($.browser.hasCanvas==undefined){var t=document.createElement('canvas');$.browser.hasCanvas=t.getContext!=undefined;} | ||
var vcanvas_base=function(width,height,target){};vcanvas_base.prototype={init:function(width,height,target){this.width=width;this.height=height;this.target=target;if(target[0])target=target[0];target.vcanvas=this;},drawShape:function(path,lineColor,fillColor,lineWidth){alert('drawShape not implemented');},drawLine:function(x1,y1,x2,y2,lineColor,lineWidth){return this.drawShape([[x1,y1],[x2,y2]],lineColor,lineWidth);},drawCircle:function(x,y,radius,lineColor,fillColor){alert('drawCircle not implemented');},drawPieSlice:function(x,y,radius,startAngle,endAngle,lineColor,fillColor){alert('drawPieSlice not implemented');},drawRect:function(x,y,width,height,lineColor,fillColor){alert('drawRect not implemented');},getElement:function(){return this.canvas;},_insert:function(el,target){$(target).html(el);}};var vcanvas_canvas=function(width,height,target){return this.init(width,height,target);};vcanvas_canvas.prototype=$.extend(new vcanvas_base,{_super:vcanvas_base.prototype,init:function(width,height,target){this._super.init(width,height,target);this.canvas=document.createElement('canvas');if(target[0])target=target[0];target.vcanvas=this;$(this.canvas).css({display:'inline-block',width:width,height:height,verticalAlign:'top'});this._insert(this.canvas,target);this.pixel_height=$(this.canvas).height();this.pixel_width=$(this.canvas).width();this.canvas.width=this.pixel_width;this.canvas.height=this.pixel_height;$(this.canvas).css({width:this.pixel_width,height:this.pixel_height});},_getContext:function(lineColor,fillColor,lineWidth){var context=this.canvas.getContext('2d');if(lineColor!=undefined) | ||
context.strokeStyle=lineColor;context.lineWidth=lineWidth==undefined?1:lineWidth;if(fillColor!=undefined) | ||
context.fillStyle=fillColor;return context;},drawShape:function(path,lineColor,fillColor,lineWidth){var context=this._getContext(lineColor,fillColor,lineWidth);context.beginPath();context.moveTo(path[0][0]+0.5,path[0][1]+0.5);for(var i=1;i<path.length;i++){context.lineTo(path[i][0]+0.5,path[i][1]+0.5);} | ||
if(lineColor!=undefined){context.stroke();} | ||
if(fillColor!=undefined){context.fill();}},drawCircle:function(x,y,radius,lineColor,fillColor){var context=this._getContext(lineColor,fillColor);context.beginPath();context.arc(x,y,radius,0,2*Math.PI,false);if(lineColor!=undefined){context.stroke();} | ||
if(fillColor!=undefined){context.fill();}},drawPieSlice:function(x,y,radius,startAngle,endAngle,lineColor,fillColor){var context=this._getContext(lineColor,fillColor);context.beginPath();context.moveTo(x,y);context.arc(x,y,radius,startAngle,endAngle,false);context.lineTo(x,y);context.closePath();if(lineColor!=undefined){context.stroke();} | ||
if(fillColor){context.fill();}},drawRect:function(x,y,width,height,lineColor,fillColor){return this.drawShape([[x,y],[x+width,y],[x+width,y+height],[x,y+height],[x,y]],lineColor,fillColor);}});var vcanvas_vml=function(width,height,target){return this.init(width,height,target);};vcanvas_vml.prototype=$.extend(new vcanvas_base,{_super:vcanvas_base.prototype,init:function(width,height,target){this._super.init(width,height,target);if(target[0])target=target[0];target.vcanvas=this;this.canvas=document.createElement('span');$(this.canvas).css({display:'inline-block',position:'relative',overflow:'hidden',width:width,height:height,margin:'0px',padding:'0px',verticalAlign:'top'});this._insert(this.canvas,target);this.pixel_height=$(this.canvas).height();this.pixel_width=$(this.canvas).width();this.canvas.width=this.pixel_width;this.canvas.height=this.pixel_height;;var groupel='<v:group coordorigin="0 0" coordsize="'+this.pixel_width+' '+this.pixel_height+'"' | ||
+' style="position:absolute;top:0;left:0;width:'+this.pixel_width+'px;height='+this.pixel_height+'px;"></v:group>';this.canvas.insertAdjacentHTML('beforeEnd',groupel);this.group=$(this.canvas).children()[0];},drawShape:function(path,lineColor,fillColor,lineWidth){var vpath=[];for(var i=0;i<path.length;i++){vpath[i]=''+(path[i][0])+','+(path[i][1]);} | ||
var initial=vpath.splice(0,1);lineWidth=lineWidth==undefined?1:lineWidth;var stroke=lineColor==undefined?' stroked="false" ':' strokeWeight="'+lineWidth+'" strokeColor="'+lineColor+'" ';var fill=fillColor==undefined?' filled="false"':' fillColor="'+fillColor+'" filled="true" ';var closed=vpath[0]==vpath[vpath.length-1]?'x ':'';var vel='<v:shape coordorigin="0 0" coordsize="'+this.pixel_width+' '+this.pixel_height+'" ' | ||
+stroke | ||
+fill | ||
+' style="position:absolute;left:0px;top:0px;height:'+this.pixel_height+'px;width:'+this.pixel_width+'px;padding:0px;margin:0px;" ' | ||
+' path="m '+initial+' l '+vpath.join(', ')+' '+closed+'e">' | ||
+' </v:shape>';this.group.insertAdjacentHTML('beforeEnd',vel);},drawCircle:function(x,y,radius,lineColor,fillColor){x-=radius+1;y-=radius+1;var stroke=lineColor==undefined?' stroked="false" ':' strokeWeight="1" strokeColor="'+lineColor+'" ';var fill=fillColor==undefined?' filled="false"':' fillColor="'+fillColor+'" filled="true" ';var vel='<v:oval ' | ||
+stroke | ||
+fill | ||
+' style="position:absolute;top:'+y+'px; left:'+x+'px; width:'+(radius*2)+'px; height:'+(radius*2)+'px"></v:oval>';this.group.insertAdjacentHTML('beforeEnd',vel);},drawPieSlice:function(x,y,radius,startAngle,endAngle,lineColor,fillColor){if(startAngle==endAngle){return;} | ||
lineshapes.push(path);} | ||
plen=fillshapes.length;for(i=0;i<plen;i++){target.drawShape(fillshapes[i],undefined,options.get('fillColor'));} | ||
if(options.get('drawNormalOnTop')){drawNormalRange();} | ||
plen=lineshapes.length;for(i=0;i<plen;i++){target.drawShape(lineshapes[i],options.get('lineColor'),undefined,options.get('lineWidth'));} | ||
if(spotRadius&&options.get('spotColor')){target.drawCircle(canvas_left+Math.round(xvalues[xvalues.length-1]*(canvas_width/rangex)),canvas_top+Math.round(canvas_height-(canvas_height*((yvalues[vl]-miny)/rangey))),spotRadius,undefined,options.get('spotColor'));} | ||
if(maxy!=minyval){if(spotRadius&&options.get('minSpotColor')){x=xvalues[$.inArray(minyval,yvalues)];target.drawCircle(canvas_left+Math.round((x-minx)*(canvas_width/rangex)),canvas_top+Math.round(canvas_height-(canvas_height*((minyval-miny)/rangey))),spotRadius,undefined,options.get('minSpotColor'));} | ||
if(spotRadius&&options.get('maxSpotColor')){x=xvalues[$.inArray(maxyval,yvalues)];target.drawCircle(canvas_left+Math.round((x-minx)*(canvas_width/rangex)),canvas_top+Math.round(canvas_height-(canvas_height*((maxyval-miny)/rangey))),spotRadius,undefined,options.get('maxSpotColor'));}}}else{this.innerHTML='';}};$.fn.sparkline.bar=function(values,options,width,height){width=(values.length*options.get('barWidth'))+((values.length-1)*options.get('barSpacing'));var num_values=[];for(var i=0,vlen=values.length;i<vlen;i++){if(values[i]=='null'||values[i]===null){values[i]=null;}else{values[i]=Number(values[i]);num_values.push(Number(values[i]));}} | ||
var max=Math.max.apply(Math,num_values),min=Math.min.apply(Math,num_values);if(options.get('chartRangeMin')!==undefined&&(options.get('chartRangeClip')||options.get('chartRangeMin')<min)){min=options.get('chartRangeMin');} | ||
if(options.get('chartRangeMax')!==undefined&&(options.get('chartRangeClip')||options.get('chartRangeMax')>max)){max=options.get('chartRangeMax');} | ||
var zeroAxis=options.get('zeroAxis');if(zeroAxis===undefined){zeroAxis=min<0;} | ||
var range=max-min===0?1:max-min;var colorMapByIndex,colorMapByValue;if($.isArray(options.get('colorMap'))){colorMapByIndex=options.get('colorMap');colorMapByValue=null;}else{colorMapByIndex=null;colorMapByValue=options.get('colorMap');} | ||
var target=$(this).simpledraw(width,height,options.get('composite'));if(target){var color,canvas_height=target.pixel_height,yzero=min<0&&zeroAxis?canvas_height-Math.round(canvas_height*(Math.abs(min)/range))-1:canvas_height-1;for(i=values.length;i--;){var x=i*(options.get('barWidth')+options.get('barSpacing')),y,val=values[i];if(val===null){if(options.get('nullColor')){color=options.get('nullColor');val=(zeroAxis&&min<0)?0:min;height=1;y=(zeroAxis&&min<0)?yzero:canvas_height-height;}else{continue;}}else{if(val<min){val=min;} | ||
if(val>max){val=max;} | ||
color=(val<0)?options.get('negBarColor'):options.get('barColor');if(zeroAxis&&min<0){height=Math.round(canvas_height*((Math.abs(val)/range)))+1;y=(val<0)?yzero:yzero-height;}else{height=Math.round(canvas_height*((val-min)/range))+1;y=canvas_height-height;} | ||
if(val===0&&options.get('zeroColor')!==undefined){color=options.get('zeroColor');} | ||
if(colorMapByValue&&colorMapByValue[val]){color=colorMapByValue[val];}else if(colorMapByIndex&&colorMapByIndex.length>i){color=colorMapByIndex[i];} | ||
if(color===null){continue;}} | ||
target.drawRect(x,y,options.get('barWidth')-1,height-1,color,color);}}else{this.innerHTML='';}};$.fn.sparkline.tristate=function(values,options,width,height){values=$.map(values,Number);width=(values.length*options.get('barWidth'))+((values.length-1)*options.get('barSpacing'));var colorMapByIndex,colorMapByValue;if($.isArray(options.get('colorMap'))){colorMapByIndex=options.get('colorMap');colorMapByValue=null;}else{colorMapByIndex=null;colorMapByValue=options.get('colorMap');} | ||
var target=$(this).simpledraw(width,height,options.get('composite'));if(target){var canvas_height=target.pixel_height,half_height=Math.round(canvas_height/2);for(var i=values.length;i--;){var x=i*(options.get('barWidth')+options.get('barSpacing')),y,color;if(values[i]<0){y=half_height;height=half_height-1;color=options.get('negBarColor');}else if(values[i]>0){y=0;height=half_height-1;color=options.get('posBarColor');}else{y=half_height-1;height=2;color=options.get('zeroBarColor');} | ||
if(colorMapByValue&&colorMapByValue[values[i]]){color=colorMapByValue[values[i]];}else if(colorMapByIndex&&colorMapByIndex.length>i){color=colorMapByIndex[i];} | ||
if(color===null){continue;} | ||
target.drawRect(x,y,options.get('barWidth')-1,height-1,color,color);}}else{this.innerHTML='';}};$.fn.sparkline.discrete=function(values,options,width,height){values=$.map(values,Number);width=options.get('width')=='auto'?values.length*2:width;var interval=Math.floor(width/values.length);var target=$(this).simpledraw(width,height,options.get('composite'));if(target){var canvas_height=target.pixel_height,line_height=options.get('lineHeight')=='auto'?Math.round(canvas_height*0.3):options.get('lineHeight'),pheight=canvas_height-line_height,min=Math.min.apply(Math,values),max=Math.max.apply(Math,values);if(options.get('chartRangeMin')!==undefined&&(options.get('chartRangeClip')||options.get('chartRangeMin')<min)){min=options.get('chartRangeMin');} | ||
if(options.get('chartRangeMax')!==undefined&&(options.get('chartRangeClip')||options.get('chartRangeMax')>max)){max=options.get('chartRangeMax');} | ||
var range=max-min;for(var i=values.length;i--;){var val=values[i];if(val<min){val=min;} | ||
if(val>max){val=max;} | ||
var x=(i*interval),ytop=Math.round(pheight-pheight*((val-min)/range));target.drawLine(x,ytop,x,ytop+line_height,(options.get('thresholdColor')&&val<options.get('thresholdValue'))?options.get('thresholdColor'):options.get('lineColor'));}}else{this.innerHTML='';}};$.fn.sparkline.bullet=function(values,options,width,height){values=$.map(values,Number);width=options.get('width')=='auto'?'4.0em':width;var target=$(this).simpledraw(width,height,options.get('composite'));if(target&&values.length>1){var canvas_width=target.pixel_width-Math.ceil(options.get('targetWidth')/2),canvas_height=target.pixel_height,min=Math.min.apply(Math,values),max=Math.max.apply(Math,values);if(options.get('base')===undefined){min=min<0?min:0;}else{min=options.get('base');} | ||
var range=max-min;for(var i=2,vlen=values.length;i<vlen;i++){var rangeval=values[i],rangewidth=Math.round(canvas_width*((rangeval-min)/range));target.drawRect(0,0,rangewidth-1,canvas_height-1,options.get('rangeColors')[i-2],options.get('rangeColors')[i-2]);} | ||
var perfval=values[1],perfwidth=Math.round(canvas_width*((perfval-min)/range));target.drawRect(0,Math.round(canvas_height*0.3),perfwidth-1,Math.round(canvas_height*0.4)-1,options.get('performanceColor'),options.get('performanceColor'));var targetval=values[0],x=Math.round(canvas_width*((targetval-min)/range)-(options.get('targetWidth')/2)),targettop=Math.round(canvas_height*0.10),targetheight=canvas_height-(targettop*2);target.drawRect(x,targettop,options.get('targetWidth')-1,targetheight-1,options.get('targetColor'),options.get('targetColor'));}else{this.innerHTML='';}};$.fn.sparkline.pie=function(values,options,width,height){values=$.map(values,Number);width=options.get('width')=='auto'?height:width;var target=$(this).simpledraw(width,height,options.get('composite'));if(target&&values.length>1){var canvas_width=target.pixel_width,canvas_height=target.pixel_height,radius=Math.floor(Math.min(canvas_width,canvas_height)/2),total=0,next=0,circle=2*Math.PI;for(var i=values.length;i--;){total+=values[i];} | ||
if(options.get('offset')){next+=(2*Math.PI)*(options.get('offset')/360);} | ||
var vlen=values.length;for(i=0;i<vlen;i++){var start=next;var end=next;if(total>0){end=next+(circle*(values[i]/total));} | ||
target.drawPieSlice(radius,radius,radius,start,end,undefined,options.get('sliceColors')[i%options.get('sliceColors').length]);next=end;}}};var quartile=function(values,q){if(q==2){var vl2=Math.floor(values.length/2);return values.length%2?values[vl2]:(values[vl2]+values[vl2+1])/2;}else{var vl4=Math.floor(values.length/4);return values.length%2?(values[vl4*q]+values[vl4*q+1])/2:values[vl4*q];}};$.fn.sparkline.box=function(values,options,width,height){values=$.map(values,Number);width=options.get('width')=='auto'?'4.0em':width;var minvalue=options.get('chartRangeMin')===undefined?Math.min.apply(Math,values):options.get('chartRangeMin'),maxvalue=options.get('chartRangeMax')===undefined?Math.max.apply(Math,values):options.get('chartRangeMax'),target=$(this).simpledraw(width,height,options.get('composite')),vlen=values.length,lwhisker,loutlier,q1,q2,q3,rwhisker,routlier;if(target&&values.length>1){var canvas_width=target.pixel_width,canvas_height=target.pixel_height;if(options.get('raw')){if(options.get('showOutliers')&&values.length>5){loutlier=values[0];lwhisker=values[1];q1=values[2];q2=values[3];q3=values[4];rwhisker=values[5];routlier=values[6];}else{lwhisker=values[0];q1=values[1];q2=values[2];q3=values[3];rwhisker=values[4];}}else{values.sort(function(a,b){return a-b;});q1=quartile(values,1);q2=quartile(values,2);q3=quartile(values,3);var iqr=q3-q1;if(options.get('showOutliers')){lwhisker=undefined;rwhisker=undefined;for(var i=0;i<vlen;i++){if(lwhisker===undefined&&values[i]>q1-(iqr*options.get('outlierIQR'))){lwhisker=values[i];} | ||
if(values[i]<q3+(iqr*options.get('outlierIQR'))){rwhisker=values[i];}} | ||
loutlier=values[0];routlier=values[vlen-1];}else{lwhisker=values[0];rwhisker=values[vlen-1];}} | ||
var unitsize=canvas_width/(maxvalue-minvalue+1),canvas_left=0;if(options.get('showOutliers')){canvas_left=Math.ceil(options.get('spotRadius'));canvas_width-=2*Math.ceil(options.get('spotRadius'));unitsize=canvas_width/(maxvalue-minvalue+1);if(loutlier<lwhisker){target.drawCircle((loutlier-minvalue)*unitsize+canvas_left,canvas_height/2,options.get('spotRadius'),options.get('outlierLineColor'),options.get('outlierFillColor'));} | ||
if(routlier>rwhisker){target.drawCircle((routlier-minvalue)*unitsize+canvas_left,canvas_height/2,options.get('spotRadius'),options.get('outlierLineColor'),options.get('outlierFillColor'));}} | ||
target.drawRect(Math.round((q1-minvalue)*unitsize+canvas_left),Math.round(canvas_height*0.1),Math.round((q3-q1)*unitsize),Math.round(canvas_height*0.8),options.get('boxLineColor'),options.get('boxFillColor'));target.drawLine(Math.round((lwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height/2),Math.round((q1-minvalue)*unitsize+canvas_left),Math.round(canvas_height/2),options.get('lineColor'));target.drawLine(Math.round((lwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height/4),Math.round((lwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height-canvas_height/4),options.get('whiskerColor'));target.drawLine(Math.round((rwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height/2),Math.round((q3-minvalue)*unitsize+canvas_left),Math.round(canvas_height/2),options.get('lineColor'));target.drawLine(Math.round((rwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height/4),Math.round((rwhisker-minvalue)*unitsize+canvas_left),Math.round(canvas_height-canvas_height/4),options.get('whiskerColor'));target.drawLine(Math.round((q2-minvalue)*unitsize+canvas_left),Math.round(canvas_height*0.1),Math.round((q2-minvalue)*unitsize+canvas_left),Math.round(canvas_height*0.9),options.get('medianColor'));if(options.get('target')){var size=Math.ceil(options.get('spotRadius'));target.drawLine(Math.round((options.get('target')-minvalue)*unitsize+canvas_left),Math.round((canvas_height/2)-size),Math.round((options.get('target')-minvalue)*unitsize+canvas_left),Math.round((canvas_height/2)+size),options.get('targetColor'));target.drawLine(Math.round((options.get('target')-minvalue)*unitsize+canvas_left-size),Math.round(canvas_height/2),Math.round((options.get('target')-minvalue)*unitsize+canvas_left+size),Math.round(canvas_height/2),options.get('targetColor'));}}else{this.innerHTML='';}};if($.browser.msie&&!document.namespaces.v){document.namespaces.add('v','urn:schemas-microsoft-com:vml','#default#VML');} | ||
if($.browser.hasCanvas===undefined){var t=document.createElement('canvas');$.browser.hasCanvas=t.getContext!==undefined;} | ||
VCanvas_base=function(width,height,target){};VCanvas_base.prototype={init:function(width,height,target){this.width=width;this.height=height;this.target=target;if(target[0]){target=target[0];} | ||
target.VCanvas=this;},drawShape:function(path,lineColor,fillColor,lineWidth){alert('drawShape not implemented');},drawLine:function(x1,y1,x2,y2,lineColor,lineWidth){return this.drawShape([[x1,y1],[x2,y2]],lineColor,lineWidth);},drawCircle:function(x,y,radius,lineColor,fillColor){alert('drawCircle not implemented');},drawPieSlice:function(x,y,radius,startAngle,endAngle,lineColor,fillColor){alert('drawPieSlice not implemented');},drawRect:function(x,y,width,height,lineColor,fillColor){alert('drawRect not implemented');},getElement:function(){return this.canvas;},_insert:function(el,target){$(target).html(el);}};VCanvas_canvas=function(width,height,target){return this.init(width,height,target);};VCanvas_canvas.prototype=$.extend(new VCanvas_base(),{_super:VCanvas_base.prototype,init:function(width,height,target){this._super.init(width,height,target);this.canvas=document.createElement('canvas');if(target[0]){target=target[0];} | ||
target.VCanvas=this;$(this.canvas).css({display:'inline-block',width:width,height:height,verticalAlign:'top'});this._insert(this.canvas,target);this.pixel_height=$(this.canvas).height();this.pixel_width=$(this.canvas).width();this.canvas.width=this.pixel_width;this.canvas.height=this.pixel_height;$(this.canvas).css({width:this.pixel_width,height:this.pixel_height});},_getContext:function(lineColor,fillColor,lineWidth){var context=this.canvas.getContext('2d');if(lineColor!==undefined){context.strokeStyle=lineColor;} | ||
context.lineWidth=lineWidth===undefined?1:lineWidth;if(fillColor!==undefined){context.fillStyle=fillColor;} | ||
return context;},drawShape:function(path,lineColor,fillColor,lineWidth){var context=this._getContext(lineColor,fillColor,lineWidth);context.beginPath();context.moveTo(path[0][0]+0.5,path[0][1]+0.5);for(var i=1,plen=path.length;i<plen;i++){context.lineTo(path[i][0]+0.5,path[i][1]+0.5);} | ||
if(lineColor!==undefined){context.stroke();} | ||
if(fillColor!==undefined){context.fill();}},drawCircle:function(x,y,radius,lineColor,fillColor){var context=this._getContext(lineColor,fillColor);context.beginPath();context.arc(x,y,radius,0,2*Math.PI,false);if(lineColor!==undefined){context.stroke();} | ||
if(fillColor!==undefined){context.fill();}},drawPieSlice:function(x,y,radius,startAngle,endAngle,lineColor,fillColor){var context=this._getContext(lineColor,fillColor);context.beginPath();context.moveTo(x,y);context.arc(x,y,radius,startAngle,endAngle,false);context.lineTo(x,y);context.closePath();if(lineColor!==undefined){context.stroke();} | ||
if(fillColor){context.fill();}},drawRect:function(x,y,width,height,lineColor,fillColor){return this.drawShape([[x,y],[x+width,y],[x+width,y+height],[x,y+height],[x,y]],lineColor,fillColor);}});VCanvas_vml=function(width,height,target){return this.init(width,height,target);};VCanvas_vml.prototype=$.extend(new VCanvas_base(),{_super:VCanvas_base.prototype,init:function(width,height,target){this._super.init(width,height,target);if(target[0]){target=target[0];} | ||
target.VCanvas=this;this.canvas=document.createElement('span');$(this.canvas).css({display:'inline-block',position:'relative',overflow:'hidden',width:width,height:height,margin:'0px',padding:'0px',verticalAlign:'top'});this._insert(this.canvas,target);this.pixel_height=$(this.canvas).height();this.pixel_width=$(this.canvas).width();this.canvas.width=this.pixel_width;this.canvas.height=this.pixel_height;var groupel='<v:group coordorigin="0 0" coordsize="'+this.pixel_width+' '+this.pixel_height+'"'+' style="position:absolute;top:0;left:0;width:'+this.pixel_width+'px;height='+this.pixel_height+'px;"></v:group>';this.canvas.insertAdjacentHTML('beforeEnd',groupel);this.group=$(this.canvas).children()[0];},drawShape:function(path,lineColor,fillColor,lineWidth){var vpath=[];for(var i=0,plen=path.length;i<plen;i++){vpath[i]=''+(path[i][0])+','+(path[i][1]);} | ||
var initial=vpath.splice(0,1);lineWidth=lineWidth===undefined?1:lineWidth;var stroke=lineColor===undefined?' stroked="false" ':' strokeWeight="'+lineWidth+'" strokeColor="'+lineColor+'" ';var fill=fillColor===undefined?' filled="false"':' fillColor="'+fillColor+'" filled="true" ';var closed=vpath[0]==vpath[vpath.length-1]?'x ':'';var vel='<v:shape coordorigin="0 0" coordsize="'+this.pixel_width+' '+this.pixel_height+'" '+ | ||
stroke+ | ||
fill+' style="position:absolute;left:0px;top:0px;height:'+this.pixel_height+'px;width:'+this.pixel_width+'px;padding:0px;margin:0px;" '+' path="m '+initial+' l '+vpath.join(', ')+' '+closed+'e">'+' </v:shape>';this.group.insertAdjacentHTML('beforeEnd',vel);},drawCircle:function(x,y,radius,lineColor,fillColor){x-=radius+1;y-=radius+1;var stroke=lineColor===undefined?' stroked="false" ':' strokeWeight="1" strokeColor="'+lineColor+'" ';var fill=fillColor===undefined?' filled="false"':' fillColor="'+fillColor+'" filled="true" ';var vel='<v:oval '+ | ||
stroke+ | ||
fill+' style="position:absolute;top:'+y+'px; left:'+x+'px; width:'+(radius*2)+'px; height:'+(radius*2)+'px"></v:oval>';this.group.insertAdjacentHTML('beforeEnd',vel);},drawPieSlice:function(x,y,radius,startAngle,endAngle,lineColor,fillColor){if(startAngle==endAngle){return;} | ||
if((endAngle-startAngle)==(2*Math.PI)){startAngle=0.0;endAngle=(2*Math.PI);} | ||
var startx=x+Math.round(Math.cos(startAngle)*radius);var starty=y+Math.round(Math.sin(startAngle)*radius);var endx=x+Math.round(Math.cos(endAngle)*radius);var endy=y+Math.round(Math.sin(endAngle)*radius);var vpath=[x-radius,y-radius,x+radius,y+radius,startx,starty,endx,endy];var stroke=lineColor==undefined?' stroked="false" ':' strokeWeight="1" strokeColor="'+lineColor+'" ';var fill=fillColor==undefined?' filled="false"':' fillColor="'+fillColor+'" filled="true" ';var vel='<v:shape coordorigin="0 0" coordsize="'+this.pixel_width+' '+this.pixel_height+'" ' | ||
+stroke | ||
+fill | ||
+' style="position:absolute;left:0px;top:0px;height:'+this.pixel_height+'px;width:'+this.pixel_width+'px;padding:0px;margin:0px;" ' | ||
+' path="m '+x+','+y+' wa '+vpath.join(', ')+' x e">' | ||
+' </v:shape>';this.group.insertAdjacentHTML('beforeEnd',vel);},drawRect:function(x,y,width,height,lineColor,fillColor){return this.drawShape([[x,y],[x,y+height],[x+width,y+height],[x+width,y],[x,y]],lineColor,fillColor);}});})(jQuery); | ||
var startx=x+Math.round(Math.cos(startAngle)*radius);var starty=y+Math.round(Math.sin(startAngle)*radius);var endx=x+Math.round(Math.cos(endAngle)*radius);var endy=y+Math.round(Math.sin(endAngle)*radius);if(startx==endx&&starty==endy&&(endAngle-startAngle)<Math.PI){return;} | ||
var vpath=[x-radius,y-radius,x+radius,y+radius,startx,starty,endx,endy];var stroke=lineColor===undefined?' stroked="false" ':' strokeWeight="1" strokeColor="'+lineColor+'" ';var fill=fillColor===undefined?' filled="false"':' fillColor="'+fillColor+'" filled="true" ';var vel='<v:shape coordorigin="0 0" coordsize="'+this.pixel_width+' '+this.pixel_height+'" '+ | ||
stroke+ | ||
fill+' style="position:absolute;left:0px;top:0px;height:'+this.pixel_height+'px;width:'+this.pixel_width+'px;padding:0px;margin:0px;" '+' path="m '+x+','+y+' wa '+vpath.join(', ')+' x e">'+' </v:shape>';this.group.insertAdjacentHTML('beforeEnd',vel);},drawRect:function(x,y,width,height,lineColor,fillColor){return this.drawShape([[x,y],[x,y+height],[x+width,y+height],[x+width,y],[x,y]],lineColor,fillColor);}});})(jQuery); |
@@ -0,0 +0,0 @@ /* |
@@ -1,2 +0,2 @@ | ||
Copyright (c) 2010 Michael Leibman, http://github.com/mleibman/slickgrid | ||
Copyright (c) 2009-2016 Michael Leibman, http://github.com/mleibman/slickgrid | ||
@@ -3,0 +3,0 @@ Permission is hereby granted, free of charge, to any person obtaining |
{ | ||
"name": "slickgrid", | ||
"version": "2.1.0", | ||
"version": "2.3.3", | ||
"description": "A lightning fast JavaScript grid/spreadsheet", | ||
@@ -12,3 +12,3 @@ "main": "slick.core.js", | ||
"type": "git", | ||
"url": "git://github.com/shtylman/SlickGrid.git" | ||
"url": "git+https://github.com/6pac/SlickGrid.git" | ||
}, | ||
@@ -20,4 +20,15 @@ "keywords": [ | ||
"author": "Michael Leibman <michael.leibman@gmail.com>", | ||
"contributors": [ "Ben McIntyre <email.ben.mcintyre@gmail.com>" ], | ||
"license": "MIT", | ||
"readmeFilename": "README.md" | ||
"bugs": { | ||
"url": "https://github.com/6pac/SlickGrid/issues" | ||
}, | ||
"homepage": "https://github.com/6pac/SlickGrid#readme", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"dependencies": { | ||
"jquery": ">=1.8.0", | ||
"jquery-ui": ">=1.8.0" | ||
} | ||
} |
(function ($) { | ||
// register namespace | ||
// Register namespace | ||
$.extend(true, window, { | ||
@@ -9,3 +9,9 @@ "Slick": { | ||
/** | ||
* AutoTooltips plugin to show/hide tooltips when columns are too narrow to fit content. | ||
* @constructor | ||
* @param {boolean} [options.enableForCells=true] - Enable tooltip for grid cells | ||
* @param {boolean} [options.enableForHeaderCells=false] - Enable tooltip for header cells | ||
* @param {number} [options.maxToolTipLength=null] - The maximum length for a tooltip | ||
*/ | ||
function AutoTooltips(options) { | ||
@@ -15,31 +21,60 @@ var _grid; | ||
var _defaults = { | ||
enableForCells: true, | ||
enableForHeaderCells: false, | ||
maxToolTipLength: null | ||
}; | ||
/** | ||
* Initialize plugin. | ||
*/ | ||
function init(grid) { | ||
options = $.extend(true, {}, _defaults, options); | ||
_grid = grid; | ||
_grid.onMouseEnter.subscribe(handleMouseEnter); | ||
if (options.enableForCells) _grid.onMouseEnter.subscribe(handleMouseEnter); | ||
if (options.enableForHeaderCells) _grid.onHeaderMouseEnter.subscribe(handleHeaderMouseEnter); | ||
} | ||
/** | ||
* Destroy plugin. | ||
*/ | ||
function destroy() { | ||
_grid.onMouseEnter.unsubscribe(handleMouseEnter); | ||
if (options.enableForCells) _grid.onMouseEnter.unsubscribe(handleMouseEnter); | ||
if (options.enableForHeaderCells) _grid.onHeaderMouseEnter.unsubscribe(handleHeaderMouseEnter); | ||
} | ||
function handleMouseEnter(e, args) { | ||
/** | ||
* Handle mouse entering grid cell to add/remove tooltip. | ||
* @param {jQuery.Event} e - The event | ||
*/ | ||
function handleMouseEnter(e) { | ||
var cell = _grid.getCellFromEvent(e); | ||
if (cell) { | ||
var node = _grid.getCellNode(cell.row, cell.cell); | ||
if ($(node).innerWidth() < node.scrollWidth) { | ||
var text = $.trim($(node).text()); | ||
var $node = $(_grid.getCellNode(cell.row, cell.cell)); | ||
var text; | ||
if ($node.innerWidth() < $node[0].scrollWidth) { | ||
text = $.trim($node.text()); | ||
if (options.maxToolTipLength && text.length > options.maxToolTipLength) { | ||
text = text.substr(0, options.maxToolTipLength - 3) + "..."; | ||
} | ||
$(node).attr("title", text); | ||
} else { | ||
$(node).attr("title", ""); | ||
text = ""; | ||
} | ||
$node.attr("title", text); | ||
} | ||
} | ||
/** | ||
* Handle mouse entering header cell to add/remove tooltip. | ||
* @param {jQuery.Event} e - The event | ||
* @param {object} args.column - The column definition | ||
*/ | ||
function handleHeaderMouseEnter(e, args) { | ||
var column = args.column, | ||
$node = $(e.target).closest(".slick-header-column"); | ||
if (column && !column.toolTip) { | ||
$node.attr("title", ($node.innerWidth() < $node[0].scrollWidth) ? column.name : ""); | ||
} | ||
} | ||
// Public API | ||
$.extend(this, { | ||
@@ -46,0 +81,0 @@ "init": init, |
@@ -49,6 +49,8 @@ (function ($) { | ||
e.preventDefault(); | ||
clearCopySelection(); | ||
ranges = _grid.getSelectionModel().getSelectedRanges(); | ||
_self.onPasteCells.notify({from: _copiedRanges, to: ranges}); | ||
_copiedRanges = null; | ||
if (!_grid.getOptions().preserveCopiedSelectionOnPaste) { | ||
clearCopySelection(); | ||
_copiedRanges = null; | ||
} | ||
} | ||
@@ -55,0 +57,0 @@ } |
@@ -23,2 +23,3 @@ (function ($) { | ||
var _defaults = { | ||
selectionCssClass: 'slick-range-decorator', | ||
selectionCss: { | ||
@@ -36,2 +37,3 @@ "zIndex": "9999", | ||
_elem = $("<div></div>", {css: options.selectionCss}) | ||
.addClass(options.selectionCssClass) | ||
.css("position", "absolute") | ||
@@ -66,2 +68,2 @@ .appendTo(grid.getCanvasNode()); | ||
} | ||
})(jQuery); | ||
})(jQuery); |
@@ -57,2 +57,4 @@ (function ($) { | ||
_grid.focus(); | ||
var start = _grid.getCellFromPoint( | ||
@@ -59,0 +61,0 @@ dd.startX - $(_canvas).offset().left, |
@@ -31,2 +31,3 @@ (function ($) { | ||
_grid.onActiveCellChanged.subscribe(handleActiveCellChange); | ||
_grid.onKeyDown.subscribe(handleKeyDown); | ||
grid.registerPlugin(_selector); | ||
@@ -39,2 +40,3 @@ _selector.onCellRangeSelected.subscribe(handleCellRangeSelected); | ||
_grid.onActiveCellChanged.unsubscribe(handleActiveCellChange); | ||
_grid.onKeyDown.unsubscribe(handleKeyDown); | ||
_selector.onCellRangeSelected.unsubscribe(handleCellRangeSelected); | ||
@@ -59,2 +61,5 @@ _selector.onBeforeCellRangeSelected.unsubscribe(handleBeforeCellRangeSelected); | ||
function setSelectedRanges(ranges) { | ||
// simle check for: empty selection didn't change, prevent firing onSelectedRangesChanged | ||
if ((!_ranges || _ranges.length === 0) && (!ranges || ranges.length === 0)) { return; } | ||
_ranges = removeInvalidRanges(ranges); | ||
@@ -84,3 +89,63 @@ _self.onSelectedRangesChanged.notify(_ranges); | ||
} | ||
function handleKeyDown(e) { | ||
/*** | ||
* Кey codes | ||
* 37 left | ||
* 38 up | ||
* 39 right | ||
* 40 down | ||
*/ | ||
var ranges, last; | ||
var active = _grid.getActiveCell(); | ||
if ( active && e.shiftKey && !e.ctrlKey && !e.altKey && | ||
(e.which == 37 || e.which == 39 || e.which == 38 || e.which == 40) ) { | ||
ranges = getSelectedRanges(); | ||
if (!ranges.length) | ||
ranges.push(new Slick.Range(active.row, active.cell)); | ||
// keyboard can work with last range only | ||
last = ranges.pop(); | ||
// can't handle selection out of active cell | ||
if (!last.contains(active.row, active.cell)) | ||
last = new Slick.Range(active.row, active.cell); | ||
var dRow = last.toRow - last.fromRow, | ||
dCell = last.toCell - last.fromCell, | ||
// walking direction | ||
dirRow = active.row == last.fromRow ? 1 : -1, | ||
dirCell = active.cell == last.fromCell ? 1 : -1; | ||
if (e.which == 37) { | ||
dCell -= dirCell; | ||
} else if (e.which == 39) { | ||
dCell += dirCell ; | ||
} else if (e.which == 38) { | ||
dRow -= dirRow; | ||
} else if (e.which == 40) { | ||
dRow += dirRow; | ||
} | ||
// define new selection range | ||
var new_last = new Slick.Range(active.row, active.cell, active.row + dirRow*dRow, active.cell + dirCell*dCell); | ||
if (removeInvalidRanges([new_last]).length) { | ||
ranges.push(new_last); | ||
var viewRow = dirRow > 0 ? new_last.toRow : new_last.fromRow; | ||
var viewCell = dirCell > 0 ? new_last.toCell : new_last.fromCell; | ||
_grid.scrollRowIntoView(viewRow); | ||
_grid.scrollCellIntoView(viewRow, viewCell); | ||
} | ||
else | ||
ranges.push(last); | ||
setSelectedRanges(ranges); | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
} | ||
} | ||
$.extend(this, { | ||
@@ -96,2 +161,2 @@ "getSelectedRanges": getSelectedRanges, | ||
} | ||
})(jQuery); | ||
})(jQuery); |
@@ -0,0 +0,0 @@ (function ($) { |
@@ -125,7 +125,7 @@ (function ($) { | ||
if (button.handler) { | ||
btn.bind("click", button.handler); | ||
btn.on("click", button.handler); | ||
} | ||
btn | ||
.bind("click", handleButtonClick) | ||
.on("click", handleButtonClick) | ||
.appendTo(args.node); | ||
@@ -178,2 +178,2 @@ } | ||
} | ||
})(jQuery); | ||
})(jQuery); |
@@ -86,3 +86,3 @@ (function ($) { | ||
buttonCssClass: null, | ||
buttonImage: "../images/down.gif" | ||
buttonImage: null | ||
}; | ||
@@ -104,3 +104,3 @@ var $menu; | ||
// Hide the menu on outside click. | ||
$(document.body).bind("mousedown", handleBodyMouseDown); | ||
$(document.body).on("mousedown", handleBodyMouseDown); | ||
} | ||
@@ -111,3 +111,3 @@ | ||
_handler.unsubscribeAll(); | ||
$(document.body).unbind("mousedown", handleBodyMouseDown); | ||
$(document.body).off("mousedown", handleBodyMouseDown); | ||
} | ||
@@ -155,3 +155,3 @@ | ||
$el | ||
.bind("click", showMenu) | ||
.on("click", showMenu) | ||
.appendTo(args.node); | ||
@@ -189,3 +189,3 @@ } | ||
$menu = $("<div class='slick-header-menu'></div>") | ||
.appendTo(document.body); | ||
.appendTo(_grid.getContainerNode()); | ||
} | ||
@@ -203,3 +203,3 @@ $menu.empty(); | ||
.data("item", item) | ||
.bind("click", handleMenuItemClick) | ||
.on("click", handleMenuItemClick) | ||
.appendTo($menu); | ||
@@ -234,4 +234,3 @@ | ||
$menu | ||
.css("top", $(this).offset().top + $(this).height()) | ||
.css("left", $(this).offset().left); | ||
.offset({ top: $(this).offset().top + $(this).height(), left: $(this).offset().left }); | ||
@@ -243,2 +242,6 @@ | ||
.addClass("slick-header-column-active"); | ||
// Stop propagation so that it doesn't register as a header click event. | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
} | ||
@@ -280,2 +283,2 @@ | ||
} | ||
})(jQuery); | ||
})(jQuery); |
@@ -0,0 +0,0 @@ (function ($) { |
@@ -84,2 +84,4 @@ (function ($) { | ||
function setSelectedRanges(ranges) { | ||
// simle check for: empty selection didn't change, prevent firing onSelectedRangesChanged | ||
if ((!_ranges || _ranges.length === 0) && (!ranges || ranges.length === 0)) { return; } | ||
_ranges = ranges; | ||
@@ -123,4 +125,4 @@ _self.onSelectedRangesChanged.notify(_ranges); | ||
_grid.scrollRowIntoView(active); | ||
_ranges = rowsToRanges(getRowsRange(top, bottom)); | ||
setSelectedRanges(_ranges); | ||
var tempRanges = rowsToRanges(getRowsRange(top, bottom)); | ||
setSelectedRanges(tempRanges); | ||
} | ||
@@ -139,34 +141,34 @@ | ||
if (!_grid.getOptions().multiSelect || ( | ||
!e.ctrlKey && !e.shiftKey && !e.metaKey)) { | ||
return false; | ||
} | ||
var selection = rangesToRows(_ranges); | ||
var idx = $.inArray(cell.row, selection); | ||
if (!e.ctrlKey && !e.shiftKey && !e.metaKey) { | ||
return false; | ||
} | ||
else if (_grid.getOptions().multiSelect) { | ||
if (idx === -1 && (e.ctrlKey || e.metaKey)) { | ||
selection.push(cell.row); | ||
_grid.setActiveCell(cell.row, cell.cell); | ||
} else if (idx !== -1 && (e.ctrlKey || e.metaKey)) { | ||
selection = $.grep(selection, function (o, i) { | ||
return (o !== cell.row); | ||
}); | ||
_grid.setActiveCell(cell.row, cell.cell); | ||
} else if (selection.length && e.shiftKey) { | ||
var last = selection.pop(); | ||
var from = Math.min(cell.row, last); | ||
var to = Math.max(cell.row, last); | ||
selection = []; | ||
for (var i = from; i <= to; i++) { | ||
if (i !== last) { | ||
selection.push(i); | ||
} | ||
if (idx === -1 && (e.ctrlKey || e.metaKey)) { | ||
selection.push(cell.row); | ||
_grid.setActiveCell(cell.row, cell.cell); | ||
} else if (idx !== -1 && (e.ctrlKey || e.metaKey)) { | ||
selection = $.grep(selection, function (o, i) { | ||
return (o !== cell.row); | ||
}); | ||
_grid.setActiveCell(cell.row, cell.cell); | ||
} else if (selection.length && e.shiftKey) { | ||
var last = selection.pop(); | ||
var from = Math.min(cell.row, last); | ||
var to = Math.max(cell.row, last); | ||
selection = []; | ||
for (var i = from; i <= to; i++) { | ||
if (i !== last) { | ||
selection.push(i); | ||
} | ||
selection.push(last); | ||
_grid.setActiveCell(cell.row, cell.cell); | ||
} | ||
selection.push(last); | ||
_grid.setActiveCell(cell.row, cell.cell); | ||
} | ||
_ranges = rowsToRanges(selection); | ||
setSelectedRanges(_ranges); | ||
var tempRanges = rowsToRanges(selection); | ||
setSelectedRanges(tempRanges); | ||
e.stopImmediatePropagation(); | ||
@@ -173,0 +175,0 @@ |
@@ -1,22 +0,55 @@ | ||
# Welcome to SlickGrid | ||
## This is the 6pac SlickGrid repo | ||
For now, please check out [the wiki](https://github.com/mleibman/SlickGrid/wiki). | ||
This is the acknowledged most active non-customised fork of SlickGrid. | ||
## SlickGrid is an advanced JavaScript grid/spreadsheet component | ||
It aims to be a viable alternative master repo, building on the legacy of the mleibman/SlickGrid master branch, keeping libraries up to date and applying small, safe core patches and enhancements without turning into a personalised build. | ||
Some highlights: | ||
Check out the [examples](https://github.com/6pac/SlickGrid/wiki/Examples) for examples demonstrating new features and use cases, such as dynamic grid creation and editors with third party controls. | ||
* Adaptive virtual scrolling (handle hundreds of thousands of rows with extreme responsiveness) | ||
* Extremely fast rendering speed | ||
* Supports jQuery UI Themes | ||
* Background post-rendering for richer cells | ||
* Configurable & customizable | ||
* Full keyboard navigation | ||
* Column resize/reorder/show/hide | ||
* Column autosizing & force-fit | ||
* Pluggable cell formatters & editors | ||
* Support for editing and creating new rows. | ||
* Grouping, filtering, custom aggregators, and more! | ||
* Advanced detached & multi-field editors with undo/redo support. | ||
* “GlobalEditorLock” to manage concurrent edits in cases where multiple Views on a page can edit the same data. | ||
* Support for [millions of rows](http://stackoverflow.com/a/2569488/1269037) | ||
Also check out my [wiki](https://github.com/6pac/SlickGrid/wiki). | ||
The following are the changes (most recent first) made since forking from the main MLeibman branch, a significant number in response to issues or pull requests. | ||
**Maintenance:** | ||
* breaking change: updated jquery.event.drag-2.2.js and jquery.event.drop-2.2.js to be compatible with jQuery 3, bumped these to jquery.event.drag-2.3.0.js and jquery.event.drop-2.3.0.js | ||
* tested with jQuery 1.8.3, 1.11.2, 2.2.4, and 3.1.0 -- thanks to lfilho | ||
* updated repo to work with jQuery 3.x (without needing jQuery-Migrate) -- thanks to lfilho | ||
* fix bug with refresh last row of grid | ||
* fix bug in compound editor example 'isValueChanged' method | ||
* add internal keycode enums | ||
* fix error in autotooltips test | ||
* remove deprecated jquery .browser property | ||
* fix bugs identified by JsHint | ||
* Patch absBox for null element bug (MLeibman #1066) | ||
* Fix column resizing issues with Bootstrap 3/box-sizing:border-box | ||
* Fix jQueryUI css interfering with SlickGrid css issues | ||
* Prevent useless onSelectedRangesChanged events in selectionmodels' setSelectedRanges | ||
* Fix tooltip error with draggable columns | ||
* additional version of ajax loading page, using Yahoo news and YQL as a source. the format of the grid rows is more in keeping with the newsfeed style of the original | ||
* Fix Issue #963 ajax example not working | ||
* update DataView compiled-expression regex to deal with some forms of minification | ||
* fix grouping bug (issue #841 & #896 mleibman#898) | ||
* Make default group comparer function more robust | ||
* Fix unnecessary horizontal scroll for autosized columns when viewport has fractional pixel width | ||
* Remove redundant slick pager code | ||
* Fix bug in dataview causing model benchmark test to throw an error | ||
* update to jquery-1.11.2 and jquery-ui-1.11.3, with minor patches to accommodate the change | ||
**New features:** | ||
* Add example of jQueryUI autocomplete editor | ||
* Add KeyCaptureList property to editor, to allow editor to capture specified keys | ||
* add optional fixed footer row | ||
* Add example of dynamic tab and grid creation for grid with all the features of example-4-model | ||
* Add example of dynamic tab and grid creation for basic grid | ||
* add custom validator option to integer, float and date editors | ||
* Add grid as member of args parameter for all events, and to column formatter. Add dataView as member of args parameter for all dataView events | ||
* Add Floating Point editor | ||
* Allow custom editors to suppress automatic cell clear on edit | ||
* Add async post render async cleanup | ||
* Add multi grid on page example (example-multi-grid-basic) | ||
* Add jQueryUI accordion and Bootstrap 3 examples | ||
* Add css manipulation so that grid initialises successfully if the parent element is hidden | ||
Original mleibman [wiki](https://github.com/mleibman/SlickGrid/wiki). |
@@ -380,2 +380,36 @@ (function($) { | ||
test("inlining replaces absolute returns", function() { | ||
var dv = new Slick.Data.DataView({ inlineFilters: true }); | ||
dv.setItems([{id:0,val:0},{id:1,val:1},{id:2,val:2}]); | ||
dv.setFilter(function(o) { | ||
if (o.val === 1) { return true; } | ||
else if (o.val === 4) { return true } | ||
return false}); | ||
same(dv.getLength(), 1, "one row is remaining"); | ||
dv.onRowsChanged.subscribe(function() { ok(false, "onRowsChanged called") }); | ||
dv.onRowCountChanged.subscribe(function() { ok(false, "onRowCountChanged called") }); | ||
dv.onPagingInfoChanged.subscribe(function() { ok(false, "onPagingInfoChanged called") }); | ||
same(dv.getItems().length, 3, "original data is still there"); | ||
same(dv.getLength(), 1, "rows are filtered"); | ||
assertConsistency(dv); | ||
}); | ||
test("inlining replaces evaluated returns", function() { | ||
var dv = new Slick.Data.DataView({ inlineFilters: true }); | ||
dv.setItems([{id:0,val:0},{id:1,val:1},{id:2,val:2}]); | ||
dv.setFilter(function(o) { | ||
if (o.val === 0) { return o.id === 2; } | ||
else if (o.val === 1) { return o.id === 2 } | ||
return o.val === 2}); | ||
same(dv.getLength(), 1, "one row is remaining"); | ||
dv.onRowsChanged.subscribe(function() { ok(false, "onRowsChanged called") }); | ||
dv.onRowCountChanged.subscribe(function() { ok(false, "onRowCountChanged called") }); | ||
dv.onPagingInfoChanged.subscribe(function() { ok(false, "onPagingInfoChanged called") }); | ||
same(dv.getItems().length, 3, "original data is still there"); | ||
same(dv.getLength(), 1, "rows are filtered"); | ||
assertConsistency(dv); | ||
}); | ||
module("updateItem"); | ||
@@ -459,3 +493,3 @@ | ||
dv.onRowsChanged.subscribe(function(e,args) { | ||
console.log(args) | ||
console.log(args); | ||
ok(false, "onRowsChanged called"); | ||
@@ -462,0 +496,0 @@ }); |
@@ -1,17 +0,17 @@ | ||
(function($) { | ||
var grid; | ||
var el, offsetBefore, offsetAfter, dragged; | ||
var drag = function(handle, dx, dy) { | ||
(function ($) { | ||
var grid; | ||
var el, offsetBefore, offsetAfter, dragged; | ||
var drag = function(handle, dx, dy) { | ||
offsetBefore = el.offset(); | ||
$(handle).simulate("drag", { | ||
dx: dx || 0, | ||
dy: dy || 0 | ||
dx: dx || 0, | ||
dy: dy || 0 | ||
}); | ||
dragged = { dx: dx, dy: dy }; | ||
offsetAfter = el.offset(); | ||
} | ||
var moved = function (dx, dy, msg) { | ||
} | ||
var moved = function (dx, dy, msg) { | ||
msg = msg ? msg + "." : ""; | ||
@@ -21,57 +21,49 @@ var actual = { left: offsetAfter.left, top: offsetAfter.top }; | ||
same(actual, expected, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ' + msg); | ||
} | ||
var ROWS = 500, COLS = 10; | ||
var data = [], row; | ||
for (var i=0; i<ROWS; i++) { | ||
row = {}; | ||
row["id"] = "id_" + i; | ||
for (var j=0; j<COLS; j++) { | ||
row["col_" + j] = i + "." + j; | ||
} | ||
var ROWS = 500, COLS = 10; | ||
var data = [], row; | ||
for (var i = 0; i < ROWS; i++) { | ||
row = { id: "id_" + i }; | ||
for (var j = 0; j < COLS; j++) { | ||
row["col_" + j] = i + "." + j; | ||
} | ||
data.push(row); | ||
} | ||
} | ||
var cols = [], col; | ||
for (var i = 0; i < COLS; i++) { | ||
cols.push({ | ||
id: "col" + i, | ||
field: "col_" + i, | ||
name: "col_" + i | ||
}); | ||
} | ||
cols[0].minWidth = 70; | ||
var cols = [], col; | ||
for (var i=0; i<COLS; i++) { | ||
col = {}; | ||
col["id"] = "col" + i; | ||
col["field"] = "col_" + i; | ||
col["name"] = "col_" + i; | ||
cols.push(col); | ||
} | ||
grid = new Slick.Grid("#container", data, cols); | ||
grid.render(); | ||
cols[0].minWidth = 70; | ||
grid = new Slick.Grid("#container", data, cols); | ||
grid.render(); | ||
module("grid - column resizing"); | ||
test("minWidth is respected", function() { | ||
module("grid - column resizing"); | ||
test("minWidth is respected", function () { | ||
var firstCol = $("#container .slick-header-column:first"); | ||
firstCol.find(".slick-resizable-handle:first").simulate("drag", {dx:100,dy:0}); | ||
firstCol.find(".slick-resizable-handle:first").simulate("drag", {dx:-200,dy:0}); | ||
firstCol.find(".slick-resizable-handle:first").simulate("drag", { dx: 100, dy: 0 }); | ||
firstCol.find(".slick-resizable-handle:first").simulate("drag", { dx: -200, dy: 0 }); | ||
equal(firstCol.outerWidth(), 70, "width set to minWidth"); | ||
}); | ||
test("onColumnsResized is fired on column resize", function() { | ||
}); | ||
test("onColumnsResized is fired on column resize", function () { | ||
expect(2); | ||
grid.onColumnsResized = function() { ok(true,"onColumnsResized called") }; | ||
grid.onColumnsResized.subscribe(function() { ok(true,"onColumnsResized called") }); | ||
var oldWidth = cols[0].width; | ||
$("#container .slick-resizable-handle:first").simulate("drag", {dx:100,dy:0}); | ||
$("#container .slick-resizable-handle:first").simulate("drag", { dx: 100, dy: 0 }); | ||
equal(cols[0].width, oldWidth+100-1, "columns array is updated"); | ||
}); | ||
test("getData should return data", function() { | ||
}); | ||
test("getData should return data", function () { | ||
equal(grid.getData(), data); | ||
}); | ||
})(jQuery); | ||
}); | ||
})(jQuery); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
3686108
166
90344
0
56
2
7
3
+ Addedjquery@>=1.8.0
+ Addedjquery-ui@>=1.8.0
+ Addedjquery@3.7.1(transitive)
+ Addedjquery-ui@1.14.1(transitive)