kolo 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: acdf7d7cd0bb17aa888ed1965d1ee228695e222a
4
- data.tar.gz: 8d7fb513eecca72635aaa338ae83c9b24574635d
3
+ metadata.gz: e7fcb9345c76d4ad57d0a0cd4cdc4b8478544c8e
4
+ data.tar.gz: da60a5b91d5d65a0686067e8860e63d11bf0d8a1
5
5
  SHA512:
6
- metadata.gz: 4eed313f0e2d717b82719c1da828f4cb6e10e5071368bfe9931db09b7acb9c4bab5b0aaf08bd85814dba5366475971385c3d2b579d3ee790bfb5726079fdc070
7
- data.tar.gz: 4016a3df873d11943ad60fbf77c151f310544b0b7a864f2e818a8fe154261c309a4b97c72428e2eac4b9b2714eebcf184926ff841bcc7082ce408b8cb99e0372
6
+ metadata.gz: 26dd02ef645c4b507ad649dcd8898aa69cfb2096bfbbb46d218360b66e0632d82c74f8300e62823f1ea4f4cf403e87af8e73ecfa6451a351bede54799120c2de
7
+ data.tar.gz: e829d228a04425aae06a1ff02df1667aa5ac175d2d6f1a8b2712a9cadc72d5b32283d1aa79579386ab2eaad05d292d839051a72ddfce7fc8ac7a73e8821ecf0c
@@ -163,12 +163,14 @@ ko.bindingHandlers.fileupload =
163
163
  options = ko.utils.unwrapObservable valueAccessor()
164
164
  property = ko.utils.unwrapObservable options.property
165
165
  parameter = ko.utils.unwrapObservable options.parameter
166
+ onStartUpload = ko.utils.unwrapObservable options.onStartUpload
166
167
  onComplete = ko.utils.unwrapObservable options.onComplete
167
168
  url = ko.utils.unwrapObservable options.url
168
169
 
169
170
  return false unless (property && url && parameter)
170
171
 
171
172
  uploadFile = (file)=>
173
+ viewModel[onStartUpload]() if viewModel[onStartUpload]?
172
174
  formData = new FormData
173
175
  formData.append parameter, file
174
176
  xhr = new XMLHttpRequest
@@ -212,3 +214,4 @@ ko.bindingHandlers.wysiwyg =
212
214
  value = ko.utils.unwrapObservable valueAccessor()
213
215
  $(element).html value
214
216
  ko.bindingHandlers.value.update element, valueAccessor
217
+
@@ -285,3 +285,4 @@ window.Db = Db
285
285
  window.Model = Model
286
286
 
287
287
  window.viewModel = new ViewModel # this will probably be overridden by other pages later on
288
+
data/lib/kolo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kolo
2
- VERSION = "0.6.4"
2
+ VERSION = "0.6.5"
3
3
  end
