Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Notification = can.DefineMap.extend({
- id: "integer",
- title: "string",
- text: "string",
- icon: "string",
- date: "string",
- looked: "string",
- });
- Notification.List = can.DefineList.extend({
- "#": Notification,
- });
- Notification.connection = can.connect.superMap({
- url: {
- resource: '/notifications'
- },
- Map: Notification,
- List: Notification.List,
- name: 'notification'
- });
- Notification.getList({}).then(bind(function(value){
- this.checkUnviewed(value); // Проверка новых сообщений
- this.notifications = value;
- }, this));
- /**
- * Проверяет есть ли новое сообщение
- * @param array
- */
- checkUnviewed: function(notifications){
- this.unviewed = notifications.some(function(item){
- return !item.looked;
- });
- },
Add Comment
Please, Sign In to add comment