Permalink
Browse files

Just updates the compiled js to version 0.5.0 (current src).

  • Loading branch information...
1 parent d225b84 commit 22e972078c7713081d137c4127c3c365b2493451 @alemangui alemangui committed Aug 21, 2013
Showing with 26 additions and 27 deletions.
  1. +26 −27 js/backbone_offline.js
@@ -1,9 +1,8 @@
-// Generated by CoffeeScript 1.4.0
+// Generated by CoffeeScript 1.6.3
(function() {
-
(function(global, _, Backbone) {
global.Offline = {
- VERSION: '0.4.3',
+ VERSION: '0.5.0',
localSync: function(method, model, options, store) {
var resp, _ref;
resp = (function() {
@@ -24,7 +23,7 @@
}
})();
if (resp) {
- return options.success(model, (_ref = resp.attributes) != null ? _ref : resp, options);
+ return options.success((_ref = resp.attributes) != null ? _ref : resp, options);
} else {
return typeof options.error === "function" ? options.error('Record not found') : void 0;
}
@@ -45,7 +44,6 @@
Backbone.ajaxSync = Backbone.sync;
Backbone.sync = Offline.sync;
Offline.Storage = (function() {
-
function Storage(name, collection, options) {
this.name = name;
this.collection = collection;
@@ -61,19 +59,23 @@
}
Storage.prototype.isLocalStorageSupport = function() {
+ var e;
try {
localStorage.setItem('isLocalStorageSupport', '1');
localStorage.removeItem('isLocalStorageSupport');
return true;
- } catch (e) {
+ } catch (_error) {
+ e = _error;
return false;
}
};
Storage.prototype.setItem = function(key, value) {
+ var e;
try {
return localStorage.setItem(key, value);
- } catch (e) {
+ } catch (_error) {
+ e = _error;
if (e.name === 'QUOTA_EXCEEDED_ERR') {
return this.collection.trigger('quota_exceed');
} else {
@@ -163,15 +165,15 @@
};
Storage.prototype.save = function(item, options) {
- var id, _ref, _ref1;
+ var newId, _ref, _ref1;
if (options == null) {
options = {};
}
if (options.regenerateId) {
- id = options.id === 'mid' ? this.mid() : this.guid();
+ newId = options.id === 'mid' ? this.mid() : this.guid();
item.set({
sid: ((_ref = item.attributes) != null ? _ref.sid : void 0) || ((_ref1 = item.attributes) != null ? _ref1.id : void 0) || 'new',
- id: id
+ id: newId
});
}
if (!options.local) {
@@ -252,7 +254,6 @@
})();
Offline.Sync = (function() {
-
function Sync(collection, storage) {
this.collection = new Offline.Collection(collection);
this.storage = storage;
@@ -273,14 +274,14 @@
options = {};
}
return this.ajax('read', this.collection.items, _.extend({}, options, {
- success: function(model, response, opts) {
+ success: function(models, opts) {
var item, _i, _len;
_this.storage.clear();
_this.collection.items.reset([], {
silent: true
});
- for (_i = 0, _len = response.length; _i < _len; _i++) {
- item = response[_i];
+ for (_i = 0, _len = models.length; _i < _len; _i++) {
+ item = models[_i];
_this.collection.items.create(item, {
silent: true,
local: true,
@@ -291,7 +292,7 @@
_this.collection.items.trigger('reset');
}
if (options.success) {
- return options.success(model, response, opts);
+ return options.success(models, opts);
}
}
}));
@@ -315,8 +316,8 @@
if (this.storage.getItem('offline')) {
this.storage.removeItem('offline');
success = options.success;
- return options.success = function(model, response, opts) {
- success(model, response, opts);
+ return options.success = function(model, opts) {
+ success(model, opts);
return _this.incremental();
};
}
@@ -328,15 +329,15 @@
options = {};
}
return this.ajax('read', this.collection.items, _.extend({}, options, {
- success: function(model, response, opts) {
+ success: function(models, opts) {
var item, _i, _len;
- _this.collection.destroyDiff(response);
- for (_i = 0, _len = response.length; _i < _len; _i++) {
- item = response[_i];
+ _this.collection.destroyDiff(models);
+ for (_i = 0, _len = models.length; _i < _len; _i++) {
+ item = models[_i];
_this.pullItem(item);
}
if (options.success) {
- return options.success(model, response, opts);
+ return options.success(models, opts);
}
}
}));
@@ -395,10 +396,10 @@
delete item.attributes.id;
_ref = item.get('sid') === 'new' ? ['create', null] : ['update', item.attributes.sid], method = _ref[0], item.id = _ref[1];
this.ajax(method, item, {
- success: function(model, response, opts) {
+ success: function(model, opts) {
if (method === 'create') {
item.set({
- sid: response.id
+ sid: model.id
});
}
return item.save({
@@ -417,7 +418,7 @@
_this = this;
model = this.collection.fakeModel(sid);
return this.ajax('delete', model, {
- success: function(model, response, opts) {
+ success: function(model, opts) {
return _this.storage.destroyIds.remove(sid);
}
});
@@ -427,7 +428,6 @@
})();
Offline.Index = (function() {
-
function Index(name, storage) {
var store;
this.name = name;
@@ -461,7 +461,6 @@
})();
return Offline.Collection = (function() {
-
function Collection(items) {
this.items = items;
}

0 comments on commit 22e9720

Please sign in to comment.