X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..refs/heads/master:/docs/source/Proxy.html diff --git a/docs/source/Proxy.html b/docs/source/Proxy.html index 2009211d..84a6a62d 100644 --- a/docs/source/Proxy.html +++ b/docs/source/Proxy.html @@ -1,101 +1,139 @@ - -
-Ext.sql.Proxy = function(conn, table, keyName, store, readonly){ - Ext.sql.Proxy.superclass.constructor.call(this); - this.conn = conn; - this.table = this.conn.getTable(table, keyName); - this.store = store; - - if (readonly !== true) { - this.store.on('add', this.onAdd, this); - this.store.on('update', this.onUpdate, this); - this.store.on('remove', this.onRemove, this); - } -}; - -Ext.sql.Proxy.DATE_FORMAT = 'Y-m-d H:i:s'; - -Ext.extend(Ext.sql.Proxy, Ext.data.DataProxy, { - load : function(params, reader, callback, scope, arg){ - if(!this.conn.isOpen()){ // assume that the connection is in the process of opening - this.conn.on('open', function(){ - this.load(params, reader, callback, scope, arg); - }, this, {single:true}); - return; - }; - if(this.fireEvent("beforeload", this, params, reader, callback, scope, arg) !== false){ - var clause = params.where || ''; - var args = params.args || []; - var group = params.groupBy; - var sort = params.sort; - var dir = params.dir; - - if(group || sort){ - clause += ' ORDER BY '; - if(group && group != sort){ - clause += group + ' ASC, '; - } - clause += sort + ' ' + (dir || 'ASC'); - } - - var rs = this.table.selectBy(clause, args); - this.onLoad({callback:callback, scope:scope, arg:arg, reader: reader}, rs); - }else{ - callback.call(scope||this, null, arg, false); - } - }, - - onLoad : function(trans, rs, e, stmt){ - if(rs === false){ - this.fireEvent("loadexception", this, null, trans.arg, e); - trans.callback.call(trans.scope||window, null, trans.arg, false); - return; - } - var result = trans.reader.readRecords(rs); - this.fireEvent("load", this, rs, trans.arg); - trans.callback.call(trans.scope||window, result, trans.arg, true); - }, - - processData : function(o){ - var fs = this.store.fields; - var r = {}; - for(var key in o){ - var f = fs.key(key), v = o[key]; - if(f){ - if(f.type == 'date'){ - r[key] = v ? v.format(Ext.sql.Proxy.DATE_FORMAT,10) : ''; - }else if(f.type == 'boolean'){ - r[key] = v ? 1 : 0; - }else{ - r[key] = v; - } - } - } - return r; - }, - - onUpdate : function(ds, record){ - var changes = record.getChanges(); - var kn = this.table.keyName; - this.table.updateBy(this.processData(changes), kn + ' = ?', [record.data[kn]]); - record.commit(true); - }, - - onAdd : function(ds, records, index){ - for(var i = 0, len = records.length; i < len; i++){ - this.table.insert(this.processData(records[i].data)); - } - }, - - onRemove : function(ds, record, index){ - var kn = this.table.keyName; - this.table.removeBy(kn + ' = ?', [record.data[kn]]); - } -});- - \ No newline at end of file + + + + +
/** + * A custom drag proxy implementation specific to {@link Ext.panel.Panel}s. This class + * is primarily used internally for the Panel's drag drop implementation, and + * should never need to be created directly. + * @private + */ +Ext.define('Ext.panel.Proxy', { + + alternateClassName: 'Ext.dd.PanelProxy', + + /** + * Creates new panel proxy. + * @param {Ext.panel.Panel} panel The {@link Ext.panel.Panel} to proxy for + * @param {Object} [config] Config object + */ + constructor: function(panel, config){ + /** + * @property panel + * @type Ext.panel.Panel + */ + this.panel = panel; + this.id = this.panel.id +'-ddproxy'; + Ext.apply(this, config); + }, + + /** + * @cfg {Boolean} insertProxy + * True to insert a placeholder proxy element while dragging the panel, false to drag with no proxy. + * Most Panels are not absolute positioned and therefore we need to reserve this space. + */ + insertProxy: true, + + // private overrides + setStatus: Ext.emptyFn, + reset: Ext.emptyFn, + update: Ext.emptyFn, + stop: Ext.emptyFn, + sync: Ext.emptyFn, + + /** + * Gets the proxy's element + * @return {Ext.Element} The proxy's element + */ + getEl: function(){ + return this.ghost.el; + }, + + /** + * Gets the proxy's ghost Panel + * @return {Ext.panel.Panel} The proxy's ghost Panel + */ + getGhost: function(){ + return this.ghost; + }, + + /** + * Gets the proxy element. This is the element that represents where the + * Panel was before we started the drag operation. + * @return {Ext.Element} The proxy's element + */ + getProxy: function(){ + return this.proxy; + }, + + /** + * Hides the proxy + */ + hide : function(){ + if (this.ghost) { + if (this.proxy) { + this.proxy.remove(); + delete this.proxy; + } + + // Unghost the Panel, do not move the Panel to where the ghost was + this.panel.unghost(null, false); + delete this.ghost; + } + }, + + /** + * Shows the proxy + */ + show: function(){ + if (!this.ghost) { + var panelSize = this.panel.getSize(); + this.panel.el.setVisibilityMode(Ext.Element.DISPLAY); + this.ghost = this.panel.ghost(); + if (this.insertProxy) { + // bc Panels aren't absolute positioned we need to take up the space + // of where the panel previously was + this.proxy = this.panel.el.insertSibling({cls: Ext.baseCSSPrefix + 'panel-dd-spacer'}); + this.proxy.setSize(panelSize); + } + } + }, + + // private + repair: function(xy, callback, scope) { + this.hide(); + if (typeof callback == "function") { + callback.call(scope || this); + } + }, + + /** + * Moves the proxy to a different position in the DOM. This is typically + * called while dragging the Panel to keep the proxy sync'd to the Panel's + * location. + * @param {HTMLElement} parentNode The proxy's parent DOM node + * @param {HTMLElement} [before] The sibling node before which the + * proxy should be inserted (defaults to the parent's last child if not + * specified) + */ + moveProxy : function(parentNode, before){ + if (this.proxy) { + parentNode.insertBefore(this.proxy.dom, before); + } + } +});+ +