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.4 to 1.0.5

demo/index.css

7

dist/angular-table-resize.js

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

// Get the resizer object for the current mode
var ResizeModel = getResizer(scope);
var ResizeModel = getResizer(scope, attr);
if (!ResizeModel) return;

@@ -201,5 +201,6 @@ resizer = new ResizeModel(table, columns, container);

function getResizer(scope) {
function getResizer(scope, attr) {
try {
var Resizer = $injector.get(scope.mode)
var mode = attr.mode ? scope.mode : 'BasicResizer';
var Resizer = $injector.get(mode)
return Resizer;

@@ -206,0 +207,0 @@ } catch (e) {

@@ -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){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}]);
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,e);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,e){try{var o=e.mode?t.mode:"BasicResizer",i=n.get(o);return i}catch(r){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}]);

@@ -30,3 +30,3 @@ /*jshint esversion: 6 */

server: {
baseDir: "./",
baseDir: "./"
}

@@ -41,3 +41,3 @@ });

gulp.task('watch', function() {
gulp.watch(['index.html', 'css/**', 'scripts/**', 'views/**'], browsersync.reload);
gulp.watch(['index.html', 'css/**', 'scripts/**', 'views/**', 'demo/**'], browsersync.reload);
});

@@ -68,2 +68,2 @@

gulp.task('default', ['dev']);
gulp.task('default', ['dev']);
{
"name": "angular-table-resize",
"version": "1.0.4",
"version": "1.0.5",
"description": "An AngularJS module for resizing table columns!",

@@ -5,0 +5,0 @@ "main": "./dist/angular-table-resize.js",

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

// Get the resizer object for the current mode
var ResizeModel = getResizer(scope);
var ResizeModel = getResizer(scope, attr);
if (!ResizeModel) return;

@@ -199,5 +199,6 @@ resizer = new ResizeModel(table, columns, container);

function getResizer(scope) {
function getResizer(scope, attr) {
try {
var Resizer = $injector.get(scope.mode)
var mode = attr.mode ? scope.mode : 'BasicResizer';
var Resizer = $injector.get(mode)
return Resizer;

@@ -204,0 +205,0 @@ } catch (e) {

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