From 04cf441c5ae18400c6b4865b0b37a71718dc9d46 Mon Sep 17 00:00:00 2001 From: Ola Bini Date: Thu, 31 Jul 2014 19:29:33 -0300 Subject: Add web-ui based on previous code --- web-ui/app/js/tags/data/tags.js | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 web-ui/app/js/tags/data/tags.js (limited to 'web-ui/app/js/tags/data') diff --git a/web-ui/app/js/tags/data/tags.js b/web-ui/app/js/tags/data/tags.js new file mode 100644 index 00000000..96f08b99 --- /dev/null +++ b/web-ui/app/js/tags/data/tags.js @@ -0,0 +1,42 @@ +define(['flight/lib/component', 'page/events'], function (defineComponent, events) { + 'use strict'; + + var DataTags = defineComponent(dataTags); + + DataTags.all = { + name: 'all', + ident: '8752888923742657436', + query: 'in:all', + default: true, + counts:{ + total:0, + read:0, + starred:0, + replied:0 + } + }; + + return DataTags; + + function dataTags() { + function sendTagsBackTo(on, params) { + return function(data) { + data.push(DataTags.all); + on.trigger(params.caller, events.tags.received, {tags: data}); + }; + } + + this.defaultAttrs({ + tagsResource: '/tags' + }); + + this.fetchTags = function(event, params) { + $.ajax(this.attr.tagsResource) + .done(sendTagsBackTo(this, params)); + }; + + this.after('initialize', function () { + this.on(document, events.tags.want, this.fetchTags); + }); + } +}); -- cgit v1.2.3