1universe.basket = (function ($, api) { 2 var self = {}; 3 var request = function (action, data, callback) { 4 universe.ajax('basket.' + action, data, callback); 5 }; 6 7 api.extend(self, api.ext.events(self, ['add', 'setQuantity', 'get', 'remove', 'clear', 'update', 'process', 'processed'])); 8 9 self.on('update', function(){ 10 self.trigger('processed'); 11 }); 12 13 self.add = function (data, callback) { 14 self.trigger('process', data.id); 15 request('add', data, function (response) { 16 if (response === true) { 17 if (api.isFunction(callback)) 18 callback.apply(null); 19 20 self.trigger('add', data); 21 self.trigger('update', 'add', data); 22 } 23 }); 24 }; 25 26 self.setQuantity = function (data, callback) { 27 self.trigger('process', data.id); 28 request('setQuantity', data, function (response) { 29 if (response === true) { 30 if (api.isFunction(callback)) 31 callback.apply(null); 32 33 self.trigger('setQuantity', data); 34 self.trigger('update', 'setQuantity', data); 35 } 36 }); 37 }; 38 39 self.remove = function (data, callback) { 40 request('remove', data, function (response) { 41 if (response === true) { 42 if (api.isFunction(callback)) 43 callback.apply(null); 44 45 self.trigger('remove', data); 46 self.trigger('update', 'remove', data); 47 } 48 }); 49 }; 50 51 self.clear = function (data, callback) { 52 request('clear', data, function (response) { 53 if (response === true) { 54 if (api.isFunction(callback)) 55 callback.apply(null); 56 57 self.trigger('clear', data); 58 self.trigger('update', 'clear', data); 59 } 60 }); 61 }; 62 63 self.update = function () { 64 self.trigger('update', 'update'); 65 }; 66 67 return self; 68})(jQuery, intec);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.