From 5e3f0e13b4472229ae403580c86f984f9a796a39 Mon Sep 17 00:00:00 2001 From: Marcin Warpechowski Date: Mon, 4 Mar 2013 00:55:31 +0100 Subject: [PATCH] Angular UI Handsontable 0.3.4 --- CHANGELOG.md | 2 +- dist/angular-ui-handsontable.full.css | 4 ++-- dist/angular-ui-handsontable.full.js | 4 ++-- dist/angular-ui-handsontable.full.min.css | 4 ++-- dist/angular-ui-handsontable.full.min.js | 4 ++-- package.json | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22cfb12c..0a004230 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## HEAD +## 0.3.4 (Mar 4, 2012) Bugfix: - fix problems with autocomplete cell type and Angular Patch integration diff --git a/dist/angular-ui-handsontable.full.css b/dist/angular-ui-handsontable.full.css index 763c5fad..ac231736 100644 --- a/dist/angular-ui-handsontable.full.css +++ b/dist/angular-ui-handsontable.full.css @@ -1,7 +1,7 @@ /** - * angular-ui-handsontable 0.3.3 + * angular-ui-handsontable 0.3.4 * - * Date: Mon Mar 04 2013 00:52:58 GMT+0100 (Central European Standard Time) + * Date: Mon Mar 04 2013 00:54:29 GMT+0100 (Central European Standard Time) */ /** diff --git a/dist/angular-ui-handsontable.full.js b/dist/angular-ui-handsontable.full.js index e9e95e7f..a597e1ae 100644 --- a/dist/angular-ui-handsontable.full.js +++ b/dist/angular-ui-handsontable.full.js @@ -1,7 +1,7 @@ /** - * angular-ui-handsontable 0.3.3 + * angular-ui-handsontable 0.3.4 * - * Date: Mon Mar 04 2013 00:52:58 GMT+0100 (Central European Standard Time) + * Date: Mon Mar 04 2013 00:54:29 GMT+0100 (Central European Standard Time) */ /** diff --git a/dist/angular-ui-handsontable.full.min.css b/dist/angular-ui-handsontable.full.min.css index 81940b55..f3468a48 100644 --- a/dist/angular-ui-handsontable.full.min.css +++ b/dist/angular-ui-handsontable.full.min.css @@ -1,7 +1,7 @@ /** - * angular-ui-handsontable 0.3.3 + * angular-ui-handsontable 0.3.4 * - * Date: Mon Mar 04 2013 00:53:00 GMT+0100 (Central European Standard Time) + * Date: Mon Mar 04 2013 00:54:31 GMT+0100 (Central European Standard Time) */ diff --git a/dist/angular-ui-handsontable.full.min.js b/dist/angular-ui-handsontable.full.min.js index 1ff1f7a8..9751d6b1 100644 --- a/dist/angular-ui-handsontable.full.min.js +++ b/dist/angular-ui-handsontable.full.min.js @@ -1,7 +1,7 @@ /** - * angular-ui-handsontable 0.3.3 + * angular-ui-handsontable 0.3.4 * - * Date: Mon Mar 04 2013 00:52:58 GMT+0100 (Central European Standard Time) + * Date: Mon Mar 04 2013 00:54:29 GMT+0100 (Central European Standard Time) */ document.all&&!document.addEventListener&&(document.createElement("ui-handsontable"),document.createElement("datacolumn"),document.createElement("optionlist")),angular.module("uiHandsontable",[]).directive("uiHandsontable",["$compile",function(t){for(var e=["data","width","height","rowHeaders","colHeaders","colWidths","columns","cells","dataSchema","contextMenu","onSelection","onSelectionByProp","onBeforeChange","onChange","onCopyLimit","startRows","startCols","minRows","minCols","maxRows","maxCols","minSpareRows","minSpareCols","multiSelect","fillHandle","undo","outsideClickDeselects","enterBeginsEditing","enterMoves","tabMoves","autoWrapRow","autoWrapCol","copyRowsLimit","copyColsLimit","currentRowClassName","currentColClassName","asyncRendering","stretchH","columnSorting","manualColumnMove","manualColumnResize"],n={selectedIndex:"=selectedindex"},i=0,s=e.length;s>i;i++)n[e[i]]="="+e[i].toLowerCase();var o={restrict:"EA",scope:n,priority:490,compile:function(n,i){var s,o,r,a={columns:[],colHeaders:!0,outsideClickDeselects:!0,autoComplete:[]},l=function(e,n,i){var s=n.optionList,o=s.match(/^\s*(.+)\s+in\s+(.*)\s*$/);if(!o)throw Error("Expected datarows in form of '_item_ in _collection_' but got '"+s+"'.");var r,a,l,h=o[1],u=o[2],d=e.$new();c.on("blur","textarea",function(){l&&l()}),n.source=function(t,s){l&&l();var o=function(){var t=i.$container.data("handsontable"),n=t.getSelected()[0];return d[i.lhs]=e.$parent.$eval(i.rhs)[n],d.$eval(u)};r=o(),d.$$phase||d.$apply(),s(r),a.$apply(),l=e.$parent.$watch(o,function(e,i){e!==i&&setTimeout(function(){n.source(t,s)},0)}),n.saveOnBlur||(d.$eval(n.value+' = "'+$.trim(t).replace(/"/g,'"')+'"'),d.$apply())},n.sorter=function(t){return t},n.highlighter=function(e){var i,s=d.$new();return s[h]=e,a=s,n.transclude?n.transclude(s,function(t){i=t[0]}):i=t(""+n.optionTemplate+"")(s),i},n.onSelect=function(t,e,i,s,o){d[h]=r[o],d.$eval(n.clickrow),d.$apply()}},c=$('
'),h=i.datarows;if(h&&(s=h.match(/^\s*(.+)\s+in\s+(.*)\s*$/)),!s)throw Error("Expected datarows in form of '_item_ in _collection_' but got '"+h+"'.");return o=s[1],r=s[2],n.data("uiDatagrid",{lhs:o,rhs:r,settings:angular.extend({},a),$container:c}),function(t,n,i){var s,a,h=n.data("uiDatagrid");h.settings=angular.extend(h.settings,t.$parent.$eval(i.uiHandsontable||i.settings));for(s in e)e.hasOwnProperty(s)&&t[e[s]]!==void 0&&(h.settings[e[s]]=t[e[s]]);if($(n).append(c),t.$parent[r]!==void 0&&(h.settings.data=t.$parent[r]),h.settings.columns){var u=RegExp("^("+o+"\\.)");for(s=0,a=h.settings.columns.length;a>s;s++)h.settings.columns[s].data=h.settings.columns[s].value.replace(u,""),"autocomplete"===h.settings.columns[s].type&&l(t,h.settings.columns[s],h)}c.handsontable(h.settings),c.on("datachange.handsontable",function(){t.$$phase||t.$apply()}),c.on("selectionbyprop.handsontable",function(e,n,i,s,o){t.$emit("datagridSelection",c,n,i,s,o)});var d=0;for(t.$watch(function(){if(t.$parent[r]!==c.handsontable("getData"))return!0;var e=c.data("handsontable"),n=e.countRows();if(d!==n)return d=n;for(var i="",s=e.countCols(),o=e.rowOffset(),a=o+e.countVisibleRows();a>o;o++)for(var l=0;s>l;l++)i+=e.getDataAtCell(o,l);return i},function(e,n){1==e?c.handsontable("loadData",t.$parent[r]):e!==n&&c.handsontable("render")},!1),s=0,a=e.length;a>s;s++)(function(e){t.$watch(e,function(n,i){if(n!==i){if("columns"===e)for(var s=RegExp("^("+o+"\\.)"),r=0,a=n.length;a>r;r++)n[r].data=n[r].value.replace(s,""),"autocomplete"===n[r].type&&l(t,n[r],h);var u={};u[e]=n,c.handsontable("updateSettings",u)}},!0)})(e[s])}}};return o}]).directive("datacolumn",function(){var t={restrict:"E",priority:500,compile:function(t,e){var n=[];for(var i in e)e.hasOwnProperty(i)&&n.push(i);return t.data("uiDatagridColumn",{value:e.value,source:null,saveOnBlur:-1!==$.inArray("saveonblur",n),strict:-1!==$.inArray("strict",n)}),function(t,e,n){var i,s=e.inheritedData("uiDatagrid"),o=t.$parent.$eval(n.title),r=t.$parent.$eval(n.width),a=t.$parent.$eval(n.type),l=n.options,c=t.$new(),h=t.$parent.$eval(l)||{};switch(h.value=n.value,h.type=a,h.title=o,h.width=r,a){case"autocomplete":var u=e.data("uiDatagridColumn");for(i in u)u.hasOwnProperty(i)&&(h[i]=u[i]);break;case"checkbox":n.checkedtemplate!==void 0&&(h.checkedTemplate=t.$parent.$eval(n.checkedtemplate)),n.uncheckedtemplate!==void 0&&(h.uncheckedTemplate=t.$parent.$eval(n.uncheckedtemplate))}n.readonly!==void 0&&(h.readOnly=!0);for(i in n)n.hasOwnProperty(i)&&"$"!==i.charAt(0)&&h[i]===void 0&&(h[i]=c.$eval(n[i]));s.settings.columns.push(h)}}};return t}).directive("optionlist",function(){var t={restrict:"E",transclude:"element",priority:510,compile:function(t,e,n){return function(t,e,i){var s=e.inheritedData("uiDatagridColumn");s.optionList=i.datarows,s.clickrow=i.clickrow,s.transclude=n}}};return t}).directive("selectedindex",function(){var t={restrict:"A",priority:491,compile:function(){return function(t,e){var n,i,s,o=e.data("uiDatagrid"),r=o.$container;r.on("selection.handsontable",function(e,o,r){n=!0,i=o,s=r,t.$$phase||void 0===t.selectedIndex||t.selectedIndex==o||t.$apply(function(){t.selectedIndex=o})}),r.on("deselect.handsontable",function(){n=!1,i=null,t.$$phase||void 0===t.selectedIndex||null==t.selectedIndex||t.$apply(function(){t.selectedIndex=null})}),t.$watch("selectedIndex",function(t){var e=1*t;if(t!==void 0&&null!==t&&e!==i){var n=s||0;r.handsontable("selectCell",e,n,e,n,!0)}},!1)}}};return t});var Handsontable={extension:{},helper:{}};(function(t,e,n){"use strict";function i(t){this.isCellEdited=!1,this.instance=t,this.originalValue="",this.row,this.col,this.prop,this.createElements(),this.bindEvents()}function s(e){this.isCellEdited=!1,this.instance=e,this.originalValue="",this.row,this.col,this.prop,this.createElements(),this.TEXTAREA.typeahead();var n=this.TEXTAREA.data("typeahead");this.typeahead=n,n._render=n.render,n._highlighter=n.highlighter,n.minLength=0,n.highlighter=n._highlighter,n.lookup=function(){var e;return this.query=this.$element.val(),e=t.isFunction(this.source)?this.source(this.query,t.proxy(this.process,this)):this.source,e?this.process(e):this},n.matcher=function(){return!0},this.bindEvents()}function o(t,e,i,s){n.helper.stringify(t.getDataAtCell(e,i))===n.helper.stringify(s.checkedTemplate)?t.setDataAtCell(e,i,s.uncheckedTemplate):t.setDataAtCell(e,i,s.checkedTemplate)}function r(){var e,i,s,o,r,a,l,c=this,h=5;this.beforeInit=function(){this.autoColumnWidths=[]},this.determineColumnWidth=function(c){i||(i=document.createElement("DIV"),i.className="handsontable",i.style.position="absolute",i.style.top="0",i.style.left="0",i.style.display="none",r=t("
")[0],i.appendChild(r),i.appendChild(document.createElement("BR")),o=t("
")[0],i.appendChild(o),i.appendChild(document.createElement("BR")),a=t('
')[0],i.appendChild(a),i.appendChild(document.createElement("BR")),l=t('
')[0],i.appendChild(l),document.body.appendChild(i),s=t(i),s.find("table").css({tableLayout:"auto",width:"auto"}));for(var u=e.countRows(),d={},p=0,f=0;u>f;f++){var g=n.helper.stringify(e.getDataAtCell(f,c)),m=g.length;m>p&&(p=m),d[m]||(d[m]={needed:h,strings:[]}),d[m].needed&&(d[m].strings.push(g),d[m].needed--)}var v=e.getSettings();v.colHeaders&&e.getColHeader(c,r.firstChild.firstChild.firstChild);var w="";for(var y in d)if(d.hasOwnProperty(y))for(var b=0,C=d[y].strings.length;C>b;b++)w+=d[y].strings[b]+"
";o.firstChild.firstChild.firstChild.innerHTML=w,t(l.firstChild.firstChild.firstChild).empty(),t(a.firstChild.firstChild.firstChild).empty(),i.style.display="block";var x=s.outerWidth(),S=e.getCellMeta(0,c);if(S.renderer){var R=9999999999;a.firstChild.firstChild.firstChild.innerHTML=R,S.renderer(e,l.firstChild.firstChild.firstChild,0,c,e.colToProp(c),R,S),x+=t(l).width()-t(a).width()}return i.style.display="none",x},this.determineColumnsWidth=function(){e=this;var t=this.getSettings();if(t.autoColumnSize||!t.colWidths)for(var n=this.countCols(),i=0;n>i;i++)this.autoColumnWidths[i]=c.determineColumnWidth(i)},this.getColWidth=function(t,e){this.autoColumnWidths[t]&&this.autoColumnWidths[t]>e.width&&(e.width=this.autoColumnWidths[t])}}function a(){var e,n=this;this.afterInit=function(){var e=this;this.getSettings().columnSorting&&(this.sortIndex=[],this.rootElement.on("click.handsontable",".columnSorting",function(i){var s=t(i.target);if(s.is(".columnSorting")){var o=s.closest("th").index();e.getSettings().rowHeaders&&o--,e.sortColumn===o?e.sortOrder=!e.sortOrder:(e.sortColumn=o,e.sortOrder=!0),n.sort.call(e),e.render()}}))},this.sort=function(){e=!1;var t=this;this.sortIndex.length=0;for(var n=0,i=this.countRows();i>n;n++)this.sortIndex.push([n,t.getDataAtCell(n,this.sortColumn)]);this.sortIndex.sort(function(e,n){return e[1]===n[1]?0:null===e[1]?1:null===n[1]?-1:e[1]n[1]?t.sortOrder?1:-1:0}),e=!0},this.translateRow=function(t){e&&this.sortIndex&&this.sortIndex.length&&(t.row=this.sortIndex[t.row][0])},this.getColHeader=function(e,n){this.getSettings().columnSorting&&t(n).find("span.colHeader").addClass("columnSorting")}}function l(){function e(t){var e=o.getSelected();if(e)switch(t){case"row_above":o.alter("insert_row",e[0]);break;case"row_below":o.alter("insert_row",e[2]+1);break;case"col_left":o.alter("insert_col",e[1]);break;case"col_right":o.alter("insert_col",e[3]+1);break;case"remove_row":o.alter(t,e[0],e[2]);break;case"remove_col":o.alter(t,e[1],e[3]);break;case"undo":o.undo();break;case"redo":o.redo()}}function n(t){return o.countRows()>=o.getSettings().maxRows&&("row_above"===t||"row_below"===t)?!0:o.countCols()>=o.getSettings().maxCols&&("col_left"===t||"col_right"===t)?!0:!1}var i,s,o=this,r={selector:"#"+o.rootElement.attr("id")+" table, #"+o.rootElement.attr("id")+" div",trigger:"right",callback:e},a={row_above:{name:"Insert row above",disabled:n},row_below:{name:"Insert row below",disabled:n},hsep1:"---------",col_left:{name:"Insert column on the left",disabled:n},col_right:{name:"Insert column on the right",disabled:n},hsep2:"---------",remove_row:{name:"Remove row",disabled:n},remove_col:{name:"Remove column",disabled:n},hsep3:"---------",undo:{name:"Undo",disabled:function(){return!o.isUndoAvailable()}},redo:{name:"Redo",disabled:function(){return!o.isRedoAvailable()}}},l={},c=o.getSettings();if(c.contextMenu){if(c.contextMenu===!0)l.items=a;else if("[object Array]"===Object.prototype.toString.apply(c.contextMenu))for(l.items={},i=0,s=c.contextMenu.length;s>i;i++){var h=c.contextMenu[i];if(a[h]===void 0)throw Error('Context menu key "'+h+'" is not recognised');l.items[h]=a[h]}else if("[object Object]"===Object.prototype.toString.apply(c.contextMenu)){if(l=c.contextMenu,l.items)for(i in l.items)l.items.hasOwnProperty(i)&&a[i]&&(l.items[i]="string"==typeof l.items[i]?a[i]:t.extend(!0,a[i],l.items[i]));else l.items=a;if(l.callback){var u=r.callback,d=l.callback;l.callback=function(t,e){u(t,e),d(t,e)}}}if(!o.rootElement.attr("id"))throw Error("Handsontable container must have an id");t.contextMenu(t.extend(!0,r,l))}}function c(){var e,n,i,s,o,r,a=t('
');a.css({position:"absolute",top:"25px",left:0,width:"10px",height:"10px",backgroundColor:"#CCC",opacity:.7}),t(document).mousemove(function(t){n&&(a[0].style.left=r+t.pageX-o+6+"px","none"===a[0].style.display&&(a[0].style.display="block"))}),t(document).mouseup(function(){n&&(s>i&&s--,e.getSettings().rowHeaders&&(i--,s--),e.manualColumnPositions.splice(s,0,e.manualColumnPositions.splice(i,1)[0]),t(".manualColumnMover.active").removeClass("active"),n=!1,e.forceFullRender=!0,e.view.render(),a[0].style.display="none")}),this.beforeInit=function(){this.manualColumnPositions=[]},this.afterInit=function(){if(this.getSettings().manualColumnMove){var l=this;this.rootElement.on("mousedown.handsontable",".manualColumnMover",function(s){e=l;var c=t(s.target),h=c.closest("th");i=h.index(),n=!0,o=s.pageX;var u=l.rootElement.find(".htCore");a.appendTo(u.parent()),a.width(c.parent().width()),a.height(u.height()),r=parseInt(h.offset().left-u.offset().left),a[0].style.left=r+6+"px"}),this.rootElement.on("mouseenter.handsontable","td, th",function(){if(n){t(".manualColumnMover.active").removeClass("active");var e=l.rootElement.find("thead th");s=t(this).index();var i=e.eq(s).find(".manualColumnMover").addClass("active");e.not(i).removeClass("active")}})}},this.modifyCol=function(t){return this.getSettings().manualColumnMove?(this.manualColumnPositions[t]===void 0&&(this.manualColumnPositions[t]=t),this.manualColumnPositions[t]):t},this.getColHeader=function(t,e){if(this.getSettings().manualColumnMove){var n=document.createElement("DIV");n.className="manualColumnMover",e.firstChild.appendChild(n)}}}function h(){var e,n,i,s,o,r,a,l,c=t('
');c.css({position:"absolute",top:0,left:0,width:0,borderRight:"1px dashed #777"}),t(document).mousemove(function(t){e&&(i=a+(t.pageX-r),h(n,i),c[0].style.left=l+i-1+"px","none"===c[0].style.display&&(c[0].style.display="block"))}),t(document).mouseup(function(){e&&(t(".manualColumnResizer.active").removeClass("active"),e=!1,s.forceFullRender=!0,s.view.render(),c[0].style.display="none")}),t(document).dblclick(function(e){t(e.target).is(".manualColumnResizer")&&h(n,R.determineColumnWidth.call(s,n))}),this.beforeInit=function(){this.manualColumnWidths=[]},this.afterInit=function(){if(this.getSettings().manualColumnResize){var h=this;this.rootElement.on("mousedown.handsontable",".manualColumnResizer",function(u){s=h;var d=t(u.target);n=d.attr("rel"),o=h.rootElement.find("col").eq(d.parent().parent().index()),e=!0,r=u.pageX,a=o.width(),i=a,d.addClass("active");var p=h.rootElement.find(".htCore");c.appendTo(p.parent()).height(p.height()),l=parseInt(d.parent().parent().offset().left-p.offset().left),c[0].style.left=l+i-1+"px"})}};var h=function(t,e){e=Math.max(e,20),e=Math.min(e,500),s.manualColumnWidths[t]=e};this.getColHeader=function(e,n){if(this.getSettings().manualColumnResize){var i=document.createElement("DIV");i.className="manualColumnResizer",t(i).attr("rel",e),n.firstChild.appendChild(i)}},this.getColWidth=function(t,e){this.getSettings().manualColumnResize&&this.manualColumnWidths[t]&&(e.width=this.manualColumnWidths[t])}}function u(t,e){this.instance=t,this.settings=e,this.wtDom=this.instance.wtDom,this.main=document.createElement("div"),this.main.style.position="absolute",this.main.style.top=0,this.main.style.left=0;for(var n=0;5>n;n++){var i=document.createElement("DIV");i.className="wtBorder "+(e.className||""),i.style.backgroundColor=e.border.color,i.style.height=e.border.width+"px",i.style.width=e.border.width+"px",this.main.appendChild(i)}this.top=this.main.childNodes[0],this.left=this.main.childNodes[1],this.bottom=this.main.childNodes[2],this.right=this.main.childNodes[3],this.corner=this.main.childNodes[4],this.corner.className+=" corner",this.corner.style.width="5px",this.corner.style.height="5px",this.corner.style.border="2px solid #FFF",this.disappear(),t.wtTable.hider.appendChild(this.main)}function d(t){var e=[];if(this.wtSettings=new w(this,t),this.wtDom=new p(this),this.wtTable=new y(this),this.wtScroll=new g(this),this.wtWheel=new b(this),this.wtEvent=new f(this),this.wtTable.THEAD.childNodes.length&&this.wtTable.THEAD.childNodes[0].childNodes.length){for(var n=0,i=this.wtTable.THEAD.childNodes[0].childNodes.length;i>n;n++)e.push(this.wtTable.THEAD.childNodes[0].childNodes[n].innerHTML);this.hasSetting("columnHeaders")||this.update("columnHeaders",function(t,n){n.innerHTML=e[t]})}this.selections={};var s=this.getSetting("selections");if(s)for(var o in s)s.hasOwnProperty(o)&&(this.selections[o]=new v(this,s[o]));this.drawn=!1}function p(t){t&&(this.instance=t),this.tdCache=[]}function f(e){var n=this;this.instance=e,this.wtDom=this.instance.wtDom;var i,s=[null,null,null,null],o=null,r=function(t){var e=n.parentCell(t.target);e.TD&&"TD"===e.TD.nodeName?n.instance.hasSetting("onCellMouseDown")&&n.instance.getSetting("onCellMouseDown",t,e.coords,e.TD):n.wtDom.hasClass(t.target,"corner")&&n.instance.getSetting("onCellCornerMouseDown",t,t.target),2!==t.button&&(e.TD&&"TD"===e.TD.nodeName?(s.shift(),s.push(e.TD)):n.wtDom.hasClass(t.target,"corner")&&(s.shift(),s.push(t.target)))},a=function(t){if(n.instance.hasSetting("onCellMouseOver")){var e=n.wtDom.closest(t.target,["TD","TH"]);e&&e!==i&&(i=e,"TD"===e.nodeName&&n.instance.getSetting("onCellMouseOver",t,n.instance.wtTable.getCoords(e),e))}},l=function(t){if(2!==t.button){var e=n.parentCell(t.target);e.TD&&"TD"===e.TD.nodeName?(s.shift(),s.push(e.TD)):(s.shift(),s.push(t.target)),null!==s[3]&&s[3]===s[2]&&(o&&s[2]===s[1]&&s[1]===s[0]?(e.TD?n.instance.getSetting("onCellDblClick",t,e.coords,e.TD):n.wtDom.hasClass(t.target,"corner")&&n.instance.getSetting("onCellCornerDblClick",t,e.coords,e.TD),clearTimeout(o),o=null):(clearTimeout(o),o=setTimeout(function(){o=null},500)))}};t(this.instance.wtTable.parent).on("mousedown",r),t(this.instance.wtTable.TABLE).on("mouseover",a),t(this.instance.wtTable.parent).on("mouseup",l)}function g(t){this.instance=t,this.wtScrollbarV=new m(t,"vertical"),this.wtScrollbarH=new m(t,"horizontal")}function m(e,n){var i=this;this.instance=e,this.type=n,this.$table=t(this.instance.wtTable.TABLE),this.slider=document.createElement("DIV"),this.slider.style.position="absolute",this.slider.style.top="0",this.slider.style.left="0",this.slider.style.display="none",this.slider.className="dragdealer "+n,this.handle=document.createElement("DIV"),this.handle.className="handle",this.slider.appendChild(this.handle),this.instance.wtTable.parent.appendChild(this.slider);var s=!0;this.dragTimeout=null;var o,r=function(){i.onScroll(o)};this.dragdealer=new L(this.slider,{vertical:"vertical"===n,horizontal:"horizontal"===n,speed:100,yPrecision:100,animationCallback:function(t,e){return s?(s=!1,void 0):(i.skipRefresh=!0,o="vertical"===n?e:t,null===i.dragTimeout&&(i.dragTimeout=setInterval(r,100),r()),void 0)},callback:function(t,e){i.skipRefresh=!1,clearInterval(i.dragTimeout),i.dragTimeout=null,o="vertical"===n?e:t,i.onScroll(o)}}),i.skipRefresh=!1}function v(t,e){this.instance=t,this.settings=e,this.selected=[],this.wtDom=new p(this.instance),e.border&&(this.border=new u(t,e))}function w(t,e){var n=this;this.instance=t,this.defaults={table:void 0,async:!1,scrollH:"auto",scrollV:"auto",stretchH:"hybrid",currentRowClassName:null,currentColumnClassName:null,data:void 0,offsetRow:0,offsetColumn:0,frozenColumns:null,columnHeaders:null,totalRows:void 0,totalColumns:void 0,width:null,height:null,cellRenderer:function(t,e,i){var s=n.getSetting("data",t,e);i.innerHTML=void 0!==s?s:""},columnWidth:50,selections:null,onCellMouseDown:null,onCellMouseOver:null,onCellDblClick:null,onCellCornerMouseDown:null,onCellCornerDblClick:null,onDraw:null,scrollbarWidth:10,scrollbarHeight:10},this.settings={};for(var i in this.defaults)if(this.defaults.hasOwnProperty(i))if(void 0!==e[i])this.settings[i]=e[i];else{if(void 0===this.defaults[i])throw Error('A required setting "'+i+'" was not provided');this.settings[i]=this.defaults[i]}this.rowHeightCache=[]}function y(e){this.instance=e,this.TABLE=this.instance.getSetting("table"),this.wtDom=this.instance.wtDom,this.wtDom.removeTextNodes(this.TABLE),this.hasEmptyCellProblem=t.browser.msie&&7>=parseInt(t.browser.version,10),this.hasCellSpacingProblem=t.browser.msie&&7>=parseInt(t.browser.version,10),this.hasCellSpacingProblem&&(this.TABLE.cellSpacing=0),this.TABLE.setAttribute("tabindex",1e4),this.visibilityStartRow=this.visibilityStartColumn=this.visibilityEdgeRow=this.visibilityEdgeColumn=null;var n=this.TABLE.parentNode;if(!n||1!==n.nodeType||!this.wtDom.hasClass(n,"wtHolder")){var i=document.createElement("DIV");this.instance.hasSetting("width")&&this.instance.hasSetting("height")&&(i.style.position="absolute",i.style.top="0",i.style.left="0",i.style.width="4000px",i.style.height="4000px"),i.className="wtSpreader",n&&n.insertBefore(i,this.TABLE),i.appendChild(this.TABLE)}if(this.spreader=this.TABLE.parentNode,n=this.spreader.parentNode,!n||1!==n.nodeType||!this.wtDom.hasClass(n,"wtHolder")){var s=document.createElement("DIV");s.style.position="relative",s.className="wtHider",n&&n.insertBefore(s,this.spreader),s.appendChild(this.spreader)}if(this.hider=this.spreader.parentNode,n=this.hider.parentNode,!n||1!==n.nodeType||!this.wtDom.hasClass(n,"wtHolder")){var o=document.createElement("DIV");o.style.position="relative",o.className="wtHolder",n&&n.insertBefore(o,this.hider),o.appendChild(this.hider)}if(this.parent=this.hider.parentNode,this.TBODY=this.TABLE.getElementsByTagName("TBODY")[0],this.TBODY||(this.TBODY=document.createElement("TBODY"),this.TABLE.appendChild(this.TBODY)),this.THEAD=this.TABLE.getElementsByTagName("THEAD")[0],this.THEAD||(this.THEAD=document.createElement("THEAD"),this.TABLE.insertBefore(this.THEAD,this.TBODY)),this.COLGROUP=this.TABLE.getElementsByTagName("COLGROUP")[0],this.COLGROUP||(this.COLGROUP=document.createElement("COLGROUP"),this.TABLE.insertBefore(this.COLGROUP,this.THEAD)),this.instance.hasSetting("columnHeaders")&&!this.THEAD.childNodes.length){var r=document.createElement("TR");this.THEAD.appendChild(r)}this.colgroupChildrenLength=this.COLGROUP.childNodes.length,this.theadChildrenLength=this.THEAD.firstChild?this.THEAD.firstChild.childNodes.length:0,this.tbodyChildrenLength=this.TBODY.childNodes.length}function b(e){var n=this;this.instance=e;var i;t(this.instance.wtTable.TABLE).on("mousewheel",function(t,e,s,o){clearTimeout(i),i=setTimeout(function(){o?n.instance.scrollVertical(-Math.ceil(o)).draw():s&&n.instance.scrollHorizontal(Math.ceil(s)).draw()},0),t.preventDefault()})}function C(t){var e=this;t=t||document.body,this.elDiv=document.createElement("DIV"),this.elDiv.style.position="fixed",this.elDiv.style.top=0,this.elDiv.style.left=0,t.appendChild(this.elDiv),this.elTextarea=document.createElement("TEXTAREA"),this.elTextarea.className="copyPaste",this.elTextarea.style.width="100px",this.elTextarea.style.height="100px",this.elDiv.appendChild(this.elTextarea),this.elTextarea.style.opacity!==void 0&&(this.elTextarea.style.opacity=0),this._bindEvent(t,"keydown",function(t){var n=!1;t.metaKey?n=!0:t.ctrlKey&&-1===navigator.userAgent.indexOf("Mac")&&(n=!0),!n||67!==t.keyCode&&86!==t.keyCode&&88!==t.keyCode||(e.selectNodeText(e.elTextarea),88===t.keyCode?setTimeout(function(){e.triggerCut(t)},0):86===t.keyCode&&setTimeout(function(){e.triggerPaste(t)},0))})}n.Core=function(i,s){this.rootElement=i;var o,r,a,l,c,h,u,d=this;o={settings:{},selStart:new n.SelectionPoint,selEnd:new n.SelectionPoint,editProxy:!1,isPopulated:null,scrollable:null,undoRedo:null,extensions:{},colToProp:null,propToCol:null,dataSchema:null,dataType:"array",firstRun:!0},r={recursiveDuckSchema:function(e){var n;if(t.isPlainObject(e)){n={};for(var i in e)e.hasOwnProperty(i)&&(n[i]=t.isPlainObject(e[i])?r.recursiveDuckSchema(e[i]):null)}else n=[];return n},recursiveDuckColumns:function(e,n,i){var s,a;if(n===void 0&&(n=0,i=""),t.isPlainObject(e))for(a in e)e.hasOwnProperty(a)&&(null===e[a]?(s=i+a,o.colToProp.push(s),o.propToCol[s]=n,n++):n=r.recursiveDuckColumns(e[a],n,a+"."));return n},createMap:function(){if(r.getSchema()===void 0)throw Error("trying to create `columns` definition but you didnt' provide `schema` nor `data`");var t,e,n=r.getSchema();if(o.colToProp=[],o.propToCol={},o.settings.columns)for(t=0,e=o.settings.columns.length;e>t;t++)o.colToProp[t]=o.settings.columns[t].data,o.propToCol[o.settings.columns[t].data]=t;else r.recursiveDuckColumns(n)},colToProp:function(t){return t=n.PluginModifiers.run(d,"col",t),o.colToProp&&o.colToProp[t]!==void 0?o.colToProp[t]:t},propToCol:function(t){var e;return e=o.propToCol[t]!==void 0?o.propToCol[t]:t,e=n.PluginModifiers.run(d,"col",e)},getSchema:function(){return o.settings.dataSchema?"function"==typeof o.settings.dataSchema?o.settings.dataSchema():o.settings.dataSchema:o.duckDataSchema},createRow:function(e){var n;if("array"===o.dataType){n=[];for(var i=0,s=d.countCols();s>i;i++)n.push(null)}else n=t.extend(!0,{},r.getSchema());!e||e.row>=d.countRows()?(o.settings.onCreateRow&&o.settings.onCreateRow(d.countRows(),n),o.settings.data.push(n)):(o.settings.onCreateRow&&o.settings.onCreateRow(e.row,n),o.settings.data.splice(e.row,0,n)),d.forceFullRender=!0},createCol:function(t){if("object"===o.dataType||o.settings.columns)throw Error("Cannot create new column. When data source in an object, you can only have as much columns as defined in first data row, data schema or in the 'columns' setting");var e=0,n=d.countRows();if(!t||t.col>=d.countCols())for(;n>e;e++)o.settings.data[e]===void 0&&(o.settings.data[e]=[]),o.settings.data[e].push("");else for(;n>e;e++)o.settings.data[e].splice(t.col,0,"");d.forceFullRender=!0},removeRow:function(t,e){t&&t.row!==d.countRows()-1?o.settings.data.splice(t.row,e.row-t.row+1):o.settings.data.pop(),d.forceFullRender=!0},removeCol:function(t,e){if("object"===o.dataType||o.settings.columns)throw Error("cannot remove column with object data source or columns option specified");var n=0;if(t&&t.col!==d.countCols()-1)for(var i=e.col-t.col+1;d.countRows()>n;n++)o.settings.data[n].splice(t.col,i);else for(;d.countRows()>n;n++)o.settings.data[n].pop();d.forceFullRender=!0},getVars:{},get:function(t,e){if(r.getVars.row=t,r.getVars.prop=e,n.PluginHooks.run(d,"beforeGet",r.getVars),"string"==typeof r.getVars.prop&&r.getVars.prop.indexOf(".")>-1){var i=r.getVars.prop.split("."),s=o.settings.data[r.getVars.row];if(!s)return null;for(var a=0,l=i.length;l>a;a++)if(s=s[i[a]],s===void 0)return null;return s}return o.settings.data[r.getVars.row]?o.settings.data[r.getVars.row][r.getVars.prop]:null},setVars:{},set:function(t,e,i){if(r.setVars.row=t,r.setVars.prop=e,r.setVars.value=i,n.PluginHooks.run(d,"beforeSet",r.setVars),"string"==typeof r.setVars.prop&&r.setVars.prop.indexOf(".")>-1){for(var s=r.setVars.prop.split("."),a=o.settings.data[r.setVars.row],l=0,c=s.length-1;c>l;l++)a=a[s[l]];a[s[l]]=r.setVars.value}else o.settings.data[r.setVars.row][r.setVars.prop]=r.setVars.value},clear:function(){for(var t=0;d.countRows()>t;t++)for(var e=0;d.countCols()>e;e++)r.set(t,r.colToProp(e),"")},getAll:function(){return o.settings.data},getRange:function(t,e){var n,i,s,o,a,l=[];for(i=Math.max(t.row,e.row),o=Math.max(t.col,e.col),n=Math.min(t.row,e.row);i>=n;n++){for(a=[],s=Math.min(t.col,e.col);o>=s;s++)a.push(r.get(n,r.colToProp(s)));l.push(a)}return l},getText:function(t,e){return SheetClip.stringify(r.getRange(t,e))}},a={alter:function(e,n,i){var s,c,h,u,f,g,m;switch(s=t.extend(!0,[],r.getAll()),e){case"insert_row":d.countRows()=n.row?(o.selStart.row(o.selStart.row()+1),l.transformEnd(1,0)):l.refreshBorders());break;case"insert_col":d.countCols()=n.col?(o.selStart.col(o.selStart.col()+1),l.transformEnd(0,1)):l.refreshBorders());break;case"remove_row":r.removeRow(n,i),a.keepEmptyRows(),l.refreshBorders();break;case"remove_col":r.removeCol(n,i),a.keepEmptyRows(),l.refreshBorders()}for(h=[],c=r.getAll(),u=0,f=c.length;f>u;u++)for(g=0,m=c[u].length;m>g;g++)h.push([u,g,s[u]?s[u][g]:null,c[u][g]]);p("datachange.handsontable",[h,"alter"]),a.keepEmptyRows()},keepEmptyRows:function(){var t,e,n,i,s,a=0,c=0;t:for(t=d.countRows()-1;t>=0;t--){for(e=0,i=d.countCols();i>e;e++)if(s=r.get(t,r.colToProp(e)),""!==s&&null!==s&&s!==void 0)break t;a++}if(n=d.countRows(),o.settings.minRows>n)for(t=0;o.settings.minRows-n>t;t++)r.createRow();if(o.settings.minSpareRows>a)for(;o.settings.minSpareRows>a&&d.countRows()0)t:for(e=d.countCols()-1;e>=0;e--){for(t=0;d.countRows()>t;t++)if(s=r.get(t,r.colToProp(e)),""!==s&&null!==s&&s!==void 0)break t;c++}if(!o.settings.columns&&d.countCols()c)for(;o.settings.minSpareCols>c&&d.countCols()o.settings.minRows&&o.settings.minSpareRows&&a>o.settings.minSpareRows;a--)r.removeRow();if(o.settings.enterBeginsEditing&&!o.settings.columns)for(;(o.settings.minCols||o.settings.minSpareCols)&&d.countCols()>o.settings.minCols&&o.settings.minSpareCols&&c>o.settings.minSpareCols;c--)r.removeCol();var h=d.countRows(),u=d.countCols();if((0===h||0===u)&&l.deselect(),o.selStart.exists()){var p,f=o.selStart.row(),g=o.selStart.col(),m=o.selEnd.row(),v=o.selEnd.col();f>h-1?(f=h-1,p=!0,m>f&&(m=f)):m>h-1&&(m=h-1,p=!0,f>m&&(f=m)),g>u-1?(g=u-1,p=!0,v>g&&(v=g)):v>u-1&&(v=u-1,p=!0,g>v&&(g=v)),p&&d.selectCell(f,g,m,v)}},populateFromArray:function(t,e,n,i){var s,a,l,c,h=[],u={};if(a=e.length,0===a)return!1;for(u.row=t.row,u.col=t.col,s=0;a>s&&!(n&&u.row>n.row||!o.settings.minSpareRows&&u.row>d.countRows()-1||u.row>=o.settings.maxRows);s++){for(u.col=t.col,c=e[s]?e[s].length:0,l=0;c>l&&!(n&&u.col>n.col||!o.settings.minSpareCols&&u.col>d.countCols()-1||u.col>=o.settings.maxCols);l++){if(d.getCellMeta(u.row,u.col).isWritable){var p=r.colToProp(u.col);h.push([u.row,p,e[s][l]])}u.col++,n&&l===c-1&&(l=-1)}u.row++,n&&s===a-1&&(s=-1)}d.setDataAtCell(h,null,null,i||"populateFromArray")},getCornerCoords:function(e){function n(e,n,i){function s(t){return t[i]}return Array.prototype.map?e.apply(Math,n.map(s)):e.apply(Math,t.map(n,s))}return{TL:{row:n(Math.min,e,"row"),col:n(Math.min,e,"col")},BR:{row:n(Math.max,e,"row"),col:n(Math.max,e,"col")}}},getCellsAtCoords:function(t,e){var n,i,s=a.getCornerCoords([t,e]),o=[];for(n=s.TL.row;s.BR.row>=n;n++)for(i=s.TL.col;s.BR.col>=i;i++)o.push(d.view.getCellAtCoords({row:n,col:i}));return o}},this.selection=l={setRangeStart:function(t){l.deselect(),o.selStart.coords(t),l.setRangeEnd(t)},setRangeEnd:function(t,e){o.selEnd.coords(t),o.settings.multiSelect||o.selStart.coords(t),d.view.wt.selections.current.clear(),d.view.wt.selections.current.add(o.selStart.arr()),d.view.wt.selections.area.clear(),l.isMultiple()&&(d.view.wt.selections.area.add(o.selStart.arr()),d.view.wt.selections.area.add(o.selEnd.arr())),d.rootElement.triggerHandler("selection.handsontable",[o.selStart.row(),o.selStart.col(),o.selEnd.row(),o.selEnd.col()]),d.rootElement.triggerHandler("selectionbyprop.handsontable",[o.selStart.row(),r.colToProp(o.selStart.col()),o.selEnd.row(),r.colToProp(o.selEnd.col())]),e!==!1&&(d.view.scrollViewport(t),d.view.wt.draw(!0),d.view.scrollViewport(t)),l.refreshBorders()},refreshBorders:function(t,e){e||c.destroy(t),d.view.render(),l.isSelected()&&!e&&c.prepare()},isMultiple:function(){return!(o.selEnd.col()===o.selStart.col()&&o.selEnd.row()===o.selStart.row())},transformStart:function(t,e,n){o.selStart.row()+t>d.countRows()-1?n&&o.settings.minSpareRows>0?d.alter("insert_row",d.countRows()):o.settings.autoWrapCol&&o.selStart.col()+eo.selStart.row()+t&&o.selStart.col()+e>=0&&(t=d.countRows()-1,e=-1),o.selStart.col()+e>d.countCols()-1?n&&o.settings.minSpareCols>0?d.alter("insert_col",d.countCols()):o.settings.autoWrapRow&&o.selStart.row()+to.selStart.col()+e&&o.selStart.row()+t>=0&&(t=-1,e=d.countCols()-1);var i=d.countRows(),s=d.countCols(),r={row:o.selStart.row()+t,col:o.selStart.col()+e};0>r.row?r.row=0:r.row>0&&r.row>=i&&(r.row=i-1),0>r.col?r.col=0:r.col>0&&r.col>=s&&(r.col=s-1),l.setRangeStart(r)},transformEnd:function(t,e){if(o.selEnd.exists()){var n=d.countRows(),i=d.countCols(),s={row:o.selEnd.row()+t,col:o.selEnd.col()+e}; diff --git a/package.json b/package.json index 951d2c08..19fe4bc5 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "url": "https://github.com/warpech/angular-ui-handsontable/issues" }, "author": "Marcin Warpechowski ", - "version": "0.3.3", + "version": "0.3.4", "devDependencies": { "grunt": "~0.4.0", "grunt-css": "~0.5.4",