- // Filters the passed candidate array and returns only items which match the passed xtype
- filterByXType = function(items, xtype, shallow) {
- if (xtype === '*') {
- return items.slice();
- }
- else {
- var result = [],
- i = 0,
- length = items.length,
- candidate;
- for (; i < length; i++) {
- candidate = items[i];
- if (candidate.isXType(xtype, shallow)) {
- result.push(candidate);
- }
- }
- return result;
- }
- },
-
- // Filters the passed candidate array and returns only items which have the passed className
- filterByClassName = function(items, className) {
- var EA = Ext.Array,
- result = [],
- i = 0,
- length = items.length,
- candidate;
- for (; i < length; i++) {
- candidate = items[i];
- if (candidate.el ? candidate.el.hasCls(className) : EA.contains(candidate.initCls(), className)) {
- result.push(candidate);
- }
- }
- return result;
- },
-
- // Filters the passed candidate array and returns only items which have the specified property match
- filterByAttribute = function(items, property, operator, value) {
- var result = [],
- i = 0,
- length = items.length,
- candidate;
- for (; i < length; i++) {
- candidate = items[i];
- if (!value ? !!candidate[property] : (String(candidate[property]) === value)) {
- result.push(candidate);
- }
- }
- return result;
- },
-
- // Filters the passed candidate array and returns only items which have the specified itemId or id
- filterById = function(items, id) {
- var result = [],
- i = 0,
- length = items.length,
- candidate;
- for (; i < length; i++) {
- candidate = items[i];
- if (candidate.getItemId() === id) {
- result.push(candidate);
- }
- }
- return result;
- },
-
- // Filters the passed candidate array and returns only items which the named pseudo class matcher filters in
- filterByPseudo = function(items, name, value) {
- return cq.pseudos[name](items, value);
- },
-
- // Determines leading mode
- // > for direct child, and ^ to switch to ownerCt axis
- modeRe = /^(\s?([>\^])\s?|\s|$)/,
-
- // Matches a token with possibly (true|false) appended for the "shallow" parameter
- tokenRe = /^(#)?([\w\-]+|\*)(?:\((true|false)\))?/,
-
- matchers = [{
- // Checks for .xtype with possibly (true|false) appended for the "shallow" parameter
- re: /^\.([\w\-]+)(?:\((true|false)\))?/,
- method: filterByXType
- },{
- // checks for [attribute=value]
- re: /^(?:[\[](?:@)?([\w\-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]])/,
- method: filterByAttribute
- }, {
- // checks for #cmpItemId
- re: /^#([\w\-]+)/,
- method: filterById
- }, {
- // checks for :<pseudo_class>(<selector>)
- re: /^\:([\w\-]+)(?:\(((?:\{[^\}]+\})|(?:(?!\{)[^\s>\/]*?(?!\})))\))?/,
- method: filterByPseudo
- }, {
- // checks for {<member_expression>}
- re: /^(?:\{([^\}]+)\})/,
- method: filterFnPattern
- }];
-
- /**
- * @class Ext.ComponentQuery.Query
- * @extends Object
- * @private
- */
- cq.Query = Ext.extend(Object, {
- constructor: function(cfg) {
- cfg = cfg || {};
- Ext.apply(this, cfg);
- },
-
- /**
- * @private
- * Executes this Query upon the selected root.
- * The root provides the initial source of candidate Component matches which are progressively
- * filtered by iterating through this Query's operations cache.
- * If no root is provided, all registered Components are searched via the ComponentManager.
- * root may be a Container who's descendant Components are filtered
- * root may be a Component with an implementation of getRefItems which provides some nested Components such as the
- * docked items within a Panel.
- * root may be an array of candidate Components to filter using this Query.
- */
- execute : function(root) {
- var operations = this.operations,
- i = 0,
- length = operations.length,
- operation,
- workingItems;
-
- // no root, use all Components in the document
- if (!root) {
- workingItems = Ext.ComponentManager.all.getArray();
- }
- // Root is a candidate Array
- else if (Ext.isArray(root)) {
- workingItems = root;
- }
-
- // We are going to loop over our operations and take care of them
- // one by one.
- for (; i < length; i++) {
- operation = operations[i];
-
- // The mode operation requires some custom handling.
- // All other operations essentially filter down our current
- // working items, while mode replaces our current working
- // items by getting children from each one of our current
- // working items. The type of mode determines the type of
- // children we get. (e.g. > only gets direct children)
- if (operation.mode === '^') {
- workingItems = getAncestors(workingItems || [root]);
- }
- else if (operation.mode) {
- workingItems = getItems(workingItems || [root], operation.mode);
- }
- else {
- workingItems = filterItems(workingItems || getItems([root]), operation);
- }
-
- // If this is the last operation, it means our current working
- // items are the final matched items. Thus return them!
- if (i === length -1) {
- return workingItems;
- }
- }
- return [];
- },
-
- is: function(component) {
- var operations = this.operations,
- components = Ext.isArray(component) ? component : [component],
- originalLength = components.length,
- lastOperation = operations[operations.length-1],
- ln, i;
-
- components = filterItems(components, lastOperation);
- if (components.length === originalLength) {
- if (operations.length > 1) {
- for (i = 0, ln = components.length; i < ln; i++) {
- if (Ext.Array.indexOf(this.execute(), components[i]) === -1) {
- return false;
- }
- }
- }
- return true;
- }
- return false;
- }
- });
-
- Ext.apply(this, {
-
- // private cache of selectors and matching ComponentQuery.Query objects
- cache: {},
-
- // private cache of pseudo class filter functions
- pseudos: {
- not: function(components, selector){
- var CQ = Ext.ComponentQuery,
- i = 0,
- length = components.length,
- results = [],
- index = -1,
- component;
-
- for(; i < length; ++i) {
- component = components[i];
- if (!CQ.is(component, selector)) {
- results[++index] = component;
- }
- }
- return results;
- }
- },
-
- /**
- * <p>Returns an array of matched Components from within the passed root object.</p>
- * <p>This method filters returned Components in a similar way to how CSS selector based DOM
- * queries work using a textual selector string.</p>
- * <p>See class summary for details.</p>
- * @param selector The selector string to filter returned Components
- * @param root <p>The Container within which to perform the query. If omitted, all Components
- * within the document are included in the search.</p>
- * <p>This parameter may also be an array of Components to filter according to the selector.</p>
- * @returns {Array} The matched Components.
- * @member Ext.ComponentQuery
- * @method query
- */
- query: function(selector, root) {
- var selectors = selector.split(','),
- length = selectors.length,
- i = 0,
- results = [],
- noDupResults = [],
- dupMatcher = {},
- query, resultsLn, cmp;
-
- for (; i < length; i++) {
- selector = Ext.String.trim(selectors[i]);
- query = this.cache[selector];
- if (!query) {
- this.cache[selector] = query = this.parse(selector);
- }
- results = results.concat(query.execute(root));
- }
-
- // multiple selectors, potential to find duplicates
- // lets filter them out.
- if (length > 1) {
- resultsLn = results.length;
- for (i = 0; i < resultsLn; i++) {
- cmp = results[i];
- if (!dupMatcher[cmp.id]) {
- noDupResults.push(cmp);
- dupMatcher[cmp.id] = true;
- }
- }
- results = noDupResults;
- }
- return results;
- },
-
- /**
- * Tests whether the passed Component matches the selector string.
- * @param component The Component to test
- * @param selector The selector string to test against.
- * @return {Boolean} True if the Component matches the selector.
- * @member Ext.ComponentQuery
- * @method query
- */
- is: function(component, selector) {
- if (!selector) {
- return true;
- }
- var query = this.cache[selector];
- if (!query) {
- this.cache[selector] = query = this.parse(selector);
- }
- return query.is(component);
- },
-
- parse: function(selector) {
- var operations = [],
- length = matchers.length,
- lastSelector,
- tokenMatch,
- matchedChar,
- modeMatch,
- selectorMatch,
- i, matcher, method;
-
- // We are going to parse the beginning of the selector over and
- // over again, slicing off the selector any portions we converted into an
- // operation, until it is an empty string.
- while (selector && lastSelector !== selector) {
- lastSelector = selector;
-
- // First we check if we are dealing with a token like #, * or an xtype
- tokenMatch = selector.match(tokenRe);
-
- if (tokenMatch) {
- matchedChar = tokenMatch[1];
-
- // If the token is prefixed with a # we push a filterById operation to our stack
- if (matchedChar === '#') {
- operations.push({
- method: filterById,
- args: [Ext.String.trim(tokenMatch[2])]
- });
- }
- // If the token is prefixed with a . we push a filterByClassName operation to our stack
- // FIXME: Not enabled yet. just needs \. adding to the tokenRe prefix
- else if (matchedChar === '.') {
- operations.push({
- method: filterByClassName,
- args: [Ext.String.trim(tokenMatch[2])]
- });
- }
- // If the token is a * or an xtype string, we push a filterByXType
- // operation to the stack.
- else {
- operations.push({
- method: filterByXType,
- args: [Ext.String.trim(tokenMatch[2]), Boolean(tokenMatch[3])]
- });
- }
-
- // Now we slice of the part we just converted into an operation
- selector = selector.replace(tokenMatch[0], '');
- }
-
- // If the next part of the query is not a space or > or ^, it means we
- // are going to check for more things that our current selection
- // has to comply to.
- while (!(modeMatch = selector.match(modeRe))) {
- // Lets loop over each type of matcher and execute it
- // on our current selector.
- for (i = 0; selector && i < length; i++) {
- matcher = matchers[i];
- selectorMatch = selector.match(matcher.re);
- method = matcher.method;
-
- // If we have a match, add an operation with the method
- // associated with this matcher, and pass the regular
- // expression matches are arguments to the operation.
- if (selectorMatch) {
- operations.push({
- method: Ext.isString(matcher.method)
- // Turn a string method into a function by formatting the string with our selector matche expression
- // A new method is created for different match expressions, eg {id=='textfield-1024'}
- // Every expression may be different in different selectors.
- ? Ext.functionFactory('items', Ext.String.format.apply(Ext.String, [method].concat(selectorMatch.slice(1))))
- : matcher.method,
- args: selectorMatch.slice(1)
- });
- selector = selector.replace(selectorMatch[0], '');
- break; // Break on match
- }
- // Exhausted all matches: It's an error
- if (i === (length - 1)) {
- Ext.Error.raise('Invalid ComponentQuery selector: "' + arguments[0] + '"');
- }
- }
- }
-
- // Now we are going to check for a mode change. This means a space
- // or a > to determine if we are going to select all the children
- // of the currently matched items, or a ^ if we are going to use the
- // ownerCt axis as the candidate source.
- if (modeMatch[1]) { // Assignment, and test for truthiness!
- operations.push({
- mode: modeMatch[2]||modeMatch[1]
- });
- selector = selector.replace(modeMatch[0], '');
- }
- }
-
- // Now that we have all our operations in an array, we are going
- // to create a new Query using these operations.
- return new cq.Query({
- operations: operations
- });
- }
- });
-});
-/**
- * @class Ext.util.Filter
- * @extends Object
- * <p>Represents a filter that can be applied to a {@link Ext.util.MixedCollection MixedCollection}. Can either simply
- * filter on a property/value pair or pass in a filter function with custom logic. Filters are always used in the context
- * of MixedCollections, though {@link Ext.data.Store Store}s frequently create them when filtering and searching on their
- * records. Example usage:</p>
-<pre><code>
-//set up a fictional MixedCollection containing a few people to filter on
-var allNames = new Ext.util.MixedCollection();
-allNames.addAll([
- {id: 1, name: 'Ed', age: 25},
- {id: 2, name: 'Jamie', age: 37},
- {id: 3, name: 'Abe', age: 32},
- {id: 4, name: 'Aaron', age: 26},
- {id: 5, name: 'David', age: 32}
-]);
-
-var ageFilter = new Ext.util.Filter({
- property: 'age',
- value : 32
-});
-
-var longNameFilter = new Ext.util.Filter({
- filterFn: function(item) {
- return item.name.length > 4;
- }
-});
-
-//a new MixedCollection with the 3 names longer than 4 characters
-var longNames = allNames.filter(longNameFilter);
-
-//a new MixedCollection with the 2 people of age 24:
-var youngFolk = allNames.filter(ageFilter);
-</code></pre>
- * @constructor
- * @param {Object} config Config object
- */
-Ext.define('Ext.util.Filter', {
-
- /* Begin Definitions */
-
- /* End Definitions */
- /**
- * @cfg {String} property The property to filter on. Required unless a {@link #filter} is passed
- */
-
- /**
- * @cfg {Function} filterFn A custom filter function which is passed each item in the {@link Ext.util.MixedCollection}
- * in turn. Should return true to accept each item or false to reject it
- */
-
- /**
- * @cfg {Boolean} anyMatch True to allow any match - no regex start/end line anchors will be added. Defaults to false
- */
- anyMatch: false,
-
- /**
- * @cfg {Boolean} exactMatch True to force exact match (^ and $ characters added to the regex). Defaults to false.
- * Ignored if anyMatch is true.
- */
- exactMatch: false,
-
- /**
- * @cfg {Boolean} caseSensitive True to make the regex case sensitive (adds 'i' switch to regex). Defaults to false.
- */
- caseSensitive: false,
-
- /**
- * @cfg {String} root Optional root property. This is mostly useful when filtering a Store, in which case we set the
- * root to 'data' to make the filter pull the {@link #property} out of the data object of each item
- */
-
- constructor: function(config) {
- Ext.apply(this, config);
-
- //we're aliasing filter to filterFn mostly for API cleanliness reasons, despite the fact it dirties the code here.
- //Ext.util.Sorter takes a sorterFn property but allows .sort to be called - we do the same here
- this.filter = this.filter || this.filterFn;
-
- if (this.filter == undefined) {
- if (this.property == undefined || this.value == undefined) {
- // Commented this out temporarily because it stops us using string ids in models. TODO: Remove this once
- // Model has been updated to allow string ids
-
- // Ext.Error.raise("A Filter requires either a property or a filterFn to be set");
- } else {
- this.filter = this.createFilterFn();
- }
-
- this.filterFn = this.filter;
- }
- },
-
- /**
- * @private
- * Creates a filter function for the configured property/value/anyMatch/caseSensitive options for this Filter
- */
- createFilterFn: function() {
- var me = this,
- matcher = me.createValueMatcher(),
- property = me.property;
-
- return function(item) {
- return matcher.test(me.getRoot.call(me, item)[property]);
- };
- },
-
- /**
- * @private
- * Returns the root property of the given item, based on the configured {@link #root} property
- * @param {Object} item The item
- * @return {Object} The root property of the object
- */
- getRoot: function(item) {
- return this.root == undefined ? item : item[this.root];
- },
-
- /**
- * @private
- * Returns a regular expression based on the given value and matching options
- */
- createValueMatcher : function() {
- var me = this,
- value = me.value,
- anyMatch = me.anyMatch,
- exactMatch = me.exactMatch,
- caseSensitive = me.caseSensitive,
- escapeRe = Ext.String.escapeRegex;
-
- if (!value.exec) { // not a regex
- value = String(value);
-
- if (anyMatch === true) {
- value = escapeRe(value);
- } else {
- value = '^' + escapeRe(value);
- if (exactMatch === true) {
- value += '$';
- }
- }
- value = new RegExp(value, caseSensitive ? '' : 'i');
- }
-
- return value;
- }
-});
-/**
- * @class Ext.util.Sorter
- * @extends Object
- * Represents a single sorter that can be applied to a Store
- */
-Ext.define('Ext.util.Sorter', {
-
- /**
- * @cfg {String} property The property to sort by. Required unless {@link #sorter} is provided
- */
-
- /**
- * @cfg {Function} sorterFn A specific sorter function to execute. Can be passed instead of {@link #property}
- */
-
- /**
- * @cfg {String} root Optional root property. This is mostly useful when sorting a Store, in which case we set the
- * root to 'data' to make the filter pull the {@link #property} out of the data object of each item
- */
-
- /**
- * @cfg {Function} transform A function that will be run on each value before
- * it is compared in the sorter. The function will receive a single argument,
- * the value.
- */
-
- /**
- * @cfg {String} direction The direction to sort by. Defaults to ASC
- */
- direction: "ASC",
-
- constructor: function(config) {
- var me = this;
-
- Ext.apply(me, config);
-
- if (me.property == undefined && me.sorterFn == undefined) {
- Ext.Error.raise("A Sorter requires either a property or a sorter function");
- }
-
- me.updateSortFunction();
- },
-
- /**
- * @private
- * Creates and returns a function which sorts an array by the given property and direction
- * @return {Function} A function which sorts by the property/direction combination provided
- */
- createSortFunction: function(sorterFn) {
- var me = this,
- property = me.property,
- direction = me.direction || "ASC",
- modifier = direction.toUpperCase() == "DESC" ? -1 : 1;
-
- //create a comparison function. Takes 2 objects, returns 1 if object 1 is greater,
- //-1 if object 2 is greater or 0 if they are equal
- return function(o1, o2) {
- return modifier * sorterFn.call(me, o1, o2);
- };
- },
-
- /**
- * @private
- * Basic default sorter function that just compares the defined property of each object
- */
- defaultSorterFn: function(o1, o2) {
- var me = this,
- transform = me.transform,
- v1 = me.getRoot(o1)[me.property],
- v2 = me.getRoot(o2)[me.property];
-
- if (transform) {
- v1 = transform(v1);
- v2 = transform(v2);
- }
-
- return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
- },
-
- /**
- * @private
- * Returns the root property of the given item, based on the configured {@link #root} property
- * @param {Object} item The item
- * @return {Object} The root property of the object
- */
- getRoot: function(item) {
- return this.root == undefined ? item : item[this.root];
- },
-
- // @TODO: Add docs for these three methods
- setDirection: function(direction) {
- var me = this;
- me.direction = direction;
- me.updateSortFunction();
- },
-
- toggle: function() {
- var me = this;
- me.direction = Ext.String.toggle(me.direction, "ASC", "DESC");
- me.updateSortFunction();
- },
-
- updateSortFunction: function() {
- var me = this;
- me.sort = me.createSortFunction(me.sorterFn || me.defaultSorterFn);
- }
-});
-/**
- * @class Ext.ElementLoader
- * A class used to load remote content to an Element. Sample usage:
- * <pre><code>
-Ext.get('el').load({
- url: 'myPage.php',
- scripts: true,
- params: {
- id: 1
- }
-});
- * </code></pre>
- * <p>
- * In general this class will not be instanced directly, rather the {@link Ext.core.Element#load} method
- * will be used.
- * </p>
- */
-Ext.define('Ext.ElementLoader', {
-
- /* Begin Definitions */
-
- mixins: {
- observable: 'Ext.util.Observable'
- },
-
- uses: [
- 'Ext.data.Connection',
- 'Ext.Ajax'
- ],
-
- statics: {
- Renderer: {
- Html: function(loader, response, active){
- loader.getTarget().update(response.responseText, active.scripts === true);
- return true;
- }
- }
- },
-
- /* End Definitions */
-
- /**
- * @cfg {String} url The url to retrieve the content from. Defaults to <tt>null</tt>.
- */
- url: null,
-
- /**
- * @cfg {Object} params Any params to be attached to the Ajax request. These parameters will
- * be overridden by any params in the load options. Defaults to <tt>null</tt>.
- */
- params: null,
-
- /**
- * @cfg {Object} baseParams Params that will be attached to every request. These parameters
- * will not be overridden by any params in the load options. Defaults to <tt>null</tt>.
- */
- baseParams: null,
-
- /**
- * @cfg {Boolean/Object} autoLoad True to have the loader make a request as soon as it is created. Defaults to <tt>false</tt>.
- * This argument can also be a set of options that will be passed to {@link #load} is called.
- */
- autoLoad: false,
-
- /**
- * @cfg {Mixed} target The target element for the loader. It can be the DOM element, the id or an Ext.Element.
- */
- target: null,
-
- /**
- * @cfg {Mixed} loadMask True or a string to show when the element is loading.
- */
- loadMask: false,
-
- /**
- * @cfg {Object} ajaxOptions Any additional options to be passed to the request, for example timeout or headers. Defaults to <tt>null</tt>.
- */
- ajaxOptions: null,
-
- /**
- * @cfg {Boolean} scripts True to parse any inline script tags in the response.
- */
- scripts: false,
-
- /**
- * @cfg {Function} success A function to be called when a load request is successful.
- */
-
- /**
- * @cfg {Function} failure A function to be called when a load request fails.
- */
-
- /**
- * @cfg {Object} scope The scope to execute the {@link #success} and {@link #failure} functions in.
- */
-
- /**
- * @cfg {Function} renderer A custom function to render the content to the element. The passed parameters
- * are
- * <ul>
- * <li>The loader</li>
- * <li>The response</li>
- * <li>The active request</li>
- * </ul>
- */
-
- isLoader: true,
-
- constructor: function(config) {
- var me = this,
- autoLoad;
-
- config = config || {};
- Ext.apply(me, config);
- me.setTarget(me.target);
- me.addEvents(
- /**
- * @event beforeload
- * Fires before a load request is made to the server.
- * Returning false from an event listener can prevent the load
- * from occurring.
- * @param {Ext.ElementLoader} this
- * @param {Object} options The options passed to the request
- */
- 'beforeload',
-
- /**
- * @event exception
- * Fires after an unsuccessful load.
- * @param {Ext.ElementLoader} this
- * @param {Object} response The response from the server
- * @param {Object} options The options passed to the request
- */
- 'exception',
-
- /**
- * @event exception
- * Fires after a successful load.
- * @param {Ext.ElementLoader} this
- * @param {Object} response The response from the server
- * @param {Object} options The options passed to the request
- */
- 'load'
- );
-
- // don't pass config because we have already applied it.
- me.mixins.observable.constructor.call(me);
-
- if (me.autoLoad) {
- autoLoad = me.autoLoad;
- if (autoLoad === true) {
- autoLoad = {};
- }
- me.load(autoLoad);
- }
- },
-
- /**
- * Set an {Ext.Element} as the target of this loader. Note that if the target is changed,
- * any active requests will be aborted.
- * @param {Mixed} target The element
- */
- setTarget: function(target){
- var me = this;
- target = Ext.get(target);
- if (me.target && me.target != target) {
- me.abort();
- }
- me.target = target;
- },
-
- /**
- * Get the target of this loader.
- * @return {Ext.Component} target The target, null if none exists.
- */
- getTarget: function(){
- return this.target || null;
- },
-
- /**
- * Aborts the active load request
- */
- abort: function(){
- var active = this.active;
- if (active !== undefined) {
- Ext.Ajax.abort(active.request);
- if (active.mask) {
- this.removeMask();
- }
- delete this.active;
- }
- },
-
- /**
- * Remove the mask on the target
- * @private
- */
- removeMask: function(){
- this.target.unmask();
- },
-
- /**
- * Add the mask on the target
- * @private
- * @param {Mixed} mask The mask configuration
- */
- addMask: function(mask){
- this.target.mask(mask === true ? null : mask);
- },
-
- /**
- * Load new data from the server.
- * @param {Object} options The options for the request. They can be any configuration option that can be specified for
- * the class, with the exception of the target option. Note that any options passed to the method will override any
- * class defaults.
- */
- load: function(options) {
- if (!this.target) {
- Ext.Error.raise('A valid target is required when loading content');
- }
-
- options = Ext.apply({}, options);
-
- var me = this,
- target = me.target,
- mask = Ext.isDefined(options.loadMask) ? options.loadMask : me.loadMask,
- params = Ext.apply({}, options.params),
- ajaxOptions = Ext.apply({}, options.ajaxOptions),
- callback = options.callback || me.callback,
- scope = options.scope || me.scope || me,
- request;
-
- Ext.applyIf(ajaxOptions, me.ajaxOptions);
- Ext.applyIf(options, ajaxOptions);
-
- Ext.applyIf(params, me.params);
- Ext.apply(params, me.baseParams);
-
- Ext.applyIf(options, {
- url: me.url
- });
-
- if (!options.url) {
- Ext.Error.raise('You must specify the URL from which content should be loaded');
- }
-
- Ext.apply(options, {
- scope: me,
- params: params,
- callback: me.onComplete
- });
-
- if (me.fireEvent('beforeload', me, options) === false) {
- return;
- }
-
- if (mask) {
- me.addMask(mask);
- }
-
- request = Ext.Ajax.request(options);
- me.active = {
- request: request,
- options: options,
- mask: mask,
- scope: scope,
- callback: callback,
- success: options.success || me.success,
- failure: options.failure || me.failure,
- renderer: options.renderer || me.renderer,
- scripts: Ext.isDefined(options.scripts) ? options.scripts : me.scripts
- };
- me.setOptions(me.active, options);
- },
-
- /**
- * Set any additional options on the active request
- * @private
- * @param {Object} active The active request
- * @param {Object} options The initial options
- */
- setOptions: Ext.emptyFn,
-
- /**
- * Parse the response after the request completes
- * @private
- * @param {Object} options Ajax options
- * @param {Boolean} success Success status of the request
- * @param {Object} response The response object
- */
- onComplete: function(options, success, response) {
- var me = this,
- active = me.active,
- scope = active.scope,
- renderer = me.getRenderer(active.renderer);
-
-
- if (success) {
- success = renderer.call(me, me, response, active);
- }
-
- if (success) {
- Ext.callback(active.success, scope, [me, response, options]);
- me.fireEvent('load', me, response, options);
- } else {
- Ext.callback(active.failure, scope, [me, response, options]);
- me.fireEvent('exception', me, response, options);
- }
- Ext.callback(active.callback, scope, [me, success, response, options]);
-
- if (active.mask) {
- me.removeMask();
- }
-
- delete me.active;
- },
-
- /**
- * Gets the renderer to use
- * @private
- * @param {String/Function} renderer The renderer to use
- * @return {Function} A rendering function to use.
- */
- getRenderer: function(renderer){
- if (Ext.isFunction(renderer)) {
- return renderer;
- }
- return this.statics().Renderer.Html;
- },
-
- /**
- * Automatically refreshes the content over a specified period.
- * @param {Number} interval The interval to refresh in ms.
- * @param {Object} options (optional) The options to pass to the load method. See {@link #load}
- */
- startAutoRefresh: function(interval, options){
- var me = this;
- me.stopAutoRefresh();
- me.autoRefresh = setInterval(function(){
- me.load(options);
- }, interval);
- },
-
- /**
- * Clears any auto refresh. See {@link #startAutoRefresh}.
- */
- stopAutoRefresh: function(){
- clearInterval(this.autoRefresh);
- delete this.autoRefresh;
- },
-
- /**
- * Checks whether the loader is automatically refreshing. See {@link #startAutoRefresh}.
- * @return {Boolean} True if the loader is automatically refreshing
- */
- isAutoRefreshing: function(){
- return Ext.isDefined(this.autoRefresh);
- },
-
- /**
- * Destroys the loader. Any active requests will be aborted.
- */
- destroy: function(){
- var me = this;
- me.stopAutoRefresh();
- delete me.target;
- me.abort();
- me.clearListeners();
- }
-});
-
-/**
- * @class Ext.layout.Layout
- * @extends Object
- * @private
- * Base Layout class - extended by ComponentLayout and ContainerLayout
- */
-
-Ext.define('Ext.layout.Layout', {
-
- /* Begin Definitions */
-
- /* End Definitions */
-
- isLayout: true,
- initialized: false,
-
- statics: {
- create: function(layout, defaultType) {
- var type;
- if (layout instanceof Ext.layout.Layout) {
- return Ext.createByAlias('layout.' + layout);
- } else {
- if (Ext.isObject(layout)) {
- type = layout.type;
- }
- else {
- type = layout || defaultType;
- layout = {};
- }
- return Ext.createByAlias('layout.' + type, layout || {});
- }
- }
- },
-
- constructor : function(config) {
- this.id = Ext.id(null, this.type + '-');
- Ext.apply(this, config);
- },
-
- /**
- * @private
- */
- layout : function() {
- var me = this;
- me.layoutBusy = true;
- me.initLayout();
-
- if (me.beforeLayout.apply(me, arguments) !== false) {
- me.layoutCancelled = false;
- me.onLayout.apply(me, arguments);
- me.childrenChanged = false;
- me.owner.needsLayout = false;
- me.layoutBusy = false;
- me.afterLayout.apply(me, arguments);
- }
- else {
- me.layoutCancelled = true;
- }
- me.layoutBusy = false;
- me.doOwnerCtLayouts();
- },
-
- beforeLayout : function() {
- this.renderItems(this.getLayoutItems(), this.getRenderTarget());
- return true;
- },
-
- /**
- * @private
- * Iterates over all passed items, ensuring they are rendered. If the items are already rendered,
- * also determines if the items are in the proper place dom.
- */
- renderItems : function(items, target) {
- var ln = items.length,
- i = 0,
- item;
-
- for (; i < ln; i++) {
- item = items[i];
- if (item && !item.rendered) {
- this.renderItem(item, target, i);
- }
- else if (!this.isValidParent(item, target, i)) {
- this.moveItem(item, target, i);
- }
- }
- },
-
- // @private - Validates item is in the proper place in the dom.
- isValidParent : function(item, target, position) {
- var dom = item.el ? item.el.dom : Ext.getDom(item);
- if (dom && target && target.dom) {
- if (Ext.isNumber(position) && dom !== target.dom.childNodes[position]) {
- return false;
- }
- return (dom.parentNode == (target.dom || target));
- }
- return false;
- },
-
- /**
- * @private
- * Renders the given Component into the target Element.
- * @param {Ext.Component} item The Component to render
- * @param {Ext.core.Element} target The target Element
- * @param {Number} position The position within the target to render the item to
- */
- renderItem : function(item, target, position) {
- if (!item.rendered) {
- item.render(target, position);
- this.configureItem(item);
- this.childrenChanged = true;
- }
- },
-
- /**
- * @private
- * Moved Component to the provided target instead.
- */
- moveItem : function(item, target, position) {
- // Make sure target is a dom element
- target = target.dom || target;
- if (typeof position == 'number') {
- position = target.childNodes[position];
- }
- target.insertBefore(item.el.dom, position || null);
- item.container = Ext.get(target);
- this.configureItem(item);
- this.childrenChanged = true;
- },
-
- /**
- * @private
- * Adds the layout's targetCls if necessary and sets
- * initialized flag when complete.
- */
- initLayout : function() {
- if (!this.initialized && !Ext.isEmpty(this.targetCls)) {
- this.getTarget().addCls(this.targetCls);
- }
- this.initialized = true;
- },
-
- // @private Sets the layout owner
- setOwner : function(owner) {
- this.owner = owner;
- },
-
- // @private - Returns empty array
- getLayoutItems : function() {
- return [];
- },
-
- /**
- * @private
- * Applies itemCls
- */
- configureItem: function(item) {
- var me = this,
- el = item.el,
- owner = me.owner;
-
- if (me.itemCls) {
- el.addCls(me.itemCls);
- }
- if (owner.itemCls) {
- el.addCls(owner.itemCls);
- }
- },
-
- // Placeholder empty functions for subclasses to extend
- onLayout : Ext.emptyFn,
- afterLayout : Ext.emptyFn,
- onRemove : Ext.emptyFn,
- onDestroy : Ext.emptyFn,
- doOwnerCtLayouts : Ext.emptyFn,
-
- /**
- * @private
- * Removes itemCls
- */
- afterRemove : function(item) {
- var me = this,
- el = item.el,
- owner = me.owner;
-
- if (item.rendered) {
- if (me.itemCls) {
- el.removeCls(me.itemCls);
- }
- if (owner.itemCls) {
- el.removeCls(owner.itemCls);
- }
- }
- },
-
- /*
- * Destroys this layout. This is a template method that is empty by default, but should be implemented
- * by subclasses that require explicit destruction to purge event handlers or remove DOM nodes.
- * @protected
- */
- destroy : function() {
- if (!Ext.isEmpty(this.targetCls)) {
- var target = this.getTarget();
- if (target) {
- target.removeCls(this.targetCls);
- }
- }
- this.onDestroy();
- }
-});
-/**
- * @class Ext.layout.component.Component
- * @extends Ext.layout.Layout
- * @private
- * <p>This class is intended to be extended or created via the <tt><b>{@link Ext.Component#componentLayout layout}</b></tt>
- * configuration property. See <tt><b>{@link Ext.Component#componentLayout}</b></tt> for additional details.</p>
- */
-
-Ext.define('Ext.layout.component.Component', {
-
- /* Begin Definitions */
-
- extend: 'Ext.layout.Layout',
-
- /* End Definitions */
-
- type: 'component',
-
- monitorChildren: true,
-
- initLayout : function() {
- var me = this,
- owner = me.owner,
- ownerEl = owner.el;
-
- if (!me.initialized) {
- if (owner.frameSize) {
- me.frameSize = owner.frameSize;
- }
- else {
- owner.frameSize = me.frameSize = {
- top: 0,
- left: 0,
- bottom: 0,
- right: 0
- };
- }
- }
- me.callParent(arguments);
- },
-
- beforeLayout : function(width, height, isSetSize, layoutOwner) {
- this.callParent(arguments);
-
- var me = this,
- owner = me.owner,
- ownerCt = owner.ownerCt,
- layout = owner.layout,
- isVisible = owner.isVisible(true),
- ownerElChild = owner.el.child,
- layoutCollection;
-
- /**
- * Do not layout calculatedSized components for fixedLayouts unless the ownerCt == layoutOwner
- * fixedLayouts means layouts which are never auto/auto in the sizing that comes from their ownerCt.
- * Currently 3 layouts MAY be auto/auto (Auto, Border, and Box)
- * The reason for not allowing component layouts is to stop component layouts from things such as Updater and
- * form Validation.
- */
- if (!isSetSize && !(Ext.isNumber(width) && Ext.isNumber(height)) && ownerCt && ownerCt.layout && ownerCt.layout.fixedLayout && ownerCt != layoutOwner) {
- me.doContainerLayout();
- return false;
- }
-
- // If an ownerCt is hidden, add my reference onto the layoutOnShow stack. Set the needsLayout flag.
- // If the owner itself is a directly hidden floater, set the needsLayout object on that for when it is shown.
- if (!isVisible && (owner.hiddenAncestor || owner.floating)) {
- if (owner.hiddenAncestor) {
- layoutCollection = owner.hiddenAncestor.layoutOnShow;
- layoutCollection.remove(owner);
- layoutCollection.add(owner);
- }
- owner.needsLayout = {
- width: width,
- height: height,
- isSetSize: false
- };
- }
-
- if (isVisible && this.needsLayout(width, height)) {
- me.rawWidth = width;
- me.rawHeight = height;
- return owner.beforeComponentLayout(width, height, isSetSize, layoutOwner);
- }
- else {
- return false;
- }
- },
-
- /**
- * Check if the new size is different from the current size and only
- * trigger a layout if it is necessary.
- * @param {Mixed} width The new width to set.
- * @param {Mixed} height The new height to set.
- */
- needsLayout : function(width, height) {
- this.lastComponentSize = this.lastComponentSize || {
- width: -Infinity,
- height: -Infinity
- };
- return (this.childrenChanged || this.lastComponentSize.width !== width || this.lastComponentSize.height !== height);
- },
-
- /**
- * Set the size of any element supporting undefined, null, and values.
- * @param {Mixed} width The new width to set.
- * @param {Mixed} height The new height to set.
- */
- setElementSize: function(el, width, height) {
- if (width !== undefined && height !== undefined) {
- el.setSize(width, height);
- }
- else if (height !== undefined) {
- el.setHeight(height);
- }
- else if (width !== undefined) {
- el.setWidth(width);
- }
- },
-
- /**
- * Returns the owner component's resize element.
- * @return {Ext.core.Element}
- */
- getTarget : function() {
- return this.owner.el;
- },
-
- /**
- * <p>Returns the element into which rendering must take place. Defaults to the owner Component's encapsulating element.</p>
- * May be overridden in Component layout managers which implement an inner element.
- * @return {Ext.core.Element}
- */
- getRenderTarget : function() {
- return this.owner.el;
- },
-
- /**
- * Set the size of the target element.
- * @param {Mixed} width The new width to set.
- * @param {Mixed} height The new height to set.
- */
- setTargetSize : function(width, height) {
- var me = this;
- me.setElementSize(me.owner.el, width, height);
-
- if (me.owner.frameBody) {
- var targetInfo = me.getTargetInfo(),
- padding = targetInfo.padding,
- border = targetInfo.border,
- frameSize = me.frameSize;
-
- me.setElementSize(me.owner.frameBody,
- Ext.isNumber(width) ? (width - frameSize.left - frameSize.right - padding.left - padding.right - border.left - border.right) : width,
- Ext.isNumber(height) ? (height - frameSize.top - frameSize.bottom - padding.top - padding.bottom - border.top - border.bottom) : height
- );
- }
-
- me.autoSized = {
- width: !Ext.isNumber(width),
- height: !Ext.isNumber(height)
- };
-
- me.lastComponentSize = {
- width: width,
- height: height
- };
- },
-
- getTargetInfo : function() {
- if (!this.targetInfo) {
- var target = this.getTarget(),
- body = this.owner.getTargetEl();
-
- this.targetInfo = {
- padding: {
- top: target.getPadding('t'),
- right: target.getPadding('r'),
- bottom: target.getPadding('b'),
- left: target.getPadding('l')
- },
- border: {
- top: target.getBorderWidth('t'),
- right: target.getBorderWidth('r'),
- bottom: target.getBorderWidth('b'),
- left: target.getBorderWidth('l')
- },
- bodyMargin: {
- top: body.getMargin('t'),
- right: body.getMargin('r'),
- bottom: body.getMargin('b'),
- left: body.getMargin('l')
- }
- };
- }
- return this.targetInfo;
- },
-
- // Start laying out UP the ownerCt's layout when flagged to do so.
- doOwnerCtLayouts: function() {
- var owner = this.owner,
- ownerCt = owner.ownerCt,
- ownerCtComponentLayout, ownerCtContainerLayout;
-
- if (!ownerCt) {
- return;
- }
-
- ownerCtComponentLayout = ownerCt.componentLayout;
- ownerCtContainerLayout = ownerCt.layout;
-
- if (!owner.floating && ownerCtComponentLayout && ownerCtComponentLayout.monitorChildren && !ownerCtComponentLayout.layoutBusy) {
- if (!ownerCt.suspendLayout && ownerCtContainerLayout && !ownerCtContainerLayout.layoutBusy) {
- // AutoContainer Layout and Dock with auto in some dimension
- if (ownerCtContainerLayout.bindToOwnerCtComponent === true) {
- ownerCt.doComponentLayout();
- }
- // Box Layouts
- else if (ownerCtContainerLayout.bindToOwnerCtContainer === true) {
- ownerCtContainerLayout.layout();
- }
- }
- }
- },
-
- doContainerLayout: function() {
- var me = this,
- owner = me.owner,
- ownerCt = owner.ownerCt,
- layout = owner.layout,
- ownerCtComponentLayout;
-
- // Run the container layout if it exists (layout for child items)
- // **Unless automatic laying out is suspended, or the layout is currently running**
- if (!owner.suspendLayout && layout && layout.isLayout && !layout.layoutBusy) {
- layout.layout();
- }
-
- // Tell the ownerCt that it's child has changed and can be re-layed by ignoring the lastComponentSize cache.
- if (ownerCt && ownerCt.componentLayout) {
- ownerCtComponentLayout = ownerCt.componentLayout;
- if (!owner.floating && ownerCtComponentLayout.monitorChildren && !ownerCtComponentLayout.layoutBusy) {
- ownerCtComponentLayout.childrenChanged = true;
- }
- }
- },
-
- afterLayout : function(width, height, isSetSize, layoutOwner) {
- this.doContainerLayout();
- this.owner.afterComponentLayout(width, height, isSetSize, layoutOwner);
- }
-});
-
-/**
- * @class Ext.state.Manager
- * This is the global state manager. By default all components that are "state aware" check this class
- * for state information if you don't pass them a custom state provider. In order for this class
- * to be useful, it must be initialized with a provider when your application initializes. Example usage:
- <pre><code>
-// in your initialization function
-init : function(){
- Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
- var win = new Window(...);
- win.restoreState();
-}
- </code></pre>
- * This class passes on calls from components to the underlying {@link Ext.state.Provider} so that
- * there is a common interface that can be used without needing to refer to a specific provider instance
- * in every component.
- * @singleton
- * @docauthor Evan Trimboli <evan@sencha.com>
- */
-Ext.define('Ext.state.Manager', {
- singleton: true,
- requires: ['Ext.state.Provider'],
- constructor: function() {
- this.provider = Ext.create('Ext.state.Provider');
- },
-
-
- /**
- * Configures the default state provider for your application
- * @param {Provider} stateProvider The state provider to set
- */
- setProvider : function(stateProvider){
- this.provider = stateProvider;
- },
-
- /**
- * Returns the current value for a key
- * @param {String} name The key name
- * @param {Mixed} defaultValue The default value to return if the key lookup does not match
- * @return {Mixed} The state data
- */
- get : function(key, defaultValue){
- return this.provider.get(key, defaultValue);
- },
-
- /**
- * Sets the value for a key
- * @param {String} name The key name
- * @param {Mixed} value The state data
- */
- set : function(key, value){
- this.provider.set(key, value);
- },
-
- /**
- * Clears a value from the state
- * @param {String} name The key name
- */
- clear : function(key){
- this.provider.clear(key);
- },
-
- /**
- * Gets the currently configured state provider
- * @return {Provider} The state provider
- */
- getProvider : function(){
- return this.provider;
- }
-});
-/**
- * @class Ext.state.Stateful
- * A mixin for being able to save the state of an object to an underlying
- * {@link Ext.state.Provider}.
- */
-Ext.define('Ext.state.Stateful', {
-
- /* Begin Definitions */
-
- mixins: {
- observable: 'Ext.util.Observable'
- },
-
- requires: ['Ext.state.Manager'],
-
- /* End Definitions */
-
- /**
- * @cfg {Boolean} stateful
- * <p>A flag which causes the object to attempt to restore the state of
- * internal properties from a saved state on startup. The object must have
- * a <code>{@link #stateId}</code> for state to be managed.
- * Auto-generated ids are not guaranteed to be stable across page loads and
- * cannot be relied upon to save and restore the same state for a object.<p>
- * <p>For state saving to work, the state manager's provider must have been
- * set to an implementation of {@link Ext.state.Provider} which overrides the
- * {@link Ext.state.Provider#set set} and {@link Ext.state.Provider#get get}
- * methods to save and recall name/value pairs. A built-in implementation,
- * {@link Ext.state.CookieProvider} is available.</p>
- * <p>To set the state provider for the current page:</p>
- * <pre><code>
-Ext.state.Manager.setProvider(new Ext.state.CookieProvider({
- expires: new Date(new Date().getTime()+(1000*60*60*24*7)), //7 days from now
-}));
- * </code></pre>
- * <p>A stateful object attempts to save state when one of the events
- * listed in the <code>{@link #stateEvents}</code> configuration fires.</p>
- * <p>To save state, a stateful object first serializes its state by
- * calling <b><code>{@link #getState}</code></b>. By default, this function does
- * nothing. The developer must provide an implementation which returns an
- * object hash which represents the restorable state of the object.</p>
- * <p>The value yielded by getState is passed to {@link Ext.state.Manager#set}
- * which uses the configured {@link Ext.state.Provider} to save the object
- * keyed by the <code>{@link stateId}</code></p>.
- * <p>During construction, a stateful object attempts to <i>restore</i>
- * its state by calling {@link Ext.state.Manager#get} passing the
- * <code>{@link #stateId}</code></p>
- * <p>The resulting object is passed to <b><code>{@link #applyState}</code></b>.
- * The default implementation of <code>{@link #applyState}</code> simply copies
- * properties into the object, but a developer may override this to support
- * more behaviour.</p>
- * <p>You can perform extra processing on state save and restore by attaching
- * handlers to the {@link #beforestaterestore}, {@link #staterestore},
- * {@link #beforestatesave} and {@link #statesave} events.</p>
- */
- stateful: true,
-
- /**
- * @cfg {String} stateId
- * The unique id for this object to use for state management purposes.
- * <p>See {@link #stateful} for an explanation of saving and restoring state.</p>
- */
-
- /**
- * @cfg {Array} stateEvents
- * <p>An array of events that, when fired, should trigger this object to
- * save its state (defaults to none). <code>stateEvents</code> may be any type
- * of event supported by this object, including browser or custom events
- * (e.g., <tt>['click', 'customerchange']</tt>).</p>
- * <p>See <code>{@link #stateful}</code> for an explanation of saving and
- * restoring object state.</p>
- */
-
- /**
- * @cfg {Number} saveBuffer A buffer to be applied if many state events are fired within
- * a short period. Defaults to 100.
- */
- saveDelay: 100,
-
- autoGenIdRe: /^((\w+-)|(ext-comp-))\d{4,}$/i,
-
- constructor: function(config) {
- var me = this;
-
- config = config || {};
- if (Ext.isDefined(config.stateful)) {
- me.stateful = config.stateful;
- }
- if (Ext.isDefined(config.saveDelay)) {
- me.saveDelay = config.saveDelay;
- }
- me.stateId = config.stateId;
-
- if (!me.stateEvents) {
- me.stateEvents = [];
- }
- if (config.stateEvents) {
- me.stateEvents.concat(config.stateEvents);
- }
- this.addEvents(
- /**
- * @event beforestaterestore
- * Fires before the state of the object is restored. Return false from an event handler to stop the restore.
- * @param {Ext.state.Stateful} this
- * @param {Object} state The hash of state values returned from the StateProvider. If this
- * event is not vetoed, then the state object is passed to <b><tt>applyState</tt></b>. By default,
- * that simply copies property values into this object. The method maybe overriden to
- * provide custom state restoration.
- */
- 'beforestaterestore',
-
- /**
- * @event staterestore
- * Fires after the state of the object is restored.
- * @param {Ext.state.Stateful} this
- * @param {Object} state The hash of state values returned from the StateProvider. This is passed
- * to <b><tt>applyState</tt></b>. By default, that simply copies property values into this
- * object. The method maybe overriden to provide custom state restoration.
- */
- 'staterestore',
-
- /**
- * @event beforestatesave
- * Fires before the state of the object is saved to the configured state provider. Return false to stop the save.
- * @param {Ext.state.Stateful} this
- * @param {Object} state The hash of state values. This is determined by calling
- * <b><tt>getState()</tt></b> on the object. This method must be provided by the
- * developer to return whetever representation of state is required, by default, Ext.state.Stateful
- * has a null implementation.
- */
- 'beforestatesave',
-
- /**
- * @event statesave
- * Fires after the state of the object is saved to the configured state provider.
- * @param {Ext.state.Stateful} this
- * @param {Object} state The hash of state values. This is determined by calling
- * <b><tt>getState()</tt></b> on the object. This method must be provided by the
- * developer to return whetever representation of state is required, by default, Ext.state.Stateful
- * has a null implementation.
- */
- 'statesave'
- );
- me.mixins.observable.constructor.call(me);
- if (me.stateful !== false) {
- me.initStateEvents();
- me.initState();
- }
- },
-
- /**
- * Initializes any state events for this object.
- * @private
- */
- initStateEvents: function() {
- this.addStateEvents(this.stateEvents);
- },
-
- /**
- * Add events that will trigger the state to be saved.
- * @param {String/Array} events The event name or an array of event names.
- */
- addStateEvents: function(events){
- if (!Ext.isArray(events)) {
- events = [events];
- }
-
- var me = this,
- i = 0,
- len = events.length;
-
- for (; i < len; ++i) {
- me.on(events[i], me.onStateChange, me);
- }
- },
-
- /**
- * This method is called when any of the {@link #stateEvents} are fired.
- * @private
- */
- onStateChange: function(){
- var me = this,
- delay = me.saveDelay;
-
- if (delay > 0) {
- if (!me.stateTask) {
- me.stateTask = Ext.create('Ext.util.DelayedTask', me.saveState, me);
- }
- me.stateTask.delay(me.saveDelay);
- } else {
- me.saveState();
- }
- },
-
- /**
- * Saves the state of the object to the persistence store.
- * @private
- */
- saveState: function() {
- var me = this,
- id,
- state;
-
- if (me.stateful !== false) {
- id = me.getStateId();
- if (id) {
- state = me.getState();
- if (me.fireEvent('beforestatesave', me, state) !== false) {
- Ext.state.Manager.set(id, state);
- me.fireEvent('statesave', me, state);
- }
- }
- }
- },
-
- /**
- * Gets the current state of the object. By default this function returns null,
- * it should be overridden in subclasses to implement methods for getting the state.
- * @return {Object} The current state
- */
- getState: function(){
- return null;
- },
-
- /**
- * Applies the state to the object. This should be overridden in subclasses to do
- * more complex state operations. By default it applies the state properties onto
- * the current object.
- * @param {Object} state The state
- */
- applyState: function(state) {
- if (state) {
- Ext.apply(this, state);
- }
- },
-
- /**
- * Gets the state id for this object.
- * @return {String} The state id, null if not found.
- */
- getStateId: function() {
- var me = this,
- id = me.stateId;
-
- if (!id) {
- id = me.autoGenIdRe.test(String(me.id)) ? null : me.id;
- }
- return id;
- },
-
- /**
- * Initializes the state of the object upon construction.
- * @private
- */
- initState: function(){
- var me = this,
- id = me.getStateId(),
- state;
-
- if (me.stateful !== false) {
- if (id) {
- state = Ext.state.Manager.get(id);
- if (state) {
- state = Ext.apply({}, state);
- if (me.fireEvent('beforestaterestore', me, state) !== false) {
- me.applyState(state);
- me.fireEvent('staterestore', me, state);
- }
- }
- }
- }
- },
-
- /**
- * Destroys this stateful object.
- */
- destroy: function(){
- var task = this.stateTask;
- if (task) {
- task.cancel();
- }
- this.clearListeners();
-
- }
-
-});
-
-/**
- * @class Ext.AbstractManager
- * @extends Object
- * @ignore
- * Base Manager class
- */
-
-Ext.define('Ext.AbstractManager', {
-
- /* Begin Definitions */
-
- requires: ['Ext.util.HashMap'],
-
- /* End Definitions */
-
- typeName: 'type',
-
- constructor: function(config) {
- Ext.apply(this, config || {});
-
- /**
- * Contains all of the items currently managed
- * @property all
- * @type Ext.util.MixedCollection
- */
- this.all = Ext.create('Ext.util.HashMap');
-
- this.types = {};
- },
-
- /**
- * Returns an item by id.
- * For additional details see {@link Ext.util.HashMap#get}.
- * @param {String} id The id of the item
- * @return {Mixed} The item, <code>undefined</code> if not found.
- */
- get : function(id) {
- return this.all.get(id);
- },
-
- /**
- * Registers an item to be managed
- * @param {Mixed} item The item to register
- */
- register: function(item) {
- this.all.add(item);
- },
-
- /**
- * Unregisters an item by removing it from this manager
- * @param {Mixed} item The item to unregister
- */
- unregister: function(item) {
- this.all.remove(item);
- },
-
- /**
- * <p>Registers a new item constructor, keyed by a type key.
- * @param {String} type The mnemonic string by which the class may be looked up.
- * @param {Constructor} cls The new instance class.
- */
- registerType : function(type, cls) {
- this.types[type] = cls;
- cls[this.typeName] = type;
- },