tableling-rails 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/tableling-rails/version.rb +1 -1
- data/spec/dummy/app/assets/javascripts/books.js +3 -0
- data/spec/dummy/log/development.log +110 -0
- data/spec/dummy/tmp/cache/assets/C20/C20/sprockets%2F932e86665765e61017be1015b249d270 +0 -0
- data/spec/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/cache/assets/D68/930/sprockets%2F5a15e52e84502f9fceb7ea04020f65fc +0 -0
- data/spec/dummy/tmp/cache/assets/D8C/140/sprockets%2F2afdbb3902a1be5d2f045cfc837903a3 +0 -0
- data/spec/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/DF0/D60/sprockets%2F5a54a1ecc1db271edfc0727bfcb8d912 +0 -0
- data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/vendor/assets/javascripts/tableling.backbone.js +47 -16
- data/vendor/assets/javascripts/tableling.js +47 -16
- data/vendor/assets/javascripts/tableling.world.js +47 -16
- metadata +1 -1
|
@@ -7165,3 +7165,113 @@ Processing by BooksController#page as JSON
|
|
|
7165
7165
|
[1m[36m (0.3ms)[0m [1mSELECT COUNT(*) FROM "books" [0m
|
|
7166
7166
|
[1m[35mBook Load (0.1ms)[0m SELECT "books".* FROM "books" LIMIT 5 OFFSET 0
|
|
7167
7167
|
Completed 200 OK in 3ms (Views: 0.5ms | ActiveRecord: 0.4ms)
|
|
7168
|
+
|
|
7169
|
+
|
|
7170
|
+
Started GET "/" for 127.0.0.1 at 2012-10-17 11:17:04 +0200
|
|
7171
|
+
Processing by BooksController#index as HTML
|
|
7172
|
+
Rendered books/index.html.haml within layouts/application (1.0ms)
|
|
7173
|
+
Compiled tableling.world.js (38ms) (pid 6723)
|
|
7174
|
+
Compiled application.js (5ms) (pid 6723)
|
|
7175
|
+
Completed 200 OK in 87ms (Views: 87.3ms | ActiveRecord: 0.0ms)
|
|
7176
|
+
|
|
7177
|
+
|
|
7178
|
+
Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:04 +0200
|
|
7179
|
+
Processing by BooksController#page as JSON
|
|
7180
|
+
Parameters: {"page"=>"1", "pageSize"=>"10"}
|
|
7181
|
+
[1m[36m (0.2ms)[0m [1mSELECT COUNT(*) FROM "books" [0m
|
|
7182
|
+
[1m[35mBook Load (0.1ms)[0m SELECT "books".* FROM "books" LIMIT 10 OFFSET 0
|
|
7183
|
+
Completed 200 OK in 3ms (Views: 0.6ms | ActiveRecord: 0.3ms)
|
|
7184
|
+
|
|
7185
|
+
|
|
7186
|
+
Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:08 +0200
|
|
7187
|
+
Processing by BooksController#page as JSON
|
|
7188
|
+
Parameters: {"page"=>"1", "pageSize"=>"15"}
|
|
7189
|
+
[1m[36m (0.1ms)[0m [1mSELECT COUNT(*) FROM "books" [0m
|
|
7190
|
+
[1m[35mBook Load (0.1ms)[0m SELECT "books".* FROM "books" LIMIT 15 OFFSET 0
|
|
7191
|
+
Completed 200 OK in 3ms (Views: 1.4ms | ActiveRecord: 0.3ms)
|
|
7192
|
+
|
|
7193
|
+
|
|
7194
|
+
Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:09 +0200
|
|
7195
|
+
Processing by BooksController#page as JSON
|
|
7196
|
+
Parameters: {"page"=>"1", "pageSize"=>"10"}
|
|
7197
|
+
[1m[36m (0.2ms)[0m [1mSELECT COUNT(*) FROM "books" [0m
|
|
7198
|
+
[1m[35mBook Load (0.2ms)[0m SELECT "books".* FROM "books" LIMIT 10 OFFSET 0
|
|
7199
|
+
Completed 200 OK in 2ms (Views: 0.7ms | ActiveRecord: 0.4ms)
|
|
7200
|
+
|
|
7201
|
+
|
|
7202
|
+
Started GET "/" for 127.0.0.1 at 2012-10-17 11:17:09 +0200
|
|
7203
|
+
Processing by BooksController#index as HTML
|
|
7204
|
+
Rendered books/index.html.haml within layouts/application (0.2ms)
|
|
7205
|
+
Completed 200 OK in 16ms (Views: 15.4ms | ActiveRecord: 0.0ms)
|
|
7206
|
+
|
|
7207
|
+
|
|
7208
|
+
Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:09 +0200
|
|
7209
|
+
Processing by BooksController#page as JSON
|
|
7210
|
+
Parameters: {"page"=>"1", "pageSize"=>"10"}
|
|
7211
|
+
[1m[36m (0.2ms)[0m [1mSELECT COUNT(*) FROM "books" [0m
|
|
7212
|
+
[1m[35mBook Load (0.1ms)[0m SELECT "books".* FROM "books" LIMIT 10 OFFSET 0
|
|
7213
|
+
Completed 200 OK in 3ms (Views: 0.9ms | ActiveRecord: 0.3ms)
|
|
7214
|
+
|
|
7215
|
+
|
|
7216
|
+
Started GET "/" for 127.0.0.1 at 2012-10-17 11:17:33 +0200
|
|
7217
|
+
Processing by BooksController#index as HTML
|
|
7218
|
+
Rendered books/index.html.haml within layouts/application (0.2ms)
|
|
7219
|
+
Compiled books.js (0ms) (pid 6723)
|
|
7220
|
+
Compiled application.js (8ms) (pid 6723)
|
|
7221
|
+
Completed 200 OK in 87ms (Views: 86.5ms | ActiveRecord: 0.0ms)
|
|
7222
|
+
|
|
7223
|
+
|
|
7224
|
+
Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:33 +0200
|
|
7225
|
+
Processing by BooksController#page as JSON
|
|
7226
|
+
Parameters: {"page"=>"1", "pageSize"=>"5"}
|
|
7227
|
+
[1m[36m (0.2ms)[0m [1mSELECT COUNT(*) FROM "books" [0m
|
|
7228
|
+
[1m[35mBook Load (0.1ms)[0m SELECT "books".* FROM "books" LIMIT 5 OFFSET 0
|
|
7229
|
+
Completed 200 OK in 2ms (Views: 0.4ms | ActiveRecord: 0.3ms)
|
|
7230
|
+
|
|
7231
|
+
|
|
7232
|
+
Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:35 +0200
|
|
7233
|
+
Processing by BooksController#page as JSON
|
|
7234
|
+
Parameters: {"page"=>"1", "pageSize"=>"10"}
|
|
7235
|
+
[1m[36m (0.2ms)[0m [1mSELECT COUNT(*) FROM "books" [0m
|
|
7236
|
+
[1m[35mBook Load (0.1ms)[0m SELECT "books".* FROM "books" LIMIT 10 OFFSET 0
|
|
7237
|
+
Completed 200 OK in 2ms (Views: 0.8ms | ActiveRecord: 0.3ms)
|
|
7238
|
+
|
|
7239
|
+
|
|
7240
|
+
Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:36 +0200
|
|
7241
|
+
Processing by BooksController#page as JSON
|
|
7242
|
+
Parameters: {"page"=>"1", "pageSize"=>"5"}
|
|
7243
|
+
[1m[36m (0.2ms)[0m [1mSELECT COUNT(*) FROM "books" [0m
|
|
7244
|
+
[1m[35mBook Load (0.2ms)[0m SELECT "books".* FROM "books" LIMIT 5 OFFSET 0
|
|
7245
|
+
Completed 200 OK in 2ms (Views: 0.5ms | ActiveRecord: 0.4ms)
|
|
7246
|
+
|
|
7247
|
+
|
|
7248
|
+
Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:37 +0200
|
|
7249
|
+
Processing by BooksController#page as JSON
|
|
7250
|
+
Parameters: {"page"=>"1", "pageSize"=>"5", "quickSearch"=>"tale"}
|
|
7251
|
+
[1m[36m (0.2ms)[0m [1mSELECT COUNT(*) FROM "books" WHERE (LOWER(books.title) LIKE '%tale%' OR LOWER(books.author) LIKE '%tale%')[0m
|
|
7252
|
+
[1m[35mBook Load (0.1ms)[0m SELECT "books".* FROM "books" WHERE (LOWER(books.title) LIKE '%tale%' OR LOWER(books.author) LIKE '%tale%') LIMIT 5 OFFSET 0
|
|
7253
|
+
Completed 200 OK in 2ms (Views: 0.2ms | ActiveRecord: 0.4ms)
|
|
7254
|
+
|
|
7255
|
+
|
|
7256
|
+
Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:38 +0200
|
|
7257
|
+
Processing by BooksController#page as JSON
|
|
7258
|
+
Parameters: {"page"=>"1", "pageSize"=>"5"}
|
|
7259
|
+
[1m[36m (0.2ms)[0m [1mSELECT COUNT(*) FROM "books" [0m
|
|
7260
|
+
[1m[35mBook Load (0.1ms)[0m SELECT "books".* FROM "books" LIMIT 5 OFFSET 0
|
|
7261
|
+
Completed 200 OK in 2ms (Views: 0.4ms | ActiveRecord: 0.3ms)
|
|
7262
|
+
|
|
7263
|
+
|
|
7264
|
+
Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:39 +0200
|
|
7265
|
+
Processing by BooksController#page as JSON
|
|
7266
|
+
Parameters: {"page"=>"2", "pageSize"=>"5"}
|
|
7267
|
+
[1m[36m (0.2ms)[0m [1mSELECT COUNT(*) FROM "books" [0m
|
|
7268
|
+
[1m[35mBook Load (0.1ms)[0m SELECT "books".* FROM "books" LIMIT 5 OFFSET 5
|
|
7269
|
+
Completed 200 OK in 2ms (Views: 0.4ms | ActiveRecord: 0.3ms)
|
|
7270
|
+
|
|
7271
|
+
|
|
7272
|
+
Started POST "/books/page" for 127.0.0.1 at 2012-10-17 11:17:40 +0200
|
|
7273
|
+
Processing by BooksController#page as JSON
|
|
7274
|
+
Parameters: {"page"=>"1", "pageSize"=>"5"}
|
|
7275
|
+
[1m[36m (0.2ms)[0m [1mSELECT COUNT(*) FROM "books" [0m
|
|
7276
|
+
[1m[35mBook Load (0.1ms)[0m SELECT "books".* FROM "books" LIMIT 5 OFFSET 0
|
|
7277
|
+
Completed 200 OK in 2ms (Views: 0.4ms | ActiveRecord: 0.3ms)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -3094,7 +3094,7 @@ Marionette.EventAggregator = Backbone.Wreqr.EventAggregator;
|
|
|
3094
3094
|
return Marionette;
|
|
3095
3095
|
})(Backbone, _, $ || window.jQuery || window.Zepto || window.ender);
|
|
3096
3096
|
/*!
|
|
3097
|
-
* Tableling v0.0.
|
|
3097
|
+
* Tableling v0.0.10
|
|
3098
3098
|
* Copyright (c) 2012 Simon Oulevay (Alpha Hydrae) <hydrae.alpha@gmail.com>
|
|
3099
3099
|
* Distributed under MIT license
|
|
3100
3100
|
* https://github.com/AlphaHydrae/tableling
|
|
@@ -3102,7 +3102,7 @@ Marionette.EventAggregator = Backbone.Wreqr.EventAggregator;
|
|
|
3102
3102
|
Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
3103
3103
|
|
|
3104
3104
|
var Tableling = {
|
|
3105
|
-
version : "0.0.
|
|
3105
|
+
version : "0.0.10"
|
|
3106
3106
|
};
|
|
3107
3107
|
|
|
3108
3108
|
// Tableling
|
|
@@ -3116,8 +3116,7 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
3116
3116
|
|
|
3117
3117
|
// Default table options can be overriden by subclasses.
|
|
3118
3118
|
tableling : {
|
|
3119
|
-
page : 1
|
|
3120
|
-
pageSize : 15
|
|
3119
|
+
page : 1
|
|
3121
3120
|
},
|
|
3122
3121
|
|
|
3123
3122
|
initialize : function(options) {
|
|
@@ -3141,8 +3140,8 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
3141
3140
|
|
|
3142
3141
|
// Called once rendering is complete. By default, it updates the table.
|
|
3143
3142
|
setup : function() {
|
|
3144
|
-
this.
|
|
3145
|
-
this.
|
|
3143
|
+
this.ventTrigger('table:setup', this.filterConfig(this.tableling, true));
|
|
3144
|
+
this.ventTrigger('table:update');
|
|
3146
3145
|
},
|
|
3147
3146
|
|
|
3148
3147
|
// Subclasses must return the Backbone.Collection used to fetch data.
|
|
@@ -3237,11 +3236,11 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
3237
3236
|
ventTrigger : function() {
|
|
3238
3237
|
|
|
3239
3238
|
var args = Array.prototype.slice.call(arguments);
|
|
3240
|
-
this.vent.trigger.apply(this.vent, args);
|
|
3241
|
-
|
|
3242
3239
|
if (Tableling.debug) {
|
|
3243
|
-
console.log(
|
|
3240
|
+
console.log(_.first(args) + ' - ' + JSON.stringify(args.slice(1)));
|
|
3244
3241
|
}
|
|
3242
|
+
|
|
3243
|
+
this.vent.trigger.apply(this.vent, args);
|
|
3245
3244
|
}
|
|
3246
3245
|
});
|
|
3247
3246
|
|
|
@@ -3354,10 +3353,13 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
3354
3353
|
initialize : function(options) {
|
|
3355
3354
|
this.vent = options.vent;
|
|
3356
3355
|
|
|
3357
|
-
// The `
|
|
3358
|
-
//
|
|
3356
|
+
// The `setup` method of the view is called when the table
|
|
3357
|
+
// is first set up.
|
|
3358
|
+
this.vent.on('table:setup', this.setup, this);
|
|
3359
|
+
|
|
3360
|
+
// The `refresh` method of the view is called every time the table
|
|
3361
|
+
// is refreshed.
|
|
3359
3362
|
this.vent.on('table:refreshed', this.refresh, this);
|
|
3360
|
-
this.on('render', this.refresh, this);
|
|
3361
3363
|
},
|
|
3362
3364
|
|
|
3363
3365
|
// Call `update` to trigger an update of the table.
|
|
@@ -3365,10 +3367,13 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
3365
3367
|
this.vent.trigger('table:update', this.config());
|
|
3366
3368
|
},
|
|
3367
3369
|
|
|
3370
|
+
// Implementations should override this to set initial values.
|
|
3371
|
+
setup : function(config) {
|
|
3372
|
+
},
|
|
3373
|
+
|
|
3368
3374
|
// Implementations should override this to stay up to date with
|
|
3369
|
-
// the table state.
|
|
3370
|
-
|
|
3371
|
-
refresh : function(data) {
|
|
3375
|
+
// the table state.
|
|
3376
|
+
refresh : function(config) {
|
|
3372
3377
|
},
|
|
3373
3378
|
|
|
3374
3379
|
// New table configuration to be sent on updates. For example,
|
|
@@ -3385,6 +3390,8 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
3385
3390
|
// defaults and only requires a `name` and a `template` parameter.
|
|
3386
3391
|
Tableling.FieldModule = Tableling.Module.extend({
|
|
3387
3392
|
|
|
3393
|
+
// TODO: check name
|
|
3394
|
+
|
|
3388
3395
|
initialize : function(options) {
|
|
3389
3396
|
|
|
3390
3397
|
Tableling.Module.prototype.initialize.call(this, options);
|
|
@@ -3402,6 +3409,11 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
3402
3409
|
this.events['change [name="' + this.name + '"]'] = 'update';
|
|
3403
3410
|
},
|
|
3404
3411
|
|
|
3412
|
+
setup : function(config) {
|
|
3413
|
+
this.ui.field.val(config[this.name]);
|
|
3414
|
+
this.vent.trigger('table:update', this.config(), { refresh : false });
|
|
3415
|
+
},
|
|
3416
|
+
|
|
3405
3417
|
// The table property updated is the one with the same name as the module.
|
|
3406
3418
|
config : function() {
|
|
3407
3419
|
var config = {};
|
|
@@ -3514,7 +3526,26 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
3514
3526
|
Tableling.Plain.PageSizeView = Tableling.Plain.Table.prototype.pageSizeView = Tableling.FieldModule.extend({
|
|
3515
3527
|
// TODO: update current page intelligently
|
|
3516
3528
|
name : 'pageSize',
|
|
3517
|
-
template : _.template('<select name="pageSize"
|
|
3529
|
+
template : _.template('<select name="pageSize" /> entries per page'),
|
|
3530
|
+
sizes : [ 10, 15, 20, 25, 50 ],
|
|
3531
|
+
|
|
3532
|
+
ui : {
|
|
3533
|
+
field : 'select'
|
|
3534
|
+
},
|
|
3535
|
+
|
|
3536
|
+
initialize : function(options) {
|
|
3537
|
+
Tableling.FieldModule.prototype.initialize.call(this, options);
|
|
3538
|
+
this.sizes = _.clone(options.sizes || this.sizes);
|
|
3539
|
+
},
|
|
3540
|
+
|
|
3541
|
+
onRender : function() {
|
|
3542
|
+
this.ui.field.empty();
|
|
3543
|
+
_.each(this.sizes, _.bind(this.addSize, this));
|
|
3544
|
+
},
|
|
3545
|
+
|
|
3546
|
+
addSize : function(size) {
|
|
3547
|
+
$('<option />').text(size).appendTo(this.ui.field);
|
|
3548
|
+
}
|
|
3518
3549
|
});
|
|
3519
3550
|
|
|
3520
3551
|
Tableling.Plain.QuickSearchView = Tableling.Plain.Table.prototype.quickSearchView = Tableling.FieldModule.extend({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Tableling v0.0.
|
|
2
|
+
* Tableling v0.0.10
|
|
3
3
|
* Copyright (c) 2012 Simon Oulevay (Alpha Hydrae) <hydrae.alpha@gmail.com>
|
|
4
4
|
* Distributed under MIT license
|
|
5
5
|
* https://github.com/AlphaHydrae/tableling
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
8
8
|
|
|
9
9
|
var Tableling = {
|
|
10
|
-
version : "0.0.
|
|
10
|
+
version : "0.0.10"
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
// Tableling
|
|
@@ -21,8 +21,7 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
21
21
|
|
|
22
22
|
// Default table options can be overriden by subclasses.
|
|
23
23
|
tableling : {
|
|
24
|
-
page : 1
|
|
25
|
-
pageSize : 15
|
|
24
|
+
page : 1
|
|
26
25
|
},
|
|
27
26
|
|
|
28
27
|
initialize : function(options) {
|
|
@@ -46,8 +45,8 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
46
45
|
|
|
47
46
|
// Called once rendering is complete. By default, it updates the table.
|
|
48
47
|
setup : function() {
|
|
49
|
-
this.
|
|
50
|
-
this.
|
|
48
|
+
this.ventTrigger('table:setup', this.filterConfig(this.tableling, true));
|
|
49
|
+
this.ventTrigger('table:update');
|
|
51
50
|
},
|
|
52
51
|
|
|
53
52
|
// Subclasses must return the Backbone.Collection used to fetch data.
|
|
@@ -142,11 +141,11 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
142
141
|
ventTrigger : function() {
|
|
143
142
|
|
|
144
143
|
var args = Array.prototype.slice.call(arguments);
|
|
145
|
-
this.vent.trigger.apply(this.vent, args);
|
|
146
|
-
|
|
147
144
|
if (Tableling.debug) {
|
|
148
|
-
console.log(
|
|
145
|
+
console.log(_.first(args) + ' - ' + JSON.stringify(args.slice(1)));
|
|
149
146
|
}
|
|
147
|
+
|
|
148
|
+
this.vent.trigger.apply(this.vent, args);
|
|
150
149
|
}
|
|
151
150
|
});
|
|
152
151
|
|
|
@@ -259,10 +258,13 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
259
258
|
initialize : function(options) {
|
|
260
259
|
this.vent = options.vent;
|
|
261
260
|
|
|
262
|
-
// The `
|
|
263
|
-
//
|
|
261
|
+
// The `setup` method of the view is called when the table
|
|
262
|
+
// is first set up.
|
|
263
|
+
this.vent.on('table:setup', this.setup, this);
|
|
264
|
+
|
|
265
|
+
// The `refresh` method of the view is called every time the table
|
|
266
|
+
// is refreshed.
|
|
264
267
|
this.vent.on('table:refreshed', this.refresh, this);
|
|
265
|
-
this.on('render', this.refresh, this);
|
|
266
268
|
},
|
|
267
269
|
|
|
268
270
|
// Call `update` to trigger an update of the table.
|
|
@@ -270,10 +272,13 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
270
272
|
this.vent.trigger('table:update', this.config());
|
|
271
273
|
},
|
|
272
274
|
|
|
275
|
+
// Implementations should override this to set initial values.
|
|
276
|
+
setup : function(config) {
|
|
277
|
+
},
|
|
278
|
+
|
|
273
279
|
// Implementations should override this to stay up to date with
|
|
274
|
-
// the table state.
|
|
275
|
-
|
|
276
|
-
refresh : function(data) {
|
|
280
|
+
// the table state.
|
|
281
|
+
refresh : function(config) {
|
|
277
282
|
},
|
|
278
283
|
|
|
279
284
|
// New table configuration to be sent on updates. For example,
|
|
@@ -290,6 +295,8 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
290
295
|
// defaults and only requires a `name` and a `template` parameter.
|
|
291
296
|
Tableling.FieldModule = Tableling.Module.extend({
|
|
292
297
|
|
|
298
|
+
// TODO: check name
|
|
299
|
+
|
|
293
300
|
initialize : function(options) {
|
|
294
301
|
|
|
295
302
|
Tableling.Module.prototype.initialize.call(this, options);
|
|
@@ -307,6 +314,11 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
307
314
|
this.events['change [name="' + this.name + '"]'] = 'update';
|
|
308
315
|
},
|
|
309
316
|
|
|
317
|
+
setup : function(config) {
|
|
318
|
+
this.ui.field.val(config[this.name]);
|
|
319
|
+
this.vent.trigger('table:update', this.config(), { refresh : false });
|
|
320
|
+
},
|
|
321
|
+
|
|
310
322
|
// The table property updated is the one with the same name as the module.
|
|
311
323
|
config : function() {
|
|
312
324
|
var config = {};
|
|
@@ -419,7 +431,26 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
419
431
|
Tableling.Plain.PageSizeView = Tableling.Plain.Table.prototype.pageSizeView = Tableling.FieldModule.extend({
|
|
420
432
|
// TODO: update current page intelligently
|
|
421
433
|
name : 'pageSize',
|
|
422
|
-
template : _.template('<select name="pageSize"
|
|
434
|
+
template : _.template('<select name="pageSize" /> entries per page'),
|
|
435
|
+
sizes : [ 10, 15, 20, 25, 50 ],
|
|
436
|
+
|
|
437
|
+
ui : {
|
|
438
|
+
field : 'select'
|
|
439
|
+
},
|
|
440
|
+
|
|
441
|
+
initialize : function(options) {
|
|
442
|
+
Tableling.FieldModule.prototype.initialize.call(this, options);
|
|
443
|
+
this.sizes = _.clone(options.sizes || this.sizes);
|
|
444
|
+
},
|
|
445
|
+
|
|
446
|
+
onRender : function() {
|
|
447
|
+
this.ui.field.empty();
|
|
448
|
+
_.each(this.sizes, _.bind(this.addSize, this));
|
|
449
|
+
},
|
|
450
|
+
|
|
451
|
+
addSize : function(size) {
|
|
452
|
+
$('<option />').text(size).appendTo(this.ui.field);
|
|
453
|
+
}
|
|
423
454
|
});
|
|
424
455
|
|
|
425
456
|
Tableling.Plain.QuickSearchView = Tableling.Plain.Table.prototype.quickSearchView = Tableling.FieldModule.extend({
|
|
@@ -14224,7 +14224,7 @@ Marionette.EventAggregator = Backbone.Wreqr.EventAggregator;
|
|
|
14224
14224
|
return Marionette;
|
|
14225
14225
|
})(Backbone, _, $ || window.jQuery || window.Zepto || window.ender);
|
|
14226
14226
|
/*!
|
|
14227
|
-
* Tableling v0.0.
|
|
14227
|
+
* Tableling v0.0.10
|
|
14228
14228
|
* Copyright (c) 2012 Simon Oulevay (Alpha Hydrae) <hydrae.alpha@gmail.com>
|
|
14229
14229
|
* Distributed under MIT license
|
|
14230
14230
|
* https://github.com/AlphaHydrae/tableling
|
|
@@ -14232,7 +14232,7 @@ Marionette.EventAggregator = Backbone.Wreqr.EventAggregator;
|
|
|
14232
14232
|
Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
14233
14233
|
|
|
14234
14234
|
var Tableling = {
|
|
14235
|
-
version : "0.0.
|
|
14235
|
+
version : "0.0.10"
|
|
14236
14236
|
};
|
|
14237
14237
|
|
|
14238
14238
|
// Tableling
|
|
@@ -14246,8 +14246,7 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
14246
14246
|
|
|
14247
14247
|
// Default table options can be overriden by subclasses.
|
|
14248
14248
|
tableling : {
|
|
14249
|
-
page : 1
|
|
14250
|
-
pageSize : 15
|
|
14249
|
+
page : 1
|
|
14251
14250
|
},
|
|
14252
14251
|
|
|
14253
14252
|
initialize : function(options) {
|
|
@@ -14271,8 +14270,8 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
14271
14270
|
|
|
14272
14271
|
// Called once rendering is complete. By default, it updates the table.
|
|
14273
14272
|
setup : function() {
|
|
14274
|
-
this.
|
|
14275
|
-
this.
|
|
14273
|
+
this.ventTrigger('table:setup', this.filterConfig(this.tableling, true));
|
|
14274
|
+
this.ventTrigger('table:update');
|
|
14276
14275
|
},
|
|
14277
14276
|
|
|
14278
14277
|
// Subclasses must return the Backbone.Collection used to fetch data.
|
|
@@ -14367,11 +14366,11 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
14367
14366
|
ventTrigger : function() {
|
|
14368
14367
|
|
|
14369
14368
|
var args = Array.prototype.slice.call(arguments);
|
|
14370
|
-
this.vent.trigger.apply(this.vent, args);
|
|
14371
|
-
|
|
14372
14369
|
if (Tableling.debug) {
|
|
14373
|
-
console.log(
|
|
14370
|
+
console.log(_.first(args) + ' - ' + JSON.stringify(args.slice(1)));
|
|
14374
14371
|
}
|
|
14372
|
+
|
|
14373
|
+
this.vent.trigger.apply(this.vent, args);
|
|
14375
14374
|
}
|
|
14376
14375
|
});
|
|
14377
14376
|
|
|
@@ -14484,10 +14483,13 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
14484
14483
|
initialize : function(options) {
|
|
14485
14484
|
this.vent = options.vent;
|
|
14486
14485
|
|
|
14487
|
-
// The `
|
|
14488
|
-
//
|
|
14486
|
+
// The `setup` method of the view is called when the table
|
|
14487
|
+
// is first set up.
|
|
14488
|
+
this.vent.on('table:setup', this.setup, this);
|
|
14489
|
+
|
|
14490
|
+
// The `refresh` method of the view is called every time the table
|
|
14491
|
+
// is refreshed.
|
|
14489
14492
|
this.vent.on('table:refreshed', this.refresh, this);
|
|
14490
|
-
this.on('render', this.refresh, this);
|
|
14491
14493
|
},
|
|
14492
14494
|
|
|
14493
14495
|
// Call `update` to trigger an update of the table.
|
|
@@ -14495,10 +14497,13 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
14495
14497
|
this.vent.trigger('table:update', this.config());
|
|
14496
14498
|
},
|
|
14497
14499
|
|
|
14500
|
+
// Implementations should override this to set initial values.
|
|
14501
|
+
setup : function(config) {
|
|
14502
|
+
},
|
|
14503
|
+
|
|
14498
14504
|
// Implementations should override this to stay up to date with
|
|
14499
|
-
// the table state.
|
|
14500
|
-
|
|
14501
|
-
refresh : function(data) {
|
|
14505
|
+
// the table state.
|
|
14506
|
+
refresh : function(config) {
|
|
14502
14507
|
},
|
|
14503
14508
|
|
|
14504
14509
|
// New table configuration to be sent on updates. For example,
|
|
@@ -14515,6 +14520,8 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
14515
14520
|
// defaults and only requires a `name` and a `template` parameter.
|
|
14516
14521
|
Tableling.FieldModule = Tableling.Module.extend({
|
|
14517
14522
|
|
|
14523
|
+
// TODO: check name
|
|
14524
|
+
|
|
14518
14525
|
initialize : function(options) {
|
|
14519
14526
|
|
|
14520
14527
|
Tableling.Module.prototype.initialize.call(this, options);
|
|
@@ -14532,6 +14539,11 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
14532
14539
|
this.events['change [name="' + this.name + '"]'] = 'update';
|
|
14533
14540
|
},
|
|
14534
14541
|
|
|
14542
|
+
setup : function(config) {
|
|
14543
|
+
this.ui.field.val(config[this.name]);
|
|
14544
|
+
this.vent.trigger('table:update', this.config(), { refresh : false });
|
|
14545
|
+
},
|
|
14546
|
+
|
|
14535
14547
|
// The table property updated is the one with the same name as the module.
|
|
14536
14548
|
config : function() {
|
|
14537
14549
|
var config = {};
|
|
@@ -14644,7 +14656,26 @@ Backbone.Tableling = Tableling = (function(Backbone, _, $){
|
|
|
14644
14656
|
Tableling.Plain.PageSizeView = Tableling.Plain.Table.prototype.pageSizeView = Tableling.FieldModule.extend({
|
|
14645
14657
|
// TODO: update current page intelligently
|
|
14646
14658
|
name : 'pageSize',
|
|
14647
|
-
template : _.template('<select name="pageSize"
|
|
14659
|
+
template : _.template('<select name="pageSize" /> entries per page'),
|
|
14660
|
+
sizes : [ 10, 15, 20, 25, 50 ],
|
|
14661
|
+
|
|
14662
|
+
ui : {
|
|
14663
|
+
field : 'select'
|
|
14664
|
+
},
|
|
14665
|
+
|
|
14666
|
+
initialize : function(options) {
|
|
14667
|
+
Tableling.FieldModule.prototype.initialize.call(this, options);
|
|
14668
|
+
this.sizes = _.clone(options.sizes || this.sizes);
|
|
14669
|
+
},
|
|
14670
|
+
|
|
14671
|
+
onRender : function() {
|
|
14672
|
+
this.ui.field.empty();
|
|
14673
|
+
_.each(this.sizes, _.bind(this.addSize, this));
|
|
14674
|
+
},
|
|
14675
|
+
|
|
14676
|
+
addSize : function(size) {
|
|
14677
|
+
$('<option />').text(size).appendTo(this.ui.field);
|
|
14678
|
+
}
|
|
14648
14679
|
});
|
|
14649
14680
|
|
|
14650
14681
|
Tableling.Plain.QuickSearchView = Tableling.Plain.Table.prototype.quickSearchView = Tableling.FieldModule.extend({
|