Skip to content

Commit

Permalink
version bump
Browse files Browse the repository at this point in the history
fixes #5
  • Loading branch information
morficus committed Dec 10, 2015
1 parent 9b82f7a commit 2f5e423
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Backgrid-ResponsiveGrid",
"version": "0.3.0",
"version": "0.4.0",
"homepage": "https://github.com/morficus/Backgrid-ResponsiveGrid",
"authors": [
"Maurice Williams <[email protected]>"
Expand Down
53 changes: 52 additions & 1 deletion dist/backgrid-responsiveGrid.min.js
Original file line number Diff line number Diff line change
@@ -1 +1,52 @@
!function(a,b){"function"==typeof define&&define.amd?define(["jquery","underscore","backbone","backgrid"],function(c,d,e,f){return a.Backgrid.Extension.ResponsiveGrid=b(d,e,f)}):"object"==typeof exports?module.exports=b(require("jquery"),require("underscore"),require("backbone"),require("backgrid")):a.Backgrid.Extension.ResponsiveGrid=b(a.$,a._,a.Backbone,a.Backgrid)}(this,function(a,b,c,d){var e=d.Grid.extend({isPinnable:!1,isPinned:!1,minScreenSize:797,columnsToPin:1,initialize:function(b){d.Grid.prototype.initialize.call(this,b),this.minScreenSize=b.minScreenSize||this.minScreenSize,this.columnsToPin=b.columnsToPin||this.columnsToPin,this.body.collection.on("backgrid:refresh",this.pinColumns,this),this.header.collection.on("backgrid:sort",this.pinColumns,this),a(window).on("resize",{grid:this},this.setSwitchable),this.setSwitchable({})},pinColumns:function(){var a=this.$el,b=a.clone(!0);if(!this.isPinnable||!a.is(":visible"))return!1;this.isPinned||(a.wrap('<div class="grid-responsive-wrapper" />'),a.wrap('<div class="grid-scrollable" />'));for(var c=b.find("th").length,d=this.columnsToPin+1;c>=d;d++)b.find("th:nth-child("+d+"),td:nth-child("+d+")").hide();return this.$el.parents(".grid-responsive-wrapper").find(".grid-pinned").remove(),this.$el.parents(".grid-responsive-wrapper").append(b),b.wrap('<div class="grid-pinned" />'),this.isPinned=!0,!0},unpinColumns:function(){var a=this.$el,b=this.$el.parents(".grid-responsive-wrapper");return a.unwrap(),b.find(".grid-pinned").remove(),a.unwrap(),this.isPinned=!1,!0},setSwitchable:function(c){var d;d=b.isUndefined(c.data)?this:c.data.grid,a(window).width()<d.minScreenSize?(d.isPinnable=!0,d.pinColumns()):(d.isPinnable=!1,d.unpinColumns())}});return e});
/**
* ResponsiveGrid is an enhancement to the base Backgrid.Grid class which improves its usability on small-screens
* such as phones or portrait-mode tablets.
*
* @class Backgrid.Extension.ResponsiveGrid
* @extends Backgrid.Grid
*/
!function(a,b){"function"==typeof define&&define.amd?
// AMD (+ global for extensions)
define(["jquery","underscore","backbone","backgrid"],function(c,d,e,f){return a.Backgrid.Extension.ResponsiveGrid=b(c,d,e,f)}):"object"==typeof exports?module.exports=b(require("jquery"),require("underscore"),require("backbone"),require("backgrid")):a.Backgrid.Extension.ResponsiveGrid=b(a.$,a._,a.Backbone,a.Backgrid)}(this,function(a,b,c,d){var e=d.Grid.extend({/** @property {boolean} is the table in a state that calls for pinned columns? */
isPinnable:!1,/** @property {boolean} are the columns already pinned? */
isPinned:!1,/** @property {Number} screen size at which 'isPinnable' will flip to true */
minScreenSize:797,/** @property {Number} number of columns to ping */
columnsToPin:1,/**
* Initializer.
*
* @param {Object} options
* @param {Number} options.minScreenSize custom screen size at which 'isPinnable' will flip to true
*/
initialize:function(b){d.Grid.prototype.initialize.call(this,b),this.minScreenSize=b.minScreenSize||this.minScreenSize,this.columnsToPin=b.columnsToPin||this.columnsToPin,this.body.collection.on("backgrid:refresh",this.pinColumns,this),this.header.collection.on("backgrid:sort",this.pinColumns,this),a(window).on("resize",{grid:this},this.setSwitchable),this.setSwitchable({})},/**
* Modifies the table to freeze the first column of the grid.
*
* @return {boolean} indicating if the column(s) was successfully pinned or not
*/
pinColumns:function(){
//deep-lone the entire table - this will later turn into the pinned columns
var a=this.$el,b=a.clone(!0);
//check if the table needs to be made into "small-screen-mode" AND if the grid is already present on the screen, if not then do nothing
if(!this.isPinnable||!a.is(":visible"))return!1;
//only wrap the element if the grid is not already in "small-screen-mode"
this.isPinned||(
//wrap the original table with some special classes to enable the y-scrolling behavior
a.wrap('<div class="grid-responsive-wrapper" />'),a.wrap('<div class="grid-scrollable" />'));
//we need to do "+1" because using ":nth-child" starts with a zero-based index
for(var c=b.find("th").length,d=this.columnsToPin+1;c>=d;d++)
//$tableCopy.find('th:nth-child(' + i + '),td:nth-child(' + i + ')').hide();
b.find("th:nth-child("+d+"),td:nth-child("+d+")").hide();
//remove all previous instances of pinned columns
//append the cloned table to the wrapper
//wrap the clone in a div to make it behave as pinned columns
return this.$el.parents(".grid-responsive-wrapper").find(".grid-pinned").remove(),this.$el.parents(".grid-responsive-wrapper").append(b),b.wrap('<div class="grid-pinned" />'),this.isPinned=!0,!0},/**
* Returns the table to its original unpinned state.
* It's the opposite of pinColumns.
*
* @return {boolean} indicates if the column(s) was successfully unpinned or not
*/
unpinColumns:function(){var a=this.$el,b=this.$el.parents(".grid-responsive-wrapper");return a.unwrap(),b.find(".grid-pinned").remove(),a.unwrap(),this.isPinned=!1,!0},/**
* Based on the screen size, sets the property to indicate if there is a need to pin the column(s) or not
*
* @param {Object} event object The window resize event (optional)
*/
setSwitchable:function(c){var d;d=b.isUndefined(c.data)?this:c.data.grid,a(window).width()<d.minScreenSize?(d.isPinnable=!0,d.pinColumns()):(d.isPinnable=!1,d.unpinColumns())}});return e});
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Backgrid-ResponsiveGrid",
"version": "0.3.0",
"version": "0.4.0",
"description": "<img src=\"//benschwarz.github.io/bower-badges/[email protected]\" width=\"130\" height=\"30\">",
"main": "./src/backgrid-responsiveGrid.js",
"directories": {
Expand All @@ -20,9 +20,9 @@
},
"homepage": "https://github.com/morficus/Backgrid-ResponsiveGrid",
"devDependencies": {
"grunt": "~0.4.4",
"grunt-contrib-uglify": "~0.4.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-recess": "~0.6.1"
"grunt": "^0.4.5",
"grunt-contrib-clean": "^0.7.0",
"grunt-contrib-uglify": "^0.11.0",
"grunt-recess": "^1.0.1"
}
}

0 comments on commit 2f5e423

Please sign in to comment.