Alien-Web-ExtJS-V3
view release on metacpan or search on metacpan
share/ext-all-debug-w-comments.js view on Meta::CPAN
*/
pluck : function(arr, prop){
var ret = [];
Ext.each(arr, function(v) {
ret.push( v[prop] );
});
return ret;
},
/**
* <p>Zips N sets together.</p>
* <pre><code>
// Example 1:
Ext.zip([1,2,3],[4,5,6]); // [[1,4],[2,5],[3,6]]
// Example 2:
Ext.zip(
[ "+", "-", "+"],
[ 12, 10, 22],
[ 43, 15, 96],
function(a, b, c){
return "$" + a + "" + b + "." + c
}
); // ["$+12.43", "$-10.15", "$+22.96"]
* </code></pre>
* @param {Arrays|NodeLists} arr This argument may be repeated. Array(s) to contribute values.
* @param {Function} zipper (optional) The last item in the argument list. This will drive how the items are zipped together.
* @return {Array} The zipped set.
*/
zip : function(){
var parts = Ext.partition(arguments, function( val ){ return typeof val != 'function'; }),
arrs = parts[0],
fn = parts[1][0],
len = Ext.max(Ext.pluck(arrs, "length")),
ret = [];
for (var i = 0; i < len; i++) {
ret[i] = [];
if(fn){
ret[i] = fn.apply(fn, Ext.pluck(arrs, i));
}else{
for (var j = 0, aLen = arrs.length; j < aLen; j++){
ret[i].push( arrs[j][i] );
}
}
}
return ret;
},
/**
* This is shorthand reference to {@link Ext.ComponentMgr#get}.
* Looks up an existing {@link Ext.Component Component} by {@link Ext.Component#id id}
* @param {String} id The component {@link Ext.Component#id id}
* @return Ext.Component The Component, <tt>undefined</tt> if not found, or <tt>null</tt> if a
* Class was found.
*/
getCmp : function(id){
return Ext.ComponentMgr.get(id);
},
/**
* By default, Ext intelligently decides whether floating elements should be shimmed. If you are using flash,
* you may want to set this to true.
* @type Boolean
*/
useShims: E.isIE6 || (E.isMac && E.isGecko2),
// inpired by a similar function in mootools library
/**
* Returns the type of object that is passed in. If the object passed in is null or undefined it
* return false otherwise it returns one of the following values:<div class="mdetail-params"><ul>
* <li><b>string</b>: If the object passed is a string</li>
* <li><b>number</b>: If the object passed is a number</li>
* <li><b>boolean</b>: If the object passed is a boolean value</li>
* <li><b>date</b>: If the object passed is a Date object</li>
* <li><b>function</b>: If the object passed is a function reference</li>
* <li><b>object</b>: If the object passed is an object</li>
* <li><b>array</b>: If the object passed is an array</li>
* <li><b>regexp</b>: If the object passed is a regular expression</li>
* <li><b>element</b>: If the object passed is a DOM Element</li>
* <li><b>nodelist</b>: If the object passed is a DOM NodeList</li>
* <li><b>textnode</b>: If the object passed is a DOM text node and contains something other than whitespace</li>
* <li><b>whitespace</b>: If the object passed is a DOM text node and contains only whitespace</li>
* </ul></div>
* @param {Mixed} object
* @return {String}
*/
type : function(o){
if(o === undefined || o === null){
return false;
}
if(o.htmlElement){
return 'element';
}
var t = typeof o;
if(t == 'object' && o.nodeName) {
switch(o.nodeType) {
case 1: return 'element';
case 3: return (/\S/).test(o.nodeValue) ? 'textnode' : 'whitespace';
}
}
if(t == 'object' || t == 'function') {
switch(o.constructor) {
case Array: return 'array';
case RegExp: return 'regexp';
case Date: return 'date';
}
if(typeof o.length == 'number' && typeof o.item == 'function') {
return 'nodelist';
}
}
return t;
},
intercept : function(o, name, fn, scope){
o[name] = o[name].createInterceptor(fn, scope);
},
// internal
callback : function(cb, scope, args, delay){
if(typeof cb == 'function'){
if(delay){
share/ext-all-debug-w-comments.js view on Meta::CPAN
* Date interval constant
* @static
* @type String
*/
MILLI : "ms",
/**
* Date interval constant
* @static
* @type String
*/
SECOND : "s",
/**
* Date interval constant
* @static
* @type String
*/
MINUTE : "mi",
/** Date interval constant
* @static
* @type String
*/
HOUR : "h",
/**
* Date interval constant
* @static
* @type String
*/
DAY : "d",
/**
* Date interval constant
* @static
* @type String
*/
MONTH : "mo",
/**
* Date interval constant
* @static
* @type String
*/
YEAR : "y",
/**
* <p>An object hash containing default date values used during date parsing.</p>
* <p>The following properties are available:<div class="mdetail-params"><ul>
* <li><code>y</code> : Number<div class="sub-desc">The default year value. (defaults to undefined)</div></li>
* <li><code>m</code> : Number<div class="sub-desc">The default 1-based month value. (defaults to undefined)</div></li>
* <li><code>d</code> : Number<div class="sub-desc">The default day value. (defaults to undefined)</div></li>
* <li><code>h</code> : Number<div class="sub-desc">The default hour value. (defaults to undefined)</div></li>
* <li><code>i</code> : Number<div class="sub-desc">The default minute value. (defaults to undefined)</div></li>
* <li><code>s</code> : Number<div class="sub-desc">The default second value. (defaults to undefined)</div></li>
* <li><code>ms</code> : Number<div class="sub-desc">The default millisecond value. (defaults to undefined)</div></li>
* </ul></div></p>
* <p>Override these properties to customize the default date values used by the {@link #parseDate} method.</p>
* <p><b>Note: In countries which experience Daylight Saving Time (i.e. DST), the <tt>h</tt>, <tt>i</tt>, <tt>s</tt>
* and <tt>ms</tt> properties may coincide with the exact time in which DST takes effect.
* It is the responsiblity of the developer to account for this.</b></p>
* Example Usage:
* <pre><code>
// set default day value to the first day of the month
Date.defaults.d = 1;
// parse a February date string containing only year and month values.
// setting the default day value to 1 prevents weird date rollover issues
// when attempting to parse the following date string on, for example, March 31st 2009.
Date.parseDate('2009-02', 'Y-m'); // returns a Date object representing February 1st 2009
</code></pre>
* @property defaults
* @static
* @type Object
*/
defaults: {},
/**
* An array of textual day names.
* Override these values for international dates.
* Example:
* <pre><code>
Date.dayNames = [
'SundayInYourLang',
'MondayInYourLang',
...
];
</code></pre>
* @type Array
* @static
*/
dayNames : [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
],
/**
* An array of textual month names.
* Override these values for international dates.
* Example:
* <pre><code>
Date.monthNames = [
'JanInYourLang',
'FebInYourLang',
...
];
</code></pre>
* @type Array
* @static
*/
monthNames : [
"January",
"February",
"March",
"April",
share/ext-all-debug-w-comments.js view on Meta::CPAN
<tpl <b>for</b>="foo.bar">...</tpl> // loop through array at foo.bar node
* </code></pre>
* Using the sample data above:
* <pre><code>
var tpl = new Ext.XTemplate(
'<p>Kids: ',
'<tpl <b>for</b>=".">', // process the data.kids node
'<p>{#}. {name}</p>', // use current array index to autonumber
'</tpl></p>'
);
tpl.overwrite(panel.body, data.kids); // pass the kids property of the data object
* </code></pre>
* <p>An example illustrating how the <b><tt>for</tt></b> property can be leveraged
* to access specified members of the provided data object to populate the template:</p>
* <pre><code>
var tpl = new Ext.XTemplate(
'<p>Name: {name}</p>',
'<p>Title: {title}</p>',
'<p>Company: {company}</p>',
'<p>Kids: ',
'<tpl <b>for="kids"</b>>', // interrogate the kids property within the data
'<p>{name}</p>',
'</tpl></p>'
);
tpl.overwrite(panel.body, data); // pass the root node of the data object
* </code></pre>
* <p>Flat arrays that contain values (and not objects) can be auto-rendered
* using the special <b><tt>{.}</tt></b> variable inside a loop. This variable
* will represent the value of the array at the current index:</p>
* <pre><code>
var tpl = new Ext.XTemplate(
'<p>{name}\'s favorite beverages:</p>',
'<tpl for="drinks">',
'<div> - {.}</div>',
'</tpl>'
);
tpl.overwrite(panel.body, data);
* </code></pre>
* <p>When processing a sub-template, for example while looping through a child array,
* you can access the parent object's members via the <b><tt>parent</tt></b> object:</p>
* <pre><code>
var tpl = new Ext.XTemplate(
'<p>Name: {name}</p>',
'<p>Kids: ',
'<tpl for="kids">',
'<tpl if="age > 1">',
'<p>{name}</p>',
'<p>Dad: {<b>parent</b>.name}</p>',
'</tpl>',
'</tpl></p>'
);
tpl.overwrite(panel.body, data);
* </code></pre>
* </div>
* </li>
*
*
* <li><b><u>Conditional processing with basic comparison operators</u></b>
* <div class="sub-desc">
* <p>The <b><tt>tpl</tt></b> tag and the <b><tt>if</tt></b> operator are used
* to provide conditional checks for deciding whether or not to render specific
* parts of the template. Notes:<div class="sub-desc"><ul>
* <li>Double quotes must be encoded if used within the conditional</li>
* <li>There is no <tt>else</tt> operator — if needed, two opposite
* <tt>if</tt> statements should be used.</li>
* </ul></div>
* <pre><code>
<tpl if="age > 1 && age < 10">Child</tpl>
<tpl if="age >= 10 && age < 18">Teenager</tpl>
<tpl <b>if</b>="this.isGirl(name)">...</tpl>
<tpl <b>if</b>="id==\'download\'">...</tpl>
<tpl <b>if</b>="needsIcon"><img src="{icon}" class="{iconCls}"/></tpl>
// no good:
<tpl if="name == "Jack"">Hello</tpl>
// encode " if it is part of the condition, e.g.
<tpl if="name == &quot;Jack&quot;">Hello</tpl>
* </code></pre>
* Using the sample data above:
* <pre><code>
var tpl = new Ext.XTemplate(
'<p>Name: {name}</p>',
'<p>Kids: ',
'<tpl for="kids">',
'<tpl if="age > 1">',
'<p>{name}</p>',
'</tpl>',
'</tpl></p>'
);
tpl.overwrite(panel.body, data);
* </code></pre>
* </div>
* </li>
*
*
* <li><b><u>Basic math support</u></b>
* <div class="sub-desc">
* <p>The following basic math operators may be applied directly on numeric
* data values:</p><pre>
* + - * /
* </pre>
* For example:
* <pre><code>
var tpl = new Ext.XTemplate(
'<p>Name: {name}</p>',
'<p>Kids: ',
'<tpl for="kids">',
'<tpl if="age &gt; 1">', // <-- Note that the > is encoded
'<p>{#}: {name}</p>', // <-- Auto-number each item
'<p>In 5 Years: {age+5}</p>', // <-- Basic math
'<p>Dad: {parent.name}</p>',
'</tpl>',
'</tpl></p>'
);
tpl.overwrite(panel.body, data);
</code></pre>
* </div>
* </li>
*
*
* <li><b><u>Execute arbitrary inline code with special built-in template variables</u></b>
* <div class="sub-desc">
share/ext-all-debug-w-comments.js view on Meta::CPAN
* the XY of this.dragData.ddel
* @param {EventObject} e The mouse up event
* @return {Array} The xy location (e.g. [100, 200])
*/
getRepairXY : function(e){
return Ext.Element.fly(this.dragData.ddel).getXY();
},
destroy : function(){
Ext.dd.DragZone.superclass.destroy.call(this);
if(this.containerScroll){
Ext.dd.ScrollManager.unregister(this.el);
}
}
});/**
* @class Ext.dd.DropZone
* @extends Ext.dd.DropTarget
* <p>This class provides a container DD instance that allows dropping on multiple child target nodes.</p>
* <p>By default, this class requires that child nodes accepting drop are registered with {@link Ext.dd.Registry}.
* However a simpler way to allow a DropZone to manage any number of target elements is to configure the
* DropZone with an implementation of {@link #getTargetFromEvent} which interrogates the passed
* mouse event to see if it has taken place within an element, or class of elements. This is easily done
* by using the event's {@link Ext.EventObject#getTarget getTarget} method to identify a node based on a
* {@link Ext.DomQuery} selector.</p>
* <p>Once the DropZone has detected through calling getTargetFromEvent, that the mouse is over
* a drop target, that target is passed as the first parameter to {@link #onNodeEnter}, {@link #onNodeOver},
* {@link #onNodeOut}, {@link #onNodeDrop}. You may configure the instance of DropZone with implementations
* of these methods to provide application-specific behaviour for these events to update both
* application state, and UI state.</p>
* <p>For example to make a GridPanel a cooperating target with the example illustrated in
* {@link Ext.dd.DragZone DragZone}, the following technique might be used:</p><pre><code>
myGridPanel.on('render', function() {
myGridPanel.dropZone = new Ext.dd.DropZone(myGridPanel.getView().scroller, {
// If the mouse is over a grid row, return that node. This is
// provided as the "target" parameter in all "onNodeXXXX" node event handling functions
getTargetFromEvent: function(e) {
return e.getTarget(myGridPanel.getView().rowSelector);
},
// On entry into a target node, highlight that node.
onNodeEnter : function(target, dd, e, data){
Ext.fly(target).addClass('my-row-highlight-class');
},
// On exit from a target node, unhighlight that node.
onNodeOut : function(target, dd, e, data){
Ext.fly(target).removeClass('my-row-highlight-class');
},
// While over a target node, return the default drop allowed class which
// places a "tick" icon into the drag proxy.
onNodeOver : function(target, dd, e, data){
return Ext.dd.DropZone.prototype.dropAllowed;
},
// On node drop we can interrogate the target to find the underlying
// application object that is the real target of the dragged data.
// In this case, it is a Record in the GridPanel's Store.
// We can use the data set up by the DragZone's getDragData method to read
// any data we decided to attach in the DragZone's getDragData method.
onNodeDrop : function(target, dd, e, data){
var rowIndex = myGridPanel.getView().findRowIndex(target);
var r = myGridPanel.getStore().getAt(rowIndex);
Ext.Msg.alert('Drop gesture', 'Dropped Record id ' + data.draggedRecord.id +
' on Record id ' + r.id);
return true;
}
});
}
</code></pre>
* See the {@link Ext.dd.DragZone DragZone} documentation for details about building a DragZone which
* cooperates with this DropZone.
* @constructor
* @param {Mixed} el The container element
* @param {Object} config
*/
Ext.dd.DropZone = function(el, config){
Ext.dd.DropZone.superclass.constructor.call(this, el, config);
};
Ext.extend(Ext.dd.DropZone, Ext.dd.DropTarget, {
/**
* Returns a custom data object associated with the DOM node that is the target of the event. By default
* this looks up the event target in the {@link Ext.dd.Registry}, although you can override this method to
* provide your own custom lookup.
* @param {Event} e The event
* @return {Object} data The custom data
*/
getTargetFromEvent : function(e){
return Ext.dd.Registry.getTargetFromEvent(e);
},
/**
* Called when the DropZone determines that a {@link Ext.dd.DragSource} has entered a drop node
* that has either been registered or detected by a configured implementation of {@link #getTargetFromEvent}.
* This method has no default implementation and should be overridden to provide
* node-specific processing if necessary.
* @param {Object} nodeData The custom data associated with the drop node (this is the same value returned from
* {@link #getTargetFromEvent} for this node)
* @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone
* @param {Event} e The event
* @param {Object} data An object containing arbitrary data supplied by the drag source
*/
onNodeEnter : function(n, dd, e, data){
},
/**
* Called while the DropZone determines that a {@link Ext.dd.DragSource} is over a drop node
* that has either been registered or detected by a configured implementation of {@link #getTargetFromEvent}.
* The default implementation returns this.dropNotAllowed, so it should be
* overridden to provide the proper feedback.
* @param {Object} nodeData The custom data associated with the drop node (this is the same value returned from
* {@link #getTargetFromEvent} for this node)
* @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone
* @param {Event} e The event
* @param {Object} data An object containing arbitrary data supplied by the drag source
* @return {String} status The CSS class that communicates the drop status back to the source so that the
* underlying {@link Ext.dd.StatusProxy} can be updated
*/
share/ext-all-debug-w-comments.js view on Meta::CPAN
destroy : 'DELETE'
},
* </code></pre>
*/
restActions : {
create : 'POST',
read : 'GET',
update : 'PUT',
destroy : 'DELETE'
},
/**
* Returns true if supplied action-name is a valid API action defined in <code>{@link #actions}</code> constants
* @param {String} action Action to test for availability.
* @return {Boolean}
*/
isAction : function(action) {
return (Ext.data.Api.actions[action]) ? true : false;
},
/**
* Returns the actual CRUD action KEY "create", "read", "update" or "destroy" from the supplied action-name. This method is used internally and shouldn't generally
* need to be used directly. The key/value pair of Ext.data.Api.actions will often be identical but this is not necessarily true. A developer can override this naming
* convention if desired. However, the framework internally calls methods based upon the KEY so a way of retreiving the the words "create", "read", "update" and "destroy" is
* required. This method will cache discovered KEYS into the private validActions hash.
* @param {String} name The runtime name of the action.
* @return {String/null} returns the action-key, or verb of the user-action or null if invalid.
* @nodoc
*/
getVerb : function(name) {
if (validActions[name]) {
return validActions[name]; // <-- found in cache. return immediately.
}
for (var verb in this.actions) {
if (this.actions[verb] === name) {
validActions[name] = verb;
break;
}
}
return (validActions[name] !== undefined) ? validActions[name] : null;
},
/**
* Returns true if the supplied API is valid; that is, check that all keys match defined actions
* otherwise returns an array of mistakes.
* @return {String[]|true}
*/
isValid : function(api){
var invalid = [];
var crud = this.actions; // <-- cache a copy of the actions.
for (var action in api) {
if (!(action in crud)) {
invalid.push(action);
}
}
return (!invalid.length) ? true : invalid;
},
/**
* Returns true if the supplied verb upon the supplied proxy points to a unique url in that none of the other api-actions
* point to the same url. The question is important for deciding whether to insert the "xaction" HTTP parameter within an
* Ajax request. This method is used internally and shouldn't generally need to be called directly.
* @param {Ext.data.DataProxy} proxy
* @param {String} verb
* @return {Boolean}
*/
hasUniqueUrl : function(proxy, verb) {
var url = (proxy.api[verb]) ? proxy.api[verb].url : null;
var unique = true;
for (var action in proxy.api) {
if ((unique = (action === verb) ? true : (proxy.api[action].url != url) ? true : false) === false) {
break;
}
}
return unique;
},
/**
* This method is used internally by <tt>{@link Ext.data.DataProxy DataProxy}</tt> and should not generally need to be used directly.
* Each action of a DataProxy api can be initially defined as either a String or an Object. When specified as an object,
* one can explicitly define the HTTP method (GET|POST) to use for each CRUD action. This method will prepare the supplied API, setting
* each action to the Object form. If your API-actions do not explicitly define the HTTP method, the "method" configuration-parameter will
* be used. If the method configuration parameter is not specified, POST will be used.
<pre><code>
new Ext.data.HttpProxy({
method: "POST", // <-- default HTTP method when not specified.
api: {
create: 'create.php',
load: 'read.php',
save: 'save.php',
destroy: 'destroy.php'
}
});
// Alternatively, one can use the object-form to specify the API
new Ext.data.HttpProxy({
api: {
load: {url: 'read.php', method: 'GET'},
create: 'create.php',
destroy: 'destroy.php',
save: 'update.php'
}
});
</code></pre>
*
* @param {Ext.data.DataProxy} proxy
*/
prepare : function(proxy) {
if (!proxy.api) {
proxy.api = {}; // <-- No api? create a blank one.
}
for (var verb in this.actions) {
var action = this.actions[verb];
proxy.api[action] = proxy.api[action] || proxy.url || proxy.directFn;
if (typeof(proxy.api[action]) == 'string') {
proxy.api[action] = {
url: proxy.api[action],
method: (proxy.restful === true) ? Ext.data.Api.restActions[action] : undefined
};
}
}
share/ext-all-debug-w-comments.js view on Meta::CPAN
} else {
this.modified.splice(this.modified.indexOf(rs), 1);
}
},
// remap record ids in MixedCollection after records have been realized. @see Store#onCreateRecords, @see DataReader#realize
reMap : function(record) {
if (Ext.isArray(record)) {
for (var i = 0, len = record.length; i < len; i++) {
this.reMap(record[i]);
}
} else {
delete this.data.map[record._phid];
this.data.map[record.id] = record;
var index = this.data.keys.indexOf(record._phid);
this.data.keys.splice(index, 1, record.id);
delete record._phid;
}
},
// @protected onCreateRecord proxy callback for create action
onCreateRecords : function(success, rs, data) {
if (success === true) {
try {
this.reader.realize(rs, data);
}
catch (e) {
this.handleException(e);
if (Ext.isArray(rs)) {
// Recurse to run back into the try {}. DataReader#realize splices-off the rs until empty.
this.onCreateRecords(success, rs, data);
}
}
}
},
// @protected, onUpdateRecords proxy callback for update action
onUpdateRecords : function(success, rs, data) {
if (success === true) {
try {
this.reader.update(rs, data);
} catch (e) {
this.handleException(e);
if (Ext.isArray(rs)) {
// Recurse to run back into the try {}. DataReader#update splices-off the rs until empty.
this.onUpdateRecords(success, rs, data);
}
}
}
},
// @protected onDestroyRecords proxy callback for destroy action
onDestroyRecords : function(success, rs, data) {
// splice each rec out of this.removed
rs = (rs instanceof Ext.data.Record) ? [rs] : [].concat(rs);
for (var i=0,len=rs.length;i<len;i++) {
this.removed.splice(this.removed.indexOf(rs[i]), 1);
}
if (success === false) {
// put records back into store if remote destroy fails.
// @TODO: Might want to let developer decide.
for (i=rs.length-1;i>=0;i--) {
this.insert(rs[i].lastIndex, rs[i]); // <-- lastIndex set in Store#destroyRecord
}
}
},
// protected handleException. Possibly temporary until Ext framework has an exception-handler.
handleException : function(e) {
// @see core/Error.js
Ext.handleError(e);
},
/**
* <p>Reloads the Record cache from the configured Proxy using the configured
* {@link Ext.data.Reader Reader} and the options from the last load operation
* performed.</p>
* <p><b>Note</b>: see the Important note in {@link #load}.</p>
* @param {Object} options <p>(optional) An <tt>Object</tt> containing
* {@link #load loading options} which may override the {@link #lastOptions options}
* used in the last {@link #load} operation. See {@link #load} for details
* (defaults to <tt>null</tt>, in which case the {@link #lastOptions} are
* used).</p>
* <br><p>To add new params to the existing params:</p><pre><code>
lastOptions = myStore.lastOptions;
Ext.apply(lastOptions.params, {
myNewParam: true
});
myStore.reload(lastOptions);
* </code></pre>
*/
reload : function(options){
this.load(Ext.applyIf(options||{}, this.lastOptions));
},
// private
// Called as a callback by the Reader during a load operation.
loadRecords : function(o, options, success){
var i, len;
if (this.isDestroyed === true) {
return;
}
if(!o || success === false){
if(success !== false){
this.fireEvent('load', this, [], options);
}
if(options.callback){
options.callback.call(options.scope || this, [], options, false, o);
}
return;
}
var r = o.records, t = o.totalRecords || r.length;
if(!options || options.add !== true){
if(this.pruneModifiedRecords){
this.modified = [];
}
for(i = 0, len = r.length; i < len; i++){
r[i].join(this);
}
if(this.snapshot){
( run in 0.537 second using v1.01-cache-2.11-cpan-119454b85a5 )