diff --git a/src/webui/static/app/acleditor.js b/src/webui/static/app/acleditor.js index eaeddbf4..1b55fae6 100644 --- a/src/webui/static/app/acleditor.js +++ b/src/webui/static/app/acleditor.js @@ -1,84 +1,75 @@ - tvheadend.acleditor = function() { - var fm = Ext.form; - - var enabledColumn = new Ext.grid.CheckColumn({ - header: "Enabled", - dataIndex: 'enabled', - width: 60 - }); + var fm = Ext.form; - var streamingColumn = new Ext.grid.CheckColumn({ - header: "Streaming", - dataIndex: 'streaming', - width: 100 - }); + var enabledColumn = new Ext.grid.CheckColumn({ + header : "Enabled", + dataIndex : 'enabled', + width : 60 + }); - var dvrColumn = new Ext.grid.CheckColumn({ - header: "Video Recorder", - dataIndex: 'dvr', - width: 100 - }); + var streamingColumn = new Ext.grid.CheckColumn({ + header : "Streaming", + dataIndex : 'streaming', + width : 100 + }); - var dvrallcfgColumn = new Ext.grid.CheckColumn({ - header: "All Configs (VR)", - dataIndex: 'dvrallcfg', - width: 100 - }); + var dvrColumn = new Ext.grid.CheckColumn({ + header : "Video Recorder", + dataIndex : 'dvr', + width : 100 + }); - var webuiColumn = new Ext.grid.CheckColumn({ - header: "Web Interface", - dataIndex: 'webui', - width: 100 - }); + var dvrallcfgColumn = new Ext.grid.CheckColumn({ + header : "All Configs (VR)", + dataIndex : 'dvrallcfg', + width : 100 + }); - var adminColumn = new Ext.grid.CheckColumn({ - header: "Admin", - dataIndex: 'admin', - width: 100 - }); + var webuiColumn = new Ext.grid.CheckColumn({ + header : "Web Interface", + dataIndex : 'webui', + width : 100 + }); - var cm = new Ext.grid.ColumnModel([ - enabledColumn, - { - header: "Username", - dataIndex: 'username', - editor: new fm.TextField({allowBlank: false}) - },{ - header: "Password", - dataIndex: 'password', - renderer: function(value, metadata, record, row, col, store) { - return 'Hidden'; - }, - editor: new fm.TextField({allowBlank: false}) - },{ - header: "Prefix", - dataIndex: 'prefix', - editor: new fm.TextField({allowBlank: false}) - }, - streamingColumn, - dvrColumn, - dvrallcfgColumn, - webuiColumn, - adminColumn, - { - header: "Comment", - dataIndex: 'comment', - width: 400, - editor: new fm.TextField({}) - } - ]); - - var UserRecord = Ext.data.Record.create([ - 'enabled','streaming','dvr','dvrallcfg','admin','webui','username', - 'prefix','password','comment' - ]); + var adminColumn = new Ext.grid.CheckColumn({ + header : "Admin", + dataIndex : 'admin', + width : 100 + }); - return new tvheadend.tableEditor('Access control', 'accesscontrol', cm, - UserRecord, - [enabledColumn, streamingColumn, - dvrColumn, dvrallcfgColumn, webuiColumn, - adminColumn], - null, - 'config_access.html', 'group'); + var cm = new Ext.grid.ColumnModel([ enabledColumn, { + header : "Username", + dataIndex : 'username', + editor : new fm.TextField({ + allowBlank : false + }) + }, { + header : "Password", + dataIndex : 'password', + renderer : function(value, metadata, record, row, col, store) { + return 'Hidden'; + }, + editor : new fm.TextField({ + allowBlank : false + }) + }, { + header : "Prefix", + dataIndex : 'prefix', + editor : new fm.TextField({ + allowBlank : false + }) + }, streamingColumn, dvrColumn, dvrallcfgColumn, webuiColumn, adminColumn, { + header : "Comment", + dataIndex : 'comment', + width : 400, + editor : new fm.TextField({}) + } ]); + + var UserRecord = Ext.data.Record.create([ 'enabled', 'streaming', 'dvr', + 'dvrallcfg', 'admin', 'webui', 'username', 'prefix', 'password', + 'comment' ]); + + return new tvheadend.tableEditor('Access control', 'accesscontrol', cm, + UserRecord, [ enabledColumn, streamingColumn, dvrColumn, dvrallcfgColumn, + webuiColumn, adminColumn ], null, 'config_access.html', 'group'); } diff --git a/src/webui/static/app/capmteditor.js b/src/webui/static/app/capmteditor.js index 7ba42441..469c5f2f 100644 --- a/src/webui/static/app/capmteditor.js +++ b/src/webui/static/app/capmteditor.js @@ -1,77 +1,79 @@ - tvheadend.capmteditor = function() { - var fm = Ext.form; - - var enabledColumn = new Ext.grid.CheckColumn({ - header: "Enabled", - dataIndex: 'enabled', - width: 60 - }); + var fm = Ext.form; - function setMetaAttr(meta, record){ - var enabled = record.get('enabled'); - if(!enabled) return; + var enabledColumn = new Ext.grid.CheckColumn({ + header : "Enabled", + dataIndex : 'enabled', + width : 60 + }); - var connected = record.get('connected'); - if(connected == 1){ - meta.attr = 'style="color:green;"'; - } else { - meta.attr = 'style="color:red;"'; - } - } + function setMetaAttr(meta, record) { + var enabled = record.get('enabled'); + if (!enabled) return; - var cm = new Ext.grid.ColumnModel([ - enabledColumn, - { - header: "Camd.socket Filename", - dataIndex: 'camdfilename', - width: 200, - renderer: function(value, metadata, record, row, col, store) { - setMetaAttr(metadata, record); - return value; - }, - editor: new fm.TextField({allowBlank: false}) - },{ - header: "Listenport", - dataIndex: 'port', - renderer: function(value, metadata, record, row, col, store) { - setMetaAttr(metadata, record); - return value; - }, - editor: new fm.TextField({allowBlank: false}) - },{ - header: "Comment", - dataIndex: 'comment', - width: 400, - renderer: function(value, metadata, record, row, col, store) { - setMetaAttr(metadata, record); - return value; - }, - editor: new fm.TextField() + var connected = record.get('connected'); + if (connected == 1) { + meta.attr = 'style="color:green;"'; + } + else { + meta.attr = 'style="color:red;"'; + } } - ]); - var rec = Ext.data.Record.create([ - 'enabled','connected','camdfilename','port','comment' - ]); + var cm = new Ext.grid.ColumnModel([ enabledColumn, { + header : "Camd.socket Filename", + dataIndex : 'camdfilename', + width : 200, + renderer : function(value, metadata, record, row, col, store) { + setMetaAttr(metadata, record); + return value; + }, + editor : new fm.TextField({ + allowBlank : false + }) + }, { + header : "Listenport", + dataIndex : 'port', + renderer : function(value, metadata, record, row, col, store) { + setMetaAttr(metadata, record); + return value; + }, + editor : new fm.TextField({ + allowBlank : false + }) + }, { + header : "Comment", + dataIndex : 'comment', + width : 400, + renderer : function(value, metadata, record, row, col, store) { + setMetaAttr(metadata, record); + return value; + }, + editor : new fm.TextField() + } ]); - store = new Ext.data.JsonStore({ - root: 'entries', - fields: rec, - url: "tablemgr", - autoLoad: true, - id: 'id', - baseParams: {table: 'capmt', op: "get"} - }); + var rec = Ext.data.Record.create([ 'enabled', 'connected', 'camdfilename', + 'port', 'comment' ]); - tvheadend.comet.on('capmtStatus', function(server) { - var rec = store.getById(server.id); - if(rec){ - rec.set('connected', server.connected); - } - }); + store = new Ext.data.JsonStore({ + root : 'entries', + fields : rec, + url : "tablemgr", + autoLoad : true, + id : 'id', + baseParams : { + table : 'capmt', + op : "get" + } + }); - return new tvheadend.tableEditor('Capmt Connections', 'capmt', cm, rec, - [enabledColumn], store, - 'config_capmt.html', 'key'); + tvheadend.comet.on('capmtStatus', function(server) { + var rec = store.getById(server.id); + if (rec) { + rec.set('connected', server.connected); + } + }); + + return new tvheadend.tableEditor('Capmt Connections', 'capmt', cm, rec, + [ enabledColumn ], store, 'config_capmt.html', 'key'); } diff --git a/src/webui/static/app/chconf.js b/src/webui/static/app/chconf.js index 0004a050..0e4b5435 100644 --- a/src/webui/static/app/chconf.js +++ b/src/webui/static/app/chconf.js @@ -1,371 +1,350 @@ - /** * Channel tags */ tvheadend.channelTags = new Ext.data.JsonStore({ - autoLoad:true, - root:'entries', - fields: ['identifier', 'name'], - id: 'identifier', - url:'channeltags', - baseParams: { - op: 'listTags' - } + autoLoad : true, + root : 'entries', + fields : [ 'identifier', 'name' ], + id : 'identifier', + url : 'channeltags', + baseParams : { + op : 'listTags' + } }); tvheadend.channelTags.setDefaultSort('name', 'ASC'); tvheadend.comet.on('channeltags', function(m) { - if(m.reload != null) - tvheadend.channelTags.reload(); + if (m.reload != null) tvheadend.channelTags.reload(); }); - /** * Channels */ tvheadend.channels = new Ext.data.JsonStore({ - autoLoad: true, - root:'entries', - fields: ['name', 'chid', 'epggrabsrc', 'tags', 'ch_icon', - 'epg_pre_start', 'epg_post_end', 'number'], - id: 'chid', - sortInfo: { field: 'number', direction: "ASC" }, - url: "channels", - baseParams: { - op: 'list' - } + autoLoad : true, + root : 'entries', + fields : [ 'name', 'chid', 'epggrabsrc', 'tags', 'ch_icon', 'epg_pre_start', + 'epg_post_end', 'number' ], + id : 'chid', + sortInfo : { + field : 'number', + direction : "ASC" + }, + url : "channels", + baseParams : { + op : 'list' + } }); tvheadend.comet.on('channels', function(m) { - if(m.reload != null) - tvheadend.channels.reload(); + if (m.reload != null) tvheadend.channels.reload(); }); - -/** -* -*/ -tvheadend.mergeChannel = function(chan) { - - function doMerge() { - panel.getForm().submit({ - url:'mergechannel/' + chan.chid, - success: function() { - win.close(); - } - }); - } - - var panel = new Ext.FormPanel({ - frame:true, - border:true, - bodyStyle:'padding:5px', - labelAlign: 'right', - labelWidth: 110, - defaultType: 'textfield', - items: [ - new Ext.form.ComboBox({ - store: tvheadend.channels, - fieldLabel: 'Target channel', - name: 'targetchannel', - hiddenName: 'targetID', - editable: false, - allowBlank: false, - triggerAction: 'all', - mode: 'remote', - displayField:'name', - valueField:'chid', - emptyText: 'Select a channel...' - }) - ], - buttons: [{ - text: 'Merge', - handler: doMerge - }] - }); - - win = new Ext.Window({ - title: 'Merge channel ' + chan.name + ' into...', - layout: 'fit', - width: 500, - height: 120, - modal: true, - plain: true, - items: panel - }); - win.show(); - -} - - /** * */ -tvheadend.chconf = function() -{ - var fm = Ext.form; +tvheadend.mergeChannel = function(chan) { - var actions = new Ext.ux.grid.RowActions({ - header:'', - dataIndex: 'actions', - width: 45, - actions: [ - { - iconCls:'merge', - qtip:'Merge this channel with another channel', - cb: function(grid, record, action, row, col) { - tvheadend.mergeChannel(record.data); - } - } - ] - }); - - - var cm = new Ext.grid.ColumnModel([ - { - header: "Number", - dataIndex: 'number', - sortable: true, - width: 50, - renderer: function(value, metadata, record, row, col, store) { - if (!value) { - return 'Not set'; - } else { - return value; - } - }, - - editor: new fm.NumberField({ - minValue: 0, - maxValue: 9999 - }) - }, - { - header: "Name", - dataIndex: 'name', - width: 150, - editor: new fm.TextField({ - allowBlank: false - }) - }, - { - header: "Play", - dataIndex: 'chid', - width: 50, - renderer: function(value, metadata, record, row, col, store) { - url = 'playlist/channelid/' + value - return "Play" - } - }, - { - header: "EPG Grab source", - dataIndex: 'epggrabsrc', - width: 150, - editor: new Ext.ux.form.LovCombo({ - loadingText: 'Loading...', - store: tvheadend.epggrabChannels, - allowBlank: true, - typeAhead: true, - minChars: 2, - lazyRender: true, - triggerAction: 'all', - mode: 'remote', - displayField:'mod-name', - valueField:'mod-id' - }) - }, - { - header: "Tags", - dataIndex: 'tags', - width: 300, - renderer: function(value, metadata, record, row, col, store) { - if (typeof value === 'undefined' || value.length < 1) { - return 'No tags'; - } - - ret = []; - tags = value.split(','); - for (var i = 0; i < tags.length; i++) { - var tag = tvheadend.channelTags.getById(tags[i]); - if (typeof tag !== 'undefined') { - ret.push(tag.data.name); - } - } - return ret.join(', '); - }, - editor: new Ext.ux.form.LovCombo({ - store: tvheadend.channelTags, - mode:'local', - valueField: 'identifier', - displayField: 'name' - }) - }, - { - header: "Icon (full URL)", - dataIndex: 'ch_icon', - width: 200, - editor: new fm.TextField() - }, - { - header: "DVR Pre-Start", - dataIndex: 'epg_pre_start', - width: 100, - - renderer: function(value, metadata, record, row, col, store) { - if (!value) { - return 'Not set'; - } else { - return value + ' min'; - } - }, - - editor: new fm.NumberField({ - minValue: 0, - maxValue: 1440 - }) - }, - { - header: "DVR Post-End", - dataIndex: 'epg_post_end', - width: 100, - renderer: function(value, metadata, record, row, col, store) { - if (!value) { - return 'Not set'; - } else { - return value + ' min'; - } - }, - - editor: new fm.NumberField({ - minValue: 0, - maxValue: 1440 - }) - }, actions - ]); - - - function delSelected() { - var selectedKeys = grid.selModel.selections.keys; - if(selectedKeys.length > 0) { - Ext.MessageBox.confirm('Message', - 'Do you really want to delete selection?', - deleteRecord); - } else { - Ext.MessageBox.alert('Message', - 'Please select at least one item to delete'); - } - } - - - function deleteRecord(btn) { - if(btn=='yes') { - var selectedKeys = grid.selModel.selections.keys; - - Ext.Ajax.request({ - url: "channels", - params: { - op:"delete", - entries:Ext.encode(selectedKeys) - }, - failure:function(response,options) { - Ext.MessageBox.alert('Server Error','Unable to delete'); - } - }) - } - } - - function saveChanges() { - var mr = tvheadend.channels.getModifiedRecords(); - var out = new Array(); - for (var x = 0; x < mr.length; x++) { - v = mr[x].getChanges(); - out[x] = v; - out[x].id = mr[x].id; + function doMerge() { + panel.getForm().submit({ + url : 'mergechannel/' + chan.chid, + success : function() { + win.close(); + } + }); } - Ext.Ajax.request({ - url: "channels", - params: { - op:"update", - entries:Ext.encode(out) - }, - success:function(response,options) { - tvheadend.channels.commitChanges(); - }, - failure:function(response,options) { - Ext.MessageBox.alert('Message', response.statusText); - } + var panel = new Ext.FormPanel({ + frame : true, + border : true, + bodyStyle : 'padding:5px', + labelAlign : 'right', + labelWidth : 110, + defaultType : 'textfield', + items : [ new Ext.form.ComboBox({ + store : tvheadend.channels, + fieldLabel : 'Target channel', + name : 'targetchannel', + hiddenName : 'targetID', + editable : false, + allowBlank : false, + triggerAction : 'all', + mode : 'remote', + displayField : 'name', + valueField : 'chid', + emptyText : 'Select a channel...' + }) ], + buttons : [ { + text : 'Merge', + handler : doMerge + } ] }); - } - var selModel = new Ext.grid.RowSelectionModel({ - singleSelect:false - }); + win = new Ext.Window({ + title : 'Merge channel ' + chan.name + ' into...', + layout : 'fit', + width : 500, + height : 120, + modal : true, + plain : true, + items : panel + }); + win.show(); - var delBtn = new Ext.Toolbar.Button({ - tooltip: 'Delete one or more selected channels', - iconCls:'remove', - text: 'Delete selected', - handler: delSelected, - disabled: true - }); - - selModel.on('selectionchange', function(s) { - delBtn.setDisabled(s.getCount() == 0); - }); - - var saveBtn = new Ext.Toolbar.Button({ - tooltip: 'Save any changes made (Changed cells have red borders).', - iconCls:'save', - text: "Save changes", - handler: saveChanges, - disabled: true - }); - - var rejectBtn = new Ext.Toolbar.Button({ - tooltip: 'Revert any changes made (Changed cells have red borders).', - iconCls:'undo', - text: "Revert changes", - handler: function() { - tvheadend.channels.rejectChanges(); - }, - disabled: true - }); - - - var grid = new Ext.grid.EditorGridPanel({ - stripeRows: true, - title: 'Channels', - iconCls: 'television', - store: tvheadend.channels, - plugins: [actions], - clicksToEdit: 2, - cm: cm, - viewConfig: { - forceFit:true - }, - selModel: selModel, - tbar: [ - delBtn, '-', saveBtn, rejectBtn, '->', { - text: 'Help', - handler: function() { - new tvheadend.help('Channels', 'config_channels.html'); - } - } - ] - }); - - tvheadend.channels.on('update', function(s, r, o) { - d = s.getModifiedRecords().length == 0 - saveBtn.setDisabled(d); - rejectBtn.setDisabled(d); - }); - - tvheadend.channelTags.on('load', function(s, r, o) { - if(grid.rendered) - grid.getView().refresh(); - }); - - return grid; +} + +/** + * + */ +tvheadend.chconf = function() { + var fm = Ext.form; + + var actions = new Ext.ux.grid.RowActions({ + header : '', + dataIndex : 'actions', + width : 45, + actions : [ { + iconCls : 'merge', + qtip : 'Merge this channel with another channel', + cb : function(grid, record, action, row, col) { + tvheadend.mergeChannel(record.data); + } + } ] + }); + + var cm = new Ext.grid.ColumnModel([ { + header : "Number", + dataIndex : 'number', + sortable : true, + width : 50, + renderer : function(value, metadata, record, row, col, store) { + if (!value) { + return 'Not set'; + } + else { + return value; + } + }, + + editor : new fm.NumberField({ + minValue : 0, + maxValue : 9999 + }) + }, { + header : "Name", + dataIndex : 'name', + width : 150, + editor : new fm.TextField({ + allowBlank : false + }) + }, { + header : "Play", + dataIndex : 'chid', + width : 50, + renderer : function(value, metadata, record, row, col, store) { + url = 'playlist/channelid/' + value + return "Play" + } + }, { + header : "EPG Grab source", + dataIndex : 'epggrabsrc', + width : 150, + editor : new Ext.ux.form.LovCombo({ + loadingText : 'Loading...', + store : tvheadend.epggrabChannels, + allowBlank : true, + typeAhead : true, + minChars : 2, + lazyRender : true, + triggerAction : 'all', + mode : 'remote', + displayField : 'mod-name', + valueField : 'mod-id' + }) + }, { + header : "Tags", + dataIndex : 'tags', + width : 300, + renderer : function(value, metadata, record, row, col, store) { + if (typeof value === 'undefined' || value.length < 1) { + return 'No tags'; + } + + ret = []; + tags = value.split(','); + for ( var i = 0; i < tags.length; i++) { + var tag = tvheadend.channelTags.getById(tags[i]); + if (typeof tag !== 'undefined') { + ret.push(tag.data.name); + } + } + return ret.join(', '); + }, + editor : new Ext.ux.form.LovCombo({ + store : tvheadend.channelTags, + mode : 'local', + valueField : 'identifier', + displayField : 'name' + }) + }, { + header : "Icon (full URL)", + dataIndex : 'ch_icon', + width : 200, + editor : new fm.TextField() + }, { + header : "DVR Pre-Start", + dataIndex : 'epg_pre_start', + width : 100, + + renderer : function(value, metadata, record, row, col, store) { + if (!value) { + return 'Not set'; + } + else { + return value + ' min'; + } + }, + + editor : new fm.NumberField({ + minValue : 0, + maxValue : 1440 + }) + }, { + header : "DVR Post-End", + dataIndex : 'epg_post_end', + width : 100, + renderer : function(value, metadata, record, row, col, store) { + if (!value) { + return 'Not set'; + } + else { + return value + ' min'; + } + }, + + editor : new fm.NumberField({ + minValue : 0, + maxValue : 1440 + }) + }, actions ]); + + function delSelected() { + var selectedKeys = grid.selModel.selections.keys; + if (selectedKeys.length > 0) { + Ext.MessageBox.confirm('Message', + 'Do you really want to delete selection?', deleteRecord); + } + else { + Ext.MessageBox.alert('Message', + 'Please select at least one item to delete'); + } + } + + function deleteRecord(btn) { + if (btn == 'yes') { + var selectedKeys = grid.selModel.selections.keys; + + Ext.Ajax.request({ + url : "channels", + params : { + op : "delete", + entries : Ext.encode(selectedKeys) + }, + failure : function(response, options) { + Ext.MessageBox.alert('Server Error', 'Unable to delete'); + } + }) + } + } + + function saveChanges() { + var mr = tvheadend.channels.getModifiedRecords(); + var out = new Array(); + for ( var x = 0; x < mr.length; x++) { + v = mr[x].getChanges(); + out[x] = v; + out[x].id = mr[x].id; + } + + Ext.Ajax.request({ + url : "channels", + params : { + op : "update", + entries : Ext.encode(out) + }, + success : function(response, options) { + tvheadend.channels.commitChanges(); + }, + failure : function(response, options) { + Ext.MessageBox.alert('Message', response.statusText); + } + }); + } + + var selModel = new Ext.grid.RowSelectionModel({ + singleSelect : false + }); + + var delBtn = new Ext.Toolbar.Button({ + tooltip : 'Delete one or more selected channels', + iconCls : 'remove', + text : 'Delete selected', + handler : delSelected, + disabled : true + }); + + selModel.on('selectionchange', function(s) { + delBtn.setDisabled(s.getCount() == 0); + }); + + var saveBtn = new Ext.Toolbar.Button({ + tooltip : 'Save any changes made (Changed cells have red borders).', + iconCls : 'save', + text : "Save changes", + handler : saveChanges, + disabled : true + }); + + var rejectBtn = new Ext.Toolbar.Button({ + tooltip : 'Revert any changes made (Changed cells have red borders).', + iconCls : 'undo', + text : "Revert changes", + handler : function() { + tvheadend.channels.rejectChanges(); + }, + disabled : true + }); + + var grid = new Ext.grid.EditorGridPanel({ + stripeRows : true, + title : 'Channels', + iconCls : 'television', + store : tvheadend.channels, + plugins : [ actions ], + clicksToEdit : 2, + cm : cm, + viewConfig : { + forceFit : true + }, + selModel : selModel, + tbar : [ delBtn, '-', saveBtn, rejectBtn, '->', { + text : 'Help', + handler : function() { + new tvheadend.help('Channels', 'config_channels.html'); + } + } ] + }); + + tvheadend.channels.on('update', function(s, r, o) { + d = s.getModifiedRecords().length == 0 + saveBtn.setDisabled(d); + rejectBtn.setDisabled(d); + }); + + tvheadend.channelTags.on('load', function(s, r, o) { + if (grid.rendered) grid.getView().refresh(); + }); + + return grid; } diff --git a/src/webui/static/app/comet.js b/src/webui/static/app/comet.js index 6182b318..74638788 100644 --- a/src/webui/static/app/comet.js +++ b/src/webui/static/app/comet.js @@ -2,19 +2,19 @@ * Comet interfaces */ Ext.extend(tvheadend.Comet = function() { - this.addEvents({ - accessUpdate: true, - tvAdapter: true, - dvbMux: true, - dvbStore: true, - dvbSatConf: true, - logmessage: true, - channeltags: true, - autorec: true, - dvrdb: true, - dvrconfig: true, - channels: true - }); + this.addEvents({ + accessUpdate : true, + tvAdapter : true, + dvbMux : true, + dvbStore : true, + dvbSatConf : true, + logmessage : true, + channeltags : true, + autorec : true, + dvrdb : true, + dvrconfig : true, + channels : true + }); }, Ext.util.Observable); tvheadend.comet = new tvheadend.Comet(); @@ -22,49 +22,49 @@ tvheadend.boxid = null; tvheadend.cometPoller = function() { - var failures = 0; + var failures = 0; - var cometRequest = new Ext.util.DelayedTask(function() { + var cometRequest = new Ext.util.DelayedTask(function() { - Ext.Ajax.request({ - url: 'comet/poll', - params : { - boxid: (tvheadend.boxid ? tvheadend.boxid : null), - immediate: failures > 0 ? 1 : 0 - }, - success: function(result, request) { - parse_comet_response(result.responseText); + Ext.Ajax + .request({ + url : 'comet/poll', + params : { + boxid : (tvheadend.boxid ? tvheadend.boxid : null), + immediate : failures > 0 ? 1 : 0 + }, + success : function(result, request) { + parse_comet_response(result.responseText); - if(failures > 1) { - tvheadend.log('Reconnected to Tvheadend', - 'font-weight: bold; color: #080'); - } - failures = 0; - }, - failure: function(result, request) { - cometRequest.delay(failures ? 1000 : 1); - if(failures == 1) { - tvheadend.log('There seems to be a problem with the ' + - 'live update feed from Tvheadend. ' + - 'Trying to reconnect...', - 'font-weight: bold; color: #f00'); - } - failures++; - } + if (failures > 1) { + tvheadend.log('Reconnected to Tvheadend', + 'font-weight: bold; color: #080'); + } + failures = 0; + }, + failure : function(result, request) { + cometRequest.delay(failures ? 1000 : 1); + if (failures == 1) { + tvheadend.log('There seems to be a problem with the ' + + 'live update feed from Tvheadend. ' + + 'Trying to reconnect...', + 'font-weight: bold; color: #f00'); + } + failures++; + } + }); }); - }); - function parse_comet_response(responsetxt) { - response = Ext.util.JSON.decode(responsetxt); - tvheadend.boxid = response.boxid - for(x = 0; x < response.messages.length; x++) { - m = response.messages[x]; - tvheadend.comet.fireEvent(m.notificationClass, m); + function parse_comet_response(responsetxt) { + response = Ext.util.JSON.decode(responsetxt); + tvheadend.boxid = response.boxid + for (x = 0; x < response.messages.length; x++) { + m = response.messages[x]; + tvheadend.comet.fireEvent(m.notificationClass, m); + } + cometRequest.delay(100); } + ; + cometRequest.delay(100); - }; - - cometRequest.delay(100); } - - diff --git a/src/webui/static/app/config.js b/src/webui/static/app/config.js index e3830720..37ed6913 100644 --- a/src/webui/static/app/config.js +++ b/src/webui/static/app/config.js @@ -1,98 +1,89 @@ tvheadend.miscconf = function() { + /* + * Basic Config + */ + var confreader = new Ext.data.JsonReader({ + root : 'config' + }, [ 'muxconfpath', 'language' ]); - /* - * Basic Config - */ + /* **************************************************************** + * Form Fields + * ***************************************************************/ - var confreader = new Ext.data.JsonReader( - { root: 'config' }, - [ - 'muxconfpath', 'language' - ] - ); + var dvbscanPath = new Ext.form.TextField({ + fieldLabel : 'DVB scan files path', + name : 'muxconfpath', + allowBlank : true + }); - /* **************************************************************** - * Form Fields - * ***************************************************************/ + var language = new Ext.form.TextField({ + fieldLabel : 'Default Language(s)', + name : 'language', + allowBlank : true + }); - var dvbscanPath = new Ext.form.TextField({ - fieldLabel : 'DVB scan files path', - name : 'muxconfpath', - allowBlank : true - }); + /* **************************************************************** + * Form + * ***************************************************************/ - var language = new Ext.form.TextField({ - fieldLabel : 'Default Language(s)', - name : 'language', - allowBlank : true - }); + var saveButton = new Ext.Button({ + text : "Save configuration", + tooltip : 'Save changes made to configuration below', + iconCls : 'save', + handler : saveChanges + }); - /* **************************************************************** - * Form - * ***************************************************************/ + var helpButton = new Ext.Button({ + text : 'Help', + handler : function() { + new tvheadend.help('General Configuration', 'config_misc.html'); + } + }); - var saveButton = new Ext.Button({ - text : "Save configuration", - tooltip : 'Save changes made to configuration below', - iconCls :'save', - handler : saveChanges - }); + var confpanel = new Ext.FormPanel({ + title : 'General', + iconCls : 'wrench', + border : false, + bodyStyle : 'padding:15px', + labelAlign : 'left', + labelWidth : 150, + waitMsgTarget : true, + reader : confreader, + layout : 'form', + defaultType : 'textfield', + autoHeight : true, + items : [ language, dvbscanPath ], + tbar : [ saveButton, '->', helpButton ] + }); - var helpButton = new Ext.Button({ - text : 'Help', - handler : function() { - new tvheadend.help('General Configuration', - 'config_misc.html'); - } - }); + /* **************************************************************** + * Load/Save + * ***************************************************************/ - var confpanel = new Ext.FormPanel({ - title : 'General', - iconCls : 'wrench', - border : false, - bodyStyle : 'padding:15px', - labelAlign : 'left', - labelWidth : 150, - waitMsgTarget : true, - reader : confreader, - layout : 'form', - defaultType : 'textfield', - autoHeight : true, - items : [ - language, - dvbscanPath - ], - tbar: [ - saveButton, - '->', - helpButton - ] - }); + confpanel.on('render', function() { + confpanel.getForm().load({ + url : 'config', + params : { + op : 'loadSettings' + }, + success : function(form, action) { + confpanel.enable(); + } + }); + }); - /* **************************************************************** - * Load/Save - * ***************************************************************/ + function saveChanges() { + confpanel.getForm().submit({ + url : 'config', + params : { + op : 'saveSettings' + }, + waitMsg : 'Saving Data...', + failure : function(form, action) { + Ext.Msg.alert('Save failed', action.result.errormsg); + } + }); + } - confpanel.on('render', function() { - confpanel.getForm().load({ - url : 'config', - params : { op : 'loadSettings' }, - success : function ( form, action ) { - confpanel.enable(); - } - }); - }); - - function saveChanges() { - confpanel.getForm().submit({ - url : 'config', - params : { op : 'saveSettings' }, - waitMsg : 'Saving Data...', - failure : function (form, action) { - Ext.Msg.alert('Save failed', action.result.errormsg); - } - }); - } - - return confpanel; + return confpanel; } diff --git a/src/webui/static/app/cteditor.js b/src/webui/static/app/cteditor.js index 57eef7a6..578c6182 100644 --- a/src/webui/static/app/cteditor.js +++ b/src/webui/static/app/cteditor.js @@ -1,60 +1,49 @@ - tvheadend.cteditor = function() { - var fm = Ext.form; - - var enabledColumn = new Ext.grid.CheckColumn({ - header: "Enabled", - dataIndex: 'enabled', - width: 60 - }); + var fm = Ext.form; - var internalColumn = new Ext.grid.CheckColumn({ - header: "Internal", - dataIndex: 'internal', - width: 100 - }); + var enabledColumn = new Ext.grid.CheckColumn({ + header : "Enabled", + dataIndex : 'enabled', + width : 60 + }); - var titledIconColumn = new Ext.grid.CheckColumn({ - header: "Icon has title", - dataIndex: 'titledIcon', - width: 100, - tooltip: 'Set this if the supplied icon has a title embedded. ' + - 'This will tell displaying application not to superimpose title '+ - 'on top of logo.' - }); + var internalColumn = new Ext.grid.CheckColumn({ + header : "Internal", + dataIndex : 'internal', + width : 100 + }); + var titledIconColumn = new Ext.grid.CheckColumn({ + header : "Icon has title", + dataIndex : 'titledIcon', + width : 100, + tooltip : 'Set this if the supplied icon has a title embedded. ' + + 'This will tell displaying application not to superimpose title ' + + 'on top of logo.' + }); - var cm = new Ext.grid.ColumnModel([ - enabledColumn, - { - header: "Name", - dataIndex: 'name', - editor: new fm.TextField({allowBlank: false}) - }, - internalColumn, - { - header: "Icon (full URL)", - dataIndex: 'icon', - width: 400, - editor: new fm.TextField({}) - }, - titledIconColumn, - { - header: "Comment", - dataIndex: 'comment', - width: 400, - editor: new fm.TextField({}) - } - ]); - - var ChannelTagRecord = Ext.data.Record.create([ - 'enabled','name','internal','icon','comment','titledIcon' - ]); - - return new tvheadend.tableEditor('Channel Tags', 'channeltags', cm, - ChannelTagRecord, - [enabledColumn, internalColumn, - titledIconColumn], - null, - 'config_tags.html', 'tags'); + var cm = new Ext.grid.ColumnModel([ enabledColumn, { + header : "Name", + dataIndex : 'name', + editor : new fm.TextField({ + allowBlank : false + }) + }, internalColumn, { + header : "Icon (full URL)", + dataIndex : 'icon', + width : 400, + editor : new fm.TextField({}) + }, titledIconColumn, { + header : "Comment", + dataIndex : 'comment', + width : 400, + editor : new fm.TextField({}) + } ]); + + var ChannelTagRecord = Ext.data.Record.create([ 'enabled', 'name', + 'internal', 'icon', 'comment', 'titledIcon' ]); + + return new tvheadend.tableEditor('Channel Tags', 'channeltags', cm, + ChannelTagRecord, [ enabledColumn, internalColumn, titledIconColumn ], + null, 'config_tags.html', 'tags'); } diff --git a/src/webui/static/app/cwceditor.js b/src/webui/static/app/cwceditor.js index ac5f610a..05fa188a 100644 --- a/src/webui/static/app/cwceditor.js +++ b/src/webui/static/app/cwceditor.js @@ -1,121 +1,125 @@ - tvheadend.cwceditor = function() { - var fm = Ext.form; - - var enabledColumn = new Ext.grid.CheckColumn({ - header: "Enabled", - dataIndex: 'enabled', - width: 60 - }); + var fm = Ext.form; - var emmColumn = new Ext.grid.CheckColumn({ - header: "Update Card", - dataIndex: 'emm', - width: 100 - }); + var enabledColumn = new Ext.grid.CheckColumn({ + header : "Enabled", + dataIndex : 'enabled', + width : 60 + }); - var emmexColumn = new Ext.grid.CheckColumn({ - header: "Update One", - dataIndex: 'emmex', - width: 100 - }); + var emmColumn = new Ext.grid.CheckColumn({ + header : "Update Card", + dataIndex : 'emm', + width : 100 + }); - function setMetaAttr(meta, record){ - var enabled = record.get('enabled'); - if(!enabled) return; + var emmexColumn = new Ext.grid.CheckColumn({ + header : "Update One", + dataIndex : 'emmex', + width : 100 + }); - var connected = record.get('connected'); - if(connected == 1){ - meta.attr = 'style="color:green;"'; - } else { - meta.attr = 'style="color:red;"'; - } - } + function setMetaAttr(meta, record) { + var enabled = record.get('enabled'); + if (!enabled) return; - var cm = new Ext.grid.ColumnModel([ - enabledColumn, - { - header: "Hostname", - dataIndex: 'hostname', - width: 200, - renderer: function(value, metadata, record, row, col, store) { - setMetaAttr(metadata, record); - return value; - }, - editor: new fm.TextField({allowBlank: false}) - },{ - header: "Port", - dataIndex: 'port', - renderer: function(value, metadata, record, row, col, store) { - setMetaAttr(metadata, record); - return value; - }, - editor: new fm.TextField({allowBlank: false}) - },{ - header: "Username", - dataIndex: 'username', - renderer: function(value, metadata, record, row, col, store) { - setMetaAttr(metadata, record); - return value; - }, - editor: new fm.TextField({allowBlank: false}) - },{ - header: "Password", - dataIndex: 'password', - renderer: function(value, metadata, record, row, col, store) { - setMetaAttr(metadata, record); - return 'Hidden'; - }, - editor: new fm.TextField({allowBlank: false}) - },{ - header: "DES Key", - dataIndex: 'deskey', - width: 300, - renderer: function(value, metadata, record, row, col, store) { - setMetaAttr(metadata, record); - return 'Hidden'; - }, - editor: new fm.TextField({allowBlank: false}) - }, - emmColumn, - emmexColumn, - { - header: "Comment", - dataIndex: 'comment', - width: 400, - renderer: function(value, metadata, record, row, col, store) { - setMetaAttr(metadata, record); - return value; - }, - editor: new fm.TextField() + var connected = record.get('connected'); + if (connected == 1) { + meta.attr = 'style="color:green;"'; + } + else { + meta.attr = 'style="color:red;"'; + } } - ]); - var rec = Ext.data.Record.create([ - 'enabled', 'connected', 'hostname', 'port', 'username', - 'password', 'deskey', 'emm', 'emmex', 'comment' - ]); + var cm = new Ext.grid.ColumnModel([ enabledColumn, { + header : "Hostname", + dataIndex : 'hostname', + width : 200, + renderer : function(value, metadata, record, row, col, store) { + setMetaAttr(metadata, record); + return value; + }, + editor : new fm.TextField({ + allowBlank : false + }) + }, { + header : "Port", + dataIndex : 'port', + renderer : function(value, metadata, record, row, col, store) { + setMetaAttr(metadata, record); + return value; + }, + editor : new fm.TextField({ + allowBlank : false + }) + }, { + header : "Username", + dataIndex : 'username', + renderer : function(value, metadata, record, row, col, store) { + setMetaAttr(metadata, record); + return value; + }, + editor : new fm.TextField({ + allowBlank : false + }) + }, { + header : "Password", + dataIndex : 'password', + renderer : function(value, metadata, record, row, col, store) { + setMetaAttr(metadata, record); + return 'Hidden'; + }, + editor : new fm.TextField({ + allowBlank : false + }) + }, { + header : "DES Key", + dataIndex : 'deskey', + width : 300, + renderer : function(value, metadata, record, row, col, store) { + setMetaAttr(metadata, record); + return 'Hidden'; + }, + editor : new fm.TextField({ + allowBlank : false + }) + }, emmColumn, emmexColumn, { + header : "Comment", + dataIndex : 'comment', + width : 400, + renderer : function(value, metadata, record, row, col, store) { + setMetaAttr(metadata, record); + return value; + }, + editor : new fm.TextField() + } ]); - var store = new Ext.data.JsonStore({ - root: 'entries', - fields: rec, - url: "tablemgr", - autoLoad: true, - id: 'id', - baseParams: {table: 'cwc', op: "get"} - }); + var rec = Ext.data.Record.create([ 'enabled', 'connected', 'hostname', + 'port', 'username', 'password', 'deskey', 'emm', 'emmex', 'comment' ]); - var grid = new tvheadend.tableEditor('Code Word Client', 'cwc', cm, rec, - [enabledColumn, emmColumn, emmexColumn], store, - 'config_cwc.html', 'key'); - - tvheadend.comet.on('cwcStatus', function(msg) { - var rec = store.getById(msg.id); - if(rec) { - rec.set('connected', msg.connected); - grid.getView().refresh(); - } - }); + var store = new Ext.data.JsonStore({ + root : 'entries', + fields : rec, + url : "tablemgr", + autoLoad : true, + id : 'id', + baseParams : { + table : 'cwc', + op : "get" + } + }); - return grid; + var grid = new tvheadend.tableEditor('Code Word Client', 'cwc', cm, rec, [ + enabledColumn, emmColumn, emmexColumn ], store, 'config_cwc.html', 'key'); + + tvheadend.comet.on('cwcStatus', function(msg) { + var rec = store.getById(msg.id); + if (rec) { + rec.set('connected', msg.connected); + grid.getView().refresh(); + } + }); + + return grid; } diff --git a/src/webui/static/app/dvb.js b/src/webui/static/app/dvb.js index 649ddb2f..34957e9c 100644 --- a/src/webui/static/app/dvb.js +++ b/src/webui/static/app/dvb.js @@ -1,1053 +1,1025 @@ - - /** * DVB Mux grid */ tvheadend.dvb_muxes = function(adapterData, satConfStore) { - adapterId = adapterData.identifier; + adapterId = adapterData.identifier; - var fm = Ext.form; - - var enabledColumn = new Ext.grid.CheckColumn({ - header: "Enabled", - dataIndex: 'enabled', - width: 40 - }); + var fm = Ext.form; - var qualityColumn = new Ext.ux.grid.ProgressColumn({ - header : "Quality", - dataIndex : 'quality', - width : 85, - textPst : '%', - colored : true - }); - - var cmlist = Array(); - - cmlist.push(enabledColumn, - { - header: "Network", - dataIndex: 'network', - width: 200 - }, - { - header: "Frequency", - dataIndex: 'freq', - width: 50 - }, - { - header: "Modulation", - dataIndex: 'mod', - width: 100 + var enabledColumn = new Ext.grid.CheckColumn({ + header : "Enabled", + dataIndex : 'enabled', + width : 40 }); - if(adapterData.satConf) { - // Include DVB-S specific stuff - - satConfStore.on('update', function(s, r, c) { - if(grid.rendered) - grid.getView().refresh(); + var qualityColumn = new Ext.ux.grid.ProgressColumn({ + header : "Quality", + dataIndex : 'quality', + width : 85, + textPst : '%', + colored : true }); - satConfStore.on('load', function(s, r, o) { - if(grid.rendered) - grid.getView().refresh(); + var cmlist = Array(); + + cmlist.push(enabledColumn, { + header : "Network", + dataIndex : 'network', + width : 200 + }, { + header : "Frequency", + dataIndex : 'freq', + width : 50 + }, { + header : "Modulation", + dataIndex : 'mod', + width : 100 }); - tvheadend.comet.on('dvbSatConf', function(m) { - if(m.adapterId == adapterId) - satConfStore.reload(); - }); + if (adapterData.satConf) { + // Include DVB-S specific stuff + + satConfStore.on('update', function(s, r, c) { + if (grid.rendered) grid.getView().refresh(); + }); + + satConfStore.on('load', function(s, r, o) { + if (grid.rendered) grid.getView().refresh(); + }); + + tvheadend.comet.on('dvbSatConf', function(m) { + if (m.adapterId == adapterId) satConfStore.reload(); + }); + + cmlist + .push( + { + header : "Polarisation", + dataIndex : 'pol', + width : 50 + }, + { + header : "Satellite config", + dataIndex : 'satconf', + width : 100, + renderer : function(value, metadata, record, row, col, store) { + r = satConfStore.getById(value); + return typeof r === 'undefined' ? 'Unset' + : r.data.name; + } + }, { + header : "Frontend status", + dataIndex : 'fe_status', + width : 30 + }); + } cmlist.push({ - header: "Polarisation", - dataIndex: 'pol', - width: 50 - }, { - header: "Satellite config", - dataIndex: 'satconf', - width: 100, - renderer: function(value, metadata, record, row, col, store) { - r = satConfStore.getById(value); - return typeof r === 'undefined' ? - 'Unset' - : r.data.name; - } - }, { - header: "Frontend status", - dataIndex: 'fe_status', - width: 30 - }); - } + header : "MuxID", + dataIndex : 'muxid', + width : 50 + }, qualityColumn); - cmlist.push( - { - header: "MuxID", - dataIndex: 'muxid', - width: 50 - }, - qualityColumn - ); + var cm = new Ext.grid.ColumnModel(cmlist); + cm.defaultSortable = true; - var cm = new Ext.grid.ColumnModel(cmlist); - cm.defaultSortable = true; + var rec = Ext.data.Record.create([ 'id', 'enabled', 'network', 'freq', + 'pol', 'satconf', 'muxid', 'quality', 'fe_status', 'mod' ]); - var rec = Ext.data.Record.create([ - 'id', 'enabled','network', 'freq', 'pol', 'satconf', - 'muxid', 'quality', 'fe_status', 'mod' - ]); - - var store = new Ext.data.JsonStore({ - root: 'entries', - fields: rec, - url: "dvb/muxes/" + adapterId, - autoLoad: true, - id: 'id', - baseParams: {op: "get"}, - listeners: { - 'update': function(s, r, o) { - d = s.getModifiedRecords().length == 0 - saveBtn.setDisabled(d); - rejectBtn.setDisabled(d); - } - } - }); - - tvheadend.comet.on('dvbMux', function(m) { - - r = store.getById(m.id) - if(typeof r === 'undefined') { - store.reload(); - return; - } - - for (key in m) - r.data[key] = m[key]; - - store.afterEdit(r); - store.fireEvent('updated', store, r, Ext.data.Record.COMMIT); - }); - - function delSelected() { - var selectedKeys = grid.selModel.selections.keys; - if(selectedKeys.length > 0) { - Ext.MessageBox.confirm('Message', - 'Do you really want to delete selection?', - deleteRecord); - } else { - Ext.MessageBox.alert('Message', - 'Please select at least one item to delete'); - } - }; - - - function deleteRecord(btn) { - if(btn=='yes') { - var selectedKeys = grid.selModel.selections.keys; - - Ext.Ajax.request({ - url: "dvb/muxes/" + adapterId, - params: { - op:"delete", - entries:Ext.encode(selectedKeys) + var store = new Ext.data.JsonStore({ + root : 'entries', + fields : rec, + url : "dvb/muxes/" + adapterId, + autoLoad : true, + id : 'id', + baseParams : { + op : "get" }, - failure:function(response,options) { - Ext.MessageBox.alert('Server Error','Unable to delete'); - }, - success:function(response,options) { - store.reload(); + listeners : { + 'update' : function(s, r, o) { + d = s.getModifiedRecords().length == 0 + saveBtn.setDisabled(d); + rejectBtn.setDisabled(d); + } } - }) - } - } - - - function copySelected() { - - function doCopy() { - var selectedKeys = grid.selModel.selections.keys; - var target = panel.getForm().getValues('targetID').targetID; - - if(adapterData.satConf) { - var satconf = panel.getForm().getValues('targetSatConfID').targetSatConfID; - var mparams = { - entries:Ext.encode(selectedKeys), - satconf:satconf - }; - } else { - var mparams = { - entries:Ext.encode(selectedKeys) - }; - } - - Ext.Ajax.request({ - url: "dvb/copymux/" + target, - params: mparams, - failure:function(response,options) { - Ext.MessageBox.alert('Server Error','Unable to copy'); - }, - success: function() { - win.close(); - } - }); - } - - targetStore = new Ext.data.JsonStore({ - root:'entries', - id: 'identifier', - url:'dvb/adapter', - fields: ['identifier', - 'name'], - baseParams: {sibling: adapterId} - }); - if(adapterData.satConf) { - targetSatConfStore = new Ext.data.JsonStore({ - root:'entries', - id: 'identifier', - url:'dvb/satconf', - fields: ['identifier', - 'name'], - baseParams: {adapter: adapterId} - }); - satConf = new Ext.form.ComboBox({ - store: targetSatConfStore, - fieldLabel: 'Target Satellite config', - name: 'targetsatconf', - hiddenName: 'targetSatConfID', - editable: false, - allowBlank: false, - triggerAction: 'all', - mode: 'remote', - displayField:'name', - valueField:'identifier', - emptyText: 'Select target adapter first...' - }); - } else { - satConf = null; - } - - var mitems = [ - new Ext.form.ComboBox({ - store: targetStore, - fieldLabel: 'Target adapter', - name: 'targetadapter', - hiddenName: 'targetID', - editable: false, - allowBlank: false, - triggerAction: 'all', - mode: 'remote', - displayField:'name', - valueField:'identifier', - emptyText: 'Select target adapter...', - listeners: { - 'select': function(combo, value) { - if (satConf) { - satConf.emptyText = 'Select satellite configuration...'; - satConf.clearValue(); - targetSatConfStore.baseParams = {adapter: combo.value}; - targetSatConfStore.load(); - satConf.focus(); - satConf.expand(); - } - } - } - }) - ]; - - if (satConf) - mitems.push(satConf); - - var panel = new Ext.FormPanel({ - frame:true, - border:true, - bodyStyle:'padding:5px', - labelAlign: 'right', - labelWidth: 150, - defaultType: 'textfield', - items: mitems, - buttons: [{ - text: 'Copy', - handler: doCopy - }] - }); - - win = new Ext.Window({ - title: 'Copy multiplex configuration', - layout: 'fit', - width: 500, - height: 150, - modal: true, - plain: true, - items: panel - }); - win.show(); - } - - - function saveChanges() { - var mr = store.getModifiedRecords(); - var out = new Array(); - for (var x = 0; x < mr.length; x++) { - v = mr[x].getChanges(); - out[x] = v; - out[x].id = mr[x].id; - } - - Ext.Ajax.request({ - url: "dvb/muxes/" + adapterId, - params: { - op:"update", - entries:Ext.encode(out) - }, - success:function(response,options) { - store.commitChanges(); - }, - failure:function(response,options) { - Ext.MessageBox.alert('Message',response.statusText); - } }); - } - - var selModel = new Ext.grid.RowSelectionModel({ - singleSelect:false - }); - var delBtn = new Ext.Toolbar.Button({ - tooltip: 'Delete one or more selected muxes', - iconCls:'remove', - text: 'Delete selected...', - handler: delSelected, - disabled: true - }); + tvheadend.comet.on('dvbMux', function(m) { - var copyBtn = new Ext.Toolbar.Button({ - tooltip: 'Copy selected multiplexes to other adapter', - iconCls:'clone', - text: 'Copy to other adapter...', - handler: copySelected, - disabled: true - }); - - selModel.on('selectionchange', function(s) { - delBtn.setDisabled(s.getCount() == 0); - copyBtn.setDisabled(s.getCount() == 0); - }); - - var saveBtn = new Ext.Toolbar.Button({ - tooltip: 'Save any changes made (Changed cells have red borders).', - iconCls:'save', - text: "Save changes", - handler: saveChanges, - disabled: true - }); - - var rejectBtn = new Ext.Toolbar.Button({ - tooltip: 'Revert any changes made (Changed cells have red borders).', - iconCls:'undo', - text: "Revert changes", - handler: function() { - store.rejectChanges(); - }, - disabled: true - }); - - var grid = new Ext.grid.EditorGridPanel({ - stripeRows: true, - title: 'Multiplexes', - plugins: [enabledColumn, qualityColumn], - store: store, - clicksToEdit: 2, - cm: cm, - viewConfig: {forceFit:true}, - selModel: selModel, - tbar: [ - delBtn, copyBtn, '-', saveBtn, rejectBtn, '-', { - text: 'Add mux(es) manually...', - iconCls:'add', - handler: function() { - tvheadend.addMuxManually(adapterData, satConfStore) + r = store.getById(m.id) + if (typeof r === 'undefined') { + store.reload(); + return; } - } - ] - }); - return grid; + for (key in m) + r.data[key] = m[key]; + + store.afterEdit(r); + store.fireEvent('updated', store, r, Ext.data.Record.COMMIT); + }); + + function delSelected() { + var selectedKeys = grid.selModel.selections.keys; + if (selectedKeys.length > 0) { + Ext.MessageBox.confirm('Message', + 'Do you really want to delete selection?', deleteRecord); + } + else { + Ext.MessageBox.alert('Message', + 'Please select at least one item to delete'); + } + } + ; + + function deleteRecord(btn) { + if (btn == 'yes') { + var selectedKeys = grid.selModel.selections.keys; + + Ext.Ajax.request({ + url : "dvb/muxes/" + adapterId, + params : { + op : "delete", + entries : Ext.encode(selectedKeys) + }, + failure : function(response, options) { + Ext.MessageBox.alert('Server Error', 'Unable to delete'); + }, + success : function(response, options) { + store.reload(); + } + }) + } + } + + function copySelected() { + + function doCopy() { + var selectedKeys = grid.selModel.selections.keys; + var target = panel.getForm().getValues('targetID').targetID; + + if (adapterData.satConf) { + var satconf = panel.getForm().getValues('targetSatConfID').targetSatConfID; + var mparams = { + entries : Ext.encode(selectedKeys), + satconf : satconf + }; + } + else { + var mparams = { + entries : Ext.encode(selectedKeys) + }; + } + + Ext.Ajax.request({ + url : "dvb/copymux/" + target, + params : mparams, + failure : function(response, options) { + Ext.MessageBox.alert('Server Error', 'Unable to copy'); + }, + success : function() { + win.close(); + } + }); + } + + targetStore = new Ext.data.JsonStore({ + root : 'entries', + id : 'identifier', + url : 'dvb/adapter', + fields : [ 'identifier', 'name' ], + baseParams : { + sibling : adapterId + } + }); + if (adapterData.satConf) { + targetSatConfStore = new Ext.data.JsonStore({ + root : 'entries', + id : 'identifier', + url : 'dvb/satconf', + fields : [ 'identifier', 'name' ], + baseParams : { + adapter : adapterId + } + }); + satConf = new Ext.form.ComboBox({ + store : targetSatConfStore, + fieldLabel : 'Target Satellite config', + name : 'targetsatconf', + hiddenName : 'targetSatConfID', + editable : false, + allowBlank : false, + triggerAction : 'all', + mode : 'remote', + displayField : 'name', + valueField : 'identifier', + emptyText : 'Select target adapter first...' + }); + } + else { + satConf = null; + } + + var mitems = [ new Ext.form.ComboBox({ + store : targetStore, + fieldLabel : 'Target adapter', + name : 'targetadapter', + hiddenName : 'targetID', + editable : false, + allowBlank : false, + triggerAction : 'all', + mode : 'remote', + displayField : 'name', + valueField : 'identifier', + emptyText : 'Select target adapter...', + listeners : { + 'select' : function(combo, value) { + if (satConf) { + satConf.emptyText = 'Select satellite configuration...'; + satConf.clearValue(); + targetSatConfStore.baseParams = { + adapter : combo.value + }; + targetSatConfStore.load(); + satConf.focus(); + satConf.expand(); + } + } + } + }) ]; + + if (satConf) mitems.push(satConf); + + var panel = new Ext.FormPanel({ + frame : true, + border : true, + bodyStyle : 'padding:5px', + labelAlign : 'right', + labelWidth : 150, + defaultType : 'textfield', + items : mitems, + buttons : [ { + text : 'Copy', + handler : doCopy + } ] + }); + + win = new Ext.Window({ + title : 'Copy multiplex configuration', + layout : 'fit', + width : 500, + height : 150, + modal : true, + plain : true, + items : panel + }); + win.show(); + } + + function saveChanges() { + var mr = store.getModifiedRecords(); + var out = new Array(); + for ( var x = 0; x < mr.length; x++) { + v = mr[x].getChanges(); + out[x] = v; + out[x].id = mr[x].id; + } + + Ext.Ajax.request({ + url : "dvb/muxes/" + adapterId, + params : { + op : "update", + entries : Ext.encode(out) + }, + success : function(response, options) { + store.commitChanges(); + }, + failure : function(response, options) { + Ext.MessageBox.alert('Message', response.statusText); + } + }); + } + + var selModel = new Ext.grid.RowSelectionModel({ + singleSelect : false + }); + + var delBtn = new Ext.Toolbar.Button({ + tooltip : 'Delete one or more selected muxes', + iconCls : 'remove', + text : 'Delete selected...', + handler : delSelected, + disabled : true + }); + + var copyBtn = new Ext.Toolbar.Button({ + tooltip : 'Copy selected multiplexes to other adapter', + iconCls : 'clone', + text : 'Copy to other adapter...', + handler : copySelected, + disabled : true + }); + + selModel.on('selectionchange', function(s) { + delBtn.setDisabled(s.getCount() == 0); + copyBtn.setDisabled(s.getCount() == 0); + }); + + var saveBtn = new Ext.Toolbar.Button({ + tooltip : 'Save any changes made (Changed cells have red borders).', + iconCls : 'save', + text : "Save changes", + handler : saveChanges, + disabled : true + }); + + var rejectBtn = new Ext.Toolbar.Button({ + tooltip : 'Revert any changes made (Changed cells have red borders).', + iconCls : 'undo', + text : "Revert changes", + handler : function() { + store.rejectChanges(); + }, + disabled : true + }); + + var grid = new Ext.grid.EditorGridPanel({ + stripeRows : true, + title : 'Multiplexes', + plugins : [ enabledColumn, qualityColumn ], + store : store, + clicksToEdit : 2, + cm : cm, + viewConfig : { + forceFit : true + }, + selModel : selModel, + tbar : [ delBtn, copyBtn, '-', saveBtn, rejectBtn, '-', { + text : 'Add mux(es) manually...', + iconCls : 'add', + handler : function() { + tvheadend.addMuxManually(adapterData, satConfStore) + } + } ] + }); + + return grid; } - /** * DVB service grid */ tvheadend.dvb_services = function(adapterId) { - var fm = Ext.form; - - var enabledColumn = new Ext.grid.CheckColumn({ - header: "Enabled", - dataIndex: 'enabled', - width: 45 - }); + var fm = Ext.form; + + var enabledColumn = new Ext.grid.CheckColumn({ + header : "Enabled", + dataIndex : 'enabled', + width : 45 + }); var eitColumn = new Ext.grid.CheckColumn({ - header: "EIT", - dataIndex: 'dvb_eit_enable', - width: 45 + header : "EIT", + dataIndex : 'dvb_eit_enable', + width : 45 }); - var actions = new Ext.ux.grid.RowActions({ - header:'', - dataIndex: 'actions', - width: 45, - actions: [ - { - iconCls:'info', - qtip:'Detailed information about service', - cb: function(grid, record, action, row, col) { - Ext.Ajax.request({ - url: "servicedetails/" + record.id, - success:function(response, options) { - r = Ext.util.JSON.decode(response.responseText); - tvheadend.showTransportDetails(r); + var actions = new Ext.ux.grid.RowActions({ + header : '', + dataIndex : 'actions', + width : 45, + actions : [ { + iconCls : 'info', + qtip : 'Detailed information about service', + cb : function(grid, record, action, row, col) { + Ext.Ajax.request({ + url : "servicedetails/" + record.id, + success : function(response, options) { + r = Ext.util.JSON.decode(response.responseText); + tvheadend.showTransportDetails(r); + } + }) } - }) - } - } - ] - }); - - var cm = new Ext.grid.ColumnModel([ - enabledColumn, - { - header: "Service name", - dataIndex: 'svcname', - width: 150 - }, - { - header: "Play", - dataIndex: 'id', - width: 50, - renderer: function(value, metadata, record, row, col, store) { - url = 'stream/service/' + value - return 'Play' - } - }, - { - header: "Channel name", - dataIndex: 'channelname', - width: 150, - renderer: function(value, metadata, record, row, col, store) { - return value ? value : - 'Unmapped'; - }, - editor: new fm.ComboBox({ - store: tvheadend.channels, - allowBlank: true, - typeAhead: true, - minChars: 2, - lazyRender: true, - triggerAction: 'all', - mode: 'local', - displayField:'name' - }) - }, - { - header: "DVB default charset", - dataIndex: 'dvb_default_charset', - width: 200, - renderer: function(value, metadata, record, row, col, store) { - return value ? value : - 'ISO6937'; - }, - editor: new fm.ComboBox({ - mode: 'local', - store: new Ext.data.SimpleStore({ - fields: ['key','value'], - data: [ - ['ISO6937','default'], - ['ISO6937','ISO6937'], - ['ISO8859-1','ISO8859-1'], - ['ISO8859-2','ISO8859-2'], - ['ISO8859-3','ISO8859-3'], - ['ISO8859-4','ISO8859-4'], - ['ISO8859-5','ISO8859-5'], - ['ISO8859-6','ISO8859-6'], - ['ISO8859-7','ISO8859-7'], - ['ISO8859-8','ISO8859-8'], - ['ISO8859-9','ISO8859-9'], - ['ISO8859-10','ISO8859-10'], - ['ISO8859-11','ISO8859-11'], - ['ISO8859-12','ISO8859-12'], - ['ISO8859-13','ISO8859-13'], - ['ISO8859-14','ISO8859-14'], - ['ISO8859-15','ISO8859-15'] - ] - }), - typeAhead: true, - lazyRender: true, - triggerAction: 'all', - displayField:'value', - valueField:'key' - }) - }, - eitColumn, - { - header: "Type", - dataIndex: 'type', - width: 50 - }, - { - header: "Provider", - dataIndex: 'provider', - width: 150 - }, - { - header: "Network", - dataIndex: 'network', - width: 100 - }, - { - header: "Multiplex", - dataIndex: 'mux', - width: 100 - }, - { - header: "Service ID", - dataIndex: 'sid', - width: 50, - hidden: true - }, - { - header: "PMT PID", - dataIndex: 'pmt', - width: 50, - hidden: true - }, - { - header: "PCR PID", - dataIndex: 'pcr', - width: 50, - hidden: true - }, actions - ]); - - cm.defaultSortable = true; - - var store = new Ext.data.JsonStore({ - root: 'entries', - fields: Ext.data.Record.create([ - 'id', 'enabled', 'type', 'sid', 'pmt', 'pcr', 'svcname', 'network', - 'provider', 'mux', 'channelname', 'dvb_default_charset', 'dvb_eit_enable' - ]), - url: "dvb/services/" + adapterId, - autoLoad: true, - id: 'id', - baseParams: {op: "get"}, - listeners: { - 'update': function(s, r, o) { - d = s.getModifiedRecords().length == 0 - saveBtn.setDisabled(d); - rejectBtn.setDisabled(d); - } - } - }); - - var storeReloader = new Ext.util.DelayedTask(function() { - store.reload() - }); - - tvheadend.comet.on('dvbService', function(m) { - storeReloader.delay(500); - }); - - - function delSelected() { - var selectedKeys = grid.selModel.selections.keys; - if(selectedKeys.length > 0) { - Ext.MessageBox.confirm('Message', - 'Do you really want to delete selection?', - deleteRecord); - } else { - Ext.MessageBox.alert('Message', - 'Please select at least one item to delete'); - } - }; - - - function saveChanges() { - var mr = store.getModifiedRecords(); - var out = new Array(); - for (var x = 0; x < mr.length; x++) { - v = mr[x].getChanges(); - out[x] = v; - out[x].id = mr[x].id; - } - - Ext.Ajax.request({ - url: "dvb/services/" + adapterId, - params: { - op:"update", - entries:Ext.encode(out) - }, - success:function(response,options) { - store.commitChanges(); - }, - failure:function(response,options) { - Ext.MessageBox.alert('Message',response.statusText); - } + } ] }); - } - var saveBtn = new Ext.Toolbar.Button({ - tooltip: 'Save any changes made (Changed cells have red borders).', - iconCls:'save', - text: "Save changes", - handler: saveChanges, - disabled: true - }); + var cm = new Ext.grid.ColumnModel([ + enabledColumn, + { + header : "Service name", + dataIndex : 'svcname', + width : 150 + }, + { + header : "Play", + dataIndex : 'id', + width : 50, + renderer : function(value, metadata, record, row, col, store) { + url = 'stream/service/' + value + return 'Play' + } + }, + { + header : "Channel name", + dataIndex : 'channelname', + width : 150, + renderer : function(value, metadata, record, row, col, store) { + return value ? value + : 'Unmapped'; + }, + editor : new fm.ComboBox({ + store : tvheadend.channels, + allowBlank : true, + typeAhead : true, + minChars : 2, + lazyRender : true, + triggerAction : 'all', + mode : 'local', + displayField : 'name' + }) + }, + { + header : "DVB default charset", + dataIndex : 'dvb_default_charset', + width : 200, + renderer : function(value, metadata, record, row, col, store) { + return value ? value + : 'ISO6937'; + }, + editor : new fm.ComboBox({ + mode : 'local', + store : new Ext.data.SimpleStore({ + fields : [ 'key', 'value' ], + data : [ [ 'ISO6937', 'default' ], [ 'ISO6937', 'ISO6937' ], + [ 'ISO8859-1', 'ISO8859-1' ], [ 'ISO8859-2', 'ISO8859-2' ], + [ 'ISO8859-3', 'ISO8859-3' ], [ 'ISO8859-4', 'ISO8859-4' ], + [ 'ISO8859-5', 'ISO8859-5' ], [ 'ISO8859-6', 'ISO8859-6' ], + [ 'ISO8859-7', 'ISO8859-7' ], [ 'ISO8859-8', 'ISO8859-8' ], + [ 'ISO8859-9', 'ISO8859-9' ], [ 'ISO8859-10', 'ISO8859-10' ], + [ 'ISO8859-11', 'ISO8859-11' ], + [ 'ISO8859-12', 'ISO8859-12' ], + [ 'ISO8859-13', 'ISO8859-13' ], + [ 'ISO8859-14', 'ISO8859-14' ], + [ 'ISO8859-15', 'ISO8859-15' ] ] + }), + typeAhead : true, + lazyRender : true, + triggerAction : 'all', + displayField : 'value', + valueField : 'key' + }) + }, eitColumn, { + header : "Type", + dataIndex : 'type', + width : 50 + }, { + header : "Provider", + dataIndex : 'provider', + width : 150 + }, { + header : "Network", + dataIndex : 'network', + width : 100 + }, { + header : "Multiplex", + dataIndex : 'mux', + width : 100 + }, { + header : "Service ID", + dataIndex : 'sid', + width : 50, + hidden : true + }, { + header : "PMT PID", + dataIndex : 'pmt', + width : 50, + hidden : true + }, { + header : "PCR PID", + dataIndex : 'pcr', + width : 50, + hidden : true + }, actions ]); - var rejectBtn = new Ext.Toolbar.Button({ - tooltip: 'Revert any changes made (Changed cells have red borders).', - iconCls:'undo', - text: "Revert changes", - handler: function() { - store.rejectChanges(); - }, - disabled: true - }); - - var selModel = new Ext.grid.RowSelectionModel({ - singleSelect:false - }); + cm.defaultSortable = true; - var grid = new Ext.grid.EditorGridPanel({ - stripeRows: true, - title: 'Services', - plugins: [enabledColumn, eitColumn, actions], - store: store, - clicksToEdit: 2, - cm: cm, - viewConfig: {forceFit:true}, - selModel: selModel, - tbar: [saveBtn, rejectBtn] - }); - return grid; + var store = new Ext.data.JsonStore({ + root : 'entries', + fields : Ext.data.Record.create([ 'id', 'enabled', 'type', 'sid', 'pmt', + 'pcr', 'svcname', 'network', 'provider', 'mux', 'channelname', + 'dvb_default_charset', 'dvb_eit_enable' ]), + url : "dvb/services/" + adapterId, + autoLoad : true, + id : 'id', + baseParams : { + op : "get" + }, + listeners : { + 'update' : function(s, r, o) { + d = s.getModifiedRecords().length == 0 + saveBtn.setDisabled(d); + rejectBtn.setDisabled(d); + } + } + }); + + var storeReloader = new Ext.util.DelayedTask(function() { + store.reload() + }); + + tvheadend.comet.on('dvbService', function(m) { + storeReloader.delay(500); + }); + + function delSelected() { + var selectedKeys = grid.selModel.selections.keys; + if (selectedKeys.length > 0) { + Ext.MessageBox.confirm('Message', + 'Do you really want to delete selection?', deleteRecord); + } + else { + Ext.MessageBox.alert('Message', + 'Please select at least one item to delete'); + } + } + ; + + function saveChanges() { + var mr = store.getModifiedRecords(); + var out = new Array(); + for ( var x = 0; x < mr.length; x++) { + v = mr[x].getChanges(); + out[x] = v; + out[x].id = mr[x].id; + } + + Ext.Ajax.request({ + url : "dvb/services/" + adapterId, + params : { + op : "update", + entries : Ext.encode(out) + }, + success : function(response, options) { + store.commitChanges(); + }, + failure : function(response, options) { + Ext.MessageBox.alert('Message', response.statusText); + } + }); + } + + var saveBtn = new Ext.Toolbar.Button({ + tooltip : 'Save any changes made (Changed cells have red borders).', + iconCls : 'save', + text : "Save changes", + handler : saveChanges, + disabled : true + }); + + var rejectBtn = new Ext.Toolbar.Button({ + tooltip : 'Revert any changes made (Changed cells have red borders).', + iconCls : 'undo', + text : "Revert changes", + handler : function() { + store.rejectChanges(); + }, + disabled : true + }); + + var selModel = new Ext.grid.RowSelectionModel({ + singleSelect : false + }); + + var grid = new Ext.grid.EditorGridPanel({ + stripeRows : true, + title : 'Services', + plugins : [ enabledColumn, eitColumn, actions ], + store : store, + clicksToEdit : 2, + cm : cm, + viewConfig : { + forceFit : true + }, + selModel : selModel, + tbar : [ saveBtn, rejectBtn ] + }); + return grid; } /** * */ tvheadend.addMuxByLocation = function(adapterData, satConfStore) { - - var addBtn = new Ext.Button({ - text: 'Add DVB network', - disabled: true, - handler: function() { - var n = locationList.getSelectionModel().getSelectedNode(); - Ext.Ajax.request({ - url: 'dvb/adapter/' + adapterData.identifier, - params: { - network: n.attributes.id, - satconf: satConfCombo ? satConfCombo.getValue() : null, - op: 'addnetwork' + + var locationListBBarElements = []; + var satConfCombo = null; + + if (satConfStore) { + satConfCombo = new Ext.form.ComboBox({ + store : satConfStore, + width : 480, + editable : false, + allowBlank : false, + triggerAction : 'all', + mode : 'remote', + displayField : 'name', + valueField : 'identifier', + emptyText : 'Select satellite configuration...' + }); + locationListBBarElements.push(satConfCombo); + } + + var addBtn = new Ext.Button({ + text : 'Add DVB network', + disabled : true, + handler : function() { + var n = locationList.getSelectionModel().getSelectedNode(); + Ext.Ajax.request({ + url : 'dvb/adapter/' + adapterData.identifier, + params : { + network : n.attributes.id, + satconf : satConfCombo != null ? satConfCombo.getValue() : null, + op : 'addnetwork' + } + }); + win.close(); } - }); - win.close(); - } - }); - - if(satConfStore) { - satConfCombo = new Ext.form.ComboBox({ - store: satConfStore, - width: 480, - editable: false, - allowBlank: false, - triggerAction: 'all', - mode: 'remote', - displayField:'name', - valueField:'identifier', - emptyText: 'Select satellite configuration...' }); - } else { - satConfCombo = false; - } - var locationList = new Ext.tree.TreePanel({ - title:'By location', - autoScroll:true, - rootVisible:false, - loader: new Ext.tree.TreeLoader({ - baseParams: {adapter: adapterData.identifier}, - dataUrl:'dvbnetworks' - }), - - root: new Ext.tree.AsyncTreeNode({ - id:'root' - }), - - bbar: [satConfCombo], + var locationList = new Ext.tree.TreePanel({ + title : 'By location', + autoScroll : true, + rootVisible : false, + loader : new Ext.tree.TreeLoader({ + baseParams : { + adapter : adapterData.identifier + }, + dataUrl : 'dvbnetworks' + }), + root : new Ext.tree.AsyncTreeNode({ + id : 'root' + }), + bbar : locationListBBarElements, + buttons : [ addBtn ], + buttonAlign : 'center' + }); - buttons: [addBtn], - buttonAlign: 'center' - }); - + locationList.on('click', function(n) { + if (n.attributes.leaf) { + addBtn.enable(); + } + else { + addBtn.disable(); + } + }); - locationList.on('click', function(n) { - if(n.attributes.leaf) { - addBtn.enable(); - } else { - addBtn.disable(); - } - }); - - win = new Ext.Window({ - title: 'Add muxes on ' + adapterData.name, - layout: 'fit', - width: 500, - height: 500, - modal: true, - plain: true, - items: new Ext.TabPanel({ - autoTabs: true, - activeTab: 0, - deferredRender: false, - border: false, - items: locationList - }) - }); - win.show(); + win = new Ext.Window({ + title : 'Add muxes on ' + adapterData.name, + layout : 'fit', + width : 500, + height : 500, + modal : true, + plain : true, + items : new Ext.TabPanel({ + autoTabs : true, + activeTab : 0, + deferredRender : false, + border : false, + items : locationList + }) + }); + win.show(); } - /** * Add mux by manual configuration */ tvheadend.addMuxManually = function(adapterData, satConfStore) { - - var adId = adapterData.identifier; + var adId = adapterData.identifier; - var items = []; + var items = []; - switch(adapterData.deliverySystem) { - case 'DVB-T': + switch (adapterData.deliverySystem) { + case 'DVB-T': - items.push(new Ext.form.NumberField({ - fieldLabel: 'Frequency (kHz)', - name: 'frequency', - allowNegative: false, - allowBlank: false, - minValue: adapterData.freqMin, - maxValue: adapterData.freqMax - })); + items.push(new Ext.form.NumberField({ + fieldLabel : 'Frequency (kHz)', + name : 'frequency', + allowNegative : false, + allowBlank : false, + minValue : adapterData.freqMin, + maxValue : adapterData.freqMax + })); - items.push(new Ext.form.ComboBox({ - fieldLabel: 'Bandwidth', - name: 'bandwidth', - hiddenName: 'bandwidthID', - editable: false, - allowBlank: false, - displayField: 'title', - valueField:'id', - mode:'remote', - triggerAction: 'all', - store: new Ext.data.JsonStore({ - root:'entries', - fields: ['title', 'id'], - url: 'dvb/feopts/bandwidths/' + adId - }) - })); + items.push(new Ext.form.ComboBox({ + fieldLabel : 'Bandwidth', + name : 'bandwidth', + hiddenName : 'bandwidthID', + editable : false, + allowBlank : false, + displayField : 'title', + valueField : 'id', + mode : 'remote', + triggerAction : 'all', + store : new Ext.data.JsonStore({ + root : 'entries', + fields : [ 'title', 'id' ], + url : 'dvb/feopts/bandwidths/' + adId + }) + })); - items.push(new Ext.form.ComboBox({ - fieldLabel: 'Constellation', - name: 'constellation', - hiddenName: 'constellationID', - editable: false, - allowBlank: false, - displayField: 'title', - valueField:'id', - mode:'remote', - triggerAction: 'all', - store: new Ext.data.JsonStore({ - root:'entries', - fields: ['title', 'id'], - url: 'dvb/feopts/constellations/' + adId - }) - })); + items.push(new Ext.form.ComboBox({ + fieldLabel : 'Constellation', + name : 'constellation', + hiddenName : 'constellationID', + editable : false, + allowBlank : false, + displayField : 'title', + valueField : 'id', + mode : 'remote', + triggerAction : 'all', + store : new Ext.data.JsonStore({ + root : 'entries', + fields : [ 'title', 'id' ], + url : 'dvb/feopts/constellations/' + adId + }) + })); - items.push(new Ext.form.ComboBox({ - fieldLabel: 'Transmission mode', - name: 'tmode', - hiddenName: 'tmodeID', - editable: false, - allowBlank: false, - displayField: 'title', - valueField:'id', - mode:'remote', - triggerAction: 'all', - store: new Ext.data.JsonStore({ - root:'entries', - fields: ['title', 'id'], - url: 'dvb/feopts/transmissionmodes/' + adId - }) - })); + items.push(new Ext.form.ComboBox({ + fieldLabel : 'Transmission mode', + name : 'tmode', + hiddenName : 'tmodeID', + editable : false, + allowBlank : false, + displayField : 'title', + valueField : 'id', + mode : 'remote', + triggerAction : 'all', + store : new Ext.data.JsonStore({ + root : 'entries', + fields : [ 'title', 'id' ], + url : 'dvb/feopts/transmissionmodes/' + adId + }) + })); - items.push(new Ext.form.ComboBox({ - fieldLabel: 'Guard interval', - name: 'guardinterval', - hiddenName: 'guardintervalID', - editable: false, - allowBlank: false, - displayField: 'title', - valueField:'id', - mode:'remote', - triggerAction: 'all', - store: new Ext.data.JsonStore({ - root:'entries', - fields: ['title', 'id'], - url: 'dvb/feopts/guardintervals/' + adId - }) - })); + items.push(new Ext.form.ComboBox({ + fieldLabel : 'Guard interval', + name : 'guardinterval', + hiddenName : 'guardintervalID', + editable : false, + allowBlank : false, + displayField : 'title', + valueField : 'id', + mode : 'remote', + triggerAction : 'all', + store : new Ext.data.JsonStore({ + root : 'entries', + fields : [ 'title', 'id' ], + url : 'dvb/feopts/guardintervals/' + adId + }) + })); - items.push(new Ext.form.ComboBox({ - fieldLabel: 'Hierarchy', - name: 'hierarchy', - hiddenName: 'hierarchyID', - editable: false, - allowBlank: false, - displayField: 'title', - valueField:'id', - mode:'remote', - triggerAction: 'all', - store: new Ext.data.JsonStore({ - root:'entries', - fields: ['title', 'id'], - url: 'dvb/feopts/hierarchies/' + adId - }) - })); + items.push(new Ext.form.ComboBox({ + fieldLabel : 'Hierarchy', + name : 'hierarchy', + hiddenName : 'hierarchyID', + editable : false, + allowBlank : false, + displayField : 'title', + valueField : 'id', + mode : 'remote', + triggerAction : 'all', + store : new Ext.data.JsonStore({ + root : 'entries', + fields : [ 'title', 'id' ], + url : 'dvb/feopts/hierarchies/' + adId + }) + })); - items.push(new Ext.form.ComboBox({ - fieldLabel: 'FEC Hi', - name: 'fechi', - hiddenName: 'fechiID', - editable: false, - allowBlank: false, - displayField: 'title', - valueField:'id', - mode:'remote', - triggerAction: 'all', - store: new Ext.data.JsonStore({ - root:'entries', - fields: ['title', 'id'], - url: 'dvb/feopts/fec/' + adId - }) - })); + items.push(new Ext.form.ComboBox({ + fieldLabel : 'FEC Hi', + name : 'fechi', + hiddenName : 'fechiID', + editable : false, + allowBlank : false, + displayField : 'title', + valueField : 'id', + mode : 'remote', + triggerAction : 'all', + store : new Ext.data.JsonStore({ + root : 'entries', + fields : [ 'title', 'id' ], + url : 'dvb/feopts/fec/' + adId + }) + })); - items.push(new Ext.form.ComboBox({ - fieldLabel: 'FEC Lo', - name: 'feclo', - hiddenName: 'fecloID', - editable: false, - allowBlank: false, - displayField: 'title', - valueField:'id', - mode:'remote', - triggerAction: 'all', - store: new Ext.data.JsonStore({ - root:'entries', - fields: ['title', 'id'], - url: 'dvb/feopts/fec/' + adId - }) - })); - break; + items.push(new Ext.form.ComboBox({ + fieldLabel : 'FEC Lo', + name : 'feclo', + hiddenName : 'fecloID', + editable : false, + allowBlank : false, + displayField : 'title', + valueField : 'id', + mode : 'remote', + triggerAction : 'all', + store : new Ext.data.JsonStore({ + root : 'entries', + fields : [ 'title', 'id' ], + url : 'dvb/feopts/fec/' + adId + }) + })); + break; - case 'DVB-C': - items.push(new Ext.form.NumberField({ - fieldLabel: 'Frequency (kHz)', - name: 'frequency', - allowNegative: false, - allowBlank: false, - minValue: adapterData.freqMin, - maxValue: adapterData.freqMax - })); + case 'DVB-C': + items.push(new Ext.form.NumberField({ + fieldLabel : 'Frequency (kHz)', + name : 'frequency', + allowNegative : false, + allowBlank : false, + minValue : adapterData.freqMin, + maxValue : adapterData.freqMax + })); - items.push(new Ext.form.NumberField({ - fieldLabel: 'Symbolrate (baud)', - name: 'symbolrate', - allowNegative: false, - allowBlank: false, - minValue: adapterData.symrateMin, - maxValue: adapterData.symrateMax - })); - - items.push(new Ext.form.ComboBox({ - fieldLabel: 'Constellation', - name: 'constellation', - hiddenName: 'constellationID', - editable: false, - allowBlank: false, - displayField: 'title', - valueField:'id', - mode:'remote', - triggerAction: 'all', - store: new Ext.data.JsonStore({ - root:'entries', - fields: ['title', 'id'], - url: 'dvb/feopts/constellations/' + adId - }) - })); - - items.push(new Ext.form.ComboBox({ - fieldLabel: 'FEC', - name: 'fec', - hiddenName: 'fecID', - editable: false, - allowBlank: false, - displayField: 'title', - valueField:'id', - mode:'remote', - triggerAction: 'all', - store: new Ext.data.JsonStore({ - root:'entries', - fields: ['title', 'id'], - url: 'dvb/feopts/fec/' + adId - }) - })); - break; + items.push(new Ext.form.NumberField({ + fieldLabel : 'Symbolrate (baud)', + name : 'symbolrate', + allowNegative : false, + allowBlank : false, + minValue : adapterData.symrateMin, + maxValue : adapterData.symrateMax + })); - case 'DVB-S': - items.push(new Ext.form.NumberField({ - fieldLabel: 'Frequency (kHz)', - name: 'frequency', - allowBlank: false, - allowNegative: false - })); + items.push(new Ext.form.ComboBox({ + fieldLabel : 'Constellation', + name : 'constellation', + hiddenName : 'constellationID', + editable : false, + allowBlank : false, + displayField : 'title', + valueField : 'id', + mode : 'remote', + triggerAction : 'all', + store : new Ext.data.JsonStore({ + root : 'entries', + fields : [ 'title', 'id' ], + url : 'dvb/feopts/constellations/' + adId + }) + })); - items.push(new Ext.form.NumberField({ - fieldLabel: 'Symbolrate (baud)', - name: 'symbolrate', - allowNegative: false, - allowBlank: false, - minValue: adapterData.symrateMin, - maxValue: adapterData.symrateMax - })); - - items.push(new Ext.form.ComboBox({ - fieldLabel: 'FEC', - name: 'fec', - hiddenName: 'fecID', - editable: false, - allowBlank: false, - displayField: 'title', - valueField:'id', - mode:'remote', - triggerAction: 'all', - store: new Ext.data.JsonStore({ - root:'entries', - fields: ['title', 'id'], - url: 'dvb/feopts/fec/' + adId - }) - })); + items.push(new Ext.form.ComboBox({ + fieldLabel : 'FEC', + name : 'fec', + hiddenName : 'fecID', + editable : false, + allowBlank : false, + displayField : 'title', + valueField : 'id', + mode : 'remote', + triggerAction : 'all', + store : new Ext.data.JsonStore({ + root : 'entries', + fields : [ 'title', 'id' ], + url : 'dvb/feopts/fec/' + adId + }) + })); + break; - items.push(new Ext.form.ComboBox({ - fieldLabel: 'Delivery System', - name: 'delsys', - hiddenName: 'delsysID', - editable: false, - allowBlank: false, - displayField: 'title', - valueField:'id', - mode:'remote', - triggerAction: 'all', - store: new Ext.data.JsonStore({ - root:'entries', - fields: ['title', 'id'], - url: 'dvb/feopts/delsys/' + adId - }) - })); + case 'DVB-S': + items.push(new Ext.form.NumberField({ + fieldLabel : 'Frequency (kHz)', + name : 'frequency', + allowBlank : false, + allowNegative : false + })); - items.push(new Ext.form.ComboBox({ - fieldLabel: 'Constellation', - name: 'constellation', - hiddenName: 'constellationID', - editable: false, - allowBlank: false, - displayField: 'title', - valueField:'id', - mode:'remote', - triggerAction: 'all', - store: new Ext.data.JsonStore({ - root:'entries', - fields: ['title', 'id'], - url: 'dvb/feopts/constellations/' + adId - }) - })); + items.push(new Ext.form.NumberField({ + fieldLabel : 'Symbolrate (baud)', + name : 'symbolrate', + allowNegative : false, + allowBlank : false, + minValue : adapterData.symrateMin, + maxValue : adapterData.symrateMax + })); - items.push(new Ext.form.ComboBox({ - fieldLabel: 'Polarisation', - name: 'polarisation', - hiddenName: 'polarisationID', - editable: false, - allowBlank: false, - displayField: 'title', - valueField:'id', - mode:'remote', - triggerAction: 'all', - store: new Ext.data.JsonStore({ - root:'entries', - fields: ['title', 'id'], - url: 'dvb/feopts/polarisations/' + adId - }) - })); - } - - if(satConfStore) { - items.push(new Ext.form.ComboBox({ - store: satConfStore, - fieldLabel: 'Satellite config', - name: 'satconf', - hiddenName: 'satconfID', - editable: false, - allowBlank: false, - triggerAction: 'all', - mode: 'remote', - displayField:'name', - valueField:'identifier' - })); - } + items.push(new Ext.form.ComboBox({ + fieldLabel : 'FEC', + name : 'fec', + hiddenName : 'fecID', + editable : false, + allowBlank : false, + displayField : 'title', + valueField : 'id', + mode : 'remote', + triggerAction : 'all', + store : new Ext.data.JsonStore({ + root : 'entries', + fields : [ 'title', 'id' ], + url : 'dvb/feopts/fec/' + adId + }) + })); + + items.push(new Ext.form.ComboBox({ + fieldLabel : 'Delivery System', + name : 'delsys', + hiddenName : 'delsysID', + editable : false, + allowBlank : false, + displayField : 'title', + valueField : 'id', + mode : 'remote', + triggerAction : 'all', + store : new Ext.data.JsonStore({ + root : 'entries', + fields : [ 'title', 'id' ], + url : 'dvb/feopts/delsys/' + adId + }) + })); + + items.push(new Ext.form.ComboBox({ + fieldLabel : 'Constellation', + name : 'constellation', + hiddenName : 'constellationID', + editable : false, + allowBlank : false, + displayField : 'title', + valueField : 'id', + mode : 'remote', + triggerAction : 'all', + store : new Ext.data.JsonStore({ + root : 'entries', + fields : [ 'title', 'id' ], + url : 'dvb/feopts/constellations/' + adId + }) + })); + + items.push(new Ext.form.ComboBox({ + fieldLabel : 'Polarisation', + name : 'polarisation', + hiddenName : 'polarisationID', + editable : false, + allowBlank : false, + displayField : 'title', + valueField : 'id', + mode : 'remote', + triggerAction : 'all', + store : new Ext.data.JsonStore({ + root : 'entries', + fields : [ 'title', 'id' ], + url : 'dvb/feopts/polarisations/' + adId + }) + })); + } + + if (satConfStore) { + items.push(new Ext.form.ComboBox({ + store : satConfStore, + fieldLabel : 'Satellite config', + name : 'satconf', + hiddenName : 'satconfID', + editable : false, + allowBlank : false, + triggerAction : 'all', + mode : 'remote', + displayField : 'name', + valueField : 'identifier' + })); + } + + function addMux() { + panel.getForm().submit({ + url : 'dvb/addmux/' + adapterId, + waitMsg : 'Creating mux...' + }); + } + + var panel = new Ext.FormPanel({ + frame : true, + border : true, + bodyStyle : 'padding:5px', + labelAlign : 'right', + labelWidth : 110, + defaultType : 'textfield', + items : items, + buttons : [ { + text : 'Add', + handler : addMux + } ] - function addMux() { - panel.getForm().submit({ - url:'dvb/addmux/' + adapterId, - waitMsg:'Creating mux...' }); - } - - var panel = new Ext.FormPanel({ - frame:true, - border:true, - bodyStyle:'padding:5px', - labelAlign: 'right', - labelWidth: 110, - defaultType: 'textfield', - items: items, - buttons: [{ - text: 'Add', - handler: addMux - }] - - }); - - win = new Ext.Window({ - title: 'Add muxes on ' + adapterData.name, - layout: 'fit', - width: 500, - height: 500, - plain: true, - items: panel - }); - win.show(); + win = new Ext.Window({ + title : 'Add muxes on ' + adapterData.name, + layout : 'fit', + width : 500, + height : 500, + plain : true, + items : panel + }); + win.show(); } @@ -1056,337 +1028,317 @@ tvheadend.addMuxManually = function(adapterData, satConfStore) { */ tvheadend.dvb_adapter_general = function(adapterData, satConfStore) { - adapterId = adapterData.identifier; + adapterId = adapterData.identifier; - var addMuxByLocationBtn = new Ext.Button({ - style:'margin:5px', - iconCls:'add', - text: 'Add DVB Network by location...', - handler:function() { - tvheadend.addMuxByLocation(adapterData, satConfStore); - } - }); - - var serviceScanBtn = new Ext.Button({ - style:'margin:5px', - iconCls:'option', - text: 'Map DVB services to channels...', - disabled: adapterData.services == 0 || adapterData.initialMuxes, - handler:function() { - Ext.Ajax.request({ - url:'dvb/adapter/' + adapterId, - params: { - op: 'serviceprobe' + var addMuxByLocationBtn = new Ext.Button({ + style : 'margin:5px', + iconCls : 'add', + text : 'Add DVB Network by location...', + handler : function() { + tvheadend.addMuxByLocation(adapterData, satConfStore); } - }) - } - }); - - - /* Tool panel */ - - var toolpanel = new Ext.Panel({ - layout: 'table', - title: 'Tools', - style:'margin:10px', - bodyStyle:'padding:5px', - columnWidth: .25, - layoutConfig: { - columns: 1 - }, - - items: [ - addMuxByLocationBtn, - serviceScanBtn - ] - }); - - /* Conf panel */ - - var confreader = new Ext.data.JsonReader({ - root: 'dvbadapters' - }, ['name', 'automux', 'skip_initialscan', 'idlescan', 'diseqcversion', 'qmon', - 'skip_checksubscr', 'dumpmux', 'poweroff', 'sidtochan', 'nitoid','extrapriority', 'disable_pmt_monitor']); - - - function saveConfForm () { - confform.getForm().submit({ - url:'dvb/adapter/' + adapterId, - params:{'op':'save'}, - waitMsg:'Saving Data...' }); - } - var items = [ - { - fieldLabel: 'Adapter name', - name: 'name', - width: 250 - }, - new Ext.form.Checkbox({ - fieldLabel: 'Autodetect muxes', - name: 'automux' - }), - new Ext.form.Checkbox({ - fieldLabel: 'Skip initial scan', - name: 'skip_initialscan' - }), - new Ext.form.Checkbox({ - fieldLabel: 'Idle scanning', - name: 'idlescan' - }), - new Ext.form.Checkbox({ - fieldLabel: 'Skip service availability check when mapping', - name: 'skip_checksubscr' - }), - new Ext.form.Checkbox({ - fieldLabel: 'Monitor signal quality', - name: 'qmon' - }), - new Ext.form.Checkbox({ - fieldLabel: 'Disable PMT monitoring', - name: 'disable_pmt_monitor' - }), - new Ext.form.Checkbox({ - fieldLabel: 'Write full DVB MUX to disk', - name: 'dumpmux', - handler: function(s, v) { - if(v) - Ext.MessageBox.alert('DVB Mux dump', - 'Please note that keeping this ' + - 'option enabled can consume a lot ' + - 'of diskspace. You have been warned'); - } - }), - { - fieldLabel: 'NIT-o Network ID', - name: 'nitoid', - width: 50 - }, - { - fieldLabel: 'Extra priority', - name: 'extrapriority', - width: 50 - } - ]; - - if(satConfStore) { - v = new Ext.form.ComboBox({ - name: 'diseqcversion', - fieldLabel: 'DiSEqC version', - editable: false, - allowBlank: false, - mode: 'remote', - triggerAction: 'all', - store: ['DiSEqC 1.0 / 2.0', 'DiSEqC 1.1 / 2.1'] + var serviceScanBtn = new Ext.Button({ + style : 'margin:5px', + iconCls : 'option', + text : 'Map DVB services to channels...', + disabled : adapterData.services == 0 || adapterData.initialMuxes, + handler : function() { + Ext.Ajax.request({ + url : 'dvb/adapter/' + adapterId, + params : { + op : 'serviceprobe' + } + }) + } }); - items.push(v); - v = new Ext.form.Checkbox({ - fieldLabel: 'Turn off LNB when idle', - name: 'poweroff' + /* Tool panel */ + + var toolpanel = new Ext.Panel({ + layout : 'table', + title : 'Tools', + style : 'margin:10px', + bodyStyle : 'padding:5px', + columnWidth : .25, + layoutConfig : { + columns : 1 + }, + + items : [ addMuxByLocationBtn, serviceScanBtn ] }); - new Ext.form.Checkbox({ - fieldLabel: 'Use SID as channel number during mapping', - name: 'sidtochan' - }), - items.push(v); - } - - var confform = new Ext.FormPanel({ - title:'Adapter configuration', - columnWidth: .40, - frame:true, - border:true, - disabled:true, - style:'margin:10px', - bodyStyle:'padding:5px', - labelAlign: 'right', - labelWidth: 160, - waitMsgTarget: true, - reader: confreader, - defaultType: 'textfield', - items: items, - buttons: [{ - text: 'Save', - handler: saveConfForm - }] - }); - - confform.getForm().load({ - url:'dvb/adapter/' + adapterId, - params:{'op':'load'}, - success:function(form, action) { - confform.enable(); + + /* Conf panel */ + + var confreader = new Ext.data.JsonReader({ + root : 'dvbadapters' + }, [ 'name', 'automux', 'skip_initialscan', 'idlescan', 'diseqcversion', + 'qmon', 'skip_checksubscr', 'dumpmux', 'poweroff', 'sidtochan', 'nitoid', + 'extrapriority', 'disable_pmt_monitor' ]); + + function saveConfForm() { + confform.getForm().submit({ + url : 'dvb/adapter/' + adapterId, + params : { + 'op' : 'save' + }, + waitMsg : 'Saving Data...' + }); } - }); - /** - * Information / capabilities panel - */ - - var infoTemplate = new Ext.XTemplate( - '
License details: http://www.gnu.org/licenses/lgpl.html
+ * + * @forum 29961 + * @demo http://rowactions.extjs.eu + * @download + ** callbacks:{ - * 'icon-open':function(...) {...} - * ,'icon-save':function(...) {...} + * 'icon-open':function(...) {...} + * ,'icon-save':function(...) {...} * } + **/ /** @@ -769,13 +824,30 @@ Ext.extend(Ext.ux.grid.RowActions, Ext.util.Observable, { */ ,header:'' + /** + * @cfg {Boolean} isColumn + * Tell ColumnModel that we are column. Do not touch! + * @private + */ + ,isColumn:true + + /** + * @cfg {Boolean} keepSelection + * Set it to true if you do not want action clicks to affect selected row(s) (defaults to false). + * By default, when user clicks an action icon the clicked row is selected and the action events are fired. + * If this option is true then the current selection is not affected, only the action events are fired. + */ + ,keepSelection:false + /** * @cfg {Boolean} menuDisabled No sense to display header menu for this column + * @private */ ,menuDisabled:true /** * @cfg {Boolean} sortable Usually it has no sense to sort by this column + * @private */ ,sortable:false @@ -803,12 +875,22 @@ Ext.extend(Ext.ux.grid.RowActions, Ext.util.Observable, { +'' /** - * @private {Number} widthIntercept constant used for auto-width calculation + * @cfg {String} hideMode How to hide hidden icons. Valid values are: 'visibility' and 'display' + * (defaluts to 'visibility'). If the mode is visibility the hidden icon is not visible but there + * is still blank space occupied by the icon. In display mode, the visible icons are shifted taking + * the space of the hidden icon. + */ + ,hideMode:'visibility' + + /** + * @cfg {Number} widthIntercept Constant used for auto-width calculation (defaults to 4). + * See {@link #autoWidth} for explanation. */ ,widthIntercept:4 /** - * @private {Number} widthSlope constant used for auto-width calculation + * @cfg {Number} widthSlope Constant used for auto-width calculation (defaults to 21). + * See {@link #autoWidth} for explanation. */ ,widthSlope:21 // }}} @@ -822,6 +904,14 @@ Ext.extend(Ext.ux.grid.RowActions, Ext.util.Observable, { ,init:function(grid) { this.grid = grid; + // the actions column must have an id for Ext 3.x + this.id = this.id || Ext.id(); + + // for Ext 3.x compatibility + var lookup = grid.getColumnModel().lookup; + delete(lookup[undefined]); + lookup[this.id] = this; + // {{{ // setup template if(!this.tpl) { @@ -840,11 +930,10 @@ Ext.extend(Ext.ux.grid.RowActions, Ext.util.Observable, { var view = grid.getView(); var cfg = {scope:this}; cfg[this.actionEvent] = this.onClick; - grid.on({ - render:{scope:this, fn:function() { - view.mainBody.on(cfg); - }} - }); + grid.afterRender = grid.afterRender.createSequence(function() { + view.mainBody.on(cfg); + grid.on('destroy', this.purgeListeners, this); + }, this); // setup renderer if(!this.renderer) { @@ -866,6 +955,15 @@ Ext.extend(Ext.ux.grid.RowActions, Ext.util.Observable, { +this.processActions(this.groupActions, this.tplGroup).apply() ; } + + // cancel click + if(true === this.keepSelection) { + grid.processEvent = grid.processEvent.createInterceptor(function(name, e) { + if('mousedown' === name) { + return !this.getAction(e); + } + }, this); + } } // eo function init // }}} @@ -878,7 +976,7 @@ Ext.extend(Ext.ux.grid.RowActions, Ext.util.Observable, { * @param {Number} row row index * @param {Number} col col index * @param {Ext.data.Store} store object from which the record is extracted - * @returns {Object} data to apply to template + * @return {Object} data to apply to template */ ,getData:function(value, cell, record, row, col, store) { return record.data || {}; @@ -908,7 +1006,10 @@ Ext.extend(Ext.ux.grid.RowActions, Ext.util.Observable, { cls:a.iconIndex ? '{' + a.iconIndex + '}' : (a.iconCls ? a.iconCls : '') ,qtip:a.qtipIndex ? '{' + a.qtipIndex + '}' : (a.tooltip || a.qtip ? a.tooltip || a.qtip : '') ,text:a.textIndex ? '{' + a.textIndex + '}' : (a.text ? a.text : '') - ,hide:a.hideIndex ? '
Embedded player could not be started.
You are probably missing VLC Mozilla plugin for your browser.
Embedded player could not be started.
You are probably missing VLC Mozilla plugin for your browser.
Embedded player could not be started.
You are probably missing VLC Mozilla plugin for your browser.
' + msg + '
' + msg + '
Extends one class to create a subclass and optionally overrides members with the passed literal. This method + * also adds the function "override()" to the subclass that can be used to override members of the class.
+ * For example, to create a subclass of Ext GridPanel: + *
+MyGridPanel = Ext.extend(Ext.grid.GridPanel, {
+ constructor: function(config) {
+
+// Create configuration for this Grid.
+ var store = new Ext.data.Store({...});
+ var colModel = new Ext.grid.ColumnModel({...});
+
+// Create a new config object containing our computed properties
+// *plus* whatever was in the config parameter.
+ config = Ext.apply({
+ store: store,
+ colModel: colModel
+ }, config);
+
+ MyGridPanel.superclass.constructor.call(this, config);
+
+// Your postprocessing here
+ },
+
+ yourMethod: function() {
+ // etc.
+ }
+});
+
+ *
+ * This function also supports a 3-argument call in which the subclass's constructor is + * passed as an argument. In this form, the parameters are as follows:
+ *subclass
: Function superclass
: Function overrides
: Object A literal with members which are copied into the subclass's + * prototype, and are therefore shared between all instances of the new class.
+ *This may contain a special member named constructor. This is used + * to define the constructor of the new class, and is returned. If this property is + * not specified, a constructor is generated and returned which just calls the + * superclass's constructor passing on its parameters.
+ *It is essential that you call the superclass constructor in any provided constructor. See example code.
+ * @return {Function} The subclass constructor from theoverrides
parameter, or a generated one if not provided.
+ */
+ extend : function(){
+ // inline overrides
+ var io = function(o){
+ for(var m in o){
+ this[m] = o[m];
+ }
+ };
+ var oc = Object.prototype.constructor;
+
+ return function(sb, sp, overrides){
+ if(typeof sp == 'object'){
+ overrides = sp;
+ sp = sb;
+ sb = overrides.constructor != oc ? overrides.constructor : function(){sp.apply(this, arguments);};
+ }
+ var F = function(){},
+ sbp,
+ spp = sp.prototype;
+
+ F.prototype = spp;
+ sbp = sb.prototype = new F();
+ sbp.constructor=sb;
+ sb.superclass=spp;
+ if(spp.constructor == oc){
+ spp.constructor=sp;
+ }
+ sb.override = function(o){
+ Ext.override(sb, o);
+ };
+ sbp.superclass = sbp.supr = (function(){
+ return spp;
+ });
+ sbp.override = io;
+ Ext.override(sb, overrides);
+ sb.extend = function(o){return Ext.extend(sb, o);};
+ return sb;
+ };
+ }(),
+
+ /**
+ * Adds a list of functions to the prototype of an existing class, overwriting any existing methods with the same name.
+ * Usage:
+Ext.override(MyClass, {
+ newMethod1: function(){
+ // etc.
+ },
+ newMethod2: function(foo){
+ // etc.
+ }
+});
+
+ * @param {Object} origclass The class to override
+ * @param {Object} overrides The list of functions to add to origClass. This should be specified as an object literal
+ * containing one or more methods.
+ * @method override
+ */
+ override : function(origclass, overrides){
+ if(overrides){
+ var p = origclass.prototype;
+ Ext.apply(p, overrides);
+ if(Ext.isIE && overrides.hasOwnProperty('toString')){
+ p.toString = overrides.toString;
+ }
+ }
+ },
+
+ /**
+ * Creates namespaces to be used for scoping variables and classes so that they are not global.
+ * Specifying the last node of a namespace implicitly creates all other nodes. Usage:
+ *
+Ext.namespace('Company', 'Company.data');
+Ext.namespace('Company.data'); // equivalent and preferable to above syntax
+Company.Widget = function() { ... }
+Company.data.CustomStore = function(config) { ... }
+
+ * @param {String} namespace1
+ * @param {String} namespace2
+ * @param {String} etc
+ * @return {Object} The namespace object. (If multiple arguments are passed, this will be the last namespace created)
+ * @method namespace
+ */
+ namespace : function(){
+ var len1 = arguments.length,
+ i = 0,
+ len2,
+ j,
+ main,
+ ns,
+ sub,
+ current;
+
+ for(; i < len1; ++i) {
+ main = arguments[i];
+ ns = arguments[i].split('.');
+ current = window[ns[0]];
+ if (current === undefined) {
+ current = window[ns[0]] = {};
+ }
+ sub = ns.slice(1);
+ len2 = sub.length;
+ for(j = 0; j < len2; ++j) {
+ current = current[sub[j]] = current[sub[j]] || {};
+ }
+ }
+ return current;
+ },
+
+ /**
+ * Takes an object and converts it to an encoded URL. e.g. Ext.urlEncode({foo: 1, bar: 2}); would return "foo=1&bar=2". Optionally, property values can be arrays, instead of keys and the resulting string that's returned will contain a name/value pair for each array value.
+ * @param {Object} o
+ * @param {String} pre (optional) A prefix to add to the url encoded string
+ * @return {String}
+ */
+ urlEncode : function(o, pre){
+ var empty,
+ buf = [],
+ e = encodeURIComponent;
+
+ Ext.iterate(o, function(key, item){
+ empty = Ext.isEmpty(item);
+ Ext.each(empty ? key : item, function(val){
+ buf.push('&', e(key), '=', (!Ext.isEmpty(val) && (val != key || !empty)) ? (Ext.isDate(val) ? Ext.encode(val).replace(/"/g, '') : e(val)) : '');
+ });
+ });
+ if(!pre){
+ buf.shift();
+ pre = '';
+ }
+ return pre + buf.join('');
+ },
+
+ /**
+ * Takes an encoded URL and and converts it to an object. Example:
+Ext.urlDecode("foo=1&bar=2"); // returns {foo: "1", bar: "2"}
+Ext.urlDecode("foo=1&bar=2&bar=3&bar=4", false); // returns {foo: "1", bar: ["2", "3", "4"]}
+
+ * @param {String} string
+ * @param {Boolean} overwrite (optional) Items of the same name will overwrite previous values instead of creating an an array (Defaults to false).
+ * @return {Object} A literal with members
+ */
+ urlDecode : function(string, overwrite){
+ if(Ext.isEmpty(string)){
+ return {};
+ }
+ var obj = {},
+ pairs = string.split('&'),
+ d = decodeURIComponent,
+ name,
+ value;
+ Ext.each(pairs, function(pair) {
+ pair = pair.split('=');
+ name = d(pair[0]);
+ value = d(pair[1]);
+ obj[name] = overwrite || !obj[name] ? value :
+ [].concat(obj[name]).concat(value);
+ });
+ return obj;
+ },
+
+ /**
+ * Appends content to the query string of a URL, handling logic for whether to place
+ * a question mark or ampersand.
+ * @param {String} url The URL to append to.
+ * @param {String} s The content to append to the URL.
+ * @return (String) The resulting URL
+ */
+ urlAppend : function(url, s){
+ if(!Ext.isEmpty(s)){
+ return url + (url.indexOf('?') === -1 ? '?' : '&') + s;
+ }
+ return url;
+ },
+
+ /**
+ * Converts any iterable (numeric indices and a length property) into a true array
+ * Don't use this on strings. IE doesn't support "abc"[0] which this implementation depends on.
+ * For strings, use this instead: "abc".match(/./g) => [a,b,c];
+ * @param {Iterable} the iterable object to be turned into a true Array.
+ * @return (Array) array
+ */
+ toArray : function(){
+ return isIE ?
+ function(a, i, j, res){
+ res = [];
+ for(var x = 0, len = a.length; x < len; x++) {
+ res.push(a[x]);
+ }
+ return res.slice(i || 0, j || res.length);
+ } :
+ function(a, i, j){
+ return Array.prototype.slice.call(a, i || 0, j || a.length);
+ };
+ }(),
+
+ isIterable : function(v){
+ //check for array or arguments
+ if(Ext.isArray(v) || v.callee){
+ return true;
+ }
+ //check for node list type
+ if(/NodeList|HTMLCollection/.test(toString.call(v))){
+ return true;
+ }
+ //NodeList has an item and length property
+ //IXMLDOMNodeList has nextNode method, needs to be checked first.
+ return ((typeof v.nextNode != 'undefined' || v.item) && Ext.isNumber(v.length));
+ },
+
+ /**
+ * Iterates an array calling the supplied function.
+ * @param {Array/NodeList/Mixed} array The array to be iterated. If this
+ * argument is not really an array, the supplied function is called once.
+ * @param {Function} fn The function to be called with each item. If the
+ * supplied function returns false, iteration stops and this method returns
+ * the current index
. This function is called with
+ * the following arguments:
+ * item
: Mixed
+ * index
+ * in the passed array
index
: Number
+ * allItems
: Array
+ * array
passed as the first
+ * argument to Ext.each
.this
reference) in which the specified function is executed.
+ * Defaults to the item
at the current index
+ * within the passed array
.
+ * @return See description for the fn parameter.
+ */
+ each : function(array, fn, scope){
+ if(Ext.isEmpty(array, true)){
+ return;
+ }
+ if(!Ext.isIterable(array) || Ext.isPrimitive(array)){
+ array = [array];
+ }
+ for(var i = 0, len = array.length; i < len; i++){
+ if(fn.call(scope || array[i], array[i], i, array) === false){
+ return i;
+ };
+ }
+ },
+
+ /**
+ * Iterates either the elements in an array, or each of the properties in an object.
+ * Note: If you are only iterating arrays, it is better to call {@link #each}.
+ * @param {Object/Array} object The object or array to be iterated
+ * @param {Function} fn The function to be called for each iteration.
+ * The iteration will stop if the supplied function returns false, or
+ * all array elements / object properties have been covered. The signature
+ * varies depending on the type of object being interated:
+ * this
reference) in which the specified function is executed. Defaults to
+ * the object
being iterated.
+ */
+ iterate : function(obj, fn, scope){
+ if(Ext.isEmpty(obj)){
+ return;
+ }
+ if(Ext.isIterable(obj)){
+ Ext.each(obj, fn, scope);
+ return;
+ }else if(typeof obj == 'object'){
+ for(var prop in obj){
+ if(obj.hasOwnProperty(prop)){
+ if(fn.call(scope || obj, prop, obj[prop], obj) === false){
+ return;
+ };
+ }
+ }
+ }
+ },
+
+ /**
+ * Return the dom node for the passed String (id), dom node, or Ext.Element.
+ * Optional 'strict' flag is needed for IE since it can return 'name' and
+ * 'id' elements by using getElementById.
+ * Here are some examples:
+ *
+// gets dom node based on id
+var elDom = Ext.getDom('elId');
+// gets dom node based on the dom node
+var elDom1 = Ext.getDom(elDom);
+
+// If we don't know if we are working with an
+// Ext.Element or a dom node use Ext.getDom
+function(el){
+ var dom = Ext.getDom(el);
+ // do something with the dom node
+}
+ *
+ * Note: the dom node to be found actually needs to exist (be rendered, etc)
+ * when this method is called to be successful.
+ * @param {Mixed} el
+ * @return HTMLElement
+ */
+ getDom : function(el, strict){
+ if(!el || !DOC){
+ return null;
+ }
+ if (el.dom){
+ return el.dom;
+ } else {
+ if (typeof el == 'string') {
+ var e = DOC.getElementById(el);
+ // IE returns elements with the 'name' and 'id' attribute.
+ // we do a strict check to return the element with only the id attribute
+ if (e && isIE && strict) {
+ if (el == e.getAttribute('id')) {
+ return e;
+ } else {
+ return null;
+ }
+ }
+ return e;
+ } else {
+ return el;
+ }
+ }
+ },
+
+ /**
+ * Returns the current document body as an {@link Ext.Element}.
+ * @return Ext.Element The document body
+ */
+ getBody : function(){
+ return Ext.get(DOC.body || DOC.documentElement);
+ },
+
+ /**
+ * Returns the current document body as an {@link Ext.Element}.
+ * @return Ext.Element The document body
+ */
+ getHead : function() {
+ var head;
+
+ return function() {
+ if (head == undefined) {
+ head = Ext.get(DOC.getElementsByTagName("head")[0]);
+ }
+
+ return head;
+ };
+ }(),
+
+ /**
+ * Removes a DOM node from the document.
+ */
+ /**
+ * Removes this element from the document, removes all DOM event listeners, and deletes the cache reference.
+ * All DOM event listeners are removed from this element. If {@link Ext#enableNestedListenerRemoval} is
+ * true
, then DOM event listeners are also removed from all child nodes. The body node
+ * will be ignored if passed in.
Returns true if the passed value is empty.
+ *The value is deemed to be empty if it is
+Ext.namespace('Company', 'Company.data');
+Ext.namespace('Company.data'); // equivalent and preferable to above syntax
+Company.Widget = function() { ... }
+Company.data.CustomStore = function(config) { ... }
+
+ * @param {String} namespace1
+ * @param {String} namespace2
+ * @param {String} etc
+ * @return {Object} The namespace object. (If multiple arguments are passed, this will be the last namespace created)
+ * @method ns
+ */
+ Ext.ns = Ext.namespace;
+})();
+
+Ext.ns('Ext.util', 'Ext.lib', 'Ext.data', 'Ext.supports');
+
+Ext.elCache = {};
+
+/**
+ * @class Function
+ * These functions are available on every Function object (any JavaScript function).
+ */
+Ext.apply(Function.prototype, {
+ /**
+ * Creates an interceptor function. The passed function is called before the original one. If it returns false,
+ * the original one is not called. The resulting function returns the results of the original function.
+ * The passed function is called with the parameters of the original function. Example usage:
+ *
+var sayHi = function(name){
+ alert('Hi, ' + name);
+}
+
+sayHi('Fred'); // alerts "Hi, Fred"
+
+// create a new function that validates input without
+// directly modifying the original function:
+var sayHiToFriend = sayHi.createInterceptor(function(name){
+ return name == 'Brian';
+});
+
+sayHiToFriend('Fred'); // no alert
+sayHiToFriend('Brian'); // alerts "Hi, Brian"
+
+ * @param {Function} fcn The function to call before the original
+ * @param {Object} scope (optional) The scope (this
reference) in which the passed function is executed.
+ * If omitted, defaults to the scope in which the original function is called or the browser window.
+ * @return {Function} The new function
+ */
+ createInterceptor : function(fcn, scope){
+ var method = this;
+ return !Ext.isFunction(fcn) ?
+ this :
+ function() {
+ var me = this,
+ args = arguments;
+ fcn.target = me;
+ fcn.method = method;
+ return (fcn.apply(scope || me || window, args) !== false) ?
+ method.apply(me || window, args) :
+ null;
+ };
+ },
+
+ /**
+ * Creates a callback that passes arguments[0], arguments[1], arguments[2], ...
+ * Call directly on any function. Example: myFunction.createCallback(arg1, arg2)
+ * Will create a function that is bound to those 2 args. If a specific scope is required in the
+ * callback, use {@link #createDelegate} instead. The function returned by createCallback always
+ * executes in the window scope.
+ * This method is required when you want to pass arguments to a callback function. If no arguments + * are needed, you can simply pass a reference to the function as a callback (e.g., callback: myFn). + * However, if you tried to pass a function with arguments (e.g., callback: myFn(arg1, arg2)) the function + * would simply execute immediately when the code is parsed. Example usage: + *
+var sayHi = function(name){
+ alert('Hi, ' + name);
+}
+
+// clicking the button alerts "Hi, Fred"
+new Ext.Button({
+ text: 'Say Hi',
+ renderTo: Ext.getBody(),
+ handler: sayHi.createCallback('Fred')
+});
+
+ * @return {Function} The new function
+ */
+ createCallback : function(/*args...*/){
+ // make args available, in function below
+ var args = arguments,
+ method = this;
+ return function() {
+ return method.apply(window, args);
+ };
+ },
+
+ /**
+ * Creates a delegate (callback) that sets the scope to obj.
+ * Call directly on any function. Example: this.myFunction.createDelegate(this, [arg1, arg2])
+ * Will create a function that is automatically scoped to obj so that the this variable inside the
+ * callback points to obj. Example usage:
+ *
+var sayHi = function(name){
+ // Note this use of "this.text" here. This function expects to
+ // execute within a scope that contains a text property. In this
+ // example, the "this" variable is pointing to the btn object that
+ // was passed in createDelegate below.
+ alert('Hi, ' + name + '. You clicked the "' + this.text + '" button.');
+}
+
+var btn = new Ext.Button({
+ text: 'Say Hi',
+ renderTo: Ext.getBody()
+});
+
+// This callback will execute in the scope of the
+// button instance. Clicking the button alerts
+// "Hi, Fred. You clicked the "Say Hi" button."
+btn.on('click', sayHi.createDelegate(btn, ['Fred']));
+
+ * @param {Object} scope (optional) The scope (this
reference) in which the function is executed.
+ * If omitted, defaults to the browser window.
+ * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
+ * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
+ * if a number the args are inserted at the specified position
+ * @return {Function} The new function
+ */
+ createDelegate : function(obj, args, appendArgs){
+ var method = this;
+ return function() {
+ var callArgs = args || arguments;
+ if (appendArgs === true){
+ callArgs = Array.prototype.slice.call(arguments, 0);
+ callArgs = callArgs.concat(args);
+ }else if (Ext.isNumber(appendArgs)){
+ callArgs = Array.prototype.slice.call(arguments, 0); // copy arguments first
+ var applyArgs = [appendArgs, 0].concat(args); // create method call params
+ Array.prototype.splice.apply(callArgs, applyArgs); // splice them in
+ }
+ return method.apply(obj || window, callArgs);
+ };
+ },
+
+ /**
+ * Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
+ *
+var sayHi = function(name){
+ alert('Hi, ' + name);
+}
+
+// executes immediately:
+sayHi('Fred');
+
+// executes after 2 seconds:
+sayHi.defer(2000, this, ['Fred']);
+
+// this syntax is sometimes useful for deferring
+// execution of an anonymous function:
+(function(){
+ alert('Anonymous');
+}).defer(100);
+
+ * @param {Number} millis The number of milliseconds for the setTimeout call (if less than or equal to 0 the function is executed immediately)
+ * @param {Object} scope (optional) The scope (this
reference) in which the function is executed.
+ * If omitted, defaults to the browser window.
+ * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
+ * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
+ * if a number the args are inserted at the specified position
+ * @return {Number} The timeout id that can be used with clearTimeout
+ */
+ defer : function(millis, obj, args, appendArgs){
+ var fn = this.createDelegate(obj, args, appendArgs);
+ if(millis > 0){
+ return setTimeout(fn, millis);
+ }
+ fn();
+ return 0;
+ }
+});
+
+/**
+ * @class String
+ * These functions are available on every String object.
+ */
+Ext.applyIf(String, {
+ /**
+ * Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each
+ * token must be unique, and must increment in the format {0}, {1}, etc. Example usage:
+ *
+var cls = 'my-class', text = 'Some text';
+var s = String.format('<div class="{0}">{1}</div>', cls, text);
+// s now contains the string: '<div class="my-class">Some text</div>'
+ *
+ * @param {String} string The tokenized string to be formatted
+ * @param {String} value1 The value to replace token {0}
+ * @param {String} value2 Etc...
+ * @return {String} The formatted string
+ * @static
+ */
+ format : function(format){
+ var args = Ext.toArray(arguments, 1);
+ return format.replace(/\{(\d+)\}/g, function(m, i){
+ return args[i];
+ });
+ }
+});
+
+/**
+ * @class Array
+ */
+Ext.applyIf(Array.prototype, {
+ /**
+ * Checks whether or not the specified object exists in the array.
+ * @param {Object} o The object to check for
+ * @param {Number} from (Optional) The index at which to begin the search
+ * @return {Number} The index of o in the array (or -1 if it is not found)
+ */
+ indexOf : function(o, from){
+ var len = this.length;
+ from = from || 0;
+ from += (from < 0) ? len : 0;
+ for (; from < len; ++from){
+ if(this[from] === o){
+ return from;
+ }
+ }
+ return -1;
+ },
+
+ /**
+ * Removes the specified object from the array. If the object is not found nothing happens.
+ * @param {Object} o The object to remove
+ * @return {Array} this array
+ */
+ remove : function(o){
+ var index = this.indexOf(o);
+ if(index != -1){
+ this.splice(index, 1);
+ }
+ return this;
+ }
+});
+/**
+ * @class Ext.util.TaskRunner
+ * Provides the ability to execute one or more arbitrary tasks in a multithreaded
+ * manner. Generally, you can use the singleton {@link Ext.TaskMgr} instead, but
+ * if needed, you can create separate instances of TaskRunner. Any number of
+ * separate tasks can be started at any time and will run independently of each
+ * other. Example usage:
+ *
+// Start a simple clock task that updates a div once per second
+var updateClock = function(){
+ Ext.fly('clock').update(new Date().format('g:i:s A'));
+}
+var task = {
+ run: updateClock,
+ interval: 1000 //1 second
+}
+var runner = new Ext.util.TaskRunner();
+runner.start(task);
+
+// equivalent using TaskMgr
+Ext.TaskMgr.start({
+ run: updateClock,
+ interval: 1000
+});
+
+ *
+ * See the {@link #start} method for details about how to configure a task object.
+ * Also see {@link Ext.util.DelayedTask}. + * + * @constructor + * @param {Number} interval (optional) The minimum precision in milliseconds supported by this TaskRunner instance + * (defaults to 10) + */ +Ext.util.TaskRunner = function(interval){ + interval = interval || 10; + var tasks = [], + removeQueue = [], + id = 0, + running = false, + + // private + stopThread = function(){ + running = false; + clearInterval(id); + id = 0; + }, + + // private + startThread = function(){ + if(!running){ + running = true; + id = setInterval(runTasks, interval); + } + }, + + // private + removeTask = function(t){ + removeQueue.push(t); + if(t.onStop){ + t.onStop.apply(t.scope || t); + } + }, + + // private + runTasks = function(){ + var rqLen = removeQueue.length, + now = new Date().getTime(); + + if(rqLen > 0){ + for(var i = 0; i < rqLen; i++){ + tasks.remove(removeQueue[i]); + } + removeQueue = []; + if(tasks.length < 1){ + stopThread(); + return; + } + } + for(var i = 0, t, itime, rt, len = tasks.length; i < len; ++i){ + t = tasks[i]; + itime = now - t.taskRunTime; + if(t.interval <= itime){ + rt = t.run.apply(t.scope || t, t.args || [++t.taskRunCount]); + t.taskRunTime = now; + if(rt === false || t.taskRunCount === t.repeat){ + removeTask(t); + return; + } + } + if(t.duration && t.duration <= (now - t.taskStartTime)){ + removeTask(t); + } + } + }; + + /** + * Starts a new task. + * @method start + * @param {Object} taskA config object that supports the following properties:
run
: FunctionThe function to execute each time the task is invoked. The
+ * function will be called at each interval and passed the args
argument if specified, and the
+ * current invocation count if not.
If a particular scope (this
reference) is required, be sure to specify it using the scope
argument.
Return false
from this function to terminate the task.
interval
: Numberargs
: Arrayrun
. If not specified, the current invocation count is passed.scope
: Objectrun
function. Defaults to the task config object.duration
: Numberrepeat
: NumberBefore each invocation, Ext injects the property taskRunCount
into the task object so
+ * that calculations based on the repeat count can be performed.
+// Start a simple clock task that updates a div once per second
+var task = {
+ run: function(){
+ Ext.fly('clock').update(new Date().format('g:i:s A'));
+ },
+ interval: 1000 //1 second
+}
+Ext.TaskMgr.start(task);
+
+ * See the {@link #start} method for details about how to configure a task object.
+ * @singleton + */ +Ext.TaskMgr = new Ext.util.TaskRunner();(function(){ + var libFlyweight; + + function fly(el) { + if (!libFlyweight) { + libFlyweight = new Ext.Element.Flyweight(); + } + libFlyweight.dom = el; + return libFlyweight; + } + + (function(){ + var doc = document, + isCSS1 = doc.compatMode == "CSS1Compat", + MAX = Math.max, + ROUND = Math.round, + PARSEINT = parseInt; + + Ext.lib.Dom = { + isAncestor : function(p, c) { + var ret = false; + + p = Ext.getDom(p); + c = Ext.getDom(c); + if (p && c) { + if (p.contains) { + return p.contains(c); + } else if (p.compareDocumentPosition) { + return !!(p.compareDocumentPosition(c) & 16); + } else { + while (c = c.parentNode) { + ret = c == p || ret; + } + } + } + return ret; + }, + + getViewWidth : function(full) { + return full ? this.getDocumentWidth() : this.getViewportWidth(); + }, + + getViewHeight : function(full) { + return full ? this.getDocumentHeight() : this.getViewportHeight(); + }, + + getDocumentHeight: function() { + return MAX(!isCSS1 ? doc.body.scrollHeight : doc.documentElement.scrollHeight, this.getViewportHeight()); + }, + + getDocumentWidth: function() { + return MAX(!isCSS1 ? doc.body.scrollWidth : doc.documentElement.scrollWidth, this.getViewportWidth()); + }, + + getViewportHeight: function(){ + return Ext.isIE ? + (Ext.isStrict ? doc.documentElement.clientHeight : doc.body.clientHeight) : + self.innerHeight; + }, + + getViewportWidth : function() { + return !Ext.isStrict && !Ext.isOpera ? doc.body.clientWidth : + Ext.isIE ? doc.documentElement.clientWidth : self.innerWidth; + }, + + getY : function(el) { + return this.getXY(el)[1]; + }, + + getX : function(el) { + return this.getXY(el)[0]; + }, + + getXY : function(el) { + var p, + pe, + b, + bt, + bl, + dbd, + x = 0, + y = 0, + scroll, + hasAbsolute, + bd = (doc.body || doc.documentElement), + ret = [0,0]; + + el = Ext.getDom(el); + + if(el != bd){ + if (el.getBoundingClientRect) { + b = el.getBoundingClientRect(); + scroll = fly(document).getScroll(); + ret = [ROUND(b.left + scroll.left), ROUND(b.top + scroll.top)]; + } else { + p = el; + hasAbsolute = fly(el).isStyle("position", "absolute"); + + while (p) { + pe = fly(p); + x += p.offsetLeft; + y += p.offsetTop; + + hasAbsolute = hasAbsolute || pe.isStyle("position", "absolute"); + + if (Ext.isGecko) { + y += bt = PARSEINT(pe.getStyle("borderTopWidth"), 10) || 0; + x += bl = PARSEINT(pe.getStyle("borderLeftWidth"), 10) || 0; + + if (p != el && !pe.isStyle('overflow','visible')) { + x += bl; + y += bt; + } + } + p = p.offsetParent; + } + + if (Ext.isSafari && hasAbsolute) { + x -= bd.offsetLeft; + y -= bd.offsetTop; + } + + if (Ext.isGecko && !hasAbsolute) { + dbd = fly(bd); + x += PARSEINT(dbd.getStyle("borderLeftWidth"), 10) || 0; + y += PARSEINT(dbd.getStyle("borderTopWidth"), 10) || 0; + } + + p = el.parentNode; + while (p && p != bd) { + if (!Ext.isOpera || (p.tagName != 'TR' && !fly(p).isStyle("display", "inline"))) { + x -= p.scrollLeft; + y -= p.scrollTop; + } + p = p.parentNode; + } + ret = [x,y]; + } + } + return ret; + }, + + setXY : function(el, xy) { + (el = Ext.fly(el, '_setXY')).position(); + + var pts = el.translatePoints(xy), + style = el.dom.style, + pos; + + for (pos in pts) { + if (!isNaN(pts[pos])) { + style[pos] = pts[pos] + "px"; + } + } + }, + + setX : function(el, x) { + this.setXY(el, [x, false]); + }, + + setY : function(el, y) { + this.setXY(el, [false, y]); + } + }; +})();Ext.lib.Event = function() { + var loadComplete = false, + unloadListeners = {}, + retryCount = 0, + onAvailStack = [], + _interval, + locked = false, + win = window, + doc = document, + + // constants + POLL_RETRYS = 200, + POLL_INTERVAL = 20, + TYPE = 0, + FN = 1, + OBJ = 2, + ADJ_SCOPE = 3, + SCROLLLEFT = 'scrollLeft', + SCROLLTOP = 'scrollTop', + UNLOAD = 'unload', + MOUSEOVER = 'mouseover', + MOUSEOUT = 'mouseout', + // private + doAdd = function() { + var ret; + if (win.addEventListener) { + ret = function(el, eventName, fn, capture) { + if (eventName == 'mouseenter') { + fn = fn.createInterceptor(checkRelatedTarget); + el.addEventListener(MOUSEOVER, fn, (capture)); + } else if (eventName == 'mouseleave') { + fn = fn.createInterceptor(checkRelatedTarget); + el.addEventListener(MOUSEOUT, fn, (capture)); + } else { + el.addEventListener(eventName, fn, (capture)); + } + return fn; + }; + } else if (win.attachEvent) { + ret = function(el, eventName, fn, capture) { + el.attachEvent("on" + eventName, fn); + return fn; + }; + } else { + ret = function(){}; + } + return ret; + }(), + // private + doRemove = function(){ + var ret; + if (win.removeEventListener) { + ret = function (el, eventName, fn, capture) { + if (eventName == 'mouseenter') { + eventName = MOUSEOVER; + } else if (eventName == 'mouseleave') { + eventName = MOUSEOUT; + } + el.removeEventListener(eventName, fn, (capture)); + }; + } else if (win.detachEvent) { + ret = function (el, eventName, fn) { + el.detachEvent("on" + eventName, fn); + }; + } else { + ret = function(){}; + } + return ret; + }(); + + function checkRelatedTarget(e) { + return !elContains(e.currentTarget, pub.getRelatedTarget(e)); + } + + function elContains(parent, child) { + if(parent && parent.firstChild){ + while(child) { + if(child === parent) { + return true; + } + child = child.parentNode; + if(child && (child.nodeType != 1)) { + child = null; + } + } + } + return false; + } + + // private + function _tryPreloadAttach() { + var ret = false, + notAvail = [], + element, i, v, override, + tryAgain = !loadComplete || (retryCount > 0); + + if(!locked){ + locked = true; + + for(i = 0; i < onAvailStack.length; ++i){ + v = onAvailStack[i]; + if(v && (element = doc.getElementById(v.id))){ + if(!v.checkReady || loadComplete || element.nextSibling || (doc && doc.body)) { + override = v.override; + element = override ? (override === true ? v.obj : override) : element; + v.fn.call(element, v.obj); + onAvailStack.remove(v); + --i; + }else{ + notAvail.push(v); + } + } + } + + retryCount = (notAvail.length === 0) ? 0 : retryCount - 1; + + if (tryAgain) { + startInterval(); + } else { + clearInterval(_interval); + _interval = null; + } + ret = !(locked = false); + } + return ret; + } + + // private + function startInterval() { + if(!_interval){ + var callback = function() { + _tryPreloadAttach(); + }; + _interval = setInterval(callback, POLL_INTERVAL); + } + } + + // private + function getScroll() { + var dd = doc.documentElement, + db = doc.body; + if(dd && (dd[SCROLLTOP] || dd[SCROLLLEFT])){ + return [dd[SCROLLLEFT], dd[SCROLLTOP]]; + }else if(db){ + return [db[SCROLLLEFT], db[SCROLLTOP]]; + }else{ + return [0, 0]; + } + } + + // private + function getPageCoord (ev, xy) { + ev = ev.browserEvent || ev; + var coord = ev['page' + xy]; + if (!coord && coord !== 0) { + coord = ev['client' + xy] || 0; + + if (Ext.isIE) { + coord += getScroll()[xy == "X" ? 0 : 1]; + } + } + + return coord; + } + + var pub = { + extAdapter: true, + onAvailable : function(p_id, p_fn, p_obj, p_override) { + onAvailStack.push({ + id: p_id, + fn: p_fn, + obj: p_obj, + override: p_override, + checkReady: false }); + + retryCount = POLL_RETRYS; + startInterval(); + }, + + // This function should ALWAYS be called from Ext.EventManager + addListener: function(el, eventName, fn) { + el = Ext.getDom(el); + if (el && fn) { + if (eventName == UNLOAD) { + if (unloadListeners[el.id] === undefined) { + unloadListeners[el.id] = []; + } + unloadListeners[el.id].push([eventName, fn]); + return fn; + } + return doAdd(el, eventName, fn, false); + } + return false; + }, + + // This function should ALWAYS be called from Ext.EventManager + removeListener: function(el, eventName, fn) { + el = Ext.getDom(el); + var i, len, li, lis; + if (el && fn) { + if(eventName == UNLOAD){ + if((lis = unloadListeners[el.id]) !== undefined){ + for(i = 0, len = lis.length; i < len; i++){ + if((li = lis[i]) && li[TYPE] == eventName && li[FN] == fn){ + unloadListeners[el.id].splice(i, 1); + } + } + } + return; + } + doRemove(el, eventName, fn, false); + } + }, + + getTarget : function(ev) { + ev = ev.browserEvent || ev; + return this.resolveTextNode(ev.target || ev.srcElement); + }, + + resolveTextNode : Ext.isGecko ? function(node){ + if(!node){ + return; + } + // work around firefox bug, https://bugzilla.mozilla.org/show_bug.cgi?id=101197 + var s = HTMLElement.prototype.toString.call(node); + if(s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]'){ + return; + } + return node.nodeType == 3 ? node.parentNode : node; + } : function(node){ + return node && node.nodeType == 3 ? node.parentNode : node; + }, + + getRelatedTarget : function(ev) { + ev = ev.browserEvent || ev; + return this.resolveTextNode(ev.relatedTarget || + (/(mouseout|mouseleave)/.test(ev.type) ? ev.toElement : + /(mouseover|mouseenter)/.test(ev.type) ? ev.fromElement : null)); + }, + + getPageX : function(ev) { + return getPageCoord(ev, "X"); + }, + + getPageY : function(ev) { + return getPageCoord(ev, "Y"); + }, + + + getXY : function(ev) { + return [this.getPageX(ev), this.getPageY(ev)]; + }, + + stopEvent : function(ev) { + this.stopPropagation(ev); + this.preventDefault(ev); + }, + + stopPropagation : function(ev) { + ev = ev.browserEvent || ev; + if (ev.stopPropagation) { + ev.stopPropagation(); + } else { + ev.cancelBubble = true; + } + }, + + preventDefault : function(ev) { + ev = ev.browserEvent || ev; + if (ev.preventDefault) { + ev.preventDefault(); + } else { + if (ev.keyCode) { + ev.keyCode = 0; + } + ev.returnValue = false; + } + }, + + getEvent : function(e) { + e = e || win.event; + if (!e) { + var c = this.getEvent.caller; + while (c) { + e = c.arguments[0]; + if (e && Event == e.constructor) { + break; + } + c = c.caller; + } + } + return e; + }, + + getCharCode : function(ev) { + ev = ev.browserEvent || ev; + return ev.charCode || ev.keyCode || 0; + }, + + //clearCache: function() {}, + // deprecated, call from EventManager + getListeners : function(el, eventName) { + Ext.EventManager.getListeners(el, eventName); + }, + + // deprecated, call from EventManager + purgeElement : function(el, recurse, eventName) { + Ext.EventManager.purgeElement(el, recurse, eventName); + }, + + _load : function(e) { + loadComplete = true; + + if (Ext.isIE && e !== true) { + // IE8 complains that _load is null or not an object + // so lets remove self via arguments.callee + doRemove(win, "load", arguments.callee); + } + }, + + _unload : function(e) { + var EU = Ext.lib.Event, + i, v, ul, id, len, scope; + + for (id in unloadListeners) { + ul = unloadListeners[id]; + for (i = 0, len = ul.length; i < len; i++) { + v = ul[i]; + if (v) { + try{ + scope = v[ADJ_SCOPE] ? (v[ADJ_SCOPE] === true ? v[OBJ] : v[ADJ_SCOPE]) : win; + v[FN].call(scope, EU.getEvent(e), v[OBJ]); + }catch(ex){} + } + } + }; + + Ext.EventManager._unload(); + + doRemove(win, UNLOAD, EU._unload); + } + }; + + // Initialize stuff. + pub.on = pub.addListener; + pub.un = pub.removeListener; + if (doc && doc.body) { + pub._load(true); + } else { + doAdd(win, "load", pub._load); + } + doAdd(win, UNLOAD, pub._unload); + _tryPreloadAttach(); + + return pub; +}(); +/* +* Portions of this file are based on pieces of Yahoo User Interface Library +* Copyright (c) 2007, Yahoo! Inc. All rights reserved. +* YUI licensed under the BSD License: +* http://developer.yahoo.net/yui/license.txt +*/ +Ext.lib.Ajax = function() { + var activeX = ['Msxml2.XMLHTTP.6.0', + 'Msxml2.XMLHTTP.3.0', + 'Msxml2.XMLHTTP'], + CONTENTTYPE = 'Content-Type'; + + // private + function setHeader(o) { + var conn = o.conn, + prop, + headers = {}; + + function setTheHeaders(conn, headers){ + for (prop in headers) { + if (headers.hasOwnProperty(prop)) { + conn.setRequestHeader(prop, headers[prop]); + } + } + } + + Ext.apply(headers, pub.headers, pub.defaultHeaders); + setTheHeaders(conn, headers); + delete pub.headers; + } + + // private + function createExceptionObject(tId, callbackArg, isAbort, isTimeout) { + return { + tId : tId, + status : isAbort ? -1 : 0, + statusText : isAbort ? 'transaction aborted' : 'communication failure', + isAbort: isAbort, + isTimeout: isTimeout, + argument : callbackArg + }; + } + + // private + function initHeader(label, value) { + (pub.headers = pub.headers || {})[label] = value; + } + + // private + function createResponseObject(o, callbackArg) { + var headerObj = {}, + headerStr, + conn = o.conn, + t, + s, + // see: https://prototype.lighthouseapp.com/projects/8886/tickets/129-ie-mangles-http-response-status-code-204-to-1223 + isBrokenStatus = conn.status == 1223; + + try { + headerStr = o.conn.getAllResponseHeaders(); + Ext.each(headerStr.replace(/\r\n/g, '\n').split('\n'), function(v){ + t = v.indexOf(':'); + if(t >= 0){ + s = v.substr(0, t).toLowerCase(); + if(v.charAt(t + 1) == ' '){ + ++t; + } + headerObj[s] = v.substr(t + 1); + } + }); + } catch(e) {} + + return { + tId : o.tId, + // Normalize the status and statusText when IE returns 1223, see the above link. + status : isBrokenStatus ? 204 : conn.status, + statusText : isBrokenStatus ? 'No Content' : conn.statusText, + getResponseHeader : function(header){return headerObj[header.toLowerCase()];}, + getAllResponseHeaders : function(){return headerStr;}, + responseText : conn.responseText, + responseXML : conn.responseXML, + argument : callbackArg + }; + } + + // private + function releaseObject(o) { + if (o.tId) { + pub.conn[o.tId] = null; + } + o.conn = null; + o = null; + } + + // private + function handleTransactionResponse(o, callback, isAbort, isTimeout) { + if (!callback) { + releaseObject(o); + return; + } + + var httpStatus, responseObject; + + try { + if (o.conn.status !== undefined && o.conn.status != 0) { + httpStatus = o.conn.status; + } + else { + httpStatus = 13030; + } + } + catch(e) { + httpStatus = 13030; + } + + if ((httpStatus >= 200 && httpStatus < 300) || (Ext.isIE && httpStatus == 1223)) { + responseObject = createResponseObject(o, callback.argument); + if (callback.success) { + if (!callback.scope) { + callback.success(responseObject); + } + else { + callback.success.apply(callback.scope, [responseObject]); + } + } + } + else { + switch (httpStatus) { + case 12002: + case 12029: + case 12030: + case 12031: + case 12152: + case 13030: + responseObject = createExceptionObject(o.tId, callback.argument, (isAbort ? isAbort : false), isTimeout); + if (callback.failure) { + if (!callback.scope) { + callback.failure(responseObject); + } + else { + callback.failure.apply(callback.scope, [responseObject]); + } + } + break; + default: + responseObject = createResponseObject(o, callback.argument); + if (callback.failure) { + if (!callback.scope) { + callback.failure(responseObject); + } + else { + callback.failure.apply(callback.scope, [responseObject]); + } + } + } + } + + releaseObject(o); + responseObject = null; + } + + function checkResponse(o, callback, conn, tId, poll, cbTimeout){ + if (conn && conn.readyState == 4) { + clearInterval(poll[tId]); + poll[tId] = null; + + if (cbTimeout) { + clearTimeout(pub.timeout[tId]); + pub.timeout[tId] = null; + } + handleTransactionResponse(o, callback); + } + } + + function checkTimeout(o, callback){ + pub.abort(o, callback, true); + } + + + // private + function handleReadyState(o, callback){ + callback = callback || {}; + var conn = o.conn, + tId = o.tId, + poll = pub.poll, + cbTimeout = callback.timeout || null; + + if (cbTimeout) { + pub.conn[tId] = conn; + pub.timeout[tId] = setTimeout(checkTimeout.createCallback(o, callback), cbTimeout); + } + poll[tId] = setInterval(checkResponse.createCallback(o, callback, conn, tId, poll, cbTimeout), pub.pollInterval); + } + + // private + function asyncRequest(method, uri, callback, postData) { + var o = getConnectionObject() || null; + + if (o) { + o.conn.open(method, uri, true); + + if (pub.useDefaultXhrHeader) { + initHeader('X-Requested-With', pub.defaultXhrHeader); + } + + if(postData && pub.useDefaultHeader && (!pub.headers || !pub.headers[CONTENTTYPE])){ + initHeader(CONTENTTYPE, pub.defaultPostHeader); + } + + if (pub.defaultHeaders || pub.headers) { + setHeader(o); + } + + handleReadyState(o, callback); + o.conn.send(postData || null); + } + return o; + } + + // private + function getConnectionObject() { + var o; + + try { + if (o = createXhrObject(pub.transactionId)) { + pub.transactionId++; + } + } catch(e) { + } finally { + return o; + } + } + + // private + function createXhrObject(transactionId) { + var http; + + try { + http = new XMLHttpRequest(); + } catch(e) { + for (var i = Ext.isIE6 ? 1 : 0; i < activeX.length; ++i) { + try { + http = new ActiveXObject(activeX[i]); + break; + } catch(e) {} + } + } finally { + return {conn : http, tId : transactionId}; + } + } + + var pub = { + request : function(method, uri, cb, data, options) { + if(options){ + var me = this, + xmlData = options.xmlData, + jsonData = options.jsonData, + hs; + + Ext.applyIf(me, options); + + if(xmlData || jsonData){ + hs = me.headers; + if(!hs || !hs[CONTENTTYPE]){ + initHeader(CONTENTTYPE, xmlData ? 'text/xml' : 'application/json'); + } + data = xmlData || (!Ext.isPrimitive(jsonData) ? Ext.encode(jsonData) : jsonData); + } + } + return asyncRequest(method || options.method || "POST", uri, cb, data); + }, + + serializeForm : function(form) { + var fElements = form.elements || (document.forms[form] || Ext.getDom(form)).elements, + hasSubmit = false, + encoder = encodeURIComponent, + name, + data = '', + type, + hasValue; + + Ext.each(fElements, function(element){ + name = element.name; + type = element.type; + + if (!element.disabled && name) { + if (/select-(one|multiple)/i.test(type)) { + Ext.each(element.options, function(opt){ + if (opt.selected) { + hasValue = opt.hasAttribute ? opt.hasAttribute('value') : opt.getAttributeNode('value').specified; + data += String.format("{0}={1}&", encoder(name), encoder(hasValue ? opt.value : opt.text)); + } + }); + } else if (!(/file|undefined|reset|button/i.test(type))) { + if (!(/radio|checkbox/i.test(type) && !element.checked) && !(type == 'submit' && hasSubmit)) { + data += encoder(name) + '=' + encoder(element.value) + '&'; + hasSubmit = /submit/i.test(type); + } + } + } + }); + return data.substr(0, data.length - 1); + }, + + useDefaultHeader : true, + defaultPostHeader : 'application/x-www-form-urlencoded; charset=UTF-8', + useDefaultXhrHeader : true, + defaultXhrHeader : 'XMLHttpRequest', + poll : {}, + timeout : {}, + conn: {}, + pollInterval : 50, + transactionId : 0, + +// This is never called - Is it worth exposing this? +// setProgId : function(id) { +// activeX.unshift(id); +// }, + +// This is never called - Is it worth exposing this? +// setDefaultPostHeader : function(b) { +// this.useDefaultHeader = b; +// }, + +// This is never called - Is it worth exposing this? +// setDefaultXhrHeader : function(b) { +// this.useDefaultXhrHeader = b; +// }, + +// This is never called - Is it worth exposing this? +// setPollingInterval : function(i) { +// if (typeof i == 'number' && isFinite(i)) { +// this.pollInterval = i; +// } +// }, + +// This is never called - Is it worth exposing this? +// resetDefaultHeaders : function() { +// this.defaultHeaders = null; +// }, + + abort : function(o, callback, isTimeout) { + var me = this, + tId = o.tId, + isAbort = false; + + if (me.isCallInProgress(o)) { + o.conn.abort(); + clearInterval(me.poll[tId]); + me.poll[tId] = null; + clearTimeout(pub.timeout[tId]); + me.timeout[tId] = null; + + handleTransactionResponse(o, callback, (isAbort = true), isTimeout); + } + return isAbort; + }, + + isCallInProgress : function(o) { + // if there is a connection and readyState is not 0 or 4 + return o.conn && !{0:true,4:true}[o.conn.readyState]; + } + }; + return pub; +}();(function(){ + var EXTLIB = Ext.lib, + noNegatives = /width|height|opacity|padding/i, + offsetAttribute = /^((width|height)|(top|left))$/, + defaultUnit = /width|height|top$|bottom$|left$|right$/i, + offsetUnit = /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i, + isset = function(v){ + return typeof v !== 'undefined'; + }, + now = function(){ + return new Date(); + }; + + EXTLIB.Anim = { + motion : function(el, args, duration, easing, cb, scope) { + return this.run(el, args, duration, easing, cb, scope, Ext.lib.Motion); + }, + + run : function(el, args, duration, easing, cb, scope, type) { + type = type || Ext.lib.AnimBase; + if (typeof easing == "string") { + easing = Ext.lib.Easing[easing]; + } + var anim = new type(el, args, duration, easing); + anim.animateX(function() { + if(Ext.isFunction(cb)){ + cb.call(scope); + } + }); + return anim; + } + }; + + EXTLIB.AnimBase = function(el, attributes, duration, method) { + if (el) { + this.init(el, attributes, duration, method); + } + }; + + EXTLIB.AnimBase.prototype = { + doMethod: function(attr, start, end) { + var me = this; + return me.method(me.curFrame, start, end - start, me.totalFrames); + }, + + + setAttr: function(attr, val, unit) { + if (noNegatives.test(attr) && val < 0) { + val = 0; + } + Ext.fly(this.el, '_anim').setStyle(attr, val + unit); + }, + + + getAttr: function(attr) { + var el = Ext.fly(this.el), + val = el.getStyle(attr), + a = offsetAttribute.exec(attr) || []; + + if (val !== 'auto' && !offsetUnit.test(val)) { + return parseFloat(val); + } + + return (!!(a[2]) || (el.getStyle('position') == 'absolute' && !!(a[3]))) ? el.dom['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)] : 0; + }, + + + getDefaultUnit: function(attr) { + return defaultUnit.test(attr) ? 'px' : ''; + }, + + animateX : function(callback, scope) { + var me = this, + f = function() { + me.onComplete.removeListener(f); + if (Ext.isFunction(callback)) { + callback.call(scope || me, me); + } + }; + me.onComplete.addListener(f, me); + me.animate(); + }, + + + setRunAttr: function(attr) { + var me = this, + a = this.attributes[attr], + to = a.to, + by = a.by, + from = a.from, + unit = a.unit, + ra = (this.runAttrs[attr] = {}), + end; + + if (!isset(to) && !isset(by)){ + return false; + } + + var start = isset(from) ? from : me.getAttr(attr); + if (isset(to)) { + end = to; + }else if(isset(by)) { + if (Ext.isArray(start)){ + end = []; + for(var i=0,len=start.length; iObject hash of "pseudo class" filter functions which are used when filtering selections. Each function is passed + * two parameters:
A filter function returns an Array of DOM elements which conform to the pseudo class.
+ *In addition to the provided pseudo classes listed above such as first-child
and nth-child
,
+ * developers may add additional, custom psuedo class filters to select elements according to application-specific requirements.
For example, to filter <a>
elements to only return links to external resources:
+Ext.DomQuery.pseudos.external = function(c, v){
+ var r = [], ri = -1;
+ for(var i = 0, ci; ci = c[i]; i++){
+// Include in result set only if it's a link to an external resource
+ if(ci.hostname != location.hostname){
+ r[++ri] = ci;
}
}
-};
-
-Ext.util.Observable.prototype.on = Ext.util.Observable.prototype.addListener;
-
-Ext.util.Observable.prototype.un = Ext.util.Observable.prototype.removeListener;
-
-
-Ext.util.Observable.capture = function(o, fn, scope){
- o.fireEvent = o.fireEvent.createInterceptor(fn, scope);
-};
-
-
-Ext.util.Observable.releaseCapture = function(o){
- o.fireEvent = Ext.util.Observable.prototype.fireEvent;
-};
-
-(function(){
-
- var createBuffered = function(h, o, scope){
- var task = new Ext.util.DelayedTask();
- return function(){
- task.delay(o.buffer, h, scope, Array.prototype.slice.call(arguments, 0));
- };
- };
-
- var createSingle = function(h, e, fn, scope){
- return function(){
- e.removeListener(fn, scope);
- return h.apply(scope, arguments);
- };
- };
-
- var createDelayed = function(h, o, scope){
- return function(){
- var args = Array.prototype.slice.call(arguments, 0);
- setTimeout(function(){
- h.apply(scope, args);
- }, o.delay || 10);
- };
- };
-
- Ext.util.Event = function(obj, name){
- this.name = name;
- this.obj = obj;
- this.listeners = [];
- };
-
- Ext.util.Event.prototype = {
- addListener : function(fn, scope, options){
- scope = scope || this.obj;
- if(!this.isListening(fn, scope)){
- var l = this.createListener(fn, scope, options);
- if(!this.firing){
- this.listeners.push(l);
- }else{ this.listeners = this.listeners.slice(0);
- this.listeners.push(l);
- }
- }
- },
-
- createListener : function(fn, scope, o){
- o = o || {};
- scope = scope || this.obj;
- var l = {fn: fn, scope: scope, options: o};
- var h = fn;
- if(o.delay){
- h = createDelayed(h, o, scope);
- }
- if(o.single){
- h = createSingle(h, this, fn, scope);
- }
- if(o.buffer){
- h = createBuffered(h, o, scope);
- }
- l.fireFn = h;
- return l;
- },
-
- findListener : function(fn, scope){
- scope = scope || this.obj;
- var ls = this.listeners;
- for(var i = 0, len = ls.length; i < len; i++){
- var l = ls[i];
- if(l.fn == fn && l.scope == scope){
- return i;
- }
- }
- return -1;
- },
-
- isListening : function(fn, scope){
- return this.findListener(fn, scope) != -1;
- },
-
- removeListener : function(fn, scope){
- var index;
- if((index = this.findListener(fn, scope)) != -1){
- if(!this.firing){
- this.listeners.splice(index, 1);
- }else{
- this.listeners = this.listeners.slice(0);
- this.listeners.splice(index, 1);
- }
- return true;
- }
- return false;
- },
-
- clearListeners : function(){
- this.listeners = [];
- },
-
- fire : function(){
- var ls = this.listeners, scope, len = ls.length;
- if(len > 0){
- this.firing = true;
- var args = Array.prototype.slice.call(arguments, 0);
- for(var i = 0; i < len; i++){
- var l = ls[i];
- if(l.fireFn.apply(l.scope||this.obj||window, arguments) === false){
- this.firing = false;
- return false;
+ return r;
+};
+ * Then external links could be gathered with the following statement:
+var externalLinks = Ext.select("a:external");
+
+ */
+ pseudos : {
+ "first-child" : function(c){
+ var r = [], ri = -1, n;
+ for(var i = 0, ci; ci = n = c[i]; i++){
+ while((n = n.previousSibling) && n.nodeType != 1);
+ if(!n){
+ r[++ri] = ci;
}
}
- this.firing = false;
- }
- return true;
- }
- };
-})();
+ return r;
+ },
-Ext.EventManager = function(){
- var docReadyEvent, docReadyProcId, docReadyState = false;
- var resizeEvent, resizeTask, textEvent, textSize;
- var E = Ext.lib.Event;
- var D = Ext.lib.Dom;
- var xname = 'Ex' + 't';
-
- var elHash = {};
-
- var addListener = function(el, ename, fn, wrap, scope){
- var id = Ext.id(el);
- if(!elHash[id]){
- elHash[id] = {};
- }
- var es = elHash[id];
- if(!es[ename]){
- es[ename] = [];
- }
- var ls = es[ename];
- ls.push({
- id: id,
- ename: ename,
- fn: fn,
- wrap: wrap,
- scope: scope
- });
-
- E.on(el, ename, wrap);
-
- if(ename == "mousewheel" && el.addEventListener){ el.addEventListener("DOMMouseScroll", wrap, false);
- E.on(window, 'unload', function(){
- el.removeEventListener("DOMMouseScroll", wrap, false);
- });
- }
- if(ename == "mousedown" && el == document){ Ext.EventManager.stoppedMouseDownEvent.addListener(wrap);
- }
- }
-
- var removeListener = function(el, ename, fn, scope){
- el = Ext.getDom(el);
- var id = Ext.id(el), es = elHash[id], wrap;
- if(es){
- var ls = es[ename], l;
- if(ls){
- for(var i = 0, len = ls.length; i < len; i++){
- l = ls[i];
- if(l.fn == fn && (!scope || l.scope == scope)){
- wrap = l.wrap;
- E.un(el, ename, wrap);
- ls.splice(i, 1);
- break;
+ "last-child" : function(c){
+ var r = [], ri = -1, n;
+ for(var i = 0, ci; ci = n = c[i]; i++){
+ while((n = n.nextSibling) && n.nodeType != 1);
+ if(!n){
+ r[++ri] = ci;
}
}
- }
- }
- if(ename == "mousewheel" && el.addEventListener && wrap){
- el.removeEventListener("DOMMouseScroll", wrap, false);
- }
- if(ename == "mousedown" && el == document && wrap){ Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
- }
- }
+ return r;
+ },
- var removeAll = function(el){
- el = Ext.getDom(el);
- var id = Ext.id(el), es = elHash[id], ls;
- if(es){
- for(var ename in es){
- if(es.hasOwnProperty(ename)){
- ls = es[ename];
- for(var i = 0, len = ls.length; i < len; i++){
- E.un(el, ename, ls[i].wrap);
- ls[i] = null;
+ "nth-child" : function(c, a) {
+ var r = [], ri = -1,
+ m = nthRe.exec(a == "even" && "2n" || a == "odd" && "2n+1" || !nthRe2.test(a) && "n+" + a || a),
+ f = (m[1] || 1) - 0, l = m[2] - 0;
+ for(var i = 0, n; n = c[i]; i++){
+ var pn = n.parentNode;
+ if (batch != pn._batch) {
+ var j = 0;
+ for(var cn = pn.firstChild; cn; cn = cn.nextSibling){
+ if(cn.nodeType == 1){
+ cn.nodeIndex = ++j;
+ }
+ }
+ pn._batch = batch;
+ }
+ if (f == 1) {
+ if (l == 0 || n.nodeIndex == l){
+ r[++ri] = n;
+ }
+ } else if ((n.nodeIndex + l) % f == 0){
+ r[++ri] = n;
}
}
- es[ename] = null;
- }
- delete elHash[id];
- }
- }
- var fireDocReady = function(){
- if(!docReadyState){
- docReadyState = Ext.isReady = true;
- if(Ext.isGecko || Ext.isOpera) {
- document.removeEventListener("DOMContentLoaded", fireDocReady, false);
- }
- }
- if(docReadyProcId){
- clearInterval(docReadyProcId);
- docReadyProcId = null;
- }
- if(docReadyEvent){
- docReadyEvent.fire();
- docReadyEvent.clearListeners();
- }
- };
+ return r;
+ },
- var initDocReady = function(){
- docReadyEvent = new Ext.util.Event();
-
- if(Ext.isReady){
- return;
- }
-
- E.on(window, 'load', fireDocReady);
-
- if(Ext.isGecko || Ext.isOpera) {
- document.addEventListener('DOMContentLoaded', fireDocReady, false);
- }
- else if(Ext.isIE){
- docReadyProcId = setInterval(function(){
- try{
- Ext.isReady || (document.documentElement.doScroll('left'));
- }catch(e){
- return;
- }
- fireDocReady(); }, 5);
-
- document.onreadystatechange = function(){
- if(document.readyState == 'complete'){
- document.onreadystatechange = null;
- fireDocReady();
- }
- };
- }
- else if(Ext.isSafari){
- docReadyProcId = setInterval(function(){
- var rs = document.readyState;
- if(rs == 'complete') {
- fireDocReady();
- }
- }, 10);
- }
- };
-
- var createBuffered = function(h, o){
- var task = new Ext.util.DelayedTask(h);
- return function(e){
- e = new Ext.EventObjectImpl(e);
- task.delay(o.buffer, h, null, [e]);
- };
- };
-
- var createSingle = function(h, el, ename, fn, scope){
- return function(e){
- Ext.EventManager.removeListener(el, ename, fn, scope);
- h(e);
- };
- };
-
- var createDelayed = function(h, o){
- return function(e){
- e = new Ext.EventObjectImpl(e);
- setTimeout(function(){
- h(e);
- }, o.delay || 10);
- };
- };
-
- var listen = function(element, ename, opt, fn, scope){
- var o = (!opt || typeof opt == "boolean") ? {} : opt;
- fn = fn || o.fn; scope = scope || o.scope;
- var el = Ext.getDom(element);
- if(!el){
- throw "Error listening for \"" + ename + '\". Element "' + element + '" doesn\'t exist.';
- }
- var h = function(e){
- if(!window[xname]){
- return;
- }
- e = Ext.EventObject.setEvent(e);
- var t;
- if(o.delegate){
- t = e.getTarget(o.delegate, el);
- if(!t){
- return;
- }
- }else{
- t = e.target;
- }
- if(o.stopEvent === true){
- e.stopEvent();
- }
- if(o.preventDefault === true){
- e.preventDefault();
- }
- if(o.stopPropagation === true){
- e.stopPropagation();
- }
-
- if(o.normalized === false){
- e = e.browserEvent;
- }
-
- fn.call(scope || el, e, t, o);
- };
- if(o.delay){
- h = createDelayed(h, o);
- }
- if(o.single){
- h = createSingle(h, el, ename, fn, scope);
- }
- if(o.buffer){
- h = createBuffered(h, o);
- }
-
- addListener(el, ename, fn, h, scope);
- return h;
- };
-
- var propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/;
- var pub = {
-
-
- addListener : function(element, eventName, fn, scope, options){
- if(typeof eventName == "object"){
- var o = eventName;
- for(var e in o){
- if(propRe.test(e)){
- continue;
- }
- if(typeof o[e] == "function"){
- listen(element, e, o, o[e], o.scope);
- }else{
- listen(element, e, o[e]);
+ "only-child" : function(c){
+ var r = [], ri = -1;;
+ for(var i = 0, ci; ci = c[i]; i++){
+ if(!prev(ci) && !next(ci)){
+ r[++ri] = ci;
}
}
- return;
- }
- return listen(element, eventName, options, fn, scope);
- },
+ return r;
+ },
-
- removeListener : function(element, eventName, fn, scope){
- return removeListener(element, eventName, fn, scope);
- },
-
-
- removeAll : function(element){
- return removeAll(element);
- },
-
-
- onDocumentReady : function(fn, scope, options){
- if(!docReadyEvent){
- initDocReady();
- }
- if(docReadyState || Ext.isReady){ options || (options = {});
- fn.defer(options.delay||0, scope);
- }else{
- docReadyEvent.addListener(fn, scope, options);
- }
- },
-
-
- onWindowResize : function(fn, scope, options){
- if(!resizeEvent){
- resizeEvent = new Ext.util.Event();
- resizeTask = new Ext.util.DelayedTask(function(){
- resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
- });
- E.on(window, "resize", this.fireWindowResize, this);
- }
- resizeEvent.addListener(fn, scope, options);
- },
-
- fireWindowResize : function(){
- if(resizeEvent){
- if((Ext.isIE||Ext.isAir) && resizeTask){
- resizeTask.delay(50);
- }else{
- resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
- }
- }
- },
-
-
- onTextResize : function(fn, scope, options){
- if(!textEvent){
- textEvent = new Ext.util.Event();
- var textEl = new Ext.Element(document.createElement('div'));
- textEl.dom.className = 'x-text-resize';
- textEl.dom.innerHTML = 'X';
- textEl.appendTo(document.body);
- textSize = textEl.dom.offsetHeight;
- setInterval(function(){
- if(textEl.dom.offsetHeight != textSize){
- textEvent.fire(textSize, textSize = textEl.dom.offsetHeight);
+ "empty" : function(c){
+ var r = [], ri = -1;
+ for(var i = 0, ci; ci = c[i]; i++){
+ var cns = ci.childNodes, j = 0, cn, empty = true;
+ while(cn = cns[j]){
+ ++j;
+ if(cn.nodeType == 1 || cn.nodeType == 3){
+ empty = false;
+ break;
+ }
}
- }, this.textResizeInterval);
- }
- textEvent.addListener(fn, scope, options);
- },
+ if(empty){
+ r[++ri] = ci;
+ }
+ }
+ return r;
+ },
-
- removeResizeListener : function(fn, scope){
- if(resizeEvent){
- resizeEvent.removeListener(fn, scope);
- }
- },
+ "contains" : function(c, v){
+ var r = [], ri = -1;
+ for(var i = 0, ci; ci = c[i]; i++){
+ if((ci.textContent||ci.innerText||'').indexOf(v) != -1){
+ r[++ri] = ci;
+ }
+ }
+ return r;
+ },
- fireResize : function(){
- if(resizeEvent){
- resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
+ "nodeValue" : function(c, v){
+ var r = [], ri = -1;
+ for(var i = 0, ci; ci = c[i]; i++){
+ if(ci.firstChild && ci.firstChild.nodeValue == v){
+ r[++ri] = ci;
+ }
+ }
+ return r;
+ },
+
+ "checked" : function(c){
+ var r = [], ri = -1;
+ for(var i = 0, ci; ci = c[i]; i++){
+ if(ci.checked == true){
+ r[++ri] = ci;
+ }
+ }
+ return r;
+ },
+
+ "not" : function(c, ss){
+ return Ext.DomQuery.filter(c, ss, true);
+ },
+
+ "any" : function(c, selectors){
+ var ss = selectors.split('|'),
+ r = [], ri = -1, s;
+ for(var i = 0, ci; ci = c[i]; i++){
+ for(var j = 0; s = ss[j]; j++){
+ if(Ext.DomQuery.is(ci, s)){
+ r[++ri] = ci;
+ break;
+ }
+ }
+ }
+ return r;
+ },
+
+ "odd" : function(c){
+ return this["nth-child"](c, "odd");
+ },
+
+ "even" : function(c){
+ return this["nth-child"](c, "even");
+ },
+
+ "nth" : function(c, a){
+ return c[a-1] || [];
+ },
+
+ "first" : function(c){
+ return c[0] || [];
+ },
+
+ "last" : function(c){
+ return c[c.length-1] || [];
+ },
+
+ "has" : function(c, ss){
+ var s = Ext.DomQuery.select,
+ r = [], ri = -1;
+ for(var i = 0, ci; ci = c[i]; i++){
+ if(s(ss, ci).length > 0){
+ r[++ri] = ci;
+ }
+ }
+ return r;
+ },
+
+ "next" : function(c, ss){
+ var is = Ext.DomQuery.is,
+ r = [], ri = -1;
+ for(var i = 0, ci; ci = c[i]; i++){
+ var n = next(ci);
+ if(n && is(n, ss)){
+ r[++ri] = ci;
+ }
+ }
+ return r;
+ },
+
+ "prev" : function(c, ss){
+ var is = Ext.DomQuery.is,
+ r = [], ri = -1;
+ for(var i = 0, ci; ci = c[i]; i++){
+ var n = prev(ci);
+ if(n && is(n, ss)){
+ r[++ri] = ci;
+ }
+ }
+ return r;
}
- },
-
- ieDeferSrc : false,
-
- textResizeInterval : 50
+ }
};
-
- pub.on = pub.addListener;
-
- pub.un = pub.removeListener;
-
- pub.stoppedMouseDownEvent = new Ext.util.Event();
- return pub;
}();
-Ext.onReady = Ext.EventManager.onDocumentReady;
-
-
-(function(){
- var initExtCss = function(){
- var bd = document.body || document.getElementsByTagName('body')[0];
- if(!bd){ return false; }
- var cls = [' ',
- Ext.isIE ? "ext-ie " + (Ext.isIE6 ? 'ext-ie6' : 'ext-ie7')
- : Ext.isGecko ? "ext-gecko " + (Ext.isGecko2 ? 'ext-gecko2' : 'ext-gecko3')
- : Ext.isOpera ? "ext-opera"
- : Ext.isSafari ? "ext-safari" : ""];
-
- if(Ext.isMac){
- cls.push("ext-mac");
- }
- if(Ext.isLinux){
- cls.push("ext-linux");
- }
- if(Ext.isBorderBox){
- cls.push('ext-border-box');
- }
- if(Ext.isStrict){ var p = bd.parentNode;
- if(p){
- p.className += ' ext-strict';
- }
- }
- bd.className += cls.join(' ');
- return true;
- }
-
- if(!initExtCss()){
- Ext.onReady(initExtCss);
- }
-})();
-
-
-Ext.EventObject = function(){
-
- var E = Ext.lib.Event;
-
- var safariKeys = {
- 3 : 13, 63234 : 37, 63235 : 39, 63232 : 38, 63233 : 40, 63276 : 33, 63277 : 34, 63272 : 46, 63273 : 36, 63275 : 35 };
-
- var btnMap = Ext.isIE ? {1:0,4:1,2:2} :
- (Ext.isSafari ? {1:0,2:1,3:2} : {0:0,1:1,2:2});
-
- Ext.EventObjectImpl = function(e){
- if(e){
- this.setEvent(e.browserEvent || e);
- }
+/**
+ * Selects an array of DOM nodes by CSS/XPath selector. Shorthand of {@link Ext.DomQuery#select}
+ * @param {String} path The selector/xpath query
+ * @param {Node} root (optional) The start of the query (defaults to document).
+ * @return {Array}
+ * @member Ext
+ * @method query
+ */
+Ext.query = Ext.DomQuery.select;
+/**
+ * @class Ext.util.DelayedTask
+ * The DelayedTask class provides a convenient way to "buffer" the execution of a method, + * performing setTimeout where a new timeout cancels the old timeout. When called, the + * task will wait the specified time period before executing. If durng that time period, + * the task is called again, the original call will be cancelled. This continues so that + * the function is only called a single time for each iteration.
+ *This method is especially useful for things like detecting whether a user has finished + * typing in a text field. An example would be performing validation on a keypress. You can + * use this class to buffer the keypress events for a certain number of milliseconds, and + * perform only if they stop for that amount of time. Usage:
+var task = new Ext.util.DelayedTask(function(){
+ alert(Ext.getDom('myInputField').value.length);
+});
+// Wait 500ms before calling our function. If the user presses another key
+// during that 500ms, it will be cancelled and we'll wait another 500ms.
+Ext.get('myInputField').on('keypress', function(){
+ task.{@link #delay}(500);
+});
+ *
+ * Note that we are using a DelayedTask here to illustrate a point. The configuration + * option buffer for {@link Ext.util.Observable#addListener addListener/on} will + * also setup a delayed task for you to buffer events.
+ * @constructor The parameters to this constructor serve as defaults and are not required. + * @param {Function} fn (optional) The default function to call. + * @param {Object} scope The default scope (Thethis
reference) in which the
+ * function is called. If not specified, this
will refer to the browser window.
+ * @param {Array} args (optional) The default Array of arguments.
+ */
+Ext.util.DelayedTask = function(fn, scope, args){
+ var me = this,
+ id,
+ call = function(){
+ clearInterval(id);
+ id = null;
+ fn.apply(scope, args || []);
+ };
+
+ /**
+ * Cancels any pending timeout and queues a new one
+ * @param {Number} delay The milliseconds to delay
+ * @param {Function} newFn (optional) Overrides function passed to constructor
+ * @param {Object} newScope (optional) Overrides scope passed to constructor. Remember that if no scope
+ * is specified, this
will refer to the browser window.
+ * @param {Array} newArgs (optional) Overrides args passed to constructor
+ */
+ me.delay = function(delay, newFn, newScope, newArgs){
+ me.cancel();
+ fn = newFn || fn;
+ scope = newScope || scope;
+ args = newArgs || args;
+ id = setInterval(call, delay);
};
- Ext.EventObjectImpl.prototype = {
-
- browserEvent : null,
-
- button : -1,
-
- shiftKey : false,
-
- ctrlKey : false,
-
- altKey : false,
-
-
- BACKSPACE: 8,
-
- TAB: 9,
-
- NUM_CENTER: 12,
-
- ENTER: 13,
-
- RETURN: 13,
-
- SHIFT: 16,
-
- CTRL: 17,
- CONTROL : 17,
- ALT: 18,
-
- PAUSE: 19,
-
- CAPS_LOCK: 20,
-
- ESC: 27,
-
- SPACE: 32,
-
- PAGE_UP: 33,
- PAGEUP : 33,
- PAGE_DOWN: 34,
- PAGEDOWN : 34,
- END: 35,
-
- HOME: 36,
-
- LEFT: 37,
-
- UP: 38,
-
- RIGHT: 39,
-
- DOWN: 40,
-
- PRINT_SCREEN: 44,
-
- INSERT: 45,
-
- DELETE: 46,
-
- ZERO: 48,
-
- ONE: 49,
-
- TWO: 50,
-
- THREE: 51,
-
- FOUR: 52,
-
- FIVE: 53,
-
- SIX: 54,
-
- SEVEN: 55,
-
- EIGHT: 56,
-
- NINE: 57,
-
- A: 65,
-
- B: 66,
-
- C: 67,
-
- D: 68,
-
- E: 69,
-
- F: 70,
-
- G: 71,
-
- H: 72,
-
- I: 73,
-
- J: 74,
-
- K: 75,
-
- L: 76,
-
- M: 77,
-
- N: 78,
-
- O: 79,
-
- P: 80,
-
- Q: 81,
-
- R: 82,
-
- S: 83,
-
- T: 84,
-
- U: 85,
-
- V: 86,
-
- W: 87,
-
- X: 88,
-
- Y: 89,
-
- Z: 90,
-
- CONTEXT_MENU: 93,
-
- NUM_ZERO: 96,
-
- NUM_ONE: 97,
-
- NUM_TWO: 98,
-
- NUM_THREE: 99,
-
- NUM_FOUR: 100,
-
- NUM_FIVE: 101,
-
- NUM_SIX: 102,
-
- NUM_SEVEN: 103,
-
- NUM_EIGHT: 104,
-
- NUM_NINE: 105,
-
- NUM_MULTIPLY: 106,
-
- NUM_PLUS: 107,
-
- NUM_MINUS: 109,
-
- NUM_PERIOD: 110,
-
- NUM_DIVISION: 111,
-
- F1: 112,
-
- F2: 113,
-
- F3: 114,
-
- F4: 115,
-
- F5: 116,
-
- F6: 117,
-
- F7: 118,
-
- F8: 119,
-
- F9: 120,
-
- F10: 121,
-
- F11: 122,
-
- F12: 123,
-
-
- setEvent : function(e){
- if(e == this || (e && e.browserEvent)){ return e;
- }
- this.browserEvent = e;
- if(e){
- this.button = e.button ? btnMap[e.button] : (e.which ? e.which-1 : -1);
- if(e.type == 'click' && this.button == -1){
- this.button = 0;
- }
- this.type = e.type;
- this.shiftKey = e.shiftKey;
- this.ctrlKey = e.ctrlKey || e.metaKey;
- this.altKey = e.altKey;
- this.keyCode = e.keyCode;
- this.charCode = e.charCode;
- this.target = E.getTarget(e);
- this.xy = E.getXY(e);
- }else{
- this.button = -1;
- this.shiftKey = false;
- this.ctrlKey = false;
- this.altKey = false;
- this.keyCode = 0;
- this.charCode = 0;
- this.target = null;
- this.xy = [0, 0];
- }
- return this;
- },
-
-
- stopEvent : function(){
- if(this.browserEvent){
- if(this.browserEvent.type == 'mousedown'){
- Ext.EventManager.stoppedMouseDownEvent.fire(this);
- }
- E.stopEvent(this.browserEvent);
- }
- },
-
-
- preventDefault : function(){
- if(this.browserEvent){
- E.preventDefault(this.browserEvent);
- }
- },
-
-
- isNavKeyPress : function(){
- var k = this.keyCode;
- k = Ext.isSafari ? (safariKeys[k] || k) : k;
- return (k >= 33 && k <= 40) || k == this.RETURN || k == this.TAB || k == this.ESC;
- },
-
- isSpecialKey : function(){
- var k = this.keyCode;
- return (this.type == 'keypress' && this.ctrlKey) || k == 9 || k == 13 || k == 40 || k == 27 ||
- (k == 16) || (k == 17) ||
- (k >= 18 && k <= 20) ||
- (k >= 33 && k <= 35) ||
- (k >= 36 && k <= 39) ||
- (k >= 44 && k <= 45);
- },
-
-
- stopPropagation : function(){
- if(this.browserEvent){
- if(this.browserEvent.type == 'mousedown'){
- Ext.EventManager.stoppedMouseDownEvent.fire(this);
- }
- E.stopPropagation(this.browserEvent);
- }
- },
-
-
- getCharCode : function(){
- return this.charCode || this.keyCode;
- },
-
-
- getKey : function(){
- var k = this.keyCode || this.charCode;
- return Ext.isSafari ? (safariKeys[k] || k) : k;
- },
-
-
- getPageX : function(){
- return this.xy[0];
- },
-
-
- getPageY : function(){
- return this.xy[1];
- },
-
-
- getTime : function(){
- if(this.browserEvent){
- return E.getTime(this.browserEvent);
- }
- return null;
- },
-
-
- getXY : function(){
- return this.xy;
- },
-
-
- getTarget : function(selector, maxDepth, returnEl){
- return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : (returnEl ? Ext.get(this.target) : this.target);
- },
-
-
- getRelatedTarget : function(){
- if(this.browserEvent){
- return E.getRelatedTarget(this.browserEvent);
- }
- return null;
- },
-
-
- getWheelDelta : function(){
- var e = this.browserEvent;
- var delta = 0;
- if(e.wheelDelta){
- delta = e.wheelDelta/120;
- }else if(e.detail){
- delta = -e.detail/3;
- }
- return delta;
- },
-
-
- hasModifier : function(){
- return ((this.ctrlKey || this.altKey) || this.shiftKey) ? true : false;
- },
-
-
- within : function(el, related){
- var t = this[related ? "getRelatedTarget" : "getTarget"]();
- return t && Ext.fly(el).contains(t);
- },
-
- getPoint : function(){
- return new Ext.lib.Point(this.xy[0], this.xy[1]);
+ /**
+ * Cancel the last queued timeout
+ */
+ me.cancel = function(){
+ if(id){
+ clearInterval(id);
+ id = null;
}
};
+};/**
+ * @class Ext.Element
+ * Encapsulates a DOM element, adding simple DOM manipulation facilities, normalizing for browser differences.
+ *All instances of this class inherit the methods of {@link Ext.Fx} making visual effects easily available to all DOM elements.
+ *Note that the events documented in this class are not Ext events, they encapsulate browser events. To + * access the underlying browser event, see {@link Ext.EventObject#browserEvent}. Some older + * browsers may not support the full range of events. Which events are supported is beyond the control of ExtJs.
+ * Usage:
+// by id
+var el = Ext.get("my-div");
- return new Ext.EventObjectImpl();
-}();
+// by DOM element reference
+var el = Ext.get(myDivElement);
+
+ * AnimationsWhen an element is manipulated, by default there is no animation.
+ *
+var el = Ext.get("my-div");
+// no animation
+el.setWidth(100);
+ *
+ * Many of the functions for manipulating an element have an optional "animate" parameter. This + * parameter can be specified as boolean (true) for default animation effects.
+ *
+// default animation
+el.setWidth(100, true);
+ *
+ *
+ * To configure the effects, an object literal with animation options to use as the Element animation + * configuration object can also be specified. Note that the supported Element animation configuration + * options are a subset of the {@link Ext.Fx} animation options specific to Fx effects. The supported + * Element animation configuration options are:
++Option Default Description +--------- -------- --------------------------------------------- +{@link Ext.Fx#duration duration} .35 The duration of the animation in seconds +{@link Ext.Fx#easing easing} easeOut The easing method +{@link Ext.Fx#callback callback} none A function to execute when the anim completes +{@link Ext.Fx#scope scope} this The scope (this) of the callback function ++ * + *
+// Element animation options object
+var opt = {
+ {@link Ext.Fx#duration duration}: 1,
+ {@link Ext.Fx#easing easing}: 'elasticIn',
+ {@link Ext.Fx#callback callback}: this.foo,
+ {@link Ext.Fx#scope scope}: this
+};
+// animation with some options set
+el.setWidth(100, opt);
+ *
+ * The Element animation object being used for the animation will be set on the options + * object as "anim", which allows you to stop or manipulate the animation. Here is an example:
+ *
+// using the "anim" property to get the Anim object
+if(opt.anim.isAnimated()){
+ opt.anim.stop();
+}
+ *
+ * Also see the {@link #animate} method for another animation technique.
+ *Composite (Collections of) Elements
+ *For working with collections of Elements, see {@link Ext.CompositeElement}
+ * @constructor Create a new Element directly. + * @param {String/HTMLElement} element + * @param {Boolean} forceNew (optional) By default the constructor checks to see if there is already an instance of this element in the cache and if there is it returns the same instance. This will skip that check (useful for extending this class). + */ (function(){ -var D = Ext.lib.Dom; -var E = Ext.lib.Event; -var A = Ext.lib.Anim; - -var propCache = {}; -var camelRe = /(-[a-z])/gi; -var camelFn = function(m, a){ return a.charAt(1).toUpperCase(); }; -var view = document.defaultView; +var DOC = document; Ext.Element = function(element, forceNew){ var dom = typeof element == "string" ? - document.getElementById(element) : element; - if(!dom){ return null; - } - var id = dom.id; - if(forceNew !== true && id && Ext.Element.cache[id]){ return Ext.Element.cache[id]; + DOC.getElementById(element) : element, + id; + + if(!dom) return null; + + id = dom.id; + + if(!forceNew && id && Ext.elCache[id]){ // element object already exists + return Ext.elCache[id].el; } - + /** + * The DOM element + * @type HTMLElement + */ this.dom = dom; - + /** + * The DOM element ID + * @type String + */ this.id = id || Ext.id(dom); }; -var El = Ext.Element; +var DH = Ext.DomHelper, + El = Ext.Element, + EC = Ext.elCache; El.prototype = { - - originalDisplay : "", + /** + * Sets the passed attributes as attributes of this element (a style attribute can be a string, object or function) + * @param {Object} o The object with the attributes + * @param {Boolean} useSet (optional) false to override the default setAttribute to use expandos. + * @return {Ext.Element} this + */ + set : function(o, useSet){ + var el = this.dom, + attr, + val, + useSet = (useSet !== false) && !!el.setAttribute; - visibilityMode : 1, - - defaultUnit : "px", - - setVisibilityMode : function(visMode){ - this.visibilityMode = visMode; - return this; - }, - - enableDisplayMode : function(display){ - this.setVisibilityMode(El.DISPLAY); - if(typeof display != "undefined") this.originalDisplay = display; - return this; - }, - - - findParent : function(simpleSelector, maxDepth, returnEl){ - var p = this.dom, b = document.body, depth = 0, dq = Ext.DomQuery, stopEl; - maxDepth = maxDepth || 50; - if(typeof maxDepth != "number"){ - stopEl = Ext.getDom(maxDepth); - maxDepth = 10; - } - while(p && p.nodeType == 1 && depth < maxDepth && p != b && p != stopEl){ - if(dq.is(p, simpleSelector)){ - return returnEl ? Ext.get(p) : p; + for (attr in o) { + if (o.hasOwnProperty(attr)) { + val = o[attr]; + if (attr == 'style') { + DH.applyStyles(el, val); + } else if (attr == 'cls') { + el.className = val; + } else if (useSet) { + el.setAttribute(attr, val); + } else { + el[attr] = val; + } } - depth++; - p = p.parentNode; } - return null; + return this; }, +// Mouse events + /** + * @event click + * Fires when a mouse click is detected within the element. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event contextmenu + * Fires when a right click is detected within the element. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event dblclick + * Fires when a mouse double click is detected within the element. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event mousedown + * Fires when a mousedown is detected within the element. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event mouseup + * Fires when a mouseup is detected within the element. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event mouseover + * Fires when a mouseover is detected within the element. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event mousemove + * Fires when a mousemove is detected with the element. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event mouseout + * Fires when a mouseout is detected with the element. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event mouseenter + * Fires when the mouse enters the element. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event mouseleave + * Fires when the mouse leaves the element. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ - - findParentNode : function(simpleSelector, maxDepth, returnEl){ - var p = Ext.fly(this.dom.parentNode, '_internal'); - return p ? p.findParent(simpleSelector, maxDepth, returnEl) : null; - }, - - - up : function(simpleSelector, maxDepth){ - return this.findParentNode(simpleSelector, maxDepth, true); - }, +// Keyboard events + /** + * @event keypress + * Fires when a keypress is detected within the element. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event keydown + * Fires when a keydown is detected within the element. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event keyup + * Fires when a keyup is detected within the element. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ +// HTML frame/object events + /** + * @event load + * Fires when the user agent finishes loading all content within the element. Only supported by window, frames, objects and images. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event unload + * Fires when the user agent removes all content from a window or frame. For elements, it fires when the target element or any of its content has been removed. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event abort + * Fires when an object/image is stopped from loading before completely loaded. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event error + * Fires when an object/image/frame cannot be loaded properly. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event resize + * Fires when a document view is resized. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event scroll + * Fires when a document view is scrolled. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ - +// Form events + /** + * @event select + * Fires when a user selects some text in a text field, including input and textarea. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event change + * Fires when a control loses the input focus and its value has been modified since gaining focus. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event submit + * Fires when a form is submitted. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event reset + * Fires when a form is reset. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event focus + * Fires when an element receives focus either via the pointing device or by tab navigation. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event blur + * Fires when an element loses focus either via the pointing device or by tabbing navigation. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + +// User Interface events + /** + * @event DOMFocusIn + * Where supported. Similar to HTML focus event, but can be applied to any focusable element. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event DOMFocusOut + * Where supported. Similar to HTML blur event, but can be applied to any focusable element. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event DOMActivate + * Where supported. Fires when an element is activated, for instance, through a mouse click or a keypress. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + +// DOM Mutation events + /** + * @event DOMSubtreeModified + * Where supported. Fires when the subtree is modified. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event DOMNodeInserted + * Where supported. Fires when a node has been added as a child of another node. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event DOMNodeRemoved + * Where supported. Fires when a descendant node of the element is removed. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event DOMNodeRemovedFromDocument + * Where supported. Fires when a node is being removed from a document. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event DOMNodeInsertedIntoDocument + * Where supported. Fires when a node is being inserted into a document. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event DOMAttrModified + * Where supported. Fires when an attribute has been modified. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + /** + * @event DOMCharacterDataModified + * Where supported. Fires when the character data has been modified. + * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event. + * @param {HtmlElement} t The target of the event. + * @param {Object} o The options configuration passed to the {@link #addListener} call. + */ + + /** + * The default unit to append to CSS values where a unit isn't provided (defaults to px). + * @type String + */ + defaultUnit : "px", + + /** + * Returns true if this element matches the passed simple selector (e.g. div.some-class or span:first-child) + * @param {String} selector The simple selector to test + * @return {Boolean} True if this element matches the selector, else false + */ is : function(simpleSelector){ return Ext.DomQuery.is(this.dom, simpleSelector); }, - - animate : function(args, duration, onComplete, easing, animType){ - this.anim(args, {duration: duration, callback: onComplete, easing: easing}, animType); - return this; - }, - - - anim : function(args, opt, animType, defaultDur, defaultEase, cb){ - animType = animType || 'run'; - opt = opt || {}; - var anim = Ext.lib.Anim[animType]( - this.dom, args, - (opt.duration || defaultDur) || .35, - (opt.easing || defaultEase) || 'easeOut', - function(){ - Ext.callback(cb, this); - Ext.callback(opt.callback, opt.scope || this, [this, opt]); - }, - this - ); - opt.anim = anim; - return anim; - }, - - preanim : function(a, i){ - return !a[i] ? false : (typeof a[i] == "object" ? a[i]: {duration: a[i+1], callback: a[i+2], easing: a[i+3]}); - }, - - - clean : function(forceReclean){ - if(this.isCleaned && forceReclean !== true){ - return this; - } - var ns = /\S/; - var d = this.dom, n = d.firstChild, ni = -1; - while(n){ - var nx = n.nextSibling; - if(n.nodeType == 3 && !ns.test(n.nodeValue)){ - d.removeChild(n); - }else{ - n.nodeIndex = ++ni; - } - n = nx; - } - this.isCleaned = true; - return this; - }, - - - scrollIntoView : function(container, hscroll){ - var c = Ext.getDom(container) || Ext.getBody().dom; - var el = this.dom; - - var o = this.getOffsetsTo(c), - l = o[0] + c.scrollLeft, - t = o[1] + c.scrollTop, - b = t+el.offsetHeight, - r = l+el.offsetWidth; - - var ch = c.clientHeight; - var ct = parseInt(c.scrollTop, 10); - var cl = parseInt(c.scrollLeft, 10); - var cb = ct + ch; - var cr = cl + c.clientWidth; - - if(el.offsetHeight > ch || t < ct){ - c.scrollTop = t; - }else if(b > cb){ - c.scrollTop = b-ch; - } - c.scrollTop = c.scrollTop; - if(hscroll !== false){ - if(el.offsetWidth > c.clientWidth || l < cl){ - c.scrollLeft = l; - }else if(r > cr){ - c.scrollLeft = r-c.clientWidth; - } - c.scrollLeft = c.scrollLeft; - } - return this; - }, - - scrollChildIntoView : function(child, hscroll){ - Ext.fly(child, '_scrollChildIntoView').scrollIntoView(this, hscroll); - }, - - - autoHeight : function(animate, duration, onComplete, easing){ - var oldHeight = this.getHeight(); - this.clip(); - this.setHeight(1); setTimeout(function(){ - var height = parseInt(this.dom.scrollHeight, 10); if(!animate){ - this.setHeight(height); - this.unclip(); - if(typeof onComplete == "function"){ - onComplete(); - } - }else{ - this.setHeight(oldHeight); this.setHeight(height, animate, duration, function(){ - this.unclip(); - if(typeof onComplete == "function") onComplete(); - }.createDelegate(this), easing); - } - }.createDelegate(this), 0); - return this; - }, - - - contains : function(el){ - if(!el){return false;} - return D.isAncestor(this.dom, el.dom ? el.dom : el); - }, - - - isVisible : function(deep) { - var vis = !(this.getStyle("visibility") == "hidden" || this.getStyle("display") == "none"); - if(deep !== true || !vis){ - return vis; - } - var p = this.dom.parentNode; - while(p && p.tagName.toLowerCase() != "body"){ - if(!Ext.fly(p, '_isVisible').isVisible()){ - return false; - } - p = p.parentNode; - } - return true; - }, - - - select : function(selector, unique){ - return El.select(selector, unique, this.dom); - }, - - - query : function(selector){ - return Ext.DomQuery.select(selector, this.dom); - }, - - - child : function(selector, returnDom){ - var n = Ext.DomQuery.selectNode(selector, this.dom); - return returnDom ? n : Ext.get(n); - }, - - - down : function(selector, returnDom){ - var n = Ext.DomQuery.selectNode(" > " + selector, this.dom); - return returnDom ? n : Ext.get(n); - }, - - - initDD : function(group, config, overrides){ - var dd = new Ext.dd.DD(Ext.id(this.dom), group, config); - return Ext.apply(dd, overrides); - }, - - - initDDProxy : function(group, config, overrides){ - var dd = new Ext.dd.DDProxy(Ext.id(this.dom), group, config); - return Ext.apply(dd, overrides); - }, - - - initDDTarget : function(group, config, overrides){ - var dd = new Ext.dd.DDTarget(Ext.id(this.dom), group, config); - return Ext.apply(dd, overrides); - }, - - - setVisible : function(visible, animate){ - if(!animate || !A){ - if(this.visibilityMode == El.DISPLAY){ - this.setDisplayed(visible); - }else{ - this.fixDisplay(); - this.dom.style.visibility = visible ? "visible" : "hidden"; - } - }else{ - var dom = this.dom; - var visMode = this.visibilityMode; - if(visible){ - this.setOpacity(.01); - this.setVisible(true); - } - this.anim({opacity: { to: (visible?1:0) }}, - this.preanim(arguments, 1), - null, .35, 'easeIn', function(){ - if(!visible){ - if(visMode == El.DISPLAY){ - dom.style.display = "none"; - }else{ - dom.style.visibility = "hidden"; - } - Ext.get(dom).setOpacity(1); - } - }); - } - return this; - }, - - - isDisplayed : function() { - return this.getStyle("display") != "none"; - }, - - - toggle : function(animate){ - this.setVisible(!this.isVisible(), this.preanim(arguments, 0)); - return this; - }, - - - setDisplayed : function(value) { - if(typeof value == "boolean"){ - value = value ? this.originalDisplay : "none"; - } - this.setStyle("display", value); - return this; - }, - - - focus : function() { + /** + * Tries to focus the element. Any exceptions are caught and ignored. + * @param {Number} defer (optional) Milliseconds to defer the focus + * @return {Ext.Element} this + */ + focus : function(defer, /* private */ dom) { + var me = this, + dom = dom || me.dom; try{ - this.dom.focus(); + if(Number(defer)){ + me.focus.defer(defer, null, [null, dom]); + }else{ + dom.focus(); + } }catch(e){} - return this; + return me; }, - + /** + * Tries to blur the element. Any exceptions are caught and ignored. + * @return {Ext.Element} this + */ blur : function() { try{ this.dom.blur(); @@ -2531,166 +2006,1097 @@ El.prototype = { return this; }, + /** + * Returns the value of the "value" attribute + * @param {Boolean} asNumber true to parse the value as a number + * @return {String/Number} + */ + getValue : function(asNumber){ + var val = this.dom.value; + return asNumber ? parseInt(val, 10) : val; + }, + + /** + * Appends an event handler to this element. The shorthand version {@link #on} is equivalent. + * @param {String} eventName The name of event to handle. + * @param {Function} fn The handler function the event invokes. This function is passed + * the following parameters:this
reference) in which the handler function is executed.
+ * If omitted, defaults to this Element..
+ * @param {Object} options (optional) An object containing handler configuration properties.
+ * This may contain any of the following properties:this
reference) in which the handler function is executed.
+ * If omitted, defaults to this Element.
+ * Combining Options
+ * In the following examples, the shorthand form {@link #on} is used rather than the more verbose
+ * addListener. The two are equivalent. Using the options argument, it is possible to combine different
+ * types of listeners:
+ *
+ * A delayed, one-time listener that auto stops the event and adds a custom argument (forumId) to the
+ * options object. The options object is available as the third parameter in the handler function.
+el.on('click', this.onClick, this, {
+ single: true,
+ delay: 100,
+ stopEvent : true,
+ forumId: 4
+});
+ *
+ * Attaching multiple handlers in 1 call
+ * The method also allows for a single argument to be passed which is a config object containing properties
+ * which specify multiple handlers.
+ * Code:
+el.on({
+ 'click' : {
+ fn: this.onClick,
+ scope: this,
+ delay: 100
+ },
+ 'mouseover' : {
+ fn: this.onMouseOver,
+ scope: this
+ },
+ 'mouseout' : {
+ fn: this.onMouseOut,
+ scope: this
+ }
+});
+ *
+ * Or a shorthand syntax:
+ * Code:
+el.on({
+ 'click' : this.onClick,
+ 'mouseover' : this.onMouseOver,
+ 'mouseout' : this.onMouseOut,
+ scope: this
+});
+ *
+ * delegate
+ *This is a configuration option that you can pass along when registering a handler for + * an event to assist with event delegation. Event delegation is a technique that is used to + * reduce memory consumption and prevent exposure to memory-leaks. By registering an event + * for a container element as opposed to each element within a container. By setting this + * configuration option to a simple selector, the target element will be filtered to look for + * a descendant of the target. + * For example:
+// using this markup:
+<div id='elId'>
+ <p id='p1'>paragraph one</p>
+ <p id='p2' class='clickable'>paragraph two</p>
+ <p id='p3'>paragraph three</p>
+</div>
+// utilize event delegation to registering just one handler on the container element:
+el = Ext.get('elId');
+el.on(
+ 'click',
+ function(e,t) {
+ // handle click
+ console.info(t.id); // 'p2'
+ },
+ this,
+ {
+ // filter the target element to be a descendant with the class 'clickable'
+ delegate: '.clickable'
+ }
+);
+ *
+ * @return {Ext.Element} this
+ */
+ addListener : function(eventName, fn, scope, options){
+ Ext.EventManager.on(this.dom, eventName, fn, scope || this, options);
+ return this;
+ },
+
+ /**
+ * Removes an event handler from this element. The shorthand version {@link #un} is equivalent.
+ * Note: if a scope was explicitly specified when {@link #addListener adding} the
+ * listener, the same scope must be specified here.
+ * Example:
+ *
+el.removeListener('click', this.handlerFn);
+// or
+el.un('click', this.handlerFn);
+
+ * @param {String} eventName The name of the event from which to remove the handler.
+ * @param {Function} fn The handler function to remove. This must be a reference to the function passed into the {@link #addListener} call.
+ * @param {Object} scope If a scope (this
reference) was specified when the listener was added,
+ * then this must refer to the same object.
+ * @return {Ext.Element} this
+ */
+ removeListener : function(eventName, fn, scope){
+ Ext.EventManager.removeListener(this.dom, eventName, fn, scope || this);
+ return this;
+ },
+
+ /**
+ * Removes all previous added listeners from this element
+ * @return {Ext.Element} this
+ */
+ removeAllListeners : function(){
+ Ext.EventManager.removeAll(this.dom);
+ return this;
+ },
+
+ /**
+ * Recursively removes all previous added listeners from this element and its children
+ * @return {Ext.Element} this
+ */
+ purgeAllListeners : function() {
+ Ext.EventManager.purgeElement(this, true);
+ return this;
+ },
+ /**
+ * @private Test if size has a unit, otherwise appends the default
+ */
+ addUnits : function(size){
+ if(size === "" || size == "auto" || size === undefined){
+ size = size || '';
+ } else if(!isNaN(size) || !unitPattern.test(size)){
+ size = size + (this.defaultUnit || 'px');
+ }
+ return size;
+ },
+
+ /**
+ * Updates the Same Origin Policy
+ *Updating innerHTML of an element will not execute embedded <script> elements. This is a browser restriction.
+ * @param {Mixed} options. Either a sring containing the URL from which to load the HTML, or an {@link Ext.Ajax#request} options object specifying + * exactly how to request the HTML. + * @return {Ext.Element} this + */ + load : function(url, params, cb){ + Ext.Ajax.request(Ext.apply({ + params: params, + url: url.url || url, + callback: cb, + el: this.dom, + indicatorText: url.indicatorText || '' + }, Ext.isObject(url) ? url : {})); + return this; + }, + - addClass : function(className){ - if(Ext.isArray(className)){ - for(var i = 0, len = className.length; i < len; i++) { - this.addClass(className[i]); + isBorderBox : function(){ + return Ext.isBorderBox || Ext.isForcedBorderBox || noBoxAdjust[(this.dom.tagName || "").toLowerCase()]; + }, + + + remove : function(){ + var me = this, + dom = me.dom; + + if (dom) { + delete me.dom; + Ext.removeNode(dom); + } + }, + + + hover : function(overFn, outFn, scope, options){ + var me = this; + me.on('mouseenter', overFn, scope || me.dom, options); + me.on('mouseleave', outFn, scope || me.dom, options); + return me; + }, + + + contains : function(el){ + return !el ? false : Ext.lib.Dom.isAncestor(this.dom, el.dom ? el.dom : el); + }, + + + getAttributeNS : function(ns, name){ + return this.getAttribute(name, ns); + }, + + + getAttribute: (function(){ + var test = document.createElement('table'), + isBrokenOnTable = false, + hasGetAttribute = 'getAttribute' in test, + unknownRe = /undefined|unknown/; + + if (hasGetAttribute) { + + try { + test.getAttribute('ext:qtip'); + } catch (e) { + isBrokenOnTable = true; } - }else{ - if(className && !this.hasClass(className)){ - this.dom.className = this.dom.className + " " + className; - } - } - return this; - }, - - - radioClass : function(className){ - var siblings = this.dom.parentNode.childNodes; - for(var i = 0; i < siblings.length; i++) { - var s = siblings[i]; - if(s.nodeType == 1){ - Ext.get(s).removeClass(className); - } - } - this.addClass(className); - return this; - }, - - - removeClass : function(className){ - if(!className || !this.dom.className){ - return this; - } - if(Ext.isArray(className)){ - for(var i = 0, len = className.length; i < len; i++) { - this.removeClass(className[i]); - } - }else{ - if(this.hasClass(className)){ - var re = this.classReCache[className]; - if (!re) { - re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', "g"); - this.classReCache[className] = re; + + return function(name, ns) { + var el = this.dom, + value; + + if (el.getAttributeNS) { + value = el.getAttributeNS(ns, name) || null; } - this.dom.className = - this.dom.className.replace(re, " "); - } - } - return this; - }, - - classReCache: {}, - - - toggleClass : function(className){ - if(this.hasClass(className)){ - this.removeClass(className); - }else{ - this.addClass(className); - } - return this; - }, - - - hasClass : function(className){ - return className && (' '+this.dom.className+' ').indexOf(' '+className+' ') != -1; - }, - - - replaceClass : function(oldClassName, newClassName){ - this.removeClass(oldClassName); - this.addClass(newClassName); - return this; - }, - - - getStyles : function(){ - var a = arguments, len = a.length, r = {}; - for(var i = 0; i < len; i++){ - r[a[i]] = this.getStyle(a[i]); - } - return r; - }, - - - getStyle : function(){ - return view && view.getComputedStyle ? - function(prop){ - var el = this.dom, v, cs, camel; - if(prop == 'float'){ - prop = "cssFloat"; - } - if(v = el.style[prop]){ - return v; - } - if(cs = view.getComputedStyle(el, "")){ - if(!(camel = propCache[prop])){ - camel = propCache[prop] = prop.replace(camelRe, camelFn); - } - return cs[camel]; - } - return null; - } : - function(prop){ - var el = this.dom, v, cs, camel; - if(prop == 'opacity'){ - if(typeof el.style.filter == 'string'){ - var m = el.style.filter.match(/alpha\(opacity=(.*)\)/i); - if(m){ - var fv = parseFloat(m[1]); - if(!isNaN(fv)){ - return fv ? fv / 100 : 0; + + if (value == null) { + if (ns) { + if (isBrokenOnTable && el.tagName.toUpperCase() == 'TABLE') { + try { + value = el.getAttribute(ns + ':' + name); + } catch (e) { + value = ''; } + } else { + value = el.getAttribute(ns + ':' + name); + } + } else { + value = el.getAttribute(name) || el[name]; + } + } + return value || ''; + }; + } else { + return function(name, ns) { + var el = this.om, + value, + attribute; + + if (ns) { + attribute = el[ns + ':' + name]; + value = unknownRe.test(typeof attribute) ? undefined : attribute; + } else { + value = el[name]; + } + return value || ''; + }; + } + test = null; + })(), + + + update : function(html) { + if (this.dom) { + this.dom.innerHTML = html; + } + return this; + } +}; + +var ep = El.prototype; + +El.addMethods = function(o){ + Ext.apply(ep, o); +}; + + +ep.on = ep.addListener; + + +ep.un = ep.removeListener; + + +ep.autoBoxAdjust = true; + + +var unitPattern = /\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i, + docEl; + + + + +El.get = function(el){ + var ex, + elm, + id; + if(!el){ return null; } + if (typeof el == "string") { + if (!(elm = DOC.getElementById(el))) { + return null; + } + if (EC[el] && EC[el].el) { + ex = EC[el].el; + ex.dom = elm; + } else { + ex = El.addToCache(new El(elm)); + } + return ex; + } else if (el.tagName) { + if(!(id = el.id)){ + id = Ext.id(el); + } + if (EC[id] && EC[id].el) { + ex = EC[id].el; + ex.dom = el; + } else { + ex = El.addToCache(new El(el)); + } + return ex; + } else if (el instanceof El) { + if(el != docEl){ + + + + + if (Ext.isIE && (el.id == undefined || el.id == '')) { + el.dom = el.dom; + } else { + el.dom = DOC.getElementById(el.id) || el.dom; + } + } + return el; + } else if(el.isComposite) { + return el; + } else if(Ext.isArray(el)) { + return El.select(el); + } else if(el == DOC) { + + if(!docEl){ + var f = function(){}; + f.prototype = El.prototype; + docEl = new f(); + docEl.dom = DOC; + } + return docEl; + } + return null; +}; + +El.addToCache = function(el, id){ + id = id || el.id; + EC[id] = { + el: el, + data: {}, + events: {} + }; + return el; +}; + + +El.data = function(el, key, value){ + el = El.get(el); + if (!el) { + return null; + } + var c = EC[el.id].data; + if(arguments.length == 2){ + return c[key]; + }else{ + return (c[key] = value); + } +}; + + + + +function garbageCollect(){ + if(!Ext.enableGarbageCollector){ + clearInterval(El.collectorThreadId); + } else { + var eid, + el, + d, + o; + + for(eid in EC){ + o = EC[eid]; + if(o.skipGC){ + continue; + } + el = o.el; + d = el.dom; + + + + + + + + + + + + + + + + + + if(!d || !d.parentNode || (!d.offsetParent && !DOC.getElementById(eid))){ + if(Ext.enableListenerCollection){ + Ext.EventManager.removeAll(d); + } + delete EC[eid]; + } + } + + if (Ext.isIE) { + var t = {}; + for (eid in EC) { + t[eid] = EC[eid]; + } + EC = Ext.elCache = t; + } + } +} +El.collectorThreadId = setInterval(garbageCollect, 30000); + +var flyFn = function(){}; +flyFn.prototype = El.prototype; + + +El.Flyweight = function(dom){ + this.dom = dom; +}; + +El.Flyweight.prototype = new flyFn(); +El.Flyweight.prototype.isFlyweight = true; +El._flyweights = {}; + + +El.fly = function(el, named){ + var ret = null; + named = named || '_global'; + + if (el = Ext.getDom(el)) { + (El._flyweights[named] = El._flyweights[named] || new El.Flyweight()).dom = el; + ret = El._flyweights[named]; + } + return ret; +}; + + +Ext.get = El.get; + + +Ext.fly = El.fly; + + +var noBoxAdjust = Ext.isStrict ? { + select:1 +} : { + input:1, select:1, textarea:1 +}; +if(Ext.isIE || Ext.isGecko){ + noBoxAdjust['button'] = 1; +} + +})(); + +Ext.Element.addMethods(function(){ + var PARENTNODE = 'parentNode', + NEXTSIBLING = 'nextSibling', + PREVIOUSSIBLING = 'previousSibling', + DQ = Ext.DomQuery, + GET = Ext.get; + + return { + + findParent : function(simpleSelector, maxDepth, returnEl){ + var p = this.dom, + b = document.body, + depth = 0, + stopEl; + if(Ext.isGecko && Object.prototype.toString.call(p) == '[object XULElement]') { + return null; + } + maxDepth = maxDepth || 50; + if (isNaN(maxDepth)) { + stopEl = Ext.getDom(maxDepth); + maxDepth = Number.MAX_VALUE; + } + while(p && p.nodeType == 1 && depth < maxDepth && p != b && p != stopEl){ + if(DQ.is(p, simpleSelector)){ + return returnEl ? GET(p) : p; + } + depth++; + p = p.parentNode; + } + return null; + }, + + + findParentNode : function(simpleSelector, maxDepth, returnEl){ + var p = Ext.fly(this.dom.parentNode, '_internal'); + return p ? p.findParent(simpleSelector, maxDepth, returnEl) : null; + }, + + + up : function(simpleSelector, maxDepth){ + return this.findParentNode(simpleSelector, maxDepth, true); + }, + + + select : function(selector){ + return Ext.Element.select(selector, this.dom); + }, + + + query : function(selector){ + return DQ.select(selector, this.dom); + }, + + + child : function(selector, returnDom){ + var n = DQ.selectNode(selector, this.dom); + return returnDom ? n : GET(n); + }, + + + down : function(selector, returnDom){ + var n = DQ.selectNode(" > " + selector, this.dom); + return returnDom ? n : GET(n); + }, + + + parent : function(selector, returnDom){ + return this.matchNode(PARENTNODE, PARENTNODE, selector, returnDom); + }, + + + next : function(selector, returnDom){ + return this.matchNode(NEXTSIBLING, NEXTSIBLING, selector, returnDom); + }, + + + prev : function(selector, returnDom){ + return this.matchNode(PREVIOUSSIBLING, PREVIOUSSIBLING, selector, returnDom); + }, + + + + first : function(selector, returnDom){ + return this.matchNode(NEXTSIBLING, 'firstChild', selector, returnDom); + }, + + + last : function(selector, returnDom){ + return this.matchNode(PREVIOUSSIBLING, 'lastChild', selector, returnDom); + }, + + matchNode : function(dir, start, selector, returnDom){ + var n = this.dom[start]; + while(n){ + if(n.nodeType == 1 && (!selector || DQ.is(n, selector))){ + return !returnDom ? GET(n) : n; + } + n = n[dir]; + } + return null; + } + }; +}()); +Ext.Element.addMethods( +function() { + var GETDOM = Ext.getDom, + GET = Ext.get, + DH = Ext.DomHelper; + + return { + + appendChild: function(el){ + return GET(el).appendTo(this); + }, + + + appendTo: function(el){ + GETDOM(el).appendChild(this.dom); + return this; + }, + + + insertBefore: function(el){ + (el = GETDOM(el)).parentNode.insertBefore(this.dom, el); + return this; + }, + + + insertAfter: function(el){ + (el = GETDOM(el)).parentNode.insertBefore(this.dom, el.nextSibling); + return this; + }, + + + insertFirst: function(el, returnDom){ + el = el || {}; + if(el.nodeType || el.dom || typeof el == 'string'){ + el = GETDOM(el); + this.dom.insertBefore(el, this.dom.firstChild); + return !returnDom ? GET(el) : el; + }else{ + return this.createChild(el, this.dom.firstChild, returnDom); + } + }, + + + replace: function(el){ + el = GET(el); + this.insertBefore(el); + el.remove(); + return this; + }, + + + replaceWith: function(el){ + var me = this; + + if(el.nodeType || el.dom || typeof el == 'string'){ + el = GETDOM(el); + me.dom.parentNode.insertBefore(el, me.dom); + }else{ + el = DH.insertBefore(me.dom, el); + } + + delete Ext.elCache[me.id]; + Ext.removeNode(me.dom); + me.id = Ext.id(me.dom = el); + Ext.Element.addToCache(me.isFlyweight ? new Ext.Element(me.dom) : me); + return me; + }, + + + createChild: function(config, insertBefore, returnDom){ + config = config || {tag:'div'}; + return insertBefore ? + DH.insertBefore(insertBefore, config, returnDom !== true) : + DH[!this.dom.firstChild ? 'overwrite' : 'append'](this.dom, config, returnDom !== true); + }, + + + wrap: function(config, returnDom){ + var newEl = DH.insertBefore(this.dom, config || {tag: "div"}, !returnDom); + newEl.dom ? newEl.dom.appendChild(this.dom) : newEl.appendChild(this.dom); + return newEl; + }, + + + insertHtml : function(where, html, returnEl){ + var el = DH.insertHtml(where, this.dom, html); + return returnEl ? Ext.get(el) : el; + } + }; +}()); +Ext.Element.addMethods(function(){ + + var supports = Ext.supports, + propCache = {}, + camelRe = /(-[a-z])/gi, + view = document.defaultView, + opacityRe = /alpha\(opacity=(.*)\)/i, + trimRe = /^\s+|\s+$/g, + EL = Ext.Element, + spacesRe = /\s+/, + wordsRe = /\w/g, + PADDING = "padding", + MARGIN = "margin", + BORDER = "border", + LEFT = "-left", + RIGHT = "-right", + TOP = "-top", + BOTTOM = "-bottom", + WIDTH = "-width", + MATH = Math, + HIDDEN = 'hidden', + ISCLIPPED = 'isClipped', + OVERFLOW = 'overflow', + OVERFLOWX = 'overflow-x', + OVERFLOWY = 'overflow-y', + ORIGINALCLIP = 'originalClip', + + borders = {l: BORDER + LEFT + WIDTH, r: BORDER + RIGHT + WIDTH, t: BORDER + TOP + WIDTH, b: BORDER + BOTTOM + WIDTH}, + paddings = {l: PADDING + LEFT, r: PADDING + RIGHT, t: PADDING + TOP, b: PADDING + BOTTOM}, + margins = {l: MARGIN + LEFT, r: MARGIN + RIGHT, t: MARGIN + TOP, b: MARGIN + BOTTOM}, + data = Ext.Element.data; + + + + function camelFn(m, a) { + return a.charAt(1).toUpperCase(); + } + + function chkCache(prop) { + return propCache[prop] || (propCache[prop] = prop == 'float' ? (supports.cssFloat ? 'cssFloat' : 'styleFloat') : prop.replace(camelRe, camelFn)); + } + + return { + + adjustWidth : function(width) { + var me = this; + var isNum = (typeof width == "number"); + if(isNum && me.autoBoxAdjust && !me.isBorderBox()){ + width -= (me.getBorderWidth("lr") + me.getPadding("lr")); + } + return (isNum && width < 0) ? 0 : width; + }, + + + adjustHeight : function(height) { + var me = this; + var isNum = (typeof height == "number"); + if(isNum && me.autoBoxAdjust && !me.isBorderBox()){ + height -= (me.getBorderWidth("tb") + me.getPadding("tb")); + } + return (isNum && height < 0) ? 0 : height; + }, + + + + addClass : function(className){ + var me = this, + i, + len, + v, + cls = []; + + if (!Ext.isArray(className)) { + if (typeof className == 'string' && !this.hasClass(className)) { + me.dom.className += " " + className; + } + } + else { + for (i = 0, len = className.length; i < len; i++) { + v = className[i]; + if (typeof v == 'string' && (' ' + me.dom.className + ' ').indexOf(' ' + v + ' ') == -1) { + cls.push(v); + } + } + if (cls.length) { + me.dom.className += " " + cls.join(" "); + } + } + return me; + }, + + + removeClass : function(className){ + var me = this, + i, + idx, + len, + cls, + elClasses; + if (!Ext.isArray(className)){ + className = [className]; + } + if (me.dom && me.dom.className) { + elClasses = me.dom.className.replace(trimRe, '').split(spacesRe); + for (i = 0, len = className.length; i < len; i++) { + cls = className[i]; + if (typeof cls == 'string') { + cls = cls.replace(trimRe, ''); + idx = elClasses.indexOf(cls); + if (idx != -1) { + elClasses.splice(idx, 1); } } - return 1; - }else if(prop == 'float'){ - prop = "styleFloat"; } - if(!(camel = propCache[prop])){ - camel = propCache[prop] = prop.replace(camelRe, camelFn); + me.dom.className = elClasses.join(" "); + } + return me; + }, + + + radioClass : function(className){ + var cn = this.dom.parentNode.childNodes, + v, + i, + len; + className = Ext.isArray(className) ? className : [className]; + for (i = 0, len = cn.length; i < len; i++) { + v = cn[i]; + if (v && v.nodeType == 1) { + Ext.fly(v, '_internal').removeClass(className); } - if(v = el.style[camel]){ - return v; - } - if(cs = el.currentStyle){ - return cs[camel]; - } - return null; }; - }(), + return this.addClass(className); + }, - - setStyle : function(prop, value){ - if(typeof prop == "string"){ - var camel; - if(!(camel = propCache[prop])){ - camel = propCache[prop] = prop.replace(camelRe, camelFn); + + toggleClass : function(className){ + return this.hasClass(className) ? this.removeClass(className) : this.addClass(className); + }, + + + hasClass : function(className){ + return className && (' '+this.dom.className+' ').indexOf(' '+className+' ') != -1; + }, + + + replaceClass : function(oldClassName, newClassName){ + return this.removeClass(oldClassName).addClass(newClassName); + }, + + isStyle : function(style, val) { + return this.getStyle(style) == val; + }, + + + getStyle : function(){ + return view && view.getComputedStyle ? + function(prop){ + var el = this.dom, + v, + cs, + out, + display; + + if(el == document){ + return null; + } + prop = chkCache(prop); + out = (v = el.style[prop]) ? v : + (cs = view.getComputedStyle(el, "")) ? cs[prop] : null; + + + + if(prop == 'marginRight' && out != '0px' && !supports.correctRightMargin){ + display = el.style.display; + el.style.display = 'inline-block'; + out = view.getComputedStyle(el, '').marginRight; + el.style.display = display; + } + + if(prop == 'backgroundColor' && out == 'rgba(0, 0, 0, 0)' && !supports.correctTransparentColor){ + out = 'transparent'; + } + return out; + } : + function(prop){ + var el = this.dom, + m, + cs; + + if(el == document) return null; + if (prop == 'opacity') { + if (el.style.filter.match) { + if(m = el.style.filter.match(opacityRe)){ + var fv = parseFloat(m[1]); + if(!isNaN(fv)){ + return fv ? fv / 100 : 0; + } + } + } + return 1; + } + prop = chkCache(prop); + return el.style[prop] || ((cs = el.currentStyle) ? cs[prop] : null); + }; + }(), + + + getColor : function(attr, defaultValue, prefix){ + var v = this.getStyle(attr), + color = (typeof prefix != 'undefined') ? prefix : '#', + h; + + if(!v || (/transparent|inherit/.test(v))) { + return defaultValue; } - if(camel == 'opacity') { - this.setOpacity(value); + if(/^r/.test(v)){ + Ext.each(v.slice(4, v.length -1).split(','), function(s){ + h = parseInt(s, 10); + color += (h < 16 ? '0' : '') + h.toString(16); + }); }else{ - this.dom.style[camel] = value; + v = v.replace('#', ''); + color += v.length == 3 ? v.replace(/^(\w)(\w)(\w)$/, '$1$1$2$2$3$3') : v; } - }else{ - for(var style in prop){ - if(typeof prop[style] != "function"){ - this.setStyle(style, prop[style]); + return(color.length > 5 ? color.toLowerCase() : defaultValue); + }, + + + setStyle : function(prop, value){ + var tmp, style; + + if (typeof prop != 'object') { + tmp = {}; + tmp[prop] = value; + prop = tmp; + } + for (style in prop) { + value = prop[style]; + style == 'opacity' ? + this.setOpacity(value) : + this.dom.style[chkCache(style)] = value; + } + return this; + }, + + + setOpacity : function(opacity, animate){ + var me = this, + s = me.dom.style; + + if(!animate || !me.anim){ + if(Ext.isIE){ + var opac = opacity < 1 ? 'alpha(opacity=' + opacity * 100 + ')' : '', + val = s.filter.replace(opacityRe, '').replace(trimRe, ''); + + s.zoom = 1; + s.filter = val + (val.length > 0 ? ' ' : '') + opac; + }else{ + s.opacity = opacity; + } + }else{ + me.anim({opacity: {to: opacity}}, me.preanim(arguments, 1), null, .35, 'easeIn'); + } + return me; + }, + + + clearOpacity : function(){ + var style = this.dom.style; + if(Ext.isIE){ + if(!Ext.isEmpty(style.filter)){ + style.filter = style.filter.replace(opacityRe, '').replace(trimRe, ''); + } + }else{ + style.opacity = style['-moz-opacity'] = style['-khtml-opacity'] = ''; + } + return this; + }, + + + getHeight : function(contentHeight){ + var me = this, + dom = me.dom, + hidden = Ext.isIE && me.isStyle('display', 'none'), + h = MATH.max(dom.offsetHeight, hidden ? 0 : dom.clientHeight) || 0; + + h = !contentHeight ? h : h - me.getBorderWidth("tb") - me.getPadding("tb"); + return h < 0 ? 0 : h; + }, + + + getWidth : function(contentWidth){ + var me = this, + dom = me.dom, + hidden = Ext.isIE && me.isStyle('display', 'none'), + w = MATH.max(dom.offsetWidth, hidden ? 0 : dom.clientWidth) || 0; + w = !contentWidth ? w : w - me.getBorderWidth("lr") - me.getPadding("lr"); + return w < 0 ? 0 : w; + }, + + + setWidth : function(width, animate){ + var me = this; + width = me.adjustWidth(width); + !animate || !me.anim ? + me.dom.style.width = me.addUnits(width) : + me.anim({width : {to : width}}, me.preanim(arguments, 1)); + return me; + }, + + + setHeight : function(height, animate){ + var me = this; + height = me.adjustHeight(height); + !animate || !me.anim ? + me.dom.style.height = me.addUnits(height) : + me.anim({height : {to : height}}, me.preanim(arguments, 1)); + return me; + }, + + + getBorderWidth : function(side){ + return this.addStyles(side, borders); + }, + + + getPadding : function(side){ + return this.addStyles(side, paddings); + }, + + + clip : function(){ + var me = this, + dom = me.dom; + + if(!data(dom, ISCLIPPED)){ + data(dom, ISCLIPPED, true); + data(dom, ORIGINALCLIP, { + o: me.getStyle(OVERFLOW), + x: me.getStyle(OVERFLOWX), + y: me.getStyle(OVERFLOWY) + }); + me.setStyle(OVERFLOW, HIDDEN); + me.setStyle(OVERFLOWX, HIDDEN); + me.setStyle(OVERFLOWY, HIDDEN); + } + return me; + }, + + + unclip : function(){ + var me = this, + dom = me.dom; + + if(data(dom, ISCLIPPED)){ + data(dom, ISCLIPPED, false); + var o = data(dom, ORIGINALCLIP); + if(o.o){ + me.setStyle(OVERFLOW, o.o); + } + if(o.x){ + me.setStyle(OVERFLOWX, o.x); + } + if(o.y){ + me.setStyle(OVERFLOWY, o.y); } } - } - return this; - }, + return me; + }, - - applyStyles : function(style){ - Ext.DomHelper.applyStyles(this.dom, style); - return this; - }, + + addStyles : function(sides, styles){ + var ttlSize = 0, + sidesArr = sides.match(wordsRe), + side, + size, + i, + len = sidesArr.length; + for (i = 0; i < len; i++) { + side = sidesArr[i]; + size = side && parseInt(this.getStyle(styles[side]), 10); + if (size) { + ttlSize += MATH.abs(size); + } + } + return ttlSize; + }, - + margins : margins + }; +}() +); + +(function(){ +var D = Ext.lib.Dom, + LEFT = "left", + RIGHT = "right", + TOP = "top", + BOTTOM = "bottom", + POSITION = "position", + STATIC = "static", + RELATIVE = "relative", + AUTO = "auto", + ZINDEX = "z-index"; + +Ext.Element.addMethods({ + getX : function(){ return D.getX(this.dom); }, @@ -2707,1943 +3113,925 @@ El.prototype = { getOffsetsTo : function(el){ - var o = this.getXY(); - var e = Ext.fly(el, '_internal').getXY(); + var o = this.getXY(), + e = Ext.fly(el, '_internal').getXY(); return [o[0]-e[0],o[1]-e[1]]; }, - setX : function(x, animate){ - if(!animate || !A){ - D.setX(this.dom, x); - }else{ - this.setXY([x, this.getY()], this.preanim(arguments, 1)); - } - return this; + setX : function(x, animate){ + return this.setXY([x, this.getY()], this.animTest(arguments, animate, 1)); }, - setY : function(y, animate){ - if(!animate || !A){ - D.setY(this.dom, y); - }else{ - this.setXY([this.getX(), y], this.preanim(arguments, 1)); - } - return this; + setY : function(y, animate){ + return this.setXY([this.getX(), y], this.animTest(arguments, animate, 1)); }, setLeft : function(left){ - this.setStyle("left", this.addUnits(left)); + this.setStyle(LEFT, this.addUnits(left)); return this; }, setTop : function(top){ - this.setStyle("top", this.addUnits(top)); + this.setStyle(TOP, this.addUnits(top)); return this; }, setRight : function(right){ - this.setStyle("right", this.addUnits(right)); + this.setStyle(RIGHT, this.addUnits(right)); return this; }, setBottom : function(bottom){ - this.setStyle("bottom", this.addUnits(bottom)); + this.setStyle(BOTTOM, this.addUnits(bottom)); return this; }, setXY : function(pos, animate){ - if(!animate || !A){ - D.setXY(this.dom, pos); + var me = this; + if(!animate || !me.anim){ + D.setXY(me.dom, pos); }else{ - this.anim({points: {to: pos}}, this.preanim(arguments, 1), 'motion'); + me.anim({points: {to: pos}}, me.preanim(arguments, 1), 'motion'); } - return this; + return me; }, setLocation : function(x, y, animate){ - this.setXY([x, y], this.preanim(arguments, 2)); - return this; + return this.setXY([x, y], this.animTest(arguments, animate, 2)); }, moveTo : function(x, y, animate){ - this.setXY([x, y], this.preanim(arguments, 2)); - return this; - }, - + return this.setXY([x, y], this.animTest(arguments, animate, 2)); + }, - getRegion : function(){ - return D.getRegion(this.dom); - }, - - - getHeight : function(contentHeight){ - var h = this.dom.offsetHeight || 0; - h = contentHeight !== true ? h : h-this.getBorderWidth("tb")-this.getPadding("tb"); - return h < 0 ? 0 : h; - }, - - - getWidth : function(contentWidth){ - var w = this.dom.offsetWidth || 0; - w = contentWidth !== true ? w : w-this.getBorderWidth("lr")-this.getPadding("lr"); - return w < 0 ? 0 : w; - }, - - - getComputedHeight : function(){ - var h = Math.max(this.dom.offsetHeight, this.dom.clientHeight); - if(!h){ - h = parseInt(this.getStyle('height'), 10) || 0; - if(!this.isBorderBox()){ - h += this.getFrameWidth('tb'); - } - } - return h; - }, - - - getComputedWidth : function(){ - var w = Math.max(this.dom.offsetWidth, this.dom.clientWidth); - if(!w){ - w = parseInt(this.getStyle('width'), 10) || 0; - if(!this.isBorderBox()){ - w += this.getFrameWidth('lr'); - } - } - return w; - }, - - - getSize : function(contentSize){ - return {width: this.getWidth(contentSize), height: this.getHeight(contentSize)}; - }, - - getStyleSize : function(){ - var w, h, d = this.dom, s = d.style; - if(s.width && s.width != 'auto'){ - w = parseInt(s.width, 10); - if(Ext.isBorderBox){ - w -= this.getFrameWidth('lr'); - } - } - if(s.height && s.height != 'auto'){ - h = parseInt(s.height, 10); - if(Ext.isBorderBox){ - h -= this.getFrameWidth('tb'); - } - } - return {width: w || this.getWidth(true), height: h || this.getHeight(true)}; - - }, - - - getViewSize : function(){ - var d = this.dom, doc = document, aw = 0, ah = 0; - if(d == doc || d == doc.body){ - return {width : D.getViewWidth(), height: D.getViewHeight()}; - }else{ - return { - width : d.clientWidth, - height: d.clientHeight - }; - } - }, - - - getValue : function(asNumber){ - return asNumber ? parseInt(this.dom.value, 10) : this.dom.value; - }, - - adjustWidth : function(width){ - if(typeof width == "number"){ - if(this.autoBoxAdjust && !this.isBorderBox()){ - width -= (this.getBorderWidth("lr") + this.getPadding("lr")); - } - if(width < 0){ - width = 0; - } - } - return width; - }, - - adjustHeight : function(height){ - if(typeof height == "number"){ - if(this.autoBoxAdjust && !this.isBorderBox()){ - height -= (this.getBorderWidth("tb") + this.getPadding("tb")); - } - if(height < 0){ - height = 0; - } - } - return height; - }, - - - setWidth : function(width, animate){ - width = this.adjustWidth(width); - if(!animate || !A){ - this.dom.style.width = this.addUnits(width); - }else{ - this.anim({width: {to: width}}, this.preanim(arguments, 1)); - } - return this; - }, - - - setHeight : function(height, animate){ - height = this.adjustHeight(height); - if(!animate || !A){ - this.dom.style.height = this.addUnits(height); - }else{ - this.anim({height: {to: height}}, this.preanim(arguments, 1)); - } - return this; - }, - - - setSize : function(width, height, animate){ - if(typeof width == "object"){ height = width.height; width = width.width; - } - width = this.adjustWidth(width); height = this.adjustHeight(height); - if(!animate || !A){ - this.dom.style.width = this.addUnits(width); - this.dom.style.height = this.addUnits(height); - }else{ - this.anim({width: {to: width}, height: {to: height}}, this.preanim(arguments, 2)); - } - return this; - }, - - - setBounds : function(x, y, width, height, animate){ - if(!animate || !A){ - this.setSize(width, height); - this.setLocation(x, y); - }else{ - width = this.adjustWidth(width); height = this.adjustHeight(height); - this.anim({points: {to: [x, y]}, width: {to: width}, height: {to: height}}, - this.preanim(arguments, 4), 'motion'); - } - return this; - }, - - - setRegion : function(region, animate){ - this.setBounds(region.left, region.top, region.right-region.left, region.bottom-region.top, this.preanim(arguments, 1)); - return this; - }, - - - addListener : function(eventName, fn, scope, options){ - Ext.EventManager.on(this.dom, eventName, fn, scope || this, options); - }, - - - removeListener : function(eventName, fn, scope){ - Ext.EventManager.removeListener(this.dom, eventName, fn, scope || this); - return this; - }, - - - removeAllListeners : function(){ - Ext.EventManager.removeAll(this.dom); - return this; - }, - - - relayEvent : function(eventName, observable){ - this.on(eventName, function(e){ - observable.fireEvent(eventName, e); - }); - }, - - - setOpacity : function(opacity, animate){ - if(!animate || !A){ - var s = this.dom.style; - if(Ext.isIE){ - s.zoom = 1; - s.filter = (s.filter || '').replace(/alpha\([^\)]*\)/gi,"") + - (opacity == 1 ? "" : " alpha(opacity=" + opacity * 100 + ")"); - }else{ - s.opacity = opacity; - } - }else{ - this.anim({opacity: {to: opacity}}, this.preanim(arguments, 1), null, .35, 'easeIn'); - } - return this; - }, - getLeft : function(local){ - if(!local){ - return this.getX(); - }else{ - return parseInt(this.getStyle("left"), 10) || 0; - } + return !local ? this.getX() : parseInt(this.getStyle(LEFT), 10) || 0; }, getRight : function(local){ - if(!local){ - return this.getX() + this.getWidth(); - }else{ - return (this.getLeft(true) + this.getWidth()) || 0; - } + var me = this; + return !local ? me.getX() + me.getWidth() : (me.getLeft(true) + me.getWidth()) || 0; }, getTop : function(local) { - if(!local){ - return this.getY(); - }else{ - return parseInt(this.getStyle("top"), 10) || 0; - } + return !local ? this.getY() : parseInt(this.getStyle(TOP), 10) || 0; }, getBottom : function(local){ - if(!local){ - return this.getY() + this.getHeight(); - }else{ - return (this.getTop(true) + this.getHeight()) || 0; - } + var me = this; + return !local ? me.getY() + me.getHeight() : (me.getTop(true) + me.getHeight()) || 0; }, position : function(pos, zIndex, x, y){ - if(!pos){ - if(this.getStyle('position') == 'static'){ - this.setStyle('position', 'relative'); - } - }else{ - this.setStyle("position", pos); + var me = this; + + if(!pos && me.isStyle(POSITION, STATIC)){ + me.setStyle(POSITION, RELATIVE); + } else if(pos) { + me.setStyle(POSITION, pos); } if(zIndex){ - this.setStyle("z-index", zIndex); - } - if(x !== undefined && y !== undefined){ - this.setXY([x, y]); - }else if(x !== undefined){ - this.setX(x); - }else if(y !== undefined){ - this.setY(y); + me.setStyle(ZINDEX, zIndex); } + if(x || y) me.setXY([x || false, y || false]); }, clearPositioning : function(value){ - value = value ||''; + value = value || ''; this.setStyle({ - "left": value, - "right": value, - "top": value, - "bottom": value, - "z-index": "", - "position" : "static" + left : value, + right : value, + top : value, + bottom : value, + "z-index" : "", + position : STATIC }); return this; }, getPositioning : function(){ - var l = this.getStyle("left"); - var t = this.getStyle("top"); + var l = this.getStyle(LEFT); + var t = this.getStyle(TOP); return { - "position" : this.getStyle("position"), + "position" : this.getStyle(POSITION), "left" : l, - "right" : l ? "" : this.getStyle("right"), + "right" : l ? "" : this.getStyle(RIGHT), "top" : t, - "bottom" : t ? "" : this.getStyle("bottom"), - "z-index" : this.getStyle("z-index") + "bottom" : t ? "" : this.getStyle(BOTTOM), + "z-index" : this.getStyle(ZINDEX) }; }, - - getBorderWidth : function(side){ - return this.addStyles(side, El.borders); - }, - - - getPadding : function(side){ - return this.addStyles(side, El.paddings); - }, - setPositioning : function(pc){ - this.applyStyles(pc); - if(pc.right == "auto"){ - this.dom.style.right = ""; + var me = this, + style = me.dom.style; + + me.setStyle(pc); + + if(pc.right == AUTO){ + style.right = ""; } - if(pc.bottom == "auto"){ - this.dom.style.bottom = ""; + if(pc.bottom == AUTO){ + style.bottom = ""; } - return this; - }, - - fixDisplay : function(){ - if(this.getStyle("display") == "none"){ - this.setStyle("visibility", "hidden"); - this.setStyle("display", this.originalDisplay); if(this.getStyle("display") == "none"){ this.setStyle("display", "block"); - } - } - }, - - setOverflow : function(v){ - if(v=='auto' && Ext.isMac && Ext.isGecko2){ this.dom.style.overflow = 'hidden'; - (function(){this.dom.style.overflow = 'auto';}).defer(1, this); - }else{ - this.dom.style.overflow = v; - } - }, - + + return me; + }, + - setLeftTop : function(left, top){ - this.dom.style.left = this.addUnits(left); - this.dom.style.top = this.addUnits(top); - return this; - }, + translatePoints : function(x, y){ + y = isNaN(x[1]) ? y : x[1]; + x = isNaN(x[0]) ? x : x[0]; + var me = this, + relative = me.isStyle(POSITION, RELATIVE), + o = me.getXY(), + l = parseInt(me.getStyle(LEFT), 10), + t = parseInt(me.getStyle(TOP), 10); + + l = !isNaN(l) ? l : (relative ? 0 : me.dom.offsetLeft); + t = !isNaN(t) ? t : (relative ? 0 : me.dom.offsetTop); - - move : function(direction, distance, animate){ - var xy = this.getXY(); - direction = direction.toLowerCase(); - switch(direction){ - case "l": - case "left": - this.moveTo(xy[0]-distance, xy[1], this.preanim(arguments, 2)); - break; - case "r": - case "right": - this.moveTo(xy[0]+distance, xy[1], this.preanim(arguments, 2)); - break; - case "t": - case "top": - case "up": - this.moveTo(xy[0], xy[1]-distance, this.preanim(arguments, 2)); - break; - case "b": - case "bottom": - case "down": - this.moveTo(xy[0], xy[1]+distance, this.preanim(arguments, 2)); - break; - } - return this; - }, - - - clip : function(){ - if(!this.isClipped){ - this.isClipped = true; - this.originalClip = { - "o": this.getStyle("overflow"), - "x": this.getStyle("overflow-x"), - "y": this.getStyle("overflow-y") - }; - this.setStyle("overflow", "hidden"); - this.setStyle("overflow-x", "hidden"); - this.setStyle("overflow-y", "hidden"); - } - return this; - }, - - - unclip : function(){ - if(this.isClipped){ - this.isClipped = false; - var o = this.originalClip; - if(o.o){this.setStyle("overflow", o.o);} - if(o.x){this.setStyle("overflow-x", o.x);} - if(o.y){this.setStyle("overflow-y", o.y);} - } - return this; - }, - - - - getAnchorXY : function(anchor, local, s){ - - var w, h, vp = false; - if(!s){ - var d = this.dom; - if(d == document.body || d == document){ - vp = true; - w = D.getViewWidth(); h = D.getViewHeight(); - }else{ - w = this.getWidth(); h = this.getHeight(); - } - }else{ - w = s.width; h = s.height; - } - var x = 0, y = 0, r = Math.round; - switch((anchor || "tl").toLowerCase()){ - case "c": - x = r(w*.5); - y = r(h*.5); - break; - case "t": - x = r(w*.5); - y = 0; - break; - case "l": - x = 0; - y = r(h*.5); - break; - case "r": - x = w; - y = r(h*.5); - break; - case "b": - x = r(w*.5); - y = h; - break; - case "tl": - x = 0; - y = 0; - break; - case "bl": - x = 0; - y = h; - break; - case "br": - x = w; - y = h; - break; - case "tr": - x = w; - y = 0; - break; - } - if(local === true){ - return [x, y]; - } - if(vp){ - var sc = this.getScroll(); - return [x + sc.left, y + sc.top]; - } - var o = this.getXY(); - return [x+o[0], y+o[1]]; - }, - - - getAlignToXY : function(el, p, o){ - el = Ext.get(el); - if(!el || !el.dom){ - throw "Element.alignToXY with an element that doesn't exist"; - } - var d = this.dom; - var c = false; var p1 = "", p2 = ""; - o = o || [0,0]; - - if(!p){ - p = "tl-bl"; - }else if(p == "?"){ - p = "tl-bl?"; - }else if(p.indexOf("-") == -1){ - p = "tl-" + p; - } - p = p.toLowerCase(); - var m = p.match(/^([a-z]+)-([a-z]+)(\?)?$/); - if(!m){ - throw "Element.alignTo with an invalid alignment " + p; - } - p1 = m[1]; p2 = m[2]; c = !!m[3]; - - var a1 = this.getAnchorXY(p1, true); - var a2 = el.getAnchorXY(p2, false); - - var x = a2[0] - a1[0] + o[0]; - var y = a2[1] - a1[1] + o[1]; - - if(c){ - var w = this.getWidth(), h = this.getHeight(), r = el.getRegion(); - var dw = D.getViewWidth()-5, dh = D.getViewHeight()-5; - - var p1y = p1.charAt(0), p1x = p1.charAt(p1.length-1); - var p2y = p2.charAt(0), p2x = p2.charAt(p2.length-1); - var swapY = ((p1y=="t" && p2y=="b") || (p1y=="b" && p2y=="t")); - var swapX = ((p1x=="r" && p2x=="l") || (p1x=="l" && p2x=="r")); - - var doc = document; - var scrollX = (doc.documentElement.scrollLeft || doc.body.scrollLeft || 0)+5; - var scrollY = (doc.documentElement.scrollTop || doc.body.scrollTop || 0)+5; - - if((x+w) > dw + scrollX){ - x = swapX ? r.left-w : dw+scrollX-w; - } - if(x < scrollX){ - x = swapX ? r.right : scrollX; - } - if((y+h) > dh + scrollY){ - y = swapY ? r.top-h : dh+scrollY-h; - } - if (y < scrollY){ - y = swapY ? r.bottom : scrollY; - } - } - return [x,y]; - }, - - getConstrainToXY : function(){ - var os = {top:0, left:0, bottom:0, right: 0}; - - return function(el, local, offsets, proposedXY){ - el = Ext.get(el); - offsets = offsets ? Ext.applyIf(offsets, os) : os; - - var vw, vh, vx = 0, vy = 0; - if(el.dom == document.body || el.dom == document){ - vw = Ext.lib.Dom.getViewWidth(); - vh = Ext.lib.Dom.getViewHeight(); - }else{ - vw = el.dom.clientWidth; - vh = el.dom.clientHeight; - if(!local){ - var vxy = el.getXY(); - vx = vxy[0]; - vy = vxy[1]; - } - } - - var s = el.getScroll(); - - vx += offsets.left + s.left; - vy += offsets.top + s.top; - - vw -= offsets.right; - vh -= offsets.bottom; - - var vr = vx+vw; - var vb = vy+vh; - - var xy = proposedXY || (!local ? this.getXY() : [this.getLeft(true), this.getTop(true)]); - var x = xy[0], y = xy[1]; - var w = this.dom.offsetWidth, h = this.dom.offsetHeight; - - var moved = false; - - if((x + w) > vr){ - x = vr - w; - moved = true; - } - if((y + h) > vb){ - y = vb - h; - moved = true; - } - if(x < vx){ - x = vx; - moved = true; - } - if(y < vy){ - y = vy; - moved = true; - } - return moved ? [x, y] : false; - }; - }(), - - adjustForConstraints : function(xy, parent, offsets){ - return this.getConstrainToXY(parent || document, false, offsets, xy) || xy; - }, - - - alignTo : function(element, position, offsets, animate){ - var xy = this.getAlignToXY(element, position, offsets); - this.setXY(xy, this.preanim(arguments, 3)); - return this; - }, - - - anchorTo : function(el, alignment, offsets, animate, monitorScroll, callback){ - var action = function(){ - this.alignTo(el, alignment, offsets, animate); - Ext.callback(callback, this); - }; - Ext.EventManager.onWindowResize(action, this); - var tm = typeof monitorScroll; - if(tm != 'undefined'){ - Ext.EventManager.on(window, 'scroll', action, this, - {buffer: tm == 'number' ? monitorScroll : 50}); - } - action.call(this); return this; + return {left: (x - o[0] + l), top: (y - o[1] + t)}; }, - clearOpacity : function(){ - if (window.ActiveXObject) { - if(typeof this.dom.style.filter == 'string' && (/alpha/i).test(this.dom.style.filter)){ - this.dom.style.filter = ""; - } - } else { - this.dom.style.opacity = ""; - this.dom.style["-moz-opacity"] = ""; - this.dom.style["-khtml-opacity"] = ""; - } - return this; - }, - + animTest : function(args, animate, i) { + return !!animate && this.preanim ? this.preanim(args, i) : false; + } +}); +})(); +Ext.Element.addMethods({ - hide : function(animate){ - this.setVisible(false, this.preanim(arguments, 0)); - return this; - }, - - - show : function(animate){ - this.setVisible(true, this.preanim(arguments, 0)); - return this; - }, - - - addUnits : function(size){ - return Ext.Element.addUnits(size, this.defaultUnit); - }, - - - update : function(html, loadScripts, callback){ - if(typeof html == "undefined"){ - html = ""; - } - if(loadScripts !== true){ - this.dom.innerHTML = html; - if(typeof callback == "function"){ - callback(); - } - return this; - } - var id = Ext.id(); - var dom = this.dom; - - html += ''; - - E.onAvailable(id, function(){ - var hd = document.getElementsByTagName("head")[0]; - var re = /(?: