/** * Search plugin for Ext.grid.GridPanel, Ext.grid.EditorGrid ver. 2.x or subclasses of them * * @author Ing. Jozef Sakalos * @copyright (c) 2008, by Ing. Jozef Sakalos * @date 17. January 2008 * @version $Id: Ext.ux.grid.Search.js 120 2008-03-31 00:09:05Z jozo $ * * @license Ext.ux.grid.Search is licensed under the terms of * the Open Source LGPL 3.0 license. Commercial use is permitted to the extent * that the code/component(s) do NOT become part of another Open Source or Commercially * licensed development library or toolkit without explicit permission. * * License details: http://www.gnu.org/licenses/lgpl.html */ /*global Ext */ Ext.ns('Ext.ux.grid'); /** * @class Ext.ux.grid.Search * @extends Ext.util.Observable * @param {Object} config configuration object * @constructor */ Ext.ux.grid.Search = function(config) { Ext.apply(this, config); Ext.ux.grid.Search.superclass.constructor.call(this); }; // eo constructor Ext.extend(Ext.ux.grid.Search, Ext.util.Observable, { /** * @cfg {String} searchText Text to display on menu button */ searchText:'Suche' /** * @cfg {String} searchTipText Text to display as input tooltip. Set to '' for no tooltip */ ,searchTipText:'Fügen Sie einen oder mehrere Suchbegriffe' /** * @cfg {String} selectAllText Text to display on menu item that selects all fields */ ,selectAllText:'Alle auswählen' ,fieldsprefix: 'tbl_name' ,additionalField: '' /** * @cfg {String} position Where to display the search controls. Valid values are top and bottom (defaults to bottom) * Corresponding toolbar has to exist at least with mimimum configuration tbar:[] for position:top or bbar:[] * for position bottom. Plugin does NOT create any toolbar. */ ,position:'top' /** * @cfg {String} iconCls Icon class for menu button (defaults to icon-magnifier) */ ,iconCls:'icon-magnifier' /** * @cfg {String/Array} checkIndexes Which indexes to check by default. Can be either 'all' for all indexes * or array of dataIndex names, e.g. ['persFirstName', 'persLastName'] */ ,checkIndexes:'all' /** * @cfg {Array} disableIndexes Array of index names to disable (not show in the menu), e.g. ['persTitle', 'persTitle2'] */ ,disableIndexes:[] /** * @cfg {String} dateFormat how to format date values. If undefined (the default) * date is formatted as configured in colummn model */ ,dateFormat:undefined /** * @cfg {Boolean} showSelectAll Select All item is shown in menu if true (defaults to true) */ ,showSelectAll:true /** * @cfg {String} mode Use 'remote' for remote stores or 'local' for local stores. If mode is local * no data requests are sent to server the grid's store is filtered instead (defaults to 'remote') */ ,mode:'remote' /** * @cfg {Number} width Width of input field in pixels (defaults to 100) */ ,width:300 /** * @cfg {String} xtype xtype is usually not used to instantiate this plugin but you have a chance to identify it */ ,xtype:'gridsearch' /** * @cfg {Object} paramNames Params name map (defaults to {fields:'fields', query:'query'} */ ,paramNames: { fields:'fields' ,query:'query' ,start:0 } /** * @cfg {String} shortcutKey Key to fucus the input field (defaults to r = Sea_r_ch). Empty string disables shortcut */ ,shortcutKey:'r' /** * @cfg {String} shortcutModifier Modifier for shortcutKey. Valid values: alt, ctrl, shift (defaults to alt) */ ,shortcutModifier:'alt' /** * @cfg {String} align 'left' or 'right' (defaults to 'left') */ /** * @cfg {Number} minLength force user to type this many character before he can make a search */ ,minLength: 3 /** * @cfg {Ext.Panel/String} toolbarContainer Panel (or id of the panel) which contains toolbar we want to render * search controls to (defaults to this.grid, the grid this plugin is plugged-in into) */ // {{{ /** * private * @param {Ext.grid.GridPanel/Ext.grid.EditorGrid} grid reference to grid this plugin is used for */ ,init:function(grid) { this.grid = grid; // setup toolbar container if id was given if('string' === typeof this.toolbarContainer) { this.toolbarContainer = Ext.getCmp(this.toolbarContainer); } // do our processing after grid render and reconfigure grid.onRender = grid.onRender.createSequence(this.onRender, this); grid.reconfigure = grid.reconfigure.createSequence(this.reconfigure, this); } // eo function init // }}} // {{{ /** * private add plugin controls to existing toolbar and calls reconfigure */ ,onRender:function() { var panel = this.toolbarContainer || this.grid; var tb = 'bottom' === this.position ? panel.bottomToolbar : panel.topToolbar; // add menu this.menu = new Ext.menu.Menu(); // handle position if('right' === this.align) { tb.addFill(); } else { tb.addSeparator(); } // add menu button tb.add({ text:this.searchText ,menu:this.menu ,iconCls:this.iconCls }); // add input field (TwinTriggerField in fact) this.field = new Ext.form.TriggerField({ width: this.width ,selectOnFocus:undefined === this.selectOnFocus ? true : this.selectOnFocus ,triggerClass:'x-form-clear-trigger' ,trigger2Class:'x-form-search-trigger' ,onTriggerClick:this.onTriggerClear.createDelegate(this) ,onTrigger2Click:this.onTriggerSearch.createDelegate(this) ,minLength:this.minLength }); // install event handlers on input field this.field.on('render', function() { this.field.el.dom.qtip = this.searchTipText; // install key map var map = new Ext.KeyMap(this.field.el, [{ key:Ext.EventObject.ENTER ,scope:this ,fn:this.onTriggerSearch },{ key:Ext.EventObject.ESC ,scope:this ,fn:this.onTriggerClear }]); map.stopEvent = true; }, this, {single:true}); tb.add(this.field); // reconfigure this.reconfigure(); // keyMap if(this.shortcutKey && this.shortcutModifier) { var shortcutEl = this.grid.getEl(); var shortcutCfg = [{ key:this.shortcutKey ,scope:this ,stopEvent:true ,fn:function() { this.field.focus(); } }]; shortcutCfg[0][this.shortcutModifier] = true; this.keymap = new Ext.KeyMap(shortcutEl, shortcutCfg); } } // eo function onRender // }}} // {{{ /** * private Clear Trigger click handler */ ,onTriggerClear:function() { this.field.setValue(''); this.field.focus(); this.onTriggerSearch(); } // eo function onTriggerClear // }}} // {{{ /** * private Search Trigger click handler (executes the search, local or remote) */ ,onTriggerSearch:function() { if(!this.field.isValid()) { return; } var val = this.field.getValue(); var store = this.grid.store; // grid's store filter if('local' === this.mode) { store.clearFilter(); if(val) { store.filterBy(function(r) { var retval = false; this.menu.items.each(function(item) { if(!item.checked || retval) { return; } var rv = r.get(item.dataIndex); rv = rv instanceof Date ? rv.format(this.dateFormat || r.fields.get(item.dataIndex).dateFormat) : rv; var re = new RegExp(val, 'gi'); retval = re.test(rv); }, this); if(retval) { return true; } return retval; }, this); } else { } } // ask server to filter records else { // clear start (necessary if we have paging) if(store.lastOptions && store.lastOptions.params) { store.lastOptions.params[store.paramNames.start] = 0; } // get fields to search array var fields = []; prefix = this.fieldsprefix; var extra_field=this.additionalField; this.menu.items.each(function(item) { if ((item.checked) && (item.dataIndex) && ((item.dataIndex) != extra_field)){ fields.push(prefix+item.dataIndex); } }); if (this.additionalField) fields.push(this.additionalField); // add fields and query to baseParams of store delete(store.baseParams[this.paramNames.fields]); delete(store.baseParams[this.paramNames.query]); if (store.lastOptions && store.lastOptions.params) { delete(store.lastOptions.params[this.paramNames.fields]); delete(store.lastOptions.params[this.paramNames.query]); } if(fields.length) { store.baseParams[this.paramNames.fields] = Ext.util.JSON.encode(fields); store.baseParams[this.paramNames.query] = val; store.baseParams['search'] = 1; } // reload store store.reload(); } } // eo function onTriggerSearch // }}} // {{{ /** * @param {Boolean} true to disable search (TwinTriggerField), false to enable */ ,setDisabled:function() { this.field.setDisabled.apply(this.field, arguments); } // eo function setDisabled // }}} // {{{ /** * Enable search (TwinTriggerField) */ ,enable:function() { this.setDisabled(false); } // eo function enable // }}} // {{{ /** * Enable search (TwinTriggerField) */ ,disable:function() { this.setDisabled(true); } // eo function disable // }}} // {{{ /** * private (re)configures the plugin, creates menu items from column model */ ,reconfigure:function() { // {{{ // remove old items var menu = this.menu; menu.removeAll(); // add Select All item plus separator if(this.showSelectAll) { menu.add(new Ext.menu.CheckItem({ text:this.selectAllText ,checked:!(this.checkIndexes instanceof Array) ,hideOnClick:false ,handler:function(item) { var checked = ! item.checked; item.parentMenu.items.each(function(i) { if(item !== i && i.setChecked) { i.setChecked(checked); } }); } }),'-'); } // }}} // {{{ // add new items var cm = this.grid.colModel; Ext.each(cm.config, function(config) { var disable = false; if(config.header && config.dataIndex) { Ext.each(this.disableIndexes, function(item) { disable = disable ? disable : item === config.dataIndex; }); if(!disable) { menu.add(new Ext.menu.CheckItem({ text:config.header ,hideOnClick:false ,checked:'all' === this.checkIndexes ,dataIndex:config.dataIndex })); } } }, this); // }}} // {{{ // check items if(this.checkIndexes instanceof Array) { Ext.each(this.checkIndexes, function(di) { var item = menu.items.find(function(itm) { return itm.dataIndex === di; }); if(item) { item.setChecked(true, true); } }, this); } // }}} } // eo function reconfigure // }}} }); // eo extend // eof Ext.ns("Ext.ux.grid.GridSummary"); Ext.ux.grid.GridSummary = function(config) { Ext.apply(this, config); }; Ext.extend(Ext.ux.grid.GridSummary, Ext.util.Observable, { init : function(grid) { this.grid = grid; this.cm = grid.getColumnModel(); this.view = grid.getView(); var v = this.view; v.onLayout = this.onLayout; // override GridView's onLayout() method v.afterMethod('render', this.refreshSummary, this); v.afterMethod('refresh', this.refreshSummary, this); v.afterMethod('syncScroll', this.syncSummaryScroll, this); v.afterMethod('onColumnWidthUpdated', this.doWidth, this); v.afterMethod('onAllColumnWidthsUpdated', this.doAllWidths, this); v.afterMethod('onColumnHiddenUpdated', this.doHidden, this); v.afterMethod('onUpdate', this.refreshSummary, this); v.afterMethod('onRemove', this.refreshSummary, this); // update summary row on store's add / remove / clear events grid.store.on('add', this.refreshSummary, this); grid.store.on('remove', this.refreshSummary, this); grid.store.on('clear', this.refreshSummary, this); if (!this.rowTpl) { this.rowTpl = new Ext.Template( '
', '', '{cells}', '
', '
' ); this.rowTpl.disableFormats = true; } this.rowTpl.compile(); if (!this.cellTpl) { this.cellTpl = new Ext.Template( '', '
{value}
', "" ); this.cellTpl.disableFormats = true; } this.cellTpl.compile(); }, calculate : function(rs, cm) { var data = {}, cfg = cm.config; for (var i = 0, len = cfg.length; i < len; i++) { // loop through all columns in ColumnModel var cf = cfg[i], // get column's configuration cname = cf.dataIndex; // get column dataIndex // initialise grid summary row data for // the current column being worked on data[cname] = 0; if (cf.summaryType) { for (var j = 0, jlen = rs.length; j < jlen; j++) { var r = rs[j]; // get a single Record data[cname] = Ext.ux.grid.GridSummary.Calculations[cf.summaryType](r.get(cname), r, cname, data, j); } } } return data; }, onLayout : function(vw, vh) { if (Ext.type(vh) != 'number') { // handles grid's height:'auto' config return; } // note: this method is scoped to the GridView if (!this.grid.getGridEl().hasClass('x-grid-hide-gridsummary')) { // readjust gridview's height only if grid summary row is visible this.scroller.setHeight(vh - this.summary.getHeight()); } }, syncSummaryScroll : function() { var mb = this.view.scroller.dom; this.view.summaryWrap.dom.scrollLeft = mb.scrollLeft; this.view.summaryWrap.dom.scrollLeft = mb.scrollLeft; // second time for IE (1/2 time first fails, other browsers ignore) }, doWidth : function(col, w, tw) { var s = this.view.summary.dom; s.firstChild.style.width = tw; s.firstChild.rows[0].childNodes[col].style.width = w; }, doAllWidths : function(ws, tw) { var s = this.view.summary.dom, wlen = ws.length; s.firstChild.style.width = tw; cells = s.firstChild.rows[0].childNodes; for (var j = 0; j < wlen; j++) { cells[j].style.width = ws[j]; } }, doHidden : function(col, hidden, tw) { var s = this.view.summary.dom, display = hidden ? 'none' : ''; s.firstChild.style.width = tw; s.firstChild.rows[0].childNodes[col].style.display = display; }, renderSummary : function(o, cs, cm) { cs = cs || this.view.getColumnData(); var cfg = cm.config, buf = [], last = cs.length - 1; for (var i = 0, len = cs.length; i < len; i++) { var c = cs[i], cf = cfg[i], p = {}; p.id = c.id; p.style = c.style; p.css = i == 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : ''); if (cf.summaryType || cf.summaryRenderer) { p.value = (cf.summaryRenderer || c.renderer)(o.data[c.name], p, o); } else { p.value = ''; } if (p.value == undefined || p.value === "") p.value = " "; buf[buf.length] = this.cellTpl.apply(p); } return this.rowTpl.apply({ tstyle: 'width:' + this.view.getTotalWidth() + ';', cells: buf.join('') }); }, refreshSummary : function() { var g = this.grid, ds = g.store, cs = this.view.getColumnData(), cm = this.cm, rs = ds.getRange(), data = this.calculate(rs, cm), buf = this.renderSummary({data: data}, cs, cm); if (!this.view.summaryWrap) { this.view.summaryWrap = Ext.DomHelper.insertAfter(this.view.scroller, { tag: 'div', cls: 'x-grid3-gridsummary-row-inner' }, true); } else { this.view.summary.remove(); } this.view.summary = this.view.summaryWrap.insertHtml('afterbegin', buf, true); }, toggleSummary : function(visible) { // true to display summary row var el = this.grid.getGridEl(); if (el) { if (visible === undefined) { visible = el.hasClass('x-grid-hide-gridsummary'); } el[visible ? 'removeClass' : 'addClass']('x-grid-hide-gridsummary'); this.view.layout(); // readjust gridview height } }, getSummaryNode : function() { return this.view.summary } }); /* * all Calculation methods are called on each Record in the Store * with the following 5 parameters: * * v - cell value * record - reference to the current Record * colName - column name (i.e. the ColumnModel's dataIndex) * data - the cumulative data for the current column + summaryType up to the current Record * rowIdx - current row index */ Ext.ux.grid.GridSummary.Calculations = { sum : function(v, record, colName, data, rowIdx) { return data[colName] + Ext.num(v, 0); }, count : function(v, record, colName, data, rowIdx) { return rowIdx + 1; }, max : function(v, record, colName, data, rowIdx) { return Math.max(Ext.num(v, 0), data[colName]); }, min : function(v, record, colName, data, rowIdx) { return Math.min(Ext.num(v, 0), data[colName]); }, average : function(v, record, colName, data, rowIdx) { var t = data[colName] + Ext.num(v, 0), count = record.store.getCount(); return rowIdx == count - 1 ? (t / count) : t; } } Ext.namespace('Ext.ux.Andrie'); /** * @class Ext.ux.Andrie.pPageSize * @extends Ext.PagingToolbar * A combobox control that glues itself to a PagingToolbar's pageSize configuration property. * @constructor * Create a new PageSize plugin. * @param {Object} config Configuration options * @author Andrei Neculau - andrei.neculau@gmail.com / http://andreineculau.wordpress.com * @version 0.6 */ Ext.ux.Andrie.pPageSize = function(config){ Ext.apply(this, config); }; Ext.extend(Ext.ux.Andrie.pPageSize, Ext.util.Observable, { /** * @cfg {String} beforeText * Text to display before the comboBox */ beforeText: '  ', /** * @cfg {String} afterText * Text to display after the comboBox */ afterText: '   Einträge pro Seite anzeigen  ', /** * @cfg {Mixed} addBefore * Toolbar item(s) to add before the PageSizer */ addBefore: '-', /** * @cfg {Mixed} addAfter * Toolbar item(s) to be added after the PageSizer */ addAfter: null, /** * @cfg {Bool} dynamic * True for dynamic variations, false for static ones */ dynamic: false, /** * @cfg {Array} variations * Variations used for determining pageSize options */ variations: [5, 10, 20, 50, 100, 200, 500, 1000], /** * @cfg {Object} comboCfg * Combo config object that overrides the defaults */ comboCfg: undefined, init: function(pagingToolbar){ this.pagingToolbar = pagingToolbar; this.pagingToolbar.pageSizeCombo = this; this.pagingToolbar.setPageSize = this.setPageSize.createDelegate(this); this.pagingToolbar.getPageSize = function(){ return this.pageSize; } this.pagingToolbar.on('render', this.onRender, this); }, //private addSize:function(value){ if (value>0){ this.sizes.push([value]); } }, //private updateStore: function(){ if (this.dynamic) { var middleValue = this.pagingToolbar.pageSize, start; middleValue = (middleValue > 0) ? middleValue : 1; this.sizes = []; var v = this.variations; for (var i = 0, len = v.length; i < len; i++) { this.addSize(middleValue - v[v.length - 1 - i]); } this.addToStore(middleValue); for (var i = 0, len = v.length; i < len; i++) { this.addSize(middleValue + v[i]); } }else{ if (!this.staticSizes){ this.sizes = []; var v = this.variations; var middleValue = 0; for (var i = 0, len = v.length; i < len; i++) { this.addSize(middleValue + v[i]); } this.staticSizes = this.sizes.slice(0); }else{ this.sizes = this.staticSizes.slice(0); } } this.combo.store.loadData(this.sizes); this.combo.collapse(); this.combo.setValue(this.pagingToolbar.pageSize); }, setPageSize:function(value, forced){ var pt = this.pagingToolbar; this.combo.collapse(); value = parseInt(value) || parseInt(this.combo.getValue()); value = (value>0)?value:1; if (value == pt.pageSize){ return; }else if (value < pt.pageSize){ pt.pageSize = value; var ap = Math.round(pt.cursor/value)+1; var cursor = (ap-1)*value; var store = pt.store; if (cursor > store.getTotalCount()) { this.pagingToolbar.pageSize = value; this.pagingToolbar.doLoad(cursor-value); }else{ store.suspendEvents(); for (var i = 0, len = cursor - pt.cursor; i < len; i++) { store.remove(store.getAt(0)); } while (store.getCount() > value) { store.remove(store.getAt(store.getCount() - 1)); } store.resumeEvents(); store.fireEvent('datachanged', store); pt.cursor = cursor; var d = pt.getPageData(); pt.afterTextEl.el.innerHTML = String.format(pt.afterPageText, d.pages); pt.field.dom.value = ap; pt.first.setDisabled(ap == 1); pt.prev.setDisabled(ap == 1); pt.next.setDisabled(ap == d.pages); pt.last.setDisabled(ap == d.pages); pt.updateInfo(); } }else{ this.pagingToolbar.pageSize = value; this.pagingToolbar.doLoad(Math.floor(this.pagingToolbar.cursor/this.pagingToolbar.pageSize) * this.pagingToolbar.pageSize); } this.updateStore(); }, //private onRender: function(){ this.combo = Ext.ComponentMgr.create(Ext.applyIf(this.comboCfg||{}, { store:new Ext.data.SimpleStore({ fields:['pageSize'], data:[] }), displayField:'pageSize', valueField:'pageSize', mode:'local', triggerAction:'all', width:80, emptyText: oc.limit_records, xtype:'combo', editable: false })); this.combo.setValue(1111); this.combo.on('select', this.setPageSize, this); this.updateStore(); if (this.addBefore){ this.pagingToolbar.add(this.addBefore); } if (this.beforeText){ this.pagingToolbar.add(this.beforeText); } this.pagingToolbar.add(this.combo); if (this.afterText){ this.pagingToolbar.add(this.afterText); } if (this.addAfter){ this.pagingToolbar.add(this.addAfter); } } }); /*! * Ext JS Library 3.2.1 * Copyright(c) 2006-2010 Ext JS, Inc. * licensing@extjs.com * http://www.extjs.com/license */ /*! * Ext JS Library 3.2.0 * Copyright(c) 2006-2010 Ext JS, Inc. * licensing@extjs.com * http://www.extjs.com/license */ Ext.ns('Ext.ux.grid'); /** * @class Ext.ux.grid.GroupSummary * @extends Ext.util.Observable * A GridPanel plugin that enables dynamic column calculations and a dynamically * updated grouped summary row. */ Ext.ux.grid.GroupSummary = Ext.extend(Ext.util.Observable, { /** * @cfg {Function} summaryRenderer Renderer example:

summaryRenderer: function(v, params, data){
    return ((v === 0 || v > 1) ? '(' + v +' Tasks)' : '(1 Task)');
},
     * 