@@ -0,0 +1,357 @@
1
+ // Generated by CoffeeScript 1.6.2
2
+ (function() {
3
+ ko.bindingHandlers.appearif = {
4
+ init: function(element, valueAccessor) {
5
+ var value;
6
+
7
+ value = ko.utils.unwrapObservable(valueAccessor());
8
+ return $(element).toggle(value);
9
+ },
10
+ update: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
11
+ var appear, duration;
12
+
13
+ appear = ko.utils.unwrapObservable(valueAccessor());
14
+ duration = allBindingsAccessor().duration || 400;
15
+ if (appear) {
16
+ $(element).fadeIn(duration);
17
+ return $(element).focus();
18
+ } else {
19
+ return $(element).fadeOut(duration);
20
+ }
21
+ }
22
+ };
23
+
24
+ ko.bindingHandlers.appearifnot = {
25
+ init: function(element, valueAccessor) {
26
+ var value;
27
+
28
+ value = ko.utils.unwrapObservable(valueAccessor());
29
+ return $(element).toggle(!value);
30
+ },
31
+ update: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
32
+ var appear, duration;
33
+
34
+ appear = ko.utils.unwrapObservable(valueAccessor());
35
+ duration = allBindingsAccessor().duration || 400;
36
+ if (!appear) {
37
+ $(element).fadeIn(duration);
38
+ return $(element).focus();
39
+ } else {
40
+ return $(element).fadeOut(duration);
41
+ }
42
+ }
43
+ };
44
+
45
+ ko.bindingHandlers.slidedownif = {
46
+ init: function(element, valueAccessor) {
47
+ var value;
48
+
49
+ value = ko.utils.unwrapObservable(valueAccessor());
50
+ return $(element).toggle(value);
51
+ },
52
+ update: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
53
+ var appear, duration;
54
+
55
+ appear = ko.utils.unwrapObservable(valueAccessor());
56
+ duration = allBindingsAccessor().duration || 1000;
57
+ if (appear) {
58
+ $(element).slideDown(duration);
59
+ return $(element).focus();
60
+ } else {
61
+ return $(element).slideUp(duration);
62
+ }
63
+ }
64
+ };
65
+
66
+ ko.bindingHandlers.slidedownifnot = {
67
+ init: function(element, valueAccessor) {
68
+ var value;
69
+
70
+ value = ko.utils.unwrapObservable(valueAccessor());
71
+ return $(element).toggle(!value);
72
+ },
73
+ update: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
74
+ var appear, duration;
75
+
76
+ appear = ko.utils.unwrapObservable(valueAccessor());
77
+ duration = allBindingsAccessor().duration || 1000;
78
+ if (!appear) {
79
+ $(element).slideDown(duration);
80
+ return $(element).focus();
81
+ } else {
82
+ return $(element).slideUp(duration);
83
+ }
84
+ }
85
+ };
86
+
87
+ ko.bindingHandlers.slideleftif = {
88
+ init: function(element, valueAccessor) {
89
+ var value;
90
+
91
+ value = ko.utils.unwrapObservable(valueAccessor());
92
+ if (!value) {
93
+ $(element).hide();
94
+ return $(element).transition({
95
+ x: '10000px'
96
+ }, 1);
97
+ } else {
98
+ $(element).show();
99
+ return $(element).focus();
100
+ }
101
+ },
102
+ update: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
103
+ var appear, duration;
104
+
105
+ appear = ko.utils.unwrapObservable(valueAccessor());
106
+ duration = allBindingsAccessor().duration || 1000;
107
+ if (appear) {
108
+ $(element).show();
109
+ return $(element).transition({
110
+ x: 0
111
+ }, duration);
112
+ } else {
113
+ return $(element).transition({
114
+ x: '10000px'
115
+ }, duration, function() {
116
+ return $(element).hide();
117
+ });
118
+ }
119
+ }
120
+ };
121
+
122
+ ko.bindingHandlers.slideleftifnot = {
123
+ init: function(element, valueAccessor) {
124
+ var value;
125
+
126
+ value = ko.utils.unwrapObservable(valueAccessor());
127
+ if (value) {
128
+ $(element).hide();
129
+ return $(element).transition({
130
+ x: '10000px'
131
+ }, 1);
132
+ } else {
133
+ $(element).show();
134
+ return $(element).focus();
135
+ }
136
+ },
137
+ update: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
138
+ var appear, duration;
139
+
140
+ appear = ko.utils.unwrapObservable(valueAccessor());
141
+ duration = allBindingsAccessor().duration || 1000;
142
+ if (!appear) {
143
+ $(element).show();
144
+ return $(element).transition({
145
+ x: 0
146
+ }, duration);
147
+ } else {
148
+ return $(element).transition({
149
+ x: '10000px'
150
+ }, duration, function() {
151
+ return $(element).hide();
152
+ });
153
+ }
154
+ }
155
+ };
156
+
157
+ ko.bindingHandlers.sliderightif = {
158
+ init: function(element, valueAccessor) {
159
+ var value;
160
+
161
+ value = ko.utils.unwrapObservable(valueAccessor());
162
+ if (!value) {
163
+ $(element).hide();
164
+ return $(element).transition({
165
+ x: '-10000px'
166
+ }, 1);
167
+ } else {
168
+ $(element).show();
169
+ return $(element).focus();
170
+ }
171
+ },
172
+ update: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
173
+ var appear, duration;
174
+
175
+ appear = ko.utils.unwrapObservable(valueAccessor());
176
+ duration = allBindingsAccessor().duration || 1000;
177
+ if (appear) {
178
+ $(element).show();
179
+ return $(element).transition({
180
+ x: 0
181
+ }, duration);
182
+ } else {
183
+ return $(element).transition({
184
+ x: '-10000px'
185
+ }, duration, function() {
186
+ return $(element).hide();
187
+ });
188
+ }
189
+ }
190
+ };
191
+
192
+ ko.bindingHandlers.sliderightifnot = {
193
+ init: function(element, valueAccessor) {
194
+ var value;
195
+
196
+ value = ko.utils.unwrapObservable(valueAccessor());
197
+ if (value) {
198
+ $(element).hide();
199
+ return $(element).transition({
200
+ x: '-10000px'
201
+ }, 1);
202
+ } else {
203
+ $(element).show();
204
+ return $(element).focus();
205
+ }
206
+ },
207
+ update: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
208
+ var appear, duration;
209
+
210
+ appear = ko.utils.unwrapObservable(valueAccessor());
211
+ duration = allBindingsAccessor().duration || 1000;
212
+ if (!appear) {
213
+ $(element).show();
214
+ return $(element).transition({
215
+ x: 0
216
+ }, duration);
217
+ } else {
218
+ return $(element).transition({
219
+ x: '-10000px'
220
+ }, duration, function() {
221
+ return $(element).hide();
222
+ });
223
+ }
224
+ }
225
+ };
226
+
227
+ ko.bindingHandlers.swipeleft = {
228
+ init: function(element, valueAccessor) {
229
+ return Hammer(element).on('swipeleft', function(event) {
230
+ var value;
231
+
232
+ value = valueAccessor();
233
+ return value(event);
234
+ });
235
+ }
236
+ };
237
+
238
+ ko.bindingHandlers.swiperight = {
239
+ init: function(element, valueAccessor) {
240
+ return Hammer(element).on('swiperight', function(event) {
241
+ var value;
242
+
243
+ value = valueAccessor();
244
+ return value(event);
245
+ });
246
+ }
247
+ };
248
+
249
+ ko.bindingHandlers.swipeup = {
250
+ init: function(element, valueAccessor) {
251
+ return Hammer(element).on('swipeup', function(event) {
252
+ var value;
253
+
254
+ value = valueAccessor();
255
+ return value(event);
256
+ });
257
+ }
258
+ };
259
+
260
+ ko.bindingHandlers.swipedown = {
261
+ init: function(element, valueAccessor) {
262
+ return Hammer(element).on('swipedown', function(event) {
263
+ var value;
264
+
265
+ value = valueAccessor();
266
+ return value(event);
267
+ });
268
+ }
269
+ };
270
+
271
+ ko.bindingHandlers.fileupload = {
272
+ init: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
273
+ var onComplete, onStartUpload, options, parameter, property, uploadFile, url,
274
+ _this = this;
275
+
276
+ options = ko.utils.unwrapObservable(valueAccessor());
277
+ property = ko.utils.unwrapObservable(options.property);
278
+ parameter = ko.utils.unwrapObservable(options.parameter);
279
+ onStartUpload = ko.utils.unwrapObservable(options.onStartUpload);
280
+ onComplete = ko.utils.unwrapObservable(options.onComplete);
281
+ url = ko.utils.unwrapObservable(options.url);
282
+ if (!(property && url && parameter)) {
283
+ return false;
284
+ }
285
+ uploadFile = function(file) {
286
+ var formData, xhr;
287
+
288
+ if (viewModel[onStartUpload] != null) {
289
+ viewModel[onStartUpload]();
290
+ }
291
+ formData = new FormData;
292
+ formData.append(parameter, file);
293
+ xhr = new XMLHttpRequest;
294
+ xhr.addEventListener('load', function(event) {
295
+ if (viewModel[onComplete] != null) {
296
+ return viewModel[onComplete]();
297
+ }
298
+ });
299
+ xhr.open('POST', url);
300
+ return xhr.send(formData);
301
+ };
302
+ element.addEventListener('drop', function(event) {
303
+ var files;
304
+
305
+ event.stopPropagation();
306
+ event.preventDefault();
307
+ files = event.dataTransfer.files;
308
+ if (!(files.length > 0)) {
309
+ return;
310
+ }
311
+ return uploadFile(files[0]);
312
+ });
313
+ element.addEventListener('change', function(event) {
314
+ var file;
315
+
316
+ event.stopPropagation();
317
+ event.preventDefault();
318
+ file = event.target.files[0];
319
+ return uploadFile(file);
320
+ });
321
+ return true;
322
+ }
323
+ };
324
+
325
+ ko.bindingHandlers.wysiwyg = {
326
+ init: function(element, valueAccessor, allBindingsAccessor) {
327
+ var value,
328
+ _this = this;
329
+
330
+ value = ko.utils.unwrapObservable(valueAccessor());
331
+ $(element).wysiwyg();
332
+ $(element).bind('blur keyup paste copy cut mouseup', function() {
333
+ var newValue, observable;
334
+
335
+ $(element).attr('data-edit-in-progress', 'true');
336
+ observable = valueAccessor();
337
+ newValue = $(element).cleanHtml();
338
+ observable(newValue);
339
+ return $(element).attr('data-edit-in-progress', '');
340
+ });
341
+ return ko.utils.domNodeDisposal.addDisposeCallback(element, function() {
342
+ return $(element).wysiwyg('destroy');
343
+ });
344
+ },
345
+ update: function(element, valueAccessor) {
346
+ var value;
347
+
348
+ if ($(element).attr('data-edit-in-progress') === 'true') {
349
+ return;
350
+ }
351
+ value = ko.utils.unwrapObservable(valueAccessor());
352
+ $(element).html(value);
353
+ return ko.bindingHandlers.value.update(element, valueAccessor);
354
+ }
355
+ };
356
+
357
+ }).call(this);
@@ -0,0 +1,446 @@
1
+ // Generated by CoffeeScript 1.6.2
2
+ (function() {
3
+ var Db, Model, ViewModel,
4
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
5
+
6
+ ViewModel = (function() {
7
+ function ViewModel() {
8
+ var _this = this;
9
+
10
+ this.loading = ko.observable(false);
11
+ this.flashMessage = ko.observable('');
12
+ this.flashMessage.subscribe(function(newValue) {
13
+ if ((newValue != null) && newValue !== '') {
14
+ setTimeout(function() {
15
+ return _this.flashMessage('');
16
+ }, 10000);
17
+ }
18
+ return true;
19
+ });
20
+ this.errorMessage = ko.observable('');
21
+ this.errorMessage.subscribe(function(newValue) {
22
+ if ((newValue != null) && newValue !== '') {
23
+ setTimeout(function() {
24
+ return _this.errorMessage('');
25
+ }, 10000);
26
+ }
27
+ return true;
28
+ });
29
+ }
30
+
31
+ ViewModel.prototype.systemNotification = function(name, value) {
32
+ $('body').attr("data-" + name, value);
33
+ return this.loading(/ing$/.test(value));
34
+ };
35
+
36
+ ViewModel.prototype.flashPanel = function(elementId) {
37
+ var _this = this;
38
+
39
+ $(elementId).fadeIn();
40
+ return setTimeout(function() {
41
+ return $(elementId).fadeOut();
42
+ }, 10000);
43
+ };
44
+
45
+ return ViewModel;
46
+
47
+ })();
48
+
49
+ Db = (function() {
50
+ function Db(viewModel, name, url, pushStateUri) {
51
+ var _this = this;
52
+
53
+ this.viewModel = viewModel;
54
+ this.name = name;
55
+ this.pushStateUri = pushStateUri;
56
+ this.errorMessage = __bind(this.errorMessage, this);
57
+ this.flashMessage = __bind(this.flashMessage, this);
58
+ this.doDelete = __bind(this.doDelete, this);
59
+ this.urlFor = __bind(this.urlFor, this);
60
+ this.toJS = __bind(this.toJS, this);
61
+ this.itemDataFrom = __bind(this.itemDataFrom, this);
62
+ this.newItem = __bind(this.newItem, this);
63
+ this.doDestroy = __bind(this.doDestroy, this);
64
+ this.doUpdate = __bind(this.doUpdate, this);
65
+ this.doCreate = __bind(this.doCreate, this);
66
+ this.doLoad = __bind(this.doLoad, this);
67
+ this.save = __bind(this.save, this);
68
+ this.add = __bind(this.add, this);
69
+ this.load = __bind(this.load, this);
70
+ this.canLoad = __bind(this.canLoad, this);
71
+ this.findOrCreate = __bind(this.findOrCreate, this);
72
+ this.find = __bind(this.find, this);
73
+ this.url = ko.observable(url);
74
+ this.createUrl = ko.observable(url);
75
+ this.items = ko.observableArray([]);
76
+ this.selected = ko.observable(null);
77
+ this.selected.subscribe(function(newValue) {
78
+ if (_this.selected() == null) {
79
+ return;
80
+ }
81
+ if (_this.selected().hasBeenSelected) {
82
+ return _this.selected().hasBeenSelected();
83
+ }
84
+ });
85
+ this.plural = "" + this.name + "s";
86
+ this.sortFunction = null;
87
+ this.onAfterLoad = null;
88
+ this.onBeforeLoad = null;
89
+ this.onAfterDelete = null;
90
+ this.onAfterSave = null;
91
+ this.onAfterPost = null;
92
+ this.autoLoading = false;
93
+ this.loading = false;
94
+ this.url.subscribe(function(newValue) {
95
+ if (newValue != null) {
96
+ return _this.load(false);
97
+ }
98
+ });
99
+ if ((this.pushStateUri != null) && (history.pushState != null)) {
100
+ this.selected.subscribe(function(newValue) {
101
+ if ((newValue != null) && (newValue.id != null)) {
102
+ return history.pushState(_this.selected().name(), _this.selected().name(), "" + _this.pushStateUri + "/" + (_this.selected().id));
103
+ } else {
104
+ return history.pushState('', '', _this.pushStateUri);
105
+ }
106
+ });
107
+ }
108
+ }
109
+
110
+ Db.prototype.find = function(id) {
111
+ var item, _i, _len, _ref;
112
+
113
+ _ref = this.items();
114
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
115
+ item = _ref[_i];
116
+ if (item.id === id) {
117
+ return item;
118
+ }
119
+ }
120
+ return null;
121
+ };
122
+
123
+ Db.prototype.findOrCreate = function(id) {
124
+ var item;
125
+
126
+ item = this.find(id);
127
+ if (item == null) {
128
+ item = this.newItem(id);
129
+ this.items.push(item);
130
+ }
131
+ return item;
132
+ };
133
+
134
+ Db.prototype.canLoad = function() {
135
+ if ((this.url() == null) || this.url() === '') {
136
+ return false;
137
+ }
138
+ return true;
139
+ };
140
+
141
+ Db.prototype.load = function(autoReload, afterLoad) {
142
+ var _this = this;
143
+
144
+ if (autoReload == null) {
145
+ autoReload = false;
146
+ }
147
+ if (afterLoad == null) {
148
+ afterLoad = null;
149
+ }
150
+ if (!this.canLoad()) {
151
+ return;
152
+ }
153
+ if (!this.selected()) {
154
+ this.viewModel.systemNotification(this.plural, 'loading');
155
+ this.viewModel.loading(true);
156
+ if (this.onBeforeLoad != null) {
157
+ this.onBeforeLoad();
158
+ }
159
+ $.get(this.url(), function(data) {
160
+ _this.doLoad(data);
161
+ if (afterLoad != null) {
162
+ afterLoad(data);
163
+ }
164
+ if (_this.onAfterLoad != null) {
165
+ _this.onAfterLoad(data);
166
+ }
167
+ _this.viewModel.loading(false);
168
+ return _this.viewModel.systemNotification(_this.plural, 'loaded');
169
+ });
170
+ }
171
+ if (autoReload) {
172
+ this.autoLoading = true;
173
+ setTimeout(function() {
174
+ return _this.load(true, afterLoad);
175
+ }, 30000);
176
+ }
177
+ return false;
178
+ };
179
+
180
+ Db.prototype.postTo = function(url, data, afterPost) {
181
+ var _this = this;
182
+
183
+ this.viewModel.systemNotification(this.name, 'saving');
184
+ this.viewModel.loading(true);
185
+ $.ajax({
186
+ url: url,
187
+ dataType: 'json',
188
+ type: 'POST',
189
+ data: data,
190
+ success: function(data) {
191
+ if (afterPost != null) {
192
+ afterPost(data);
193
+ }
194
+ if (_this.onAfterPost != null) {
195
+ _this.onAfterPost(data);
196
+ }
197
+ _this.viewModel.loading(false);
198
+ _this.viewModel.systemNotification(_this.name, 'saved');
199
+ return _this.load(false);
200
+ }
201
+ });
202
+ return true;
203
+ };
204
+
205
+ Db.prototype.add = function() {
206
+ var itemToAdd;
207
+
208
+ itemToAdd = this.newItem(null);
209
+ this.selected(itemToAdd);
210
+ this.viewModel.systemNotification(this.name, 'new');
211
+ return itemToAdd;
212
+ };
213
+
214
+ Db.prototype.save = function(item, afterSave, onError) {
215
+ if (!item.valid() && (onError != null)) {
216
+ onError();
217
+ }
218
+ if (item.id != null) {
219
+ return this.doUpdate(item, afterSave);
220
+ } else {
221
+ return this.doCreate(item, afterSave);
222
+ }
223
+ };
224
+
225
+ Db.prototype.doLoad = function(data) {
226
+ var item, itemData, _i, _len, _ref;
227
+
228
+ _ref = this.itemDataFrom(data);
229
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
230
+ itemData = _ref[_i];
231
+ item = this.findOrCreate(itemData.id);
232
+ if (item.updating != null) {
233
+ item.updating(true);
234
+ }
235
+ item.updateAttributes(itemData);
236
+ if (item.updating != null) {
237
+ item.updating(false);
238
+ }
239
+ }
240
+ if (this.sortFunction != null) {
241
+ return this.items.sort(this.sortFunction);
242
+ }
243
+ };
244
+
245
+ Db.prototype.doCreate = function(item, afterSave) {
246
+ var _this = this;
247
+
248
+ this.viewModel.systemNotification(this.name, 'saving');
249
+ this.viewModel.loading(true);
250
+ $.ajax({
251
+ url: this.createUrl(),
252
+ dataType: 'json',
253
+ type: 'POST',
254
+ data: this.toJS(item),
255
+ success: function(data) {
256
+ if (data.id != null) {
257
+ item.id = data.id;
258
+ }
259
+ _this.selected(null);
260
+ if (afterSave != null) {
261
+ afterSave(item);
262
+ }
263
+ if (_this.onAfterSave != null) {
264
+ _this.onAfterSave(item);
265
+ }
266
+ _this.viewModel.systemNotification(_this.name, 'saved');
267
+ _this.viewModel.loading(false);
268
+ return _this.load();
269
+ }
270
+ });
271
+ return false;
272
+ };
273
+
274
+ Db.prototype.doUpdate = function(item, afterSave) {
275
+ var _this = this;
276
+
277
+ this.viewModel.systemNotification(this.name, 'saving');
278
+ this.viewModel.loading(true);
279
+ $.ajax({
280
+ url: this.urlFor(item),
281
+ dataType: 'json',
282
+ type: 'PUT',
283
+ data: this.toJS(item),
284
+ success: function(data) {
285
+ _this.selected(null);
286
+ if (afterSave != null) {
287
+ afterSave(item);
288
+ }
289
+ if (_this.onAfterSave != null) {
290
+ _this.onAfterSave(item);
291
+ }
292
+ _this.viewModel.systemNotification(_this.name, 'saved');
293
+ _this.viewModel.loading(false);
294
+ return _this.load();
295
+ }
296
+ });
297
+ return false;
298
+ };
299
+
300
+ Db.prototype.doDestroy = function(item, afterDelete) {
301
+ var _this = this;
302
+
303
+ this.viewModel.systemNotification(this.name, 'deleting');
304
+ this.viewModel.loading(true);
305
+ $.ajax({
306
+ url: this.urlFor(item),
307
+ dataType: 'json',
308
+ type: 'DELETE',
309
+ success: function(data) {
310
+ _this.selected(null);
311
+ _this.items.remove(item);
312
+ if (afterDelete != null) {
313
+ afterDelete();
314
+ }
315
+ if (_this.onAfterDelete != null) {
316
+ _this.onAfterDelete(item);
317
+ }
318
+ _this.viewModel.systemNotification(_this.name, 'deleted');
319
+ _this.viewModel.loading(false);
320
+ return _this.load();
321
+ }
322
+ });
323
+ return false;
324
+ };
325
+
326
+ Db.prototype.newItem = function(id) {
327
+ return null;
328
+ };
329
+
330
+ Db.prototype.itemDataFrom = function(data) {
331
+ return null;
332
+ };
333
+
334
+ Db.prototype.toJS = function(item) {
335
+ return null;
336
+ };
337
+
338
+ Db.prototype.urlFor = function(item) {
339
+ return null;
340
+ };
341
+
342
+ Db.prototype.doDelete = function(client) {
343
+ return null;
344
+ };
345
+
346
+ Db.prototype.flashMessage = function(message) {
347
+ return this.viewModel.flashMessage(message);
348
+ };
349
+
350
+ Db.prototype.errorMessage = function(message) {
351
+ return this.viewModel.errorMessage(message);
352
+ };
353
+
354
+ return Db;
355
+
356
+ })();
357
+
358
+ Model = (function() {
359
+ function Model(id, db) {
360
+ var _this = this;
361
+
362
+ this.id = id;
363
+ this.db = db;
364
+ this.elementSelector = __bind(this.elementSelector, this);
365
+ this.elementId = __bind(this.elementId, this);
366
+ this.viewModel = __bind(this.viewModel, this);
367
+ this.editing = ko.observable(false);
368
+ this.deleting = ko.observable(false);
369
+ this.updating = ko.observable(false);
370
+ this.selected = ko.computed(function() {
371
+ return _this.db.selected() === _this;
372
+ });
373
+ }
374
+
375
+ Model.prototype.viewModel = function() {
376
+ return this.db.viewModel;
377
+ };
378
+
379
+ Model.prototype.elementId = function() {
380
+ return "" + this.db.name + "-" + this.id;
381
+ };
382
+
383
+ Model.prototype.elementSelector = function() {
384
+ return "#" + (this.elementId());
385
+ };
386
+
387
+ Model.prototype.updateAttributes = function(data) {
388
+ return null;
389
+ };
390
+
391
+ Model.prototype.valid = function() {
392
+ return true;
393
+ };
394
+
395
+ Model.prototype.select = function() {
396
+ return this.db.selected(this);
397
+ };
398
+
399
+ Model.prototype.deselect = function() {
400
+ this.deleting(false);
401
+ this.editing(false);
402
+ return this.db.selected(null);
403
+ };
404
+
405
+ Model.prototype.hasBeenSelected = function() {};
406
+
407
+ Model.prototype.edit = function() {
408
+ this.select();
409
+ return this.editing(true);
410
+ };
411
+
412
+ Model.prototype.startDeleting = function() {
413
+ this.edit();
414
+ return this.deleting(true);
415
+ };
416
+
417
+ Model.prototype.stopDeleting = function() {
418
+ return this.deleting(false);
419
+ };
420
+
421
+ Model.prototype.save = function() {
422
+ if (!this.valid()) {
423
+ return;
424
+ }
425
+ this.deselect();
426
+ return this.db.save(this);
427
+ };
428
+
429
+ Model.prototype.doDestroy = function() {
430
+ this.deselect();
431
+ return this.db.doDestroy(this);
432
+ };
433
+
434
+ return Model;
435
+
436
+ })();
437
+
438
+ window.ViewModel = ViewModel;
439
+
440
+ window.Db = Db;
441
+
442
+ window.Model = Model;
443
+
444
+ window.viewModel = new ViewModel;
445
+
446
+ }).call(this);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kolo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rahoul Baruah
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-28 00:00:00.000000000 Z
11
+ date: 2014-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -73,6 +73,8 @@ files:
73
73
  - lib/kolo.rb
74
74
  - lib/kolo/icons.rb
75
75
  - lib/kolo/version.rb
76
+ - public/js/bindings.js
77
+ - public/js/data-access.js
76
78
  homepage: ''
77
79
  licenses:
78
80
  - LGPL