Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-table-resize

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-table-resize - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

0

bower.json

@@ -0,0 +0,0 @@ {

12

dist/angular-table-resize.js

@@ -62,3 +62,3 @@ angular.module("ngTableResize", []);

function resetTable(table) {
$(table).width('100%');
$(table).outerWidth('100%');
$(table).find('th').width('auto');

@@ -81,3 +81,2 @@ }

resizer = new ResizeModel(table, columns, container);
console.log("Resizer", resizer);

@@ -109,3 +108,2 @@ // Load column sized from saved storage

resetTable(table);
//console.error("No table size settings found");
return;

@@ -119,3 +117,2 @@ }

var cacheWidth = cache[id];
//console.log("Set " + id + " to " + cacheWidth);
$(column).css({ width: cacheWidth });

@@ -305,3 +302,3 @@ })

// Table is by default 100% width
$(this.table).width('100%');
$(this.table).outerWidth('100%');
};

@@ -457,7 +454,2 @@

FixedResizer.prototype.onTableReady = function() {
// For mode fixed, make table 100% width always
$(this.table).width('100%');
};
FixedResizer.prototype.handles = function() {

@@ -464,0 +456,0 @@ // Mode fixed does not require handler on last column

2

dist/angular-table-resize.min.js

@@ -1,1 +0,1 @@

angular.module("ngTableResize",[]),angular.module("ngTableResize").directive("resizeable",["resizeStorage","$injector",function(t,n){function e(t,n,e){g=n,z=t.container?$(t.container):$(g).parent(),$(g).addClass("resize"),a(g,e,t),o(g,e,t),i(g,e,t)}function o(t,n,e){void 0!==e.bind&&(e.bind={update:function(){r(t),a(t,n,e)}})}function i(t,n,e){e.$watch(function(){return e.mode},function(){r(t),a(t,n,e)})}function r(t){C=!0,s(t)}function u(t){$(t).width("100%"),$(t).find("th").width("auto")}function s(t){$(t).find("th").find(".handle").remove()}function a(n,e,o){y=$(n).find("th"),v=o.mode;var i=f(o);i&&(R=new i(n,y,z),console.log("Resizer",R),T=t.loadTableSizes(n,o.mode),b=R.handles(y),w=R.ctrlColumns,R.setup(),c(T),b.each(function(t,e){l(n,e)}))}function c(t){return t?($(g).width("auto"),w.each(function(n,e){var o=$(e).attr("id"),i=t[o];$(e).css({width:i})}),void R.onTableReady()):void u(g)}function l(t,n){var e=$("<div>",{"class":"handle"});$(n).prepend(e);var o=R.handleMiddleware(e,n);d(t,e,o)}function d(t,n,e){$(n).mousedown(function(t){C&&(R.onFirstDrag(e,n),R.onTableReady(),C=!1);var o={};R.intervene&&(o=R.intervene.selector(e),o.column=o,o.orgWidth=$(o).width()),t.preventDefault(),$(n).addClass("active"),$("body").addClass("table-resize");var i=t.clientX,r=$(e).width();$(window).mousemove(h(e,i,r,o)),$(window).one("mouseup",p(n))})}function h(t,n,e,o){return function(i){var r=i.clientX,u=r-n,s=R.calculate(e,u);if(!R.restrict(s)){if(R.intervene){var a=R.intervene.calculator(o.orgWidth,u);if(R.intervene.restrict(a))return;$(o).width(a)}$(t).width(s)}}}function f(t){try{var e=n.get(t.mode);return e}catch(o){return console.error("The resizer "+t.mode+" was not found"),null}}function p(t){return function(){$(t).removeClass("active"),$(window).unbind("mousemove"),$("body").removeClass("table-resize"),R.onEndDrag(),m()}}function m(){T||(T={}),$(y).each(function(t,n){var e=$(n).attr("id");e&&(T[e]=R.saveAttr(n))}),t.saveTableSizes(g,v,T)}var v,y=null,w=null,b=null,g=null,z=null,R=null,C=!0,T=null;return{restrict:"A",link:e,scope:{mode:"=",bind:"=",container:"@"}}}]),angular.module("ngTableResize").service("resizeStorage",["$window",function(t){function n(t,n){var o=t.attr("id");return o?e+"."+t.attr("id")+"."+n:void console.error("Table has no id",t)}var e="ngColumnResize";this.loadTableSizes=function(e,o){var i=n(e,o),r=t.localStorage.getItem(i);return JSON.parse(r)},this.saveTableSizes=function(e,o,i){var r=n(e,o);if(r){var u=JSON.stringify(i);t.localStorage.setItem(r,u)}}}]),angular.module("ngTableResize").factory("ResizerModel",[function(){function t(t,n,e){this.minWidth=25,this.table=t,this.columns=n,this.container=e,this.handleColumns=this.handles(),this.ctrlColumns=this.ctrlColumns()}return t.prototype.setup=function(){$(this.container).css({overflowX:"hidden"})},t.prototype.onTableReady=function(){$(this.table).width("100%")},t.prototype.handles=function(){return this.columns},t.prototype.ctrlColumns=function(){return this.handleColumns},t.prototype.onFirstDrag=function(){$(this.ctrlColumns).each(function(t,n){$(n).width($(n).width())})},t.prototype.handleMiddleware=function(t,n){return n},t.prototype.restrict=function(t){return t<this.minWidth},t.prototype.calculate=function(t,n){return t+n},t.prototype.onEndDrag=function(){},t.prototype.saveAttr=function(t){return $(t).outerWidth()},t}]),angular.module("ngTableResize").factory("BasicResizer",["ResizerModel",function(t){function n(n,r,u){t.call(this,n,r,u),this.ctrlColumns=this.columns,this.intervene={selector:e,calculator:o,restrict:i}}function e(t){return $(t).next()}function o(t,n){return t-n}function i(t){return t<25}return n.prototype=Object.create(t.prototype),n.prototype.setup=function(){$(this.container).css({overflowX:"hidden"}),$(this.columns).first().css({width:"auto"})},n.prototype.handles=function(){return $(this.columns).not(":last")},n.prototype.onFirstDrag=function(){$(this.columns).each(function(t,n){$(n).width($(n).width())})},n.prototype.onEndDrag=function(){var t=$(this.table).outerWidth(),n=0;$(this.columns).each(function(e,o){var i=$(o).outerWidth(),r=i/t*100+"%";n+=i/t*100,$(o).css({width:r})})},n.prototype.saveAttr=function(t){return $(t)[0].style.width},n}]),angular.module("ngTableResize").factory("FixedResizer",["ResizerModel",function(t){function n(n,e,o){t.call(this,n,e,o),this.fixedColumn=$(n).find("th").first(),this.bound=!1}return n.prototype=Object.create(t.prototype),n.prototype.setup=function(){$(this.container).css({overflowX:"hidden"}),$(this.columns).first().css({width:"auto"})},n.prototype.onTableReady=function(){$(this.table).width("100%")},n.prototype.handles=function(){return $(this.columns).not(":last")},n.prototype.ctrlColumns=function(){return $(this.columns).not(":first")},n.prototype.onFirstDrag=function(){$(this.ctrlColumns).each(function(t,n){$(n).width($(n).width())})},n.prototype.handleMiddleware=function(t,n){return $(n).next()},n.prototype.restrict=function(t){return this.bound?!(t<this.bound)||($(this.fixedColumn).width("auto"),this.bound=!1,!1):t<this.minWidth||($(this.fixedColumn).width()<=this.minWidth?(this.bound=t,$(this.fixedColumn).width(this.minWidth),!0):void 0)},n.prototype.calculate=function(t,n){return t-n},n}]),angular.module("ngTableResize").factory("OverflowResizer",["ResizerModel",function(t){function n(n,e,o){t.call(this,n,e,o)}return n.prototype=Object.create(t.prototype),n.prototype.setup=function(){$(this.container).css({overflow:"auto"})},n.prototype.onTableReady=function(){$(this.table).width(1)},n}]);
angular.module("ngTableResize",[]),angular.module("ngTableResize").directive("resizeable",["resizeStorage","$injector",function(t,n){function e(t,n,e){g=n,z=t.container?$(t.container):$(g).parent(),$(g).addClass("resize"),a(g,e,t),o(g,e,t),i(g,e,t)}function o(t,n,e){void 0!==e.bind&&(e.bind={update:function(){r(t),a(t,n,e)}})}function i(t,n,e){e.$watch(function(){return e.mode},function(){r(t),a(t,n,e)})}function r(t){R=!0,s(t)}function u(t){$(t).outerWidth("100%"),$(t).find("th").width("auto")}function s(t){$(t).find("th").find(".handle").remove()}function a(n,e,o){y=$(n).find("th"),v=o.mode;var i=f(o);i&&(C=new i(n,y,z),T=t.loadTableSizes(n,o.mode),b=C.handles(y),w=C.ctrlColumns,C.setup(),c(T),b.each(function(t,e){l(n,e)}))}function c(t){return t?($(g).width("auto"),w.each(function(n,e){var o=$(e).attr("id"),i=t[o];$(e).css({width:i})}),void C.onTableReady()):void u(g)}function l(t,n){var e=$("<div>",{"class":"handle"});$(n).prepend(e);var o=C.handleMiddleware(e,n);d(t,e,o)}function d(t,n,e){$(n).mousedown(function(t){R&&(C.onFirstDrag(e,n),C.onTableReady(),R=!1);var o={};C.intervene&&(o=C.intervene.selector(e),o.column=o,o.orgWidth=$(o).width()),t.preventDefault(),$(n).addClass("active"),$("body").addClass("table-resize");var i=t.clientX,r=$(e).width();$(window).mousemove(h(e,i,r,o)),$(window).one("mouseup",p(n))})}function h(t,n,e,o){return function(i){var r=i.clientX,u=r-n,s=C.calculate(e,u);if(!C.restrict(s)){if(C.intervene){var a=C.intervene.calculator(o.orgWidth,u);if(C.intervene.restrict(a))return;$(o).width(a)}$(t).width(s)}}}function f(t){try{var e=n.get(t.mode);return e}catch(o){return console.error("The resizer "+t.mode+" was not found"),null}}function p(t){return function(){$(t).removeClass("active"),$(window).unbind("mousemove"),$("body").removeClass("table-resize"),C.onEndDrag(),m()}}function m(){T||(T={}),$(y).each(function(t,n){var e=$(n).attr("id");e&&(T[e]=C.saveAttr(n))}),t.saveTableSizes(g,v,T)}var v,y=null,w=null,b=null,g=null,z=null,C=null,R=!0,T=null;return{restrict:"A",link:e,scope:{mode:"=",bind:"=",container:"@"}}}]),angular.module("ngTableResize").service("resizeStorage",["$window",function(t){function n(t,n){var o=t.attr("id");return o?e+"."+t.attr("id")+"."+n:void console.error("Table has no id",t)}var e="ngColumnResize";this.loadTableSizes=function(e,o){var i=n(e,o),r=t.localStorage.getItem(i);return JSON.parse(r)},this.saveTableSizes=function(e,o,i){var r=n(e,o);if(r){var u=JSON.stringify(i);t.localStorage.setItem(r,u)}}}]),angular.module("ngTableResize").factory("ResizerModel",[function(){function t(t,n,e){this.minWidth=25,this.table=t,this.columns=n,this.container=e,this.handleColumns=this.handles(),this.ctrlColumns=this.ctrlColumns()}return t.prototype.setup=function(){$(this.container).css({overflowX:"hidden"})},t.prototype.onTableReady=function(){$(this.table).outerWidth("100%")},t.prototype.handles=function(){return this.columns},t.prototype.ctrlColumns=function(){return this.handleColumns},t.prototype.onFirstDrag=function(){$(this.ctrlColumns).each(function(t,n){$(n).width($(n).width())})},t.prototype.handleMiddleware=function(t,n){return n},t.prototype.restrict=function(t){return t<this.minWidth},t.prototype.calculate=function(t,n){return t+n},t.prototype.onEndDrag=function(){},t.prototype.saveAttr=function(t){return $(t).outerWidth()},t}]),angular.module("ngTableResize").factory("BasicResizer",["ResizerModel",function(t){function n(n,r,u){t.call(this,n,r,u),this.ctrlColumns=this.columns,this.intervene={selector:e,calculator:o,restrict:i}}function e(t){return $(t).next()}function o(t,n){return t-n}function i(t){return t<25}return n.prototype=Object.create(t.prototype),n.prototype.setup=function(){$(this.container).css({overflowX:"hidden"}),$(this.columns).first().css({width:"auto"})},n.prototype.handles=function(){return $(this.columns).not(":last")},n.prototype.onFirstDrag=function(){$(this.columns).each(function(t,n){$(n).width($(n).width())})},n.prototype.onEndDrag=function(){var t=$(this.table).outerWidth(),n=0;$(this.columns).each(function(e,o){var i=$(o).outerWidth(),r=i/t*100+"%";n+=i/t*100,$(o).css({width:r})})},n.prototype.saveAttr=function(t){return $(t)[0].style.width},n}]),angular.module("ngTableResize").factory("FixedResizer",["ResizerModel",function(t){function n(n,e,o){t.call(this,n,e,o),this.fixedColumn=$(n).find("th").first(),this.bound=!1}return n.prototype=Object.create(t.prototype),n.prototype.setup=function(){$(this.container).css({overflowX:"hidden"}),$(this.columns).first().css({width:"auto"})},n.prototype.handles=function(){return $(this.columns).not(":last")},n.prototype.ctrlColumns=function(){return $(this.columns).not(":first")},n.prototype.onFirstDrag=function(){$(this.ctrlColumns).each(function(t,n){$(n).width($(n).width())})},n.prototype.handleMiddleware=function(t,n){return $(n).next()},n.prototype.restrict=function(t){return this.bound?!(t<this.bound)||($(this.fixedColumn).width("auto"),this.bound=!1,!1):t<this.minWidth||($(this.fixedColumn).width()<=this.minWidth?(this.bound=t,$(this.fixedColumn).width(this.minWidth),!0):void 0)},n.prototype.calculate=function(t,n){return t-n},n}]),angular.module("ngTableResize").factory("OverflowResizer",["ResizerModel",function(t){function n(n,e,o){t.call(this,n,e,o)}return n.prototype=Object.create(t.prototype),n.prototype.setup=function(){$(this.container).css({overflow:"auto"})},n.prototype.onTableReady=function(){$(this.table).width(1)},n}]);
{
"name": "angular-table-resize",
"version": "1.0.2",
"version": "1.0.3",
"description": "An AngularJS module for resizing table columns!",

@@ -5,0 +5,0 @@ "main": "index.js",

# angular-table-resize
An AngularJS module for resizing table columns!
## Demo
You can try out a demo by [clicking here](https://tympanix.github.io/angular-table-resize/). You can also use the demo as an example for implementing the module on your own page. The soruce can be found in the [gh-pages branch](https://github.com/Tympanix/angular-table-resize/tree/gh-pages)
## Installation

@@ -32,2 +35,7 @@ #### Bower

## Use
Make sure your app imports the module
```javascript
angular.module('myApplication', ['ngTableResize']);
```
On a HTML table tag put the **resizeable** directive

@@ -34,0 +42,0 @@ ```html

@@ -0,0 +0,0 @@ // Module

@@ -60,3 +60,3 @@ angular.module("ngTableResize").directive('resizeable', ['resizeStorage', '$injector', function(resizeStorage, $injector) {

function resetTable(table) {
$(table).width('100%');
$(table).outerWidth('100%');
$(table).find('th').width('auto');

@@ -79,3 +79,2 @@ }

resizer = new ResizeModel(table, columns, container);
console.log("Resizer", resizer);

@@ -107,3 +106,2 @@ // Load column sized from saved storage

resetTable(table);
//console.error("No table size settings found");
return;

@@ -117,3 +115,2 @@ }

var cacheWidth = cache[id];
//console.log("Set " + id + " to " + cacheWidth);
$(column).css({ width: cacheWidth });

@@ -120,0 +117,0 @@ })

@@ -26,7 +26,2 @@ angular.module("ngTableResize").factory("FixedResizer", ["ResizerModel", function(ResizerModel) {

FixedResizer.prototype.onTableReady = function() {
// For mode fixed, make table 100% width always
$(this.table).width('100%');
};
FixedResizer.prototype.handles = function() {

@@ -33,0 +28,0 @@ // Mode fixed does not require handler on last column

@@ -23,3 +23,3 @@ angular.module("ngTableResize").factory("ResizerModel", [function() {

// Table is by default 100% width
$(this.table).width('100%');
$(this.table).outerWidth('100%');
};

@@ -26,0 +26,0 @@

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc