Skip to content

Commit

Permalink
Added footable refresh upon data change
Browse files Browse the repository at this point in the history
Added load-when attribute watch to redraw footable (footable_redraw)
[useful with dynamically populated content]. Moves specs.js under test.
Rewrote gulp processing since boilerplate gulp wasn't working with the
most recent packages (gulp.series() undefined error).
  • Loading branch information
alexrayan committed Jan 28, 2016
1 parent 546b32b commit 7425fa0
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 54 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-footable",
"version": "0.0.1",
"version": "0.0.2",
"homepage": "https://github.com/ziscloud/angular-footable",
"authors": [
"Tony Wang <[email protected]>"
Expand Down
18 changes: 8 additions & 10 deletions dist/angular-footable.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var o;"undefined"!=typeof window?o=window:"undefined"!=typeof global?o=global:"undefined"!=typeof self&&(o=self),o.angularFootable=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
'use strict';

angular
.module('ui.footable', [])
.directive('footable', function() {
.directive('footable', ['$timeout', function($timeout) {
var events = {
beforeFiltering: 'footable_filtering'
};
Expand Down Expand Up @@ -53,13 +52,12 @@ angular

bindEventHandler(tableObj, scope, attrs);

scope.$watch(function() {return attrs.loadWhen; }, function(){
$timeout(function(){
element.trigger('footable_redraw');
});
});

}
};
});

},{}]},{},[1])

(1)
});

//# sourceMappingURL=data:application/json;base64,eyJ2Z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5vdCBmaW5kIG1vZHVsZSAnXCIrbytcIidcIil9dmFyIGY9bltvXT17ZXhwb3J0czp7fX07dFtvXVswXS5jYWxsKGYuZXhwb3J0cyxmdW5jdGlvbihlKXt2YXIgbj10W29dWzFdW2VdO3JldHVybiBzKG4/bjplKX0sZixmLmV4cG9ydHMsZSx0LG4scil9cmV0dXJuIG5bb10uZXhwb3J0c312YXIgaT10eXBlb2YgcmVxdWlyZT09XCJmdW5jdGlvblwiJiZyZXF1aXJlO2Zvcih2YXIgbz0wO288ci5sZW5ndGg7bysrKXMocltvXSk7cmV0dXJuIHN9KSIsIid1c2Ugc3RyaWN0JztcblxuYW5ndWxhclxuICAgIC5tb2R1bGUoJ3VpLmZvb3RhYmxlJywgW10pXG4gICAgLmRpcmVjdGl2ZSgnZm9vdGFibGUnLCBmdW5jdGlvbigpIHtcbiAgICAgICAgdmFyIGV2ZW50cyA9IHtcbiAgICAgICAgICAgIGJlZm9yZUZpbHRlcmluZzogJ2Zvb3RhYmxlX2ZpbHRlcmluZydcbiAgICAgICAgfTtcbiAgICAgICAgdmFyIGV4dHJhY3RTcGVjT3B0cyA9IGZ1bmN0aW9uKG9wdHMsIGF0dHJzKSB7XG4gICAgICAgICAgICB2YXIgZXh0cmFjdGVkID0ge30sXG4gICAgICAgICAgICAgICAgaztcbiAgICAgICAgICAgIGZvciAoayBpbiBvcHRzKSB7XG4gICAgICAgICAgICAgICAgaWYgKGsgIT09ICdmaWx0ZXInICYmICghYW5ndWxhci5pc1VuZGVmaW5lZChldmVudHNba10pKSkge1xuICAgICAgICAgICAgICAgICAgICBpZighYW5ndWxhci5pc0Z1bmN0aW9uKHNjb3BlLiRldmFsKGF0dHJzW2tdKSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4dHJhY3RlZFtrXSA9IGF0dHJzW2tdO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGV4dHJhY3RlZDtcbiAgICAgICAgfTtcblxuICAgICAgICB2YXIgYmluZEV2ZW50SGFuZGxlciA9IGZ1bmN0aW9uKHRhYmxlT2JqLCBzY29wZSwgYXR0cnMpIHtcbiAgICAgICAgICAgIHZhciBrO1xuICAgICAgICAgICAgZm9yIChrIGluIGF0dHJzKSB7XG4gICAgICAgICAgICAgICAgaWYgKGsgIT09ICdmaWx0ZXInICYmICghYW5ndWxhci5pc1VuZGVmaW5lZChldmVudHNba10pKSkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgdGFyZ2V0RXZlbnROYW1lID0gZXZlbnRzW2tdO1xuICAgICAgICAgICAgICAgICAgICBpZihhbmd1bGFyLmlzRnVuY3Rpb24oc2NvcGUuJGV2YWwoYXR0cnNba10pKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGFibGVPYmouYmluZCh0YXJnZXRFdmVudE5hbWUsIHNjb3BlLiRldmFsKGF0dHJzW2tdKSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG5cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIHJlc3RyaWN0OiAnQycsXG4gICAgICAgICAgICBsaW5rOiBmdW5jdGlvbihzY29wZSwgZWxlbWVudCwgYXR0cnMpIHtcbiAgICAgICAgICAgICAgICB2YXIgdGFibGVPcHRzID0ge1xuICAgICAgICAgICAgICAgICAgICAnZXZlbnQtZmlsdGVyaW5nJzogbnVsbFxuICAgICAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgICAgICBhbmd1bGFyLmV4dGVuZChcbiAgICAgICAgICAgICAgICAgICAgdGFibGVPcHRzLFxuICAgICAgICAgICAgICAgICAgICBmb290YWJsZS5vcHRpb25zXG4gICAgICAgICAgICAgICAgKTtcblxuICAgICAgICAgICAgICAgIGFuZ3VsYXIuZXh0ZW5kKFxuICAgICAgICAgICAgICAgICAgICB0YWJsZU9wdHMsXG4gICAgICAgICAgICAgICAgICAgIGV4dHJhY3RTcGVjT3B0cyh0YWJsZU9wdHMsIGF0dHJzKVxuICAgICAgICAgICAgICAgICk7XG5cbiAgICAgICAgICAgICAgICB2YXIgdGFibGVPYmogPSBlbGVtZW50LmZvb3RhYmxlKHRhYmxlT3B0cyk7XG5cbiAgICAgICAgICAgICAgICBiaW5kRXZlbnRIYW5kbGVyKHRhYmxlT2JqLCBzY29wZSwgYXR0cnMpO1xuXG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgfSk7XG4iXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
}]);
3 changes: 1 addition & 2 deletions dist/angular-footable.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion dist/angular-footable.min.js.map

This file was deleted.

39 changes: 30 additions & 9 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
var gulp = require('gulp'),
boilerplate = require('boilerplate-gulp');

boilerplate(gulp, {
pkg: require('./package.json'),
jsMain: './src/angular-footable.js',
karmaConfig: require('./test/karma.conf.js'),
connectConfig: require('./example/connect.conf.js')
});
var gulp = require('gulp');

var rename = require('gulp-rename');
var clean = require('gulp-clean');
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');

var paths = {
scripts: ['src/*.js'],
};
var bases = {
dist: 'dist'
};
gulp.task('clean', function(){
return gulp.src(bases.dist+'/*.js', {read:false})
.pipe(clean());
});
gulp.task('scripts', ['clean'], function(){
gulp.src(paths.scripts)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(gulp.dest(bases.dist))
.pipe(uglify())
.pipe(rename({
extname: '.min.js'
}))
.pipe(gulp.dest(bases.dist));
});
gulp.task('default',['scripts']);
62 changes: 34 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
{
"name": "angular-footable",
"version": "0.0.1",
"description": "Angular derictive for FooTable",
"main": "dist/angular-footable.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "gulp test"
},
"repository": {
"type": "git",
"url": "https://github.com/ziscloud/angular-footable.git"
},
"keywords": [
"angular",
"footable"
],
"author": "Tony Wang",
"license": "MIT",
"bugs": {
"url": "https://github.com/ziscloud/angular-footable/issues"
},
"homepage": "https://github.com/ziscloud/angular-footable",
"devDependencies": {
"gulp": "~3.8.0",
"boilerplate-gulp": "~0.3.0"
}
"name": "angular-footable",
"version": "0.0.1",
"description": "Angular derictive for FooTable",
"main": "dist/angular-footable.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "gulp test"
},
"repository": {
"type": "git",
"url": "https://github.com/ziscloud/angular-footable.git"
},
"keywords": [
"angular",
"footable"
],
"author": "Tony Wang",
"license": "MIT",
"bugs": {
"url": "https://github.com/ziscloud/angular-footable/issues"
},
"homepage": "https://github.com/ziscloud/angular-footable",
"devDependencies": {
"boilerplate-gulp": "~0.3.0",
"gulp": "~3.8.0",
"gulp-clean": "^0.3.1",
"gulp-concat": "^2.6.0",
"gulp-jshint": "^2.0.0",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^1.5.1",
"jshint": "^2.9.1"
}
}
10 changes: 8 additions & 2 deletions src/angular-footable.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

angular
.module('ui.footable', [])
.directive('footable', function() {
.directive('footable', ['$timeout', function($timeout) {
var events = {
beforeFiltering: 'footable_filtering'
};
Expand Down Expand Up @@ -52,6 +52,12 @@ angular

bindEventHandler(tableObj, scope, attrs);

scope.$watch(function() {return attrs.loadWhen; }, function(){
$timeout(function(){
element.trigger('footable_redraw');
});
});

}
};
});
}]);
File renamed without changes.
2 changes: 1 addition & 1 deletion test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
frameworks: ['jasmine'],

preprocessors: {
'src/**/!(*Spec).js': ['coverage'],
'test/**/!(*Spec).js': ['coverage'],
'src/**/*.js': ['commonjs']
},

Expand Down

0 comments on commit 7425fa0

Please sign in to comment.