final move of files
[web.mtrack] / MTrackWeb / templates / images / js / mtrack.watch.js
1 // <script type="text/javascript">
2
3 mtrack = typeof(mtrack) == 'undefined' ? {} : mtrack;
4
5 /**
6  * new mtrack.watch({ objname = 'ticket' , objid : '123', domid : 'subscribers' });
7  * 
8  */
9 mtrack.watch = function(cfg)
10 {
11     for(var i in cfg) {
12         this[i] = cfg[i];
13     }
14     this.url = baseURL + '/Watch';
15     this.load();
16 }
17  
18       
19 mtrack.watch.prototype = {
20     // watch -> click -> send url.. update UI...
21     /**
22      * 
23      * cfg: 
24      *   objname : 
25      *   objid
26      *   userid
27      *   
28      *   elname : dom id to replace with new watch results..
29      */
30     addUser : function (userid)
31     {
32         var _this = this;
33         //console.log('#' + this.domid);
34         $('#' + this.domid).load(this.url,
35             {
36                 objname: this.objname,
37                 objid :  this.objid,
38                 userid:  userid
39             }, 
40             function () {
41                 
42                 $('select.subscribe-add').change(function()  {
43                     if (!$(this).val().length) {
44                         return;
45                     }
46                     _this.addUser($(this).val());
47                     
48                 });
49             }
50             
51         );
52          
53          
54     },
55     removeUser : function (userid)
56     {
57         // confirm???
58         
59     },
60     
61     
62     
63     load : function ()
64     {
65         var _this = this;
66         $('#' + this.domid).load(this.url + '?'  + jQuery.param({
67             objname : this.objname,
68             objid : this.objid
69            }),
70            function() {
71             // add hooks to elements...
72                 $('select.subscribe-add').change(function()  {
73                     
74                    
75                     if (!$(this).val().length) {
76                         return;
77                     }
78                   //  console.log("call add user with" + $(this).val()); 
79                      //return;
80                     _this.addUser($(this).val());
81                     
82                 });
83             
84         });
85     }
86 }