*/ /** * @cfg {String} summaryType (Optional) The type of * calculation to be used for the column. For options available see * {@link #Calculations}. */ constructor : function(config){ Ext.apply(this, config); Ext.ux.grid.GroupSummary.superclass.constructor.call(this); }, init : function(grid){ this.grid = grid; var v = this.view = grid.getView(); v.doGroupEnd = this.doGroupEnd.createDelegate(this); v.afterMethod('onColumnWidthUpdated', this.doWidth, this); v.afterMethod('onAllColumnWidthsUpdated', this.doAllWidths, this); v.afterMethod('onColumnHiddenUpdated', this.doHidden, this); v.afterMethod('onUpdate', this.doUpdate, this); v.afterMethod('onRemove', this.doRemove, this); if(!this.rowTpl){ this.rowTpl = new Ext.Template( '
', '', '{cells}', '
' ); this.rowTpl.disableFormats = true; } this.rowTpl.compile(); if(!this.cellTpl){ this.cellTpl = new Ext.Template( '', '
{value}
', "" ); this.cellTpl.disableFormats = true; } this.cellTpl.compile(); }, /** * Toggle the display of the summary row on/off * @param {Boolean} visible true to show the summary, false to hide the summary. */ toggleSummaries : function(visible){ var el = this.grid.getGridEl(); if(el){ if(visible === undefined){ visible = el.hasClass('x-grid-hide-summary'); } el[visible ? 'removeClass' : 'addClass']('x-grid-hide-summary'); } }, renderSummary : function(o, cs){ cs = cs || this.view.getColumnData(); var cfg = this.grid.getColumnModel().config, buf = [], c, p = {}, cf, last = cs.length-1; for(var i = 0, len = cs.length; i < len; i++){ c = cs[i]; cf = cfg[i]; p.id = c.id; p.style = c.style; p.css = i == 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : ''); if(cf.summaryType || cf.summaryRenderer){ p.value = (cf.summaryRenderer || c.renderer)(o.data[c.name], p, o); }else{ p.value = ''; } if(p.value == undefined || p.value === "") p.value = " "; buf[buf.length] = this.cellTpl.apply(p); } return this.rowTpl.apply({ tstyle: 'width:'+this.view.getTotalWidth()+';', cells: buf.join('') }); }, /** * @private * @param {Object} rs * @param {Object} cs */ calculate : function(rs, cs){ var data = {}, r, c, cfg = this.grid.getColumnModel().config, cf; for(var j = 0, jlen = rs.length; j < jlen; j++){ r = rs[j]; for(var i = 0, len = cs.length; i < len; i++){ c = cs[i]; cf = cfg[i]; if(cf.summaryType){ data[c.name] = Ext.ux.grid.GroupSummary.Calculations[cf.summaryType](data[c.name] || 0, r, c.name, data); } } } return data; }, doGroupEnd : function(buf, g, cs, ds, colCount){ var data = this.calculate(g.rs, cs); buf.push('', this.renderSummary({data: data}, cs), ''); }, doWidth : function(col, w, tw){ if(!this.isGrouped()){ return; } var gs = this.view.getGroups(), len = gs.length, i = 0, s; for(; i < len; ++i){ s = gs[i].childNodes[2]; s.style.width = tw; s.firstChild.style.width = tw; s.firstChild.rows[0].childNodes[col].style.width = w; } }, doAllWidths : function(ws, tw){ if(!this.isGrouped()){ return; } var gs = this.view.getGroups(), len = gs.length, i = 0, j, s, cells, wlen = ws.length; for(; i < len; i++){ s = gs[i].childNodes[2]; s.style.width = tw; s.firstChild.style.width = tw; cells = s.firstChild.rows[0].childNodes; for(j = 0; j < wlen; j++){ cells[j].style.width = ws[j]; } } }, doHidden : function(col, hidden, tw){ if(!this.isGrouped()){ return; } var gs = this.view.getGroups(), len = gs.length, i = 0, s, display = hidden ? 'none' : ''; for(; i < len; i++){ s = gs[i].childNodes[2]; s.style.width = tw; s.firstChild.style.width = tw; s.firstChild.rows[0].childNodes[col].style.display = display; } }, isGrouped : function(){ return !Ext.isEmpty(this.grid.getStore().groupField); }, // Note: requires that all (or the first) record in the // group share the same group value. Returns false if the group // could not be found. refreshSummary : function(groupValue){ return this.refreshSummaryById(this.view.getGroupId(groupValue)); }, getSummaryNode : function(gid){ var g = Ext.fly(gid, '_gsummary'); if(g){ return g.down('.x-grid3-summary-row', true); } return null; }, refreshSummaryById : function(gid){ var g = Ext.getDom(gid); if(!g){ return false; } var rs = []; this.grid.getStore().each(function(r){ if(r._groupId == gid){ rs[rs.length] = r; } }); var cs = this.view.getColumnData(), data = this.calculate(rs, cs), markup = this.renderSummary({data: data}, cs), existing = this.getSummaryNode(gid); if(existing){ g.removeChild(existing); } Ext.DomHelper.append(g, markup); return true; }, doUpdate : function(ds, record){ this.refreshSummaryById(record._groupId); }, doRemove : function(ds, record, index, isUpdate){ if(!isUpdate){ this.refreshSummaryById(record._groupId); } }, /** * Show a message in the summary row. *

grid.on('afteredit', function(){
    var groupValue = 'Ext Forms: Field Anchoring';
    summary.showSummaryMsg(groupValue, 'Updating Summary...');
});
     * 
* @param {String} groupValue * @param {String} msg Text to use as innerHTML for the summary row. */ showSummaryMsg : function(groupValue, msg){ var gid = this.view.getGroupId(groupValue), node = this.getSummaryNode(gid); if(node){ node.innerHTML = '
' + msg + '
'; } } }); //backwards compat Ext.grid.GroupSummary = Ext.ux.grid.GroupSummary; /** * Calculation types for summary row:

*

Custom calculations may be implemented. An example of * custom summaryType=totalCost:


// define a custom summary function
Ext.ux.grid.GroupSummary.Calculations['totalCost'] = function(v, record, field){
    return v + (record.data.estimate * record.data.rate);
};
 * 
* @property Calculations */ Ext.ux.grid.GroupSummary.Calculations = { 'sum' : function(v, record, field){ return v + (record.data[field]||0); }, 'count' : function(v, record, field, data){ return data[field+'count'] ? ++data[field+'count'] : (data[field+'count'] = 1); }, 'max' : function(v, record, field, data){ var v = record.data[field]; var max = data[field+'max'] === undefined ? (data[field+'max'] = v) : data[field+'max']; return v > max ? (data[field+'max'] = v) : max; }, 'min' : function(v, record, field, data){ var v = record.data[field]; var min = data[field+'min'] === undefined ? (data[field+'min'] = v) : data[field+'min']; return v < min ? (data[field+'min'] = v) : min; }, 'average' : function(v, record, field, data){ var c = data[field+'count'] ? ++data[field+'count'] : (data[field+'count'] = 1); var t = (data[field+'total'] = ((data[field+'total']||0) + (record.data[field]||0))); return t === 0 ? 0 : t / c; } }; Ext.grid.GroupSummary.Calculations = Ext.ux.grid.GroupSummary.Calculations; /** * @class Ext.ux.grid.HybridSummary * @extends Ext.ux.grid.GroupSummary * Adds capability to specify the summary data for the group via json as illustrated here: *

{
    data: [
        {
            projectId: 100,     project: 'House',
            taskId:    112, description: 'Paint',
            estimate:    6,        rate:     150,
            due:'06/24/2007'
        },
        ...
    ],

    summaryData: {
        'House': {
            description: 14, estimate: 9,
                   rate: 99, due: new Date(2009, 6, 29),
                   cost: 999
        }
    }
}
 * 
* */ Ext.ux.grid.HybridSummary = Ext.extend(Ext.ux.grid.GroupSummary, { /** * @private * @param {Object} rs * @param {Object} cs */ calculate : function(rs, cs){ var gcol = this.view.getGroupField(), gvalue = rs[0].data[gcol], gdata = this.getSummaryData(gvalue); return gdata || Ext.ux.grid.HybridSummary.superclass.calculate.call(this, rs, cs); }, /** *

grid.on('afteredit', function(){
    var groupValue = 'Ext Forms: Field Anchoring';
    summary.showSummaryMsg(groupValue, 'Updating Summary...');
    setTimeout(function(){ // simulate server call
        // HybridSummary class implements updateSummaryData
        summary.updateSummaryData(groupValue,
            // create data object based on configured dataIndex
            {description: 22, estimate: 888, rate: 888, due: new Date(), cost: 8});
    }, 2000);
});
     * 
* @param {String} groupValue * @param {Object} data data object * @param {Boolean} skipRefresh (Optional) Defaults to false */ updateSummaryData : function(groupValue, data, skipRefresh){ var json = this.grid.getStore().reader.jsonData; if(!json.summaryData){ json.summaryData = {}; } json.summaryData[groupValue] = data; if(!skipRefresh){ this.refreshSummary(groupValue); } }, /** * Returns the summaryData for the specified groupValue or null. * @param {String} groupValue * @return {Object} summaryData */ getSummaryData : function(groupValue){ var reader = this.grid.getStore().reader, json = reader.jsonData, fields = reader.recordType.prototype.fields, v; if(json && json.summaryData){ v = json.summaryData[groupValue]; if(v){ return reader.extractValues(v, fields.items, fields.length); } } return null; } }); //backwards compat Ext.grid.HybridSummary = Ext.ux.grid.HybridSummary; // vim: ts=4:sw=4:nu:fdc=4:nospell /*global Ext */ /** * @class Ext.ux.grid.RowActions * @extends Ext.util.Observable * * RowActions plugin for Ext grid. Contains renderer for icons and fires events when an icon is clicked. * CSS rules from Ext.ux.RowActions.css are mandatory * * Important general information: Actions are identified by iconCls. Wherever an action * is referenced (event argument, callback argument), the iconCls of clicked icon is used. * In other words, action identifier === iconCls. * * @author Ing. Jozef Sakalos * @copyright (c) 2008, by Ing. Jozef Sakalos * @date 22. March 2008 * @version 1.0 * @revision $Id: Ext.ux.grid.RowActions.js 747 2009-09-03 23:30:52Z jozo $ * * @license Ext.ux.grid.RowActions is licensed under the terms of * the Open Source LGPL 3.0 license. Commercial use is permitted to the extent * that the code/component(s) do NOT become part of another Open Source or Commercially * licensed development library or toolkit without explicit permission. * *

License details: http://www.gnu.org/licenses/lgpl.html

* * @forum 29961 * @demo http://rowactions.extjs.eu * @download * * * @donate *
* * * * *
*/ Ext.ns('Ext.ux.grid'); // add RegExp.escape if it has not been already added if('function' !== typeof RegExp.escape) { RegExp.escape = function(s) { if('string' !== typeof s) { return s; } // Note: if pasting from forum, precede ]/\ with backslash manually return s.replace(/([.*+?\^=!:${}()|\[\]\/\\])/g, '\\$1'); }; // eo function escape } /** * Creates new RowActions plugin * @constructor * @param {Object} config A config object */ Ext.ux.grid.RowActions = function(config) { Ext.apply(this, config); // {{{ this.addEvents( /** * @event beforeaction * Fires before action event. Return false to cancel the subsequent action event. * @param {Ext.grid.GridPanel} grid * @param {Ext.data.Record} record Record corresponding to row clicked * @param {String} action Identifies the action icon clicked. Equals to icon css class name. * @param {Integer} rowIndex Index of clicked grid row * @param {Integer} colIndex Index of clicked grid column that contains all action icons */ 'beforeaction' /** * @event action * Fires when icon is clicked * @param {Ext.grid.GridPanel} grid * @param {Ext.data.Record} record Record corresponding to row clicked * @param {String} action Identifies the action icon clicked. Equals to icon css class name. * @param {Integer} rowIndex Index of clicked grid row * @param {Integer} colIndex Index of clicked grid column that contains all action icons */ ,'action' /** * @event beforegroupaction * Fires before group action event. Return false to cancel the subsequent groupaction event. * @param {Ext.grid.GridPanel} grid * @param {Array} records Array of records in this group * @param {String} action Identifies the action icon clicked. Equals to icon css class name. * @param {String} groupId Identifies the group clicked */ ,'beforegroupaction' /** * @event groupaction * Fires when icon in a group header is clicked * @param {Ext.grid.GridPanel} grid * @param {Array} records Array of records in this group * @param {String} action Identifies the action icon clicked. Equals to icon css class name. * @param {String} groupId Identifies the group clicked */ ,'groupaction' ); // }}} // call parent Ext.ux.grid.RowActions.superclass.constructor.call(this); }; Ext.extend(Ext.ux.grid.RowActions, Ext.util.Observable, { // configuration options // {{{ /** * @cfg {Array} actions Mandatory. Array of action configuration objects. The action * configuration object recognizes the following options: * */ /** * @cfg {String} actionEvent Event to trigger actions, e.g. click, dblclick, mouseover (defaults to 'click') */ actionEvent:'click' /** * @cfg {Boolean} autoWidth true to calculate field width for iconic actions only (defaults to true). * If true, the width is calculated as {@link #widthSlope} * number of actions + {@link #widthIntercept}. */ ,autoWidth:true /** * @cfg {String} dataIndex - Do not touch! * @private */ ,dataIndex:'' /** * @cfg {Boolean} editable - Do not touch! * Must be false to prevent errors in editable grids */ ,editable:false /** * @cfg {Array} groupActions Array of action to use for group headers of grouping grids. * These actions support static icons, texts and tooltips same way as {@link #actions}. There is one * more action config option recognized: * */ /** * @cfg {Object} callbacks iconCls keyed object that contains callback functions. For example: *
	 * callbacks:{
	 *      'icon-open':function(...) {...}
	 *     ,'icon-save':function(...) {...}
	 * }
	 * 
*/ /** * @cfg {String} header Actions column header */ ,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 /** * @cfg {String} tplGroup Template for group actions * @private */ ,tplGroup: '' +'
ux-action-right ' +'{cls}" style="{style}" qtip="{qtip}">{text}
' +'
' /** * @cfg {String} tplRow Template for row actions * @private */ ,tplRow: '
' +'' +'
' +'ux-row-action-text" style="{hide}{style}" qtip="{qtip}">' +'{text}
' +'
' +'
' /** * @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 /** * @cfg {Number} widthSlope Constant used for auto-width calculation (defaults to 21). * See {@link #autoWidth} for explanation. */ ,widthSlope:21 // }}} // methods // {{{ /** * Init function * @param {Ext.grid.GridPanel} grid Grid this plugin is in */ ,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) { this.tpl = this.processActions(this.actions); } // eo template setup // }}} // calculate width if(this.autoWidth) { this.width = this.widthSlope * this.actions.length + this.widthIntercept; this.fixed = true; } // body click handler var view = grid.getView(); var cfg = {scope:this}; cfg[this.actionEvent] = this.onClick; grid.afterRender = grid.afterRender.createSequence(function() { view.mainBody.on(cfg); grid.on('destroy', this.purgeListeners, this); }, this); // setup renderer if(!this.renderer) { this.renderer = function(value, cell, record, row, col, store) { cell.css += (cell.css ? ' ' : '') + 'ux-row-action-cell'; return this.tpl.apply(this.getData(value, cell, record, row, col, store)); }.createDelegate(this); } // actions in grouping grids support if(view.groupTextTpl && this.groupActions) { view.interceptMouse = view.interceptMouse.createInterceptor(function(e) { if(e.getTarget('.ux-grow-action-item')) { return false; } }); view.groupTextTpl = '
' + view.groupTextTpl +'
' +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 // }}} // {{{ /** * Returns data to apply to template. Override this if needed. * @param {Mixed} value * @param {Object} cell object to set some attributes of the grid cell * @param {Ext.data.Record} record from which the data is extracted * @param {Number} row row index * @param {Number} col col index * @param {Ext.data.Store} store object from which the record is extracted * @return {Object} data to apply to template */ ,getData:function(value, cell, record, row, col, store) { return record.data || {}; } // eo function getData // }}} // {{{ /** * Processes actions configs and returns template. * @param {Array} actions * @param {String} template Optional. Template to use for one action item. * @return {String} * @private */ ,processActions:function(actions, template) { var acts = []; // actions loop Ext.each(actions, function(a, i) { // save callback if(a.iconCls && 'function' === typeof (a.callback || a.cb)) { this.callbacks = this.callbacks || {}; this.callbacks[a.iconCls] = a.callback || a.cb; } // data for intermediate template var o = { 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 ? '' + ('display' === this.hideMode ? 'display:none' :'visibility:hidden') + ';' : (a.hide ? ('display' === this.hideMode ? 'display:none' :'visibility:hidden;') : '') ,align:a.align || 'right' ,style:a.style ? a.style : '' }; acts.push(o); }, this); // eo actions loop var xt = new Ext.XTemplate(template || this.tplRow); return new Ext.XTemplate(xt.apply({actions:acts})); } // eo function processActions // }}} ,getAction:function(e) { var action = false; var t = e.getTarget('.ux-row-action-item'); if(t) { action = t.className.replace(/ux-row-action-item /, ''); if(action) { action = action.replace(/ ux-row-action-text/, ''); action = action.trim(); } } return action; } // eo function getAction // {{{ /** * Grid body actionEvent event handler * @private */ ,onClick:function(e, target) { var view = this.grid.getView(); // handle row action click var row = e.getTarget('.x-grid3-row'); var col = view.findCellIndex(target.parentNode.parentNode); var action = this.getAction(e); // var t = e.getTarget('.ux-row-action-item'); // if(t) { // action = this.getAction(t); // action = t.className.replace(/ux-row-action-item /, ''); // if(action) { // action = action.replace(/ ux-row-action-text/, ''); // action = action.trim(); // } // } if(false !== row && false !== col && false !== action) { var record = this.grid.store.getAt(row.rowIndex); // call callback if any if(this.callbacks && 'function' === typeof this.callbacks[action]) { this.callbacks[action](this.grid, record, action, row.rowIndex, col); } // fire events if(true !== this.eventsSuspended && false === this.fireEvent('beforeaction', this.grid, record, action, row.rowIndex, col)) { return; } else if(true !== this.eventsSuspended) { this.fireEvent('action', this.grid, record, action, row.rowIndex, col); } } // handle group action click t = e.getTarget('.ux-grow-action-item'); if(t) { // get groupId var group = view.findGroup(target); var groupId = group ? group.id.replace(/ext-gen[0-9]+-gp-/, '') : null; // get matching records var records; if(groupId) { var re = new RegExp(RegExp.escape(groupId)); records = this.grid.store.queryBy(function(r) { return r._groupId.match(re); }); records = records ? records.items : []; } action = t.className.replace(/ux-grow-action-item (ux-action-right )*/, ''); // call callback if any if('function' === typeof this.callbacks[action]) { this.callbacks[action](this.grid, records, action, groupId); } // fire events if(true !== this.eventsSuspended && false === this.fireEvent('beforegroupaction', this.grid, records, action, groupId)) { return false; } this.fireEvent('groupaction', this.grid, records, action, groupId); } } // eo function onClick // }}} }); // registre xtype Ext.reg('rowactions', Ext.ux.grid.RowActions); // eof /*! * Ext JS Library 3.2.1 * Copyright(c) 2006-2010 Ext JS, Inc. * licensing@extjs.com * http://www.extjs.com/license */ Ext.ns('Ext.ux.grid'); Ext.ux.grid.LockingGridView = Ext.extend(Ext.grid.GridView, { lockText : 'Lock', unlockText : 'Unlock', rowBorderWidth : 1, lockedBorderWidth : 1, /* * This option ensures that height between the rows is synchronized * between the locked and unlocked sides. This option only needs to be used * when the row heights aren't predictable. */ syncHeights: false, initTemplates : function(){ var ts = this.templates || {}; if (!ts.master) { ts.master = new Ext.Template( '
', '
', '
{lockedHeader}
', '
{lockedBody}
', '
', '
', '
{header}
', '
{body}
', '
', '
 
', '
 
', '
' ); } this.templates = ts; Ext.ux.grid.LockingGridView.superclass.initTemplates.call(this); }, getEditorParent : function(ed){ return this.el.dom; }, initElements : function(){ var E = Ext.Element, el = this.grid.getGridEl().dom.firstChild, cs = el.childNodes; this.el = new E(el); this.lockedWrap = new E(cs[0]); this.lockedHd = new E(this.lockedWrap.dom.firstChild); this.lockedInnerHd = this.lockedHd.dom.firstChild; this.lockedScroller = new E(this.lockedWrap.dom.childNodes[1]); this.lockedBody = new E(this.lockedScroller.dom.firstChild); this.mainWrap = new E(cs[1]); this.mainHd = new E(this.mainWrap.dom.firstChild); if (this.grid.hideHeaders) { this.lockedHd.setDisplayed(false); this.mainHd.setDisplayed(false); } this.innerHd = this.mainHd.dom.firstChild; this.scroller = new E(this.mainWrap.dom.childNodes[1]); if(this.forceFit){ this.scroller.setStyle('overflow-x', 'hidden'); } this.mainBody = new E(this.scroller.dom.firstChild); this.focusEl = new E(this.scroller.dom.childNodes[1]); this.resizeMarker = new E(cs[2]); this.resizeProxy = new E(cs[3]); this.focusEl.swallowEvent('click', true); }, getLockedRows : function(){ return this.hasRows() ? this.lockedBody.dom.childNodes : []; }, getLockedRow : function(row){ return this.getLockedRows()[row]; }, getCell : function(row, col){ var llen = this.cm.getLockedCount(); if(col < llen){ return this.getLockedRow(row).getElementsByTagName('td')[col]; } return Ext.ux.grid.LockingGridView.superclass.getCell.call(this, row, col - llen); }, getHeaderCell : function(index){ var llen = this.cm.getLockedCount(); if(index < llen){ return this.lockedHd.dom.getElementsByTagName('td')[index]; } return Ext.ux.grid.LockingGridView.superclass.getHeaderCell.call(this, index - llen); }, addRowClass : function(row, cls){ var r = this.getLockedRow(row); if(r){ this.fly(r).addClass(cls); } Ext.ux.grid.LockingGridView.superclass.addRowClass.call(this, row, cls); }, removeRowClass : function(row, cls){ var r = this.getLockedRow(row); if(r){ this.fly(r).removeClass(cls); } Ext.ux.grid.LockingGridView.superclass.removeRowClass.call(this, row, cls); }, removeRow : function(row) { Ext.removeNode(this.getLockedRow(row)); Ext.ux.grid.LockingGridView.superclass.removeRow.call(this, row); }, removeRows : function(firstRow, lastRow){ var bd = this.lockedBody.dom; for(var rowIndex = firstRow; rowIndex <= lastRow; rowIndex++){ Ext.removeNode(bd.childNodes[firstRow]); } Ext.ux.grid.LockingGridView.superclass.removeRows.call(this, firstRow, lastRow); }, syncScroll : function(e){ var mb = this.scroller.dom; this.lockedScroller.dom.scrollTop = mb.scrollTop; Ext.ux.grid.LockingGridView.superclass.syncScroll.call(this, e); }, updateSortIcon : function(col, dir){ var sc = this.sortClasses, lhds = this.lockedHd.select('td').removeClass(sc), hds = this.mainHd.select('td').removeClass(sc), llen = this.cm.getLockedCount(), cls = sc[dir == 'DESC' ? 1 : 0]; if(col < llen){ lhds.item(col).addClass(cls); }else{ hds.item(col - llen).addClass(cls); } }, updateAllColumnWidths : function(){ var tw = this.getTotalWidth(), clen = this.cm.getColumnCount(), lw = this.getLockedWidth(), llen = this.cm.getLockedCount(), ws = [], len, i; this.updateLockedWidth(); for(i = 0; i < clen; i++){ ws[i] = this.getColumnWidth(i); var hd = this.getHeaderCell(i); hd.style.width = ws[i]; } var lns = this.getLockedRows(), ns = this.getRows(), row, trow, j; for(i = 0, len = ns.length; i < len; i++){ row = lns[i]; row.style.width = lw; if(row.firstChild){ row.firstChild.style.width = lw; trow = row.firstChild.rows[0]; for (j = 0; j < llen; j++) { trow.childNodes[j].style.width = ws[j]; } } row = ns[i]; row.style.width = tw; if(row.firstChild){ row.firstChild.style.width = tw; trow = row.firstChild.rows[0]; for (j = llen; j < clen; j++) { trow.childNodes[j - llen].style.width = ws[j]; } } } this.onAllColumnWidthsUpdated(ws, tw); this.syncHeaderHeight(); }, updateColumnWidth : function(col, width){ var w = this.getColumnWidth(col), llen = this.cm.getLockedCount(), ns, rw, c, row; this.updateLockedWidth(); if(col < llen){ ns = this.getLockedRows(); rw = this.getLockedWidth(); c = col; }else{ ns = this.getRows(); rw = this.getTotalWidth(); c = col - llen; } var hd = this.getHeaderCell(col); hd.style.width = w; for(var i = 0, len = ns.length; i < len; i++){ row = ns[i]; row.style.width = rw; if(row.firstChild){ row.firstChild.style.width = rw; row.firstChild.rows[0].childNodes[c].style.width = w; } } this.onColumnWidthUpdated(col, w, this.getTotalWidth()); this.syncHeaderHeight(); }, updateColumnHidden : function(col, hidden){ var llen = this.cm.getLockedCount(), ns, rw, c, row, display = hidden ? 'none' : ''; this.updateLockedWidth(); if(col < llen){ ns = this.getLockedRows(); rw = this.getLockedWidth(); c = col; }else{ ns = this.getRows(); rw = this.getTotalWidth(); c = col - llen; } var hd = this.getHeaderCell(col); hd.style.display = display; for(var i = 0, len = ns.length; i < len; i++){ row = ns[i]; row.style.width = rw; if(row.firstChild){ row.firstChild.style.width = rw; row.firstChild.rows[0].childNodes[c].style.display = display; } } this.onColumnHiddenUpdated(col, hidden, this.getTotalWidth()); delete this.lastViewWidth; this.layout(); }, doRender : function(cs, rs, ds, startRow, colCount, stripe){ var ts = this.templates, ct = ts.cell, rt = ts.row, last = colCount-1, tstyle = 'width:'+this.getTotalWidth()+';', lstyle = 'width:'+this.getLockedWidth()+';', buf = [], lbuf = [], cb, lcb, c, p = {}, rp = {}, r; for(var j = 0, len = rs.length; j < len; j++){ r = rs[j]; cb = []; lcb = []; var rowIndex = (j+startRow); for(var i = 0; i < colCount; i++){ c = cs[i]; p.id = c.id; p.css = (i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '')) + (this.cm.config[i].cellCls ? ' ' + this.cm.config[i].cellCls : ''); p.attr = p.cellAttr = ''; p.value = c.renderer(r.data[c.name], p, r, rowIndex, i, ds); p.style = c.style; if(Ext.isEmpty(p.value)){ p.value = ' '; } if(this.markDirty && r.dirty && Ext.isDefined(r.modified[c.name])){ p.css += ' x-grid3-dirty-cell'; } if(c.locked){ lcb[lcb.length] = ct.apply(p); }else{ cb[cb.length] = ct.apply(p); } } var alt = []; if(stripe && ((rowIndex+1) % 2 === 0)){ alt[0] = 'x-grid3-row-alt'; } if(r.dirty){ alt[1] = ' x-grid3-dirty-row'; } rp.cols = colCount; if(this.getRowClass){ alt[2] = this.getRowClass(r, rowIndex, rp, ds); } rp.alt = alt.join(' '); rp.cells = cb.join(''); rp.tstyle = tstyle; buf[buf.length] = rt.apply(rp); rp.cells = lcb.join(''); rp.tstyle = lstyle; lbuf[lbuf.length] = rt.apply(rp); } return [buf.join(''), lbuf.join('')]; }, processRows : function(startRow, skipStripe){ if(!this.ds || this.ds.getCount() < 1){ return; } var rows = this.getRows(), lrows = this.getLockedRows(), row, lrow; skipStripe = skipStripe || !this.grid.stripeRows; startRow = startRow || 0; for(var i = 0, len = rows.length; i < len; ++i){ row = rows[i]; lrow = lrows[i]; row.rowIndex = i; lrow.rowIndex = i; if(!skipStripe){ row.className = row.className.replace(this.rowClsRe, ' '); lrow.className = lrow.className.replace(this.rowClsRe, ' '); if ((i + 1) % 2 === 0){ row.className += ' x-grid3-row-alt'; lrow.className += ' x-grid3-row-alt'; } } if(this.syncHeights){ var el1 = Ext.get(row), el2 = Ext.get(lrow), h1 = el1.getHeight(), h2 = el2.getHeight(); if(h1 > h2){ el2.setHeight(h1); }else if(h2 > h1){ el1.setHeight(h2); } } } if(startRow === 0){ Ext.fly(rows[0]).addClass(this.firstRowCls); Ext.fly(lrows[0]).addClass(this.firstRowCls); } Ext.fly(rows[rows.length - 1]).addClass(this.lastRowCls); Ext.fly(lrows[lrows.length - 1]).addClass(this.lastRowCls); }, afterRender : function(){ if(!this.ds || !this.cm){ return; } var bd = this.renderRows() || [' ', ' ']; this.mainBody.dom.innerHTML = bd[0]; this.lockedBody.dom.innerHTML = bd[1]; this.processRows(0, true); if(this.deferEmptyText !== true){ this.applyEmptyText(); } }, renderUI : function(){ var header = this.renderHeaders(); var body = this.templates.body.apply({rows:' '}); var html = this.templates.master.apply({ body: body, header: header[0], ostyle: 'width:'+this.getOffsetWidth()+';', bstyle: 'width:'+this.getTotalWidth()+';', lockedBody: body, lockedHeader: header[1], lstyle: 'width:'+this.getLockedWidth()+';' }); var g = this.grid; g.getGridEl().dom.innerHTML = html; this.initElements(); Ext.fly(this.innerHd).on('click', this.handleHdDown, this); Ext.fly(this.lockedInnerHd).on('click', this.handleHdDown, this); this.mainHd.on({ scope: this, mouseover: this.handleHdOver, mouseout: this.handleHdOut, mousemove: this.handleHdMove }); this.lockedHd.on({ scope: this, mouseover: this.handleHdOver, mouseout: this.handleHdOut, mousemove: this.handleHdMove }); this.scroller.on('scroll', this.syncScroll, this); if(g.enableColumnResize !== false){ this.splitZone = new Ext.grid.GridView.SplitDragZone(g, this.mainHd.dom); this.splitZone.setOuterHandleElId(Ext.id(this.lockedHd.dom)); this.splitZone.setOuterHandleElId(Ext.id(this.mainHd.dom)); } if(g.enableColumnMove){ this.columnDrag = new Ext.grid.GridView.ColumnDragZone(g, this.innerHd); this.columnDrag.setOuterHandleElId(Ext.id(this.lockedInnerHd)); this.columnDrag.setOuterHandleElId(Ext.id(this.innerHd)); this.columnDrop = new Ext.grid.HeaderDropZone(g, this.mainHd.dom); } if(g.enableHdMenu !== false){ this.hmenu = new Ext.menu.Menu({id: g.id + '-hctx'}); this.hmenu.add( {itemId: 'asc', text: this.sortAscText, cls: 'xg-hmenu-sort-asc'}, {itemId: 'desc', text: this.sortDescText, cls: 'xg-hmenu-sort-desc'} ); if(this.grid.enableColLock !== false){ this.hmenu.add('-', {itemId: 'lock', text: this.lockText, cls: 'xg-hmenu-lock'}, {itemId: 'unlock', text: this.unlockText, cls: 'xg-hmenu-unlock'} ); } if(g.enableColumnHide !== false){ this.colMenu = new Ext.menu.Menu({id:g.id + '-hcols-menu'}); this.colMenu.on({ scope: this, beforeshow: this.beforeColMenuShow, itemclick: this.handleHdMenuClick }); this.hmenu.add('-', { itemId:'columns', hideOnClick: false, text: this.columnsText, menu: this.colMenu, iconCls: 'x-cols-icon' }); } this.hmenu.on('itemclick', this.handleHdMenuClick, this); } if(g.trackMouseOver){ this.mainBody.on({ scope: this, mouseover: this.onRowOver, mouseout: this.onRowOut }); this.lockedBody.on({ scope: this, mouseover: this.onRowOver, mouseout: this.onRowOut }); } if(g.enableDragDrop || g.enableDrag){ this.dragZone = new Ext.grid.GridDragZone(g, { ddGroup : g.ddGroup || 'GridDD' }); } this.updateHeaderSortState(); }, layout : function(){ if(!this.mainBody){ return; } var g = this.grid; var c = g.getGridEl(); var csize = c.getSize(true); var vw = csize.width; if(!g.hideHeaders && (vw < 20 || csize.height < 20)){ return; } this.syncHeaderHeight(); if(g.autoHeight){ this.scroller.dom.style.overflow = 'visible'; this.lockedScroller.dom.style.overflow = 'visible'; if(Ext.isWebKit){ this.scroller.dom.style.position = 'static'; this.lockedScroller.dom.style.position = 'static'; } }else{ this.el.setSize(csize.width, csize.height); var hdHeight = this.mainHd.getHeight(); var vh = csize.height - (hdHeight); } this.updateLockedWidth(); if(this.forceFit){ if(this.lastViewWidth != vw){ this.fitColumns(false, false); this.lastViewWidth = vw; } }else { this.autoExpand(); this.syncHeaderScroll(); } this.onLayout(vw, vh); }, getOffsetWidth : function() { return (this.cm.getTotalWidth() - this.cm.getTotalLockedWidth() + this.getScrollOffset()) + 'px'; }, renderHeaders : function(){ var cm = this.cm, ts = this.templates, ct = ts.hcell, cb = [], lcb = [], p = {}, len = cm.getColumnCount(), last = len - 1; for(var i = 0; i < len; i++){ p.id = cm.getColumnId(i); p.value = cm.getColumnHeader(i) || ''; p.style = this.getColumnStyle(i, true); p.tooltip = this.getColumnTooltip(i); p.css = (i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '')) + (cm.config[i].headerCls ? ' ' + cm.config[i].headerCls : ''); if(cm.config[i].align == 'right'){ p.istyle = 'padding-right:16px'; } else { delete p.istyle; } if(cm.isLocked(i)){ lcb[lcb.length] = ct.apply(p); }else{ cb[cb.length] = ct.apply(p); } } return [ts.header.apply({cells: cb.join(''), tstyle:'width:'+this.getTotalWidth()+';'}), ts.header.apply({cells: lcb.join(''), tstyle:'width:'+this.getLockedWidth()+';'})]; }, updateHeaders : function(){ var hd = this.renderHeaders(); this.innerHd.firstChild.innerHTML = hd[0]; this.innerHd.firstChild.style.width = this.getOffsetWidth(); this.innerHd.firstChild.firstChild.style.width = this.getTotalWidth(); this.lockedInnerHd.firstChild.innerHTML = hd[1]; var lw = this.getLockedWidth(); this.lockedInnerHd.firstChild.style.width = lw; this.lockedInnerHd.firstChild.firstChild.style.width = lw; }, getResolvedXY : function(resolved){ if(!resolved){ return null; } var c = resolved.cell, r = resolved.row; return c ? Ext.fly(c).getXY() : [this.scroller.getX(), Ext.fly(r).getY()]; }, syncFocusEl : function(row, col, hscroll){ Ext.ux.grid.LockingGridView.superclass.syncFocusEl.call(this, row, col, col < this.cm.getLockedCount() ? false : hscroll); }, ensureVisible : function(row, col, hscroll){ return Ext.ux.grid.LockingGridView.superclass.ensureVisible.call(this, row, col, col < this.cm.getLockedCount() ? false : hscroll); }, insertRows : function(dm, firstRow, lastRow, isUpdate){ var last = dm.getCount() - 1; if(!isUpdate && firstRow === 0 && lastRow >= last){ this.refresh(); }else{ if(!isUpdate){ this.fireEvent('beforerowsinserted', this, firstRow, lastRow); } var html = this.renderRows(firstRow, lastRow), before = this.getRow(firstRow); if(before){ if(firstRow === 0){ this.removeRowClass(0, this.firstRowCls); } Ext.DomHelper.insertHtml('beforeBegin', before, html[0]); before = this.getLockedRow(firstRow); Ext.DomHelper.insertHtml('beforeBegin', before, html[1]); }else{ this.removeRowClass(last - 1, this.lastRowCls); Ext.DomHelper.insertHtml('beforeEnd', this.mainBody.dom, html[0]); Ext.DomHelper.insertHtml('beforeEnd', this.lockedBody.dom, html[1]); } if(!isUpdate){ this.fireEvent('rowsinserted', this, firstRow, lastRow); this.processRows(firstRow); }else if(firstRow === 0 || firstRow >= last){ this.addRowClass(firstRow, firstRow === 0 ? this.firstRowCls : this.lastRowCls); } } this.syncFocusEl(firstRow); }, getColumnStyle : function(col, isHeader){ var style = !isHeader ? this.cm.config[col].cellStyle || this.cm.config[col].css || '' : this.cm.config[col].headerStyle || ''; style += 'width:'+this.getColumnWidth(col)+';'; if(this.cm.isHidden(col)){ style += 'display:none;'; } var align = this.cm.config[col].align; if(align){ style += 'text-align:'+align+';'; } return style; }, getLockedWidth : function() { return this.cm.getTotalLockedWidth() + 'px'; }, getTotalWidth : function() { return (this.cm.getTotalWidth() - this.cm.getTotalLockedWidth()) + 'px'; }, getColumnData : function(){ var cs = [], cm = this.cm, colCount = cm.getColumnCount(); for(var i = 0; i < colCount; i++){ var name = cm.getDataIndex(i); cs[i] = { name : (!Ext.isDefined(name) ? this.ds.fields.get(i).name : name), renderer : cm.getRenderer(i), id : cm.getColumnId(i), style : this.getColumnStyle(i), locked : cm.isLocked(i) }; } return cs; }, renderBody : function(){ var markup = this.renderRows() || [' ', ' ']; return [this.templates.body.apply({rows: markup[0]}), this.templates.body.apply({rows: markup[1]})]; }, refreshRow : function(record){ Ext.ux.grid.LockingGridView.superclass.refreshRow.call(this, record); var index = Ext.isNumber(record) ? record : this.ds.indexOf(record); this.getLockedRow(index).rowIndex = index; }, refresh : function(headersToo){ this.fireEvent('beforerefresh', this); this.grid.stopEditing(true); var result = this.renderBody(); this.mainBody.update(result[0]).setWidth(this.getTotalWidth()); this.lockedBody.update(result[1]).setWidth(this.getLockedWidth()); if(headersToo === true){ this.updateHeaders(); this.updateHeaderSortState(); } this.processRows(0, true); this.layout(); this.applyEmptyText(); this.fireEvent('refresh', this); }, onDenyColumnLock : function(){ }, initData : function(ds, cm){ if(this.cm){ this.cm.un('columnlockchange', this.onColumnLock, this); } Ext.ux.grid.LockingGridView.superclass.initData.call(this, ds, cm); if(this.cm){ this.cm.on('columnlockchange', this.onColumnLock, this); } }, onColumnLock : function(){ this.refresh(true); }, handleHdMenuClick : function(item){ var index = this.hdCtxIndex, cm = this.cm, id = item.getItemId(), llen = cm.getLockedCount(); switch(id){ case 'lock': if(cm.getColumnCount(true) <= llen + 1){ this.onDenyColumnLock(); return; } cm.setLocked(index, true); if(llen != index){ cm.moveColumn(index, llen); this.grid.fireEvent('columnmove', index, llen); } break; case 'unlock': if(llen - 1 != index){ cm.setLocked(index, false, true); cm.moveColumn(index, llen - 1); this.grid.fireEvent('columnmove', index, llen - 1); }else{ cm.setLocked(index, false); } break; default: return Ext.ux.grid.LockingGridView.superclass.handleHdMenuClick.call(this, item); } return true; }, handleHdDown : function(e, t){ Ext.ux.grid.LockingGridView.superclass.handleHdDown.call(this, e, t); if(this.grid.enableColLock !== false){ if(Ext.fly(t).hasClass('x-grid3-hd-btn')){ var hd = this.findHeaderCell(t), index = this.getCellIndex(hd), ms = this.hmenu.items, cm = this.cm; ms.get('lock').setDisabled(cm.isLocked(index)); ms.get('unlock').setDisabled(!cm.isLocked(index)); } } }, syncHeaderHeight: function(){ this.innerHd.firstChild.firstChild.style.height = 'auto'; this.lockedInnerHd.firstChild.firstChild.style.height = 'auto'; var hd = this.innerHd.firstChild.firstChild.offsetHeight, lhd = this.lockedInnerHd.firstChild.firstChild.offsetHeight, height = (lhd > hd ? lhd : hd) + 'px'; this.innerHd.firstChild.firstChild.style.height = height; this.lockedInnerHd.firstChild.firstChild.style.height = height; }, updateLockedWidth: function(){ var lw = this.cm.getTotalLockedWidth(), tw = this.cm.getTotalWidth() - lw, csize = this.grid.getGridEl().getSize(true), lp = Ext.isBorderBox ? 0 : this.lockedBorderWidth, rp = Ext.isBorderBox ? 0 : this.rowBorderWidth, vw = (csize.width - lw - lp - rp) + 'px', so = this.getScrollOffset(); if(!this.grid.autoHeight){ var vh = (csize.height - this.mainHd.getHeight()) + 'px'; this.lockedScroller.dom.style.height = vh; this.scroller.dom.style.height = vh; } this.lockedWrap.dom.style.width = (lw + rp) + 'px'; this.scroller.dom.style.width = vw; this.mainWrap.dom.style.left = (lw + lp + rp) + 'px'; if(this.innerHd){ this.lockedInnerHd.firstChild.style.width = lw + 'px'; this.lockedInnerHd.firstChild.firstChild.style.width = lw + 'px'; this.innerHd.style.width = vw; this.innerHd.firstChild.style.width = (tw + rp + so) + 'px'; this.innerHd.firstChild.firstChild.style.width = tw + 'px'; } if(this.mainBody){ this.lockedBody.dom.style.width = (lw + rp) + 'px'; this.mainBody.dom.style.width = (tw + rp) + 'px'; } } }); Ext.ux.grid.LockingColumnModel = Ext.extend(Ext.grid.ColumnModel, { /** * Returns true if the given column index is currently locked * @param {Number} colIndex The column index * @return {Boolean} True if the column is locked */ isLocked : function(colIndex){ return this.config[colIndex].locked === true; }, /** * Locks or unlocks a given column * @param {Number} colIndex The column index * @param {Boolean} value True to lock, false to unlock * @param {Boolean} suppressEvent Pass false to cause the columnlockchange event not to fire */ setLocked : function(colIndex, value, suppressEvent){ if (this.isLocked(colIndex) == value) { return; } this.config[colIndex].locked = value; if (!suppressEvent) { this.fireEvent('columnlockchange', this, colIndex, value); } }, /** * Returns the total width of all locked columns * @return {Number} The width of all locked columns */ getTotalLockedWidth : function(){ var totalWidth = 0; for (var i = 0, len = this.config.length; i < len; i++) { if (this.isLocked(i) && !this.isHidden(i)) { totalWidth += this.getColumnWidth(i); } } return totalWidth; }, /** * Returns the total number of locked columns * @return {Number} The number of locked columns */ getLockedCount : function() { var len = this.config.length; for (var i = 0; i < len; i++) { if (!this.isLocked(i)) { return i; } } //if we get to this point all of the columns are locked so we return the total return len; }, /** * Moves a column from one position to another * @param {Number} oldIndex The current column index * @param {Number} newIndex The destination column index */ moveColumn : function(oldIndex, newIndex){ var oldLocked = this.isLocked(oldIndex), newLocked = this.isLocked(newIndex); if (oldIndex < newIndex && oldLocked && !newLocked) { this.setLocked(oldIndex, false, true); } else if (oldIndex > newIndex && !oldLocked && newLocked) { this.setLocked(oldIndex, true, true); } Ext.ux.grid.LockingColumnModel.superclass.moveColumn.apply(this, arguments); } }); Ext.grid.CheckColumn = function(config){ this.addEvents({ click: true }); Ext.grid.CheckColumn.superclass.constructor.call(this); Ext.apply(this, config, { init: function(grid){ this.grid = grid; this.grid.on('render', function(){ var view = this.grid.getView(); view.mainBody.on('mousedown', this.onMouseDown, this); }, this); }, onMouseDown: function(e, t){ if (t.className && t.className.indexOf('x-grid3-cc-' + this.id) != -1) { e.stopEvent(); var index = this.grid.getView().findRowIndex(t); var record = this.grid.store.getAt(index); record.set(this.dataIndex, (record.data[this.dataIndex] == 1 ? 0 : 1)); this.fireEvent('click', this, e, record); } }, renderer: function(v, p, record){ p.css += ' x-grid3-check-col-td'; return '
 
'; } }); if (!this.id) { this.id = Ext.id(); } this.renderer = this.renderer.createDelegate(this); }; Ext.extend(Ext.grid.CheckColumn, Ext.util.Observable);// docs here : http://extjs.com/forum/showthread.php?p=202511 Ext.grid.RadioColumn = function(config){ Ext.apply(this, config); if (!this.id) { this.id = Ext.id(); } this.renderer = this.renderer.createDelegate(this); }; Ext.grid.RadioColumn.prototype = { init: function(grid){ this.grid = grid; this.grid.on('render', function(){ var view = this.grid.getView(); view.mainBody.on('mousedown', this.onMouseDown, this); }, this); }, onMouseDown: function(e, t){ if (t.className && t.className.indexOf('x-grid3-cc-' + this.id) != -1) { e.stopEvent(); var index = this.grid.getView().findRowIndex(t); var record = this.grid.store.getAt(index); record.set(this.dataIndex, this.inputValue); } }, renderer: function(v, p, record){ p.css += ' x-grid3-check-col-td'; return '
'; } };Ext.ns('Ext.ux.window'); /** * An object that represents a group of {@link Ext.ux.window.MessageWindow} instances * and provides position management in addition to the standard Window Group features. * @class Ext.ux.window.MessageWindowGroup * @extends Ext.WindowGroup * @constructor */ Ext.ux.window.MessageWindowGroup = function (config) { config = config || {}; var mgr = new Ext.WindowGroup(); mgr.positions = []; Ext.apply(mgr, config); return mgr; }; /** * The default global Message Window group that is available automatically. To have * more than one group of Message Windows to utilize separate positioning in addition * to the standard Window Manager features create additional instances of * {@link Ext.ux.window.MessageWindowGroup} as needed. * @class Ext.ux.window.MessageWindowMgr * @extends Ext.ux.window.MessageWindowGroup * @singleton */ Ext.ux.window.MessageWindowMgr = Ext.ux.window.MessageWindowGroup(); /** *

If you are looking for a lightweight implementation of Toast or Notification windows this is * NOT the class you want. This class builds upon the implementation by Edouard Fattal. * This class creates a specialized Window for notification messages and offers the following features:

* *
Demo link: here *
Forum thread: here
* * Features: * *
* Known issues/caveats/bugs/roadmap: * * @class Ext.ux.window.MessageWindow * @extends Ext.Window * @author Michael LeComte (mjlecomte), inspired by Ext.ux.Notification\ToastWindow (Edouard Fattal) * @license LGPL 3.0 * @version 0.08 - Nov 8, 2008 (ALPHA!!!) * @donate
*/ Ext.ux.window.MessageWindow = Ext.extend(Ext.Window, { /** * @cfg {Boolean} autoDestroy * The action to take after the message window has been hidden. The default is true which * will actually remove the window from the DOM and destroy it. False will simply hide the * window by setting visibility to hidden and applying negative offsets, keeping the window * available to be redisplayed via the {@link #show} method. */ autoDestroy: true, /** * @cfg {Boolean} autoHide * {@link #autoHide} * True to have message window automatically hide itself (defaults to true). */ autoHide: true, /** * @cfg {Boolean} autoHeight * True to use height:'auto', false to use fixed height (defaults to false). */ autoHeight: false, /** * @cfg {String} bodyStyle * Custom CSS styles to be applied to the body element in the format expected by * Ext.Element.applyStyles (defaults to 'text-align:left;padding:10px;'). */ bodyStyle: 'text-align:left;padding:10px;', /** * @cfg {String} baseCls * The base CSS class to apply to this panel's element (defaults to 'x-window'). */ /** * @cfg {String} buttonAlign * The alignment of any buttons added to this panel. Valid values are 'right', 'left', * and 'center' (defaults to 'center'). */ buttonAlign: 'center', /** * @cfg {String} cls * An optional extra CSS class that will be added to this component's Element (defaults * to 'x-notification'). This can be useful for adding customized styles to the component * or any of its children using standard CSS rules. */ cls: 'x-notification', /** * @cfg {Boolean} constrain * True to constrain the window to the viewport, false to allow it to fall outside of * the viewport (defaults to true). Optionally the header only can be constrained using * {@link #constrainHeader}. */ constrain: true, /** * @cfg {Boolean} constrainHeader * True to constrain the window header to the viewport, allowing the window body to fall * outside of the viewport, false to allow the header to fall outside the viewport (defaults * to true). Optionally the entire window can be constrained using {@link #constrain}. */ constrainHeader: true, /** * @cfg {Boolean} draggable * True to allow the window to be dragged by the header bar, false to disable dragging * (defaults to true). Note that by default the window will be centered in the viewport, * so if dragging is disabled the window may need to be positioned programmatically after * render (e.g., myWindow.setPosition(100, 100);). */ draggable: true, /** @cfg {Boolean} floating */ /** @private */ floating: true, /** * @cfg {Boolean} focusOnShow * True to focus the window when shown (defaults to false). */ /** @cfg {Boolean} frame */ /** @private */ frame: true, /** * @cfg {Ext.ux.window.MessageWindowGroup} manager * A reference to the MessageWindowGroup that should manage this Message Window (defaults * to {@link Ext.ux.window.MessageWindowMgr}). Specify a reference to an instance unless * you want a new manager for each instance: *

     * var group2 = new Ext.ux.window.MessageWindowGroup({
     *     //override any defaults or add to base class instance
     *     groupId: 2, //groupId not implemented at this time
     *     zseed: 2000 //change the zseed (default = 9000)
     * });
     * var mw1 = new Ext.ux.window.MessageWindow({
     *     manager: group2//specify the MessageWindowGroup manager (instead of using default manager)
     * });
     * var mw2 = new Ext.ux.window.MessageWindow({
     *     manager: group2//specify the MessageWindowGroup manager (instead of using default manager)
     * });
     * var mw3 = new Ext.ux.window.MessageWindow({
     *     //will use default manager
     * });
     * 
*/ /** * @cfg {Function} handleHelp * Handler function when the help tool is clicked (defaults to {@link Ext#emptyFn}). * @param {Object} event The click event. * @param {Object} toolEl The tool Element. * @param {Object} panel The host Panel. */ handleHelp: Ext.emptyFn, /** * @cfg {Boolean} help * True to display tools for help. Defaults to true. */ help: true, /** * @cfg {Object} hideFx * Config object for hide effects settings. An example with defaults shown: *

     * hideFx: {
     *     delay: 5000,  //time in milliseconds to delay the start of the effect
     *     duration: 0.25, //duration of the effect
     *     mode: 'standard', // null = will not hide
     *                       // 'standard' = traditional window hide (vanish)
     *                       // 'standard' = traditional window hide (vanish)
     *                       // anything else will use the default of ghost
     *     useProxy: true //default is false to hide window instead
     * }
     * 
*/ hideFx: { delay: 5000 }, /** * @cfg {String} hoverCls * An extra CSS class that will be added to this component's Element when * hovering over (defaults to 'msg-over'). */ hoverCls: 'msg-over', /** * @cfg {String} iconCls * A CSS class that will provide a background image to be used as the header icon (defaults * to 'x-icon-information'). An example custom icon class would be something like: * .my-icon { background: url(../images/my-icon.gif) 0 6px no-repeat !important;} */ iconCls: 'x-icon-information', /** * @cfg {Boolean} maximizable * True to display the 'maximize' tool button and allow the user to maximize the window, false to hide the button * and disallow maximizing the window (defaults to false). Note that when a window is maximized, the tool button * will automatically change to a 'restore' button with the appropriate behavior already built-in that will * restore the window to its previous size. */ /** * @cfg {Boolean} minimizable * True to display the 'minimize' tool button and allow the user to minimize the window, false to hide the button * and disallow minimizing the window (defaults to false). Note that this button provides no implementation -- * the behavior of minimizing a window is implementation-specific, so the minimize event must be handled and a * custom minimize behavior implemented for this option to be useful. */ /** * @cfg {Number} minHeight * The minimum height in pixels allowed for this window (defaults to 100). Only applies when resizable = true. */ minHeight: 40, /** * @cfg {Number} minWidth * The minimum width in pixels allowed for this window (defaults to 200). Only applies when resizable = true. */ minWidth: 200, /** * @cfg {Boolean} modal * True to make the window modal and mask everything behind it when displayed, false to display it without * restricting access to other UI elements (defaults to false). */ /** * @cfg {Array} msgs * An array to hold the message queue for refreshing messages. Body of the message window will be updated * from the text element. * Example: *

     * msgs: [
     *     {text: 'Some text message 1', url:'http://extjs.com/support/training/'},
     *     {text: 'Some text message 2 »', url:'http://extjs.com/support/training/'}
     * ],
     * 
* The first message that will be displayed uses the Title and html config options. */ msgs: [], /** * @cfg {Boolean} monitorResize * This is automatically managed based on the value of constrain and constrainToHeader */ monitorResize : true, /** * @cfg {Function} onEsc * Allows override of the built-in processing for the escape key. Default action * is to close the Window (performing whatever action is specified in {@link #closeAction}. * To prevent the Window closing when the escape key is pressed, specify this as * Ext.emptyFn (See {@link Ext#emptyFn}). */ /** * @cfg {Object} origin * Config object for the message origin with the following sample of default properties: * Example: *

     * //configure a different origin than the default bottom right corner of the window:
     * origin: {
     *     //get window's Ext.element:
     *     el: Ext.get('northRegion'), //element to align to (defaults to document)
     *     pos: "bl-bl",//position to align to (see {@link Ext.Element#alignTo} for more details defaults to "br-br").
     *     offX: 10, //amount to offset horizontally (-20 by default)
     *     offY: 0 //amount to offset vertically (-20 by default)
     * },
     * 
*/ /** * @cfg {Boolean} pinOnClick * True to display the 'pin' tool button and allow the user to pin the window, false * to hide the button and disallow pinning the window (defaults to true). */ pinOnClick: true, /** * @cfg {String} pinState * Specify the initial pin state when the window is first shown. Specify null, 'pin', or the default * 'unpin'.
     * pinState  effect
     * --------  ------
     * null      window will show/hide itself, user can not control
     * 'pin'     window will initially show itself in pinned state, user will need to click unpin to hide
     * 'unpin'   window will initially show itself in unpinned state, user will need to click pin to keep open
     * 
*/ pinState: 'unpin', /** * @cfg {Boolean} plain * True to render the window body with a transparent background so that it will blend into the framing * elements, false to add a lighter background color to visually highlight the body element and separate it * more distinctly from the surrounding frame (defaults to false). */ plain: false, /** * @cfg {Boolean} resizable * True to allow user resizing at each edge and corner of the window, false to disable resizing (defaults to false). */ resizable: false, /** * @cfg {String} resizeHandles * A valid {@link Ext.Resizable} handles config string (defaults to 'all'). Only applies when resizable = true. */ /** * @cfg {String} textHelp * Qtip text to display for help tool (defaults to 'Get hel'). Only applicable if help = true. */ textHelp: 'Get help', /** * @cfg {String} textPin * Qtip text to display for pin tool. Only applicable if {@link pinState} == 'pin' or 'unpin'. */ textPin: 'Pin this to prevent closing', /** * @cfg {String} textUnpin * Qtip text to display for unpin tool. Only applicable if {@link pinState} == 'pin' or 'unpin'. */ textUnpin: 'Unpin this to close', /** * @cfg {Number} x * The X position of the left edge of the Window on initial showing. Defaults to centering the Window within * the width of the Window's container {@link Ext.Element Element) (The Element that the Window is rendered to). */ /** * @cfg {Number} y * The Y position of the top edge of the Window on initial showing. Defaults to centering the Window within * the height of the Window's container {@link Ext.Element Element) (The Element that the Window is rendered to). */ /** @private */ initHidden : true, /** @private */ initComponent : function () { Ext.apply(this, { collapsible: false, footer: false, minHeight: 20, stateful: false }); //if interval is specified automatically show message windows if (this.interval) { this.startAutoRefresh(); } //set up automatic hide/close of window if so configured if (this.autoHide) { if (this.pinState === 'unpin') { this.task = new Ext.util.DelayedTask(this.hide, this); } } //new else { this.closable = true; } //added this.closable //call parent Ext.ux.window.MessageWindow.superclass.initComponent.call(this); //add listeners this.on({ hide: { scope: this, fn: function () { if (this.autoDestroy) { if (this.fireEvent("beforeclose", this) !== false) { this.fireEvent('close', this); this.destroy(); } } } }, mouseout: { scope: this, fn: this.onMouseout } }); //add events this.addEvents( /** * @event activate * Fires after the window has been visually activated via {@link setActive}. * @param {Ext.ux.window.MessageWindow} this */ /** * @event deactivate * Fires after the window has been visually deactivated via {@link setActive}. * @param {Ext.ux.window.MessageWindow} this */ /** * @event resize * Fires after the window has been resized. * @param {Ext.ux.window.MessageWindow} this * @param {Number} width The window's new width * @param {Number} height The window's new height */ /** * @event maximize * Fires after the window has been maximized. * @param {Ext.ux.window.MessageWindow} this */ /** * @event minimize * Fires after the window has been minimized. * @param {Ext.ux.window.MessageWindow} this */ /** * @event restore * Fires after the window has been restored to its original size after being maximized. * @param {Ext.ux.window.MessageWindow} this */ /** * @event pinned * Fires after the window has been pinned. * @param {Ext.ux.window.MessageWindow} this */ 'afterpin', /** * @event unpinned * Fires after the window has been unpinned. * @param {Ext.ux.window.MessageWindow} this */ 'afterunpin', /** * @event click * Fires after the window has been clicked. * @param {Ext.ux.window.MessageWindow} this * @param {Ext.ux.window.MessageWindow} msg The message from the message array if configured. */ 'click'); }, //override /** @private */ initEvents: function () { //use a slighly enhanced Ext.ux.window.MessageWindowMgr instead of the default WindowMgr this.manager = this.manager || Ext.ux.window.MessageWindowMgr; //the parent class will register, so no need to do it here: //this.manager = this.manager || Ext.WindowMgr; Ext.ux.window.MessageWindow.superclass.initEvents.call(this); }, focus: function () { Ext.ux.window.MessageWindow.superclass.focus.call(this); }, /** @private */ toFront: function () { if(this.manager.bringToFront(this)){ //only focus if configured as such if(this.focusOnShow){ this.focus(); } } return this; }, /** @private */ initTools: function () { this.addTool({ id: 'unpin', // image points left handler: this.handlePin, //set initial visibility (also check if pinState is null) hidden: (!this.pinState || this.pinState === 'pin'), qtip: this.textPin, scope: this }); this.addTool({ id: 'pin',// image points down handler: this.handleUnpin, hidden: (!this.pinState || this.pinState === 'unpin'), qtip: this.textUnpin, scope: this }); if (this.help) { this.addTool({ id: 'help', handler: this.handleHelp, qtip: this.textHelp, scope: this }); } }, /** @private */ onRender: function (ct, position) { Ext.ux.window.MessageWindow.superclass.onRender.call(this, ct, position); //after call to parent class onRender this.el exists. //clip part of the window (for example the recurring messages that //eject from a border have the bottom rounded edge, etc. clipped off. if (this.clip) { switch (this.clip) { case 'bottom': Ext.destroy(this.getEl().child('.' + this.baseCls + '-bl')); break; } } //add a class when hovering over in order to disable //any updates to the window while hovering over if (true) { this.el.addClassOnOver(this.hoverCls); } //add click listener to body Ext.fly(this.body.dom).on('click', this.handleClick, this); }, /** * Toggles the active pin state. */ togglePinState: function (event) { //check which tool is visible if (this.tools.unpin.isVisible()) { this.handlePin(event, this.tools.unpin, this); } else { this.handleUnpin(event, this.tools.pin, this); } }, /** * Override to the Panel Class createElement method. This method is called by * Panel Class' onRender(). Normally the panel class will create a header in the * *-tc class, to utilize the default box class for styling we'll move the header * inside the *-mc class to utilize Ext.Element.boxMarkup:
##HEADER##
CONTAINER ###############

Title

Message
* @param {Object} name * @param {Object} pnode *///override panel class method: // private createElement : function (name, pnode) { if (this.shiftHeader) { switch (name) { case 'header': //don't create header yet if putting inside mc, do it when tbar is done return; case 'tbar': Ext.ux.window.MessageWindow.superclass.createElement.call(this, 'header', pnode); Ext.ux.window.MessageWindow.superclass.createElement.call(this, name, pnode); return; } } //caught the ones we needed to, call the default implementation Ext.ux.window.MessageWindow.superclass.createElement.call(this, name, pnode); }, //override/disable focus, see above. focus: Ext.emptyFn, /** @private */ getState : function () { return Ext.apply(Ext.ux.window.MessageWindow.superclass.getState.call(this) || {}, this.getBox()); }, /** * Handler for when the message window body is clicked * @param {Object} event The click event. */ handleClick: function (event) { this.fireEvent('click', this, this.msg); this.togglePinState(event); }, /** * Handler for when pin button is clicked * @param {Object} event The click event. * @param {Object} toolEl The tool Element. * @param {Object} panel The host Panel. */ handlePin: function (event, toolEl, panel) { //hide the unpin button toolEl.hide(); //show the pin button this.tools.pin.show(); this.cancelHiding(); this.fireEvent('afterpin', this); }, /** * Handler for when pin button is clicked * @param {Object} event The click event. * @param {Object} toolEl The tool Element. * @param {Object} panel The host Panel. */ handleUnpin: function (event, toolEl, panel) { //hide the pin button toolEl.hide(); //show the unpin button this.tools.unpin.show(); this.hide(); this.fireEvent('afterunpin', this); }, /** * cancel hiding of the window if {@link #autoHide} is true */ cancelHiding: function () { this.addClass('fixed'); if (this.autoHide) { if (this.pinState === 'unpin') { this.task.cancel(); } } //show the pin button this.tools.pin.show(); //make sure the unpin button is hidden this.tools.unpin.hide(); }, //override parent method /** @private */ animHide: function () { //remove the position of this element from the manager this.manager.positions.remove(this.pos); //element to hide and configured Fx var w, fx = this.hideFx || {}; //animate using a proxy instead of actual element if so configured if (fx.useProxy) { w = this.proxy; this.proxy.setOpacity(0.5); this.proxy.show(); var tb = this.getBox(false); this.proxy.setBox(tb); this.el.hide(); Ext.apply(fx, tb); } else { w = this.el; } Ext.applyIf(fx, { block: false,//default for window is true callback: this.afterHide, easing: 'easeOut',//'easeNone'; remove: true, scope: this }); switch (fx.mode) { case 'none': break; case 'slideIn': w[fx.mode]("b", fx); // w.slideIn("b", fx); break; case 'custom': Ext.callback(fx.callback, fx.scope, [this, w, fx]);//callback(cb,scope,args,delay) break; case 'standard': fx.duration = fx.duration || 0.25; fx.opacity = 0; w.shift(fx); break; default: fx.duration = fx.duration || 1; w.ghost("b", fx); break; } }, //override parent method /** @private */ afterShow: function () { Ext.ux.window.MessageWindow.superclass.afterShow.call(this); //if user moves remove from position manager and cancel hiding this.on('move', function(){ //remove the position of this element from the manager this.manager.positions.remove(this.pos); this.cancelHiding(); }, this); if (this.autoHide) { if (this.pinState === 'unpin') { this.task.delay(this.hideFx.delay); } } }, /** * some cleanup still needed this method * sizing / placement issues when height of windows changes * should recalculate placement based on window height */ /** @private */ animShow: function () { //don't update if hovering over message //check if visible so it will show initially if (this.el.isVisible() && this.el.hasClass(this.hoverCls)) { return; } if (this.msgs.length > 1) { this.updateMsg(); } /* //for reference this.el.disableShadow(); this.setPosition(0, 0); delete this.el.lastXY; delete this.el.lastLT; if(this.x === undefined || this.y === undefined){ var xy = this.el.getAlignToXY(this.container, 'c-c'); var pos = this.el.translatePoints(xy[0], xy[1]); this.x = this.x === undefined? pos.left : this.x; this.y = this.y === undefined? pos.top : this.y; } this.el.setLeftTop(this.x, this.y); alignTo : 'tl', alignToXY : [ 5, (this.el.getComputedHeight() * -1) + 5], slideDirection : 'b' console.info('this.el.lastXY',this.el.lastXY); console.info('this.el.lastLT',this.el.lastLT); console.info('this.el.x',this.el.x); console.info('this.el.y',this.el.y); console.info('this.el.getComputedHeight()',this.el.getComputedHeight()); console.log('===='); */ //element to hide and configured Fx var w = this.el, fx = this.showFx || {}; this.origin = this.origin || {}; //apply defaults if not already configured Ext.applyIf(this.origin, { el: Ext.getDoc(), //defaults to document increment: true, //whether to increment position of subsequent messages pos: "br-br",//position to align to (see {@link Ext.Element#alignTo} for more details defaults to "br-br"). offX: -20, //amount to offset horizontally offY: -20, //amount to offset vertically spaY: 5 //vertical spacing between adjacent messages }); //track positions of each instance this.pos = 0; if (this.origin.increment) { while (this.manager.positions.indexOf(this.pos) > -1) { this.pos++; } this.manager.positions.push(this.pos); } var y = this.origin.offY - ((this.getSize().height + this.origin.spaY) * this.pos); //unused t (used for debugging) // var t = this.getSize(); //set the window size this.setSize(this.width || this.minWidth, this.height || this.minHeight); //increment the vertical position of the window if (this.origin.increment) { y = this.origin.offY - ((this.getSize().height + this.origin.spaY) * this.pos); } else { y = 0; } w.alignTo( this.origin.el, // element to align to. this.origin.pos, // position to align to (see {@link Ext.Element#alignTo} for more details). [ this.origin.offX, y ] // Offset the positioning by [x, y]: ); w.slideIn('b', { duration: fx.duration || 1, callback: this.afterShow, scope: this }); }, onMouseout: function () { //console.info('in onMouseout'); //console.info(arguments); }, /** * @param {Object} el * @param {Object} x * @param {Object} y * @private */ positionPanel: function (el, x, y) { if(x && typeof x[1] == 'number'){ y = x[1]; x = x[0]; } el.pageX = x; el.pageY = y; if(x === undefined || y === undefined){ // cannot translate undefined points return; } if(y < 0){ y = 10; } var p = el.translatePoints(x, y); el.setLocation(p.left, p.top); return el; }, /** * Specify the message to be shown * @param {String} msg Message to update the body with. */ setMessage: function (msg) { this.body.update(msg); }, /** * Set the title of the message window * @param {String} title Title of Window * @param {String} iconCls icon to use in header area */ setTitle: function (title, iconCls) { Ext.ux.window.MessageWindow.superclass.setTitle.call(this, title, iconCls || this.iconCls); }, /** * Start recurring messages * @param {Boolean} update Whether to update the message before starting automatic refreshes. */ startAutoRefresh : function(update){ if(update){ this.updateMsg(true); } if(this.autoRefreshProcId){ clearInterval(this.autoRefreshProcId); } // native javascript function to delay for a specified time before triggering the // execution of a specific function. After triggering the called function the command // doesn't complete. Instead it waits for the specified time again and then triggers // the function again and continues to repeat this process of triggering the function // at the specified intervals until either the web page is unloaded or the clearInterval // function is called. this.autoRefreshProcId = setInterval(this.animShow.createDelegate(this, []), this.interval); }, /** * Stop recurring messages */ stopAutoRefresh : function(){ if(this.autoRefreshProcId){ clearInterval(this.autoRefreshProcId); } }, /** * Update the message * @param {String} msg The updated msg */ updateMsg: function (msg) { //don't update if hovering over message if (this.el && !this.el.hasClass(this.hoverCls)) { if (msg) { // console.info('message passed'); } else { this.msgIndex = this.msgs[this.msgIndex + 1] ? this.msgIndex + 1 : 0; this.msg = this.msgs[this.msgIndex]; } //update the innerHTML of element //this.el.dom.update(this.msg.text); this.body.update(this.msg.text); } else { //console.info('hovering'); } } }); //register the xtype Ext.reg('message-window', Ext.ux.window.MessageWindow);/** * Ext.ux.form.XCheckbox - checkbox with configurable submit values * * @author Ing. Jozef Sakalos * @version $Id: Ext.ux.form.XCheckbox.js 313 2008-08-18 18:00:16Z jozo $ * @date 10. February 2008 * * * @license Ext.ux.form.XCheckbox is licensed under the terms of * the Open Source LGPL 3.0 license. Commercial use is permitted to the extent * that the code/component(s) do NOT become part of another Open Source or Commercially * licensed development library or toolkit without explicit permission. * * License details: http://www.gnu.org/licenses/lgpl.html */ /** * @class Ext.ux.XCheckbox * @extends Ext.form.Checkbox */ Ext.ns('Ext.ux.form'); Ext.ux.form.XCheckbox = Ext.extend(Ext.form.Checkbox, { submitOffValue: '0', submitOnValue: '1', onRender: function(){ this.inputValue = this.submitOnValue; // call parent Ext.ux.form.XCheckbox.superclass.onRender.apply(this, arguments); // create hidden field that is submitted if checkbox is not checked this.hiddenField = this.wrap.insertFirst({ tag: 'input', type: 'hidden' }); // support tooltip if (this.tooltip) { this.imageEl.set({ qtip: this.tooltip }); } // update value of hidden field this.updateHidden(); } // eo function onRender /** * Calls parent and updates hiddenField * @private */ , setValue: function(v){ v = this.convertValue(v); this.updateHidden(v); Ext.ux.form.XCheckbox.superclass.setValue.apply(this, arguments); } // eo function setValue /** * Updates hiddenField * @private */ , updateHidden: function(v){ v = undefined !== v ? v : this.checked; v = this.convertValue(v); if (this.hiddenField) { this.hiddenField.dom.value = v ? this.submitOnValue : this.submitOffValue; this.hiddenField.dom.name = v ? '' : this.el.dom.name; } } // eo function updateHidden /** * Converts value to boolean * @private */ , convertValue: function(v){ return (v === true || v === 'true' || v === this.submitOnValue || String(v).toLowerCase() === 'on'); } // eo function convertValue }); // eo extend // register xtype Ext.reg('xcheckbox', Ext.ux.form.XCheckbox); /** * Ext.ux.UploadDialog namespace. */ Ext.namespace('Ext.ux.UploadDialog'); /** * File upload browse button. * * @class Ext.ux.UploadDialog.BrowseButton */ Ext.ux.UploadDialog.BrowseButton = Ext.extend(Ext.Button, { input_name : 'file', input_file : null, original_handler : null, original_scope : null, /** * @access private */ initComponent : function() { Ext.ux.UploadDialog.BrowseButton.superclass.initComponent.call(this); this.original_handler = this.handler || null; this.original_scope = this.scope || window; this.handler = null; this.scope = null; }, /** * @access private */ onRender : function(ct, position) { Ext.ux.UploadDialog.BrowseButton.superclass.onRender.call(this, ct, position); this.createInputFile(); }, /** * @access private */ createInputFile : function() { var button_container = this.el.child('.x-btn-center'); button_container.position('relative'); this.input_file = Ext.DomHelper.append( button_container, { tag: 'input', type: 'file', size: 1, name: this.input_name || Ext.id(this.el), style: 'position: absolute; display: block; border: none; cursor: pointer' }, true ); this.input_file.setOpacity(0.0); this.adjustInputFileBox(); if (this.handleMouseEvents) { this.input_file.on('mouseover', this.onMouseOver, this); this.input_file.on('mousedown', this.onMouseDown, this); } if(this.tooltip){ if(typeof this.tooltip == 'object'){ Ext.QuickTips.register(Ext.apply({target: this.input_file}, this.tooltip)); } else { this.input_file.dom[this.tooltipType] = this.tooltip; } } this.input_file.on('change', this.onInputFileChange, this); this.input_file.on('click', function(e) { e.stopPropagation(); }); }, /** * @access private */ autoWidth : function() { Ext.ux.UploadDialog.BrowseButton.superclass.autoWidth.call(this); this.adjustInputFileBox(); }, /** * @access private */ adjustInputFileBox : function() { var btn_cont, btn_box, inp_box, adj; if (this.el && this.input_file) { btn_cont = this.el.child('.x-btn-center'); btn_box = btn_cont.getBox(); this.input_file.setStyle('font-size', (btn_box.width * 0.5) + 'px'); inp_box = this.input_file.getBox(); adj = {x: 3, y: 3} if (Ext.isIE) { adj = {x: -3, y: 3} } this.input_file.setLeft(btn_box.width - inp_box.width + adj.x + 'px'); this.input_file.setTop(btn_box.height - inp_box.height + adj.y + 'px'); } }, /** * @access public */ detachInputFile : function(no_create) { var result = this.input_file; no_create = no_create || false; if (typeof this.tooltip == 'object') { Ext.QuickTips.unregister(this.input_file); } else { this.input_file.dom[this.tooltipType] = null; } this.input_file.removeAllListeners(); this.input_file = null; if (!no_create) { this.createInputFile(); } return result; }, /** * @access public */ getInputFile : function() { return this.input_file; }, /** * @access public */ disable : function() { Ext.ux.UploadDialog.BrowseButton.superclass.disable.call(this); this.input_file.dom.disabled = true; }, /** * @access public */ enable : function() { Ext.ux.UploadDialog.BrowseButton.superclass.enable.call(this); this.input_file.dom.disabled = false; }, /** * @access public */ destroy : function() { var input_file = this.detachInputFile(true); input_file.remove(); input_file = null; Ext.ux.UploadDialog.BrowseButton.superclass.destroy.call(this); }, /** * @access private */ onInputFileChange : function() { if (this.original_handler) { this.original_handler.call(this.original_scope, this); } } }); /** * Toolbar file upload browse button. * * @class Ext.ux.UploadDialog.TBBrowseButton */ Ext.ux.UploadDialog.TBBrowseButton = Ext.extend(Ext.ux.UploadDialog.BrowseButton, { hideParent : true, onDestroy : function() { Ext.ux.UploadDialog.TBBrowseButton.superclass.onDestroy.call(this); if(this.container) { this.container.remove(); } } });Ext.namespace('oc'); oc.zGrid = function(config){ function recalculateVerteilung(record, combo){ var zIndex = grid.getStore().indexOf(record); if (record.get('Verteilung') == 2) { for (counter = 0; counter < 17; counter++) { grid.getStore().data.items[zIndex].data[String(counter)] = 0; if (counter == combo.getValue()) { grid.getStore().data.items[zIndex].data[String(counter)] = 100; } else { grid.getStore().data.items[zIndex].data[String(counter)] = 0; } } record.set('PCNR', combo.getValue()); } } var renderStore = new oc.storeVerteilung_dropdown; grid1 = this; grid2 = this; var grid = this; var cookie; var save_params; var ztype = config.ztype; var _key; var _table; var record_id; var selectedId; if (config.selectedId) { selectedId = config.selectedId; } else { selectedId = false; } switch (ztype) { case 'personal': cookie = nav_cookie_personal; _key = 'PNR,Jahr'; _table = 'tbl_p_verteilungen'; if (selectedId) { record_id = 'Jahr'; group_field = false; store_baseParams = {}; save_params = {}; } else { record_id = 'PNR'; group_field = 'ProfitCenter'; store_baseParams = {}; save_params = {}; } sort_by = record_id; break; case 'anlagen': cookie = nav_cookie_anlagen; _key = 'ANR,Jahr'; _table = 'tbl_a_verteilungen'; if (selectedId) { record_id = 'Jahr'; group_field = false; store_baseParams = {}; save_params = {}; } else { record_id = 'ANR'; group_field = 'ProfitCenter'; store_baseParams = {}; save_params = {}; } sort_by = record_id; break; case 'erg': function erg_months_j(v){ if (!v) { v = 1; } return Date.getShortMonthName(v - 1); } function erg_months_d(v){ if (!v) { v = 12; } return Date.getShortMonthName(v - 1); } arrayColumn = []; for (monat = 0; monat < 12; monat++) { arrayColumn.push([(monat + 1), Date.getShortMonthName(monat)]); } comboboxStore = new Ext.data.SimpleStore({ fields: ['id', 'display'], data: arrayColumn }); arrayColumn.push([13, 'JAB']); arrayColumn.push(['PlanGuV', 'Plan']); comboboxStore = new Ext.data.SimpleStore({ fields: ['id', 'display'], data: arrayColumn }); edit_von = new Ext.form.ComboBox({ id: 'von', store: comboboxStore, mode: 'local', displayField: 'display', valueField: 'id', width: 150, triggerAction: 'all', editable: false, emptyText: 'Jan' }); edit_bis = new Ext.form.ComboBox({ id: 'bis', store: comboboxStore, mode: 'local', displayField: 'display', valueField: 'id', width: 150, triggerAction: 'all', editable: false, emptyText: 'Dez' }); _key = 'KNR,Jahr'; _table = 'tbl_k_verteilungen'; cookie = nav_cookie_ergebnisse; record_id = 'KNR'; sort_by = 'Reihenfolge'; group_field = false; store_baseParams = {}; save_params = {}; break; } function erg_nachUmsatz(value, metaData, record, rowIndex, colIndex, store){ if (rowIndex % 2 == 1) { metaData.css = 'readOnlyRow_'; } else { metaData.css = 'readOnlyRow'; } if (record.get('Verteilung') == 1) { return ' - '; } if (record.get('Verteilung') == 2) { if (record.get(0) !== 0) { metaData.css = metaData.css + ' attention'; return Ext.util.Format.realpercents(value); } else { return ' - ' } } value = Ext.util.Format.realpercents(value); return value; } function ergDD(value, metaData, record, rowIndex, colIndex, store){ if (record.get('Verteilung') == 2) { metaData.css = 'greenrow_editable'; } else { metaData.css = 'greenrow'; } if (renderStore.getById(value)) { record = renderStore.getById(value); rValue = record.get("Bezeichnung"); if (record.get('Verteilung') == 2) { return '' + rValue + ''; } else { return rValue; } } return "Direkteingabe"; } function pcRenderer(value, metaData, record, rowIndex, colIndex, store){ value = Ext.util.Format.realpercents(value); if (record.get('Verteilung') == 2) { metaData.css = 'greenrow_editable'; } else if (record.get('Verteilung') == 1) { value = '' + value + ''; } else { value = '-'; } return value; } var storeZuordnungen = new Ext.xGroupingStore({ groupField: group_field, sortInfo: { field: sort_by, direction: "ASC" }, proxy: new Ext.data.HttpProxy({ url: 'api.php?a=list&t=' + ztype + '_zuordnungen', method: 'POST', baseParams: { year: cookie.get("current_year") } }), reader: new Ext.data.JsonReader({ root: 'data', id: record_id, totalProperty: 'total' }, [{ name: 'KontoName' }, { name: 'Reihenfolge' }, { name: 'KNR' }, { name: 'full_name' }, { name: 'Name' }, { name: 'Vorname' }, { name: 'Jahr' }, { name: 'ANR' }, { name: 'Nummer' }, { name: 'Verteilung' }, { name: '0', type: "float", e_type: "percent" }, { name: 'PNR', type: 'int' }, { name: 'GKZ' }, { name: 'ProfitCenter' }, { name: 'PCNR' }, { name: '1', type: 'float' }, { name: '2', type: 'float' }, { name: '3', type: 'float' }, { name: '4', type: 'float' }, { name: '5', type: 'float' }, { name: '6', type: 'float' }, { name: '7', type: 'float' }, { name: '8', type: 'float' }, { name: '9', type: 'float' }, { name: '10', type: 'float' }, { name: '11', type: 'float' }, { name: '12', type: 'float' }, { name: '13', type: 'float' }, { name: '14', type: 'float' }, { name: '15', type: 'float' }, { name: '16', type: 'float' }, { name: '17', type: 'float' }]) }); storeZuordnungen.on('load', function(store){ Ext.Ajax.request({ url: 'cm.php?' + (selectedId ? '_LOAD_COLUMNMODEL_FOR_SINGLE_USER_ID=' + selectedId : '_LOAD_COLUMNMODEL_FOR_MULTIPLE_USERS'), method: 'POST', params: { year: cookie.get("current_year"), ztype: ztype, id: selectedId }, success: function(response){ var cm = new Ext.grid.ColumnModel({ columns: eval(response.responseText), isCellEditable: function(col, rowIndex){ // check if cell can be edited at all if (Ext.grid.ColumnModel.prototype.isCellEditable.call(this, col, rowIndex)) { var field = this.getDataIndex(col); if (field == 'PCNR') { return true; } var record = storeZuordnungen.getAt(rowIndex); if (field == '0') { return false; } if (field == 'Verteilung') { return true; } else if (record.get('Verteilung') == 2) { return true; } } else { return false; } } }); grid.reconfigure(grid.getStore(), cm); } }); }); storeZuordnungen.on('update', function(storeZuordnungen, record, action){ function saveRecordOnServer(record){ if ((record.dirty) && (!selectedId) && (ztype !== 'erg')) { function executeSave(jsonData){ Ext.Ajax.request({ url: 'io.php?type=grid&execute=calc_zuordnungen', params: { data: jsonData, key: _key, table: _table, year: cookie.get("current_year") }, success: function(result, request){ var res = Ext.util.JSON.decode(result.responseText); if (res.success == false) { xErrorMessage({ title: 'Server Error! (executeSave)', text: res.errorInfo || result.responseText }); } else { record.commit(); } } }); } var array = new Array(); storeZuordnungen.each(function(record){ if (record.dirty) { array.push(record.data); } }); if (array.length > 0) { var json = Ext.util.JSON.encode(array); executeSave(json); } } else { if (record.modified) { //print_r(record.modified); if (record.modified.Verteilung) { delete (record.modified.Verteilung); } } } } var i = storeZuordnungen.indexOf(record); var modified_id = 'Verteilung'; var zuordnungen = record; var sum = 0; var cm = grid.getColumnModel(); //record.data.Verteilung for (counter = 1; counter < 29; counter++) { if (cm.findColumnIndex(String(counter)) !== -1) { if (record.data[counter]) { sum = sum + Number(zuordnungen.data[counter]); if (record.isModified(counter)) { modified_id = counter; } } } } if (record.isModified('Verteilung')) { delete (record.modified['Verteilung']); if (record.get('Verteilung') == 2) { setAllPCsToNull = function(){ //storeZuordnungen.suspendEvents(); record.beginEdit(); record.set('0', 100); //delete(record.modified['0']); //delete(record.modified['Verteilung']); for (counter = 1; counter < 29; counter++) { if (cm.findColumnIndex(String(counter)) !== -1) { if (record.get('PCNR') == counter) { record.set(String(counter), 100); } else { record.set(String(counter), 0); } } } record.endEdit(); //saveRecordOnServer(record); } setAllPCsToNull(); /* Ext.Msg.show({ title: 'Verteilung', msg: 'Sie haben Prozentual festgelegt ausgewählt. Wollen Sie die prozentuale Verteilung für alle Profitcenter auf 0% setzen ?', buttons: Ext.Msg.YESNO, fn: function(btn){ if (btn == 'yes') { setAllPCsToNull(); } else { saveRecordOnServer(record); } }, animEl: 'elId', icon: Ext.MessageBox.QUESTION }); */ } else { saveRecordOnServer(record); } } else { umsatz = (100 - sum); if (Number(umsatz) < 0) { if (modified_id !== 'Verteilung') { max_value = (umsatz + 100); record.data['0'] = umsatz; } umsatz = 0; } record.data['0'] = umsatz; saveRecordOnServer(record); } }); oc.zGrid.superclass.constructor.call(this, { ztype: this.ztype, title: 'Zuordnungen', clicksToEdit: 1, store: storeZuordnungen, cm: new Ext.grid.ColumnModel({ columns: [{ header: "ProfitCenter", dataIndex: "ProfitCenter" }] }), sm: new Ext.grid.RowSelectionModel({ singleSelect: true }), stripeRows: true, view: new Ext.grid.GroupingView({ groupTextTpl: '{text}', hideGroupedColumn: true, forceFit: (ztype == 'erg' ? true : false) }), header: false, border: false, autoScroll: true }); if (ztype == 'erg') { oc.zGrid.superclass.constructor.call(this, { tbar: [{ text: 'Vorlage laden', iconCls: 'icon-load', handler: function(){ var applyDataWin = new Ext.Window({ id: 'applyDataWin', modal: true, width: 400, height: 200, resizable: false, layout: 'column', title: 'Daten übernehmen für ' + nav_cookie_ergebnisse.get('current_year'), bodyStyle: 'background-color: #fff;', defaults: { width: 400, border: false, xtype: 'panel', frame: false, bodyStyle: 'padding-left: 10px; padding-right: 10px; padding-top: 10px;' }, items: [{ html: 'Bitte wählen Sie das Jahr, das Sie als Vorlage benutzen wollen, aus', width: 385 }, { xtype: 'form', width: 385, items: new Ext.form.ComboBox({ fieldLabel: 'Basisjahr', emptyText: nav_cookie_ergebnisse.get("current_year"), value: nav_cookie_ergebnisse.get("current_year"), name: 'Year', id: 'zYearDD', value: nav_cookie_ergebnisse.get("current_year"), typeAhead: false, editable: false, triggerAction: 'all', store: new Ext.xStore({ proxy: new Ext.data.HttpProxy({ url: 'api.php?a=tabs&t=ergebnisse' }), reader: new Ext.data.JsonReader({ root: 'data' }, [{ name: 'title' }, { name: 'id' }]) }), displayField: 'title', valueField: 'id' }) }, { html: 'Sie können die Zuordnungen entweder zuerst Übernehmen und dann manuell speichern oder direkt Übernehmen und Speichern', height: 75, width: 385 }], buttons: [{ text: 'Übernehmen', //clickEvent: 'load', iconCls: 'icon-defaults', handler: applyDataFromYear }, { text: 'Übernehmen und Speichern', //clickEvent: 'save', iconCls: 'icon-save-table', handler: applyDataFromYear }] }); applyDataWin.show(); } }, '->', { iconCls: 'icon-save-table', text: 'Speichern', handler: function(){ grid.fireEvent('save'); } }] }); applyDataFromYear = function(b, e){ var tWin = Ext.getCmp('applyDataWin'); tWin.getEl().mask('Die Daten werden übernohmmen... Bitte warten Sie'); grid.getStore().load({ params: { year: Ext.getCmp('zYearDD').getValue() }, callback: function(){ grid.getStore().each(function(record){ record.set('Jahr', nav_cookie_ergebnisse.get("current_year")); }); if (b.text !== 'Übernehmen') { grid.fireEvent('save'); } tWin.destroy(); } }); } } if ((!selectedId) && (ztype !== 'erg')) { oc.zGrid.superclass.constructor.call(this, { bbar: new Ext.AdvancedPagingToolbar({ //plugins: new Ext.ux.Andrie.pPageSize(), nav_var: cookie, pageSize: oc.limit_records, store: storeZuordnungen, displayInfo: true, displayMsg: '{0} - {1} von {2}', emptyMsg: "Keine gefunden" }), tbar: ['->', { text: 'MS Excel', iconCls: 'icon-excel', handler: function(){ submitQuery(grid); } }, '-', { text: 'Druckversion', iconCls: 'icon-print', handler: function(){ submitQuery(grid, 'print'); } }] }); } }; Ext.extend(oc.zGrid, Ext.grid.EditorGridPanel, {}); Ext.xStore = Ext.extend(Ext.data.Store, { //method: 'POST', listeners: { loadexception: function(httpProxy, dataObject, arguments, exception){ console.log('** - Data Store listener fired (loadexception), arguments:', arguments); print_r(arguments.responseText); //print_r(this.params); } } }); Ext.xGroupingStore = Ext.extend(Ext.data.GroupingStore, { listeners: { loadexception: function(httpProxy, dataObject, arguments, exception){ console.log('** - Data Store listener fired (loadexception), arguments:', arguments); print_r(arguments.responseText); //print_r(this.params); } } }); function xErrorMessage(conf){ if (!conf.title) conf.title = 'Error!'; if (!conf.text) conf.text = 'UNEXPECTED ERROR'; Ext.Msg.alert(conf.title, conf.text); } Backup = function() { var BackupsDataStore; var BackupsColumnModel; var BackupListingEditorGrid; var BackupListingWindow; var selected_backup; var selected_backup_notes; function jsonDataDecode(stringData) { try { return Ext.util.JSON.decode(stringData); } catch (err) { Ext.MessageBox.alert('Fehler', 'Could not decode ' + stringData); } } function download(file_name) { Ext.DomHelper.append(document.body, { tag: 'iframe', id: 'downloadIframe', frameBorder: 0, width: 0, height: 0, css: 'display:none;visibility:hidden;height:0px;', src: 'modules/admin/sqlbackup-export.php?get=' + file_name }); } function createInfoWindow(backup_name) { var backup_name = (backup_name == null) ? '' : backup_name; var info = new Ext.form.TextArea({ id: 'Info', name: 'info', fieldLabel: 'Info', hideLabel: true, anchor: '100% -1' }); var InfoForm = new Ext.form.FormPanel({ labelAlign: 'absolute', bodyStyle: 'padding:5px', width: 600, url: 'modules/admin/sqlbackup.php', items: [info], buttons: [{ id: 'save', text: 'Speichern', iconCls: 'icon-save-table', // reference to our css handler: function() { saveInfo(info.getValue()); InfoWindow.close(); } }, { text: 'Verwerfen', iconCls: 'icon-cross', // reference to our css handler: function() { InfoWindow.close(); } }], listeners: { render: function() { InfoForm.load({ params: { cmd: "GETBACKUPINFO", backup_name: backup_name } }); } } }); var InfoWindow = new Ext.Window({ id: 'info_window', title: 'Notizen für ' + '"' + backup_name + '"', closable: true, width: 400, height: 250, plain: true, layout: 'fit', modal: true, items: [InfoForm] }); InfoWindow.show(); //Ext.getCmp('Info').focus(false, 1000); } function saveInfo(info) { Ext.Ajax.request({ waitMsg: 'bitte warten ...', url: 'modules/admin/sqlbackup.php', params: { cmd: "SAVEBACKUPINFO", backup_name: selected_backup, info_data: info }, success: function(response) { if (response.responseText != '') { var jsonData = jsonDataDecode(response.responseText); switch (jsonData.success) { case 1: // createInfoWindow( jsonData.name, jsonData.data ); break; default: Ext.MessageBox.alert('Fehler', 'Es ist ein fehler aufgetreten.'); break; } BackupsDataStore.reload(); } else { Ext.MessageBox.alert('Warning', 'Could not save info.'); } }, failure: function(response) { var result = response.responseText; Ext.MessageBox.alert('Fehler', 'Es ist ein fehler aufgetreten.'); } }); } function createBackup() { Ext.Ajax.request({ waitMsg: 'bitte warten ...', url: 'modules/admin/sqlbackup.php', params: { cmd: "CREATEBACKUP" }, success: function(response) { if (response.responseText != '') { var jsonData = jsonDataDecode(response.responseText); switch (jsonData.success) { case 1: selected_backup = jsonData.name; BackupsDataStore.reload(); createInfoWindow(selected_backup); break; default: Ext.MessageBox.alert('Warning', 'Could not create backup!!!'); break; } } else { Ext.MessageBox.alert('Fehler', 'Es ist ein fehler aufgetreten.'); } }, failure: function(response) { var result = response.responseText; Ext.MessageBox.alert('Fehler', 'Es ist ein fehler aufgetreten.'); } }); } function deleteBackup(btn) { if (btn == 'yes') { Ext.Ajax.request({ waitMsg: 'bitte warten ...', url: 'modules/admin/sqlbackup.php', params: { cmd: "DELETEBACKUP", backup_name: selected_backup }, success: function(response) { if (response.responseText != '') { var jsonData = jsonDataDecode(response.responseText); switch (jsonData.success) { case 1: BackupsDataStore.reload(); Ext.MessageBox.alert('', 'Die Datenbank-Kopie wurde erfolgreich gelöscht.'); break; default: Ext.MessageBox.alert('', 'Die Datenbank-Kopie konte nicht gelöscht werden.'); break; } } else { Ext.MessageBox.alert('Fehler', 'Es ist ein fehler aufgetreten.'); } }, failure: function(response) { var result = response.responseText; Ext.MessageBox.alert('Fehler', 'Es ist ein fehler aufgetreten.'); } }); } } function restoreBackup(btn) { if (btn == 'yes') { Ext.Ajax.request({ waitMsg: 'bitte warten ...', url: 'modules/admin/sqlbackup.php', params: { cmd: "RESTOREBACKUP", backup_name: selected_backup, backup_notes: selected_backup_notes }, success: function(response) { if (response.responseText != '') { var jsonData = jsonDataDecode(response.responseText); switch (jsonData.success) { case 1: BackupsDataStore.reload(); Ext.MessageBox.alert('', 'Die Datenbank wurde erfolgreich geladen.
Bitte melden Sie sich erneut an.'); break; default: Ext.MessageBox.alert('', 'Die Datenbank konnte nicht geladen werden.'); break; } } else { Ext.MessageBox.alert('Fehler', 'Es ist ein fehler aufgetreten.'); } }, failure: function(response) { var result = response.responseText; Ext.MessageBox.alert('Fehler', 'Es ist ein fehler aufgetreten.'); } }); } } function backupGrid() { //Ext.QuickTips.init(); deleteRowAction = new Ext.ux.grid.RowAction({ iconCls: 'icon-minus', qtip: 'Backup löschen' }); deleteRowAction.on('action', function(grid, record, action, row, col) { selected_backup = record.data.backup_name; Ext.MessageBox.confirm('Confirm', "Möchten Sie die Datei
" + selected_backup + " wirklich löschen?", deleteBackup); }); infoRowAction = new Ext.ux.grid.RowAction({ iconCls: 'icon-info', qtip: 'Notizen bearbeiten' }); infoRowAction.on('action', function(grid, record, action, row, col) { selected_backup = record.data.backup_name; createInfoWindow(selected_backup); }); saveRowAction = new Ext.ux.grid.RowAction({ iconCls: 'icon-disk', qtip: 'Backup herunterladen' }); saveRowAction.on('action', function(grid, record, action, row, col) { selected_backup = record.data.backup_name; download(selected_backup); }); restoreRowAction = new Ext.ux.grid.RowAction({ iconCls: 'icon-undo', qtip: 'Datenbank auf dem Zustand bringen' }); restoreRowAction.on('action', function(grid, record, action, row, col) { selected_backup = record.data.backup_name; selected_backup_notes = record.data.notes; Ext.MessageBox.confirm('Confirm', "Sind Sie sicher, dass Sie die Datenbank aus der Datei '" + selected_backup + "' neuladen möchten?", restoreBackup); }); BackupsDataStore = new Ext.data.Store({ id: 'BackupsDataStore', proxy: new Ext.data.HttpProxy({ url: 'modules/admin/sqlbackup.php', method: 'POST' }), baseParams: { cmd: "getData" }, // this parameter is passed for any HTTP request reader: new Ext.data.JsonReader({ root: 'data', totalProperty: 'total', id: 'id' }, [{ name: 'backup_name', type: 'string' }, { name: 'notes', type: 'string' }, { name: 'size', type: 'string' }, { name: 'userid', type: 'string' }, { name: 'created', type: 'date', dateFormat: 'Y-m-d H:i:s' }, { name: 'info', type: 'string' }]), sortInfo: { field: 'id', direction: "ASC" }, remoteSort: true }); var BackupsColumnModel = new Ext.grid.ColumnModel([{ header: 'Von', dataIndex: 'created', width: 120, renderer: Ext.util.Format.dateRenderer('d.m.Y H:i'), sortable: true, fixed: true }, { header: 'Benutzername', dataIndex: 'userid', width: 100, sortable: true, hidden: true }, { header: 'Bezeichnung', dataIndex: 'notes', width: 300, sortable: true }, { header: 'Datei', dataIndex: 'backup_name', width: 300, sortable: true }, { header: 'Größe', dataIndex: 'size', width: 110, renderer: Ext.util.Format.bytes, sortable: true, fixed: true, align: 'right' }, infoRowAction, restoreRowAction, saveRowAction, deleteRowAction]); BackupsColumnModel.defaultSortable = true; dialog = new Ext.ux.UploadDialog.Dialog({ url: 'modules/admin/sqlbackup.php', reset_on_hide: true, allow_close_on_upload: true, upload_autostart: true, base_params: { cmd: 'UPLOAD' }, permitted_extensions: ['zip'], listeners: { uploadsuccess: function(dialog, filename, data, record) { BackupsDataStore.reload(); dialog.hide(); } } }); var backupGrid = new Ext.grid.GridPanel({ id: 'BackupListingEditorGrid', store: BackupsDataStore, cm: BackupsColumnModel, border: false, tbar: [{ text: 'Hochladen', iconCls: 'icon-plus', handler: function() { dialog.show('show-button'); //var tb = dialog.grid_panel.getBottomToolbar(); //var add_button = tb.items.items[0]; } }, { text: 'Datenbankzustand speichern', //tooltip: 'Backup database', iconCls: 'icon-clock', // reference to our css handler: function() { createBackup(); } }], stripeRows: true, viewConfig: { forceFit: true }, loadMask: true, selModel: new Ext.grid.RowSelectionModel({ singleSelect: true }), plugins: [new Ext.ux.grid.Search({ iconCls: 'icon-zoom', readonlyIndexes: ['name'], disableIndexes: ['time', 'size', 'userid'], //minChars:1, position: 'top', //menuStyle:'radio', searchText: 'Suche', showSelectAll: false, autoFocus: true, width: 200 }), restoreRowAction, deleteRowAction, infoRowAction, saveRowAction] }); return backupGrid; } //end return return { returnGrid: function() { return backupGrid(); } }; }; /* * ux.Media.ChartPack 2.1.3 * Copyright(c) 2008-2010, Active Group, Inc. * licensing@theactivegroup.com * * http://licensing.theactivegroup.com */ Ext.namespace('Ext.ux.plugin'); Ext.onReady(function(){ var CSS = Ext.util.CSS; if(CSS){ CSS.getRule('.x-hide-nosize') || //already defined? CSS.createStyleSheet('.x-hide-nosize{height:0px!important;width:0px!important;border:none!important;zoom:1;}.x-hide-nosize * {height:0px!important;width:0px!important;border:none!important;zoom:1;}'); CSS.refreshCache(); } }); (function(){ var El = Ext.Element, A = Ext.lib.Anim, supr = El.prototype; var VISIBILITY = "visibility", DISPLAY = "display", HIDDEN = "hidden", NONE = "none"; var fx = {}; fx.El = { setDisplayed : function(value) { var me=this; me.visibilityCls ? (me[value !== false ?'removeClass':'addClass'](me.visibilityCls)) : supr.setDisplayed.call(me, value); return me; }, isDisplayed : function() { return !(this.hasClass(this.visibilityCls) || this.isStyle(DISPLAY, NONE)); }, // private fixDisplay : function(){ var me = this; supr.fixDisplay.call(me); me.visibilityCls && me.removeClass(me.visibilityCls); }, isVisible : function(deep) { var vis = this.visible || (!this.isStyle(VISIBILITY, HIDDEN) && (this.visibilityCls ? !this.hasClass(this.visibilityCls) : !this.isStyle(DISPLAY, NONE)) ); if (deep !== true || !vis) { return vis; } var p = this.dom.parentNode, bodyRE = /^body/i; while (p && !bodyRE.test(p.tagName)) { if (!Ext.fly(p, '_isVisible').isVisible()) { return false; } p = p.parentNode; } return true; }, //Assert isStyle method for Ext 2.x isStyle: supr.isStyle || function(style, val) { return this.getStyle(style) == val; } }; //Add basic capabilities to the Ext.Element.Flyweight class Ext.override(El.Flyweight, fx.El); Ext.ux.plugin.VisibilityMode = function(opt) { Ext.apply(this, opt||{}); var CSS = Ext.util.CSS; if(CSS && !Ext.isIE && this.fixMaximizedWindow !== false && !Ext.ux.plugin.VisibilityMode.MaxWinFixed){ //Prevent overflow:hidden (reflow) transitions when an Ext.Window is maximize. CSS.updateRule ( '.x-window-maximized-ct', 'overflow', ''); Ext.ux.plugin.VisibilityMode.MaxWinFixed = true; //only updates the CSS Rule once. } }; Ext.extend(Ext.ux.plugin.VisibilityMode , Object, { bubble : true, fixMaximizedWindow : true, elements : null, visibilityCls : 'x-hide-nosize', hideMode : 'nosize' , ptype : 'uxvismode', init : function(c) { var hideMode = this.hideMode || c.hideMode, plugin = this, bubble = Ext.Container.prototype.bubble, changeVis = function(){ var els = [this.collapseEl, this.actionMode].concat(plugin.elements||[]); Ext.each(els, function(el){ plugin.extend( this[el] || el ); },this); var cfg = { visFixed : true, animCollapse : false, animFloat : false, hideMode : hideMode, defaults : this.defaults || {} }; cfg.defaults.hideMode = hideMode; Ext.apply(this, cfg); Ext.apply(this.initialConfig || {}, cfg); }; c.on('render', function(){ // Bubble up the layout and set the new // visibility mode on parent containers // which might also cause DOM reflow when // hidden or collapsed. if(plugin.bubble !== false && this.ownerCt){ bubble.call(this.ownerCt, function(){ this.visFixed || this.on('afterlayout', changeVis, this, {single:true} ); }); } changeVis.call(this); }, c, {single:true}); }, extend : function(el, visibilityCls){ el && Ext.each([].concat(el), function(e){ if(e && e.dom){ if('visibilityCls' in e)return; //already applied or defined? Ext.apply(e, fx.El); e.visibilityCls = visibilityCls || this.visibilityCls; } },this); return this; } }); Ext.preg && Ext.preg('uxvismode', Ext.ux.plugin.VisibilityMode ); Ext.provide && Ext.provide('uxvismode'); })(); (function(){ //remove null and undefined members from an object and optionally URL encode the results var compactObj = function(obj, encodeIt){ var out = obj && Ext.isObject(obj)? {} : obj; if(out && Ext.isObject(out)){ for (var member in obj){ (obj[member] === null || obj[member] === undefined) || (out[member] = obj[member]); } } return encodeIt ? ((out && Ext.isObject(out)) ? Ext.urlEncode(out) : encodeURI(out)) : out; }, toString = Object.prototype.toString; Ext.ns('Ext.ux.plugin'); Ext.ux.Media = function(config){ this.toString = this.asMarkup; //Inline rendering support for this and all subclasses Ext.apply(this,config||{}); this.initMedia(); }; var ux = Ext.ux.Media, stateRE = /4$/i; if(parseFloat(Ext.version) < 2.2){ throw "Ext.ux.Media and sub-classes are not License-Compatible with your Ext release.";} Ext.ux.Media.prototype = { hasVisModeFix : !!Ext.ux.plugin.VisibilityMode, mediaObject : null, mediaCfg : null, mediaVersion : null, requiredVersion : null, hideMode : 'display', unsupportedText : null, animCollapse : Ext.enableFx && Ext.isIE, animFloat : Ext.enableFx && Ext.isIE, autoScroll : true, bodyStyle : {position: 'relative'}, initMedia : function(){ this.hasVisModeFix = !!Ext.ux.plugin.VisibilityMode; }, disableCaching : false, _maxPoll : 200, getMediaType: function(type){ return ux.mediaTypes[type]; }, assert : function(v,def){ v= typeof v === 'function'?v.call(v.scope||null):v; return Ext.value(v ,def); }, assertId : function(id, def){ id || (id = def || Ext.id()); return id; }, prepareURL : function(url, disableCaching){ var parts = url ? url.split('#') : ['']; if(!!url && (disableCaching = disableCaching === undefined ? this.disableCaching : disableCaching) ){ var u = parts[0]; if( !(/_dc=/i).test(u) ){ var append = "_dc=" + (new Date().getTime()); if(u.indexOf("?") !== -1){ u += "&" + append; }else{ u += "?" + append; } parts[0] = u; } } return parts.length > 1 ? parts.join('#') : parts[0]; }, prepareMedia : function(mediaCfg, width, height, ct){ mediaCfg = mediaCfg ||this.mediaCfg; if(!mediaCfg){return '';} var m= Ext.apply({url:false,autoSize:false}, mediaCfg); //make a copy m.url = this.prepareURL(this.assert(m.url,false),m.disableCaching); if( m.mediaType){ var value,tag, p, El = Ext.Element.prototype; var media = Ext.apply({}, this.getMediaType(this.assert(m.mediaType,false)) || false ); var params = compactObj(Ext.apply(media.params||{},m.params || {})); for(var key in params){ if(params.hasOwnProperty(key)){ m.children || (m.children = []); p = this.assert(params[key],null); p && (p = compactObj(p, m.encodeParams !== false)); tag = {tag:'param' ,name:key ,value: p }; (tag.value == key) && delete tag.value; p && m.children.push(tag); } } delete media.params; //childNode Text if plugin/object is not installed. var unsup = this.assert(m.unsupportedText|| this.unsupportedText || media.unsupportedText,null); if(unsup){ m.children || (m.children = []); m.children.push(unsup); } if(m.style && typeof m.style != "object") { throw 'Style must be JSON formatted'; } m.style = this.assert(Ext.apply(media.style || {}, m.style || {}) , {}); delete media.style; m.height = this.assert(height || m.height || media.height || m.style.height, null); m.width = this.assert(width || m.width || media.width || m.style.width ,null); m = Ext.apply({tag:'object'},m,media); //Convert element height and width to inline style to avoid issues with display:none; if(m.height || m.autoSize) { Ext.apply(m.style, { //Ext 2 & 3 compatibility -- Use the defaultUnit from the Component's el for default height:(Ext.Element.addUnits || El.addUnits).call(this.mediaEl, m.autoSize ? '100%' : m.height ,El.defaultUnit||'px')}); } if(m.width || m.autoSize) { Ext.apply(m.style, { //Ext 2 & 3 compatibility -- Use the defaultUnit from the Component's el for default width :(Ext.Element.addUnits || El.addUnits).call(this.mediaEl, m.autoSize ? '100%' : m.width ,El.defaultUnit||'px')}); } m.id = this.assertId(m.id); m.name = this.assertId(m.name, m.id); m._macros= { url : m.url || '' ,height : (/%$/.test(m.height)) ? m.height : parseInt(m.height,10)||null ,width : (/%$/.test(m.width)) ? m.width : parseInt(m.width,10)||null ,scripting : this.assert(m.scripting,false) ,controls : this.assert(m.controls,false) ,scale : this.assert(m.scale,1) ,status : this.assert(m.status,false) ,start : this.assert(m.start, false) ,loop : this.assert(m.loop, false) ,volume : this.assert(m.volume, 20) ,id : m.id }; delete m.url; delete m.mediaType; delete m.controls; delete m.status; delete m.start; delete m.loop; delete m.scale; delete m.scripting; delete m.volume; delete m.autoSize; delete m.autoScale; delete m.params; delete m.unsupportedText; delete m.renderOnResize; delete m.disableCaching; delete m.listeners; delete m.height; delete m.width; delete m.encodeParams; return m; }else{ var unsup = this.assert(m.unsupportedText|| this.unsupportedText || media.unsupportedText,null); unsup = unsup ? Ext.DomHelper.markup(unsup): null; return String.format(unsup || 'Media Configuration/Plugin Error',' ',' '); } }, asMarkup : function(mediaCfg){ return this.mediaMarkup(this.prepareMedia(mediaCfg)); }, mediaMarkup : function(mediaCfg){ mediaCfg = mediaCfg || this.mediaCfg; if(mediaCfg){ var _macros = mediaCfg._macros; delete mediaCfg._macros; var m = Ext.DomHelper.markup(mediaCfg); if(_macros){ var _m, n; for ( n in _macros){ _m = _macros[n]; if(_m !== null){ m = m.replace(new RegExp('((%40|@)'+n+')','g'),_m+''); } } } return m; } }, setMask : function(el) { var mm; if((mm = this.mediaMask)){ mm.el || (mm = this.mediaMask = new Ext.ux.IntelliMask(el,Ext.isObject(mm) ? mm : {msg : mm})); mm.el.addClass('x-media-mask'); } }, refreshMedia : function(target){ if(this.mediaCfg) {this.renderMedia(null,target);} return this; }, renderMedia : function(mediaCfg, ct, domPosition , w , h){ if(!Ext.isReady){ Ext.onReady(this.renderMedia.createDelegate(this,Array.prototype.slice.call(arguments,0))); return; } var mc = (this.mediaCfg = mediaCfg || this.mediaCfg) ; ct = Ext.get(this.lastCt || ct || (this.mediaObject?this.mediaObject.dom.parentNode:null)); this.onBeforeMedia.call(this, mc, ct, domPosition , w , h); if(ct){ this.lastCt = ct; if(mc && (mc = this.prepareMedia(mc, w, h, ct))){ this.setMask(ct); this.mediaMask && this.autoMask && this.mediaMask.show(); this.clearMedia().writeMedia(mc, ct, domPosition || 'afterbegin'); } } this.onAfterMedia(ct); }, writeMedia : function(mediaCfg, container, domPosition ){ var ct = Ext.get(container), markup; if(ct){ markup = this.mediaMarkup(mediaCfg) domPosition ? Ext.DomHelper.insertHtml(domPosition, ct.dom, markup) :ct.update(markup); } }, clearMedia : function(){ var mo; if(Ext.isReady && (mo = this.mediaObject)){ mo.remove(true,true); } this.mediaObject = null; return this; }, resizeMedia : function(comp, aw, ah, w, h){ var mc = this.mediaCfg; if(mc && this.rendered && mc.renderOnResize && (!!aw || !!ah)){ // Ext.Window.resizer fires this event a second time if(arguments.length > 3 && (!this.mediaObject || mc.renderOnResize )){ this.refreshMedia(this[this.mediaEl]); } } }, onBeforeMedia : function(mediaCfg, ct, domPosition, width, height){ var m = mediaCfg || this.mediaCfg, mt; if( m && (mt = this.getMediaType(m.mediaType)) ){ m.autoSize = m.autoSize || mt.autoSize===true; var autoSizeEl; //Calculate parent container size for macros (if available) if(m.autoSize && (autoSizeEl = Ext.isReady? //Are we in a layout ? autoSize to the container el. Ext.get(this[this.mediaEl] || this.lastCt || ct) :null) ){ m.height = this.autoHeight ? null : autoSizeEl.getHeight(true); m.width = this.autoWidth ? null : autoSizeEl.getWidth(true); } } this.assert(m.height,height); this.assert(m.width ,width); mediaCfg = m; }, onMediaLoad : function(e){ if(e && e.type == 'load'){ this.fireEvent('mediaload',this, this.mediaObject ); this.mediaMask && this.autoMask && this.mediaMask.hide(); } }, onAfterMedia : function(ct){ var mo; if(this.mediaCfg && ct && (mo = new (this.elementClass || Ext.ux.Media.Element)(ct.child('.x-media', true),true )) && mo.dom ){ //Update ElCache with the new Instance this.mediaObject = mo; mo.ownerCt = this; var L; //Reattach any DOM Listeners after rendering. if(L = this.mediaCfg.listeners ||null){ mo.on(L); //set any DOM listeners } this.fireEvent('mediarender',this, this.mediaObject ); //Load detection for non- media (iframe, img) if(mo.dom.tagName !== 'OBJECT'){ mo.on({ load :this.onMediaLoad ,scope:this ,single:true }); } else { //IE, Opera possibly others, support a readyState on s this._countPoll = 0; this.pollReadyState( this.onMediaLoad.createDelegate(this,[{type:'load'}],0)); } } (this.autoWidth || this.autoHeight) && this.syncSize(); }, pollReadyState : function( cb, readyRE){ var media = this.getInterface(); if(media && 'readyState' in media){ (readyRE || stateRE).test(media.readyState) ? cb() : arguments.callee.defer(10,this,arguments); } }, getInterface : function(){ return this.mediaObject?this.mediaObject.dom||null:null; }, detectVersion : Ext.emptyFn, autoMask : false }; var componentAdapter = { init : function(){ this.getId = function(){ return this.id || (this.id = "media-comp" + (++Ext.Component.AUTO_ID)); }; this.html = this.contentEl = this.items = null; this.initMedia(); //Attach the Visibility Fix (if available) to the current instance if(this.hideMode == 'nosize' && this.hasVisModeFix ){ new Ext.ux.plugin.VisibilityMode({ elements: ['bwrap','mediaEl'], hideMode:'nosize'}).init(this); } //Inline rendering support for this and all subclasses this.toString = this.asMarkup; this.addEvents( 'mediarender', 'mediaload'); }, afterRender : function(ct){ //set the mediaMask this.setMask(this[this.mediaEl] || ct); componentAdapter.setAutoScroll.call(this); this.renderMedia(this.mediaCfg, this[this.mediaEl]); }, beforeDestroy : function(){ this.clearMedia(); Ext.destroy(this.mediaMask, this.loadMask); this.lastCt = this.mediaObject = this.renderTo = this.applyTo = this.mediaMask = this.loadMask = null; }, setAutoScroll : function(){ if(this.rendered){ this.getContentTarget().setOverflow(!!this.autoScroll ? 'auto':'hidden'); } }, getContentTarget : function(){ return this[this.mediaEl]; }, onResize : function(){ if(this.mediaObject && this.mediaCfg.renderOnResize){ this.refreshMedia(); } } }; Ext.ux.Media.Component= Ext.extend ( Ext.BoxComponent, { ctype : "Ext.ux.Media.Component", mediaEl : 'el', autoScroll : true, autoEl : {tag:'div',style : { overflow: 'hidden', display:'block',position: 'relative'}}, cls : "x-media-comp", mediaClass : Ext.ux.Media, constructor : function(config){ //Inherit the ux.Media class Ext.apply(this , config, this.mediaClass.prototype ); ux.Component.superclass.constructor.apply(this, arguments); }, initComponent : function(){ ux.Component.superclass.initComponent.apply(this,arguments); componentAdapter.init.apply(this,arguments); }, afterRender : function(ct){ ux.Component.superclass.afterRender.apply(this,arguments); componentAdapter.afterRender.apply(this,arguments); }, beforeDestroy : function(){ componentAdapter.beforeDestroy.apply(this,arguments); this.rendered && ux.Component.superclass.beforeDestroy.apply(this,arguments); }, doAutoLoad : Ext.emptyFn, getContentTarget : componentAdapter.getContentTarget, //Ext 2.x does not have Box setAutoscroll setAutoScroll : componentAdapter.setAutoScroll, onResize : function(){ ux.Component.superclass.onResize.apply(this,arguments); componentAdapter.onResize.apply(this,arguments); } }); Ext.reg('uxmedia', Ext.ux.Media.Component); Ext.reg('media', Ext.ux.Media.Component); Ext.ux.Media.Panel = Ext.extend( Ext.Panel, { cls : "x-media-panel", ctype : "Ext.ux.Media.Panel", autoScroll : false, mediaEl : 'body', mediaClass : Ext.ux.Media, constructor : function(config){ //Inherit the ux.Media class Ext.apply(this , this.mediaClass.prototype ); ux.Panel.superclass.constructor.apply(this, arguments); }, initComponent : function(){ ux.Panel.superclass.initComponent.apply(this,arguments); componentAdapter.init.apply(this,arguments); }, afterRender : function(ct){ ux.Panel.superclass.afterRender.apply(this,arguments); componentAdapter.afterRender.apply(this,arguments); }, beforeDestroy : function(){ componentAdapter.beforeDestroy.apply(this,arguments); this.rendered && ux.Panel.superclass.beforeDestroy.apply(this,arguments); }, doAutoLoad : Ext.emptyFn, getContentTarget : componentAdapter.getContentTarget, setAutoScroll : componentAdapter.setAutoScroll, onResize : function(){ ux.Panel.superclass.onResize.apply(this,arguments); componentAdapter.onResize.apply(this,arguments); } }); Ext.reg('mediapanel', Ext.ux.Media.Panel); Ext.ux.Media.Portlet = Ext.extend ( Ext.ux.Media.Panel , { anchor : '100%', frame : true, collapseEl : 'bwrap', collapsible : true, draggable : true, autoWidth : true, ctype : "Ext.ux.Media.Portlet", cls : 'x-portlet x-media-portlet' }); Ext.reg('mediaportlet', Ext.ux.Media.Portlet); Ext.ux.Media.Window = Ext.extend( Ext.Window ,{ constructor : function(){ Ext.applyIf(this , this.mediaClass.prototype ); ux.Window.superclass.constructor.apply(this, arguments); }, cls : "x-media-window", autoScroll : false, ctype : "Ext.ux.Media.Window", mediaClass : Ext.ux.Media, mediaEl : 'body', initComponent : function(){ ux.Window.superclass.initComponent.apply(this,arguments); componentAdapter.init.apply(this,arguments); }, afterRender : function(){ ux.Window.superclass.afterRender.apply(this,arguments); //wait for sizing componentAdapter.afterRender.apply(this,arguments); }, beforeDestroy : function(){ componentAdapter.beforeDestroy.apply(this,arguments); this.rendered && ux.Window.superclass.beforeDestroy.apply(this,arguments); }, doAutoLoad : Ext.emptyFn, getContentTarget : componentAdapter.getContentTarget, setAutoScroll : componentAdapter.setAutoScroll, onResize : function(){ ux.Window.superclass.onResize.apply(this,arguments); componentAdapter.onResize.apply(this,arguments); } }); Ext.reg('mediawindow', ux.Window); Ext.ns('Ext.capabilities'); Ext.ns('Ext.ux.Media.plugin'); var CAPS = (Ext.capabilities.hasAudio || (Ext.capabilities.hasAudio = function(){ var aTag = !!document.createElement('audio').canPlayType, aAudio = ('Audio' in window) ? new Audio('') : {}, caps = aTag || ('canPlayType' in aAudio) ? { tag : aTag, object : ('play' in aAudio)} : false, mime, chk, mimes = { mp3 : 'audio/mpeg', //mp3 ogg : 'audio/ogg', //Ogg Vorbis wav : 'audio/x-wav', //wav basic : 'audio/basic', //au, snd aif : 'audio/x-aiff' //aif, aifc, aiff }; if(caps && ('canPlayType' in aAudio)){ for (chk in mimes){ caps[chk] = (mime = aAudio.canPlayType(mimes[chk])) != 'no' && (mime != ''); } } return caps; }())); Ext.iterate || Ext.apply (Ext, { iterate : function(obj, fn, scope){ if(Ext.isEmpty(obj)){ return; } if(Ext.isIterable(obj)){ Ext.each(obj, fn, scope); return; }else if(Ext.isObject(obj)){ for(var prop in obj){ if(obj.hasOwnProperty(prop)){ if(fn.call(scope || obj, prop, obj[prop], obj) === false){ return; }; } } } }, 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 ((v.nextNode || v.item) && Ext.isNumber(v.length)); }, isObject : function(obj){ return !!obj && toString.apply(obj) == '[object Object]'; } }); Ext.ux.Media.plugin.AudioEvents = Ext.extend(Ext.ux.Media.Component,{ autoEl : {tag:'div' }, cls: 'x-hide-offsets', disableCaching : false, audioEvents : {}, volume : .5, ptype : 'audioevents', initComponent : function(){ this.mediaCfg || (this.mediaCfg = { mediaType : 'WAV', start : true, url : '' }); Ext.ux.Media.plugin.AudioEvents.superclass.initComponent.apply(this,arguments); this.addEvents( 'beforeaudio'); this.setVolume(this.volume); }, init : function( target ){ this.rendered || this.render(Ext.getBody()); if(target.dom || target.ctype){ var plugin = this; Ext.iterate(this.audioEvents || {}, function(event){ if(target.events && !target.events[event]) return; Ext.applyIf(target, { audioPlugin : plugin, audioListeners : {}, removeAudioListener : function(audioEvent){ if(audioEvent && this.audioListeners[audioEvent]){ this.removeListener && this.removeListener(audioEvent, this.audioListeners[audioEvent], this); delete this.audioListeners[audioEvent]; } }, removeAudioListeners : function(){ var c = []; Ext.iterate(this.audioListeners, function(audioEvent){c.push(audioEvent)}); Ext.iterate(c, this.removeAudioListener, this); }, addAudioListener : function(audioEvent){ if(this.audioListeners[audioEvent]){ this.removeAudioListener(audioEvent); } this.addListener && this.addListener (audioEvent, this.audioListeners[audioEvent] = function(){ this.audioPlugin.onEvent(this, audioEvent); }, this); } , enableAudio : function(){ this.audioPlugin && this.audioPlugin.enable(); }, disableAudio : function(){ this.audioPlugin && this.audioPlugin.disable(); }, setVolume : function(volume){ this.audioPlugin && this.audioPlugin.setVolume(volume); } }); target.addAudioListener(event); },this); } }, setVolume : function(volume){ var AO = this.audioObject, v = Math.max(Math.min(parseFloat(volume)||0, 1),0); this.mediaCfg && (this.mediaCfg.volume = v*100); this.volume = v; AO && (AO.volume = v); return this; }, onEvent : function(comp, event){ if(!this.disabled && this.audioEvents && this.audioEvents[event]){ if(this.fireEvent('beforeaudio',this, comp, event) !== false ){ this.mediaCfg.url = this.audioEvents[event]; if(CAPS.object){ //HTML5 Audio support? this.audioObject && this.audioObject.stop && this.audioObject.stop(); if(this.audioObject = new Audio(this.mediaCfg.url || '')){ this.setVolume(this.volume); this.audioObject.play && this.audioObject.play(); } } else { var O = this.getInterface(); if(O){ if(O.object){ //IE ActiveX O= O.object; ('Open' in O) && O.Open(this.mediaCfg.url || ''); ('Play' in O) && O.Play(); }else { //All Others - just rerender the tag this.refreshMedia(); } } } } } } }); Ext.preg && Ext.preg('audioevents', Ext.ux.Media.plugin.AudioEvents); Ext.onReady(function(){ //Generate CSS Rules if not defined in markup var CSS = Ext.util.CSS, rules=[]; CSS.getRule('.x-media', true) || (rules.push('.x-media{width:100%;height:100%;outline:none;overflow:hidden;}')); CSS.getRule('.x-media-mask') || (rules.push('.x-media-mask{width:100%;height:100%;overflow:hidden;position:relative;zoom:1;}')); //default Rule for IMG: h/w: auto; CSS.getRule('.x-media-img') || (rules.push('.x-media-img{background-color:transparent;width:auto;height:auto;position:relative;}')); // Add the new masking rule if not present. CSS.getRule('.x-masked-relative') || (rules.push('.x-masked-relative{position:relative!important;}')); if(!!rules.length){ CSS.createStyleSheet(rules.join('')); CSS.refreshCache(); } }); Ext.ux.Media.Element = Ext.extend ( Ext.Element , { constructor : function( element ) { Ext.ux.Media.Element.superclass.constructor.apply(this, arguments); if(Ext.elCache){ //Ext 3.1 compat Ext.elCache[this.id] || (Ext.elCache[this.id] = { events : {}, data : {} }); Ext.elCache[this.id].el = this; }else { Ext.Element.cache[this.id] = this; } }, mask : function(msg, msgCls){ this.maskEl || (this.maskEl = this.parent('.x-media-mask') || this.parent()); return this.maskEl.mask.apply(this.maskEl, arguments); }, unmask : function(remove){ if(this.maskEl){ this.maskEl.unmask(remove); this.maskEl = null; } }, remove : function(cleanse, deep){ if(this.dom){ this.unmask(true); this.removeAllListeners(); //remove any Ext-defined DOM listeners Ext.ux.Media.Element.superclass.remove.apply(this,arguments); this.dom = null; //clear ANY DOM references } } }); Ext.ux.Media.prototype.elementClass = Ext.ux.Media.Element; Ext.ux.IntelliMask = function(el, config){ Ext.apply(this, config || {msg : this.msg}); this.el = Ext.get(el); }; Ext.ux.IntelliMask.prototype = { removeMask : false, msg : 'Loading Media...', msgCls : 'x-mask-loading', zIndex : null, disabled: false, active: false, autoHide: false, disable : function(){ this.disabled = true; }, enable : function(){ this.disabled = false; }, show: function(msg, msgCls, fn, fnDelay ){ var opt={}, autoHide = this.autoHide; fnDelay = parseInt(fnDelay,10) || 20; //ms delay to allow mask to quiesce if fn specified if(Ext.isObject(msg)){ opt = msg; msg = opt.msg; msgCls = opt.msgCls; fn = opt.fn; autoHide = typeof opt.autoHide != 'undefined' ? opt.autoHide : autoHide; fnDelay = opt.fnDelay || fnDelay ; } if(!this.active && !this.disabled && this.el){ var mask = this.el.mask(msg || this.msg, msgCls || this.msgCls); this.active = !!this.el._mask; if(this.active){ if(this.zIndex){ this.el._mask.setStyle("z-index", this.zIndex); if(this.el._maskMsg){ this.el._maskMsg.setStyle("z-index", this.zIndex+1); } } } } else {fnDelay = 0;} //passed function is called regardless of the mask state. if(typeof fn === 'function'){ fn.defer(fnDelay ,opt.scope || null); } else { fnDelay = 0; } if(autoHide && (autoHide = parseInt(autoHide , 10)||2000)){ this.hide.defer(autoHide+(fnDelay ||0),this ); } return this.active? {mask: this.el._mask , maskMsg: this.el._maskMsg} : null; }, hide: function(remove){ if(this.el){ this.el.unmask(remove || this.removeMask); } this.active = false; return this; }, // private destroy : function(){this.hide(true); this.el = null; } }; Ext.ux.Media.mediaTypes = { WAV : Ext.apply( { tag : 'object' ,cls : 'x-media x-media-wav' ,data : "@url" ,type : 'audio/x-wav' ,loop : false ,params : { filename : "@url" ,displaysize : 0 ,autostart : '@start' ,showControls : '@controls' ,showStatusBar: false ,showaudiocontrols : '@controls' ,stretchToFit : false ,Volume : "@volume" ,PlayCount : 1 } },Ext.isIE?{ classid :"CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" //default for WMP installed w/Windows ,codebase:"http" + ((Ext.isSecure) ? 's' : '') + "://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ,type:'application/x-oleobject' }: {src:"@url"}), PDF : Ext.apply({ //Acrobat plugin thru release 8.0 all crash FF3 tag : 'object' ,cls : 'x-media x-media-pdf' ,type : "application/pdf" ,data : "@url" ,autoSize:true ,params : { src : "@url"} },Ext.isIE?{ classid :"CLSID:CA8A9780-280D-11CF-A24D-444553540000" }:false), PDFFRAME : { tag : 'iframe' ,cls : 'x-media x-media-pdf-frame' ,frameBorder : 0 ,style : { 'z-index' : 2} ,src : "@url" ,autoSize :true }, WMV : Ext.apply( {tag :'object' ,cls : 'x-media x-media-wmv' ,type : 'application/x-mplayer2' //,type : "video/x-ms-wmv" ,data : "@url" ,autoSize : true ,params : { filename : "@url" ,displaysize : 0 ,autostart : "@start" ,showControls : "@controls" ,showStatusBar: "@status" ,showaudiocontrols : true ,stretchToFit : true ,Volume :"@volume" ,PlayCount : 1 } },Ext.isIE?{ classid :"CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" //default for WMP installed w/Windows ,codebase:"http" + ((Ext.isSecure) ? 's' : '') + "://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ,type:'application/x-oleobject' }: {src:"@url"} ), APPLET : { tag :'object' ,cls : 'x-media x-media-applet' ,type : 'application/x-java-applet' ,unsupportedText : {tag : 'p', html:'Java is not installed/enabled.'} ,params : { url : '@url', archive : '', //the jar file code : '' //the Java class } }, "AUDIO-OGG" : { tag : 'audio', controls : '@controls', src : '@url' }, "VIDEO-OGG" : { tag : 'video', controls : '@controls', src : '@url' }, SWF : Ext.apply({ tag :'object' ,cls : 'x-media x-media-swf' ,type : 'application/x-shockwave-flash' ,scripting: 'sameDomain' ,standby : 'Loading..' ,loop : true ,start : false ,unsupportedText : {cn:['The Adobe Flash Player is required.',{tag:'br'},{tag:'a',cn:[{tag:'img',src:'http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif'}],href:'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash',target:'_flash'}]} ,params : { movie : "@url" ,menu : "@controls" ,play : "@start" ,quality : "high" ,allowscriptaccess : "@scripting" ,allownetworking : 'all' ,allowfullScreen : false ,bgcolor : "#FFFFFF" ,wmode : "opaque" ,loop : "@loop" } },Ext.isIE? {classid :"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", codebase:"http" + ((Ext.isSecure) ? 's' : '') + "://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" }: {data : "@url"}), SCRIBD : Ext.apply({ tag :'object' ,cls : 'x-media x-media-scribd' ,type : 'application/x-shockwave-flash' ,scripting: 'always' ,standby : 'Loading..' ,loop : true ,start : false ,unsupportedText : {cn:['The Adobe Flash Player is required.',{tag:'br'},{tag:'a',cn:[{tag:'img',src:'http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif'}],href:'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash',target:'_flash'}]} ,params : { movie : "@url" ,menu : "@controls" ,play : "@start" ,quality : "high" ,menu : true ,scale : 'showall' ,salign : ' ' ,allowscriptaccess : "@scripting" ,allownetworking : 'all' ,allowfullScreen : true ,bgcolor : "#FFFFFF" ,wmode : "opaque" ,loop : "@loop" } },Ext.isIE? {classid :"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", codebase:"http" + ((Ext.isSecure) ? 's' : '') + "://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" }: {data : "@url"}), JWP : Ext.apply({ tag :'object' ,cls : 'x-media x-media-swf x-media-flv' ,type : 'application/x-shockwave-flash' ,data : "@url" ,loop : false ,start : false //ExternalInterface bindings ,boundExternals : ['sendEvent' , 'addModelListener', 'addControllerListener', 'addViewListener', 'getConfig', 'getPlaylist'] ,params : { movie : "@url" ,flashVars : { autostart:'@start' ,repeat :'@loop' ,height :'@height' ,width :'@width' ,id :'@id' } } },Ext.isIE?{ classid :"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ,codebase:"http" + ((Ext.isSecure) ? 's' : '') + "://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" }:false), QT : Ext.apply({ tag : 'object' ,cls : 'x-media x-media-quicktime' ,type : "video/quicktime" ,style : {position:'relative',"z-index":1 ,behavior:'url(#qt_event_source)'} ,scale : 'aspect' // ( .5, 1, 2 , ToFit, Aspect ) ,unsupportedText : 'Get QuickTime' ,scripting : true ,volume : '50%' //also 0-255 ,data : '@url' ,params : { src : Ext.isIE?'@url': null ,href : "http://quicktime.com" ,target : "_blank" ,autoplay : "@start" ,targetcache : true ,cache : true ,wmode : 'opaque' ,controller : "@controls" ,enablejavascript : "@scripting" ,loop : '@loop' ,scale : '@scale' ,volume : '@volume' ,QTSRC : '@url' } },Ext.isIE? { classid :'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' ,codebase :"http" + ((Ext.isSecure) ? 's' : '') + '://www.apple.com/qtactivex/qtplugin.cab#version=7,2,1,0' }: { PLUGINSPAGE : "http://www.apple.com/quicktime/download/" }), QTEVENTS : { tag : 'object' ,id : 'qt_event_source' ,cls : 'x-media x-media-qtevents' ,type : "video/quicktime" ,params : {} ,classid :'clsid:CB927D12-4FF7-4a9e-A169-56E4B8A75598' ,codebase :"http" + ((Ext.isSecure) ? 's' : '') + '://www.apple.com/qtactivex/qtplugin.cab#version=7,2,1,0' }, WPMP3 : Ext.apply({ tag : 'object' ,cls : 'x-media x-media-audio x-media-wordpress' ,type : 'application/x-shockwave-flash' ,data : '@url' ,start : true ,loop : false ,boundExternals : ['open','close','setVolume','load'] ,params : { movie : "@url" ,width :'@width' //required ,flashVars : { autostart : "@start" ,controller : "@controls" ,enablejavascript : "@scripting" ,loop :'@loop' ,scale :'@scale' ,initialvolume:'@volume' ,width :'@width' //required ,encode : 'no' //mp3 urls will be encoded ,soundFile : '' //required } } },Ext.isIE?{classid :"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"}:false), REAL : Ext.apply({ tag :'object' ,cls : 'x-media x-media-real' ,type : "audio/x-pn-realaudio-plugin" ,data : "@url" ,controls: 'all' ,start : -1 ,standby : "Loading Real Media Player components..." ,params : { src : "@url" ,autostart : "@start" ,center : false ,maintainaspect : true ,prefetch : false ,controller : "@controls" ,controls : "@controls" ,volume :'@volume' ,loop : "@loop" ,numloop : null ,shuffle : false ,console : "_master" ,backgroundcolor : '#000000' } },Ext.isIE?{classid :"clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA"}:false), SVG : { tag : 'object' ,cls : 'x-media x-media-img x-media-svg' ,type : "image/svg+xml" ,data : "@url" ,params : { src : "@url"} }, GIF : { tag : 'img' ,cls : 'x-media x-media-img x-media-gif' ,src : "@url" }, TIFF : { tag : 'object' ,type : "image/tiff" ,cls : 'x-media x-media-img x-media-tiff' ,data : "@url" }, JPEG : { tag : 'img' ,cls : 'x-media x-media-img x-media-jpeg' //,style : {overflow:'hidden', display:'inline'} ,src : "@url" }, JP2 :{ tag : 'object' ,cls : 'x-media x-media-img x-media-jp2' ,type : Ext.isIE ? "image/jpeg2000-image" : "image/jp2" ,data : "@url" }, PNG : { tag : 'img' ,cls : 'x-media x-media-img x-media-png' ,src : "@url" }, HTM : { tag : 'iframe' ,cls : 'x-media x-media-html' ,frameBorder : 0 ,autoSize : true ,style : {overflow:'auto', 'z-index' : 2} ,src : "@url" }, TXT : { tag : 'object' ,cls : 'x-media x-media-text' ,type : "text/plain" ,style : {overflow:'auto',width:'100%',height:'100%'} ,data : "@url" }, RTF : { tag : 'object' ,cls : 'x-media x-media-rtf' ,type : "application/rtf" ,style : {overflow:'auto',width:'100%',height:'100%'} ,data : "@url" }, JS : { tag : 'object' ,cls : 'x-media x-media-js' ,type : "text/javascript" ,style : {overflow:'auto',width:'100%',height:'100%'} ,data : "@url" }, CSS : { tag : 'object' ,cls : 'x-media x-media-css' ,type : "text/css" ,style : {overflow:'auto',width:'100%',height:'100%'} ,data : "@url" }, SILVERLIGHT : { tag : 'object' ,cls : 'x-media x-media-silverlight' ,type :"application/ag-plugin" ,data : "@url" ,params : { MinRuntimeVersion: "1.0" , source : "@url" } }, SILVERLIGHT2 : { tag : 'object' ,cls : 'x-media x-media-silverlight' ,type :"application/x-silverlight-2" ,data : "data:application/x-silverlight," ,params : { MinRuntimeVersion: "2.0" } ,unsupportedText: 'Get Microsoft Silverlight' }, XML : { tag : 'iframe' ,cls : 'x-media x-media-xml' ,style : {overflow:'auto'} ,src : "@url" }, //VLC ActiveX Player -- Suffers the same fate as the Acrobat ActiveX Plugin VLC : Ext.apply({ tag : 'object' ,cls : 'x-media x-media-vlc' ,type : "application/x-google-vlc-plugin" ,pluginspage:"http://www.videolan.org" ,events : true ,start : false ,params : { Src : "@url" ,MRL : "@url" ,autoplay : "@start" ,ShowDisplay: "@controls" ,Volume : '@volume' ,Autoloop : "@loop" } },Ext.isIE?{ classid :"clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" ,CODEBASE :"http" + ((Ext.isSecure) ? 's' : '') + "://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab" }:{target : '@url'}), ODT : Ext.apply({ tag : 'object' ,cls : 'x-media x-media-odt' ,type : "application/vnd.oasis.opendocument.text" ,data : "@url" ,params : { src : '@url' } },Ext.isIE?{ classid :"clsid:67F2A879-82D5-4A6D-8CC5-FFB3C114B69D" }:false), ODS : Ext.apply({ tag : 'object' ,cls : 'x-media x-media-odt' ,type : "application/vnd.oasis.opendocument.spreadsheet" ,data : "@url" ,params : { src : '@url' } },Ext.isIE?{ classid :"clsid:67F2A879-82D5-4A6D-8CC5-FFB3C114B69D" }:false), IMPRESS : Ext.apply({ tag : 'object' ,cls : 'x-media x-media-sxi' ,start : false ,type : "application/vnd.sun.xml.impress" ,data : "@url" ,params : { wmode : 'transparent', src : Ext.isIE ? '@url' : null } },Ext.isIE?{ classid :"clsid:67F2A879-82D5-4A6D-8CC5-FFB3C114B69D" }:{ data : "@url" }) }; if (Ext.provide) { Ext.provide('uxmedia'); } Ext.applyIf(Array.prototype, { map : function(fun, scope) { var len = this.length; if (typeof fun != "function") { throw new TypeError(); } var res = new Array(len); for (var i = 0; i < len; i++) { if (i in this) { res[i] = fun.call(scope || this, this[i], i, this); } } return res; } }); Ext.ux.MediaComponent = Ext.ux.Media.Component; Ext.ux.MediaPanel = Ext.ux.Media.Panel; Ext.ux.MediaPortlet = Ext.ux.Media.Portlet; Ext.ux.MediaWindow = Ext.ux.Media.Window; })(); (function(){ var ux = Ext.ux.Media; Ext.ux.Media.Flash = Ext.extend( Ext.ux.Media, { varsName :'flashVars', externalsNamespace : null, mediaType: Ext.apply({ tag : 'object' ,cls : 'x-media x-media-swf' ,type : 'application/x-shockwave-flash' ,loop : null ,style : {'z-index':0} ,scripting: "sameDomain" ,start : true ,unsupportedText : {cn:['The Adobe Flash Player{0}is required.',{tag:'br'},{tag:'a',cn:[{tag:'img',src:'http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif'}],href:'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash',target:'_flash'}]} ,params : { movie : "@url" ,play : "@start" ,loop : "@loop" ,menu : "@controls" ,quality : "high" ,bgcolor : "#FFFFFF" ,wmode : "opaque" ,allowscriptaccess : "@scripting" ,allowfullscreen : false ,allownetworking : 'all' } },Ext.isIE? {classid :"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", codebase:"http" + ((Ext.isSecure) ? 's' : '') + "://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" }: {data : "@url"}), getMediaType: function(){ return this.mediaType; }, assertId : function(id, def){ id || (id = def || Ext.id()); return id.replace(/\+|-|\\|\/|\*/g,''); }, initMedia : function(){ ux.Flash.superclass.initMedia.call(this); var mc = Ext.apply({}, this.mediaCfg||{}); var requiredVersion = (this.requiredVersion = mc.requiredVersion || this.requiredVersion|| false ) ; var hasFlash = !!(this.playerVersion = this.detectFlashVersion()); var hasRequired = hasFlash && (requiredVersion?this.assertVersion(requiredVersion):true); var unsupportedText = this.assert(mc.unsupportedText || this.unsupportedText || (this.getMediaType()||{}).unsupportedText,null); if(unsupportedText){ unsupportedText = Ext.DomHelper.markup(unsupportedText); unsupportedText = mc.unsupportedText = String.format(unsupportedText, (requiredVersion?' '+requiredVersion+' ':' '), (this.playerVersion?' '+this.playerVersion+' ':' Not installed.')); } mc.mediaType = "SWF"; if(!hasRequired ){ this.autoMask = false; //Version check for the Flash Player that has the ability to start Player Product Install (6.0r65) var canInstall = hasFlash && this.assertVersion('6.0.65'); if(canInstall && mc.installUrl){ mc = mc.installDescriptor || { mediaType : 'SWF' ,tag : 'object' ,cls : 'x-media x-media-swf x-media-swfinstaller' ,id : 'SWFInstaller' ,type : 'application/x-shockwave-flash' ,data : "@url" ,url : this.prepareURL(mc.installUrl) //The dimensions of playerProductInstall.swf must be at least 310 x 138 pixels, ,width : (/%$/.test(mc.width)) ? mc.width : ((parseInt(mc.width,10) || 0) < 310 ? 310 :mc.width) ,height : (/%$/.test(mc.height))? mc.height :((parseInt(mc.height,10) || 0) < 138 ? 138 :mc.height) ,loop : false ,start : true ,unsupportedText : unsupportedText ,params:{ quality : "high" ,movie : '@url' ,allowscriptacess : "always" ,wmode : "opaque" ,align : "middle" ,bgcolor : "#3A6EA5" ,pluginspage : mc.pluginsPage || this.pluginsPage || "http://www.adobe.com/go/getflashplayer" } }; mc.params[this.varsName] = "MMredirectURL="+( mc.installRedirect || window.location)+ "&MMplayerType="+(Ext.isIE?"ActiveX":"Plugin")+ "&MMdoctitle="+(document.title = document.title.slice(0, 47) + " - Flash Player Installation"); } else { //Let superclass handle with unsupportedText property mc.mediaType=null; } } if(mc.eventSynch){ mc.params || (mc.params = {}); var vars = mc.params[this.varsName] || (mc.params[this.varsName] = {}); if(typeof vars === 'string'){ vars = Ext.urlDecode(vars,true); } var eventVars = (mc.eventSynch === true ? { allowedDomain : vars.allowedDomain || document.location.hostname ,elementID : mc.id || (mc.id = Ext.id()) ,eventHandler : 'Ext.ux.Media.Flash.eventSynch' }: mc.eventSynch ); Ext.apply(mc.params,{ allowscriptaccess : 'always' })[this.varsName] = Ext.applyIf(vars,eventVars); } this.bindExternals(mc.boundExternals); delete mc.requiredVersion; delete mc.installUrl; delete mc.installRedirect; delete mc.installDescriptor; delete mc.eventSynch; delete mc.boundExternals; this.mediaCfg = mc; }, assertVersion : function(versionMap){ var compare; versionMap || (versionMap = []); if(Ext.isArray(versionMap)){ compare = versionMap; } else { compare = String(versionMap).split('.'); } compare = (compare.concat([0,0,0,0])).slice(0,3); //normalize var tpv; if(!(tpv = this.playerVersion || (this.playerVersion = this.detectFlashVersion()) )){ return false; } if (tpv.major > parseFloat(compare[0])) { return true; } else if (tpv.major == parseFloat(compare[0])) { if (tpv.minor > parseFloat(compare[1])) {return true;} else if (tpv.minor == parseFloat(compare[1])) { if (tpv.rev >= parseFloat(compare[2])) { return true;} } } return false; }, detectFlashVersion : function(){ if(ux.Flash.prototype.flashVersion ){ return this.playerVersion = ux.Flash.prototype.flashVersion; } var version=false; var formatVersion = function(version){ return version && !!version.length? {major:version[0] !== null? parseInt(version[0],10): 0 ,minor:version[1] !== null? parseInt(version[1],10): 0 ,rev :version[2] !== null? parseInt(version[2],10): 0 ,toString : function(){return this.major+'.'+this.minor+'.'+this.rev;} }:false; }; var sfo= null; if(Ext.isIE){ try{ sfo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); }catch(e){ try { sfo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); version = [6,0,21]; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this solution) sfo.allowscriptaccess = "always"; } catch(ex) { if(version && version[0] === 6) {return formatVersion(version); } } try { sfo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); } catch(ex1) {} } if (sfo) { version = sfo.GetVariable("$version").split(" ")[1].split(","); } }else if(navigator.plugins && navigator.mimeTypes.length){ sfo = navigator.plugins["Shockwave Flash"]; if(sfo && sfo.description) { version = sfo.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."); } } return (this.playerVersion = ux.Flash.prototype.flashVersion = formatVersion(version)); } ,onAfterMedia : function(ct){ ux.Flash.superclass.onAfterMedia.apply(this,arguments); var mo; if(mo = this.mediaObject){ var id = mo.id; if(Ext.isIE ){ //fscommand bindings //implement a fsCommand event interface since its not supported on IE when writing innerHTML if(!(Ext.query('script[for='+id+']').length)){ writeScript('var c;if(c=Ext.getCmp("'+this.id+'")){c.onfsCommand.apply(c,arguments);}', {event:"FSCommand", htmlFor:id}); } }else{ window[id+'_DoFSCommand'] || (window[id+'_DoFSCommand']= this.onfsCommand.createDelegate(this)); } } }, clearMedia : function(){ //de-register fscommand hooks if(this.mediaObject){ var id = this.mediaObject.id; if(Ext.isIE){ Ext.select('script[for='+id+']',true).remove(); } else { window[id+'_DoFSCommand']= null; delete window[id+'_DoFSCommand']; } } return ux.Flash.superclass.clearMedia.call(this) || this; }, getSWFObject : function() { return this.getInterface(); }, onfsCommand : function( command, args){ if(this.events){ this.fireEvent('fscommand', this, command ,args ); } }, setVariable : function(varName, value){ var fo = this.getInterface(); if(fo && 'SetVariable' in fo){ fo.SetVariable(varName,value); return true; } fo = null; return false; }, getVariable : function(varName ){ var fo = this.getInterface(); if(fo && 'GetVariable' in fo){ return fo.GetVariable(varName ); } fo = null; return undefined; }, bindExternals : function(methods){ if(methods && this.playerVersion.major >= 8){ methods = new Array().concat(methods); }else{ return; } var nameSpace = (typeof this.externalsNamespace == 'string' ? this[this.externalsNamespace] || (this[this.externalsNamespace] = {} ) : this ); Ext.each(methods,function(method){ var m = method.name || method; var returnType = method.returnType || 'javascript'; //Do not overwrite existing function with the same name. nameSpace[m] || (nameSpace[m] = function(){ return this.invoke.apply(this,[m, returnType].concat(Array.prototype.slice.call(arguments,0))); }.createDelegate(this)); },this); }, invoke : function(method , returnType ){ var obj,r; if(method && (obj = this.getInterface()) && 'CallFunction' in obj ){ var c = [ String.format('',method, returnType), '', (Array.prototype.slice.call(arguments,2)).map(this._toXML, this).join(''), '', ''].join(''); r = obj.CallFunction(c); typeof r === 'string' && returnType ==='javascript' && (r= Ext.decode(r)); } return r; }, onFlashInit : function(){ if(this.mediaMask && this.autoMask){this.mediaMask.hide();} this.fireEvent.defer(300,this,['flashinit',this, this.getInterface()]); }, pollReadyState : function(cb, readyRE){ var media; if(media= this.getInterface()){ if(typeof media.PercentLoaded != 'undefined'){ var perc = media.PercentLoaded() ; this.fireEvent( 'progress' ,this , this.getInterface(), perc) ; if( perc = 100 ) { cb(); return; } } this._countPoll++ > this._maxPoll || arguments.callee.defer(10,this,arguments); } }, _handleSWFEvent: function(event) { var type = event.type||event||false; if(type){ if(this.events && !this.events[String(type)]) { this.addEvents(String(type));} return this.fireEvent.apply(this, [String(type), this].concat(Array.prototype.slice.call(arguments,0))); } }, _toXML : function(value){ var format = Ext.util.Format; var type = typeof value; if (type == "string") { return "" + format.xmlEncode(value) + "";} else if (type == "undefined") {return "";} else if (type == "number") {return "" + value + "";} else if (value == null) {return "";} else if (type == "boolean") {return value ? "" : "";} else if (value instanceof Date) {return "" + value.getTime() + "";} else if (Ext.isArray(value)) {return this._arrayToXML(value);} else if (type == "object") {return this._objectToXML(value);} else {return "";} }, _arrayToXML : function(arrObj){ var s = ""; for (var i = 0,l = arrObj.length ; i < l; i++) { s += "" + this._toXML(arrObj[i]) + ""; } return s + ""; }, _objectToXML : function(obj){ var s = ""; for (var prop in obj) { if(obj.hasOwnProperty(prop)){ s += "" + this._toXML(obj[prop]) + ""; } } return s + ""; } }); Ext.ux.Media.Flash.eventSynch = function(elementID, event ){ var SWF = Ext.get(elementID), inst; if(SWF && (inst = SWF.ownerCt)){ return inst._handleSWFEvent.apply(inst, Array.prototype.slice.call(arguments,1)); } }; var componentAdapter = { init : function(){ this.getId = function(){ return this.id || (this.id = "flash-comp" + (++Ext.Component.AUTO_ID)); }; this.addEvents( 'flashinit', 'fscommand', 'progress' ); } }; Ext.ux.Media.Flash.Component = Ext.extend(Ext.ux.Media.Component, { ctype : "Ext.ux.Media.Flash.Component", cls : "x-media-flash-comp", autoEl : {tag:'div',style : { overflow: 'hidden', display:'block'}}, mediaClass : Ext.ux.Media.Flash, initComponent : function(){ componentAdapter.init.apply(this,arguments); Ext.ux.Media.Flash.Component.superclass.initComponent.apply(this,arguments); } }); Ext.reg('uxflash', Ext.ux.Media.Flash.Component); ux.Flash.prototype.detectFlashVersion(); Ext.ux.Media.Flash.Panel = Ext.extend(Ext.ux.Media.Panel,{ ctype : "Ext.ux.Media.Flash.Panel", mediaClass : Ext.ux.Media.Flash, autoScroll : false, shadow : false, initComponent : function(){ componentAdapter.init.apply(this,arguments); Ext.ux.Media.Flash.Panel.superclass.initComponent.apply(this,arguments); } }); Ext.reg('flashpanel', ux.Flash.Panel); Ext.reg('uxflashpanel', ux.Flash.Panel); Ext.ux.Media.Flash.Portlet = Ext.extend(Ext.ux.Media.Portlet,{ ctype : "Ext.ux.Media.Flash.Portlet", anchor : '100%', frame : true, collapseEl : 'bwrap', collapsible : true, draggable : true, autoScroll : false, autoWidth : true, cls : 'x-portlet x-flash-portlet', mediaClass : Ext.ux.Media.Flash, initComponent : function(){ componentAdapter.init.apply(this,arguments); Ext.ux.Media.Flash.Panel.superclass.initComponent.apply(this,arguments); } }); Ext.reg('flashportlet', ux.Flash.Portlet); Ext.reg('uxflashportlet', ux.Flash.Portlet); Ext.ux.Media.Flash.Window = Ext.extend( Ext.ux.Media.Window , { ctype : "Ext.ux.Media.Flash.Window", mediaClass : Ext.ux.Media.Flash, autoScroll : false, shadow : false, initComponent : function(){ componentAdapter.init.apply(this,arguments); Ext.ux.Media.Flash.Window.superclass.initComponent.apply(this,arguments); } }); Ext.reg('flashwindow', ux.Flash.Window); Ext.ux.Media.Flash.Element = Ext.extend ( Ext.ux.Media.Element , { remove : function(){ var d ; // Fix streaming media troubles for IE // IE has issues with loose references when removing an // before the onload event fires (all s should have readyState == 4 after browsers onload) // Advice: do not attempt to remove the Component before onload has fired on IE/Win. if(Ext.isIE && Ext.isWindows && (d = this.dom)){ this.removeAllListeners(); d.style.display = 'none'; //hide it regardless of state if(d.readyState == 4){ for (var x in d) { if (x.toLowerCase() != 'flashvars' && typeof d[x] == 'function') { d[x] = null; } } } } Ext.ux.Media.Flash.Element.superclass.remove.apply(this, arguments); } }); Ext.ux.Media.Flash.prototype.elementClass = Ext.ux.Media.Flash.Element; var writeScript = function(block, attributes) { attributes = Ext.apply({},attributes||{},{type :"text/javascript",text:block}); try{ var head,script, doc= document; if(doc && doc.getElementsByTagName){ if(!(head = doc.getElementsByTagName("head")[0] )){ head =doc.createElement("head"); doc.getElementsByTagName("html")[0].appendChild(head); } if(head && (script = doc.createElement("script"))){ for(var attrib in attributes){ if(attributes.hasOwnProperty(attrib) && attrib in script){ script[attrib] = attributes[attrib]; } } return !!head.appendChild(script); } } }catch(ex){} return false; }; if(Ext.isIE && Ext.isWindows && ux.Flash.prototype.flashVersion.major == 9) { window.attachEvent('onbeforeunload', function() { __flash_unloadHandler = __flash_savedUnloadHandler = function() {}; }); //Note: we cannot use IE's onbeforeunload event because an internal Flash Form-POST // raises the browsers onbeforeunload event when the server returns a response. that is crazy! window.attachEvent('onunload', function() { Ext.each(Ext.query('.x-media-swf'), function(item, index) { item.style.display = 'none'; for (var x in item) { if (x.toLowerCase() != 'flashvars' && typeof item[x] == 'function') { item[x] = null; } } }); }); } Ext.apply(Ext.util.Format , { xmlEncode : function(value){ return !value ? value : String(value) .replace(/&/g, "&") .replace(/>/g, ">") .replace(/") .replace(/</g, "<") .replace(/"/g, '"') .replace(/&/g, "&") .replace(/'/g, "'"); } }); Ext.ux.FlashComponent = Ext.ux.Media.Flash.Component ; Ext.ux.FlashPanel = Ext.ux.Media.Flash.Panel; Ext.ux.FlashPortlet = Ext.ux.Media.Flash.Portlet; Ext.ux.FlashWindow = Ext.ux.Media.Flash.Window; })(); (function(){ Ext.namespace("Ext.ux.Chart"); var chart = Ext.ux.Chart; var flash = Ext.ux.Media.Flash; Ext.ux.Chart.FlashAdapter = Ext.extend( Ext.ux.Media.Flash, { requiredVersion : 8, unsupportedText : {cn:['The Adobe Flash Player{0}is required.',{tag:'br'},{tag:'a',cn:[{tag:'img',src:'http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif'}],href:'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash',target:'_flash'}]}, chartURL : null, chartData : null, dataURL : null, autoLoad : null, loadMask : null, mediaMask : null, autoMask : null, disableCaching : true, blankChartData : '', externalsNamespace : 'chart', chartCfg : null, chart : null, mediaCfg : {url : null, id : null, start : true, controls : true, height : null, width : null, autoSize : true, renderOnResize:false, scripting : 'always', cls :'x-media x-media-swf x-chart', params : { allowscriptaccess : '@scripting', wmode :'opaque', scale :'exactfit', scale : null, salign : null } }, initMedia : function(){ this.addEvents( 'beforeload', 'loadexception', 'chartload', 'chartrender' ); this.mediaCfg.renderOnResize = this.mediaCfg.renderOnResize || (this.chartCfg || {}).renderOnResize; chart.FlashAdapter.superclass.initMedia.call(this); if(this.autoLoad){ this.on('mediarender', this.doAutoLoad, this, {single:true} ); } }, onBeforeMedia: function(){ var mc = this.mediaCfg; var mp = mc.params||{}; delete mc.params; var mv = mp[this.varsName]||{}; delete mp[this.varsName]; //chartCfg var cCfg = Ext.apply({},this.chartCfg || {}); //chart params var cp = Ext.apply({}, this.assert( cCfg.params,{})); delete cCfg.params; //chart.params.flashVars var cv = Ext.apply({}, this.assert( cp[this.varsName],{})); delete cp[this.varsName]; Ext.apply(mc , cCfg, { url : this.assert(this.chartURL, null) }); mc.params = Ext.apply(mp,cp); mc.params[this.varsName] = Ext.apply(mv,cv); chart.FlashAdapter.superclass.onBeforeMedia.call(this); }, setChartDataURL : function(url, immediate){ return this; }, load : function(url, params, callback, scope){ if(!url){return null;} this.connection || (this.connection = new Ext.data.Connection() ); if(this.loadMask && this.autoMask && !this.loadMask.active ){ this.loadMask.show({ msg : url.text || null ,fn : arguments.callee.createDelegate(this,arguments) ,fnDelay : 100 }); return this.connection; } var method , dataUrl, cfg, callerScope,timeout,disableCaching ; if(typeof url === "object"){ // must be config object cfg = Ext.apply({},url); dataUrl = cfg.url; params = params || cfg.params; callback = callback || cfg.callback; callerScope = scope || cfg.scope; method = cfg.method || params ? 'POST': 'GET'; disableCaching = cfg.disableCaching ; timeout = cfg.timeout || 30; } else { dataUrl = url; } //resolve Function if supplied if(!(dataUrl = this.assert(dataUrl, null)) ){return null;} method = method || (params ? "POST" : "GET"); if(method === "GET"){ dataUrl= this.prepareURL(dataUrl, disableCaching ); } var o; o = Ext.apply(cfg ||{}, { url : dataUrl, params: params, method: method, success: function(response, options){ o.loadData = this.fireEvent('beforeload', this, this.getInterface(), response, options) !== false; }, failure: function(response, options){ this.fireEvent('loadexception', this, this.getInterface(), response, options); }, scope: this, //Actual response is managed here callback: function(options, success, response ) { o.loadData = success; if(callback){ o.loadData = callback.call(callerScope , this, success, response, options )!== false; } if(success && o.loadData){ this.setChartData(options.chartResponse || response.responseText); } if(this.autoMask){ this.onChartLoaded(); } }, timeout: (timeout*1000), argument: { "options" : cfg, "url" : dataUrl, "form" : null, "callback" : callback, "scope" : callerScope , "params" : params } }); this.connection.request(o); return this.connection; }, setChartData : function(data){ return this; }, setMask : function(ct) { chart.FlashAdapter.superclass.setMask.apply(this, arguments); //loadMask reserved for data loading operations only //see: @cfg:mediaMask for Chart object masking var lm=this.loadMask; if(lm && !lm.disabled){ lm.el || (this.loadMask = lm = new Ext.ux.IntelliMask( this[this.mediaEl] || ct, Ext.isObject(lm) ? lm : {msg : lm})); } }, doAutoLoad : function(){ this.load ( typeof this.autoLoad === 'object' ? this.autoLoad : {url: this.autoLoad}); this.autoLoad = null; }, onChartRendered : function(){ this.fireEvent('chartrender', this, this.getInterface()); if(this.loadMask && this.autoMask){this.loadMask.hide();} }, onChartLoaded : function(){ this.fireEvent('chartload', this, this.getInterface()); if(this.loadMask && this.autoMask){this.loadMask.hide();} }, onFlashInit : function(id){ chart.FlashAdapter.superclass.onFlashInit.apply(this,arguments); this.fireEvent.defer(1,this,['chartload',this, this.getInterface()]); }, loadMask : false, getChartVersion : function(){} }); chart.FlashAdapter.chartOnLoad = function(DOMId){ var c, d = Ext.get(DOMId); if(d && (c = d.ownerCt)){ c.onChartLoaded.defer(1, c); c = d=null; return false; } d= null; }; chart.FlashAdapter.chartOnRender = function(DOMId){ var c, d = Ext.get(DOMId); if(d && (c = d.ownerCt)){ c.onChartRendered.defer(1, c); c = d = null; return false; } d= null; }; Ext.apply(Ext.util.Format , { xmlEncode : function(value){ return !value ? value : String(value) .replace(/&/g, "&") .replace(/>/g, ">") .replace(/") .replace(/</g, "<") .replace(/"/g, '"') .replace(/&/g, "&") .replace(/'/g, "'"); } }); })(); (function(){ Ext.namespace("Ext.ux.Chart.Fusion"); var chart = Ext.ux.Chart; Ext.ux.Chart.Fusion.Adapter = Ext.extend( Ext.ux.Chart.FlashAdapter, { requiredVersion : 8, blankChartData : '', chartData : null, disableCaching : false, dataURL : null, autoLoad : null, chartCfg : null, autoScroll : true, mediaCfg : {url : null, id : null, start : true, controls : true, height : null, width : null, autoSize : true, autoScale : false, renderOnResize:true, //Fusion required after reflow for < Fusion 3.1 (use when autoScale is false) scripting : 'always', cls :'x-media x-media-swf x-chart-fusion', params : { wmode :'opaque', salign : null }, boundExternals : ['print', 'saveAsImage', 'setDataXML', 'setDataURL', 'getDataAsCSV', 'getXML', 'getChartAttribute', 'hasRendered', 'signature', 'exportChart' ] }, initMedia : function(){ this.addEvents( //Defined in FlashAdaper superclass 'dataloaded', 'dataloaderror', 'nodatatodisplay', 'dataxmlinvalid', 'exported', 'exportready' ); //For compat with previous versions < 2.1 this.chartCfg || (this.chartCfg = this.fusionCfg || {}); chart.Fusion.Adapter.superclass.initMedia.call(this); }, onBeforeMedia: function(){ var mc = this.mediaCfg; var cCfg = this.chartCfg || (this.chartCfg = {}); cCfg.params = this.assert( cCfg.params,{}); cCfg.params[this.varsName] = this.assert( cCfg.params[this.varsName],{}); cCfg.params[this.varsName] = Ext.apply({ chartWidth : '@width' , chartHeight : '@height', scaleMode : mc.autoScale ? 'exactFit' : 'noScale', debugMode : 0, DOMId : '@id', registerWithJS: 1, allowScriptAccess: "@scripting" , lang : 'EN', dataXML : this.dataURL ? null : this.assert(this.dataXML || this.chartData || this.blankChartData,null), dataURL : this.dataURL ? encodeURI(this.prepareURL(this.dataURL)) : null }, cCfg.params[this.varsName]); chart.Fusion.Adapter.superclass.onBeforeMedia.call(this); }, setChartData : function(xml, immediate){ var o; this.chartData = xml; this.dataURL = null; if( immediate !== false && (o = this.getInterface())){ if( 'setDataXML' in o ){ o.setDataXML(xml); } else { //FC Free Interface this.setVariable("_root.dataURL",""); //Set the flag this.setVariable("_root.isNewData","1"); //Set the actual data this.setVariable("_root.newData",xml); //Go to the required frame if('TGotoLabel' in o){ o.TGotoLabel("/", "JavaScriptHandler"); } } } o = null; return this; }, setChartDataURL : function(url, immediate){ var o; this.dataURL = url; if(immediate !== false && (o = this.getInterface())){ 'setDataURL' in o ? o.setDataURL(url) : //FusionCharts Free has no support for dynamic loading of URLs this.load({url:url, nocache:this.disableCaching} ); o=null; } }, getChartVersion : function(){ return ''; } }); window.FC_Rendered = window.FC_Rendered ? window.FC_Rendered.createInterceptor(chart.FlashAdapter.chartOnRender):chart.FlashAdapter.chartOnRender; window.FC_Loaded = window.FC_Loaded ? window.FC_Loaded.createInterceptor(chart.FlashAdapter.chartOnLoad):chart.FlashAdapter.chartOnLoad; var dispatchEvent = function(name, id){ var c, d = Ext.get(id); if(d && (c = d.ownerCt)){ c.fireEvent.apply(c, [name, c, c.getInterface()].concat(Array.prototype.slice.call(arguments,2))); } c = d =null; }; //Bind Fusion callbacks to an Ext.Event for the corresponding chart. Ext.each(['FC_DataLoaded', 'FC_DataLoadError' , 'FC_NoDataToDisplay','FC_DataXMLInvalid','FC_Exported','FC_ExportReady'], function(fnName){ var cb = dispatchEvent.createDelegate(null,[fnName.toLowerCase().replace(/^FC_/i,'')],0); window[fnName] = typeof window[fnName] == 'function' ? window[fnName].createInterceptor(cb): cb ; }); Ext.ux.Chart.Fusion.Component = Ext.extend(Ext.ux.Media.Flash.Component, { ctype : 'Ext.ux.Chart.Fusion.Component' , mediaClass : Ext.ux.Chart.Fusion.Adapter }); Ext.reg('fusion', chart.Fusion.Component); Ext.ux.Chart.Fusion.Panel = Ext.extend(Ext.ux.Media.Flash.Panel, { ctype : 'Ext.ux.Chart.Fusion.Panel', mediaClass : Ext.ux.Chart.Fusion.Adapter }); Ext.reg('fusionpanel', chart.Fusion.Panel); Ext.ux.Chart.Fusion.Portlet = Ext.extend(Ext.ux.Media.Flash.Panel, { anchor : '100%', frame : true, collapseEl : 'bwrap', collapsible : true, draggable : true, cls : 'x-portlet x-chart-portlet', ctype : 'Ext.ux.Chart.Fusion.Portlet', mediaClass : Ext.ux.Chart.Fusion.Adapter }); Ext.reg('fusionportlet', chart.Fusion.Portlet); Ext.ux.Chart.Fusion.Window = Ext.extend(Ext.ux.Media.Flash.Window, { ctype : "Ext.ux.Chart.Fusion.Window", mediaClass : chart.Fusion.Adapter }); Ext.reg('fusionwindow', Ext.ux.Chart.Fusion.Window); })(); if (Ext.provide) { Ext.provide('uxfusion');}