summaryrefslogtreecommitdiff
path: root/skins/jason/help.js
blob: d41e642b28a149e54f97965d579afbb4d49acca8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
 * jason - Javascript based skin for xxv
 * Copyright(c) 2008-2012, anbr
 * 
 * http://projects.vdr-developer.org/projects/xxv
 *
 */

Ext.xxv.help = function(/*config*/){
    //Ext.xxv.help.superclass.constructor.call(this, config);
    //Ext.apply(this, config);

    this.store = new Ext.data.Store({
             baseParams:{cmd:'help'}
            ,autoLoad: true
            ,reader: new Ext.xxv.jsonReader({
                        fields: [
                                  {name: 'id', type: 'string'},
                                  {name: 'cmd', type: 'string'},
                                  {name: 'module', type: 'string'},
                                  {name: 'description', type: 'string'}
                                ]
                    })
            ,proxy : new Ext.data.HttpProxy({
                url: this.baseURL()
               ,method: 'GET'
            })
    });

    this.store.on('load', this.onLoad , this);
};


Ext.extend(Ext.xxv.help, Ext.util.Observable, {

  onLoad : function(store, records, options) {

    if(!this.cmdDisabled('ce')) {
      var lastModule;
      for(var i = 0, len = store.getCount(); i < len; i++){
        var record = store.getAt(i);
        if(!lastModule || record.data.module != lastModule) {
          lastModule = record.data.module;
          XXV.configMenu.add(new Ext.menu.Item(
            { 
               text: record.data.module
              ,disabled:false
              ,handler: this.Configure
              ,scope:this
            }));
        }
      }
    }
  }
  ,Configure : function(item, e) {
    if(e) {
      if(XXV.tab.formwin){
        XXV.tab.formwin.close();
      }
      XXV.tab.formwin = new Ext.xxv.Question({
         cmd:   'ce'
        ,id:    item.text
        ,title: item.text
      });
    }
  }
  ,Settings : function(item, e) {
    if(e) {
      if(XXV.tab.formwin){
        XXV.tab.formwin.close();
      }
      XXV.tab.formwin = new Ext.xxv.Question({
         cmd:   'up'
        ,title: item.text
      });
    }
  }
  ,baseURL: function(param) {
    if(!param) {
      param = {};
    }
    param.ajax = 'json';
    return '?' + Ext.urlEncode(param);
  }
  ,cmdHTML: function(cmd, param) {
    if(!param) {
      param = {};
    }
    param.cmd = cmd;
    return '?' + Ext.urlEncode(param);
  }
  ,cmdAJAX: function(cmd, param) {
    if(!param) {
      param = {};
    }
    param.cmd = cmd;
    param.ajax = 'json';
    return this.cmdHTML(cmd,param);
  }
  ,cmdAllowed: function(cmd) {
    var record = this.store.getById(cmd);
    return (record) ? true : false;
  }
  ,cmdDisabled: function(cmd) {
    var record = this.store.getById(cmd);
    return (record) ? false : true;
  }
});