1 //<script type="text/javascript">
5 Pman.on('beforeload', function()
10 modKey : '002-pman-tab-builderevents',
11 module : Pman.Tab.BuilderEvents,
13 parent : Pman.Tab.BuilderTree,
14 name : "Builder Events"
19 Pman.Tab.BuilderEvents = {
23 currentNode : false, // pointer to edited node.
24 add : function(parentLayout, region) {
30 parentLayout.getRegion(region).showPanel(this.panel);
35 parentLayout.beginUpdate();
37 var frm = parentLayout.getRegion(region).getEl().createChild({tag:'div'});
38 //this.grid = new Roo.grid.EditorGrid(frm, {
39 this.grid = new Roo.grid.PropertyGrid(frm, {
40 id: 'grid-builderevents',
42 //nameText: 'Properties Grid',
46 // scrollOffset:2 // the grid will never have scrollbars
54 propertychange : function(s, id, v, ov) {
55 //console.log(id + ':'+ v);
56 _this.currentNode.elConfig.listeners = _this.currentNode.elConfig.listeners || {};
57 _this.currentNode.elConfig.listeners[id] = v;
58 // no need to update view..
59 //var bp = Pman.Tab.BuilderPanel;
60 //bp.redraw.defer(100,bp);
61 //_this.currentNode.setText(
62 // Pman.Tab.BuilderTree.configToText(_this.currentNode.elConfig)
65 cellclick :function (g, ri, ci, e)
67 // console.log('rowclick');
70 _this.menu.show(e.getTarget(), 'tr');
73 // other wise edith it!!!
74 var data = _this.grid.getDataSource().getAt(ri).data;
75 Pman.Dialog.BuilderSourceEdit.show({
79 _this.currentNode.elConfig.listeners[data.name] = d.value;
80 _this.setCurrrentNode(_this.currentNode);
81 // no point in redrawing the panel!!!
82 //var bp = Pman.Tab.BuilderPanel;
83 //bp.redraw.defer(100,bp);
90 // click on left col..
92 // _this.menu.show(e.getTarget(), 'tr');
98 this.menu = new Roo.menu.Menu({
102 text: 'Delete Listener',
104 handler : function() {
105 var rc = _this.grid.getSelectionModel().getSelectedCell();
106 var n = _this.grid.getDataSource().getAt(rc[0]).data.name;
108 delete _this.currentNode.elConfig.listeners[n];
109 _this.setCurrrentNode(_this.currentNode);
110 //var bp = Pman.Tab.BuilderPanel;
111 //bp.redraw.defer(100,bp);
112 //_this.currentNode.setText(
113 // Pman.Tab.BuilderTree.configToText(_this.currentNode.elConfig)
121 this.panel = parentLayout.add(region, new Roo.GridPanel(this.grid ,
122 { fitToframe: true,fitContainer: true, title: "Events", background: true })
126 this.grid.getColumnModel().renderPropDelegate = function(v,p) {
127 return String.format('<b qtip="{0}">{1}</b>', _this.getDesc(v),v );
130 var gridHead = this.grid.getView().getHeaderPanel(true);
131 //this.toolbar = new Roo.Toolbar(gridHead);
132 this.toolbar = new Roo.Toolbar(gridHead.createChild({tag: 'span'}));
136 this.addsel = new Roo.form.ComboBox({
151 url: baseURL + '/Builder/PropList.php',
156 beforeload: function(s, o) {
157 o.params = o.params || {};
158 if (!_this.currentNode || !_this.currentNode.elConfig) {
161 o.params.xtype = _this.currentNode.elConfig.xtype;
162 o.params.xns= _this.currentNode.elConfig['|xns'] || '';
163 o.params.view = 'listeners'
168 totalProperty : 'total',
170 xtype : 'JsonReader',
172 'name', 'desc', 'type', 'sig'
182 forceSelection: true,
184 triggerAction: 'all',
186 tpl: new Roo.Template(
187 '<div class="x-grid-cell-text x-btn button" qtip="\{desc\}">',
188 '<b >\{name\}</b> [\{type\}] ',
192 queryParam: 'query[name]',
193 loadingText: "Searching...",
199 select : function(cb, rec, ix) {
200 cb.lastData = rec.data;
201 _this.addProp(rec.data.name, rec.data.sig);
205 collapse : function()
207 this.lastQuery = '~~~~~~~~'; // force a query!
220 this.toolbar.add('Add:', this.addsel);
223 // add stuff to toolbar?
224 //this.innerLayout.endUpdate();
225 parentLayout.endUpdate();
230 setCurrrentNode : function(node) {
234 if (!node || !node.elConfig) {
235 this.currentNode = false;
237 p.view.el.mask('select a node');
239 node.elConfig.listeners= node.elConfig.listeners || { };
240 if (node.elConfig.listener) { // kludge to fix old bug.
241 delete node.elConfig.listener;
243 var config = node.elConfig.listeners;
246 // for anything that is a onject - ecode it to set it..
247 // probably should dupe the config first..
249 for (var k in config) {
254 this.currentNode = node;
255 this.setSource(ncfg);
257 //if (node.fEl == this.builderPanel) {
264 getDesc :function(prop) {
267 if (typeof(this.currentNode.elConfig) == 'undefined') {
270 var cfg = this.currentNode.elConfig;
272 var data = this.getPropDef(cfg.xtype, cfg['|xns']);
273 var pp= prop.replace('|', '');
275 if ((typeof(data[pp]) == 'undefined') || (typeof(data[pp].desc) == 'undefined')) {
278 return data[pp].desc;
284 getPropDef : function(xtype,xns)
287 this.propdefs = Pman.Tab.BuilderProps.propdefs;
289 var xpre = xns ? (xns + '.') : '';
290 if (typeof(this.propdefs[xpre + xtype]) != 'undefined') {
291 return this.propdefToMap(xpre + xtype);
294 for (var i in [ 'Roo', 'Roo.menu' , 'Roo.form', 'Roo.data', 'Roo.grid', 'Roo.Toolbar' ]) {
295 if (typeof(this.propdefs[i +'.' + xtype]) != 'undefined') {
296 return this.propdefToMap(i +'.' + xtype);
303 propdefToMap : function(cls)
306 if ((typeof(this.propdefs[cls].events) == 'undefined') || !this.propdefs[cls].events.length) {
309 Roo.each(this.propdefs[cls].events, function(c) {
316 setSource : function(ltns)
319 var et = {}; // editor type
322 et[k] = false; // not really...
325 _this.grid.customEditors = et;
326 _this.grid.setSource(ltns);
330 addProp: function (name, sig) { // messy but will do..
331 this.currentNode.elConfig.listeners = this.currentNode.elConfig.listeners || { };
333 var c = this.currentNode.elConfig.listeners;
334 if (typeof(c['|' +name]) != 'undefined') {
341 Pman.Dialog.BuilderSourceEdit.show({
345 _this.currentNode.elConfig.listeners['|'+ name] = d.value;
346 _this.setCurrrentNode(_this.currentNode);
347 //var bp = Pman.Tab.BuilderPanel;
348 //bp.redraw.defer(100,bp);
351 //this.currentNode.setText(
352 // Pman.Tab.BuilderTree.configToText(this.currentNode.elConfig)