Sha256: 8ea4571f56e5ccf0967c8dbe1adeb274dba061225272953594c2cb19ded0e824

Contents?: true

Size: 1.13 KB

Versions: 7

Compression:

Stored size: 1.13 KB

Contents

/*
---

script: HtmlTable.Zebra.js

name: HtmlTable.Zebra

description: Builds a stripy table with methods to add rows.

license: MIT-style license

authors:
  - Harald Kirschner
  - Aaron Newton

requires:
  - /HtmlTable
  - /Element.Shortcuts
  - /Class.refactor

provides: [HtmlTable.Zebra]

...
*/

HtmlTable = Class.refactor(HtmlTable, {

	options: {
		classZebra: 'table-tr-odd',
		zebra: true,
		zebraOnlyVisibleRows: true
	},

	initialize: function(){
		this.previous.apply(this, arguments);
		if (this.occluded) return this.occluded;
		if (this.options.zebra) this.updateZebras();
	},

	updateZebras: function(){
		var index = 0;
		Array.each(this.body.rows, function(row){
			if (!this.options.zebraOnlyVisibleRows || row.isDisplayed()){
				this.zebra(row, index++);
			}
		}, this);
	},

	setRowStyle: function(row, i){
		if (this.previous) this.previous(row, i);
		this.zebra(row, i);
	},

	zebra: function(row, i){
		return row[((i % 2) ? 'remove' : 'add')+'Class'](this.options.classZebra);
	},

	push: function(){
		var pushed = this.previous.apply(this, arguments);
		if (this.options.zebra) this.updateZebras();
		return pushed;
	}

});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lsd_rails-0.1.6 Packages/mootools-more/Source/Interface/HtmlTable.Zebra.js
lsd_rails-0.1.5 Packages/mootools-more/Source/Interface/HtmlTable.Zebra.js
lsd_rails-0.1.4 Packages/mootools-more/Source/Interface/HtmlTable.Zebra.js
lsd_rails-0.1.3 Packages/mootools-more/Source/Interface/HtmlTable.Zebra.js
lsd_rails-0.1.2 Packages/mootools-more/Source/Interface/HtmlTable.Zebra.js
lsd_rails-0.1.1 Packages/mootools-more/Source/Interface/HtmlTable.Zebra.js
lsd_rails-0.1 Packages/mootools-more/Source/Interface/HtmlTable.Zebra.js